Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gfs2: Fix an incorrect gfs2_assert()

When updating the inode information after a change in allocation,
convert the change into the same units as the inode's i_blocks count
before comparing it in an assertion.

Also, change the comparison so that it is still possible to set i_blocks
to zero by adding -i_blocks, something that was previously only possible
because of the difference in units.

Signed-off-by: Tim Smith <tim.smith@citrix.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>

authored by

Tim Smith and committed by
Bob Peterson
7c03e756 2abbf9a4

+2 -2
+2 -2
fs/gfs2/inode.h
··· 59 59 60 60 static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change) 61 61 { 62 - gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks > -change)); 63 - change *= (GFS2_SB(inode)->sd_sb.sb_bsize/GFS2_BASIC_BLOCK); 62 + change <<= inode->i_blkbits - GFS2_BASIC_BLOCK_SHIFT; 63 + gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change)); 64 64 inode->i_blocks += change; 65 65 } 66 66