1 diff -urp linux-2.6.32.46-0.orig/fs/quota/dquot.c linux-2.6.32.46-0/fs/quota/dquot.c
2 --- linux-2.6.32.46-0.orig/fs/quota/dquot.c 2013-04-26 11:56:35.000000000 -0400
3 +++ linux-2.6.32.46-0/fs/quota/dquot.c 2013-04-26 12:00:44.000000000 -0400
6 * There are three quota SMP locks. dq_list_lock protects all lists with quotas
7 * and quota formats, dqstats structure containing statistics about the lists
8 - * dq_data_lock protects data from dq_dqb and also mem_dqinfo structures and
9 - * also guards consistency of dquot->dq_dqb with inode->i_blocks, i_bytes.
10 - * i_blocks and i_bytes updates itself are guarded by i_lock acquired directly
11 - * in inode_add_bytes() and inode_sub_bytes(). dq_state_lock protects
12 - * modifications of quota state (on quotaon and quotaoff) and readers who care
13 - * about latest values take it as well.
14 + * dq_data_lock protects data from dq_dqb and also mem_dqinfo structures.
15 + * dq_state_lock protects modifications of quota state (on quotaon and quotaoff)
16 + * and readers who care about latest values take it as well.
18 - * The spinlock ordering is hence: dq_data_lock > dq_list_lock > i_lock,
19 + * The spinlock ordering is hence: i_lock > dq_data_lock > dq_list_lock,
20 * dq_list_lock > dq_state_lock
22 * Note that some things (eg. sb pointer, type, id) doesn't change during
23 * the life of the dquot structure and so needn't to be protected by a lock
25 - * Any operation working on dquots via inode pointers must hold dqptr_sem. If
26 - * operation is just reading pointers from inode (or not using them at all) the
27 - * read lock is enough. If pointers are altered function must hold write lock
28 + * Any operation working on dquots via inode pointers must hold i_lock.
29 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that
30 * for altering the flag i_mutex is also needed).
33 * spinlock to internal buffers before writing.
35 * Lock ordering (including related VFS locks) is the following:
36 - * i_mutex > dqonoff_sem > journal_lock > dqptr_sem > dquot->dq_lock >
38 - * The lock ordering of dqptr_sem imposed by quota code is only dqonoff_sem >
39 - * dqptr_sem. But filesystem has to count with the fact that functions such as
40 - * dquot_alloc_space() acquire dqptr_sem and they usually have to be called
41 - * from inside a transaction to keep filesystem consistency after a crash. Also
42 - * filesystems usually want to do some IO on dquot from ->mark_dirty which is
43 - * called with dqptr_sem held.
44 - * i_mutex on quota files is special (it's below dqio_mutex)
45 + * i_mutex > dqonoff_sem > journal_lock > dquot->dq_lock > dqio_mutex
46 + * i_mutex on quota files is special (it's below dqio_mutex)
49 static __cacheline_aligned_in_smp DEFINE_SPINLOCK(dq_list_lock);
50 @@ -867,7 +855,6 @@ static inline int dqput_blocks(struct dq
52 * Remove references to dquots from inode and add dquot to list for freeing
53 * if we have the last referece to dquot
54 - * We can't race with anybody because we hold dqptr_sem for writing...
56 static int remove_inode_dquot_ref(struct inode *inode, int type,
57 struct list_head *tofree_head)
58 @@ -925,10 +912,12 @@ static void remove_dquot_ref(struct supe
59 * We have to scan also I_NEW inodes because they can already
60 * have quota pointer initialized. Luckily, we need to touch
61 * only quota pointers and these have separate locking
65 + spin_lock(&inode->i_lock);
66 if (!IS_NOQUOTA(inode))
67 remove_inode_dquot_ref(inode, type, tofree_head);
68 + spin_unlock(&inode->i_lock);
70 spin_unlock(&inode_lock);
72 @@ -939,9 +928,7 @@ static void drop_dquot_ref(struct super_
73 LIST_HEAD(tofree_head);
76 - down_write(&sb_dqopt(sb)->dqptr_sem);
77 remove_dquot_ref(sb, type, &tofree_head);
78 - up_write(&sb_dqopt(sb)->dqptr_sem);
79 put_dquot_list(&tofree_head);
82 @@ -1303,8 +1290,6 @@ static int info_bdq_free(struct dquot *d
85 * Initialize quota pointers in inode
86 - * We do things in a bit complicated way but by that we avoid calling
87 - * dqget() and thus filesystem callbacks under dqptr_sem.
89 int dquot_initialize(struct inode *inode, int type)
91 @@ -1334,8 +1319,7 @@ int dquot_initialize(struct inode *inode
92 got[cnt] = dqget(sb, id, cnt);
95 - down_write(&sb_dqopt(sb)->dqptr_sem);
96 - /* Having dqptr_sem we know NOQUOTA flags can't be altered... */
97 + spin_lock(&inode->i_lock);
98 if (IS_NOQUOTA(inode))
100 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
101 @@ -1352,12 +1336,16 @@ int dquot_initialize(struct inode *inode
102 * did a write before quota was turned on
104 rsv = inode_get_rsv_space(inode);
106 + if (unlikely(rsv)) {
107 + spin_lock(&dq_data_lock);
108 dquot_resv_space(inode->i_dquot[cnt], rsv);
109 + spin_unlock(&dq_data_lock);
114 - up_write(&sb_dqopt(sb)->dqptr_sem);
115 + spin_unlock(&inode->i_lock);
117 /* Drop unused references */
118 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
120 @@ -1373,12 +1361,12 @@ int dquot_drop(struct inode *inode)
122 struct dquot *put[MAXQUOTAS];
124 - down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
125 + spin_lock(&inode->i_lock);
126 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
127 put[cnt] = inode->i_dquot[cnt];
128 inode->i_dquot[cnt] = NULL;
130 - up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
131 + spin_unlock(&inode->i_lock);
133 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
135 @@ -1421,27 +1409,42 @@ static qsize_t *inode_reserved_space(str
136 return inode->i_sb->dq_op->get_reserved_space(inode);
139 +static inline void __inode_add_rsv_space(struct inode *inode, qsize_t number)
141 + *inode_reserved_space(inode) += number;
144 void inode_add_rsv_space(struct inode *inode, qsize_t number)
146 spin_lock(&inode->i_lock);
147 - *inode_reserved_space(inode) += number;
148 + __inode_add_rsv_space(inode, number);
149 spin_unlock(&inode->i_lock);
151 EXPORT_SYMBOL(inode_add_rsv_space);
153 -void inode_claim_rsv_space(struct inode *inode, qsize_t number)
154 +static inline void __inode_claim_rsv_space(struct inode *inode, qsize_t number)
156 - spin_lock(&inode->i_lock);
157 *inode_reserved_space(inode) -= number;
158 __inode_add_bytes(inode, number);
161 +void inode_claim_rsv_space(struct inode *inode, qsize_t number)
163 + spin_lock(&inode->i_lock);
164 + __inode_claim_rsv_space(inode, number);
165 spin_unlock(&inode->i_lock);
167 EXPORT_SYMBOL(inode_claim_rsv_space);
169 +static inline void __inode_sub_rsv_space(struct inode *inode, qsize_t number)
171 + *inode_reserved_space(inode) -= number;
174 void inode_sub_rsv_space(struct inode *inode, qsize_t number)
176 spin_lock(&inode->i_lock);
177 - *inode_reserved_space(inode) -= number;
178 + __inode_sub_rsv_space(inode, number);
179 spin_unlock(&inode->i_lock);
181 EXPORT_SYMBOL(inode_sub_rsv_space);
182 @@ -1452,9 +1455,8 @@ static qsize_t inode_get_rsv_space(struc
184 if (!inode->i_sb->dq_op->get_reserved_space)
186 - spin_lock(&inode->i_lock);
188 ret = *inode_reserved_space(inode);
189 - spin_unlock(&inode->i_lock);
193 @@ -1462,17 +1464,17 @@ static void inode_incr_space(struct inod
197 - inode_add_rsv_space(inode, number);
198 + __inode_add_rsv_space(inode, number);
200 - inode_add_bytes(inode, number);
201 + __inode_add_bytes(inode, number);
204 static void inode_decr_space(struct inode *inode, qsize_t number, int reserve)
207 - inode_sub_rsv_space(inode, number);
208 + __inode_sub_rsv_space(inode, number);
210 - inode_sub_bytes(inode, number);
211 + __inode_sub_bytes(inode, number);
215 @@ -1492,6 +1494,7 @@ int __dquot_alloc_space(struct inode *in
217 int cnt, ret = QUOTA_OK;
218 char warntype[MAXQUOTAS];
219 + struct dquot *dquot[MAXQUOTAS] = { NULL };
222 * First test before acquiring mutex - solves deadlocks when we
223 @@ -1502,10 +1505,11 @@ int __dquot_alloc_space(struct inode *in
227 - down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
228 + spin_lock(&inode->i_lock);
229 if (IS_NOQUOTA(inode)) {
230 inode_incr_space(inode, number, reserve);
232 + spin_unlock(&inode->i_lock);
236 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
237 @@ -1513,9 +1517,11 @@ int __dquot_alloc_space(struct inode *in
239 spin_lock(&dq_data_lock);
240 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
241 - if (!inode->i_dquot[cnt])
242 + dquot[cnt] = inode->i_dquot[cnt];
245 - if (check_bdq(inode->i_dquot[cnt], number, warn, warntype+cnt)
246 + atomic_inc(&dquot[cnt]->dq_count);
247 + if (check_bdq(dquot[cnt], number, warn, warntype+cnt)
250 spin_unlock(&dq_data_lock);
251 @@ -1523,26 +1529,27 @@ int __dquot_alloc_space(struct inode *in
254 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
255 - if (!inode->i_dquot[cnt])
259 - dquot_resv_space(inode->i_dquot[cnt], number);
260 + dquot_resv_space(dquot[cnt], number);
262 - dquot_incr_space(inode->i_dquot[cnt], number);
263 + dquot_incr_space(dquot[cnt], number);
265 inode_incr_space(inode, number, reserve);
266 spin_unlock(&dq_data_lock);
267 + spin_unlock(&inode->i_lock);
271 /* Dirtify all the dquots - this can block when journalling */
272 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
273 - if (inode->i_dquot[cnt])
274 - mark_dquot_dirty(inode->i_dquot[cnt]);
276 + mark_dquot_dirty(dquot[cnt]);
278 - flush_warnings(inode->i_dquot, warntype);
280 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
281 + flush_warnings(dquot, warntype);
282 + for (cnt = 0; cnt < MAXQUOTAS; cnt++)
287 @@ -1566,6 +1573,7 @@ int dquot_alloc_inode(const struct inode
289 int cnt, ret = NO_QUOTA;
290 char warntype[MAXQUOTAS];
291 + struct dquot *dquot[MAXQUOTAS] = { NULL };
293 /* First test before acquiring mutex - solves deadlocks when we
294 * re-enter the quota code and are already holding the mutex */
295 @@ -1573,35 +1581,41 @@ int dquot_alloc_inode(const struct inode
297 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
298 warntype[cnt] = QUOTA_NL_NOWARN;
299 - down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
301 + spin_lock(&((struct inode *)inode)->i_lock);
302 if (IS_NOQUOTA(inode)) {
303 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
304 + spin_unlock(&((struct inode *)inode)->i_lock);
307 spin_lock(&dq_data_lock);
308 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
309 - if (!inode->i_dquot[cnt])
310 + dquot[cnt] = inode->i_dquot[cnt];
313 - if (check_idq(inode->i_dquot[cnt], number, warntype+cnt)
314 + atomic_inc(&dquot[cnt]->dq_count);
315 + if (check_idq(dquot[cnt], number, warntype+cnt)
320 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
321 - if (!inode->i_dquot[cnt])
324 - dquot_incr_inodes(inode->i_dquot[cnt], number);
325 + dquot_incr_inodes(dquot[cnt], number);
329 spin_unlock(&dq_data_lock);
330 + spin_unlock(&((struct inode *)inode)->i_lock);
333 /* Dirtify all the dquots - this can block when journalling */
334 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
335 - if (inode->i_dquot[cnt])
336 - mark_dquot_dirty(inode->i_dquot[cnt]);
337 - flush_warnings(inode->i_dquot, warntype);
338 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
340 + mark_dquot_dirty(dquot[cnt]);
341 + flush_warnings(dquot, warntype);
342 + for (cnt = 0; cnt < MAXQUOTAS; cnt++)
346 EXPORT_SYMBOL(dquot_alloc_inode);
347 @@ -1610,34 +1624,40 @@ int dquot_claim_space(struct inode *inod
351 + struct dquot *dquot[MAXQUOTAS] = { NULL };
353 if (IS_NOQUOTA(inode)) {
354 inode_claim_rsv_space(inode, number);
358 - down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
359 + spin_lock(&inode->i_lock);
360 if (IS_NOQUOTA(inode)) {
361 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
362 - inode_claim_rsv_space(inode, number);
363 + __inode_claim_rsv_space(inode, number);
364 + spin_unlock(&inode->i_lock);
368 spin_lock(&dq_data_lock);
369 /* Claim reserved quotas to allocated quotas */
370 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
371 - if (inode->i_dquot[cnt])
372 - dquot_claim_reserved_space(inode->i_dquot[cnt],
374 + dquot[cnt] = inode->i_dquot[cnt];
376 + atomic_inc(&dquot[cnt]->dq_count);
377 + dquot_claim_reserved_space(dquot[cnt], number);
380 /* Update inode bytes */
381 - inode_claim_rsv_space(inode, number);
382 + __inode_claim_rsv_space(inode, number);
383 spin_unlock(&dq_data_lock);
384 + spin_unlock(&inode->i_lock);
386 /* Dirtify all the dquots - this can block when journalling */
387 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
388 - if (inode->i_dquot[cnt])
389 - mark_dquot_dirty(inode->i_dquot[cnt]);
390 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
392 + mark_dquot_dirty(dquot[cnt]);
393 + for (cnt = 0; cnt < MAXQUOTAS; cnt++)
398 @@ -1650,6 +1670,7 @@ int __dquot_free_space(struct inode *ino
401 char warntype[MAXQUOTAS];
402 + struct dquot *dquot[MAXQUOTAS] = { NULL };
404 /* First test before acquiring mutex - solves deadlocks when we
405 * re-enter the quota code and are already holding the mutex */
406 @@ -1659,34 +1680,37 @@ out_sub:
410 - down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
411 - /* Now recheck reliably when holding dqptr_sem */
412 + spin_lock(&inode->i_lock);
413 if (IS_NOQUOTA(inode)) {
414 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
415 + spin_unlock(&inode->i_lock);
418 spin_lock(&dq_data_lock);
419 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
420 - if (!inode->i_dquot[cnt])
421 + dquot[cnt] = inode->i_dquot[cnt];
424 - warntype[cnt] = info_bdq_free(inode->i_dquot[cnt], number);
425 + atomic_inc(&dquot[cnt]->dq_count);
426 + warntype[cnt] = info_bdq_free(dquot[cnt], number);
428 - dquot_free_reserved_space(inode->i_dquot[cnt], number);
429 + dquot_free_reserved_space(dquot[cnt], number);
431 - dquot_decr_space(inode->i_dquot[cnt], number);
432 + dquot_decr_space(dquot[cnt], number);
434 inode_decr_space(inode, number, reserve);
435 spin_unlock(&dq_data_lock);
436 + spin_unlock(&inode->i_lock);
441 /* Dirtify all the dquots - this can block when journalling */
442 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
443 - if (inode->i_dquot[cnt])
444 - mark_dquot_dirty(inode->i_dquot[cnt]);
446 - flush_warnings(inode->i_dquot, warntype);
447 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
449 + mark_dquot_dirty(dquot[cnt]);
451 + flush_warnings(dquot, warntype);
452 + for (cnt = 0; cnt < MAXQUOTAS; cnt++)
457 @@ -1713,32 +1737,37 @@ int dquot_free_inode(const struct inode
460 char warntype[MAXQUOTAS];
461 + struct dquot *dquot[MAXQUOTAS] = { NULL };
463 /* First test before acquiring mutex - solves deadlocks when we
464 * re-enter the quota code and are already holding the mutex */
465 if (IS_NOQUOTA(inode))
468 - down_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
469 - /* Now recheck reliably when holding dqptr_sem */
470 + spin_lock(&((struct inode *)inode)->i_lock);
471 if (IS_NOQUOTA(inode)) {
472 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
473 + spin_unlock(&((struct inode *)inode)->i_lock);
476 spin_lock(&dq_data_lock);
477 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
478 - if (!inode->i_dquot[cnt])
479 + dquot[cnt] = inode->i_dquot[cnt];
482 - warntype[cnt] = info_idq_free(inode->i_dquot[cnt], number);
483 - dquot_decr_inodes(inode->i_dquot[cnt], number);
484 + atomic_inc(&dquot[cnt]->dq_count);
485 + warntype[cnt] = info_idq_free(dquot[cnt], number);
486 + dquot_decr_inodes(dquot[cnt], number);
488 spin_unlock(&dq_data_lock);
489 + spin_unlock(&((struct inode *)inode)->i_lock);
491 /* Dirtify all the dquots - this can block when journalling */
492 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
493 - if (inode->i_dquot[cnt])
494 - mark_dquot_dirty(inode->i_dquot[cnt]);
495 - flush_warnings(inode->i_dquot, warntype);
496 - up_read(&sb_dqopt(inode->i_sb)->dqptr_sem);
498 + mark_dquot_dirty(dquot[cnt]);
499 + flush_warnings(dquot, warntype);
500 + for (cnt = 0; cnt < MAXQUOTAS; cnt++)
504 EXPORT_SYMBOL(dquot_free_inode);
505 @@ -1778,14 +1807,13 @@ int dquot_transfer(struct inode *inode,
506 transfer_to[GRPQUOTA] = dqget(inode->i_sb, iattr->ia_gid,
509 - down_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
510 - /* Now recheck reliably when holding dqptr_sem */
511 + spin_lock(&inode->i_lock);
512 if (IS_NOQUOTA(inode)) { /* File without quota accounting? */
513 - up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
514 + spin_unlock(&inode->i_lock);
517 spin_lock(&dq_data_lock);
518 - cur_space = inode_get_bytes(inode);
519 + cur_space = __inode_get_bytes(inode);
520 rsv_space = inode_get_rsv_space(inode);
521 space = cur_space + rsv_space;
522 /* Build the transfer_from list and check the limits */
523 @@ -1828,7 +1856,7 @@ int dquot_transfer(struct inode *inode,
524 inode->i_dquot[cnt] = transfer_to[cnt];
526 spin_unlock(&dq_data_lock);
527 - up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
528 + spin_unlock(&inode->i_lock);
530 /* Dirtify all the dquots - this can block when journalling */
531 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
532 @@ -1852,7 +1880,7 @@ put_all:
535 spin_unlock(&dq_data_lock);
536 - up_write(&sb_dqopt(inode->i_sb)->dqptr_sem);
537 + spin_unlock(&inode->i_lock);
538 /* Clear dquot pointers we don't want to dqput() */
539 for (cnt = 0; cnt < MAXQUOTAS; cnt++)
540 transfer_from[cnt] = NULL;
541 @@ -2104,13 +2132,13 @@ static int vfs_load_quota_inode(struct i
542 /* We don't want quota and atime on quota files (deadlocks
543 * possible) Also nobody should write to the file - we use
544 * special IO operations which ignore the immutable bit. */
545 - down_write(&dqopt->dqptr_sem);
546 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
547 + spin_lock(&inode->i_lock);
548 oldflags = inode->i_flags & (S_NOATIME | S_IMMUTABLE |
550 inode->i_flags |= S_NOQUOTA | S_NOATIME | S_IMMUTABLE;
551 + spin_unlock(&inode->i_lock);
552 mutex_unlock(&inode->i_mutex);
553 - up_write(&dqopt->dqptr_sem);
554 sb->dq_op->drop(inode);
557 @@ -2147,14 +2175,14 @@ out_file_init:
560 if (oldflags != -1) {
561 - down_write(&dqopt->dqptr_sem);
562 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
563 + spin_lock(&inode->i_lock);
564 /* Set the flags back (in the case of accidental quotaon()
565 * on a wrong file we don't want to mess up the flags) */
566 inode->i_flags &= ~(S_NOATIME | S_NOQUOTA | S_IMMUTABLE);
567 inode->i_flags |= oldflags;
568 + spin_unlock(&inode->i_lock);
569 mutex_unlock(&inode->i_mutex);
570 - up_write(&dqopt->dqptr_sem);
572 mutex_unlock(&dqopt->dqonoff_mutex);
574 diff -urp linux-2.6.32.46-0.orig/fs/quota/quota.c linux-2.6.32.46-0/fs/quota/quota.c
575 --- linux-2.6.32.46-0.orig/fs/quota/quota.c 2009-12-02 22:51:21.000000000 -0500
576 +++ linux-2.6.32.46-0/fs/quota/quota.c 2013-04-26 11:59:22.000000000 -0400
577 @@ -255,13 +255,13 @@ static int do_quotactl(struct super_bloc
581 - down_read(&sb_dqopt(sb)->dqptr_sem);
582 + mutex_lock(&sb_dqopt(sb)->dqonoff_mutex);
583 if (!sb_has_quota_active(sb, type)) {
584 - up_read(&sb_dqopt(sb)->dqptr_sem);
585 + mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
588 fmt = sb_dqopt(sb)->info[type].dqi_format->qf_fmt_id;
589 - up_read(&sb_dqopt(sb)->dqptr_sem);
590 + mutex_unlock(&sb_dqopt(sb)->dqonoff_mutex);
591 if (copy_to_user(addr, &fmt, sizeof(fmt)))
594 diff -urp linux-2.6.32.46-0.orig/fs/stat.c linux-2.6.32.46-0/fs/stat.c
595 --- linux-2.6.32.46-0.orig/fs/stat.c 2013-04-26 11:56:28.000000000 -0400
596 +++ linux-2.6.32.46-0/fs/stat.c 2013-04-26 11:59:22.000000000 -0400
597 @@ -422,9 +422,8 @@ void inode_add_bytes(struct inode *inode
599 EXPORT_SYMBOL(inode_add_bytes);
601 -void inode_sub_bytes(struct inode *inode, loff_t bytes)
602 +void __inode_sub_bytes(struct inode *inode, loff_t bytes)
604 - spin_lock(&inode->i_lock);
605 inode->i_blocks -= bytes >> 9;
607 if (inode->i_bytes < bytes) {
608 @@ -432,17 +431,28 @@ void inode_sub_bytes(struct inode *inode
609 inode->i_bytes += 512;
611 inode->i_bytes -= bytes;
614 +void inode_sub_bytes(struct inode *inode, loff_t bytes)
616 + spin_lock(&inode->i_lock);
617 + __inode_sub_bytes(inode, bytes);
618 spin_unlock(&inode->i_lock);
621 EXPORT_SYMBOL(inode_sub_bytes);
623 +loff_t __inode_get_bytes(struct inode *inode)
625 + return (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
628 loff_t inode_get_bytes(struct inode *inode)
632 spin_lock(&inode->i_lock);
633 - ret = (((loff_t)inode->i_blocks) << 9) + inode->i_bytes;
634 + ret = __inode_get_bytes(inode);
635 spin_unlock(&inode->i_lock);
638 diff -urp linux-2.6.32.46-0.orig/fs/super.c linux-2.6.32.46-0/fs/super.c
639 --- linux-2.6.32.46-0.orig/fs/super.c 2013-04-26 11:56:52.000000000 -0400
640 +++ linux-2.6.32.46-0/fs/super.c 2013-04-26 11:59:22.000000000 -0400
641 @@ -98,7 +98,6 @@ static struct super_block *alloc_super(s
642 mutex_init(&s->s_vfs_rename_mutex);
643 mutex_init(&s->s_dquot.dqio_mutex);
644 mutex_init(&s->s_dquot.dqonoff_mutex);
645 - init_rwsem(&s->s_dquot.dqptr_sem);
646 init_waitqueue_head(&s->s_wait_unfrozen);
647 s->s_maxbytes = MAX_NON_LFS;
648 s->dq_op = sb_dquot_ops;
649 diff -urp linux-2.6.32.46-0.orig/include/linux/fs.h linux-2.6.32.46-0/include/linux/fs.h
650 --- linux-2.6.32.46-0.orig/include/linux/fs.h 2013-04-26 11:56:52.000000000 -0400
651 +++ linux-2.6.32.46-0/include/linux/fs.h 2013-04-26 11:59:22.000000000 -0400
652 @@ -2356,7 +2356,9 @@ extern void generic_fillattr(struct inod
653 extern int vfs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
654 void __inode_add_bytes(struct inode *inode, loff_t bytes);
655 void inode_add_bytes(struct inode *inode, loff_t bytes);
656 +void __inode_sub_bytes(struct inode *inode, loff_t bytes);
657 void inode_sub_bytes(struct inode *inode, loff_t bytes);
658 +loff_t __inode_get_bytes(struct inode *inode);
659 loff_t inode_get_bytes(struct inode *inode);
660 void inode_set_bytes(struct inode *inode, loff_t bytes);