small fixes for 6.13
Hi all,
two little fixes and a refactoring to prepare one of them for the new rtgroup code.
Diffstat:
libxfs/xfs_bmap.c | 6 +---- xfs_rtalloc.c | 62 +++++++++++++++++++++++++++--------------------------- 2 files changed, 33 insertions(+), 35 deletions(-)
PATCH 1/3 xfs: factor out a xfs_rt_check_size helper
Add a helper to check that the last block of a RT device is readable to share the code between mount and growfs. This also adds the mount time overflow check to growfs and improves the error messages.
--- fs/xfs/xfs_rtalloc.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
fs/xfs/xfs_rtalloc.c +31 -31
@@ -1225,6 +1225,34 @@ xfs_grow_last_rtg( mp->m_sb.sb_rgextents; } +/* +* Read in the last block of the RT device to make sure it is accessible. +*/ +static int +xfs_rt_check_size ( +struct xfs_mount *mp, +xfs_rfsblock_t last_block) +{ +xfs_daddr_t daddr =XFS_FSB_TO_BB (mp, last_block); +struct xfs_buf *bp; +int error; + +if (XFS_BB_TO_FSB (mp, daddr) != last_block) { +xfs_warn (mp,"RT device size overflow: %llu != %llu" , +XFS_BB_TO_FSB (mp, daddr), last_block); +return -EFBIG ; + } + + error =xfs_buf_read_uncached (mp->m_rtdev_targp, daddr, +XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); +if (error) +xfs_warn (mp,"cannot read last RT device block (%lld)" , + last_block); +else +xfs_buf_relse (bp); +return error; +} +/* * Grow the realtime area of the filesystem. */
@@ -1236,7 +1264,6 @@ xfs_growfs_rt(xfs_rgnumber_t old_rgcount = mp->m_sb.sb_rgcount;xfs_rgnumber_t new_rgcount =1 ;xfs_rgnumber_t rgno; -struct xfs_buf *bp;xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize;int error;
@@ -1273,15 +1300,10 @@ xfs_growfs_rt( error =xfs_sb_validate_fsb_count (&mp->m_sb, in->newblocks);if (error) goto out_unlock; -/* -* Read in the last block of the device, make sure it exists. -*/ - error =xfs_buf_read_uncached (mp->m_rtdev_targp, -XFS_FSB_TO_BB (mp, in->newblocks -1 ), -XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); + + error =xfs_rt_check_size (mp, in->newblocks -1 );if (error) goto out_unlock; -xfs_buf_relse (bp);/* * Calculate new parameters. These are the final values to be reached.
@@ -1408,10 +1430,6 @@ int /* error */xfs_rtmount_init ( struct xfs_mount *mp) /* file system mount structure */ { -struct xfs_buf *bp;/* buffer for last block of subvolume */ -xfs_daddr_t d;/* address of last block of subvolume */ -int error; -if (mp->m_sb.sb_rblocks ==0 )return 0 ;if (mp->m_rtdev_targp ==NULL ) {
@@ -1422,25 +1440,7 @@ xfs_rtmount_init( mp->m_rsumblocks =xfs_rtsummary_blockcount (mp, &mp->m_rsumlevels); -/* -* Check that the realtime section is an ok size. -*/ - d = (xfs_daddr_t )XFS_FSB_TO_BB (mp, mp->m_sb.sb_rblocks); -if (XFS_BB_TO_FSB (mp, d) != mp->m_sb.sb_rblocks) { -xfs_warn (mp,"realtime mount -- %llu != %llu" , - (unsigned long long )XFS_BB_TO_FSB (mp, d), - (unsigned long long ) mp->m_sb.sb_rblocks); -return -EFBIG ; - } - error =xfs_buf_read_uncached (mp->m_rtdev_targp, - d -XFS_FSB_TO_BB (mp,1 ), -XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); -if (error) { -xfs_warn (mp,"realtime device size check failed" ); -return error; - } -xfs_buf_relse (bp); -return 0 ; +return xfs_rt_check_size (mp, mp->m_sb.sb_rblocks -1 ); } static int
Signature · 1 line
2.45.2
Re: [PATCH 1/3] xfs: factor out a xfs_rt_check_size helper
Quoted 30 lines · Christoph Hellwig
Add a helper to check that the last block of a RT device is readable to share the code between mount and growfs. This also adds the mount time overflow check to growfs and improves the error messages.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_rtalloc.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-)fs/xfs/xfs_rtalloc.c +13
-0@@ -1225,6 +1225,34 @@ xfs_grow_last_rtg( mp->m_sb.sb_rgextents; } +/* +* Read in the last block of the RT device to make sure it is accessible. +*/ +static int +xfs_rt_check_size ( +struct xfs_mount *mp, +xfs_rfsblock_t last_block) +{ +xfs_daddr_t daddr =XFS_FSB_TO_BB (mp, last_block); +struct xfs_buf *bp; +int error; + +if (XFS_BB_TO_FSB (mp, daddr) != last_block) {
fs/xfs/xfs_rtalloc.c xfs_grow_last_rtg( · line 1250
Quoted 10 lines
fs/xfs/xfs_rtalloc.c +10
-0+xfs_warn (mp,"RT device size overflow: %llu != %llu" , +XFS_BB_TO_FSB (mp, daddr), last_block); +return -EFBIG ; + } + + error =xfs_buf_read_uncached (mp->m_rtdev_targp, daddr, +XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); +if (error) +xfs_warn (mp,"cannot read last RT device block (%lld)" , + last_block);
"cannot read last RT device sector"? Something to hint that the units are 512b blocks, not fsblocks? This is certainly better than the old message. :)
Also, should there be a similar function to handle the last datadev read that mount and growfs perform?
--D
Quoted 76 lines
fs/xfs/xfs_rtalloc.c +8
-31+else +xfs_buf_relse (bp); +return error; +} +/* * Grow the realtime area of the filesystem. */ @@ -1236,7 +1264,6 @@ xfs_growfs_rt(xfs_rgnumber_t old_rgcount = mp->m_sb.sb_rgcount;xfs_rgnumber_t new_rgcount =1 ;xfs_rgnumber_t rgno; -struct xfs_buf *bp;xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize;int error;@@ -1273,15 +1300,10 @@ xfs_growfs_rt( error =xfs_sb_validate_fsb_count (&mp->m_sb, in->newblocks);if (error) goto out_unlock; -/* -* Read in the last block of the device, make sure it exists. -*/ - error =xfs_buf_read_uncached (mp->m_rtdev_targp, -XFS_FSB_TO_BB (mp, in->newblocks -1 ), -XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); + + error =xfs_rt_check_size (mp, in->newblocks -1 );if (error) goto out_unlock; -xfs_buf_relse (bp);/* * Calculate new parameters. These are the final values to be reached. @@ -1408,10 +1430,6 @@ int /* error */xfs_rtmount_init ( struct xfs_mount *mp) /* file system mount structure */ { -struct xfs_buf *bp;/* buffer for last block of subvolume */ -xfs_daddr_t d;/* address of last block of subvolume */ -int error; -if (mp->m_sb.sb_rblocks ==0 )return 0 ;if (mp->m_rtdev_targp ==NULL ) {@@ -1422,25 +1440,7 @@ xfs_rtmount_init( mp->m_rsumblocks =xfs_rtsummary_blockcount (mp, &mp->m_rsumlevels); -/* -* Check that the realtime section is an ok size. -*/ - d = (xfs_daddr_t )XFS_FSB_TO_BB (mp, mp->m_sb.sb_rblocks); -if (XFS_BB_TO_FSB (mp, d) != mp->m_sb.sb_rblocks) { -xfs_warn (mp,"realtime mount -- %llu != %llu" , - (unsigned long long )XFS_BB_TO_FSB (mp, d), - (unsigned long long ) mp->m_sb.sb_rblocks); -return -EFBIG ; - } - error =xfs_buf_read_uncached (mp->m_rtdev_targp, - d -XFS_FSB_TO_BB (mp,1 ), -XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); -if (error) { -xfs_warn (mp,"realtime device size check failed" ); -return error; - } -xfs_buf_relse (bp); -return 0 ; +return xfs_rt_check_size (mp, mp->m_sb.sb_rblocks -1 ); } static intSignature · 1 line
2.45.2
Re: [PATCH 1/3] xfs: factor out a xfs_rt_check_size helper
Quoted 9 lines · Darrick J. Wong
fs/xfs/xfs_rtalloc.c xfs_grow_last_rtg( · line 1250
Quoted 5 lines
fs/xfs/xfs_rtalloc.c +5
-0+ error =xfs_buf_read_uncached (mp->m_rtdev_targp, daddr, +XFS_FSB_TO_BB (mp,1 ),0 , &bp,NULL ); +if (error) +xfs_warn (mp,"cannot read last RT device block (%lld)" , + last_block);"cannot read last RT device sector"? Something to hint that the units are 512b blocks, not fsblocks? This is certainly better than the old message. :)
Sure.
Quoted 2 lines
Also, should there be a similar function to handle the last datadev read that mount and growfs perform?
I'll take a look.
PATCH 2/3 xfs: use the proper conversion helpers in xfs_rt_check_size
In reply to Christoph HellwigUse the proper helpers to deal with sparse rtbno encoding.
--- fs/xfs/xfs_rtalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_rtalloc.c +3 -3
@@ -1233,13 +1233,13 @@ xfs_rt_check_size( struct xfs_mount *mp, xfs_rfsblock_t last_block) { -xfs_daddr_t daddr =XFS_FSB_TO_BB (mp, last_block); +xfs_daddr_t daddr =xfs_rtb_to_daddr (mp, last_block);struct xfs_buf *bp;int error; -if (XFS_BB_TO_FSB (mp, daddr) != last_block) { +if (xfs_daddr_to_rtb (mp, daddr) != last_block) {xfs_warn (mp,"RT device size overflow: %llu != %llu" , -XFS_BB_TO_FSB (mp, daddr), last_block); +xfs_daddr_to_rtb (mp, daddr), last_block);return -EFBIG ; }
Signature · 1 line
2.45.2
Re: [PATCH 2/3] xfs: use the proper conversion helpers in xfs_rt_check_size
Quoted 12 lines · Christoph Hellwig
Use the proper helpers to deal with sparse rtbno encoding.
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_rtalloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/xfs/xfs_rtalloc.c +0
-0
fs/xfs/xfs_rtalloc.c xfs_rt_check_size( · line 1240
Quoted 10 lines
fs/xfs/xfs_rtalloc.c +2
-2@@ -1233,13 +1233,13 @@ xfs_rt_check_size( struct xfs_mount *mp, xfs_rfsblock_t last_block) { -xfs_daddr_t daddr =XFS_FSB_TO_BB (mp, last_block); +xfs_daddr_t daddr =xfs_rtb_to_daddr (mp, last_block);struct xfs_buf *bp;int error; -if (XFS_BB_TO_FSB (mp, daddr) != last_block) { +if (xfs_daddr_to_rtb (mp, daddr) != last_block) {
Er... this converts the daddr to a segmented xfs_rtblock_t type, but last_block is a non segmented xfs_rfsblock_t type. You can't compare the two directly. I think the code was correct without this patch.
--D
Quoted 10 lines
fs/xfs/xfs_rtalloc.c +1
-1xfs_warn (mp,"RT device size overflow: %llu != %llu" , -XFS_BB_TO_FSB (mp, daddr), last_block); +xfs_daddr_to_rtb (mp, daddr), last_block);return -EFBIG ; }Signature · 1 line
2.45.2
Re: [PATCH 2/3] xfs: use the proper conversion helpers in xfs_rt_check_size
Quoted 11 lines · Darrick J. Wong
fs/xfs/xfs_rtalloc.c xfs_rt_check_size( · line 1240
Quoted 7 lines
fs/xfs/xfs_rtalloc.c +2
-2-xfs_daddr_t daddr =XFS_FSB_TO_BB (mp, last_block); +xfs_daddr_t daddr =xfs_rtb_to_daddr (mp, last_block);struct xfs_buf *bp;int error; -if (XFS_BB_TO_FSB (mp, daddr) != last_block) { +if (xfs_daddr_to_rtb (mp, daddr) != last_block) {Er... this converts the daddr to a segmented
xfs_rtblock_ttype, butlast_blockis a non segmentedxfs_rfsblock_ttype. You can't compare the two directly. I think the code was correct without this patch.
Hmm. Yeah, it just breaks the other things I'm about to overload xfs_rtb_to_daddr/xfs_daddr_to_rtb with.. Time for even more helpers probably..
PATCH 3/3 xfs: don't call xfs_bmap_same_rtgroup in xfs_bmap_add_extent_hole_delay
In reply to Christoph Hellwigxfs_bmap_add_extent_hole_delay works entirely on delalloc extents, for which xfs_bmap_same_rtgroup doesn't make sense.
--- fs/xfs/libxfs/xfs_bmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +2 -4
@@ -2620,8 +2620,7 @@ xfs_bmap_add_extent_hole_delay(*/ if ((state &BMAP_LEFT_VALID ) && (state &BMAP_LEFT_DELAY ) && left.br_startoff + left.br_blockcount == new->br_startoff && - left.br_blockcount + new->br_blockcount <=XFS_MAX_BMBT_EXTLEN && -xfs_bmap_same_rtgroup (ip, whichfork, &left, new)) + left.br_blockcount + new->br_blockcount <=XFS_MAX_BMBT_EXTLEN ) state |=BMAP_LEFT_CONTIG ; if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) &&
@@ -2629,8 +2628,7 @@ xfs_bmap_add_extent_hole_delay( new->br_blockcount + right.br_blockcount <=XFS_MAX_BMBT_EXTLEN && (!(state &BMAP_LEFT_CONTIG ) || (left.br_blockcount + new->br_blockcount + - right.br_blockcount <=XFS_MAX_BMBT_EXTLEN )) && - xfs_bmap_same_rtgroup(ip, whichfork, new, &right)) + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN))) state |= BMAP_RIGHT_CONTIG;/*
Signature · 1 line
2.45.2
Re: [PATCH 3/3] xfs: don't call xfs_bmap_same_rtgroup in xfs_bmap_add_extent_hole_delay
Quoted 4 lines · Christoph Hellwig
xfs_bmap_add_extent_hole_delayworks entirely on delalloc extents, for whichxfs_bmap_same_rtgroupdoesn't make sense.Signed-off-by Christoph Hellwig <[email protected]>
Oooooops :(
--D
Quoted 32 lines
--- fs/xfs/libxfs/xfs_bmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/xfs/libxfs/xfs_bmap.c +2
-4@@ -2620,8 +2620,7 @@ xfs_bmap_add_extent_hole_delay(*/ if ((state &BMAP_LEFT_VALID ) && (state &BMAP_LEFT_DELAY ) && left.br_startoff + left.br_blockcount == new->br_startoff && - left.br_blockcount + new->br_blockcount <=XFS_MAX_BMBT_EXTLEN && -xfs_bmap_same_rtgroup (ip, whichfork, &left, new)) + left.br_blockcount + new->br_blockcount <=XFS_MAX_BMBT_EXTLEN ) state |=BMAP_LEFT_CONTIG ; if ((state & BMAP_RIGHT_VALID) && (state & BMAP_RIGHT_DELAY) &&@@ -2629,8 +2628,7 @@ xfs_bmap_add_extent_hole_delay( new->br_blockcount + right.br_blockcount <=XFS_MAX_BMBT_EXTLEN && (!(state &BMAP_LEFT_CONTIG ) || (left.br_blockcount + new->br_blockcount + - right.br_blockcount <=XFS_MAX_BMBT_EXTLEN )) && - xfs_bmap_same_rtgroup(ip, whichfork, new, &right)) + right.br_blockcount <= XFS_MAX_BMBT_EXTLEN))) state |= BMAP_RIGHT_CONTIG;/* Signature · 1 line
2.45.2