Skip to content

Commit 4415965

Browse files
Shida Zhangdchinner
authored andcommitted
xfs: trim the mapp array accordingly in xfs_da_grow_inode_int
Take a look at the for-loop in xfs_da_grow_inode_int: ====== for(){ nmap = min(XFS_BMAP_MAX_NMAP, count); ... error = xfs_bmapi_write(...,&mapp[mapi], &nmap);//(..., $1, $2) ... mapi += nmap; } ===== where $1 stands for the start address of the array, while $2 is used to indicate the size of the array. The array $1 will advance by $nmap in each iteration after the allocation of extents. But the size $2 still remains unchanged, which is determined by min(XFS_BMAP_MAX_NMAP, count). It seems that it has forgotten to trim the mapp array after each iteration, so change it. Signed-off-by: Shida Zhang <zhangshida@kylinos.cn> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Dave Chinner <david@fromorbit.com>
1 parent dc25641 commit 4415965

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/xfs/libxfs/xfs_da_btree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2192,8 +2192,8 @@ xfs_da_grow_inode_int(
21922192
*/
21932193
mapp = kmem_alloc(sizeof(*mapp) * count, 0);
21942194
for (b = *bno, mapi = 0; b < *bno + count; ) {
2195-
nmap = min(XFS_BMAP_MAX_NMAP, count);
21962195
c = (int)(*bno + count - b);
2196+
nmap = min(XFS_BMAP_MAX_NMAP, c);
21972197
error = xfs_bmapi_write(tp, dp, b, c,
21982198
xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
21992199
args->total, &mapp[mapi], &nmap);

0 commit comments

Comments
 (0)