xfs: cleanup buftarg handling in XFS_IOC_VERIFY_MEDIA
PATCH 1/1 xfs: cleanup buftarg handling in XFS_IOC_VERIFY_MEDIA
The newly added XFS_IOC_VERIFY_MEDIA is a bit unusual in how it handles buftarg fields. Update it to be more in line with other XFS code:
- use btp->bt_dev instead of btp->bt_bdev->bd_dev to retrieve the device number for tracing
- use btp->bt_logical_sectorsize instead of bdev_logical_block_size(btp->bt_bdev) to retrieve the logical sector size
- compare the buftarg and not the bdev to see if there is a separate log buftarg
--- fs/xfs/xfs_verify_media.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
fs/xfs/xfs_verify_media.c +8 -10
@@ -183,10 +183,9 @@ xfs_verify_iosize(min_not_zero (SZ_1M , me->me_max_io_size);BUILD_BUG_ON (BBSHIFT !=SECTOR_SHIFT ); -ASSERT (BBTOB (bbcount) >=bdev_logical_block_size (btp->bt_bdev)); +ASSERT (BBTOB (bbcount) >= btp->bt_logical_sectorsize); -return clamp (iosize,bdev_logical_block_size (btp->bt_bdev), -BBTOB (bbcount)); +return clamp (iosize, btp->bt_logical_sectorsize,BBTOB (bbcount)); }/* Allocate as much memory as we can get for verification buffer. */
@@ -218,8 +217,8 @@ xfs_verify_media_error(unsigned int bio_bbcount, blk_status_t bio_status) { - trace_xfs_verify_media_error(mp, me, btp->bt_bdev->bd_dev, daddr, -bio_bbcount ,bio_status ); + trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount, +bio_status );/* * Pass any error, I/O or otherwise, up to the caller if we didn't
@@ -280,7 +279,7 @@ xfs_verify_media( btp = mp->m_ddev_targp;break ;case XFS_DEV_LOG : -if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) +if (mp->m_logdev_targp != mp->m_ddev_targp) btp = mp->m_logdev_targp;break ;case XFS_DEV_RT :
@@ -299,7 +298,7 @@ xfs_verify_media(/* start and end have to be aligned to the lba size */ if (!IS_ALIGNED (BBTOB (me->me_start_daddr | me->me_end_daddr), -bdev_logical_block_size (btp->bt_bdev))) + btp->bt_logical_sectorsize))return -EINVAL ;/*
@@ -331,8 +330,7 @@ xfs_verify_media(if (!folio)return -ENOMEM ; -trace_xfs_verify_media (mp, me, btp->bt_bdev->bd_dev, daddr, bbcount, - folio); +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) {
@@ -400,7 +398,7 @@ xfs_verify_media(* an operational error. */ me->me_start_daddr = daddr; -trace_xfs_verify_media_end (mp, me, btp->bt_bdev->bd_dev); +trace_xfs_verify_media_end (mp, me, btp->bt_dev);return 0 ; }
Signature · 1 line
2.47.3
Quoted 8 lines · Christoph Hellwig
The newly added
XFS_IOC_VERIFY_MEDIAis a bit unusual in how it handles buftarg fields. Update it to be more in line with other XFS code:- use
btp->bt_devinstead ofbtp->bt_bdev->bd_devto retrieve the device number for tracing
- usebtp->bt_logical_sectorsizeinstead ofbdev_logical_block_size(btp->bt_bdev)to retrieve the logical sector size
Heh, aliased variables. I wish I'd remembered that those exist.
Quoted 2 lines
- compare the buftarg and not the bdev to see if there is a separate log buftarg
<nod> Yeah, that's also correct, and less pointer chasing.
Quoted 1 line
Signed-off-by Christoph Hellwig <[email protected]>
--D
Quoted 73 lines
--- fs/xfs/xfs_verify_media.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)fs/xfs/xfs_verify_media.c +8
-10@@ -183,10 +183,9 @@ xfs_verify_iosize(min_not_zero (SZ_1M , me->me_max_io_size);BUILD_BUG_ON (BBSHIFT !=SECTOR_SHIFT ); -ASSERT (BBTOB (bbcount) >=bdev_logical_block_size (btp->bt_bdev)); +ASSERT (BBTOB (bbcount) >= btp->bt_logical_sectorsize); -return clamp (iosize,bdev_logical_block_size (btp->bt_bdev), -BBTOB (bbcount)); +return clamp (iosize, btp->bt_logical_sectorsize,BBTOB (bbcount)); }/* Allocate as much memory as we can get for verification buffer. */ @@ -218,8 +217,8 @@ xfs_verify_media_error(unsigned int bio_bbcount, blk_status_t bio_status) { - trace_xfs_verify_media_error(mp, me, btp->bt_bdev->bd_dev, daddr, -bio_bbcount ,bio_status ); + trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount, +bio_status );/* * Pass any error, I/O or otherwise, up to the caller if we didn't @@ -280,7 +279,7 @@ xfs_verify_media( btp = mp->m_ddev_targp;break ;case XFS_DEV_LOG : -if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev) +if (mp->m_logdev_targp != mp->m_ddev_targp) btp = mp->m_logdev_targp;break ;case XFS_DEV_RT :@@ -299,7 +298,7 @@ xfs_verify_media(/* start and end have to be aligned to the lba size */ if (!IS_ALIGNED (BBTOB (me->me_start_daddr | me->me_end_daddr), -bdev_logical_block_size (btp->bt_bdev))) + btp->bt_logical_sectorsize))return -EINVAL ;/* @@ -331,8 +330,7 @@ xfs_verify_media(if (!folio)return -ENOMEM ; -trace_xfs_verify_media (mp, me, btp->bt_bdev->bd_dev, daddr, bbcount, - folio); +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) {@@ -400,7 +398,7 @@ xfs_verify_media(* an operational error. */ me->me_start_daddr = daddr; -trace_xfs_verify_media_end (mp, me, btp->bt_bdev->bd_dev); +trace_xfs_verify_media_end (mp, me, btp->bt_dev);return 0 ; }Signature · 1 line
2.47.3
Quoted 11 lines · Christoph Hellwig
The newly added
XFS_IOC_VERIFY_MEDIAis a bit unusual in how it handles buftarg fields. Update it to be more in line with other XFS code:- use
btp->bt_devinstead ofbtp->bt_bdev->bd_devto retrieve the device number for tracing
- usebtp->bt_logical_sectorsizeinstead ofbdev_logical_block_size(btp->bt_bdev)to retrieve the logical sector size
- compare the buftarg and not the bdev to see if there is a separate log buftarg
Quoted 1 line
[...]
Applied to for-next, thanks!
[1/1] xfs: cleanup buftarg handling in XFS_IOC_VERIFY_MEDIA
commit: 0c98524ab20193d8772cff9c71b00ad004fb1349
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>