Skip to content

Commit 50e0bdb

Browse files
committed
xfs: grab dquots without taking the ilock
Add a new dqget flag that grabs the dquot without taking the ilock. This will be used by the scrubber (which will have already grabbed the ilock) to perform basic sanity checking of the quota data. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
1 parent 244e3de commit 50e0bdb

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

fs/xfs/libxfs/xfs_quota_defs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ typedef uint16_t xfs_qwarncnt_t;
136136
*/
137137
#define XFS_QMOPT_INHERIT 0x1000000
138138

139+
#define XFS_QMOPT_NOLOCK 0x2000000 /* don't ilock during dqget */
140+
139141
/*
140142
* flags to xfs_trans_mod_dquot.
141143
*/

fs/xfs/xfs_dquot.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,23 @@ xfs_qm_dqtobp(
472472
struct xfs_mount *mp = dqp->q_mount;
473473
xfs_dqid_t id = be32_to_cpu(dqp->q_core.d_id);
474474
struct xfs_trans *tp = (tpp ? *tpp : NULL);
475-
uint lock_mode;
475+
uint lock_mode = 0;
476476

477477
quotip = xfs_quota_inode(dqp->q_mount, dqp->dq_flags);
478478
dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;
479479

480-
lock_mode = xfs_ilock_data_map_shared(quotip);
480+
ASSERT(!(flags & XFS_QMOPT_NOLOCK) ||
481+
xfs_isilocked(quotip, XFS_ILOCK_SHARED) ||
482+
xfs_isilocked(quotip, XFS_ILOCK_EXCL));
483+
if (!(flags & XFS_QMOPT_NOLOCK))
484+
lock_mode = xfs_ilock_data_map_shared(quotip);
481485
if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
482486
/*
483487
* Return if this type of quotas is turned off while we
484488
* didn't have the quota inode lock.
485489
*/
486-
xfs_iunlock(quotip, lock_mode);
490+
if (lock_mode)
491+
xfs_iunlock(quotip, lock_mode);
487492
return -ESRCH;
488493
}
489494

@@ -493,7 +498,8 @@ xfs_qm_dqtobp(
493498
error = xfs_bmapi_read(quotip, dqp->q_fileoffset,
494499
XFS_DQUOT_CLUSTER_SIZE_FSB, &map, &nmaps, 0);
495500

496-
xfs_iunlock(quotip, lock_mode);
501+
if (lock_mode)
502+
xfs_iunlock(quotip, lock_mode);
497503
if (error)
498504
return error;
499505

0 commit comments

Comments
 (0)