]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: don't open code XFS_FILBLKS_MIN in xfs_bmapi_write
authorChristoph Hellwig <hch@lst.de>
Mon, 29 Jul 2024 23:22:55 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:04 +0000 (17:01 -0700)
Source kernel commit: 9d06960341ec5f45d3d65bdead3fbce753455e8a

XFS_FILBLKS_MIN uses min_t and thus does the comparison using the correct
xfs_filblks_t type.  Use it in xfs_bmapi_write and slightly adjust the
comment document th potential pitfall to take account of this

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
libxfs/xfs_bmap.c

index 5b1c305ec26714ba5ba45a3661034f9ac05d3109..87f0a28534b4ff6ecb53da81d8c5f8606aa47c58 100644 (file)
@@ -4522,14 +4522,11 @@ xfs_bmapi_write(
                         * allocation length request (which can be 64 bits in
                         * length) and the bma length request, which is
                         * xfs_extlen_t and therefore 32 bits. Hence we have to
-                        * check for 32-bit overflows and handle them here.
+                        * be careful and do the min() using the larger type to
+                        * avoid overflows.
                         */
-                       if (len > (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN)
-                               bma.length = XFS_MAX_BMBT_EXTLEN;
-                       else
-                               bma.length = len;
+                       bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN);
 
-                       ASSERT(len > 0);
                        ASSERT(bma.length > 0);
                        error = xfs_bmapi_allocate(&bma);
                        if (error) {