public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Jingbo Xu <jefflexu@linux.alibaba.com>,
	xiang@kernel.org, chao@kernel.org, linux-erofs@lists.ozlabs.org,
	huyue2@coolpad.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] erofs: call erofs_map_dev() inside erofs_map_blocks()
Date: Fri, 3 Feb 2023 13:52:29 +0800	[thread overview]
Message-ID: <cc67566e-6b49-c351-b8e7-9c842df8325e@linux.alibaba.com> (raw)
In-Reply-To: <20230203035303.35082-4-jefflexu@linux.alibaba.com>



On 2023/2/3 11:53, Jingbo Xu wrote:
> For now erofs_map_blocks() is always followed by erofs_map_dev().
> Make erofs_map_dev() called inside erofs_map_blocks() to reduce code
> duplication.

Could we just integrate mdev into struct erofs_map_blocks?

BTW, I still think erofs_map_dev() is useful since it can handle
non-inode IO requests, so let's keep this rather than mergeing all
code into erofs_map_blocks()

Thanks,
Gao Xiang

> 
> Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
> ---
>   fs/erofs/data.c     | 21 ++++++++++-----------
>   fs/erofs/fscache.c  | 20 ++------------------
>   fs/erofs/internal.h |  3 ++-
>   3 files changed, 14 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 32e66d29968f..cbe7a6d6846d 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -116,7 +116,8 @@ static int erofs_map_blocks_flatmode(struct inode *inode,
>   	return 0;
>   }
>   
> -int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
> +int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map,
> +		     struct erofs_map_dev *mdev)
>   {
>   	struct super_block *sb = inode->i_sb;
>   	struct erofs_inode *vi = EROFS_I(inode);
> @@ -188,8 +189,14 @@ int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map)
>   out_unlock:
>   	erofs_put_metabuf(&buf);
>   out:
> -	if (!err)
> +	if (!err) {
>   		map->m_llen = map->m_plen;
> +		*mdev = (struct erofs_map_dev) {
> +			.m_deviceid = map->m_deviceid,
> +			.m_pa = map->m_pa,
> +		};
> +		err = erofs_map_dev(sb, mdev);
> +	}
>   	trace_erofs_map_blocks_exit(inode, map, EROFS_GET_BLOCKS_RAW, err);
>   	return err;
>   }
> @@ -253,15 +260,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
>   	map.m_la = offset;
>   	map.m_llen = length;
>   
> -	ret = erofs_map_blocks(inode, &map);
> -	if (ret < 0)
> -		return ret;
> -
> -	mdev = (struct erofs_map_dev) {
> -		.m_deviceid = map.m_deviceid,
> -		.m_pa = map.m_pa,
> -	};
> -	ret = erofs_map_dev(inode->i_sb, &mdev);
> +	ret = erofs_map_blocks(inode, &map, &mdev);
>   	if (ret)
>   		return ret;
>   
> diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
> index 7f1ef2ffc4db..140ccacc1043 100644
> --- a/fs/erofs/fscache.c
> +++ b/fs/erofs/fscache.c
> @@ -229,7 +229,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary)
>   	int ret;
>   
>   	map.m_la = pos;
> -	ret = erofs_map_blocks(inode, &map);
> +	ret = erofs_map_blocks(inode, &map, &mdev);
>   	if (ret)
>   		return ret;
>   
> @@ -270,14 +270,6 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_request *primary)
>   	count = min_t(size_t, map.m_llen - (pos - map.m_la), count);
>   	DBG_BUGON(!count || count % PAGE_SIZE);
>   
> -	mdev = (struct erofs_map_dev) {
> -		.m_deviceid = map.m_deviceid,
> -		.m_pa = map.m_pa,
> -	};
> -	ret = erofs_map_dev(sb, &mdev);
> -	if (ret)
> -		return ret;
> -
>   	req = erofs_fscache_req_chain(primary, count);
>   	if (IS_ERR(req))
>   		return PTR_ERR(req);
> @@ -377,15 +369,7 @@ static int erofs_fscache_share_file_open(struct inode *inode, struct file *filp)
>   	struct file *realfile;
>   	int ret;
>   
> -	ret = erofs_map_blocks(inode, &map);
> -	if (ret)
> -		return ret;
> -
> -	mdev = (struct erofs_map_dev) {
> -		.m_deviceid = map.m_deviceid,
> -		.m_pa = map.m_pa,
> -	};
> -	ret = erofs_map_dev(inode->i_sb, &mdev);
> +	ret = erofs_map_blocks(inode, &map, &mdev);
>   	if (ret)
>   		return ret;
>   
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 323c2c775023..c54dec32a868 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -502,7 +502,8 @@ void *erofs_read_metabuf(struct erofs_buf *buf, struct super_block *sb,
>   int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *dev);
>   int erofs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>   		 u64 start, u64 len);
> -int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map);
> +int erofs_map_blocks(struct inode *inode, struct erofs_map_blocks *map,
> +		     struct erofs_map_dev *mdev);
>   
>   /* inode.c */
>   static inline unsigned long erofs_inode_hash(erofs_nid_t nid)

  reply	other threads:[~2023-02-03  5:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  3:53 [PATCH 0/3] erofs: cleanup for erofs_map_blocks() Jingbo Xu
2023-02-03  3:53 ` [PATCH 1/3] erofs: add print symbols for various flags in trace Jingbo Xu
2023-02-03  5:48   ` Gao Xiang
2023-02-03  3:53 ` [PATCH 2/3] erofs: remove unused flags parameter of erofs_map_blocks() Jingbo Xu
2023-02-03  3:53 ` [PATCH 3/3] erofs: call erofs_map_dev() inside erofs_map_blocks() Jingbo Xu
2023-02-03  5:52   ` Gao Xiang [this message]
2023-02-03  5:55     ` Jingbo Xu

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=cc67566e-6b49-c351-b8e7-9c842df8325e@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=chao@kernel.org \
    --cc=huyue2@coolpad.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiang@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox