提交 c354ad22 编写于 作者: C Chandan Babu R 提交者: Zheng Zengkai

xfs: Check for extent overflow when writing to unwritten extent

mainline inclusion
from mainline-v5.12-rc1
commit c442f308
category: bugfix
bugzilla: 187510,https://gitee.com/openeuler/kernel/issues/I4KIAO

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

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

A write to a sub-interval of an existing unwritten extent causes
the original extent to be split into 3 extents
i.e. | Unwritten | Real | Unwritten |
Hence extent count can increase by 2.
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NAllison Henderson <allison.henderson@oracle.com>
Signed-off-by: NChandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>

Conflict: commit 3a1af6c3 ("xfs: refactor common
transaction/inode/quota allocation idiom") is backported, which
introduce some conflicts on code context.
Signed-off-by: NYu Kuai <yukuai3@huawei.com>
Signed-off-by: NGuo Xuenan <guoxuenan@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 a1f6d467
......@@ -70,6 +70,15 @@ struct xfs_ifork {
#define XFS_IEXT_ATTR_MANIP_CNT(rmt_blks) \
(XFS_DA_NODE_MAXDEPTH + max(1, rmt_blks))
/*
* A write to a sub-interval of an existing unwritten extent causes the original
* extent to be split into 3 extents
* i.e. | Unwritten | Real | Unwritten |
* Hence extent count can increase by 2.
*/
#define XFS_IEXT_WRITE_UNWRITTEN_CNT (2)
/*
* Fork handling.
*/
......
......@@ -545,6 +545,10 @@ xfs_iomap_write_unwritten(
if (error)
return error;
error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
XFS_IEXT_WRITE_UNWRITTEN_CNT);
if (error)
goto error_on_bmapi_transaction;
/*
* Modify the unwritten extent state of the buffer.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册