]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - src/patches/suse-2.6.27.31/patches.suse/quota-Increase-size-of-variables-for-limits-and-ino.patch
Move xen patchset to new version's subdir.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.31 / patches.suse / quota-Increase-size-of-variables-for-limits-and-ino.patch
CommitLineData
00e5a55c
BS
1From: Jan Kara <jack@suse.cz>
2References: fate#302681
3Subject: [PATCH 02/28] quota: Increase size of variables for limits and inode usage
4Patch-mainline: 2.6.29?
5
6So far quota was fine with quota block limits and inode limits/numbers in
7a 32-bit type. Now with rapid increase in storage sizes there are coming
8requests to be able to handle quota limits above 4TB / more that 2^32 inodes.
9So bump up sizes of types in mem_dqblk structure to 64-bits to be able to
10handle this. Also update inode allocation / checking functions to use qsize_t
11and make global structure keep quota limits in bytes so that things are
12consistent.
13
14Signed-off-by: Jan Kara <jack@suse.cz>
15---
16 fs/dquot.c | 50 ++++++++++++++++++++++++++-------------------
17 fs/quota_v1.c | 25 +++++++++++++++++-----
18 fs/quota_v2.c | 21 +++++++++++++++---
19 include/linux/quota.h | 28 +++++++++++--------------
20 include/linux/quotaops.h | 4 +-
21 5 files changed, 79 insertions(+), 49 deletions(-)
22
23diff --git a/fs/dquot.c b/fs/dquot.c
24index e1dac3e..758bf4a 100644
25--- a/fs/dquot.c
26+++ b/fs/dquot.c
27@@ -833,7 +833,7 @@ static void drop_dquot_ref(struct super_block *sb, int type)
28 }
29 }
30
31-static inline void dquot_incr_inodes(struct dquot *dquot, unsigned long number)
32+static inline void dquot_incr_inodes(struct dquot *dquot, qsize_t number)
33 {
34 dquot->dq_dqb.dqb_curinodes += number;
35 }
36@@ -843,7 +843,7 @@ static inline void dquot_incr_space(struct dquot *dquot, qsize_t number)
37 dquot->dq_dqb.dqb_curspace += number;
38 }
39
40-static inline void dquot_decr_inodes(struct dquot *dquot, unsigned long number)
41+static inline void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
42 {
43 if (dquot->dq_dqb.dqb_curinodes > number)
44 dquot->dq_dqb.dqb_curinodes -= number;
45@@ -860,7 +860,7 @@ static inline void dquot_decr_space(struct dquot *dquot, qsize_t number)
46 dquot->dq_dqb.dqb_curspace -= number;
47 else
48 dquot->dq_dqb.dqb_curspace = 0;
49- if (toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit)
50+ if (dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
51 dquot->dq_dqb.dqb_btime = (time_t) 0;
52 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
53 }
54@@ -1038,7 +1038,7 @@ static inline char ignore_hardlimit(struct dquot *dquot)
55 }
56
57 /* needs dq_data_lock */
58-static int check_idq(struct dquot *dquot, ulong inodes, char *warntype)
59+static int check_idq(struct dquot *dquot, qsize_t inodes, char *warntype)
60 {
61 *warntype = QUOTA_NL_NOWARN;
62 if (inodes <= 0 || test_bit(DQ_FAKE_B, &dquot->dq_flags))
63@@ -1077,7 +1077,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
64 return QUOTA_OK;
65
66 if (dquot->dq_dqb.dqb_bhardlimit &&
67- toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bhardlimit &&
68+ dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bhardlimit &&
69 !ignore_hardlimit(dquot)) {
70 if (!prealloc)
71 *warntype = QUOTA_NL_BHARDWARN;
72@@ -1085,7 +1085,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
73 }
74
75 if (dquot->dq_dqb.dqb_bsoftlimit &&
76- toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit &&
77+ dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
78 dquot->dq_dqb.dqb_btime && get_seconds() >= dquot->dq_dqb.dqb_btime &&
79 !ignore_hardlimit(dquot)) {
80 if (!prealloc)
81@@ -1094,7 +1094,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
82 }
83
84 if (dquot->dq_dqb.dqb_bsoftlimit &&
85- toqb(dquot->dq_dqb.dqb_curspace + space) > dquot->dq_dqb.dqb_bsoftlimit &&
86+ dquot->dq_dqb.dqb_curspace + space > dquot->dq_dqb.dqb_bsoftlimit &&
87 dquot->dq_dqb.dqb_btime == 0) {
88 if (!prealloc) {
89 *warntype = QUOTA_NL_BSOFTWARN;
90@@ -1111,7 +1111,7 @@ static int check_bdq(struct dquot *dquot, qsize_t space, int prealloc, char *war
91 return QUOTA_OK;
92 }
93
94-static int info_idq_free(struct dquot *dquot, ulong inodes)
95+static int info_idq_free(struct dquot *dquot, qsize_t inodes)
96 {
97 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
98 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit)
99@@ -1128,15 +1128,13 @@ static int info_idq_free(struct dquot *dquot, ulong inodes)
100 static int info_bdq_free(struct dquot *dquot, qsize_t space)
101 {
102 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
103- toqb(dquot->dq_dqb.dqb_curspace) <= dquot->dq_dqb.dqb_bsoftlimit)
104+ dquot->dq_dqb.dqb_curspace <= dquot->dq_dqb.dqb_bsoftlimit)
105 return QUOTA_NL_NOWARN;
106
107- if (toqb(dquot->dq_dqb.dqb_curspace - space) <=
108- dquot->dq_dqb.dqb_bsoftlimit)
109+ if (dquot->dq_dqb.dqb_curspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
110 return QUOTA_NL_BSOFTBELOW;
111- if (toqb(dquot->dq_dqb.dqb_curspace) >= dquot->dq_dqb.dqb_bhardlimit &&
112- toqb(dquot->dq_dqb.dqb_curspace - space) <
113- dquot->dq_dqb.dqb_bhardlimit)
114+ if (dquot->dq_dqb.dqb_curspace >= dquot->dq_dqb.dqb_bhardlimit &&
115+ dquot->dq_dqb.dqb_curspace - space < dquot->dq_dqb.dqb_bhardlimit)
116 return QUOTA_NL_BHARDBELOW;
117 return QUOTA_NL_NOWARN;
118 }
119@@ -1279,7 +1277,7 @@ warn_put_all:
120 /*
121 * This operation can block, but only after everything is updated
122 */
123-int dquot_alloc_inode(const struct inode *inode, unsigned long number)
124+int dquot_alloc_inode(const struct inode *inode, qsize_t number)
125 {
126 int cnt, ret = NO_QUOTA;
127 char warntype[MAXQUOTAS];
128@@ -1364,7 +1362,7 @@ out_sub:
129 /*
130 * This operation can block, but only after everything is updated
131 */
132-int dquot_free_inode(const struct inode *inode, unsigned long number)
133+int dquot_free_inode(const struct inode *inode, qsize_t number)
134 {
135 unsigned int cnt;
136 char warntype[MAXQUOTAS];
137@@ -1881,14 +1879,24 @@ int vfs_dq_quota_on_remount(struct super_block *sb)
138 return ret;
139 }
140
141+static inline qsize_t qbtos(qsize_t blocks)
142+{
143+ return blocks << QIF_DQBLKSIZE_BITS;
144+}
145+
146+static inline qsize_t stoqb(qsize_t space)
147+{
148+ return (space + QIF_DQBLKSIZE - 1) >> QIF_DQBLKSIZE_BITS;
149+}
150+
151 /* Generic routine for getting common part of quota structure */
152 static void do_get_dqblk(struct dquot *dquot, struct if_dqblk *di)
153 {
154 struct mem_dqblk *dm = &dquot->dq_dqb;
155
156 spin_lock(&dq_data_lock);
157- di->dqb_bhardlimit = dm->dqb_bhardlimit;
158- di->dqb_bsoftlimit = dm->dqb_bsoftlimit;
159+ di->dqb_bhardlimit = stoqb(dm->dqb_bhardlimit);
160+ di->dqb_bsoftlimit = stoqb(dm->dqb_bsoftlimit);
161 di->dqb_curspace = dm->dqb_curspace;
162 di->dqb_ihardlimit = dm->dqb_ihardlimit;
163 di->dqb_isoftlimit = dm->dqb_isoftlimit;
164@@ -1935,8 +1943,8 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
165 check_blim = 1;
166 }
167 if (di->dqb_valid & QIF_BLIMITS) {
168- dm->dqb_bsoftlimit = di->dqb_bsoftlimit;
169- dm->dqb_bhardlimit = di->dqb_bhardlimit;
170+ dm->dqb_bsoftlimit = qbtos(di->dqb_bsoftlimit);
171+ dm->dqb_bhardlimit = qbtos(di->dqb_bhardlimit);
172 check_blim = 1;
173 }
174 if (di->dqb_valid & QIF_INODES) {
175@@ -1954,7 +1962,7 @@ static int do_set_dqblk(struct dquot *dquot, struct if_dqblk *di)
176 dm->dqb_itime = di->dqb_itime;
177
178 if (check_blim) {
179- if (!dm->dqb_bsoftlimit || toqb(dm->dqb_curspace) < dm->dqb_bsoftlimit) {
180+ if (!dm->dqb_bsoftlimit || dm->dqb_curspace < dm->dqb_bsoftlimit) {
181 dm->dqb_btime = 0;
182 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
183 }
184diff --git a/fs/quota_v1.c b/fs/quota_v1.c
185index 5ae15b1..3e078ee 100644
186--- a/fs/quota_v1.c
187+++ b/fs/quota_v1.c
188@@ -14,14 +14,27 @@ MODULE_AUTHOR("Jan Kara");
189 MODULE_DESCRIPTION("Old quota format support");
190 MODULE_LICENSE("GPL");
191
192+#define QUOTABLOCK_BITS 10
193+#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
194+
195+static inline qsize_t v1_stoqb(qsize_t space)
196+{
197+ return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
198+}
199+
200+static inline qsize_t v1_qbtos(qsize_t blocks)
201+{
202+ return blocks << QUOTABLOCK_BITS;
203+}
204+
205 static void v1_disk2mem_dqblk(struct mem_dqblk *m, struct v1_disk_dqblk *d)
206 {
207 m->dqb_ihardlimit = d->dqb_ihardlimit;
208 m->dqb_isoftlimit = d->dqb_isoftlimit;
209 m->dqb_curinodes = d->dqb_curinodes;
210- m->dqb_bhardlimit = d->dqb_bhardlimit;
211- m->dqb_bsoftlimit = d->dqb_bsoftlimit;
212- m->dqb_curspace = ((qsize_t)d->dqb_curblocks) << QUOTABLOCK_BITS;
213+ m->dqb_bhardlimit = v1_qbtos(d->dqb_bhardlimit);
214+ m->dqb_bsoftlimit = v1_qbtos(d->dqb_bsoftlimit);
215+ m->dqb_curspace = v1_qbtos(d->dqb_curblocks);
216 m->dqb_itime = d->dqb_itime;
217 m->dqb_btime = d->dqb_btime;
218 }
219@@ -31,9 +44,9 @@ static void v1_mem2disk_dqblk(struct v1_disk_dqblk *d, struct mem_dqblk *m)
220 d->dqb_ihardlimit = m->dqb_ihardlimit;
221 d->dqb_isoftlimit = m->dqb_isoftlimit;
222 d->dqb_curinodes = m->dqb_curinodes;
223- d->dqb_bhardlimit = m->dqb_bhardlimit;
224- d->dqb_bsoftlimit = m->dqb_bsoftlimit;
225- d->dqb_curblocks = toqb(m->dqb_curspace);
226+ d->dqb_bhardlimit = v1_stoqb(m->dqb_bhardlimit);
227+ d->dqb_bsoftlimit = v1_stoqb(m->dqb_bsoftlimit);
228+ d->dqb_curblocks = v1_stoqb(m->dqb_curspace);
229 d->dqb_itime = m->dqb_itime;
230 d->dqb_btime = m->dqb_btime;
231 }
232diff --git a/fs/quota_v2.c b/fs/quota_v2.c
233index b53827d..51c4717 100644
234--- a/fs/quota_v2.c
235+++ b/fs/quota_v2.c
236@@ -26,6 +26,19 @@ typedef char *dqbuf_t;
237 #define GETIDINDEX(id, depth) (((id) >> ((V2_DQTREEDEPTH-(depth)-1)*8)) & 0xff)
238 #define GETENTRIES(buf) ((struct v2_disk_dqblk *)(((char *)buf)+sizeof(struct v2_disk_dqdbheader)))
239
240+#define QUOTABLOCK_BITS 10
241+#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
242+
243+static inline qsize_t v2_stoqb(qsize_t space)
244+{
245+ return (space + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS;
246+}
247+
248+static inline qsize_t v2_qbtos(qsize_t blocks)
249+{
250+ return blocks << QUOTABLOCK_BITS;
251+}
252+
253 /* Check whether given file is really vfsv0 quotafile */
254 static int v2_check_quota_file(struct super_block *sb, int type)
255 {
256@@ -104,8 +117,8 @@ static void disk2memdqb(struct mem_dqblk *m, struct v2_disk_dqblk *d)
257 m->dqb_isoftlimit = le32_to_cpu(d->dqb_isoftlimit);
258 m->dqb_curinodes = le32_to_cpu(d->dqb_curinodes);
259 m->dqb_itime = le64_to_cpu(d->dqb_itime);
260- m->dqb_bhardlimit = le32_to_cpu(d->dqb_bhardlimit);
261- m->dqb_bsoftlimit = le32_to_cpu(d->dqb_bsoftlimit);
262+ m->dqb_bhardlimit = v2_qbtos(le32_to_cpu(d->dqb_bhardlimit));
263+ m->dqb_bsoftlimit = v2_qbtos(le32_to_cpu(d->dqb_bsoftlimit));
264 m->dqb_curspace = le64_to_cpu(d->dqb_curspace);
265 m->dqb_btime = le64_to_cpu(d->dqb_btime);
266 }
267@@ -116,8 +129,8 @@ static void mem2diskdqb(struct v2_disk_dqblk *d, struct mem_dqblk *m, qid_t id)
268 d->dqb_isoftlimit = cpu_to_le32(m->dqb_isoftlimit);
269 d->dqb_curinodes = cpu_to_le32(m->dqb_curinodes);
270 d->dqb_itime = cpu_to_le64(m->dqb_itime);
271- d->dqb_bhardlimit = cpu_to_le32(m->dqb_bhardlimit);
272- d->dqb_bsoftlimit = cpu_to_le32(m->dqb_bsoftlimit);
273+ d->dqb_bhardlimit = cpu_to_le32(v2_qbtos(m->dqb_bhardlimit));
274+ d->dqb_bsoftlimit = cpu_to_le32(v2_qbtos(m->dqb_bsoftlimit));
275 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
276 d->dqb_btime = cpu_to_le64(m->dqb_btime);
277 d->dqb_id = cpu_to_le32(id);
278diff --git a/include/linux/quota.h b/include/linux/quota.h
279index eeae7a9..5167786 100644
280--- a/include/linux/quota.h
281+++ b/include/linux/quota.h
282@@ -41,15 +41,6 @@
283 #define __DQUOT_VERSION__ "dquot_6.5.1"
284 #define __DQUOT_NUM_VERSION__ 6*10000+5*100+1
285
286-/* Size of blocks in which are counted size limits */
287-#define QUOTABLOCK_BITS 10
288-#define QUOTABLOCK_SIZE (1 << QUOTABLOCK_BITS)
289-
290-/* Conversion routines from and to quota blocks */
291-#define qb2kb(x) ((x) << (QUOTABLOCK_BITS-10))
292-#define kb2qb(x) ((x) >> (QUOTABLOCK_BITS-10))
293-#define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
294-
295 #define MAXQUOTAS 2
296 #define USRQUOTA 0 /* element used for user quotas */
297 #define GRPQUOTA 1 /* element used for group quotas */
298@@ -82,6 +73,11 @@
299 #define Q_GETQUOTA 0x800007 /* get user quota structure */
300 #define Q_SETQUOTA 0x800008 /* set user quota structure */
301
302+/* Size of block in which space limits are passed through the quota
303+ * interface */
304+#define QIF_DQBLKSIZE_BITS 10
305+#define QIF_DQBLKSIZE (1 << QIF_DQBLKSIZE_BITS)
306+
307 /*
308 * Quota structure used for communication with userspace via quotactl
309 * Following flags are used to specify which fields are valid
310@@ -189,12 +185,12 @@ extern spinlock_t dq_data_lock;
311 * Data for one user/group kept in memory
312 */
313 struct mem_dqblk {
314- __u32 dqb_bhardlimit; /* absolute limit on disk blks alloc */
315- __u32 dqb_bsoftlimit; /* preferred limit on disk blks */
316+ qsize_t dqb_bhardlimit; /* absolute limit on disk blks alloc */
317+ qsize_t dqb_bsoftlimit; /* preferred limit on disk blks */
318 qsize_t dqb_curspace; /* current used space */
319- __u32 dqb_ihardlimit; /* absolute limit on allocated inodes */
320- __u32 dqb_isoftlimit; /* preferred inode limit */
321- __u32 dqb_curinodes; /* current # allocated inodes */
322+ qsize_t dqb_ihardlimit; /* absolute limit on allocated inodes */
323+ qsize_t dqb_isoftlimit; /* preferred inode limit */
324+ qsize_t dqb_curinodes; /* current # allocated inodes */
325 time_t dqb_btime; /* time limit for excessive disk use */
326 time_t dqb_itime; /* time limit for excessive inode use */
327 };
328@@ -289,9 +285,9 @@ struct dquot_operations {
329 int (*initialize) (struct inode *, int);
330 int (*drop) (struct inode *);
331 int (*alloc_space) (struct inode *, qsize_t, int);
332- int (*alloc_inode) (const struct inode *, unsigned long);
333+ int (*alloc_inode) (const struct inode *, qsize_t);
334 int (*free_space) (struct inode *, qsize_t);
335- int (*free_inode) (const struct inode *, unsigned long);
336+ int (*free_inode) (const struct inode *, qsize_t);
337 int (*transfer) (struct inode *, struct iattr *);
338 int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
339 struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot (can be NULL if no special entries dquot are needed) */
340diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
341index ca6b9b5..9e7bc4b 100644
342--- a/include/linux/quotaops.h
343+++ b/include/linux/quotaops.h
344@@ -29,10 +29,10 @@ int dquot_initialize(struct inode *inode, int type);
345 int dquot_drop(struct inode *inode);
346
347 int dquot_alloc_space(struct inode *inode, qsize_t number, int prealloc);
348-int dquot_alloc_inode(const struct inode *inode, unsigned long number);
349+int dquot_alloc_inode(const struct inode *inode, qsize_t number);
350
351 int dquot_free_space(struct inode *inode, qsize_t number);
352-int dquot_free_inode(const struct inode *inode, unsigned long number);
353+int dquot_free_inode(const struct inode *inode, qsize_t number);
354
355 int dquot_transfer(struct inode *inode, struct iattr *iattr);
356 int dquot_commit(struct dquot *dquot);
357--
3581.5.2.4
359