Skip to content

Commit 34ad6fa

Browse files
Andreas Gruenbacherbrauner
authored andcommitted
gfs2: switch to lockref_init(..., 1)
In qd_alloc(), initialize the lockref count to 1 to cover the common case. Compensate for that in gfs2_quota_init() by adjusting the count back down to 0; this only occurs when mounting the filesystem rw. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent d9b3a3c commit 34ad6fa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/gfs2/quota.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, str
236236
return NULL;
237237

238238
qd->qd_sbd = sdp;
239-
lockref_init(&qd->qd_lockref, 0);
239+
lockref_init(&qd->qd_lockref, 1);
240240
qd->qd_id = qid;
241241
qd->qd_slot = -1;
242242
INIT_LIST_HEAD(&qd->qd_lru);
@@ -297,7 +297,6 @@ static int qd_get(struct gfs2_sbd *sdp, struct kqid qid,
297297
spin_lock_bucket(hash);
298298
*qdp = qd = gfs2_qd_search_bucket(hash, sdp, qid);
299299
if (qd == NULL) {
300-
new_qd->qd_lockref.count++;
301300
*qdp = new_qd;
302301
list_add(&new_qd->qd_list, &sdp->sd_quota_list);
303302
hlist_bl_add_head_rcu(&new_qd->qd_hlist, &qd_hash_table[hash]);
@@ -1450,6 +1449,7 @@ int gfs2_quota_init(struct gfs2_sbd *sdp)
14501449
if (qd == NULL)
14511450
goto fail_brelse;
14521451

1452+
qd->qd_lockref.count = 0;
14531453
set_bit(QDF_CHANGE, &qd->qd_flags);
14541454
qd->qd_change = qc_change;
14551455
qd->qd_slot = slot;

0 commit comments

Comments
 (0)