Skip to content

Commit 55c1bc3

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: return the dquot unlocked from xfs_qm_dqget
There is no reason to lock the dquot in xfs_qm_dqget, which just acquires a reference. Move the locking to the callers, or remove it in cases where the caller instantly unlocks the dquot. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent bf5066e commit 55c1bc3

7 files changed

Lines changed: 9 additions & 5 deletions

File tree

fs/xfs/scrub/dqiterate.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ xchk_dquot_iter(
205205
if (error)
206206
return error;
207207

208+
mutex_lock(&dq->q_qlock);
208209
cursor->id = dq->q_id + 1;
209210
*dqpp = dq;
210211
return 1;

fs/xfs/scrub/quotacheck.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ xqcheck_walk_observations(
635635
if (error)
636636
return error;
637637

638+
mutex_lock(&dq->q_qlock);
638639
error = xqcheck_compare_dquot(xqc, dqtype, dq);
639640
mutex_unlock(&dq->q_qlock);
640641
xfs_qm_dqrele(dq);

fs/xfs/scrub/quotacheck_repair.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ xqcheck_commit_dqtype(
187187
if (error)
188188
return error;
189189

190+
mutex_lock(&dq->q_qlock);
190191
error = xqcheck_commit_dquot(xqc, dqtype, dq);
191192
mutex_unlock(&dq->q_qlock);
192193
xfs_qm_dqrele(dq);

fs/xfs/xfs_dquot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ xfs_qm_dqget_checks(
895895

896896
/*
897897
* Given the file system, id, and type (UDQUOT/GDQUOT/PDQUOT), return a
898-
* locked dquot, doing an allocation (if requested) as needed.
898+
* dquot, doing an allocation (if requested) as needed.
899899
*/
900900
int
901901
xfs_qm_dqget(
@@ -940,7 +940,6 @@ xfs_qm_dqget(
940940
trace_xfs_dqget_miss(dqp);
941941
found:
942942
*O_dqpp = dqp;
943-
mutex_lock(&dqp->q_qlock);
944943
return 0;
945944
}
946945

@@ -1098,6 +1097,7 @@ xfs_qm_dqget_next(
10981097
else if (error != 0)
10991098
break;
11001099

1100+
mutex_lock(&dqp->q_qlock);
11011101
if (!XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
11021102
*dqpp = dqp;
11031103
return 0;

fs/xfs/xfs_qm.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,7 @@ xfs_qm_quotacheck_dqadjust(
12681268
return error;
12691269
}
12701270

1271+
mutex_lock(&dqp->q_qlock);
12711272
error = xfs_dquot_attach_buf(NULL, dqp);
12721273
if (error)
12731274
goto out_unlock;
@@ -1907,7 +1908,6 @@ xfs_qm_vop_dqalloc(
19071908
/*
19081909
* Get the ilock in the right order.
19091910
*/
1910-
mutex_unlock(&uq->q_qlock);
19111911
lockflags = XFS_ILOCK_SHARED;
19121912
xfs_ilock(ip, lockflags);
19131913
} else {
@@ -1929,7 +1929,6 @@ xfs_qm_vop_dqalloc(
19291929
ASSERT(error != -ENOENT);
19301930
goto error_rele;
19311931
}
1932-
mutex_unlock(&gq->q_qlock);
19331932
lockflags = XFS_ILOCK_SHARED;
19341933
xfs_ilock(ip, lockflags);
19351934
} else {
@@ -1947,7 +1946,6 @@ xfs_qm_vop_dqalloc(
19471946
ASSERT(error != -ENOENT);
19481947
goto error_rele;
19491948
}
1950-
mutex_unlock(&pq->q_qlock);
19511949
lockflags = XFS_ILOCK_SHARED;
19521950
xfs_ilock(ip, lockflags);
19531951
} else {

fs/xfs/xfs_qm_bhv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ xfs_qm_statvfs(
7373
struct xfs_dquot *dqp;
7474

7575
if (!xfs_qm_dqget(mp, ip->i_projid, XFS_DQTYPE_PROJ, false, &dqp)) {
76+
mutex_lock(&dqp->q_qlock);
7677
xfs_fill_statvfs_from_dquot(statp, ip, dqp);
7778
mutex_unlock(&dqp->q_qlock);
7879
xfs_qm_dqrele(dqp);

fs/xfs/xfs_qm_syscalls.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ xfs_qm_scall_setqlim(
302302
return error;
303303
}
304304

305+
mutex_lock(&dqp->q_qlock);
305306
defq = xfs_get_defquota(q, xfs_dquot_type(dqp));
306307
mutex_unlock(&dqp->q_qlock);
307308

@@ -459,6 +460,7 @@ xfs_qm_scall_getquota(
459460
* If everything's NULL, this dquot doesn't quite exist as far as
460461
* our utility programs are concerned.
461462
*/
463+
mutex_lock(&dqp->q_qlock);
462464
if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
463465
error = -ENOENT;
464466
goto out_put;

0 commit comments

Comments
 (0)