Document update
[ct-quota-pq.git] / quota-add-dquot_id.patch
blobff885cbdad9c139b33d89d5b412bb07693a83d11
1 quota: introduce get_id callback
3 During some quota oparations we have to determine quota_id for given inode
4 according to quota_type. But only USRQUOTA/GRPQUOTA id are intermediately
5 accessible from generic vfs-inode. This patch introduce new per_sb quota
6 operation for this purpose.
9 diff --git a/fs/ext3/super.c b/fs/ext3/super.c
10 index 3d2e0ce..5d5a83d 100644
11 --- a/fs/ext3/super.c
12 +++ b/fs/ext3/super.c
13 @@ -727,6 +727,7 @@ static const struct dquot_operations ext3_quota_operations = {
14 .free_space = dquot_free_space,
15 .free_inode = dquot_free_inode,
16 .transfer = dquot_transfer,
17 + .get_id = dquot_get_id,
18 .write_dquot = ext3_write_dquot,
19 .acquire_dquot = ext3_acquire_dquot,
20 .release_dquot = ext3_release_dquot,
21 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
22 index 7c4b742..75a291a 100644
23 --- a/fs/ext4/super.c
24 +++ b/fs/ext4/super.c
25 @@ -996,6 +996,7 @@ static const struct dquot_operations ext4_quota_operations = {
26 .free_space = dquot_free_space,
27 .free_inode = dquot_free_inode,
28 .transfer = dquot_transfer,
29 + .get_id = dquot_get_id,
30 .write_dquot = ext4_write_dquot,
31 .acquire_dquot = ext4_acquire_dquot,
32 .release_dquot = ext4_release_dquot,
33 diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
34 index b437dc0..1ede78f 100644
35 --- a/fs/ocfs2/quota_global.c
36 +++ b/fs/ocfs2/quota_global.c
37 @@ -858,6 +858,7 @@ const struct dquot_operations ocfs2_quota_operations = {
38 .free_space = dquot_free_space,
39 .free_inode = dquot_free_inode,
40 .transfer = dquot_transfer,
41 + .get_id = dquot_get_id,
42 .write_dquot = ocfs2_write_dquot,
43 .acquire_dquot = ocfs2_acquire_dquot,
44 .release_dquot = ocfs2_release_dquot,
45 diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
46 index 9e51459..13503af 100644
47 --- a/fs/quota/dquot.c
48 +++ b/fs/quota/dquot.c
49 @@ -1287,6 +1287,21 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
50 return QUOTA_NL_BHARDBELOW;
51 return QUOTA_NL_NOWARN;
54 +qid_t dquot_get_id(struct inode *inode, int type)
56 + switch (type) {
57 + case USRQUOTA:
58 + return inode->i_uid;
59 + case GRPQUOTA:
60 + return inode->i_gid;
61 + default:
62 + //// XXX: BUG or WARN ?
63 + BUG();
64 + }
66 +EXPORT_SYMBOL(dquot_get_id);
69 * Initialize quota pointers in inode
70 * We do things in a bit complicated way but by that we avoid calling
71 @@ -1308,14 +1323,9 @@ int dquot_initialize(struct inode *inode, int type)
72 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
73 if (type != -1 && cnt != type)
74 continue;
75 - switch (cnt) {
76 - case USRQUOTA:
77 - id = inode->i_uid;
78 - break;
79 - case GRPQUOTA:
80 - id = inode->i_gid;
81 - break;
82 - }
83 + if (!sb_has_quota_active(sb, cnt))
84 + continue;
85 + id = inode->i_sb->dq_op->get_id(inode, cnt);
86 got[cnt] = dqget(sb, id, cnt);
89 @@ -1855,6 +1865,7 @@ const struct dquot_operations dquot_operations = {
90 .free_space = dquot_free_space,
91 .free_inode = dquot_free_inode,
92 .transfer = dquot_transfer,
93 + .get_id = dquot_get_id,
94 .write_dquot = dquot_commit,
95 .acquire_dquot = dquot_acquire,
96 .release_dquot = dquot_release,
97 diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
98 index f0ad05f..fd92ac3 100644
99 --- a/fs/reiserfs/super.c
100 +++ b/fs/reiserfs/super.c
101 @@ -620,6 +620,7 @@ static const struct dquot_operations reiserfs_quota_operations = {
102 .free_space = dquot_free_space,
103 .free_inode = dquot_free_inode,
104 .transfer = dquot_transfer,
105 + .get_id = dquot_get_id,
106 .write_dquot = reiserfs_write_dquot,
107 .acquire_dquot = reiserfs_acquire_dquot,
108 .release_dquot = reiserfs_release_dquot,
109 diff --git a/include/linux/quota.h b/include/linux/quota.h
110 index 09c52b9..f279c51 100644
111 --- a/include/linux/quota.h
112 +++ b/include/linux/quota.h
113 @@ -301,6 +301,7 @@ struct dquot_operations {
114 int (*free_inode) (const struct inode *, qsize_t);
115 int (*transfer) (struct inode *, qid_t *, unsigned long);
116 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
117 + qid_t (*get_id)(struct inode *, int); /* Quota id for given type */
118 struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot */
119 void (*destroy_dquot)(struct dquot *); /* Free memory for dquot */
120 int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
121 diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
122 index 6554348..b194878 100644
123 --- a/include/linux/quotaops.h
124 +++ b/include/linux/quotaops.h
125 @@ -26,6 +26,7 @@ static inline void writeout_quota_sb(struct super_block *sb, int type)
126 sb->s_qcop->quota_sync(sb, type);
129 +qid_t dquot_get_id(struct inode *inode, int type);
130 int dquot_initialize(struct inode *inode, int type);
131 int dquot_drop(struct inode *inode);
132 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);