From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 8/8] xfs: add a shrinker for quotacheck
Date: Fri, 2 Mar 2012 15:11:47 +1100 [thread overview]
Message-ID: <1330661507-1121-9-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1330661507-1121-1-git-send-email-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
From: Dave Chinner <dchinner@redhat.com>
Whenthe filesystem is mounting, the superblock based shrinker cannot run due to
the mount process holding the sb->s_umount lock exclusively. Hence when
quotacheck runs, it cannot shrink the inode cache if it grows too large. We've
had repeated problems with the inode cache shrinker startup and quotacheck
resulting in OOM conditions.
Avoid this problem altogether by installing a quotacheck specific inode cache
shrinker that is registered before the quotacheck starts, and is then
unregistered after the quotacheck finishes. This shrinker uses exactly the same
infrastructure as the superblock based inode cache shrinker, so there is very
little extra code.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_qm.c | 28 ++++++++++++++++++++++++++++
fs/xfs/xfs_qm.h | 2 ++
2 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index c872fea..c1a42f1 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -823,6 +823,7 @@ xfs_qm_init_quotainfo(
return error;
}
+ qinf->qi_mount = mp;
INIT_LIST_HEAD(&qinf->qi_dqlist);
mutex_init(&qinf->qi_dqlist_lock);
lockdep_set_class(&qinf->qi_dqlist_lock, &xfs_quota_mplist_class);
@@ -1398,6 +1399,26 @@ error0:
}
/*
+ * quotacheck specific shrinker. This is only active while quotacheck is in
+ * progress as the superblock shrinker won't run until the mount completes and
+ * drops the sb->s_umount lock.
+ */
+static int
+xfs_qm_quotacheck_shrink(
+ struct shrinker *shr,
+ struct shrink_control *sc)
+{
+ struct xfs_quotainfo *qi = container_of(shr, struct xfs_quotainfo,
+ qi_shrinker);
+ if (!(sc->gfp_mask & __GFP_FS))
+ return -1;
+ if (sc->nr_to_scan)
+ xfs_reclaim_inodes_nr(qi->qi_mount, sc->nr_to_scan);
+
+ return xfs_reclaim_inodes_count(qi->qi_mount);
+}
+
+/*
* Walk thru all the filesystem inodes and construct a consistent view
* of the disk quota world. If the quotacheck fails, disable quotas.
*/
@@ -1410,6 +1431,7 @@ xfs_qm_quotacheck(
size_t structsz;
xfs_inode_t *uip, *gip;
uint flags;
+ struct xfs_quotainfo *qi = mp->m_quotainfo;
count = INT_MAX;
structsz = 1;
@@ -1427,6 +1449,11 @@ xfs_qm_quotacheck(
xfs_notice(mp, "Quotacheck needed: Please wait.");
+ qi->qi_shrinker.seeks = DEFAULT_SEEKS;
+ qi->qi_shrinker.shrink = xfs_qm_quotacheck_shrink;
+ qi->qi_shrinker.batch = 1024;
+ register_shrinker(&qi->qi_shrinker);
+
/*
* First we go thru all the dquots on disk, USR and GRP/PRJ, and reset
* their counters to zero. We need a clean slate.
@@ -1500,6 +1527,7 @@ xfs_qm_quotacheck(
mp->m_qflags |= flags;
error_return:
+ unregister_shrinker(&qi->qi_shrinker);
if (error) {
xfs_warn(mp,
"Quotacheck: Unsuccessful (Error %d): Disabling quotas.",
diff --git a/fs/xfs/xfs_qm.h b/fs/xfs/xfs_qm.h
index 9a9b997..9ee7990 100644
--- a/fs/xfs/xfs_qm.h
+++ b/fs/xfs/xfs_qm.h
@@ -73,6 +73,8 @@ typedef struct xfs_qm {
typedef struct xfs_quotainfo {
xfs_inode_t *qi_uquotaip; /* user quota inode */
xfs_inode_t *qi_gquotaip; /* group quota inode */
+ struct xfs_mount *qi_mount;
+ struct shrinker qi_shrinker;
struct list_head qi_dqlist; /* all dquots in filesys */
struct mutex qi_dqlist_lock;
int qi_dquots;
--
1.7.9
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-03-02 4:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 4:11 [PATCH 0/8] xfs: bug fixes for 3.4 Dave Chinner
2012-03-02 4:11 ` [PATCH 1/8] xfs: clean up minor sparse warnings Dave Chinner
2012-03-02 7:46 ` Christoph Hellwig
2012-03-02 7:59 ` Dave Chinner
2012-03-02 4:11 ` [PATCH 2/8] xfs: Fix open flag handling in open_by_handle code Dave Chinner
2012-03-02 7:47 ` Christoph Hellwig
2012-03-02 4:11 ` [PATCH 3/8] xfs: handle kmalloc failure when reading attrs Dave Chinner
2012-03-02 7:49 ` Christoph Hellwig
2012-03-02 9:49 ` Dave Chinner
2012-03-02 10:31 ` Christoph Hellwig
2012-03-02 4:11 ` [PATCH 4/8] xfs: avoid memory allocation failures in xfs_getbmap Dave Chinner
2012-03-02 7:49 ` Christoph Hellwig
2012-03-02 4:11 ` [PATCH 5/8] xfs: introduce an allocation workqueue Dave Chinner
2012-03-02 4:11 ` [PATCH 6/8] xfs: remove remaining scraps of struct xfs_iomap Dave Chinner
2012-03-02 4:11 ` [PATCH 7/8] xfs: fix inode lookup race Dave Chinner
2012-03-02 4:11 ` Dave Chinner [this message]
2012-03-02 7:51 ` [PATCH 8/8] xfs: add a shrinker for quotacheck Christoph Hellwig
2012-03-02 10:04 ` Dave Chinner
2012-03-02 10:38 ` Christoph Hellwig
2012-03-02 11:14 ` Christoph Hellwig
2012-03-05 1:49 ` 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=1330661507-1121-9-git-send-email-david@fromorbit.com \
--to=david@fromorbit.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