]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.suse/quota-Add-callbacks-for-allocating-and-destroying-d.patch
Imported linux-2.6.27.39 suse/xen patches.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.suse / quota-Add-callbacks-for-allocating-and-destroying-d.patch
CommitLineData
2cb7cef9
BS
1From: Jan Kara <jack@suse.cz>
2References: fate#302681
3Subject: [PATCH 01/28] quota: Add callbacks for allocating and destroying dquot structures
4Patch-mainline: 2.6.29?
5
6Some filesystems would like to keep private information together with each
7dquot. Add callbacks alloc_dquot and destroy_dquot allowing filesystem to
8allocate larger dquots from their private slab in a similar fashion we
9currently allocate inodes.
10
11Signed-off-by: Jan Kara <jack@suse.cz>
12---
13 fs/dquot.c | 19 +++++++++++++++----
14 include/linux/quota.h | 2 ++
15 2 files changed, 17 insertions(+), 4 deletions(-)
16
17diff --git a/fs/dquot.c b/fs/dquot.c
18index 8ec4d6c..e1dac3e 100644
19--- a/fs/dquot.c
20+++ b/fs/dquot.c
21@@ -417,6 +417,14 @@ out_dqlock:
22 return ret;
23 }
24
25+static void destroy_dquot(struct dquot *dquot)
26+{
27+ if (dquot->dq_sb->dq_op->destroy_dquot)
28+ dquot->dq_sb->dq_op->destroy_dquot(dquot);
29+ else
30+ kmem_cache_free(dquot_cachep, dquot);
31+}
32+
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);
39 remove_inuse(dquot);
40- kmem_cache_free(dquot_cachep, dquot);
41+ destroy_dquot(dquot);
42 }
43 spin_unlock(&dq_list_lock);
44 }
45@@ -529,7 +537,7 @@ static void prune_dqcache(int count)
46 remove_dquot_hash(dquot);
47 remove_free_dquot(dquot);
48 remove_inuse(dquot);
49- kmem_cache_free(dquot_cachep, dquot);
50+ destroy_dquot(dquot);
51 count--;
52 head = free_dquots.prev;
53 }
54@@ -631,7 +639,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
55 {
56 struct dquot *dquot;
57
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);
61+ else
62+ dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
63 if(!dquot)
64 return NODQUOT;
65
66@@ -684,7 +695,7 @@ we_slept:
67 dqstats.lookups++;
68 spin_unlock(&dq_list_lock);
69 if (empty)
70- kmem_cache_free(dquot_cachep, empty);
71+ destroy_dquot(empty);
72 }
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 */
75diff --git a/include/linux/quota.h b/include/linux/quota.h
76index 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 */
88--
891.5.2.4
90