Re: [PATCH 3/3] iomap: use GFP_NOWAIT when application for iomap_dio_simple allocations

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-ext4,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-xfs
Message-ID <20260723164352.GE7380@frogsfrogsfrogs>
On Thu, Jul 23, 2026 at 07:01:41AM +0200, Christoph Hellwig wrote:
> For non-blocking iocbs we should avoid blocking allocation where
> possible, so switch to a GFP_NOWAIT allocation here.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>

Reviewed-by: "Darrick J. Wong" <[email protected]>

--D

> ---
>  fs/iomap/direct-io.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c
> index 36c976cf0848..5c28124b9f02 100644
> --- a/fs/iomap/direct-io.c
> +++ b/fs/iomap/direct-io.c
> @@ -986,6 +986,7 @@ static void iomap_dio_simple_end_io(struct bio *bio)
>  ssize_t __iomap_dio_read_simple(struct kiocb *iocb, struct iov_iter *iter,
>  		struct iomap_iter *iomi)
>  {
> +	gfp_t gfp = (iomi->flags & IOMAP_NOWAIT) ? GFP_NOWAIT : GFP_KERNEL;
>  	struct iomap_dio_simple *sr;
>  	unsigned int alignment;
>  	struct bio *bio;
> @@ -1015,7 +1016,11 @@ ssize_t __iomap_dio_read_simple(struct kiocb *iocb, struct iov_iter *iter,
>  
>  	bio = bio_alloc_bioset(iomi->iomap.bdev,
>  			       bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS),
> -			       REQ_OP_READ, GFP_KERNEL, &iomap_dio_simple_pool);
> +			       REQ_OP_READ, gfp, &iomap_dio_simple_pool);
> +	if (!bio) {
> +		ret = -EAGAIN;
> +		goto out_dio_end;
> +	}
>  	sr = container_of(bio, struct iomap_dio_simple, bio);
>  	sr->iocb = iocb;
>  	sr->dio_flags = 0;
> -- 
> 2.53.0
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.