1 From: Jan Kara <jack@suse.cz>
2 References: fate#302681
3 Subject: [PATCH 17/28] quota: Implement function for scanning active dquots
4 Patch-mainline: 2.6.29?
6 OCFS2 needs to scan all active dquots once in a while and sync quota
7 information among cluster nodes. Provide a helper function for it so
8 that it does not have to reimplement internally a list which VFS
9 already has. Moreover this function is probably going to be useful
10 for other clustered filesystems if they decide to use VFS quotas.
12 Signed-off-by: Jan Kara <jack@suse.cz>
14 fs/dquot.c | 36 ++++++++++++++++++++++++++++++++++++
15 include/linux/quotaops.h | 3 +++
16 2 files changed, 39 insertions(+), 0 deletions(-)
18 diff --git a/fs/dquot.c b/fs/dquot.c
19 index 9fb1d71..6a17416 100644
22 @@ -476,6 +476,41 @@ restart:
23 spin_unlock(&dq_list_lock);
26 +/* Call callback for every active dquot on given filesystem */
27 +int dquot_scan_active(struct super_block *sb,
28 + int (*fn)(struct dquot *dquot, unsigned long priv),
31 + struct dquot *dquot, *old_dquot = NULL;
34 + mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
35 + spin_lock(&dq_list_lock);
36 + list_for_each_entry(dquot, &inuse_list, dq_inuse) {
37 + if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
39 + if (dquot->dq_sb != sb)
41 + /* Now we have active dquot so we can just increase use count */
42 + atomic_inc(&dquot->dq_count);
44 + spin_unlock(&dq_list_lock);
47 + ret = fn(dquot, priv);
50 + spin_lock(&dq_list_lock);
51 + /* We are safe to continue now because our dquot could not
52 + * be moved out of the inuse list while we hold the reference */
54 + spin_unlock(&dq_list_lock);
57 + mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
61 int vfs_quota_sync(struct super_block *sb, int type)
63 struct list_head *dirty;
64 @@ -2316,6 +2351,7 @@ EXPORT_SYMBOL(vfs_quota_on_path);
65 EXPORT_SYMBOL(vfs_quota_on_mount);
66 EXPORT_SYMBOL(vfs_quota_disable);
67 EXPORT_SYMBOL(vfs_quota_off);
68 +EXPORT_SYMBOL(dquot_scan_active);
69 EXPORT_SYMBOL(vfs_quota_sync);
70 EXPORT_SYMBOL(vfs_get_dqinfo);
71 EXPORT_SYMBOL(vfs_set_dqinfo);
72 diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
73 index 1f990f2..f2147eb 100644
74 --- a/include/linux/quotaops.h
75 +++ b/include/linux/quotaops.h
76 @@ -31,6 +31,9 @@ int dquot_drop_locked(struct inode *inode);
77 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
78 void dqput(struct dquot *dquot);
79 int dquot_is_cached(struct super_block *sb, unsigned int id, int type);
80 +int dquot_scan_active(struct super_block *sb,
81 + int (*fn)(struct dquot *dquot, unsigned long priv),
82 + unsigned long priv);
84 int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
85 int dquot_alloc_inode(const struct inode *inode, qsize_t number);