]>
Commit | Line | Data |
---|---|---|
09c434b8 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
1da177e4 LT |
2 | /* |
3 | * vfsv0 quota IO operations on file | |
4 | */ | |
5 | ||
6 | #include <linux/errno.h> | |
7 | #include <linux/fs.h> | |
8 | #include <linux/mount.h> | |
9 | #include <linux/dqblk_v2.h> | |
1da177e4 LT |
10 | #include <linux/kernel.h> |
11 | #include <linux/init.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/slab.h> | |
74abb989 | 14 | #include <linux/quotaops.h> |
1da177e4 LT |
15 | |
16 | #include <asm/byteorder.h> | |
17 | ||
1ccd14b9 | 18 | #include "quota_tree.h" |
cf770c13 JK |
19 | #include "quotaio_v2.h" |
20 | ||
1da177e4 LT |
21 | MODULE_AUTHOR("Jan Kara"); |
22 | MODULE_DESCRIPTION("Quota format v2 support"); | |
23 | MODULE_LICENSE("GPL"); | |
24 | ||
498c6015 JK |
25 | static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot); |
26 | static void v2r0_disk2memdqb(struct dquot *dquot, void *dp); | |
27 | static int v2r0_is_id(void *dp, struct dquot *dquot); | |
28 | static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot); | |
29 | static void v2r1_disk2memdqb(struct dquot *dquot, void *dp); | |
30 | static int v2r1_is_id(void *dp, struct dquot *dquot); | |
31 | ||
d1b98c23 | 32 | static const struct qtree_fmt_operations v2r0_qtree_ops = { |
498c6015 JK |
33 | .mem2disk_dqblk = v2r0_mem2diskdqb, |
34 | .disk2mem_dqblk = v2r0_disk2memdqb, | |
35 | .is_id = v2r0_is_id, | |
36 | }; | |
37 | ||
d1b98c23 | 38 | static const struct qtree_fmt_operations v2r1_qtree_ops = { |
498c6015 JK |
39 | .mem2disk_dqblk = v2r1_mem2diskdqb, |
40 | .disk2mem_dqblk = v2r1_disk2memdqb, | |
41 | .is_id = v2r1_is_id, | |
1ccd14b9 | 42 | }; |
1da177e4 | 43 | |
12095460 JK |
44 | #define QUOTABLOCK_BITS 10 |
45 | #define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS) | |
46 | ||
47 | static inline qsize_t v2_stoqb(qsize_t space) | |
48 | { | |
49 | return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS; | |
50 | } | |
51 | ||
52 | static inline qsize_t v2_qbtos(qsize_t blocks) | |
53 | { | |
54 | return blocks << QUOTABLOCK_BITS; | |
55 | } | |
56 | ||
498c6015 JK |
57 | static int v2_read_header(struct super_block *sb, int type, |
58 | struct v2_disk_dqheader *dqhead) | |
59 | { | |
60 | ssize_t size; | |
61 | ||
62 | size = sb->s_op->quota_read(sb, type, (char *)dqhead, | |
63 | sizeof(struct v2_disk_dqheader), 0); | |
64 | if (size != sizeof(struct v2_disk_dqheader)) { | |
fb5ffb0e JZ |
65 | quota_error(sb, "Failed header read: expected=%zd got=%zd", |
66 | sizeof(struct v2_disk_dqheader), size); | |
f98bbe37 JK |
67 | if (size < 0) |
68 | return size; | |
69 | return -EIO; | |
498c6015 | 70 | } |
f98bbe37 | 71 | return 0; |
498c6015 JK |
72 | } |
73 | ||
1da177e4 LT |
74 | /* Check whether given file is really vfsv0 quotafile */ |
75 | static int v2_check_quota_file(struct super_block *sb, int type) | |
76 | { | |
77 | struct v2_disk_dqheader dqhead; | |
1da177e4 LT |
78 | static const uint quota_magics[] = V2_INITQMAGICS; |
79 | static const uint quota_versions[] = V2_INITQVERSIONS; | |
27942ef5 | 80 | |
f98bbe37 | 81 | if (v2_read_header(sb, type, &dqhead)) |
1da177e4 | 82 | return 0; |
1da177e4 | 83 | if (le32_to_cpu(dqhead.dqh_magic) != quota_magics[type] || |
498c6015 | 84 | le32_to_cpu(dqhead.dqh_version) > quota_versions[type]) |
1da177e4 LT |
85 | return 0; |
86 | return 1; | |
87 | } | |
88 | ||
89 | /* Read information header from quota file */ | |
90 | static int v2_read_file_info(struct super_block *sb, int type) | |
91 | { | |
92 | struct v2_disk_dqinfo dinfo; | |
498c6015 | 93 | struct v2_disk_dqheader dqhead; |
42fdb858 JK |
94 | struct quota_info *dqopt = sb_dqopt(sb); |
95 | struct mem_dqinfo *info = &dqopt->info[type]; | |
e3d4d56b | 96 | struct qtree_mem_dqinfo *qinfo; |
1da177e4 | 97 | ssize_t size; |
498c6015 | 98 | unsigned int version; |
42fdb858 | 99 | int ret; |
498c6015 | 100 | |
42fdb858 | 101 | down_read(&dqopt->dqio_sem); |
f98bbe37 JK |
102 | ret = v2_read_header(sb, type, &dqhead); |
103 | if (ret < 0) | |
42fdb858 | 104 | goto out; |
498c6015 | 105 | version = le32_to_cpu(dqhead.dqh_version); |
869835df | 106 | if ((info->dqi_fmt_id == QFMT_VFS_V0 && version != 0) || |
42fdb858 | 107 | (info->dqi_fmt_id == QFMT_VFS_V1 && version != 1)) { |
cb8d01b4 | 108 | ret = -EINVAL; |
42fdb858 JK |
109 | goto out; |
110 | } | |
1da177e4 LT |
111 | |
112 | size = sb->s_op->quota_read(sb, type, (char *)&dinfo, | |
113 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); | |
114 | if (size != sizeof(struct v2_disk_dqinfo)) { | |
fb5ffb0e | 115 | quota_error(sb, "Can't read info structure"); |
f98bbe37 JK |
116 | if (size < 0) |
117 | ret = size; | |
118 | else | |
119 | ret = -EIO; | |
42fdb858 | 120 | goto out; |
1da177e4 | 121 | } |
e3d4d56b JK |
122 | info->dqi_priv = kmalloc(sizeof(struct qtree_mem_dqinfo), GFP_NOFS); |
123 | if (!info->dqi_priv) { | |
42fdb858 JK |
124 | ret = -ENOMEM; |
125 | goto out; | |
e3d4d56b JK |
126 | } |
127 | qinfo = info->dqi_priv; | |
498c6015 JK |
128 | if (version == 0) { |
129 | /* limits are stored as unsigned 32-bit data */ | |
7e08da50 | 130 | info->dqi_max_spc_limit = 0xffffffffLL << QUOTABLOCK_BITS; |
b10a0819 | 131 | info->dqi_max_ino_limit = 0xffffffff; |
498c6015 | 132 | } else { |
7e08da50 JK |
133 | /* |
134 | * Used space is stored as unsigned 64-bit value in bytes but | |
135 | * quota core supports only signed 64-bit values so use that | |
136 | * as a limit | |
137 | */ | |
138 | info->dqi_max_spc_limit = 0x7fffffffffffffffLL; /* 2^63-1 */ | |
139 | info->dqi_max_ino_limit = 0x7fffffffffffffffLL; | |
498c6015 | 140 | } |
1da177e4 LT |
141 | info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); |
142 | info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); | |
c119c5b9 JK |
143 | /* No flags currently supported */ |
144 | info->dqi_flags = 0; | |
e3d4d56b JK |
145 | qinfo->dqi_sb = sb; |
146 | qinfo->dqi_type = type; | |
147 | qinfo->dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); | |
148 | qinfo->dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); | |
149 | qinfo->dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); | |
150 | qinfo->dqi_blocksize_bits = V2_DQBLKSIZE_BITS; | |
151 | qinfo->dqi_usable_bs = 1 << V2_DQBLKSIZE_BITS; | |
152 | qinfo->dqi_qtree_depth = qtree_depth(qinfo); | |
498c6015 JK |
153 | if (version == 0) { |
154 | qinfo->dqi_entry_size = sizeof(struct v2r0_disk_dqblk); | |
155 | qinfo->dqi_ops = &v2r0_qtree_ops; | |
156 | } else { | |
157 | qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk); | |
158 | qinfo->dqi_ops = &v2r1_qtree_ops; | |
159 | } | |
11c514a9 JK |
160 | ret = -EUCLEAN; |
161 | /* Some sanity checks of the read headers... */ | |
162 | if ((loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits > | |
163 | i_size_read(sb_dqopt(sb)->files[type])) { | |
164 | quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).", | |
165 | (loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits, | |
166 | i_size_read(sb_dqopt(sb)->files[type])); | |
167 | goto out; | |
168 | } | |
169 | if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) { | |
170 | quota_error(sb, "Free block number too big (%u >= %u).", | |
171 | qinfo->dqi_free_blk, qinfo->dqi_blocks); | |
172 | goto out; | |
173 | } | |
174 | if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) { | |
175 | quota_error(sb, "Block with free entry too big (%u >= %u).", | |
176 | qinfo->dqi_free_entry, qinfo->dqi_blocks); | |
177 | goto out; | |
178 | } | |
42fdb858 JK |
179 | ret = 0; |
180 | out: | |
181 | up_read(&dqopt->dqio_sem); | |
182 | return ret; | |
1da177e4 LT |
183 | } |
184 | ||
185 | /* Write information header to quota file */ | |
186 | static int v2_write_file_info(struct super_block *sb, int type) | |
187 | { | |
188 | struct v2_disk_dqinfo dinfo; | |
9a8ae30e JK |
189 | struct quota_info *dqopt = sb_dqopt(sb); |
190 | struct mem_dqinfo *info = &dqopt->info[type]; | |
e3d4d56b | 191 | struct qtree_mem_dqinfo *qinfo = info->dqi_priv; |
1da177e4 LT |
192 | ssize_t size; |
193 | ||
9a8ae30e | 194 | down_write(&dqopt->dqio_sem); |
1da177e4 LT |
195 | spin_lock(&dq_data_lock); |
196 | info->dqi_flags &= ~DQF_INFO_DIRTY; | |
197 | dinfo.dqi_bgrace = cpu_to_le32(info->dqi_bgrace); | |
198 | dinfo.dqi_igrace = cpu_to_le32(info->dqi_igrace); | |
c119c5b9 JK |
199 | /* No flags currently supported */ |
200 | dinfo.dqi_flags = cpu_to_le32(0); | |
1da177e4 | 201 | spin_unlock(&dq_data_lock); |
e3d4d56b JK |
202 | dinfo.dqi_blocks = cpu_to_le32(qinfo->dqi_blocks); |
203 | dinfo.dqi_free_blk = cpu_to_le32(qinfo->dqi_free_blk); | |
204 | dinfo.dqi_free_entry = cpu_to_le32(qinfo->dqi_free_entry); | |
1da177e4 LT |
205 | size = sb->s_op->quota_write(sb, type, (char *)&dinfo, |
206 | sizeof(struct v2_disk_dqinfo), V2_DQINFOOFF); | |
9a8ae30e | 207 | up_write(&dqopt->dqio_sem); |
1da177e4 | 208 | if (size != sizeof(struct v2_disk_dqinfo)) { |
fb5ffb0e | 209 | quota_error(sb, "Can't write info structure"); |
1da177e4 LT |
210 | return -1; |
211 | } | |
212 | return 0; | |
213 | } | |
214 | ||
498c6015 | 215 | static void v2r0_disk2memdqb(struct dquot *dquot, void *dp) |
1da177e4 | 216 | { |
498c6015 | 217 | struct v2r0_disk_dqblk *d = dp, empty; |
1ccd14b9 JK |
218 | struct mem_dqblk *m = &dquot->dq_dqb; |
219 | ||
1da177e4 LT |
220 | m->dqb_ihardlimit = le32_to_cpu(d->dqb_ihardlimit); |
221 | m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit); | |
222 | m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes); | |
223 | m->dqb_itime = le64_to_cpu(d->dqb_itime); | |
12095460 JK |
224 | m->dqb_bhardlimit = v2_qbtos(le32_to_cpu(d->dqb_bhardlimit)); |
225 | m->dqb_bsoftlimit = v2_qbtos(le32_to_cpu(d->dqb_bsoftlimit)); | |
1da177e4 LT |
226 | m->dqb_curspace = le64_to_cpu(d->dqb_curspace); |
227 | m->dqb_btime = le64_to_cpu(d->dqb_btime); | |
1ccd14b9 | 228 | /* We need to escape back all-zero structure */ |
498c6015 | 229 | memset(&empty, 0, sizeof(struct v2r0_disk_dqblk)); |
1ccd14b9 | 230 | empty.dqb_itime = cpu_to_le64(1); |
498c6015 | 231 | if (!memcmp(&empty, dp, sizeof(struct v2r0_disk_dqblk))) |
1ccd14b9 | 232 | m->dqb_itime = 0; |
1da177e4 LT |
233 | } |
234 | ||
498c6015 | 235 | static void v2r0_mem2diskdqb(void *dp, struct dquot *dquot) |
1da177e4 | 236 | { |
498c6015 | 237 | struct v2r0_disk_dqblk *d = dp; |
1ccd14b9 JK |
238 | struct mem_dqblk *m = &dquot->dq_dqb; |
239 | struct qtree_mem_dqinfo *info = | |
4c376dca | 240 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv; |
1ccd14b9 | 241 | |
1da177e4 LT |
242 | d->dqb_ihardlimit = cpu_to_le32(m->dqb_ihardlimit); |
243 | d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit); | |
244 | d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes); | |
245 | d->dqb_itime = cpu_to_le64(m->dqb_itime); | |
cf770c13 JK |
246 | d->dqb_bhardlimit = cpu_to_le32(v2_stoqb(m->dqb_bhardlimit)); |
247 | d->dqb_bsoftlimit = cpu_to_le32(v2_stoqb(m->dqb_bsoftlimit)); | |
1da177e4 LT |
248 | d->dqb_curspace = cpu_to_le64(m->dqb_curspace); |
249 | d->dqb_btime = cpu_to_le64(m->dqb_btime); | |
4c376dca | 250 | d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id)); |
1ccd14b9 JK |
251 | if (qtree_entry_unused(info, dp)) |
252 | d->dqb_itime = cpu_to_le64(1); | |
1da177e4 LT |
253 | } |
254 | ||
498c6015 JK |
255 | static int v2r0_is_id(void *dp, struct dquot *dquot) |
256 | { | |
257 | struct v2r0_disk_dqblk *d = dp; | |
258 | struct qtree_mem_dqinfo *info = | |
4c376dca | 259 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv; |
498c6015 JK |
260 | |
261 | if (qtree_entry_unused(info, dp)) | |
262 | return 0; | |
4c376dca EB |
263 | return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type, |
264 | le32_to_cpu(d->dqb_id)), | |
265 | dquot->dq_id); | |
498c6015 JK |
266 | } |
267 | ||
268 | static void v2r1_disk2memdqb(struct dquot *dquot, void *dp) | |
269 | { | |
270 | struct v2r1_disk_dqblk *d = dp, empty; | |
271 | struct mem_dqblk *m = &dquot->dq_dqb; | |
272 | ||
273 | m->dqb_ihardlimit = le64_to_cpu(d->dqb_ihardlimit); | |
274 | m->dqb_isoftlimit = le64_to_cpu(d->dqb_isoftlimit); | |
275 | m->dqb_curinodes = le64_to_cpu(d->dqb_curinodes); | |
276 | m->dqb_itime = le64_to_cpu(d->dqb_itime); | |
277 | m->dqb_bhardlimit = v2_qbtos(le64_to_cpu(d->dqb_bhardlimit)); | |
278 | m->dqb_bsoftlimit = v2_qbtos(le64_to_cpu(d->dqb_bsoftlimit)); | |
279 | m->dqb_curspace = le64_to_cpu(d->dqb_curspace); | |
280 | m->dqb_btime = le64_to_cpu(d->dqb_btime); | |
281 | /* We need to escape back all-zero structure */ | |
282 | memset(&empty, 0, sizeof(struct v2r1_disk_dqblk)); | |
283 | empty.dqb_itime = cpu_to_le64(1); | |
284 | if (!memcmp(&empty, dp, sizeof(struct v2r1_disk_dqblk))) | |
285 | m->dqb_itime = 0; | |
286 | } | |
287 | ||
288 | static void v2r1_mem2diskdqb(void *dp, struct dquot *dquot) | |
289 | { | |
290 | struct v2r1_disk_dqblk *d = dp; | |
291 | struct mem_dqblk *m = &dquot->dq_dqb; | |
292 | struct qtree_mem_dqinfo *info = | |
4c376dca | 293 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv; |
498c6015 JK |
294 | |
295 | d->dqb_ihardlimit = cpu_to_le64(m->dqb_ihardlimit); | |
296 | d->dqb_isoftlimit = cpu_to_le64(m->dqb_isoftlimit); | |
297 | d->dqb_curinodes = cpu_to_le64(m->dqb_curinodes); | |
298 | d->dqb_itime = cpu_to_le64(m->dqb_itime); | |
299 | d->dqb_bhardlimit = cpu_to_le64(v2_stoqb(m->dqb_bhardlimit)); | |
300 | d->dqb_bsoftlimit = cpu_to_le64(v2_stoqb(m->dqb_bsoftlimit)); | |
301 | d->dqb_curspace = cpu_to_le64(m->dqb_curspace); | |
302 | d->dqb_btime = cpu_to_le64(m->dqb_btime); | |
4c376dca | 303 | d->dqb_id = cpu_to_le32(from_kqid(&init_user_ns, dquot->dq_id)); |
3d3dc274 | 304 | d->dqb_pad = 0; |
498c6015 JK |
305 | if (qtree_entry_unused(info, dp)) |
306 | d->dqb_itime = cpu_to_le64(1); | |
307 | } | |
308 | ||
309 | static int v2r1_is_id(void *dp, struct dquot *dquot) | |
1da177e4 | 310 | { |
498c6015 | 311 | struct v2r1_disk_dqblk *d = dp; |
1ccd14b9 | 312 | struct qtree_mem_dqinfo *info = |
4c376dca | 313 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv; |
1da177e4 | 314 | |
1ccd14b9 | 315 | if (qtree_entry_unused(info, dp)) |
1da177e4 | 316 | return 0; |
4c376dca EB |
317 | return qid_eq(make_kqid(&init_user_ns, dquot->dq_id.type, |
318 | le32_to_cpu(d->dqb_id)), | |
319 | dquot->dq_id); | |
1da177e4 LT |
320 | } |
321 | ||
1ccd14b9 | 322 | static int v2_read_dquot(struct dquot *dquot) |
1da177e4 | 323 | { |
e342e38d JK |
324 | struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); |
325 | int ret; | |
326 | ||
327 | down_read(&dqopt->dqio_sem); | |
328 | ret = qtree_read_dquot( | |
329 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, | |
330 | dquot); | |
331 | up_read(&dqopt->dqio_sem); | |
332 | return ret; | |
1da177e4 LT |
333 | } |
334 | ||
1da177e4 LT |
335 | static int v2_write_dquot(struct dquot *dquot) |
336 | { | |
8fc32c2b JK |
337 | struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); |
338 | int ret; | |
d2faa415 JK |
339 | bool alloc = false; |
340 | ||
341 | /* | |
342 | * If space for dquot is already allocated, we don't need any | |
343 | * protection as we'll only overwrite the place of dquot. We are | |
344 | * still protected by concurrent writes of the same dquot by | |
345 | * dquot->dq_lock. | |
346 | */ | |
347 | if (!dquot->dq_off) { | |
348 | alloc = true; | |
349 | down_write(&dqopt->dqio_sem); | |
4c6bb696 JK |
350 | } else { |
351 | down_read(&dqopt->dqio_sem); | |
d2faa415 | 352 | } |
8fc32c2b JK |
353 | ret = qtree_write_dquot( |
354 | sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, | |
355 | dquot); | |
d2faa415 JK |
356 | if (alloc) |
357 | up_write(&dqopt->dqio_sem); | |
4c6bb696 JK |
358 | else |
359 | up_read(&dqopt->dqio_sem); | |
8fc32c2b | 360 | return ret; |
1da177e4 LT |
361 | } |
362 | ||
1da177e4 LT |
363 | static int v2_release_dquot(struct dquot *dquot) |
364 | { | |
b9a1a7f4 JK |
365 | struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); |
366 | int ret; | |
367 | ||
368 | down_write(&dqopt->dqio_sem); | |
369 | ret = qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot); | |
370 | up_write(&dqopt->dqio_sem); | |
371 | ||
372 | return ret; | |
e3d4d56b JK |
373 | } |
374 | ||
375 | static int v2_free_file_info(struct super_block *sb, int type) | |
376 | { | |
377 | kfree(sb_dqinfo(sb, type)->dqi_priv); | |
378 | return 0; | |
1da177e4 LT |
379 | } |
380 | ||
0066373d JK |
381 | static int v2_get_next_id(struct super_block *sb, struct kqid *qid) |
382 | { | |
f14618c6 JK |
383 | struct quota_info *dqopt = sb_dqopt(sb); |
384 | int ret; | |
385 | ||
386 | down_read(&dqopt->dqio_sem); | |
387 | ret = qtree_get_next_id(sb_dqinfo(sb, qid->type)->dqi_priv, qid); | |
388 | up_read(&dqopt->dqio_sem); | |
389 | return ret; | |
0066373d JK |
390 | } |
391 | ||
1472da5f | 392 | static const struct quota_format_ops v2_format_ops = { |
1da177e4 LT |
393 | .check_quota_file = v2_check_quota_file, |
394 | .read_file_info = v2_read_file_info, | |
395 | .write_file_info = v2_write_file_info, | |
e3d4d56b | 396 | .free_file_info = v2_free_file_info, |
1da177e4 LT |
397 | .read_dqblk = v2_read_dquot, |
398 | .commit_dqblk = v2_write_dquot, | |
399 | .release_dqblk = v2_release_dquot, | |
0066373d | 400 | .get_next_id = v2_get_next_id, |
1da177e4 LT |
401 | }; |
402 | ||
498c6015 | 403 | static struct quota_format_type v2r0_quota_format = { |
1da177e4 LT |
404 | .qf_fmt_id = QFMT_VFS_V0, |
405 | .qf_ops = &v2_format_ops, | |
406 | .qf_owner = THIS_MODULE | |
407 | }; | |
408 | ||
498c6015 JK |
409 | static struct quota_format_type v2r1_quota_format = { |
410 | .qf_fmt_id = QFMT_VFS_V1, | |
411 | .qf_ops = &v2_format_ops, | |
412 | .qf_owner = THIS_MODULE | |
413 | }; | |
414 | ||
1da177e4 LT |
415 | static int __init init_v2_quota_format(void) |
416 | { | |
498c6015 JK |
417 | int ret; |
418 | ||
419 | ret = register_quota_format(&v2r0_quota_format); | |
420 | if (ret) | |
421 | return ret; | |
422 | return register_quota_format(&v2r1_quota_format); | |
1da177e4 LT |
423 | } |
424 | ||
425 | static void __exit exit_v2_quota_format(void) | |
426 | { | |
498c6015 JK |
427 | unregister_quota_format(&v2r0_quota_format); |
428 | unregister_quota_format(&v2r1_quota_format); | |
1da177e4 LT |
429 | } |
430 | ||
431 | module_init(init_v2_quota_format); | |
432 | module_exit(exit_v2_quota_format); |