Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 5/9] xfs: use bdev_rw_virt in xfs_verify_media
Date: Thu, 24 Sep 2026 13:18:14 -0700	[thread overview]
Message-ID: <20260924201814.GU2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924095740.2732474-6-hch@lst.de>

On Thu, Sep 24, 2026 at 11:57:06AM +0200, Christoph Hellwig wrote:
> Use bdev_rw_virt for reading data from disk.  This simply uses an
> on-stack bio and bio_vec and removes the need to allocate an bio and
> reset it for each iteration.  Because bdev_rw_virt returns a negative
> errno, pass that on to xfs_verify_media_error to avoid a double
> conversion.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Nice cleanup!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_verify_media.c | 41 +++++++++++----------------------------
>  1 file changed, 11 insertions(+), 30 deletions(-)
> 
> diff --git a/fs/xfs/xfs_verify_media.c b/fs/xfs/xfs_verify_media.c
> index 8ce3773aa875..71f4d6c832a9 100644
> --- a/fs/xfs/xfs_verify_media.c
> +++ b/fs/xfs/xfs_verify_media.c
> @@ -229,8 +229,10 @@ xfs_verify_media_error(
>  	struct xfs_buftarg	*btp,
>  	xfs_daddr_t		daddr,
>  	unsigned int		bio_bbcount,
> -	blk_status_t		bio_status)
> +	int			error)
>  {
> +	blk_status_t		bio_status = errno_to_blk_status(error);
> +
>  	trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount,
>  			bio_status);
>  
> @@ -239,7 +241,7 @@ xfs_verify_media_error(
>  	 * successfully verify any bytes at all.
>  	 */
>  	if (me->me_start_daddr == daddr)
> -		me->me_ioerror = -blk_status_to_errno(bio_status);
> +		me->me_ioerror = -error;
>  
>  	/*
>  	 * PI validation failures, medium errors, or general IO errors are
> @@ -266,7 +268,6 @@ xfs_verify_media(
>  	struct xfs_verify_media	*me)
>  {
>  	struct xfs_buftarg	*btp = NULL;
> -	struct bio		*bio;
>  	struct folio		*folio;
>  	xfs_daddr_t		daddr;
>  	uint64_t		bbcount;
> @@ -332,33 +333,16 @@ xfs_verify_media(
>  
>  	trace_xfs_verify_media(mp, me, btp->bt_dev, daddr, bbcount, folio);
>  
> -	bio = bio_alloc(btp->bt_bdev, 1, REQ_OP_READ, GFP_KERNEL);
> -	if (!bio) {
> -		error = -ENOMEM;
> -		goto out_folio;
> -	}
> -
> -	while (bbcount > 0) {
> +	for (;;) {
>  		unsigned int	bio_bbcount;
> -		blk_status_t	bio_status;
> -
> -		bio_reset(bio, btp->bt_bdev, REQ_OP_READ);
> -		bio->bi_iter.bi_sector = daddr;
> -		bio_add_folio_nofail(bio, folio,
> -				min(bbcount << SECTOR_SHIFT, folio_size(folio)),
> -				0);
>  
> -		/*
> -		 * Save the length of the bio before we submit it, because we
> -		 * need the original daddr and length for reporting IO errors
> -		 * if the bio fails.
> -		 */
> -		bio_bbcount = bio->bi_iter.bi_size >> SECTOR_SHIFT;
> -		submit_bio_wait(bio);
> -		bio_status = bio->bi_status;
> -		if (bio_status != BLK_STS_OK) {
> +		bio_bbcount = min(bbcount, folio_size(folio) >> SECTOR_SHIFT);
> +		error = bdev_rw_virt(btp->bt_bdev, daddr, folio_address(folio),
> +				bio_bbcount << SECTOR_SHIFT,
> +				REQ_OP_READ);
> +		if (error) {
>  			xfs_verify_media_error(mp, me, btp, daddr, bio_bbcount,
> -					bio_status);
> +					error);
>  			error = 0;
>  			break;
>  		}
> @@ -386,10 +370,7 @@ xfs_verify_media(
>  		cond_resched();
>  	}
>  
> -	bio_put(bio);
> -out_folio:
>  	folio_put(folio);
> -
>  	if (error)
>  		return error;
>  
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-09-24 20:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  9:57 misc cleanups Christoph Hellwig
2026-09-24  9:57 ` [PATCH 1/9] xfs: centralize setting of buf_ops/buf_type/magic for rtblocks Christoph Hellwig
2026-09-24 19:01   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 2/9] xfs: factor out a xfs_rtfile_initialize_buf helper Christoph Hellwig
2026-09-24 19:02   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 3/9] xfs: add a xfs_rtblock_payload helper Christoph Hellwig
2026-09-24 20:13   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 4/9] xfs: cleanup xfs_verify_media_error Christoph Hellwig
2026-09-24 20:14   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 5/9] xfs: use bdev_rw_virt in xfs_verify_media Christoph Hellwig
2026-09-24 20:18   ` Darrick J. Wong [this message]
2026-09-24  9:57 ` [PATCH 6/9] xfs: lift setting the NOFS context to xfs_end_io Christoph Hellwig
2026-09-24 20:18   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 7/9] xfs: split xfs_end_ioend_write Christoph Hellwig
2026-09-24 20:26   ` Darrick J. Wong
2026-09-25  5:46     ` Christoph Hellwig
2026-09-24  9:57 ` [PATCH 8/9] xfs: factor out a xfs_zoned_fill_srcmap helper Christoph Hellwig
2026-09-24 20:27   ` Darrick J. Wong
2026-09-24  9:57 ` [PATCH 9/9] xfs: calculate end_fsb later in xfs_zoned_fill_srcmap Christoph Hellwig
2026-09-24 20:29   ` Darrick J. Wong
2026-10-05 18:06 ` misc cleanups Carlos Maiolino

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=20260924201814.GU2705364@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.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