diff options
author | Christoph Hellwig <hch@lst.de> | 2024-04-29 08:15:24 +0200 |
---|---|---|
committer | Chandan Babu R <chandanbabu@kernel.org> | 2024-04-30 06:15:19 +0200 |
commit | 9d06960341ec5f45d3d65bdead3fbce753455e8a (patch) | |
tree | 767b84af6811fad905ecef85f52e6c4bfb5b9cc1 /fs/xfs | |
parent | xfs: lift a xfs_valid_startblock into xfs_bmapi_allocate (diff) | |
download | linux-9d06960341ec5f45d3d65bdead3fbce753455e8a.tar.xz linux-9d06960341ec5f45d3d65bdead3fbce753455e8a.zip |
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 <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index eade9689599f..6507dcaac438 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4528,14 +4528,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) { |