All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jörg-Volker Peetz" <jvpeetz@web.de>
To: linux-ext4@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: Re: [PATCH -v2] ext4: fix fencepost error in lazytime optimization
Date: Sun, 05 Jul 2015 12:04:59 +0200	[thread overview]
Message-ID: <5599014B.5050309@web.de> (raw)
In-Reply-To: <1436064066-22403-1-git-send-email-tytso@mit.edu>

Hi,

Theodore Ts'o wrote on 07/05/2015 04:41:
> 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 | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index e057c6f..4ad73d3 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4348,7 +4348,12 @@ 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;
> +	/*
> +	 * Calculate the first inode in the inode table block.  Inode
> +	 * numbers are one-based.  That is, the first inode in a block
> +	 * (assuming 4k blocks and 256 byte inodes) is (n*16 + 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;
> 
thank you very much for the explanation. Now I think I understand:

/*
 * Calculate the first inode in the original inode's inode table
 * block. Inode numbers are one-based. That is, the first inode
 * in a block is one plus the next-lowest to (orig_ino - 1)
 * integral multiple of inodes_per_block. This can be calculated
 * efficiently by bit masking since inodes_per_block is a power
 * of 2 (assuming 4k blocks and 256 byte inodes).
*/

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

WARNING: multiple messages have this Message-ID (diff)
From: "Jörg-Volker Peetz" <jvpeetz@web.de>
To: Theodore Ts'o <tytso@mit.edu>,
	Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH -v2] ext4: fix fencepost error in lazytime optimization
Date: Sun, 05 Jul 2015 12:04:59 +0200	[thread overview]
Message-ID: <5599014B.5050309@web.de> (raw)
In-Reply-To: <1436064066-22403-1-git-send-email-tytso@mit.edu>

Hi,

Theodore Ts'o wrote on 07/05/2015 04:41:
> 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 | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index e057c6f..4ad73d3 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4348,7 +4348,12 @@ 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;
> +	/*
> +	 * Calculate the first inode in the inode table block.  Inode
> +	 * numbers are one-based.  That is, the first inode in a block
> +	 * (assuming 4k blocks and 256 byte inodes) is (n*16 + 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;
> 
thank you very much for the explanation. Now I think I understand:

/*
 * Calculate the first inode in the original inode's inode table
 * block. Inode numbers are one-based. That is, the first inode
 * in a block is one plus the next-lowest to (orig_ino - 1)
 * integral multiple of inodes_per_block. This can be calculated
 * efficiently by bit masking since inodes_per_block is a power
 * of 2 (assuming 4k blocks and 256 byte inodes).
*/

Regards,
J�rg.


  reply	other threads:[~2015-07-05 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mn5vitbh@ger.gmane.org>
2015-07-05  2:41 ` [PATCH -v2] ext4: fix fencepost error in lazytime optimization Theodore Ts'o
2015-07-05 10:04   ` Jörg-Volker Peetz [this message]
2015-07-05 10:04     ` Jörg-Volker Peetz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5599014B.5050309@web.de \
    --to=jvpeetz@web.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.