Skip to content

Commit 9d06960

Browse files
Christoph HellwigChandan Babu R
authored andcommitted
xfs: don't open code XFS_FILBLKS_MIN in xfs_bmapi_write
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 <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 04c609e commit 9d06960

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,14 +4528,11 @@ xfs_bmapi_write(
45284528
* allocation length request (which can be 64 bits in
45294529
* length) and the bma length request, which is
45304530
* xfs_extlen_t and therefore 32 bits. Hence we have to
4531-
* check for 32-bit overflows and handle them here.
4531+
* be careful and do the min() using the larger type to
4532+
* avoid overflows.
45324533
*/
4533-
if (len > (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN)
4534-
bma.length = XFS_MAX_BMBT_EXTLEN;
4535-
else
4536-
bma.length = len;
4534+
bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN);
45374535

4538-
ASSERT(len > 0);
45394536
ASSERT(bma.length > 0);
45404537
error = xfs_bmapi_allocate(&bma);
45414538
if (error) {

0 commit comments

Comments
 (0)