diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-03-27 10:34:46 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-05-14 17:20:15 -0400 |
commit | b4d05e3019692fc5a8c573fbce60de2d48c5b7a1 (patch) | |
tree | df2c46061cc44055771475056962bc4c45a7b758 | |
parent | 8a00ebe4cfc90eda9ecb575ba97e22021cd8cf70 (diff) |
xfs: avoid taking the ilock unnessecarily in xfs_qm_dqattach
Check if we actually need to attach a dquot before taking the ilock in
xfs_qm_dqattach. This avoid superflous lock roundtrips for the common cases
of quota support compiled in but not activated on a filesystem and an
inode that already has the dquots attached.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
-rw-r--r-- | fs/xfs/xfs_qm.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 55c6afedc879..18ba438386ab 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -483,6 +483,23 @@ done: | |||
483 | xfs_dqunlock(udq); | 483 | xfs_dqunlock(udq); |
484 | } | 484 | } |
485 | 485 | ||
486 | static bool | ||
487 | xfs_qm_need_dqattach( | ||
488 | struct xfs_inode *ip) | ||
489 | { | ||
490 | struct xfs_mount *mp = ip->i_mount; | ||
491 | |||
492 | if (!XFS_IS_QUOTA_RUNNING(mp)) | ||
493 | return false; | ||
494 | if (!XFS_IS_QUOTA_ON(mp)) | ||
495 | return false; | ||
496 | if (!XFS_NOT_DQATTACHED(mp, ip)) | ||
497 | return false; | ||
498 | if (ip->i_ino == mp->m_sb.sb_uquotino || | ||
499 | ip->i_ino == mp->m_sb.sb_gquotino) | ||
500 | return false; | ||
501 | return true; | ||
502 | } | ||
486 | 503 | ||
487 | /* | 504 | /* |
488 | * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON | 505 | * Given a locked inode, attach dquot(s) to it, taking U/G/P-QUOTAON |
@@ -500,11 +517,7 @@ xfs_qm_dqattach_locked( | |||
500 | uint nquotas = 0; | 517 | uint nquotas = 0; |
501 | int error = 0; | 518 | int error = 0; |
502 | 519 | ||
503 | if (!XFS_IS_QUOTA_RUNNING(mp) || | 520 | if (!xfs_qm_need_dqattach(ip)) |
504 | !XFS_IS_QUOTA_ON(mp) || | ||
505 | !XFS_NOT_DQATTACHED(mp, ip) || | ||
506 | ip->i_ino == mp->m_sb.sb_uquotino || | ||
507 | ip->i_ino == mp->m_sb.sb_gquotino) | ||
508 | return 0; | 521 | return 0; |
509 | 522 | ||
510 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); | 523 | ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); |
@@ -575,6 +588,9 @@ xfs_qm_dqattach( | |||
575 | { | 588 | { |
576 | int error; | 589 | int error; |
577 | 590 | ||
591 | if (!xfs_qm_need_dqattach(ip)) | ||
592 | return 0; | ||
593 | |||
578 | xfs_ilock(ip, XFS_ILOCK_EXCL); | 594 | xfs_ilock(ip, XFS_ILOCK_EXCL); |
579 | error = xfs_qm_dqattach_locked(ip, flags); | 595 | error = xfs_qm_dqattach_locked(ip, flags); |
580 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 596 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |