aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/quota/xfs_qm.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-04-20 03:01:30 -0400
committerAlex Elder <aelder@sgi.com>2010-05-19 10:58:14 -0400
commit8a7b8a89a3ae5b510396cdcc821698d4aa20afcf (patch)
treec64b285dfc53091a258319c82571431c25b85921 /fs/xfs/quota/xfs_qm.c
parent37bc5743fdc29f60fb104cd9031babbabddff25a (diff)
xfs: access quotainfo structure directly
Access fields in m_quotainfo directly instead of hiding them behind the XFS_QI_* macros. Add local variables for the quotainfo pointer in places where we have lots of them. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/quota/xfs_qm.c')
-rw-r--r--fs/xfs/quota/xfs_qm.c144
1 files changed, 76 insertions, 68 deletions
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index c40ca94e23ea..6ef2809b3166 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}