Skip to content

Commit 6129b08

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: remove xfs_dqunlock and friends
There's really no point in wrapping the basic mutex operations. Remove the wrapper to ease lock analysis annotations and make the code a litte easier to read. 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 36cebab commit 6129b08

9 files changed

Lines changed: 47 additions & 62 deletions

File tree

fs/xfs/scrub/quota.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ xchk_quota_item(
158158
* However, dqiterate gave us a locked dquot, so drop the dquot lock to
159159
* get the ILOCK.
160160
*/
161-
xfs_dqunlock(dq);
161+
mutex_unlock(&dq->q_qlock);
162162
xchk_ilock(sc, XFS_ILOCK_SHARED);
163-
xfs_dqlock(dq);
163+
mutex_lock(&dq->q_qlock);
164164

165165
/*
166166
* Except for the root dquot, the actual dquot we got must either have

fs/xfs/scrub/quota_repair.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ xrep_quota_item(
187187
* dqiterate gave us a locked dquot, so drop the dquot lock to get the
188188
* ILOCK_EXCL.
189189
*/
190-
xfs_dqunlock(dq);
190+
mutex_unlock(&dq->q_qlock);
191191
xchk_ilock(sc, XFS_ILOCK_EXCL);
192-
xfs_dqlock(dq);
192+
mutex_lock(&dq->q_qlock);
193193

194194
error = xrep_quota_item_bmap(sc, dq, &dirty);
195195
xchk_iunlock(sc, XFS_ILOCK_EXCL);
@@ -258,7 +258,7 @@ xrep_quota_item(
258258
}
259259
xfs_trans_log_dquot(sc->tp, dq);
260260
error = xfs_trans_roll(&sc->tp);
261-
xfs_dqlock(dq);
261+
mutex_lock(&dq->q_qlock);
262262
return error;
263263
}
264264

fs/xfs/scrub/quotacheck_repair.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ xqcheck_commit_dquot(
5353
int error = 0;
5454

5555
/* Unlock the dquot just long enough to allocate a transaction. */
56-
xfs_dqunlock(dq);
56+
mutex_unlock(&dq->q_qlock);
5757
error = xchk_trans_alloc(xqc->sc, 0);
58-
xfs_dqlock(dq);
58+
mutex_lock(&dq->q_qlock);
5959
if (error)
6060
return error;
6161

@@ -122,7 +122,7 @@ xqcheck_commit_dquot(
122122
* dquot).
123123
*/
124124
error = xrep_trans_commit(xqc->sc);
125-
xfs_dqlock(dq);
125+
mutex_lock(&dq->q_qlock);
126126
return error;
127127

128128
out_unlock:
@@ -131,7 +131,7 @@ xqcheck_commit_dquot(
131131
xchk_trans_cancel(xqc->sc);
132132

133133
/* Re-lock the dquot so the caller can put the reference. */
134-
xfs_dqlock(dq);
134+
mutex_lock(&dq->q_qlock);
135135
return error;
136136
}
137137

fs/xfs/xfs_dquot.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* ip->i_lock
3333
* qi->qi_tree_lock
34-
* dquot->q_qlock (xfs_dqlock() and friends)
34+
* dquot->q_qlock
3535
* dquot->q_flush (xfs_dqflock() and friends)
3636
* qi->qi_lru_lock
3737
*
@@ -816,9 +816,9 @@ xfs_qm_dqget_cache_lookup(
816816
return NULL;
817817
}
818818

819-
xfs_dqlock(dqp);
819+
mutex_lock(&dqp->q_qlock);
820820
if (dqp->q_flags & XFS_DQFLAG_FREEING) {
821-
xfs_dqunlock(dqp);
821+
mutex_unlock(&dqp->q_qlock);
822822
mutex_unlock(&qi->qi_tree_lock);
823823
trace_xfs_dqget_freeing(dqp);
824824
delay(1);
@@ -865,7 +865,7 @@ xfs_qm_dqget_cache_insert(
865865
}
866866

867867
/* Return a locked dquot to the caller, with a reference taken. */
868-
xfs_dqlock(dqp);
868+
mutex_lock(&dqp->q_qlock);
869869
dqp->q_nrefs = 1;
870870
qi->qi_dquots++;
871871

@@ -1051,7 +1051,7 @@ xfs_qm_dqget_inode(
10511051
if (dqp1) {
10521052
xfs_qm_dqdestroy(dqp);
10531053
dqp = dqp1;
1054-
xfs_dqlock(dqp);
1054+
mutex_lock(&dqp->q_qlock);
10551055
goto dqret;
10561056
}
10571057
} else {
@@ -1136,7 +1136,7 @@ xfs_qm_dqput(
11361136
if (list_lru_add_obj(&qi->qi_lru, &dqp->q_lru))
11371137
XFS_STATS_INC(dqp->q_mount, xs_qm_dquot_unused);
11381138
}
1139-
xfs_dqunlock(dqp);
1139+
mutex_unlock(&dqp->q_qlock);
11401140
}
11411141

11421142
/*
@@ -1152,7 +1152,7 @@ xfs_qm_dqrele(
11521152

11531153
trace_xfs_dqrele(dqp);
11541154

1155-
xfs_dqlock(dqp);
1155+
mutex_lock(&dqp->q_qlock);
11561156
/*
11571157
* We don't care to flush it if the dquot is dirty here.
11581158
* That will create stutters that we want to avoid.

fs/xfs/xfs_dquot.h

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,6 @@ static inline void xfs_dqfunlock(struct xfs_dquot *dqp)
121121
complete(&dqp->q_flush);
122122
}
123123

124-
static inline int xfs_dqlock_nowait(struct xfs_dquot *dqp)
125-
{
126-
return mutex_trylock(&dqp->q_qlock);
127-
}
128-
129-
static inline void xfs_dqlock(struct xfs_dquot *dqp)
130-
{
131-
mutex_lock(&dqp->q_qlock);
132-
}
133-
134-
static inline void xfs_dqunlock(struct xfs_dquot *dqp)
135-
{
136-
mutex_unlock(&dqp->q_qlock);
137-
}
138-
139124
static inline int
140125
xfs_dquot_type(const struct xfs_dquot *dqp)
141126
{
@@ -246,9 +231,9 @@ void xfs_dquot_detach_buf(struct xfs_dquot *dqp);
246231

247232
static inline struct xfs_dquot *xfs_qm_dqhold(struct xfs_dquot *dqp)
248233
{
249-
xfs_dqlock(dqp);
234+
mutex_lock(&dqp->q_qlock);
250235
dqp->q_nrefs++;
251-
xfs_dqunlock(dqp);
236+
mutex_unlock(&dqp->q_qlock);
252237
return dqp;
253238
}
254239

fs/xfs/xfs_dquot_item.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ xfs_qm_dquot_logitem_push(
132132
if (atomic_read(&dqp->q_pincount) > 0)
133133
return XFS_ITEM_PINNED;
134134

135-
if (!xfs_dqlock_nowait(dqp))
135+
if (!mutex_trylock(&dqp->q_qlock))
136136
return XFS_ITEM_LOCKED;
137137

138138
/*
@@ -177,7 +177,7 @@ xfs_qm_dquot_logitem_push(
177177
out_relock_ail:
178178
spin_lock(&lip->li_ailp->ail_lock);
179179
out_unlock:
180-
xfs_dqunlock(dqp);
180+
mutex_unlock(&dqp->q_qlock);
181181
return rval;
182182
}
183183

@@ -195,7 +195,7 @@ xfs_qm_dquot_logitem_release(
195195
* transaction layer, within trans_commit. Hence, no LI_HOLD flag
196196
* for the logitem.
197197
*/
198-
xfs_dqunlock(dqp);
198+
mutex_unlock(&dqp->q_qlock);
199199
}
200200

201201
STATIC void

fs/xfs/xfs_qm.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ xfs_qm_dqpurge(
128128
struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;
129129
int error = -EAGAIN;
130130

131-
xfs_dqlock(dqp);
131+
mutex_lock(&dqp->q_qlock);
132132
if ((dqp->q_flags & XFS_DQFLAG_FREEING) || dqp->q_nrefs != 0)
133133
goto out_unlock;
134134

@@ -177,7 +177,7 @@ xfs_qm_dqpurge(
177177
!test_bit(XFS_LI_IN_AIL, &dqp->q_logitem.qli_item.li_flags));
178178

179179
xfs_dqfunlock(dqp);
180-
xfs_dqunlock(dqp);
180+
mutex_unlock(&dqp->q_qlock);
181181

182182
radix_tree_delete(xfs_dquot_tree(qi, xfs_dquot_type(dqp)), dqp->q_id);
183183
qi->qi_dquots--;
@@ -194,7 +194,7 @@ xfs_qm_dqpurge(
194194
return 0;
195195

196196
out_unlock:
197-
xfs_dqunlock(dqp);
197+
mutex_unlock(&dqp->q_qlock);
198198
return error;
199199
}
200200

@@ -329,7 +329,7 @@ xfs_qm_dqattach_one(
329329
* that the dquot returned is the one that should go in the inode.
330330
*/
331331
*IO_idqpp = dqp;
332-
xfs_dqunlock(dqp);
332+
mutex_unlock(&dqp->q_qlock);
333333
return 0;
334334
}
335335

@@ -468,7 +468,7 @@ xfs_qm_dquot_isolate(
468468
struct xfs_qm_isolate *isol = arg;
469469
enum lru_status ret = LRU_SKIP;
470470

471-
if (!xfs_dqlock_nowait(dqp))
471+
if (!mutex_trylock(&dqp->q_qlock))
472472
goto out_miss_busy;
473473

474474
/*
@@ -494,7 +494,7 @@ xfs_qm_dquot_isolate(
494494
* the freelist and try again.
495495
*/
496496
if (dqp->q_nrefs) {
497-
xfs_dqunlock(dqp);
497+
mutex_unlock(&dqp->q_qlock);
498498
XFS_STATS_INC(dqp->q_mount, xs_qm_dqwants);
499499

500500
trace_xfs_dqreclaim_want(dqp);
@@ -519,7 +519,7 @@ xfs_qm_dquot_isolate(
519519
* Prevent lookups now that we are past the point of no return.
520520
*/
521521
dqp->q_flags |= XFS_DQFLAG_FREEING;
522-
xfs_dqunlock(dqp);
522+
mutex_unlock(&dqp->q_qlock);
523523

524524
ASSERT(dqp->q_nrefs == 0);
525525
list_lru_isolate_move(lru, &dqp->q_lru, &isol->dispose);
@@ -529,7 +529,7 @@ xfs_qm_dquot_isolate(
529529
return LRU_REMOVED;
530530

531531
out_miss_unlock:
532-
xfs_dqunlock(dqp);
532+
mutex_unlock(&dqp->q_qlock);
533533
out_miss_busy:
534534
trace_xfs_dqreclaim_busy(dqp);
535535
XFS_STATS_INC(dqp->q_mount, xs_qm_dqreclaim_misses);
@@ -1467,7 +1467,7 @@ xfs_qm_flush_one(
14671467
struct xfs_buf *bp = NULL;
14681468
int error = 0;
14691469

1470-
xfs_dqlock(dqp);
1470+
mutex_lock(&dqp->q_qlock);
14711471
if (dqp->q_flags & XFS_DQFLAG_FREEING)
14721472
goto out_unlock;
14731473
if (!XFS_DQ_IS_DIRTY(dqp))
@@ -1489,7 +1489,7 @@ xfs_qm_flush_one(
14891489
xfs_buf_delwri_queue(bp, buffer_list);
14901490
xfs_buf_relse(bp);
14911491
out_unlock:
1492-
xfs_dqunlock(dqp);
1492+
mutex_unlock(&dqp->q_qlock);
14931493
return error;
14941494
}
14951495

@@ -1952,7 +1952,7 @@ xfs_qm_vop_dqalloc(
19521952
/*
19531953
* Get the ilock in the right order.
19541954
*/
1955-
xfs_dqunlock(uq);
1955+
mutex_unlock(&uq->q_qlock);
19561956
lockflags = XFS_ILOCK_SHARED;
19571957
xfs_ilock(ip, lockflags);
19581958
} else {
@@ -1974,7 +1974,7 @@ xfs_qm_vop_dqalloc(
19741974
ASSERT(error != -ENOENT);
19751975
goto error_rele;
19761976
}
1977-
xfs_dqunlock(gq);
1977+
mutex_unlock(&gq->q_qlock);
19781978
lockflags = XFS_ILOCK_SHARED;
19791979
xfs_ilock(ip, lockflags);
19801980
} else {
@@ -1992,7 +1992,7 @@ xfs_qm_vop_dqalloc(
19921992
ASSERT(error != -ENOENT);
19931993
goto error_rele;
19941994
}
1995-
xfs_dqunlock(pq);
1995+
mutex_unlock(&pq->q_qlock);
19961996
lockflags = XFS_ILOCK_SHARED;
19971997
xfs_ilock(ip, lockflags);
19981998
} else {
@@ -2079,15 +2079,15 @@ xfs_qm_vop_chown(
20792079
* back now.
20802080
*/
20812081
tp->t_flags |= XFS_TRANS_DIRTY;
2082-
xfs_dqlock(prevdq);
2082+
mutex_lock(&prevdq->q_qlock);
20832083
if (isrt) {
20842084
ASSERT(prevdq->q_rtb.reserved >= ip->i_delayed_blks);
20852085
prevdq->q_rtb.reserved -= ip->i_delayed_blks;
20862086
} else {
20872087
ASSERT(prevdq->q_blk.reserved >= ip->i_delayed_blks);
20882088
prevdq->q_blk.reserved -= ip->i_delayed_blks;
20892089
}
2090-
xfs_dqunlock(prevdq);
2090+
mutex_unlock(&prevdq->q_qlock);
20912091

20922092
/*
20932093
* Take an extra reference, because the inode is going to keep

fs/xfs/xfs_qm_syscalls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ xfs_qm_scall_setqlim(
303303
}
304304

305305
defq = xfs_get_defquota(q, xfs_dquot_type(dqp));
306-
xfs_dqunlock(dqp);
306+
mutex_unlock(&dqp->q_qlock);
307307

308308
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_qm_setqlim, 0, 0, 0, &tp);
309309
if (error)
310310
goto out_rele;
311311

312-
xfs_dqlock(dqp);
312+
mutex_lock(&dqp->q_qlock);
313313
xfs_trans_dqjoin(tp, dqp);
314314

315315
/*

0 commit comments

Comments
 (0)