diff options
author | Jan Kara <jack@suse.cz> | 2008-10-02 12:44:14 -0400 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:40:21 -0500 |
commit | e3d4d56b9715e40ded2a84d0d4fa7f3b6c58983c (patch) | |
tree | 67648a89b3c9056d77caa6ef42776cf1053c5e70 | |
parent | 1ccd14b9c271c1ac6eec5c5ec5def433100e7248 (diff) |
quota: Convert union in mem_dqinfo to a pointer
Coming quota support for OCFS2 is going to need quite a bit
of additional per-sb quota information. Moreover having fs.h
include all the types needed for this structure would be a
pain in the a**. So remove the union from mem_dqinfo and add
a private pointer for filesystem's use.
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r-- | fs/quota_v2.c | 53 | ||||
-rw-r--r-- | include/linux/dqblk_v1.h | 4 | ||||
-rw-r--r-- | include/linux/dqblk_v2.h | 4 | ||||
-rw-r--r-- | include/linux/quota.h | 5 |
4 files changed, 35 insertions, 31 deletions
diff --git a/fs/quota_v2.c b/fs/quota_v2.c index a87f1028a425..b618b563635c 100644 --- a/fs/quota_v2.c +++ b/fs/quota_v2.c | |||
@@ -71,6 +71,7 @@ static int v2_read_file_info(struct super_block *sb, int type) | |||
71 | { | 71 | { |
72 | struct v2_disk_dqinfo dinfo; | 72 | struct v2_disk_dqinfo dinfo; |
73 | struct mem_dqinfo *info = sb_dqinfo(sb, type); | 73 | struct mem_dqinfo *info = sb_dqinfo(sb, type); |
74 | struct qtree_mem_dqinfo *qinfo; | ||
74 | ssize_t size; | 75 | ssize_t size; |
75 | 76 | ||
76 | size = sb->s_op->quota_read(sb, type, (char *)&dinfo, | 77 | size = sb->s_op->quota_read(sb, type, (char *)&dinfo, |
@@ -80,22 +81,29 @@ static int v2_read_file_info(struct super_block *sb, int type) | |||
80 | sb->s_id); | 81 | sb->s_id); |
81 | return -1; | 82 | return -1; |
82 | } | 83 | } |
84 | info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS); | ||
85 | if (!info->dqi_priv) { | ||
86 | printk(KERN_WARNING | ||
87 | "Not enough memory for quota information structure.\n"); | ||
88 | return -1; | ||
89 | } | ||
90 | qinfo = info->dqi_priv; | ||
83 | /* limits are stored as unsigned 32-bit data */ | 91 | /* limits are stored as unsigned 32-bit data */ |
84 | info->dqi_maxblimit = 0xffffffff; | 92 | info->dqi_maxblimit = 0xffffffff; |
85 | info->dqi_maxilimit = 0xffffffff; | 93 | info->dqi_maxilimit = 0xffffffff; |
86 | info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); | 94 | info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); |
87 | info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); | 95 | info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); |
88 | info->dqi_flags = le32_to_cpu(dinfo.dqi_flags); | 96 | info->dqi_flags = le32_to_cpu(dinfo.dqi_flags); |
89 | info->u.v2_i.i.dqi_sb = sb; | 97 | qinfo->dqi_sb = sb; |
90 | info->u.v2_i.i.dqi_type = type; | 98 | qinfo->dqi_type = type; |
91 | info->u.v2_i.i.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); | 99 | qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); |
92 | info->u.v2_i.i.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); | 100 | qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); |
93 | info->u.v2_i.i.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); | 101 | qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); |
94 | info->u.v2_i.i.dqi_blocksize_bits = V2_DQBLKSIZE_BITS; | 102 | qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS; |
95 | info->u.v2_i.i.dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS; | 103 | qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS; |
96 | info->u.v2_i.i.dqi_qtree_depth = qtree_depth(&info->u.v2_i.i); | 104 | qinfo->dqi_qtree_depth = qtree_depth(qinfo); |
97 | info->u.v2_i.i.dqi_entry_size = sizeof(struct v2_disk_dqblk); | 105 | qinfo->dqi_entry_size = sizeof(struct v2_disk_dqblk); |
98 | info->u.v2_i.i.dqi_ops = &v2_qtree_ops; | 106 | qinfo->dqi_ops = &v2_qtree_ops; |
99 | return 0; | 107 | return 0; |
100 | } | 108 | } |
101 | 109 | ||
@@ -104,6 +112,7 @@ static int v2_write_file_info(struct super_block *sb, int type) | |||
104 | { | 112 | { |
105 | struct v2_disk_dqinfo dinfo; | 113 | struct v2_disk_dqinfo dinfo; |
106 | struct mem_dqinfo *info = sb_dqinfo(sb, type); | 114 | struct mem_dqinfo *info = sb_dqinfo(sb, type); |
115 | struct qtree_mem_dqinfo *qinfo = info->dqi_priv; | ||
107 | ssize_t size; | 116 | ssize_t size; |
108 | 117 | ||
109 | spin_lock(&dq_data_lock); | 118 | spin_lock(&dq_data_lock); |
@@ -112,9 +121,9 @@ static int v2_write_file_info(struct super_block *sb, int type) | |||
112 | dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace); | 121 | dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace); |
113 | dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK); | 122 | dinfo.dqi_flags = cpu_to_le32(info->dqi_flags & DQF_MASK); |
114 | spin_unlock(&dq_data_lock); | 123 | spin_unlock(&dq_data_lock); |
115 | dinfo.dqi_blocks = cpu_to_le32(info->u.v2_i.i.dqi_blocks); | 124 | dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks); |
116 | dinfo.dqi_free_blk = cpu_to_le32(info->u.v2_i.i.dqi_free_blk); | 125 | dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk); |
117 | dinfo.dqi_free_entry = cpu_to_le32(info->u.v2_i.i.dqi_free_entry); | 126 | dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry); |
118 | size = sb->s_op->quota_write(sb, type, (char *)&dinfo, | 127 | size = sb->s_op->quota_write(sb, type, (char *)&dinfo, |
119 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); | 128 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); |
120 | if (size != sizeof(struct v2_disk_dqinfo)) { | 129 | if (size != sizeof(struct v2_disk_dqinfo)) { |
@@ -150,7 +159,7 @@ static void v2_mem2diskdqb(void *dp, struct dquot *dquot) | |||
150 | struct v2_disk_dqblk *d = dp; | 159 | struct v2_disk_dqblk *d = dp; |
151 | struct mem_dqblk *m = &dquot->dq_dqb; | 160 | struct mem_dqblk *m = &dquot->dq_dqb; |
152 | struct qtree_mem_dqinfo *info = | 161 | struct qtree_mem_dqinfo *info = |
153 | &sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i; | 162 | sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; |
154 | 163 | ||
155 | d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit); | 164 | d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit); |
156 | d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); | 165 | d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); |
@@ -169,7 +178,7 @@ static int v2_is_id(void *dp, struct dquot *dquot) | |||
169 | { | 178 | { |
170 | struct v2_disk_dqblk *d = dp; | 179 | struct v2_disk_dqblk *d = dp; |
171 | struct qtree_mem_dqinfo *info = | 180 | struct qtree_mem_dqinfo *info = |
172 | &sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i; | 181 | sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; |
173 | 182 | ||
174 | if (qtree_entry_unused(info, dp)) | 183 | if (qtree_entry_unused(info, dp)) |
175 | return 0; | 184 | return 0; |
@@ -178,24 +187,30 @@ static int v2_is_id(void *dp, struct dquot *dquot) | |||
178 | 187 | ||
179 | static int v2_read_dquot(struct dquot *dquot) | 188 | static int v2_read_dquot(struct dquot *dquot) |
180 | { | 189 | { |
181 | return qtree_read_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot); | 190 | return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); |
182 | } | 191 | } |
183 | 192 | ||
184 | static int v2_write_dquot(struct dquot *dquot) | 193 | static int v2_write_dquot(struct dquot *dquot) |
185 | { | 194 | { |
186 | return qtree_write_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot); | 195 | return qtree_write_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); |
187 | } | 196 | } |
188 | 197 | ||
189 | static int v2_release_dquot(struct dquot *dquot) | 198 | static int v2_release_dquot(struct dquot *dquot) |
190 | { | 199 | { |
191 | return qtree_release_dquot(&sb_dqinfo(dquot->dq_sb, dquot->dq_type)->u.v2_i.i, dquot); | 200 | return qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv, dquot); |
201 | } | ||
202 | |||
203 | static int v2_free_file_info(struct super_block *sb, int type) | ||
204 | { | ||
205 | kfree(sb_dqinfo(sb, type)->dqi_priv); | ||
206 | return 0; | ||
192 | } | 207 | } |
193 | 208 | ||
194 | static struct quota_format_ops v2_format_ops = { | 209 | static struct quota_format_ops v2_format_ops = { |
195 | .check_quota_file = v2_check_quota_file, | 210 | .check_quota_file = v2_check_quota_file, |
196 | .read_file_info = v2_read_file_info, | 211 | .read_file_info = v2_read_file_info, |
197 | .write_file_info = v2_write_file_info, | 212 | .write_file_info = v2_write_file_info, |
198 | .free_file_info = NULL, | 213 | .free_file_info = v2_free_file_info, |
199 | .read_dqblk = v2_read_dquot, | 214 | .read_dqblk = v2_read_dquot, |
200 | .commit_dqblk = v2_write_dquot, | 215 | .commit_dqblk = v2_write_dquot, |
201 | .release_dqblk = v2_release_dquot, | 216 | .release_dqblk = v2_release_dquot, |
diff --git a/include/linux/dqblk_v1.h b/include/linux/dqblk_v1.h index 57f1250d5a52..9cea901f5bba 100644 --- a/include/linux/dqblk_v1.h +++ b/include/linux/dqblk_v1.h | |||
@@ -17,8 +17,4 @@ | |||
17 | #define V1_DEL_ALLOC 0 | 17 | #define V1_DEL_ALLOC 0 |
18 | #define V1_DEL_REWRITE 2 | 18 | #define V1_DEL_REWRITE 2 |
19 | 19 | ||
20 | /* Special information about quotafile */ | ||
21 | struct v1_mem_dqinfo { | ||
22 | }; | ||
23 | |||
24 | #endif /* _LINUX_DQBLK_V1_H */ | 20 | #endif /* _LINUX_DQBLK_V1_H */ |
diff --git a/include/linux/dqblk_v2.h b/include/linux/dqblk_v2.h index e5e22a787d58..ff8af1b4bda7 100644 --- a/include/linux/dqblk_v2.h +++ b/include/linux/dqblk_v2.h | |||
@@ -16,8 +16,4 @@ | |||
16 | #define V2_DEL_ALLOC QTREE_DEL_ALLOC | 16 | #define V2_DEL_ALLOC QTREE_DEL_ALLOC |
17 | #define V2_DEL_REWRITE QTREE_DEL_REWRITE | 17 | #define V2_DEL_REWRITE QTREE_DEL_REWRITE |
18 | 18 | ||
19 | struct v2_mem_dqinfo { | ||
20 | struct qtree_mem_dqinfo i; | ||
21 | }; | ||
22 | |||
23 | #endif /* _LINUX_DQBLK_V2_H */ | 19 | #endif /* _LINUX_DQBLK_V2_H */ |
diff --git a/include/linux/quota.h b/include/linux/quota.h index 80b8807b4988..e51dfdc0aef0 100644 --- a/include/linux/quota.h +++ b/include/linux/quota.h | |||
@@ -208,10 +208,7 @@ struct mem_dqinfo { | |||
208 | unsigned int dqi_igrace; | 208 | unsigned int dqi_igrace; |
209 | qsize_t dqi_maxblimit; | 209 | qsize_t dqi_maxblimit; |
210 | qsize_t dqi_maxilimit; | 210 | qsize_t dqi_maxilimit; |
211 | union { | 211 | void *dqi_priv; |
212 | struct v1_mem_dqinfo v1_i; | ||
213 | struct v2_mem_dqinfo v2_i; | ||
214 | } u; | ||
215 | }; | 212 | }; |
216 | 213 | ||
217 | struct super_block; | 214 | struct super_block; |