Skip to contentSkip to conversation

ext4: fix fencepost error in lazytime optimization

PATCH In review Theodore Ts'o 2 participants 2 messages Jul 2, 2015 – Jul 3, 2015

Subsystems (2)
lore
Share & tools
lore

Theodore Ts'o

author maintainer
#0 lore raw

PATCH 1/1 ext4: fix fencepost error in lazytime optimization

Commit 8f4d8558391: "ext4: fix lazytime optimization" was not a complete fix. In the case where the inode number is a multiple of 16, and we could still end up updating an inode with dirty timestamps written to the wrong inode on disk. Oops.

This can be easily reproduced by using generic/005 with a file system with metadata_csum and lazytime enabled.

---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
index e057c6f..0b4dd57 100644
@@ -4348,7 +4348,7 @@ static void ext4_update_other_inodes_time(struct super_block *sb,
 	int inode_size = EXT4_INODE_SIZE(sb);
 
 	oi.orig_ino = orig_ino;
-	ino = (orig_ino & ~(inodes_per_block - 1)) + 1;
+	ino = ((orig_ino - 1) & ~(inodes_per_block - 1)) + 1;
 	for (i = 0; i < inodes_per_block; i++, ino++, buf += inode_size) {
 		if (ino == orig_ino)
 			continue;
Signature · 1 line
2.3.0
#1 lore raw

Theodore Ts'o wrote on 07/02/2015 05:38:

Quoted 5 lines

Commit 8f4d8558391: "ext4: fix lazytime optimization" was not a complete fix. In the case where the inode number is a multiple of 16, and we could still end up updating an inode with dirty timestamps written to the wrong inode on disk. Oops.

<snip>

fs/ext4/inode.c static void ext4_update_other_inodes_time(struct super_block *sb, · line 4351

Quoted 2 lines
fs/ext4/inode.c +1 -1
-	ino = (orig_ino & ~(inodes_per_block - 1)) + 1;
+	ino = ((orig_ino - 1) & ~(inodes_per_block - 1)) + 1;

Maybe, a comment stating what should be accomplished here would help?

Signature · 8 lines
Regards,
Jörg.


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html