diff mbox series

[2/3] xfs: use the proper conversion helpers in xfs_rt_check_size

Message ID 20241119154959.1302744-3-hch@lst.de (mailing list archive)
State New
Headers show
Series [1/3] xfs: factor out a xfs_rt_check_size helper | expand

Commit Message

Christoph Hellwig Nov. 19, 2024, 3:49 p.m. UTC
Use the proper helpers to deal with sparse rtbno encoding.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_rtalloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Darrick J. Wong Nov. 19, 2024, 4:21 p.m. UTC | #1
On Tue, Nov 19, 2024 at 04:49:48PM +0100, Christoph Hellwig wrote:
> Use the proper helpers to deal with sparse rtbno encoding.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_rtalloc.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
> index 90f4fdd47087..a991b750df81 100644
> --- a/fs/xfs/xfs_rtalloc.c
> +++ b/fs/xfs/xfs_rtalloc.c
> @@ -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

>  		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;
>  	}
>  
> -- 
> 2.45.2
> 
>
Christoph Hellwig Nov. 19, 2024, 4:23 p.m. UTC | #2
On Tue, Nov 19, 2024 at 08:21:42AM -0800, Darrick J. Wong wrote:
> > -	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.

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..
diff mbox series

Patch

diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 90f4fdd47087..a991b750df81 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -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;
 	}