summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_icache.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-08-30 15:45:05 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2019-10-19 10:39:11 -0700
commit99117c70e1e95d6b3a6017e7346c1a4355de888f (patch)
tree2011a6d97b8a5eea903dfa354b6f118206228519 /fs/xfs/xfs_icache.c
parent0eb7dd4e4e25147ec47adc54e30fda87d071ab27 (diff)
xfs: flush speculative space allocations when we run out of spacereclaim-space-harder_2019-10-19
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: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_icache.c')
-rw-r--r--fs/xfs/xfs_icache.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 6fc5cb54914f..b7f8ad93b14b 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -1524,6 +1524,15 @@ xfs_icache_free_eofblocks(
XFS_ICI_EOFBLOCKS_TAG);
}
+static inline void
+xfs_inode_free_scan(
+ struct xfs_mount *mp,
+ struct xfs_eofblocks *eofb)
+{
+ xfs_icache_free_eofblocks(mp, eofb);
+ xfs_icache_free_cowblocks(mp, eofb);
+}
+
/*
* Run cow/eofblocks scans on the quotas applicable to the inode. For inodes
* with multiple quotas, we don't know exactly which quota caused an allocation
@@ -1579,11 +1588,28 @@ xfs_inode_free_quota_blocks(
trace_xfs_inode_free_quota_blocks(ip->i_mount, &eofb, _RET_IP_);
- xfs_icache_free_eofblocks(ip->i_mount, &eofb);
- xfs_icache_free_cowblocks(ip->i_mount, &eofb);
+ xfs_inode_free_scan(ip->i_mount, &eofb);
return true;
}
+/*
+ * Try to free space in the filesystem by purging eofblocks and cowblocks.
+ */
+void
+xfs_inode_free_blocks(
+ struct xfs_mount *mp,
+ bool sync)
+{
+ struct xfs_eofblocks eofb = {0};
+
+ if (sync)
+ eofb.eof_flags |= XFS_EOF_FLAGS_SYNC;
+
+ trace_xfs_inode_free_blocks(mp, &eofb, _RET_IP_);
+
+ xfs_inode_free_scan(mp, &eofb);
+}
+
static inline unsigned long
xfs_iflag_for_tag(
int tag)