linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: fix fencepost error in lazytime optimization
@ 2015-07-02  3:38 Theodore Ts'o
  2015-07-03 12:35 ` Jörg-Volker Peetz
  0 siblings, 1 reply; 2+ messages in thread
From: Theodore Ts'o @ 2015-07-02  3:38 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o, stable

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.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index e057c6f..0b4dd57 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -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;
-- 
2.3.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ext4: fix fencepost error in lazytime optimization
  2015-07-02  3:38 [PATCH] ext4: fix fencepost error in lazytime optimization Theodore Ts'o
@ 2015-07-03 12:35 ` Jörg-Volker Peetz
  0 siblings, 0 replies; 2+ messages in thread
From: Jörg-Volker Peetz @ 2015-07-03 12:35 UTC (permalink / raw)
  To: linux-ext4

Theodore Ts'o wrote on 07/02/2015 05:38:
> 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>
> -	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?
-- 
Regards,
Jörg.


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-07-03 12:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-02  3:38 [PATCH] ext4: fix fencepost error in lazytime optimization Theodore Ts'o
2015-07-03 12:35 ` Jörg-Volker Peetz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).