提交 d264b3cf 编写于 作者: D Darrick J. Wong 提交者: Zheng Zengkai

xfs: flush speculative space allocations when we run out of space

mainline-inclusion
from mainline-v5.11-rc4
commit a1a7d05a
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4KIAO
CVE: NA

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

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

If a fs modification (creation, file write, reflink, etc.) is unable to
reserve enough space to handle the modification, try clearing whatever
space the filesystem might have been hanging onto in the hopes of
speeding up the filesystem.  The flushing behavior will become
particularly important when we add deferred inode inactivation because
that will increase the amount of space that isn't actively tied to user
data.
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NBrian Foster <bfoster@redhat.com>
Signed-off-by: NLihong Kou <koulihong@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 d1d239ec
......@@ -289,6 +289,17 @@ xfs_trans_alloc(
tp->t_firstblock = NULLFSBLOCK;
error = xfs_trans_reserve(tp, resp, blocks, rtextents);
if (error == -ENOSPC) {
/*
* We weren't able to reserve enough space for the transaction.
* Flush the other speculative space allocations to free space.
* Do not perform a synchronous scan because callers can hold
* other locks.
*/
error = xfs_blockgc_free_space(mp, NULL);
if (!error)
error = xfs_trans_reserve(tp, resp, blocks, rtextents);
}
if (error) {
xfs_trans_cancel(tp);
return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册