From: Sankar P Subject: novfs: novfs reports incorrect file size Patch-mainline: no References: bnc#426536 While updating the inode, make sure that the s_blocks member is updated to the number of 512 blocks units. This fixes the issue of novfs reporting invalid file sizes. Signed-off-by: Sankar P Acked-by: Jan Kara --- fs/novfs/inode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/fs/novfs/inode.c +++ b/fs/novfs/inode.c @@ -2671,8 +2671,17 @@ void update_inode(struct inode *Inode, s Inode->i_mtime = Info->mtime; if (Inode->i_size && Inode->i_sb->s_blocksize) { - Inode->i_blocks = - (unsigned long) (Info->size >> (loff_t) Inode->i_blkbits); + + /* + * Filling number of blocks as in NSS filesystem. + * The s_blocksize is initialized to PAGE_CACHE_SIZE in + * the super block initialization. + * + * Update i_blocks to have the number of 512 blocks + */ + Inode->i_blocks = (((loff_t)Info->size) + Inode->i_sb->s_blocksize - 1) + >> (loff_t)Inode->i_blkbits; + Inode->i_blocks = Inode->i_blocks << (PAGE_CACHE_SHIFT - 9); Inode->i_bytes = Info->size & (Inode->i_sb->s_blocksize - 1); DbgPrint("i_sb->s_blocksize=%d", Inode->i_sb->s_blocksize);