linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Joanne Koong <joannelkoong@gmail.com>
Cc: miklos@szeredi.hu, brauner@kernel.org,
	linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
	bernd.schubert@fastmail.fm, kernel-team@meta.com
Subject: Re: [PATCH v1 3/8] iomap: add buffered write support for IOMAP_IN_MEM iomaps
Date: Mon, 9 Jun 2025 09:38:40 -0700	[thread overview]
Message-ID: <20250609163840.GJ6156@frogsfrogsfrogs> (raw)
In-Reply-To: <20250606233803.1421259-4-joannelkoong@gmail.com>

On Fri, Jun 06, 2025 at 04:37:58PM -0700, Joanne Koong wrote:
> Add buffered write support for IOMAP_IN_MEM iomaps. This lets
> IOMAP_IN_MEM iomaps use some of the internal features in iomaps
> such as granular dirty tracking for large folios.
> 
> Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
> ---
>  fs/iomap/buffered-io.c | 24 +++++++++++++++++-------
>  include/linux/iomap.h  | 10 ++++++++++
>  2 files changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index 1caeb4921035..fd2ea1306d88 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -300,7 +300,7 @@ static inline bool iomap_block_needs_zeroing(const struct iomap_iter *iter,
>  {
>  	const struct iomap *srcmap = iomap_iter_srcmap(iter);
>  
> -	return srcmap->type != IOMAP_MAPPED ||
> +	return (srcmap->type != IOMAP_MAPPED && srcmap->type != IOMAP_IN_MEM) ||
>  		(srcmap->flags & IOMAP_F_NEW) ||
>  		pos >= i_size_read(iter->inode);
>  }
> @@ -583,16 +583,26 @@ iomap_write_failed(struct inode *inode, loff_t pos, unsigned len)
>  					 pos + len - 1);
>  }
>  
> -static int iomap_read_folio_sync(loff_t block_start, struct folio *folio,
> -		size_t poff, size_t plen, const struct iomap *iomap)
> +static int iomap_read_folio_sync(const struct iomap_iter *iter, loff_t block_start,
> +				 struct folio *folio, size_t poff, size_t plen)
>  {
> -	return iomap_bio_read_folio_sync(block_start, folio, poff, plen, iomap);
> +	const struct iomap_folio_ops *folio_ops = iter->iomap.folio_ops;
> +	const struct iomap *srcmap = iomap_iter_srcmap(iter);
> +
> +	if (folio_ops && folio_ops->read_folio_sync)
> +		return folio_ops->read_folio_sync(block_start, folio,
> +						  poff, plen, srcmap,
> +						  iter->private);

Hmm, patch 6 hooks this up to fuse_do_readfolio, which means that iomap
provides the folios and manages their uptodate/dirty state.  You still
want fuse to handle the folio contents (aka poke the fuse server via
FUSE_READ/FUSE_WRITE), but this avoids the memcpy that IOMAP_INLINE
performs.

So I think you're effectively addding another IO path to buffered-io.c,
which explains why you moved the bio code to a separate file.  I wonder
if you could hook up this new IO path by checking for a non-NULL
->read_folio_sync function and calling it regardless of iomap::type?

--D

> +
> +	/* IOMAP_IN_MEM iomaps must always handle ->read_folio_sync() */
> +	WARN_ON_ONCE(iter->iomap.type == IOMAP_IN_MEM);
> +
> +	return iomap_bio_read_folio_sync(block_start, folio, poff, plen, srcmap);
>  }
>  
>  static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
>  		size_t len, struct folio *folio)
>  {
> -	const struct iomap *srcmap = iomap_iter_srcmap(iter);
>  	struct iomap_folio_state *ifs;
>  	loff_t block_size = i_blocksize(iter->inode);
>  	loff_t block_start = round_down(pos, block_size);
> @@ -640,8 +650,8 @@ static int __iomap_write_begin(const struct iomap_iter *iter, loff_t pos,
>  			if (iter->flags & IOMAP_NOWAIT)
>  				return -EAGAIN;
>  
> -			status = iomap_read_folio_sync(block_start, folio,
> -					poff, plen, srcmap);
> +			status = iomap_read_folio_sync(iter, block_start, folio,
> +						       poff, plen);
>  			if (status)
>  				return status;
>  		}
> diff --git a/include/linux/iomap.h b/include/linux/iomap.h
> index dbbf217eb03f..e748aeebe1a5 100644
> --- a/include/linux/iomap.h
> +++ b/include/linux/iomap.h
> @@ -175,6 +175,16 @@ struct iomap_folio_ops {
>  	 * locked by the iomap code.
>  	 */
>  	bool (*iomap_valid)(struct inode *inode, const struct iomap *iomap);
> +
> +	/*
> +	 * Required for IOMAP_IN_MEM iomaps. Otherwise optional if the caller
> +	 * wishes to handle reading in a folio.
> +	 *
> +	 * The read must be done synchronously.
> +	 */
> +	int (*read_folio_sync)(loff_t block_start, struct folio *folio,
> +			       size_t off, size_t len, const struct iomap *iomap,
> +			       void *private);
>  };
>  
>  /*
> -- 
> 2.47.1
> 
> 

  parent reply	other threads:[~2025-06-09 16:38 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 23:37 [PATCH v1 0/8] fuse: use iomap for buffered writes + writeback Joanne Koong
2025-06-06 23:37 ` [PATCH v1 1/8] iomap: move buffered io bio logic into separate file Joanne Koong
2025-06-08 19:17   ` Anuj gupta
2025-06-09  4:44   ` Christoph Hellwig
2025-06-09 20:01     ` Joanne Koong
2025-06-06 23:37 ` [PATCH v1 2/8] iomap: add IOMAP_IN_MEM iomap type Joanne Koong
2025-06-09  4:45   ` Christoph Hellwig
2025-06-09 21:45     ` Joanne Koong
2025-06-10  3:39       ` Christoph Hellwig
2025-06-10 13:27         ` Christoph Hellwig
2025-06-10 20:13           ` Joanne Koong
2025-06-11  4:04             ` Christoph Hellwig
2025-06-11  6:00               ` Joanne Koong
2025-06-11  6:08                 ` Christoph Hellwig
2025-06-11 18:33                 ` Joanne Koong
2025-06-11 18:50                   ` Darrick J. Wong
2025-06-11 23:08                     ` Joanne Koong
2025-06-12  4:42                       ` Christoph Hellwig
2025-06-09 16:24   ` Darrick J. Wong
2025-06-09 21:28     ` Joanne Koong
2025-06-12  3:53       ` Darrick J. Wong
2025-06-06 23:37 ` [PATCH v1 3/8] iomap: add buffered write support for IOMAP_IN_MEM iomaps Joanne Koong
2025-06-09  4:56   ` Christoph Hellwig
2025-06-09 22:45     ` Joanne Koong
2025-06-10  3:44       ` Christoph Hellwig
2025-06-09 16:38   ` Darrick J. Wong [this message]
2025-06-09 22:03     ` Joanne Koong
2025-06-12  3:54       ` Darrick J. Wong
2025-06-06 23:37 ` [PATCH v1 4/8] iomap: add writepages " Joanne Koong
2025-06-09  5:32   ` Christoph Hellwig
2025-06-09 16:57     ` Darrick J. Wong
2025-06-10  3:49       ` Christoph Hellwig
2025-06-12  3:56         ` Darrick J. Wong
2025-06-09 23:15     ` Joanne Koong
2025-06-10  3:58       ` Christoph Hellwig
2025-06-10 18:23         ` Joanne Koong
2025-06-10 18:58           ` Joanne Koong
2025-06-11  4:01           ` Christoph Hellwig
2025-06-06 23:38 ` [PATCH v1 5/8] iomap: add iomap_writeback_dirty_folio() Joanne Koong
2025-06-09  4:51   ` Christoph Hellwig
2025-06-09 17:14     ` Darrick J. Wong
2025-06-09 23:54       ` Joanne Koong
2025-06-10  3:59       ` Christoph Hellwig
2025-06-11  4:34         ` Matthew Wilcox
2025-06-18  4:47           ` does fuse need ->launder_folios, was: " Christoph Hellwig
2025-06-18 12:17           ` Jeff Layton
2025-06-20 18:15             ` Matthew Wilcox
2025-06-25  5:26               ` Joanne Koong
2025-06-25  6:26                 ` Christoph Hellwig
2025-06-25 16:44                   ` Joanne Koong
2025-07-01  5:41                     ` Darrick J. Wong
2025-07-02 21:36                       ` Joanne Koong
2025-07-02 21:47                         ` Joanne Koong
2025-07-01  6:23                     ` Miklos Szeredi
2025-06-09 23:30     ` Joanne Koong
2025-06-10  4:03       ` Christoph Hellwig
2025-06-06 23:38 ` [PATCH v1 6/8] fuse: use iomap for buffered writes Joanne Koong
2025-06-06 23:38 ` [PATCH v1 7/8] fuse: use iomap for writeback Joanne Koong
2025-06-08 19:20   ` Anuj gupta
2025-06-06 23:38 ` [PATCH v1 8/8] fuse: use iomap for folio laundering Joanne Koong
2025-06-08 19:12 ` [PATCH v1 0/8] fuse: use iomap for buffered writes + writeback Anuj gupta
2025-06-09 19:59   ` Joanne Koong
2025-06-14 14:22     ` Anuj gupta
2025-06-09  4:40 ` Christoph Hellwig
2025-06-09 12:38   ` Anuj gupta
2025-06-09 19:47     ` Joanne Koong
2025-06-10  4:04     ` Christoph Hellwig
2025-06-10  0:47 ` Dave Chinner
2025-06-10  4:06   ` Christoph Hellwig
2025-06-10 20:33   ` Joanne Koong

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=20250609163840.GJ6156@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=bernd.schubert@fastmail.fm \
    --cc=brauner@kernel.org \
    --cc=joannelkoong@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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).