Commit e220e905 authored by Shida Zhang's avatar Shida Zhang Committed by Long Li
Browse files

xfs: trim the mapp array accordingly in xfs_da_grow_inode_int

mainline inclusion
from mainline-v6.0-rc6
commit 44159659
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I76JSK
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=44159659df8ca381b84261e11058b2176fa03ba0



--------------------------------

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: default avatarShida Zhang <zhangshida@kylinos.cn>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 563f881c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment