From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [RFC PATCH 4/4] xfs: add background scanning to clear EOFBLOCKS inodes
Date: Mon, 27 Aug 2012 15:51:51 -0400 [thread overview]
Message-ID: <1346097111-4476-5-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1346097111-4476-1-git-send-email-bfoster@redhat.com>
Create a delayed_work to enable background scanning and freeing
of EOFBLOCKS inodes. The scanner kicks in once speculative
preallocation occurs and stops requeueing itself when no EOFBLOCKS
inodes exist.
Scans are queued on the existing syncd workqueue and the interval
is tied to the syncd interval, which is a default of 30s. The
minimum file size for a background scan is hardcoded to 100MB.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_mount.h | 2 ++
fs/xfs/xfs_sync.c | 33 +++++++++++++++++++++++++++++++++
fs/xfs/xfs_sync.h | 3 +++
3 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index 05a05a7..a966bf4 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -204,6 +204,8 @@ typedef struct xfs_mount {
struct xfs_mru_cache *m_filestream; /* per-mount filestream data */
struct delayed_work m_sync_work; /* background sync work */
struct delayed_work m_reclaim_work; /* background inode reclaim */
+ struct delayed_work m_eofblocks_work; /* background eof blocks
+ trimming */
struct work_struct m_flush_work; /* background inode flush */
__int64_t m_update_flags; /* sb flags we need to update
on the next remount,rw */
diff --git a/fs/xfs/xfs_sync.c b/fs/xfs/xfs_sync.c
index 27c3c46..bd1ca90 100644
--- a/fs/xfs/xfs_sync.c
+++ b/fs/xfs/xfs_sync.c
@@ -489,6 +489,34 @@ xfs_flush_worker(
xfs_sync_data(mp, SYNC_TRYLOCK | SYNC_WAIT);
}
+/*
+ * Background scanning to trim post-EOF preallocated space. This is queued
+ * based on the syncd tunable (30s by default).
+ *
+ * TODO: Do we want an independent tunable (and default.. off by default)?
+ */
+STATIC void
+xfs_queue_eofblocks(
+ struct xfs_mount *mp)
+{
+ rcu_read_lock();
+ if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_EOFBLOCKS_TAG))
+ queue_delayed_work(xfs_syncd_wq, &mp->m_eofblocks_work,
+ msecs_to_jiffies(xfs_syncd_centisecs * 10));
+ rcu_read_unlock();
+}
+
+STATIC void
+xfs_eofblocks_worker(
+ struct work_struct *work)
+{
+ struct xfs_mount *mp = container_of(to_delayed_work(work),
+ struct xfs_mount, m_eofblocks_work);
+ xfs_inodes_free_eofblocks(mp, XFS_DQ_PROJ, XFS_PROJID_DEFAULT,
+ XFS_EOFBLOCKS_DEFAULT_MINFILESIZE, 0);
+ xfs_queue_eofblocks(mp);
+}
+
int
xfs_syncd_init(
struct xfs_mount *mp)
@@ -496,6 +524,7 @@ xfs_syncd_init(
INIT_WORK(&mp->m_flush_work, xfs_flush_worker);
INIT_DELAYED_WORK(&mp->m_sync_work, xfs_sync_worker);
INIT_DELAYED_WORK(&mp->m_reclaim_work, xfs_reclaim_worker);
+ INIT_DELAYED_WORK(&mp->m_eofblocks_work, xfs_eofblocks_worker);
xfs_syncd_queue_sync(mp);
@@ -508,6 +537,7 @@ xfs_syncd_stop(
{
cancel_delayed_work_sync(&mp->m_sync_work);
cancel_delayed_work_sync(&mp->m_reclaim_work);
+ cancel_delayed_work_sync(&mp->m_eofblocks_work);
cancel_work_sync(&mp->m_flush_work);
}
@@ -1159,6 +1189,9 @@ __xfs_inode_set_eofblocks_tag(
XFS_ICI_EOFBLOCKS_TAG);
spin_unlock(&ip->i_mount->m_perag_lock);
+ /* kick off background trimming */
+ xfs_queue_eofblocks(ip->i_mount);
+
trace_xfs_perag_set_eofblocks(ip->i_mount, pag->pag_agno,
-1, _RET_IP_);
}
diff --git a/fs/xfs/xfs_sync.h b/fs/xfs/xfs_sync.h
index 78aca41..3ce8c3f 100644
--- a/fs/xfs/xfs_sync.h
+++ b/fs/xfs/xfs_sync.h
@@ -45,6 +45,9 @@ void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag,
#define EOFBLOCKS_WAIT 0x0001
+/* TODO: should we have a tunable? */
+#define XFS_EOFBLOCKS_DEFAULT_MINFILESIZE 1024 * 1024 * 100
+
void xfs_inode_set_eofblocks_tag(struct xfs_inode *ip);
void xfs_inode_clear_eofblocks_tag(struct xfs_inode *ip);
int xfs_inodes_free_eofblocks(struct xfs_mount *, int, uint32_t, uint64_t, int);
--
1.7.7.6
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-08-27 19:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-27 19:51 [RFC PATCH 0/4] xfs: add support for tracking inodes with post-EOF speculative preallocation Brian Foster
2012-08-27 19:51 ` [RFC PATCH 1/4] xfs: add EOFBLOCKS inode tagging/untagging Brian Foster
2012-09-03 4:20 ` Dave Chinner
2012-08-27 19:51 ` [RFC PATCH 2/4] xfs: create function to scan and clear EOFBLOCKS inodes Brian Foster
2012-09-03 5:06 ` Dave Chinner
2012-09-04 14:10 ` Brian Foster
2012-09-05 6:42 ` Dave Chinner
2012-09-05 12:22 ` Brian Foster
2012-08-27 19:51 ` [RFC PATCH 3/4] xfs: add FREE_EOFBLOCKS ioctl Brian Foster
2012-09-03 5:17 ` Dave Chinner
2012-09-04 14:10 ` Brian Foster
2012-09-05 6:49 ` Dave Chinner
2012-09-05 12:22 ` Brian Foster
2012-08-27 19:51 ` Brian Foster [this message]
2012-09-03 5:28 ` [RFC PATCH 4/4] xfs: add background scanning to clear EOFBLOCKS inodes Dave Chinner
2012-09-04 14:10 ` Brian Foster
2012-09-05 7:00 ` Dave Chinner
2012-09-05 12:22 ` Brian Foster
2012-09-05 23:43 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1346097111-4476-5-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox