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: <7e5c2elo5gwxnolzjbukwwka7zdvdwdsl54utqs75nefvxpwrn@ffnsmj7m62ty>
Date: Mon, 6 Jan 2025 16:40:33 +0100
From: Jan Kara <jack@...e.cz>
To: Julian Sun <sunjunchao2870@...il.com>
Cc: linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org, 
	tytso@....edu, adilger.kernel@...ger.ca, jack@...e.cz, boyu.mt@...bao.com, 
	tm@....ma
Subject: Re: [PATCH 6/7] ext4: Refactor out ext4_try_to_write_inline_data()

On Fri 20-12-24 23:16:24, Julian Sun wrote:
> Refactor ext4_try_to_write_inline_data() to simplify its
> implementation by directly invoking ext4_generic_write_inline_data().
> 
> Signed-off-by: Julian Sun <sunjunchao2870@...il.com>

Looks good. Feel free to add:

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

								Honza

> ---
>  fs/ext4/inline.c | 77 ++----------------------------------------------
>  1 file changed, 3 insertions(+), 74 deletions(-)
> 
> diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
> index 5dd91524b2ca..2abb35f1555d 100644
> --- a/fs/ext4/inline.c
> +++ b/fs/ext4/inline.c
> @@ -747,81 +747,10 @@ int ext4_try_to_write_inline_data(struct address_space *mapping,
>  				  loff_t pos, unsigned len,
>  				  struct folio **foliop)
>  {
> -	int ret;
> -	handle_t *handle;
> -	struct folio *folio;
> -	struct ext4_iloc iloc;
> -
>  	if (pos + len > ext4_get_max_inline_size(inode))
> -		goto convert;
> -
> -	ret = ext4_get_inode_loc(inode, &iloc);
> -	if (ret)
> -		return ret;
> -
> -	/*
> -	 * The possible write could happen in the inode,
> -	 * so try to reserve the space in inode first.
> -	 */
> -	handle = ext4_journal_start(inode, EXT4_HT_INODE, 1);
> -	if (IS_ERR(handle)) {
> -		ret = PTR_ERR(handle);
> -		handle = NULL;
> -		goto out;
> -	}
> -
> -	ret = ext4_prepare_inline_data(handle, inode, pos + len);
> -	if (ret && ret != -ENOSPC)
> -		goto out;
> -
> -	/* We don't have space in inline inode, so convert it to extent. */
> -	if (ret == -ENOSPC) {
> -		ext4_journal_stop(handle);
> -		brelse(iloc.bh);
> -		goto convert;
> -	}
> -
> -	ret = ext4_journal_get_write_access(handle, inode->i_sb, iloc.bh,
> -					    EXT4_JTR_NONE);
> -	if (ret)
> -		goto out;
> -
> -	folio = __filemap_get_folio(mapping, 0, FGP_WRITEBEGIN | FGP_NOFS,
> -					mapping_gfp_mask(mapping));
> -	if (IS_ERR(folio)) {
> -		ret = PTR_ERR(folio);
> -		goto out;
> -	}
> -
> -	*foliop = folio;
> -	down_read(&EXT4_I(inode)->xattr_sem);
> -	if (!ext4_has_inline_data(inode)) {
> -		ret = 0;
> -		folio_unlock(folio);
> -		folio_put(folio);
> -		goto out_up_read;
> -	}
> -
> -	if (!folio_test_uptodate(folio)) {
> -		ret = ext4_read_inline_folio(inode, folio);
> -		if (ret < 0) {
> -			folio_unlock(folio);
> -			folio_put(folio);
> -			goto out_up_read;
> -		}
> -	}
> -
> -	ret = 1;
> -	handle = NULL;
> -out_up_read:
> -	up_read(&EXT4_I(inode)->xattr_sem);
> -out:
> -	if (handle && (ret != 1))
> -		ext4_journal_stop(handle);
> -	brelse(iloc.bh);
> -	return ret;
> -convert:
> -	return ext4_convert_inline_data_to_extent(mapping, inode);
> +		return ext4_convert_inline_data_to_extent(mapping, inode);
> +	return ext4_generic_write_inline_data(mapping, inode, pos, len,
> +					      foliop, NULL, false);
>  }
>  
>  int ext4_write_inline_data_end(struct inode *inode, loff_t pos, unsigned len,
> -- 
> 2.39.5
> 
-- 
Jan Kara <jack@...e.com>
SUSE Labs, CR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ