further lockref cleanups
Subsystems (3)
Andreas Gruenbacher
maintainerv2 cover further lockref cleanups
Here's an updated version with:
* An additional comment saying that lockref_init() initializes count to 1.
* Reviewed-by tags from Christoph.
Thanks,
Andreas
Andreas Gruenbacher (3):
gfs2: use lockref_init for gl_lockref
gfs2: switch to lockref_init(..., 1)
lockref: remove count argument of lockref_init
fs/dcache.c | 2 +- fs/erofs/zdata.c | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/main.c | 1 - fs/gfs2/quota.c | 4 ++-- include/linux/lockref.h | 7 ++++--- 6 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.48.1
Andreas Gruenbacher
maintainerPATCH v2 1/3 gfs2: use lockref_init for gl_lockref
Move the initialization of gl_lockref from gfs2_init_glock_once() to gfs2_glock_get(). This allows to use lockref_init() there.
--- fs/gfs2/glock.c | 2 +- fs/gfs2/main.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
fs/gfs2/glock.c +1 -1
@@ -1201,8 +1201,8 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,if (glops->go_instantiate) gl->gl_flags |=BIT (GLF_INSTANTIATE_NEEDED ); gl->gl_name = name; +lockref_init (&gl->gl_lockref,1 );lockdep_set_subclass (&gl->gl_lockref.lock, glops->go_subclass); - gl->gl_lockref.count =1 ; gl->gl_state =LM_ST_UNLOCKED ; gl->gl_target =LM_ST_UNLOCKED ; gl->gl_demote_state =LM_ST_EXCLUSIVE ;
fs/gfs2/main.c +0 -1
@@ -51,7 +51,6 @@ static void gfs2_init_glock_once(void *foo) {struct gfs2_glock *gl = foo; -spin_lock_init (&gl->gl_lockref.lock);INIT_LIST_HEAD (&gl->gl_holders);INIT_LIST_HEAD (&gl->gl_lru);INIT_LIST_HEAD (&gl->gl_ail_list);
Signature · 1 line
2.48.1
Andreas Gruenbacher
maintainerPATCH v2 2/3 gfs2: switch to lockref_init(..., 1)
In reply to Andreas GruenbacherIn 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.
--- fs/gfs2/quota.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/gfs2/quota.c +2 -2
@@ -236,7 +236,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, strreturn NULL ; qd->qd_sbd = sdp; -lockref_init (&qd->qd_lockref,0 ); +lockref_init (&qd->qd_lockref,1 ); qd->qd_id = qid; qd->qd_slot =-1 ;INIT_LIST_HEAD (&qd->qd_lru);
@@ -297,7 +297,6 @@ static int qd_get(struct gfs2_sbd *sdp, struct kqid qid,spin_lock_bucket (hash); *qdp = qd =gfs2_qd_search_bucket (hash, sdp, qid);if (qd ==NULL ) { - new_qd->qd_lockref.count++; *qdp = new_qd;list_add (&new_qd->qd_list, &sdp->sd_quota_list);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)if (qd ==NULL ) goto fail_brelse; + qd->qd_lockref.count =0 ;set_bit (QDF_CHANGE , &qd->qd_flags); qd->qd_change = qc_change; qd->qd_slot = slot;
Signature · 1 line
2.48.1
Andreas Gruenbacher
maintainerPATCH v2 3/3 lockref: remove count argument of lockref_init
In reply to Andreas GruenbacherAll users of lockref_init() now initialize the count to 1, so hardcode that and remove the count argument.
--- fs/dcache.c | 2 +- fs/erofs/zdata.c | 2 +- fs/gfs2/glock.c | 2 +- fs/gfs2/quota.c | 2 +- include/linux/lockref.h | 7 ++++--- 5 files changed, 8 insertions(+), 7 deletions(-)
fs/dcache.c +1 -1
@@ -1682,7 +1682,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)smp_store_release (&dentry->d_name.name, dname);/* ^^^ */ dentry->d_flags =0 ; -lockref_init (&dentry->d_lockref,1 ); +lockref_init (&dentry->d_lockref);seqcount_spinlock_init (&dentry->d_seq, &dentry->d_lock); dentry->d_inode =NULL ; dentry->d_parent = dentry;
fs/erofs/zdata.c +1 -1
@@ -747,7 +747,7 @@ static int z_erofs_register_pcluster(struct z_erofs_decompress_frontend *fe)if (IS_ERR (pcl))return PTR_ERR (pcl); -lockref_init (&pcl->lockref,1 );/* one ref for this request */ +lockref_init (&pcl->lockref);/* one ref for this request */ pcl->algorithmformat = map->m_algorithmformat; pcl->length =0 ; pcl->partial = true;
fs/gfs2/glock.c +1 -1
@@ -1201,7 +1201,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,if (glops->go_instantiate) gl->gl_flags |=BIT (GLF_INSTANTIATE_NEEDED ); gl->gl_name = name; -lockref_init (&gl->gl_lockref,1 ); +lockref_init (&gl->gl_lockref);lockdep_set_subclass (&gl->gl_lockref.lock, glops->go_subclass); gl->gl_state =LM_ST_UNLOCKED ; gl->gl_target =LM_ST_UNLOCKED ;
fs/gfs2/quota.c +1 -1
@@ -236,7 +236,7 @@ static struct gfs2_quota_data *qd_alloc(unsigned hash, struct gfs2_sbd *sdp, strreturn NULL ; qd->qd_sbd = sdp; -lockref_init (&qd->qd_lockref,1 ); +lockref_init (&qd->qd_lockref); qd->qd_id = qid; qd->qd_slot =-1 ;INIT_LIST_HEAD (&qd->qd_lru);
include/linux/lockref.h +4 -3
@@ -37,12 +37,13 @@ struct lockref {/** * lockref_init - Initialize a lockref * @lockref: pointer to lockref structure -* @count: initial count +* +* Initializes @lockref->count to 1. */ -static inline void lockref_init (struct lockref *lockref,unsigned int count) +static inline void lockref_init (struct lockref *lockref) {spin_lock_init (&lockref->lock); - lockref->count = count; + lockref->count =1 ; }void lockref_get (struct lockref *lockref);
Signature · 1 line
2.48.1
Quoted 8 lines · Andreas Gruenbacher
Here's an updated version with:
* An additional comment saying that
lockref_init()initializes count to 1.* Reviewed-by tags from Christoph.
[...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/3] gfs2: use lockref_init for gl_lockref
https://git.kernel.org/vfs/vfs/c/6c789b8e0913 [2/3] gfs2: switch to lockref_init(..., 1) https://git.kernel.org/vfs/vfs/c/69469b7ad4a4 [3/3] lockref: remove count argument of lockref_init https://git.kernel.org/vfs/vfs/c/24239add174c