1 From: Jan Kara <jack@suse.cz>
2 References: fate#302681
3 Subject: [PATCH 01/28] quota: Add callbacks for allocating and destroying dquot structures
4 Patch-mainline: 2.6.29?
6 Some filesystems would like to keep private information together with each
7 dquot. Add callbacks alloc_dquot and destroy_dquot allowing filesystem to
8 allocate larger dquots from their private slab in a similar fashion we
9 currently allocate inodes.
11 Signed-off-by: Jan Kara <jack@suse.cz>
13 fs/dquot.c | 19 +++++++++++++++----
14 include/linux/quota.h | 2 ++
15 2 files changed, 17 insertions(+), 4 deletions(-)
17 diff --git a/fs/dquot.c b/fs/dquot.c
18 index 8ec4d6c..e1dac3e 100644
21 @@ -417,6 +417,14 @@ out_dqlock:
25 +static void destroy_dquot(struct dquot *dquot)
27 + if (dquot->dq_sb->dq_op->destroy_dquot)
28 + dquot->dq_sb->dq_op->destroy_dquot(dquot);
30 + kmem_cache_free(dquot_cachep, dquot);
33 /* Invalidate all dquots on the list. Note that this function is called after
34 * quota is disabled and pointers from inodes removed so there cannot be new
35 * quota users. There can still be some users of quotas due to inodes being
36 @@ -465,7 +473,7 @@ restart:
37 remove_dquot_hash(dquot);
38 remove_free_dquot(dquot);
40 - kmem_cache_free(dquot_cachep, dquot);
41 + destroy_dquot(dquot);
43 spin_unlock(&dq_list_lock);
45 @@ -529,7 +537,7 @@ static void prune_dqcache(int count)
46 remove_dquot_hash(dquot);
47 remove_free_dquot(dquot);
49 - kmem_cache_free(dquot_cachep, dquot);
50 + destroy_dquot(dquot);
52 head = free_dquots.prev;
54 @@ -631,7 +639,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
58 - dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
59 + if (sb->dq_op->alloc_dquot)
60 + dquot = sb->dq_op->alloc_dquot(sb, type);
62 + dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
66 @@ -684,7 +695,7 @@ we_slept:
68 spin_unlock(&dq_list_lock);
70 - kmem_cache_free(dquot_cachep, empty);
71 + destroy_dquot(empty);
73 /* Wait for dq_lock - after this we know that either dquot_release() is already
74 * finished or it will be canceled due to dq_count > 1 test */
75 diff --git a/include/linux/quota.h b/include/linux/quota.h
76 index 376a050..eeae7a9 100644
77 --- a/include/linux/quota.h
78 +++ b/include/linux/quota.h
79 @@ -294,6 +294,8 @@ struct dquot_operations {
80 int (*free_inode) (const struct inode *, unsigned long);
81 int (*transfer) (struct inode *, struct iattr *);
82 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
83 + struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot (can be NULL if no special entries dquot are needed) */
84 + void (*destroy_dquot)(struct dquot *); /* Free memory for dquot (can be NULL if alloc_dquot is NULL) */
85 int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
86 int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
87 int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */