public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@lst.de>
Cc: Christian Brauner <brauner@kernel.org>,
	 Alexander Viro <viro@zeniv.linux.org.uk>,
	"Darrick J. Wong" <djwong@kernel.org>, Jan Kara <jack@suse.cz>,
	 Jens Axboe <axboe@kernel.dk>, Avi Kivity <avi@scylladb.com>,
	 Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	 Johannes Thumshirn <jth@kernel.org>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 io-uring@vger.kernel.org
Subject: Re: [PATCH 3/5] iomap: rework REQ_FUA selection
Date: Wed, 12 Nov 2025 21:07:20 +0100	[thread overview]
Message-ID: <7ew6yrzcgv7v6ckhmw4oxw7bjx37n4dabzdlbbs6gpowcph2yk@4qaombbiigik> (raw)
In-Reply-To: <20251112072214.844816-4-hch@lst.de>

On Wed 12-11-25 08:21:27, Christoph Hellwig wrote:
> The way how iomap_dio_can_use_fua and the caller is structured is
> a bit confusing, as the main guarding condition is hidden in the
> helper, and the secondary conditions are split between caller and
> callee.
> 
> Refactor the code, so that there is a main IOMAP_DIO_WRITE_THROUGH
> guard in iomap_dio_bio_iter, which is directly tied to clearing it
> when not supported, and a helper that just checks if the I/O is a
> pure overwrite.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

One nit below but feel free to add:

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

> -static inline bool iomap_dio_can_use_fua(const struct iomap *iomap,
> -		struct iomap_dio *dio)
> +static inline bool iomap_dio_is_overwrite(const struct iomap *iomap)
>  {
> -	if (iomap->flags & (IOMAP_F_SHARED | IOMAP_F_DIRTY))
> +	if (iomap->type != IOMAP_MAPPED)
>  		return false;
> -	if (!(dio->flags & IOMAP_DIO_WRITE_THROUGH))
> -		return false;
> -	return !bdev_write_cache(iomap->bdev) || bdev_fua(iomap->bdev);
> +	return !(iomap->flags & (IOMAP_F_NEW | IOMAP_F_SHARED));
>  }

I'm a bit puzzled why did you leave IOMAP_F_DIRTY check in the caller.
Because that means we need metadata update to make the extent stable as the
comment before this function states...

								Honza

>  static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
> @@ -355,12 +349,22 @@ static int iomap_dio_bio_iter(struct iomap_iter *iter, struct iomap_dio *dio)
>  
>  		if (iomap->flags & IOMAP_F_NEW)
>  			need_zeroout = true;
> -		else if (iomap->type == IOMAP_MAPPED &&
> -			 iomap_dio_can_use_fua(iomap, dio))
> -			bio_opf |= REQ_FUA;
>  
> -		if (!(bio_opf & REQ_FUA))
> -			dio->flags &= ~IOMAP_DIO_WRITE_THROUGH;
> +		/*
> +		 * Use a FUA write if we need datasync semantics and this is a
> +		 * pure overwrite that doesn't require any metadata updates.
> +		 *
> +		 * This allows us to avoid cache flushes on I/O completion.
> +		 */
> +		if (dio->flags & IOMAP_DIO_WRITE_THROUGH) {
> +			if (iomap_dio_is_overwrite(iomap) &&
> +			    !(iomap->flags & IOMAP_F_DIRTY) &&
> +			    (!bdev_write_cache(iomap->bdev) ||
> +			     bdev_fua(iomap->bdev)))
> +				bio_opf |= REQ_FUA;
> +			else
> +				dio->flags &= ~IOMAP_DIO_WRITE_THROUGH;
> +		}
>  	} else {
>  		bio_opf |= REQ_OP_READ;
>  	}
> -- 
> 2.47.3
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2025-11-12 20:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12  7:21 enable iomap dio write completions from interrupt context Christoph Hellwig
2025-11-12  7:21 ` [PATCH 1/5] fs, iomap: remove IOCB_DIO_CALLER_COMP Christoph Hellwig
2025-11-12 19:59   ` Jan Kara
2025-11-13  0:00   ` Chaitanya Kulkarni
2025-11-12  7:21 ` [PATCH 2/5] iomap: always run error completions in user context Christoph Hellwig
2025-11-12 20:01   ` Jan Kara
2025-11-13  0:02   ` Chaitanya Kulkarni
2025-11-12  7:21 ` [PATCH 3/5] iomap: rework REQ_FUA selection Christoph Hellwig
2025-11-12 20:07   ` Jan Kara [this message]
2025-11-12  7:21 ` [PATCH 4/5] iomap: support write completions from interrupt context Christoph Hellwig
2025-11-12 20:25   ` Jan Kara
2025-11-13  6:50     ` Christoph Hellwig
2025-11-13  9:54       ` Jan Kara
2025-11-13 10:06         ` Christoph Hellwig
2025-11-13 12:06           ` Jan Kara
2025-11-13 12:35             ` Christoph Hellwig
2025-11-12  7:21 ` [PATCH 5/5] iomap: invert the polarity of IOMAP_DIO_INLINE_COMP Christoph Hellwig
2025-11-13 12:09   ` Jan Kara
2025-11-12  8:43 ` enable iomap dio write completions from interrupt context Damien Le Moal
2025-11-12  8:44   ` Christoph Hellwig
2025-11-12  8:46     ` Damien Le Moal
2025-11-13  9:58 ` Jan Kara
2025-11-13 10:05   ` Christoph Hellwig
2025-11-13 10:07     ` Damien Le Moal
2025-11-13 11:52     ` Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2025-11-13 17:06 enable iomap dio write completions from interrupt context v2 Christoph Hellwig
2025-11-13 17:06 ` [PATCH 3/5] iomap: rework REQ_FUA selection Christoph Hellwig
2025-11-24 11:05   ` Jan Kara

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=7ew6yrzcgv7v6ckhmw4oxw7bjx37n4dabzdlbbs6gpowcph2yk@4qaombbiigik \
    --to=jack@suse.cz \
    --cc=avi@scylladb.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=djwong@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=hch@lst.de \
    --cc=io-uring@vger.kernel.org \
    --cc=jth@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=viro@zeniv.linux.org.uk \
    /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