All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca,
	Denis Lukianov <denis@voxelsoft.com>
Subject: Re: [PATCH] ext4: fix directory index node split corruption
Date: Wed, 4 Aug 2021 17:15:35 +0200	[thread overview]
Message-ID: <20210804151535.GG4578@quack2.suse.cz> (raw)
In-Reply-To: <20210730182403.3254365-1-artem.blagodarenko@gmail.com>

On Fri 30-07-21 14:24:03, Artem Blagodarenko wrote:
> I send patch whose author is Denis Lukianov <denis@voxelsoft.com>
> His messages can't reach this list somehow.
> I only rebased it ontop of master's HEAD and tested that it fixes
> the problem and reviewed.
> 
> ----
> 
> Following commit b5776e7, a trivial sequential write of empty files to
> an empty ext4 file system (with large_dir enabled) fails after just
> over 26 million files. Depending on luck, file creation will give error
> EEXIST or EUCLEAN.
> 
> Commit b5776e7 fixed the no-restart condition so that
> ext4_handle_dirty_dx_node is always called, but it also broke the
> restart condition. This is because when restart=1, the original
> implementation correctly skipped do_split() but b5776e7 clobbered the
> "if(restart)goto journal_error;" logic.
> 
> This complementary change protects do_split() from restart condition,
> making it safe from both current and future ordering of goto statements
> in earlier sections of the code.
> 
> Tested on 5.11.20 with handy testing script:
> 
> i = 0
> while i <= 32000000:
>     print (i)
>     with open('tmpmnt/%d' % i, 'wb') as fout:
>         i += 1
> 
> Google-Bug-Id: 176345532
> Fixes: b5776e7 ("ext4: fix potential htree index checksum corruption")

Please use 12 characters from git commit when identifying it (7 characters 
is likely to become non-unique). Otherwise the fix looks good so feel free
to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Also I think you should include Ted in 'To' or 'CC' to make it more likely
he sees the patch.

								Honza


> Signed-off-by: Denis Lukianov <denis@voxelsoft.com>
> Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
> ---
>  fs/ext4/namei.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 5fd56f616cf0..0bbff03d4167 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2542,13 +2542,16 @@ static int ext4_dx_add_entry(handle_t *handle, struct ext4_filename *fname,
>  			goto journal_error;
>  		}
>  	}
> -	de = do_split(handle, dir, &bh, frame, &fname->hinfo);
> -	if (IS_ERR(de)) {
> -		err = PTR_ERR(de);
> +	if (!restart) {
> +		de = do_split(handle, dir, &bh, frame, &fname->hinfo);
> +		if (IS_ERR(de)) {
> +			err = PTR_ERR(de);
> +			goto cleanup;
> +		}
> +		err = add_dirent_to_buf(handle, fname, dir, inode, de,
> +bh);
>  		goto cleanup;
>  	}
> -	err = add_dirent_to_buf(handle, fname, dir, inode, de, bh);
> -	goto cleanup;
>  
>  journal_error:
>  	ext4_std_error(dir->i_sb, err); /* this is a no-op if err == 0 */
> -- 
> 2.18.4
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2021-08-04 15:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-30 18:24 [PATCH] ext4: fix directory index node split corruption Artem Blagodarenko
2021-08-04 15:15 ` Jan Kara [this message]

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=20210804151535.GG4578@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=artem.blagodarenko@gmail.com \
    --cc=denis@voxelsoft.com \
    --cc=linux-ext4@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.