lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230503143135.qusbbl5dmlcnmnce@quack3>
Date:   Wed, 3 May 2023 16:31:35 +0200
From:   Jan Kara <jack@...e.cz>
To:     Baokun Li <libaokun1@...wei.com>
Cc:     linux-ext4@...r.kernel.org, tytso@....edu,
        adilger.kernel@...ger.ca, jack@...e.cz, ritesh.list@...il.com,
        linux-kernel@...r.kernel.org, yi.zhang@...wei.com,
        yangerkun@...wei.com, yukuai3@...wei.com
Subject: Re: [PATCH v4 07/12] ext4: using nofail preallocation in
 ext4_es_insert_delayed_block()

On Mon 24-04-23 11:38:41, Baokun Li wrote:
> Similar to in ext4_es_remove_extent(), we use a no-fail preallocation
> to avoid inconsistencies, except that here we may have to preallocate
> two extent_status.
> 
> Suggested-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Baokun Li <libaokun1@...wei.com>

Looks good to me. Feel free to add:

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

								Honza

> ---
>  fs/ext4/extents_status.c | 33 ++++++++++++++++++++++-----------
>  1 file changed, 22 insertions(+), 11 deletions(-)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index f4d50cd501fc..f892277155fa 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -2013,7 +2013,10 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
>  				 bool allocated)
>  {
>  	struct extent_status newes;
> -	int err = 0;
> +	int err1 = 0;
> +	int err2 = 0;
> +	struct extent_status *es1 = NULL;
> +	struct extent_status *es2 = NULL;
>  
>  	if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
>  		return 0;
> @@ -2028,29 +2031,37 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
>  
>  	ext4_es_insert_extent_check(inode, &newes);
>  
> +retry:
> +	if (err1 && !es1)
> +		es1 = __es_alloc_extent(true);
> +	if ((err1 || err2) && !es2)
> +		es2 = __es_alloc_extent(true);
>  	write_lock(&EXT4_I(inode)->i_es_lock);
>  
> -	err = __es_remove_extent(inode, lblk, lblk, NULL, NULL);
> -	if (err != 0)
> +	err1 = __es_remove_extent(inode, lblk, lblk, NULL, es1);
> +	if (err1 != 0)
>  		goto error;
> -retry:
> -	err = __es_insert_extent(inode, &newes, NULL);
> -	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode->i_sb),
> -					  128, EXT4_I(inode)))
> -		goto retry;
> -	if (err != 0)
> +
> +	err2 = __es_insert_extent(inode, &newes, es2);
> +	if (err2 != 0)
>  		goto error;
>  
>  	if (allocated)
>  		__insert_pending(inode, lblk);
>  
> +	/* es is pre-allocated but not used, free it. */
> +	if (es1 && !es1->es_len)
> +		__es_free_extent(es1);
> +	if (es2 && !es2->es_len)
> +		__es_free_extent(es2);
>  error:
>  	write_unlock(&EXT4_I(inode)->i_es_lock);
> +	if (err1 || err2)
> +		goto retry;
>  
>  	ext4_es_print_tree(inode);
>  	ext4_print_pending_tree(inode);
> -
> -	return err;
> +	return 0;
>  }
>  
>  /*
> -- 
> 2.31.1
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ