fs: sysv: Fix sysv_nblocks() returns wrong value
authorChen Zhongjin <chenzhongjin@huawei.com>
Fri, 9 Dec 2022 10:04:48 +0000 (18:04 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:15 +0000 (12:07 +0100)
[ Upstream commit e0c49bd2b4d3cd1751491eb2d940bce968ac65e9 ]

sysv_nblocks() returns 'blocks' rather than 'res', which only counting
the number of triple-indirect blocks and causing sysv_getattr() gets a
wrong result.

[AV: this is actually a sysv counterpart of minixfs fix -
0fcd426de9d0 "[PATCH] minix block usage counting fix" in
historical tree; mea culpa, should've thought to check
fs/sysv back then...]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/sysv/itree.c

index 08d3e630b49c8691fe24e9ce8d7294c370a7d067..f5b0837511cf1e2dc3ef5e9c141ffd13aa277d93 100644 (file)
@@ -437,7 +437,7 @@ static unsigned sysv_nblocks(struct super_block *s, loff_t size)
                res += blocks;
                direct = 1;
        }
-       return blocks;
+       return res;
 }
 
 int sysv_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)