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: <20230503142838.d4ijsruotb5l2xnp@quack3>
Date:   Wed, 3 May 2023 16:28:38 +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 04/12] ext4: use pre-allocated es in
 __es_insert_extent()

On Mon 24-04-23 11:38:38, Baokun Li wrote:
> Pass a extent_status pointer prealloc to __es_insert_extent(). If the
> pointer is non-null, it is used directly when a new extent_status is
> needed to avoid memory allocation failures.
> 
> Suggested-by: Jan Kara <jack@...e.cz>
> Signed-off-by: Baokun Li <libaokun1@...wei.com>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/ext4/extents_status.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 18665394392f..a6a62a744e83 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -144,7 +144,8 @@
>  static struct kmem_cache *ext4_es_cachep;
>  static struct kmem_cache *ext4_pending_cachep;
>  
> -static int __es_insert_extent(struct inode *inode, struct extent_status *newes);
> +static int __es_insert_extent(struct inode *inode, struct extent_status *newes,
> +			      struct extent_status *prealloc);
>  static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
>  			      ext4_lblk_t end, int *reserved);
>  static int es_reclaim_extents(struct ext4_inode_info *ei, int *nr_to_scan);
> @@ -768,7 +769,8 @@ static inline void ext4_es_insert_extent_check(struct inode *inode,
>  }
>  #endif
>  
> -static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
> +static int __es_insert_extent(struct inode *inode, struct extent_status *newes,
> +			      struct extent_status *prealloc)
>  {
>  	struct ext4_es_tree *tree = &EXT4_I(inode)->i_es_tree;
>  	struct rb_node **p = &tree->root.rb_node;
> @@ -808,7 +810,10 @@ static int __es_insert_extent(struct inode *inode, struct extent_status *newes)
>  		}
>  	}
>  
> -	es = __es_alloc_extent(false);
> +	if (prealloc)
> +		es = prealloc;
> +	else
> +		es = __es_alloc_extent(false);
>  	if (!es)
>  		return -ENOMEM;
>  	ext4_es_init_extent(inode, es, newes->es_lblk, newes->es_len,
> @@ -868,7 +873,7 @@ int ext4_es_insert_extent(struct inode *inode, ext4_lblk_t lblk,
>  	if (err != 0)
>  		goto error;
>  retry:
> -	err = __es_insert_extent(inode, &newes);
> +	err = __es_insert_extent(inode, &newes, NULL);
>  	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode->i_sb),
>  					  128, EXT4_I(inode)))
>  		goto retry;
> @@ -918,7 +923,7 @@ void ext4_es_cache_extent(struct inode *inode, ext4_lblk_t lblk,
>  
>  	es = __es_tree_search(&EXT4_I(inode)->i_es_tree.root, lblk);
>  	if (!es || es->es_lblk > end)
> -		__es_insert_extent(inode, &newes);
> +		__es_insert_extent(inode, &newes, NULL);
>  	write_unlock(&EXT4_I(inode)->i_es_lock);
>  }
>  
> @@ -1366,7 +1371,7 @@ static int __es_remove_extent(struct inode *inode, ext4_lblk_t lblk,
>  					orig_es.es_len - len2;
>  			ext4_es_store_pblock_status(&newes, block,
>  						    ext4_es_status(&orig_es));
> -			err = __es_insert_extent(inode, &newes);
> +			err = __es_insert_extent(inode, &newes, NULL);
>  			if (err) {
>  				es->es_lblk = orig_es.es_lblk;
>  				es->es_len = orig_es.es_len;
> @@ -2020,7 +2025,7 @@ int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
>  	if (err != 0)
>  		goto error;
>  retry:
> -	err = __es_insert_extent(inode, &newes);
> +	err = __es_insert_extent(inode, &newes, NULL);
>  	if (err == -ENOMEM && __es_shrink(EXT4_SB(inode->i_sb),
>  					  128, EXT4_I(inode)))
>  		goto retry;
> -- 
> 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