Skip to content

Commit b06ddfe

Browse files
committed
Merge patch series "further lockref cleanups"
Andreas Gruenbacher <[email protected]> says: Here's an updated version with an additional comment saying that lockref_init() initializes count to 1. * patches from https://lore.kernel.org/r/[email protected]: lockref: remove count argument of lockref_init gfs2: switch to lockref_init(..., 1) gfs2: use lockref_init for gl_lockref Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents e52e97f + bb504b4 commit b06ddfe

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

fs/dcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
17001700
smp_store_release(&dentry->d_name.name, dname); /* ^^^ */
17011701

17021702
dentry->d_flags = 0;
1703-
lockref_init(&dentry->d_lockref, 1);
1703+
lockref_init(&dentry->d_lockref);
17041704
seqcount_spinlock_init(&dentry->d_seq, &dentry->d_lock);
17051705
dentry->d_inode = NULL;
17061706
dentry->d_parent = dentry;

fs/erofs/zdata.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ static int z_erofs_register_pcluster(struct z_erofs_frontend *fe)
726726
if (IS_ERR(pcl))
727727
return PTR_ERR(pcl);
728728

729-
lockref_init(&pcl->lockref, 1); /* one ref for this request */
729+
lockref_init(&pcl->lockref); /* one ref for this request */
730730
pcl->algorithmformat = map->m_algorithmformat;
731731
pcl->length = 0;
732732
pcl->partial = true;

fs/gfs2/glock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,8 +1201,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
12011201
if (glops->go_instantiate)
12021202
gl->gl_flags |= BIT(GLF_INSTANTIATE_NEEDED);
12031203
gl->gl_name = name;
1204+
lockref_init(&gl->gl_lockref);
12041205
lockdep_set_subclass(&gl->gl_lockref.lock, glops->go_subclass);
1205-
gl->gl_lockref.count = 1;
12061206
gl->gl_state = LM_ST_UNLOCKED;
12071207
gl->gl_target = LM_ST_UNLOCKED;
12081208
gl->gl_demote_state = LM_ST_EXCLUSIVE;

fs/gfs2/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ static void gfs2_init_glock_once(void *foo)
5151
{
5252
struct gfs2_glock *gl = foo;
5353

54-
spin_lock_init(&gl->gl_lockref.lock);
5554
INIT_LIST_HEAD(&gl->gl_holders);
5655
INIT_LIST_HEAD(&gl->gl_lru);
5756
INIT_LIST_HEAD(&gl->gl_ail_list);

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);
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;

include/linux/lockref.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ struct lockref {
3737
/**
3838
* lockref_init - Initialize a lockref
3939
* @lockref: pointer to lockref structure
40-
* @count: initial count
40+
*
41+
* Initializes @lockref->count to 1.
4142
*/
42-
static inline void lockref_init(struct lockref *lockref, unsigned int count)
43+
static inline void lockref_init(struct lockref *lockref)
4344
{
4445
spin_lock_init(&lockref->lock);
45-
lockref->count = count;
46+
lockref->count = 1;
4647
}
4748

4849
void lockref_get(struct lockref *lockref);

0 commit comments

Comments
 (0)