1 ext4: fix fencepost error in lazytime optimization
3 Commit 8f4d8558391: "ext4: fix lazytime optimization" was not a
4 complete fix. In the case where the inode number is a multiple of 16,
5 and we could still end up updating an inode with dirty timestamps
6 written to the wrong inode on disk. Oops.
8 This can be easily reproduced by using generic/005 with a file system
9 with metadata_csum and lazytime enabled.
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
12 Cc: stable@vger.kernel.org
14 fs/ext4/inode.c | 7 ++++++-
15 1 file changed, 6 insertions(+), 1 deletion(-)
17 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
18 index e057c6f..4ad73d3 100644
21 @@ -4348,7 +4348,12 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
22 int inode_size = EXT4_INODE_SIZE(sb);
24 oi.orig_ino = orig_ino;
25 - ino = (orig_ino & ~(inodes_per_block - 1)) + 1;
27 + * Calculate the first inode in the inode table block. Inode
28 + * numbers are one-based. That is, the first inode in a block
29 + * (assuming 4k blocks and 256 byte inodes) is (n*16 + 1).
31 + ino = ((orig_ino - 1) & ~(inodes_per_block - 1)) + 1;
32 for (i = 0; i < inodes_per_block; i++, ino++, buf += inode_size) {