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

xfs: flush eof/cowblocks if we can't reserve quota for file blocks

mainline-inclusion
from mainline-v5.11-rc4
commit 766aabd5
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=766aabd59929cd05fc1a249f376e4395bed93d30

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

If a fs modification (data write, reflink, xattr set, fallocate, etc.)
is unable to reserve enough quota 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>
上级 88fc0153
......@@ -1086,6 +1086,11 @@ xfs_reflink_remap_extent(
* count. This is suboptimal, but the VFS flushed the dest range
* before we started. That should have removed all the delalloc
* reservations, but we code defensively.
*
* xfs_trans_alloc_inode above already tried to grab an even larger
* quota reservation, and kicked off a blockgc scan if it couldn't.
* If we can't get a potentially smaller quota reservation now, we're
* done.
*/
if (!quota_reserved && !smap_real && dmap_written) {
error = xfs_trans_reserve_quota_nblks(tp, ip,
......
......@@ -23,6 +23,7 @@
#include "xfs_inode.h"
#include "xfs_dquot_item.h"
#include "xfs_dquot.h"
#include "xfs_icache.h"
kmem_zone_t *xfs_trans_zone;
......@@ -1042,8 +1043,10 @@ xfs_trans_alloc_inode(
{
struct xfs_trans *tp;
struct xfs_mount *mp = ip->i_mount;
bool retried = false;
int error;
retry:
error = xfs_trans_alloc(mp, resv, dblocks,
rblocks / mp->m_sb.sb_rextsize,
force ? XFS_TRANS_RESERVE : 0, &tp);
......@@ -1061,6 +1064,13 @@ xfs_trans_alloc_inode(
}
error = xfs_trans_reserve_quota_nblks(tp, ip, dblocks, rblocks, force);
if ((error == -EDQUOT || error == -ENOSPC) && !retried) {
xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL);
xfs_blockgc_free_quota(ip, 0);
retried = true;
goto retry;
}
if (error)
goto out_cancel;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册