cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Darrick J. Wong <djwong@kernel.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] iomap: iomap_read_inline_data cleanup
Date: Wed, 17 Nov 2021 09:12:25 -0800	[thread overview]
Message-ID: <20211117171225.GY24307@magnolia> (raw)
In-Reply-To: <20211117103202.44346-1-agruenba@redhat.com>

On Wed, Nov 17, 2021 at 11:32:02AM +0100, Andreas Gruenbacher wrote:
> Change iomap_read_inline_data to return 0 or an error code; this
> simplifies the callers.  Add a description.
> 
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>

Looks good, thank you for cleaning this up for me!
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/iomap/buffered-io.c | 30 ++++++++++++++----------------
>  1 file changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index fe10d8a30f6b..f1bc9a35184d 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -205,7 +205,15 @@ struct iomap_readpage_ctx {
>  	struct readahead_control *rac;
>  };
>  
> -static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
> +/**
> + * iomap_read_inline_data - copy inline data into the page cache
> + * @iter: iteration structure
> + * @page: page to copy to
> + *
> + * Copy the inline data in @iter into @page and zero out the rest of the page.
> + * Only a single IOMAP_INLINE extent is allowed at the end of each file.
> + */
> +static int iomap_read_inline_data(const struct iomap_iter *iter,
>  		struct page *page)
>  {
>  	const struct iomap *iomap = iomap_iter_srcmap(iter);
> @@ -214,7 +222,7 @@ static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
>  	void *addr;
>  
>  	if (PageUptodate(page))
> -		return PAGE_SIZE - poff;
> +		return 0;
>  
>  	if (WARN_ON_ONCE(size > PAGE_SIZE - poff))
>  		return -EIO;
> @@ -231,7 +239,7 @@ static loff_t iomap_read_inline_data(const struct iomap_iter *iter,
>  	memset(addr + size, 0, PAGE_SIZE - poff - size);
>  	kunmap_local(addr);
>  	iomap_set_range_uptodate(page, poff, PAGE_SIZE - poff);
> -	return PAGE_SIZE - poff;
> +	return 0;
>  }
>  
>  static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter,
> @@ -256,13 +264,8 @@ static loff_t iomap_readpage_iter(const struct iomap_iter *iter,
>  	unsigned poff, plen;
>  	sector_t sector;
>  
> -	if (iomap->type == IOMAP_INLINE) {
> -		loff_t ret = iomap_read_inline_data(iter, page);
> -
> -		if (ret < 0)
> -			return ret;
> -		return 0;
> -	}
> +	if (iomap->type == IOMAP_INLINE)
> +		return iomap_read_inline_data(iter, page);
>  
>  	/* zero post-eof blocks as the page may be mapped */
>  	iop = iomap_page_create(iter->inode, page);
> @@ -587,15 +590,10 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
>  static int iomap_write_begin_inline(const struct iomap_iter *iter,
>  		struct page *page)
>  {
> -	int ret;
> -
>  	/* needs more work for the tailpacking case; disable for now */
>  	if (WARN_ON_ONCE(iomap_iter_srcmap(iter)->offset != 0))
>  		return -EIO;
> -	ret = iomap_read_inline_data(iter, page);
> -	if (ret < 0)
> -		return ret;
> -	return 0;
> +	return iomap_read_inline_data(iter, page);
>  }
>  
>  static int iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
> -- 
> 2.31.1
> 



      parent reply	other threads:[~2021-11-17 17:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 10:32 [Cluster-devel] [PATCH] iomap: iomap_read_inline_data cleanup Andreas Gruenbacher
2021-11-17 12:31 ` Christoph Hellwig
2021-11-17 17:12 ` Darrick J. Wong [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=20211117171225.GY24307@magnolia \
    --to=djwong@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;
as well as URLs for NNTP newsgroup(s).