xfs: clean code for setting bma length in xfs_bmapi_write
PATCH 1/1 xfs: clean code for setting bma length in xfs_bmapi_write
From: Lei Chen <[email protected]>
xfs_bmapi_write may need alloc blocks when it encounters a hole or delay extent. When setting bma.length, it does not need comparing MAXEXTLEN and the length that the caller wants, because xfs_bmapi_allocate will handle every thing properly for bma.length.
--- fs/xfs/libxfs/xfs_bmap.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -12
@@ -4417,18 +4417,7 @@ struct xfs_iread_state { bma.wasdel = wasdelay; bma.offset = bno; bma.flags = flags; - -/* -* There's a 32/64 bit type mismatch between the -* 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. -*/ -if (len > (xfs_filblks_t )MAXEXTLEN ) - bma.length =MAXEXTLEN ; -else - bma.length = len; + bma.length = len;ASSERT (len >0 );ASSERT (bma.length >0 );
Signature · 1 line
1.8.3.1
Quoted 23 lines · On Sat, Dec 12, 2020 at 08:48:17PM +0800, [email protected] wrote:
From: Lei Chen <[email protected]>
xfs_bmapi_writemay need alloc blocks when it encounters a hole or delay extent. When setting bma.length, it does not need comparing MAXEXTLEN and the length that the caller wants, becausexfs_bmapi_allocatewill handle every thing properly for bma.length.Signed-off-by Lei Chen <[email protected]>--- fs/xfs/libxfs/xfs_bmap.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)fs/xfs/libxfs/xfs_bmap.c +0
-3@@ -4417,18 +4417,7 @@ struct xfs_iread_state { bma.wasdel = wasdelay; bma.offset = bno; bma.flags = flags; - -/* -* There's a 32/64 bit type mismatch between the
fs/xfs/libxfs/xfs_bmap.c struct xfs_iread_state { · line 4420
Quoted 10 lines
fs/xfs/libxfs/xfs_bmap.c +1
-9-* 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. -*/ -if (len > (xfs_filblks_t )MAXEXTLEN ) - bma.length =MAXEXTLEN ; -else - bma.length = len; + bma.length = len;
After refering to the definition of struct xfs_bmalloca, so I think bma.length is still a xfs_extlen_t ===> uint32_t, so I'm afraid the commit a99ebf43f49f ("xfs: fix allocation length overflow in xfs_bmapi_write()")
and the reason for adding this is still valid for now?
Thanks,
Gao Xiang