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-09 09:39:23 -0700
commit700899d7c79c0ea916bc902100472c42ee577040 (patch)
tree5adb3d28a00d7e912824da4f712fbb447ed66abc /fs/xfs/xfs_icache.c
parent055f78e8d716546e7eeb3733cc40e564ff3e6cdc (diff)
xfs: flush speculative space allocations when we run out of spacereclaim-space-harder_2019-10-09
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)