aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/quota/xfs_dquot.c57
-rw-r--r--fs/xfs/quota/xfs_dquot_item.c2
-rw-r--r--fs/xfs/quota/xfs_qm.c144
-rw-r--r--fs/xfs/quota/xfs_qm_syscalls.c114
-rw-r--r--fs/xfs/quota/xfs_quota_priv.h14
-rw-r--r--fs/xfs/quota/xfs_trans_dquot.c6
6 files changed, 165 insertions, 172 deletions
diff --git a/fs/xfs/quota/xfs_dquot.c b/fs/xfs/quota/xfs_dquot.c
index 02dac0a5f1e..9b1e8be9882 100644
--- a/fs/xfs/quota/xfs_dquot.c
+++ b/fs/xfs/quota/xfs_dquot.c
@@ -252,7 +252,7 @@ xfs_qm_adjust_dqtimers(
252 (be64_to_cpu(d->d_bcount) >= 252 (be64_to_cpu(d->d_bcount) >=
253 be64_to_cpu(d->d_blk_hardlimit)))) { 253 be64_to_cpu(d->d_blk_hardlimit)))) {
254 d->d_btimer = cpu_to_be32(get_seconds() + 254 d->d_btimer = cpu_to_be32(get_seconds() +
255 XFS_QI_BTIMELIMIT(mp)); 255 mp->m_quotainfo->qi_btimelimit);
256 } else { 256 } else {
257 d->d_bwarns = 0; 257 d->d_bwarns = 0;
258 } 258 }
@@ -275,7 +275,7 @@ xfs_qm_adjust_dqtimers(
275 (be64_to_cpu(d->d_icount) >= 275 (be64_to_cpu(d->d_icount) >=
276 be64_to_cpu(d->d_ino_hardlimit)))) { 276 be64_to_cpu(d->d_ino_hardlimit)))) {
277 d->d_itimer = cpu_to_be32(get_seconds() + 277 d->d_itimer = cpu_to_be32(get_seconds() +
278 XFS_QI_ITIMELIMIT(mp)); 278 mp->m_quotainfo->qi_itimelimit);
279 } else { 279 } else {
280 d->d_iwarns = 0; 280 d->d_iwarns = 0;
281 } 281 }
@@ -298,7 +298,7 @@ xfs_qm_adjust_dqtimers(
298 (be64_to_cpu(d->d_rtbcount) >= 298 (be64_to_cpu(d->d_rtbcount) >=
299 be64_to_cpu(d->d_rtb_hardlimit)))) { 299 be64_to_cpu(d->d_rtb_hardlimit)))) {
300 d->d_rtbtimer = cpu_to_be32(get_seconds() + 300 d->d_rtbtimer = cpu_to_be32(get_seconds() +
301 XFS_QI_RTBTIMELIMIT(mp)); 301 mp->m_quotainfo->qi_rtbtimelimit);
302 } else { 302 } else {
303 d->d_rtbwarns = 0; 303 d->d_rtbwarns = 0;
304 } 304 }
@@ -325,6 +325,7 @@ xfs_qm_init_dquot_blk(
325 uint type, 325 uint type,
326 xfs_buf_t *bp) 326 xfs_buf_t *bp)
327{ 327{
328 struct xfs_quotainfo *q = mp->m_quotainfo;
328 xfs_dqblk_t *d; 329 xfs_dqblk_t *d;
329 int curid, i; 330 int curid, i;
330 331
@@ -337,16 +338,16 @@ xfs_qm_init_dquot_blk(
337 /* 338 /*
338 * ID of the first dquot in the block - id's are zero based. 339 * ID of the first dquot in the block - id's are zero based.
339 */ 340 */
340 curid = id - (id % XFS_QM_DQPERBLK(mp)); 341 curid = id - (id % q->qi_dqperchunk);
341 ASSERT(curid >= 0); 342 ASSERT(curid >= 0);
342 memset(d, 0, BBTOB(XFS_QI_DQCHUNKLEN(mp))); 343 memset(d, 0, BBTOB(q->qi_dqchunklen));
343 for (i = 0; i < XFS_QM_DQPERBLK(mp); i++, d++, curid++) 344 for (i = 0; i < q->qi_dqperchunk; i++, d++, curid++)
344 xfs_qm_dqinit_core(curid, type, d); 345 xfs_qm_dqinit_core(curid, type, d);
345 xfs_trans_dquot_buf(tp, bp, 346 xfs_trans_dquot_buf(tp, bp,
346 (type & XFS_DQ_USER ? XFS_BLI_UDQUOT_BUF : 347 (type & XFS_DQ_USER ? XFS_BLI_UDQUOT_BUF :
347 ((type & XFS_DQ_PROJ) ? XFS_BLI_PDQUOT_BUF : 348 ((type & XFS_DQ_PROJ) ? XFS_BLI_PDQUOT_BUF :
348 XFS_BLI_GDQUOT_BUF))); 349 XFS_BLI_GDQUOT_BUF)));
349 xfs_trans_log_buf(tp, bp, 0, BBTOB(XFS_QI_DQCHUNKLEN(mp)) - 1); 350 xfs_trans_log_buf(tp, bp, 0, BBTOB(q->qi_dqchunklen) - 1);
350} 351}
351 352
352 353
@@ -419,7 +420,7 @@ xfs_qm_dqalloc(
419 /* now we can just get the buffer (there's nothing to read yet) */ 420 /* now we can just get the buffer (there's nothing to read yet) */
420 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, 421 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
421 dqp->q_blkno, 422 dqp->q_blkno,
422 XFS_QI_DQCHUNKLEN(mp), 423 mp->m_quotainfo->qi_dqchunklen,
423 0); 424 0);
424 if (!bp || (error = XFS_BUF_GETERROR(bp))) 425 if (!bp || (error = XFS_BUF_GETERROR(bp)))
425 goto error1; 426 goto error1;
@@ -500,7 +501,8 @@ xfs_qm_dqtobp(
500 */ 501 */
501 if (dqp->q_blkno == (xfs_daddr_t) 0) { 502 if (dqp->q_blkno == (xfs_daddr_t) 0) {
502 /* We use the id as an index */ 503 /* We use the id as an index */
503 dqp->q_fileoffset = (xfs_fileoff_t)id / XFS_QM_DQPERBLK(mp); 504 dqp->q_fileoffset = (xfs_fileoff_t)id /
505 mp->m_quotainfo->qi_dqperchunk;
504 nmaps = 1; 506 nmaps = 1;
505 quotip = XFS_DQ_TO_QIP(dqp); 507 quotip = XFS_DQ_TO_QIP(dqp);
506 xfs_ilock(quotip, XFS_ILOCK_SHARED); 508 xfs_ilock(quotip, XFS_ILOCK_SHARED);
@@ -529,7 +531,7 @@ xfs_qm_dqtobp(
529 /* 531 /*
530 * offset of dquot in the (fixed sized) dquot chunk. 532 * offset of dquot in the (fixed sized) dquot chunk.
531 */ 533 */
532 dqp->q_bufoffset = (id % XFS_QM_DQPERBLK(mp)) * 534 dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) *
533 sizeof(xfs_dqblk_t); 535 sizeof(xfs_dqblk_t);
534 if (map.br_startblock == HOLESTARTBLOCK) { 536 if (map.br_startblock == HOLESTARTBLOCK) {
535 /* 537 /*
@@ -559,15 +561,13 @@ xfs_qm_dqtobp(
559 * Read in the buffer, unless we've just done the allocation 561 * Read in the buffer, unless we've just done the allocation
560 * (in which case we already have the buf). 562 * (in which case we already have the buf).
561 */ 563 */
562 if (! newdquot) { 564 if (!newdquot) {
563 trace_xfs_dqtobp_read(dqp); 565 trace_xfs_dqtobp_read(dqp);
564 566
565 if ((error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, 567 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp,
566 dqp->q_blkno, 568 dqp->q_blkno,
567 XFS_QI_DQCHUNKLEN(mp), 569 mp->m_quotainfo->qi_dqchunklen,
568 0, &bp))) { 570 0, &bp);
569 return (error);
570 }
571 if (error || !bp) 571 if (error || !bp)
572 return XFS_ERROR(error); 572 return XFS_ERROR(error);
573 } 573 }
@@ -689,14 +689,14 @@ xfs_qm_idtodq(
689 tp = NULL; 689 tp = NULL;
690 if (flags & XFS_QMOPT_DQALLOC) { 690 if (flags & XFS_QMOPT_DQALLOC) {
691 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC); 691 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC);
692 if ((error = xfs_trans_reserve(tp, 692 error = xfs_trans_reserve(tp, XFS_QM_DQALLOC_SPACE_RES(mp),
693 XFS_QM_DQALLOC_SPACE_RES(mp), 693 XFS_WRITE_LOG_RES(mp) +
694 XFS_WRITE_LOG_RES(mp) + 694 BBTOB(mp->m_quotainfo->qi_dqchunklen) - 1 +
695 BBTOB(XFS_QI_DQCHUNKLEN(mp)) - 1 + 695 128,
696 128, 696 0,
697 0, 697 XFS_TRANS_PERM_LOG_RES,
698 XFS_TRANS_PERM_LOG_RES, 698 XFS_WRITE_LOG_COUNT);
699 XFS_WRITE_LOG_COUNT))) { 699 if (error) {
700 cancelflags = 0; 700 cancelflags = 0;
701 goto error0; 701 goto error0;
702 } 702 }
@@ -1495,6 +1495,7 @@ void
1495xfs_qm_dqflock_pushbuf_wait( 1495xfs_qm_dqflock_pushbuf_wait(
1496 xfs_dquot_t *dqp) 1496 xfs_dquot_t *dqp)
1497{ 1497{
1498 xfs_mount_t *mp = dqp->q_mount;
1498 xfs_buf_t *bp; 1499 xfs_buf_t *bp;
1499 1500
1500 /* 1501 /*
@@ -1503,14 +1504,14 @@ xfs_qm_dqflock_pushbuf_wait(
1503 * out immediately. We'll be able to acquire 1504 * out immediately. We'll be able to acquire
1504 * the flush lock when the I/O completes. 1505 * the flush lock when the I/O completes.
1505 */ 1506 */
1506 bp = xfs_incore(dqp->q_mount->m_ddev_targp, dqp->q_blkno, 1507 bp = xfs_incore(mp->m_ddev_targp, dqp->q_blkno,
1507 XFS_QI_DQCHUNKLEN(dqp->q_mount), XBF_TRYLOCK); 1508 mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK);
1508 if (!bp) 1509 if (!bp)
1509 goto out_lock; 1510 goto out_lock;
1510 1511
1511 if (XFS_BUF_ISDELAYWRITE(bp)) { 1512 if (XFS_BUF_ISDELAYWRITE(bp)) {
1512 if (XFS_BUF_ISPINNED(bp)) 1513 if (XFS_BUF_ISPINNED(bp))
1513 xfs_log_force(dqp->q_mount, 0); 1514 xfs_log_force(mp, 0);
1514 xfs_buf_delwri_promote(bp); 1515 xfs_buf_delwri_promote(bp);
1515 wake_up_process(bp->b_target->bt_task); 1516 wake_up_process(bp->b_target->bt_task);
1516 } 1517 }
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index 165bbdf44be..8d89a24ae32 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -227,7 +227,7 @@ xfs_qm_dquot_logitem_pushbuf(
227 } 227 }
228 mp = dqp->q_mount; 228 mp = dqp->q_mount;
229 bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno, 229 bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno,
230 XFS_QI_DQCHUNKLEN(mp), XBF_TRYLOCK); 230 mp->m_quotainfo->qi_dqchunklen, XBF_TRYLOCK);
231 xfs_dqunlock(dqp); 231 xfs_dqunlock(dqp);
232 if (!bp) 232 if (!bp)
233 return; 233 return;
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index c40ca94e23e..6ef2809b316 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -465,20 +465,21 @@ xfs_qm_unmount_quotas(
465 */ 465 */
466STATIC int 466STATIC int
467xfs_qm_dqflush_all( 467xfs_qm_dqflush_all(
468 xfs_mount_t *mp, 468 struct xfs_mount *mp,
469 int sync_mode) 469 int sync_mode)
470{ 470{
471 int recl; 471 struct xfs_quotainfo *q = mp->m_quotainfo;
472 xfs_dquot_t *dqp; 472 int recl;
473 int niters; 473 struct xfs_dquot *dqp;
474 int error; 474 int niters;
475 int error;
475 476
476 if (mp->m_quotainfo == NULL) 477 if (!q)
477 return 0; 478 return 0;
478 niters = 0; 479 niters = 0;
479again: 480again:
480 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 481 mutex_lock(&q->qi_dqlist_lock);
481 list_for_each_entry(dqp, &mp->m_quotainfo->qi_dqlist, q_mplist) { 482 list_for_each_entry(dqp, &q->qi_dqlist, q_mplist) {
482 xfs_dqlock(dqp); 483 xfs_dqlock(dqp);
483 if (! XFS_DQ_IS_DIRTY(dqp)) { 484 if (! XFS_DQ_IS_DIRTY(dqp)) {
484 xfs_dqunlock(dqp); 485 xfs_dqunlock(dqp);
@@ -486,7 +487,7 @@ again:
486 } 487 }
487 488
488 /* XXX a sentinel would be better */ 489 /* XXX a sentinel would be better */
489 recl = mp->m_quotainfo->qi_dqreclaims; 490 recl = q->qi_dqreclaims;
490 if (!xfs_dqflock_nowait(dqp)) { 491 if (!xfs_dqflock_nowait(dqp)) {
491 /* 492 /*
492 * If we can't grab the flush lock then check 493 * If we can't grab the flush lock then check
@@ -501,21 +502,21 @@ again:
501 * Let go of the mplist lock. We don't want to hold it 502 * Let go of the mplist lock. We don't want to hold it
502 * across a disk write. 503 * across a disk write.
503 */ 504 */
504 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 505 mutex_unlock(&q->qi_dqlist_lock);
505 error = xfs_qm_dqflush(dqp, sync_mode); 506 error = xfs_qm_dqflush(dqp, sync_mode);
506 xfs_dqunlock(dqp); 507 xfs_dqunlock(dqp);
507 if (error) 508 if (error)
508 return error; 509 return error;
509 510
510 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 511 mutex_lock(&q->qi_dqlist_lock);
511 if (recl != mp->m_quotainfo->qi_dqreclaims) { 512 if (recl != q->qi_dqreclaims) {
512 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 513 mutex_unlock(&q->qi_dqlist_lock);
513 /* XXX restart limit */ 514 /* XXX restart limit */
514 goto again; 515 goto again;
515 } 516 }
516 } 517 }
517 518
518 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 519 mutex_unlock(&q->qi_dqlist_lock);
519 /* return ! busy */ 520 /* return ! busy */
520 return 0; 521 return 0;
521} 522}
@@ -525,14 +526,15 @@ again:
525 */ 526 */
526STATIC void 527STATIC void
527xfs_qm_detach_gdquots( 528xfs_qm_detach_gdquots(
528 xfs_mount_t *mp) 529 struct xfs_mount *mp)
529{ 530{
530 xfs_dquot_t *dqp, *gdqp; 531 struct xfs_quotainfo *q = mp->m_quotainfo;
531 int nrecl; 532 struct xfs_dquot *dqp, *gdqp;
533 int nrecl;
532 534
533 again: 535 again:
534 ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock)); 536 ASSERT(mutex_is_locked(&q->qi_dqlist_lock));
535 list_for_each_entry(dqp, &mp->m_quotainfo->qi_dqlist, q_mplist) { 537 list_for_each_entry(dqp, &q->qi_dqlist, q_mplist) {
536 xfs_dqlock(dqp); 538 xfs_dqlock(dqp);
537 if ((gdqp = dqp->q_gdquot)) { 539 if ((gdqp = dqp->q_gdquot)) {
538 xfs_dqlock(gdqp); 540 xfs_dqlock(gdqp);
@@ -545,12 +547,12 @@ xfs_qm_detach_gdquots(
545 * Can't hold the mplist lock across a dqput. 547 * Can't hold the mplist lock across a dqput.
546 * XXXmust convert to marker based iterations here. 548 * XXXmust convert to marker based iterations here.
547 */ 549 */
548 nrecl = mp->m_quotainfo->qi_dqreclaims; 550 nrecl = q->qi_dqreclaims;
549 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 551 mutex_unlock(&q->qi_dqlist_lock);
550 xfs_qm_dqput(gdqp); 552 xfs_qm_dqput(gdqp);
551 553
552 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 554 mutex_lock(&q->qi_dqlist_lock);
553 if (nrecl != mp->m_quotainfo->qi_dqreclaims) 555 if (nrecl != q->qi_dqreclaims)
554 goto again; 556 goto again;
555 } 557 }
556 } 558 }
@@ -564,22 +566,23 @@ xfs_qm_detach_gdquots(
564 */ 566 */
565STATIC int 567STATIC int
566xfs_qm_dqpurge_int( 568xfs_qm_dqpurge_int(
567 xfs_mount_t *mp, 569 struct xfs_mount *mp,
568 uint flags) /* QUOTAOFF/UMOUNTING/UQUOTA/PQUOTA/GQUOTA */ 570 uint flags)
569{ 571{
570 xfs_dquot_t *dqp, *n; 572 struct xfs_quotainfo *q = mp->m_quotainfo;
571 uint dqtype; 573 struct xfs_dquot *dqp, *n;
572 int nrecl; 574 uint dqtype;
573 int nmisses; 575 int nrecl;
576 int nmisses;
574 577
575 if (mp->m_quotainfo == NULL) 578 if (!q)
576 return 0; 579 return 0;
577 580
578 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0; 581 dqtype = (flags & XFS_QMOPT_UQUOTA) ? XFS_DQ_USER : 0;
579 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0; 582 dqtype |= (flags & XFS_QMOPT_PQUOTA) ? XFS_DQ_PROJ : 0;
580 dqtype |= (flags & XFS_QMOPT_GQUOTA) ? XFS_DQ_GROUP : 0; 583 dqtype |= (flags & XFS_QMOPT_GQUOTA) ? XFS_DQ_GROUP : 0;
581 584
582 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 585 mutex_lock(&q->qi_dqlist_lock);
583 586
584 /* 587 /*
585 * In the first pass through all incore dquots of this filesystem, 588 * In the first pass through all incore dquots of this filesystem,
@@ -591,12 +594,12 @@ xfs_qm_dqpurge_int(
591 594
592 again: 595 again:
593 nmisses = 0; 596 nmisses = 0;
594 ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock)); 597 ASSERT(mutex_is_locked(&q->qi_dqlist_lock));
595 /* 598 /*
596 * Try to get rid of all of the unwanted dquots. The idea is to 599 * Try to get rid of all of the unwanted dquots. The idea is to
597 * get them off mplist and hashlist, but leave them on freelist. 600 * get them off mplist and hashlist, but leave them on freelist.
598 */ 601 */
599 list_for_each_entry_safe(dqp, n, &mp->m_quotainfo->qi_dqlist, q_mplist) { 602 list_for_each_entry_safe(dqp, n, &q->qi_dqlist, q_mplist) {
600 /* 603 /*
601 * It's OK to look at the type without taking dqlock here. 604 * It's OK to look at the type without taking dqlock here.
602 * We're holding the mplist lock here, and that's needed for 605 * We're holding the mplist lock here, and that's needed for
@@ -606,10 +609,10 @@ xfs_qm_dqpurge_int(
606 continue; 609 continue;
607 610
608 if (!mutex_trylock(&dqp->q_hash->qh_lock)) { 611 if (!mutex_trylock(&dqp->q_hash->qh_lock)) {
609 nrecl = mp->m_quotainfo->qi_dqreclaims; 612 nrecl = q->qi_dqreclaims;
610 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 613 mutex_unlock(&q->qi_dqlist_lock);
611 mutex_lock(&dqp->q_hash->qh_lock); 614 mutex_lock(&dqp->q_hash->qh_lock);
612 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 615 mutex_lock(&q->qi_dqlist_lock);
613 616
614 /* 617 /*
615 * XXXTheoretically, we can get into a very long 618 * XXXTheoretically, we can get into a very long
@@ -617,7 +620,7 @@ xfs_qm_dqpurge_int(
617 * No one can be adding dquots to the mplist at 620 * No one can be adding dquots to the mplist at
618 * this point, but somebody might be taking things off. 621 * this point, but somebody might be taking things off.
619 */ 622 */
620 if (nrecl != mp->m_quotainfo->qi_dqreclaims) { 623 if (nrecl != q->qi_dqreclaims) {
621 mutex_unlock(&dqp->q_hash->qh_lock); 624 mutex_unlock(&dqp->q_hash->qh_lock);
622 goto again; 625 goto again;
623 } 626 }
@@ -629,7 +632,7 @@ xfs_qm_dqpurge_int(
629 */ 632 */
630 nmisses += xfs_qm_dqpurge(dqp); 633 nmisses += xfs_qm_dqpurge(dqp);
631 } 634 }
632 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 635 mutex_unlock(&q->qi_dqlist_lock);
633 return nmisses; 636 return nmisses;
634} 637}
635 638
@@ -929,12 +932,13 @@ xfs_qm_dqdetach(
929 932
930int 933int
931xfs_qm_sync( 934xfs_qm_sync(
932 xfs_mount_t *mp, 935 struct xfs_mount *mp,
933 int flags) 936 int flags)
934{ 937{
935 int recl, restarts; 938 struct xfs_quotainfo *q = mp->m_quotainfo;
936 xfs_dquot_t *dqp; 939 int recl, restarts;
937 int error; 940 struct xfs_dquot *dqp;
941 int error;
938 942
939 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) 943 if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp))
940 return 0; 944 return 0;
@@ -942,7 +946,7 @@ xfs_qm_sync(
942 restarts = 0; 946 restarts = 0;
943 947
944 again: 948 again:
945 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 949 mutex_lock(&q->qi_dqlist_lock);
946 /* 950 /*
947 * dqpurge_all() also takes the mplist lock and iterate thru all dquots 951 * dqpurge_all() also takes the mplist lock and iterate thru all dquots
948 * in quotaoff. However, if the QUOTA_ACTIVE bits are not cleared 952 * in quotaoff. However, if the QUOTA_ACTIVE bits are not cleared
@@ -950,11 +954,11 @@ xfs_qm_sync(
950 * as long as we have it locked. 954 * as long as we have it locked.
951 */ 955 */
952 if (!XFS_IS_QUOTA_ON(mp)) { 956 if (!XFS_IS_QUOTA_ON(mp)) {
953 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 957 mutex_unlock(&q->qi_dqlist_lock);
954 return 0; 958 return 0;
955 } 959 }
956 ASSERT(mutex_is_locked(&mp->m_quotainfo->qi_dqlist_lock)); 960 ASSERT(mutex_is_locked(&q->qi_dqlist_lock));
957 list_for_each_entry(dqp, &mp->m_quotainfo->qi_dqlist, q_mplist) { 961 list_for_each_entry(dqp, &q->qi_dqlist, q_mplist) {
958 /* 962 /*
959 * If this is vfs_sync calling, then skip the dquots that 963 * If this is vfs_sync calling, then skip the dquots that
960 * don't 'seem' to be dirty. ie. don't acquire dqlock. 964 * don't 'seem' to be dirty. ie. don't acquire dqlock.
@@ -978,7 +982,7 @@ xfs_qm_sync(
978 } 982 }
979 983
980 /* XXX a sentinel would be better */ 984 /* XXX a sentinel would be better */
981 recl = mp->m_quotainfo->qi_dqreclaims; 985 recl = q->qi_dqreclaims;
982 if (!xfs_dqflock_nowait(dqp)) { 986 if (!xfs_dqflock_nowait(dqp)) {
983 if (flags & SYNC_TRYLOCK) { 987 if (flags & SYNC_TRYLOCK) {
984 xfs_dqunlock(dqp); 988 xfs_dqunlock(dqp);
@@ -998,7 +1002,7 @@ xfs_qm_sync(
998 * Let go of the mplist lock. We don't want to hold it 1002 * Let go of the mplist lock. We don't want to hold it
999 * across a disk write 1003 * across a disk write
1000 */ 1004 */
1001 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 1005 mutex_unlock(&q->qi_dqlist_lock);
1002 error = xfs_qm_dqflush(dqp, flags); 1006 error = xfs_qm_dqflush(dqp, flags);
1003 xfs_dqunlock(dqp); 1007 xfs_dqunlock(dqp);
1004 if (error && XFS_FORCED_SHUTDOWN(mp)) 1008 if (error && XFS_FORCED_SHUTDOWN(mp))
@@ -1006,17 +1010,17 @@ xfs_qm_sync(
1006 else if (error) 1010 else if (error)
1007 return error; 1011 return error;
1008 1012
1009 mutex_lock(&mp->m_quotainfo->qi_dqlist_lock); 1013 mutex_lock(&q->qi_dqlist_lock);
1010 if (recl != mp->m_quotainfo->qi_dqreclaims) { 1014 if (recl != q->qi_dqreclaims) {
1011 if (++restarts >= XFS_QM_SYNC_MAX_RESTARTS) 1015 if (++restarts >= XFS_QM_SYNC_MAX_RESTARTS)
1012 break; 1016 break;
1013 1017
1014 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 1018 mutex_unlock(&q->qi_dqlist_lock);
1015 goto again; 1019 goto again;
1016 } 1020 }
1017 } 1021 }
1018 1022
1019 mutex_unlock(&mp->m_quotainfo->qi_dqlist_lock); 1023 mutex_unlock(&q->qi_dqlist_lock);
1020 return 0; 1024 return 0;
1021} 1025}
1022 1026
@@ -1382,10 +1386,10 @@ xfs_qm_reset_dqcounts(
1382#ifdef DEBUG 1386#ifdef DEBUG
1383 j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB); 1387 j = XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
1384 do_div(j, sizeof(xfs_dqblk_t)); 1388 do_div(j, sizeof(xfs_dqblk_t));
1385 ASSERT(XFS_QM_DQPERBLK(mp) == j); 1389 ASSERT(mp->m_quotainfo->qi_dqperchunk == j);
1386#endif 1390#endif
1387 ddq = (xfs_disk_dquot_t *)XFS_BUF_PTR(bp); 1391 ddq = (xfs_disk_dquot_t *)XFS_BUF_PTR(bp);
1388 for (j = 0; j < XFS_QM_DQPERBLK(mp); j++) { 1392 for (j = 0; j < mp->m_quotainfo->qi_dqperchunk; j++) {
1389 /* 1393 /*
1390 * Do a sanity check, and if needed, repair the dqblk. Don't 1394 * Do a sanity check, and if needed, repair the dqblk. Don't
1391 * output any warnings because it's perfectly possible to 1395 * output any warnings because it's perfectly possible to
@@ -1440,7 +1444,7 @@ xfs_qm_dqiter_bufs(
1440 while (blkcnt--) { 1444 while (blkcnt--) {
1441 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 1445 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
1442 XFS_FSB_TO_DADDR(mp, bno), 1446 XFS_FSB_TO_DADDR(mp, bno),
1443 (int)XFS_QI_DQCHUNKLEN(mp), 0, &bp); 1447 mp->m_quotainfo->qi_dqchunklen, 0, &bp);
1444 if (error) 1448 if (error)
1445 break; 1449 break;
1446 1450
@@ -1450,7 +1454,7 @@ xfs_qm_dqiter_bufs(
1450 * goto the next block. 1454 * goto the next block.
1451 */ 1455 */
1452 bno++; 1456 bno++;
1453 firstid += XFS_QM_DQPERBLK(mp); 1457 firstid += mp->m_quotainfo->qi_dqperchunk;
1454 } 1458 }
1455 return error; 1459 return error;
1456} 1460}
@@ -1516,7 +1520,7 @@ xfs_qm_dqiterate(
1516 continue; 1520 continue;
1517 1521
1518 firstid = (xfs_dqid_t) map[i].br_startoff * 1522 firstid = (xfs_dqid_t) map[i].br_startoff *
1519 XFS_QM_DQPERBLK(mp); 1523 mp->m_quotainfo->qi_dqperchunk;
1520 /* 1524 /*
1521 * Do a read-ahead on the next extent. 1525 * Do a read-ahead on the next extent.
1522 */ 1526 */
@@ -1527,7 +1531,7 @@ xfs_qm_dqiterate(
1527 while (rablkcnt--) { 1531 while (rablkcnt--) {
1528 xfs_baread(mp->m_ddev_targp, 1532 xfs_baread(mp->m_ddev_targp,
1529 XFS_FSB_TO_DADDR(mp, rablkno), 1533 XFS_FSB_TO_DADDR(mp, rablkno),
1530 (int)XFS_QI_DQCHUNKLEN(mp)); 1534 mp->m_quotainfo->qi_dqchunklen);
1531 rablkno++; 1535 rablkno++;
1532 } 1536 }
1533 } 1537 }
@@ -1758,7 +1762,7 @@ xfs_qm_quotacheck(
1758 lastino = 0; 1762 lastino = 0;
1759 flags = 0; 1763 flags = 0;
1760 1764
1761 ASSERT(XFS_QI_UQIP(mp) || XFS_QI_GQIP(mp)); 1765 ASSERT(mp->m_quotainfo->qi_uquotaip || mp->m_quotainfo->qi_gquotaip);
1762 ASSERT(XFS_IS_QUOTA_RUNNING(mp)); 1766 ASSERT(XFS_IS_QUOTA_RUNNING(mp));
1763 1767
1764 /* 1768 /*
@@ -1774,15 +1778,19 @@ xfs_qm_quotacheck(
1774 * their counters to zero. We need a clean slate. 1778 * their counters to zero. We need a clean slate.
1775 * We don't log our changes till later. 1779 * We don't log our changes till later.
1776 */ 1780 */
1777 if ((uip = XFS_QI_UQIP(mp))) { 1781 uip = mp->m_quotainfo->qi_uquotaip;
1778 if ((error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA))) 1782 if (uip) {
1783 error = xfs_qm_dqiterate(mp, uip, XFS_QMOPT_UQUOTA);
1784 if (error)
1779 goto error_return; 1785 goto error_return;
1780 flags |= XFS_UQUOTA_CHKD; 1786 flags |= XFS_UQUOTA_CHKD;
1781 } 1787 }
1782 1788
1783 if ((gip = XFS_QI_GQIP(mp))) { 1789 gip = mp->m_quotainfo->qi_gquotaip;
1784 if ((error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ? 1790 if (gip) {
1785 XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA))) 1791 error = xfs_qm_dqiterate(mp, gip, XFS_IS_GQUOTA_ON(mp) ?
1792 XFS_QMOPT_GQUOTA : XFS_QMOPT_PQUOTA);
1793 if (error)
1786 goto error_return; 1794 goto error_return;
1787 flags |= XFS_OQUOTA_CHKD; 1795 flags |= XFS_OQUOTA_CHKD;
1788 } 1796 }
@@ -1931,8 +1939,8 @@ xfs_qm_init_quotainos(
1931 } 1939 }
1932 } 1940 }
1933 1941
1934 XFS_QI_UQIP(mp) = uip; 1942 mp->m_quotainfo->qi_uquotaip = uip;
1935 XFS_QI_GQIP(mp) = gip; 1943 mp->m_quotainfo->qi_gquotaip = gip;
1936 1944
1937 return 0; 1945 return 0;
1938} 1946}
diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 45337440672..0688019984b 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -79,6 +79,7 @@ xfs_qm_scall_quotaoff(
79 xfs_mount_t *mp, 79 xfs_mount_t *mp,
80 uint flags) 80 uint flags)
81{ 81{
82 struct xfs_quotainfo *q = mp->m_quotainfo;
82 uint dqtype; 83 uint dqtype;
83 int error; 84 int error;
84 uint inactivate_flags; 85 uint inactivate_flags;
@@ -102,11 +103,8 @@ xfs_qm_scall_quotaoff(
102 * critical thing. 103 * critical thing.
103 * If quotaoff, then we must be dealing with the root filesystem. 104 * If quotaoff, then we must be dealing with the root filesystem.
104 */ 105 */
105 ASSERT(mp->m_quotainfo); 106 ASSERT(q);
106 if (mp->m_quotainfo) 107 mutex_lock(&q->qi_quotaofflock);
107 mutex_lock(&(XFS_QI_QOFFLOCK(mp)));
108
109 ASSERT(mp->m_quotainfo);
110 108
111 /* 109 /*
112 * If we're just turning off quota enforcement, change mp and go. 110 * If we're just turning off quota enforcement, change mp and go.
@@ -117,7 +115,7 @@ xfs_qm_scall_quotaoff(
117 spin_lock(&mp->m_sb_lock); 115 spin_lock(&mp->m_sb_lock);
118 mp->m_sb.sb_qflags = mp->m_qflags; 116 mp->m_sb.sb_qflags = mp->m_qflags;
119 spin_unlock(&mp->m_sb_lock); 117 spin_unlock(&mp->m_sb_lock);
120 mutex_unlock(&(XFS_QI_QOFFLOCK(mp))); 118 mutex_unlock(&q->qi_quotaofflock);
121 119
122 /* XXX what to do if error ? Revert back to old vals incore ? */ 120 /* XXX what to do if error ? Revert back to old vals incore ? */
123 error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS); 121 error = xfs_qm_write_sb_changes(mp, XFS_SB_QFLAGS);
@@ -150,10 +148,8 @@ xfs_qm_scall_quotaoff(
150 * Nothing to do? Don't complain. This happens when we're just 148 * Nothing to do? Don't complain. This happens when we're just
151 * turning off quota enforcement. 149 * turning off quota enforcement.
152 */ 150 */
153 if ((mp->m_qflags & flags) == 0) { 151 if ((mp->m_qflags & flags) == 0)
154 mutex_unlock(&(XFS_QI_QOFFLOCK(mp))); 152 goto out_unlock;
155 return (0);
156 }
157 153
158 /* 154 /*
159 * Write the LI_QUOTAOFF log record, and do SB changes atomically, 155 * Write the LI_QUOTAOFF log record, and do SB changes atomically,
@@ -162,7 +158,7 @@ xfs_qm_scall_quotaoff(
162 */ 158 */
163 error = xfs_qm_log_quotaoff(mp, &qoffstart, flags); 159 error = xfs_qm_log_quotaoff(mp, &qoffstart, flags);
164 if (error) 160 if (error)
165 goto out_error; 161 goto out_unlock;
166 162
167 /* 163 /*
168 * Next we clear the XFS_MOUNT_*DQ_ACTIVE bit(s) in the mount struct 164 * Next we clear the XFS_MOUNT_*DQ_ACTIVE bit(s) in the mount struct
@@ -222,7 +218,7 @@ xfs_qm_scall_quotaoff(
222 if (error) { 218 if (error) {
223 /* We're screwed now. Shutdown is the only option. */ 219 /* We're screwed now. Shutdown is the only option. */
224 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 220 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
225 goto out_error; 221 goto out_unlock;
226 } 222 }
227 223
228 /* 224 /*
@@ -230,27 +226,26 @@ xfs_qm_scall_quotaoff(
230 */ 226 */
231 if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) || 227 if (((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET1) ||
232 ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) { 228 ((flags & XFS_MOUNT_QUOTA_ALL) == XFS_MOUNT_QUOTA_SET2)) {
233 mutex_unlock(&(XFS_QI_QOFFLOCK(mp))); 229 mutex_unlock(&q->qi_quotaofflock);
234 xfs_qm_destroy_quotainfo(mp); 230 xfs_qm_destroy_quotainfo(mp);
235 return (0); 231 return (0);
236 } 232 }
237 233
238 /* 234 /*
239 * Release our quotainode references, and vn_purge them, 235 * Release our quotainode references if we don't need them anymore.
240 * if we don't need them anymore.
241 */ 236 */
242 if ((dqtype & XFS_QMOPT_UQUOTA) && XFS_QI_UQIP(mp)) { 237 if ((dqtype & XFS_QMOPT_UQUOTA) && q->qi_uquotaip) {
243 IRELE(XFS_QI_UQIP(mp)); 238 IRELE(q->qi_uquotaip);
244 XFS_QI_UQIP(mp) = NULL; 239 q->qi_uquotaip = NULL;
245 } 240 }
246 if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && XFS_QI_GQIP(mp)) { 241 if ((dqtype & (XFS_QMOPT_GQUOTA|XFS_QMOPT_PQUOTA)) && q->qi_gquotaip) {
247 IRELE(XFS_QI_GQIP(mp)); 242 IRELE(q->qi_gquotaip);
248 XFS_QI_GQIP(mp) = NULL; 243 q->qi_gquotaip = NULL;
249 } 244 }
250out_error:
251 mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
252 245
253 return (error); 246out_unlock:
247 mutex_unlock(&q->qi_quotaofflock);
248 return error;
254} 249}
255 250
256int 251int
@@ -379,9 +374,9 @@ xfs_qm_scall_quotaon(
379 /* 374 /*
380 * Switch on quota enforcement in core. 375 * Switch on quota enforcement in core.
381 */ 376 */
382 mutex_lock(&(XFS_QI_QOFFLOCK(mp))); 377 mutex_lock(&mp->m_quotainfo->qi_quotaofflock);
383 mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD); 378 mp->m_qflags |= (flags & XFS_ALL_QUOTA_ENFD);
384 mutex_unlock(&(XFS_QI_QOFFLOCK(mp))); 379 mutex_unlock(&mp->m_quotainfo->qi_quotaofflock);
385 380
386 return (0); 381 return (0);
387} 382}
@@ -392,11 +387,12 @@ xfs_qm_scall_quotaon(
392 */ 387 */
393int 388int
394xfs_qm_scall_getqstat( 389xfs_qm_scall_getqstat(
395 xfs_mount_t *mp, 390 struct xfs_mount *mp,
396 fs_quota_stat_t *out) 391 struct fs_quota_stat *out)
397{ 392{
398 xfs_inode_t *uip, *gip; 393 struct xfs_quotainfo *q = mp->m_quotainfo;
399 boolean_t tempuqip, tempgqip; 394 struct xfs_inode *uip, *gip;
395 boolean_t tempuqip, tempgqip;
400 396
401 uip = gip = NULL; 397 uip = gip = NULL;
402 tempuqip = tempgqip = B_FALSE; 398 tempuqip = tempgqip = B_FALSE;
@@ -415,9 +411,9 @@ xfs_qm_scall_getqstat(
415 out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino; 411 out->qs_uquota.qfs_ino = mp->m_sb.sb_uquotino;
416 out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino; 412 out->qs_gquota.qfs_ino = mp->m_sb.sb_gquotino;
417 413
418 if (mp->m_quotainfo) { 414 if (q) {
419 uip = mp->m_quotainfo->qi_uquotaip; 415 uip = q->qi_uquotaip;
420 gip = mp->m_quotainfo->qi_gquotaip; 416 gip = q->qi_gquotaip;
421 } 417 }
422 if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) { 418 if (!uip && mp->m_sb.sb_uquotino != NULLFSINO) {
423 if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino, 419 if (xfs_iget(mp, NULL, mp->m_sb.sb_uquotino,
@@ -441,15 +437,15 @@ xfs_qm_scall_getqstat(
441 if (tempgqip) 437 if (tempgqip)
442 IRELE(gip); 438 IRELE(gip);
443 } 439 }
444 if (mp->m_quotainfo) { 440 if (q) {
445 out->qs_incoredqs = mp->m_quotainfo->qi_dquots; 441 out->qs_incoredqs = q->qi_dquots;
446 out->qs_btimelimit = XFS_QI_BTIMELIMIT(mp); 442 out->qs_btimelimit = q->qi_btimelimit;
447 out->qs_itimelimit = XFS_QI_ITIMELIMIT(mp); 443 out->qs_itimelimit = q->qi_itimelimit;
448 out->qs_rtbtimelimit = XFS_QI_RTBTIMELIMIT(mp); 444 out->qs_rtbtimelimit = q->qi_rtbtimelimit;
449 out->qs_bwarnlimit = XFS_QI_BWARNLIMIT(mp); 445 out->qs_bwarnlimit = q->qi_bwarnlimit;
450 out->qs_iwarnlimit = XFS_QI_IWARNLIMIT(mp); 446 out->qs_iwarnlimit = q->qi_iwarnlimit;
451 } 447 }
452 return (0); 448 return 0;
453} 449}
454 450
455/* 451/*
@@ -462,6 +458,7 @@ xfs_qm_scall_setqlim(
462 uint type, 458 uint type,
463 fs_disk_quota_t *newlim) 459 fs_disk_quota_t *newlim)
464{ 460{
461 struct xfs_quotainfo *q = mp->m_quotainfo;
465 xfs_disk_dquot_t *ddq; 462 xfs_disk_dquot_t *ddq;
466 xfs_dquot_t *dqp; 463 xfs_dquot_t *dqp;
467 xfs_trans_t *tp; 464 xfs_trans_t *tp;
@@ -485,7 +482,7 @@ xfs_qm_scall_setqlim(
485 * a quotaoff from happening). (XXXThis doesn't currently happen 482 * a quotaoff from happening). (XXXThis doesn't currently happen
486 * because we take the vfslock before calling xfs_qm_sysent). 483 * because we take the vfslock before calling xfs_qm_sysent).
487 */ 484 */
488 mutex_lock(&(XFS_QI_QOFFLOCK(mp))); 485 mutex_lock(&q->qi_quotaofflock);
489 486
490 /* 487 /*
491 * Get the dquot (locked), and join it to the transaction. 488 * Get the dquot (locked), and join it to the transaction.
@@ -493,9 +490,8 @@ xfs_qm_scall_setqlim(
493 */ 490 */
494 if ((error = xfs_qm_dqget(mp, NULL, id, type, XFS_QMOPT_DQALLOC, &dqp))) { 491 if ((error = xfs_qm_dqget(mp, NULL, id, type, XFS_QMOPT_DQALLOC, &dqp))) {
495 xfs_trans_cancel(tp, XFS_TRANS_ABORT); 492 xfs_trans_cancel(tp, XFS_TRANS_ABORT);
496 mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
497 ASSERT(error != ENOENT); 493 ASSERT(error != ENOENT);
498 return (error); 494 goto out_unlock;
499 } 495 }
500 xfs_trans_dqjoin(tp, dqp); 496 xfs_trans_dqjoin(tp, dqp);
501 ddq = &dqp->q_core; 497 ddq = &dqp->q_core;
@@ -513,8 +509,8 @@ xfs_qm_scall_setqlim(
513 ddq->d_blk_hardlimit = cpu_to_be64(hard); 509 ddq->d_blk_hardlimit = cpu_to_be64(hard);
514 ddq->d_blk_softlimit = cpu_to_be64(soft); 510 ddq->d_blk_softlimit = cpu_to_be64(soft);
515 if (id == 0) { 511 if (id == 0) {
516 mp->m_quotainfo->qi_bhardlimit = hard; 512 q->qi_bhardlimit = hard;
517 mp->m_quotainfo->qi_bsoftlimit = soft; 513 q->qi_bsoftlimit = soft;
518 } 514 }
519 } else { 515 } else {
520 qdprintk("blkhard %Ld < blksoft %Ld\n", hard, soft); 516 qdprintk("blkhard %Ld < blksoft %Ld\n", hard, soft);
@@ -529,8 +525,8 @@ xfs_qm_scall_setqlim(
529 ddq->d_rtb_hardlimit = cpu_to_be64(hard); 525 ddq->d_rtb_hardlimit = cpu_to_be64(hard);
530 ddq->d_rtb_softlimit = cpu_to_be64(soft); 526 ddq->d_rtb_softlimit = cpu_to_be64(soft);
531 if (id == 0) { 527 if (id == 0) {
532 mp->m_quotainfo->qi_rtbhardlimit = hard; 528 q->qi_rtbhardlimit = hard;
533 mp->m_quotainfo->qi_rtbsoftlimit = soft; 529 q->qi_rtbsoftlimit = soft;
534 } 530 }
535 } else { 531 } else {
536 qdprintk("rtbhard %Ld < rtbsoft %Ld\n", hard, soft); 532 qdprintk("rtbhard %Ld < rtbsoft %Ld\n", hard, soft);
@@ -546,8 +542,8 @@ xfs_qm_scall_setqlim(
546 ddq->d_ino_hardlimit = cpu_to_be64(hard); 542 ddq->d_ino_hardlimit = cpu_to_be64(hard);
547 ddq->d_ino_softlimit = cpu_to_be64(soft); 543 ddq->d_ino_softlimit = cpu_to_be64(soft);
548 if (id == 0) { 544 if (id == 0) {
549 mp->m_quotainfo->qi_ihardlimit = hard; 545 q->qi_ihardlimit = hard;
550 mp->m_quotainfo->qi_isoftlimit = soft; 546 q->qi_isoftlimit = soft;
551 } 547 }
552 } else { 548 } else {
553 qdprintk("ihard %Ld < isoft %Ld\n", hard, soft); 549 qdprintk("ihard %Ld < isoft %Ld\n", hard, soft);
@@ -572,23 +568,23 @@ xfs_qm_scall_setqlim(
572 * for warnings. 568 * for warnings.
573 */ 569 */
574 if (newlim->d_fieldmask & FS_DQ_BTIMER) { 570 if (newlim->d_fieldmask & FS_DQ_BTIMER) {
575 mp->m_quotainfo->qi_btimelimit = newlim->d_btimer; 571 q->qi_btimelimit = newlim->d_btimer;
576 ddq->d_btimer = cpu_to_be32(newlim->d_btimer); 572 ddq->d_btimer = cpu_to_be32(newlim->d_btimer);
577 } 573 }
578 if (newlim->d_fieldmask & FS_DQ_ITIMER) { 574 if (newlim->d_fieldmask & FS_DQ_ITIMER) {
579 mp->m_quotainfo->qi_itimelimit = newlim->d_itimer; 575 q->qi_itimelimit = newlim->d_itimer;
580 ddq->d_itimer = cpu_to_be32(newlim->d_itimer); 576 ddq->d_itimer = cpu_to_be32(newlim->d_itimer);
581 } 577 }
582 if (newlim->d_fieldmask & FS_DQ_RTBTIMER) { 578 if (newlim->d_fieldmask & FS_DQ_RTBTIMER) {
583 mp->m_quotainfo->qi_rtbtimelimit = newlim->d_rtbtimer; 579 q->qi_rtbtimelimit = newlim->d_rtbtimer;
584 ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer); 580 ddq->d_rtbtimer = cpu_to_be32(newlim->d_rtbtimer);
585 } 581 }
586 if (newlim->d_fieldmask & FS_DQ_BWARNS) 582 if (newlim->d_fieldmask & FS_DQ_BWARNS)
587 mp->m_quotainfo->qi_bwarnlimit = newlim->d_bwarns; 583 q->qi_bwarnlimit = newlim->d_bwarns;
588 if (newlim->d_fieldmask & FS_DQ_IWARNS) 584 if (newlim->d_fieldmask & FS_DQ_IWARNS)
589 mp->m_quotainfo->qi_iwarnlimit = newlim->d_iwarns; 585 q->qi_iwarnlimit = newlim->d_iwarns;
590 if (newlim->d_fieldmask & FS_DQ_RTBWARNS) 586 if (newlim->d_fieldmask & FS_DQ_RTBWARNS)
591 mp->m_quotainfo->qi_rtbwarnlimit = newlim->d_rtbwarns; 587 q->qi_rtbwarnlimit = newlim->d_rtbwarns;
592 } else { 588 } else {
593 /* 589 /*
594 * If the user is now over quota, start the timelimit. 590 * If the user is now over quota, start the timelimit.
@@ -605,8 +601,9 @@ xfs_qm_scall_setqlim(
605 error = xfs_trans_commit(tp, 0); 601 error = xfs_trans_commit(tp, 0);
606 xfs_qm_dqprint(dqp); 602 xfs_qm_dqprint(dqp);
607 xfs_qm_dqrele(dqp); 603 xfs_qm_dqrele(dqp);
608 mutex_unlock(&(XFS_QI_QOFFLOCK(mp)));
609 604
605 out_unlock:
606 mutex_unlock(&q->qi_quotaofflock);
610 return error; 607 return error;
611} 608}
612 609
@@ -853,7 +850,8 @@ xfs_dqrele_inode(
853 int error; 850 int error;
854 851
855 /* skip quota inodes */ 852 /* skip quota inodes */
856 if (ip == XFS_QI_UQIP(ip->i_mount) || ip == XFS_QI_GQIP(ip->i_mount)) { 853 if (ip == ip->i_mount->m_quotainfo->qi_uquotaip ||
854 ip == ip->i_mount->m_quotainfo->qi_gquotaip) {
857 ASSERT(ip->i_udquot == NULL); 855 ASSERT(ip->i_udquot == NULL);
858 ASSERT(ip->i_gdquot == NULL); 856 ASSERT(ip->i_gdquot == NULL);
859 read_unlock(&pag->pag_ici_lock); 857 read_unlock(&pag->pag_ici_lock);
diff --git a/fs/xfs/quota/xfs_quota_priv.h b/fs/xfs/quota/xfs_quota_priv.h
index 3eeee2e591d..f1179ffa5e9 100644
--- a/fs/xfs/quota/xfs_quota_priv.h
+++ b/fs/xfs/quota/xfs_quota_priv.h
@@ -24,22 +24,8 @@
24 */ 24 */
25#define XFS_DQITER_MAP_SIZE 10 25#define XFS_DQITER_MAP_SIZE 10
26 26
27/* Number of dquots that fit in to a dquot block */
28#define XFS_QM_DQPERBLK(mp) ((mp)->m_quotainfo->qi_dqperchunk)
29
30#define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t)) 27#define XFS_DQ_IS_ADDEDTO_TRX(t, d) ((d)->q_transp == (t))
31 28
32#define XFS_QI_UQIP(mp) ((mp)->m_quotainfo->qi_uquotaip)
33#define XFS_QI_GQIP(mp) ((mp)->m_quotainfo->qi_gquotaip)
34#define XFS_QI_DQCHUNKLEN(mp) ((mp)->m_quotainfo->qi_dqchunklen)
35#define XFS_QI_BTIMELIMIT(mp) ((mp)->m_quotainfo->qi_btimelimit)
36#define XFS_QI_RTBTIMELIMIT(mp) ((mp)->m_quotainfo->qi_rtbtimelimit)
37#define XFS_QI_ITIMELIMIT(mp) ((mp)->m_quotainfo->qi_itimelimit)
38#define XFS_QI_BWARNLIMIT(mp) ((mp)->m_quotainfo->qi_bwarnlimit)
39#define XFS_QI_RTBWARNLIMIT(mp) ((mp)->m_quotainfo->qi_rtbwarnlimit)
40#define XFS_QI_IWARNLIMIT(mp) ((mp)->m_quotainfo->qi_iwarnlimit)
41#define XFS_QI_QOFFLOCK(mp) ((mp)->m_quotainfo->qi_quotaofflock)
42
43/* 29/*
44 * Hash into a bucket in the dquot hash table, based on <mp, id>. 30 * Hash into a bucket in the dquot hash table, based on <mp, id>.
45 */ 31 */
diff --git a/fs/xfs/quota/xfs_trans_dquot.c b/fs/xfs/quota/xfs_trans_dquot.c
index c3ab75cb1d9..5ae2e32ae7b 100644
--- a/fs/xfs/quota/xfs_trans_dquot.c
+++ b/fs/xfs/quota/xfs_trans_dquot.c
@@ -639,7 +639,7 @@ xfs_trans_dqresv(
639 softlimit = q->qi_bsoftlimit; 639 softlimit = q->qi_bsoftlimit;
640 timer = be32_to_cpu(dqp->q_core.d_btimer); 640 timer = be32_to_cpu(dqp->q_core.d_btimer);
641 warns = be16_to_cpu(dqp->q_core.d_bwarns); 641 warns = be16_to_cpu(dqp->q_core.d_bwarns);
642 warnlimit = XFS_QI_BWARNLIMIT(dqp->q_mount); 642 warnlimit = dqp->q_mount->m_quotainfo->qi_bwarnlimit;
643 resbcountp = &dqp->q_res_bcount; 643 resbcountp = &dqp->q_res_bcount;
644 } else { 644 } else {
645 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS); 645 ASSERT(flags & XFS_TRANS_DQ_RES_RTBLKS);
@@ -651,7 +651,7 @@ xfs_trans_dqresv(
651 softlimit = q->qi_rtbsoftlimit; 651 softlimit = q->qi_rtbsoftlimit;
652 timer = be32_to_cpu(dqp->q_core.d_rtbtimer); 652 timer = be32_to_cpu(dqp->q_core.d_rtbtimer);
653 warns = be16_to_cpu(dqp->q_core.d_rtbwarns); 653 warns = be16_to_cpu(dqp->q_core.d_rtbwarns);
654 warnlimit = XFS_QI_RTBWARNLIMIT(dqp->q_mount); 654 warnlimit = dqp->q_mount->m_quotainfo->qi_rtbwarnlimit;
655 resbcountp = &dqp->q_res_rtbcount; 655 resbcountp = &dqp->q_res_rtbcount;
656 } 656 }
657 657
@@ -691,7 +691,7 @@ xfs_trans_dqresv(
691 count = be64_to_cpu(dqp->q_core.d_icount); 691 count = be64_to_cpu(dqp->q_core.d_icount);
692 timer = be32_to_cpu(dqp->q_core.d_itimer); 692 timer = be32_to_cpu(dqp->q_core.d_itimer);
693 warns = be16_to_cpu(dqp->q_core.d_iwarns); 693 warns = be16_to_cpu(dqp->q_core.d_iwarns);
694 warnlimit = XFS_QI_IWARNLIMIT(dqp->q_mount); 694 warnlimit = dqp->q_mount->m_quotainfo->qi_iwarnlimit;
695 hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit); 695 hardlimit = be64_to_cpu(dqp->q_core.d_ino_hardlimit);
696 if (!hardlimit) 696 if (!hardlimit)
697 hardlimit = q->qi_ihardlimit; 697 hardlimit = q->qi_ihardlimit;