gfs2: Make gfs2_glock_hold return its glock argument
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 2 Dec 2022 17:00:15 +0000 (18:00 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 6 Dec 2022 15:06:31 +0000 (16:06 +0100)
This allows code like 'gl = gfs2_glock_hold(...)'.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/file.c
fs/gfs2/glock.c
fs/gfs2/glock.h

index 60c6fb9..eea5be4 100644 (file)
@@ -1445,14 +1445,13 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
 
 static void __flock_holder_uninit(struct file *file, struct gfs2_holder *fl_gh)
 {
-       struct gfs2_glock *gl = fl_gh->gh_gl;
+       struct gfs2_glock *gl = gfs2_glock_hold(fl_gh->gh_gl);
 
        /*
         * Make sure gfs2_glock_put() won't sleep under the file->f_lock
         * spinlock.
         */
 
-       gfs2_glock_hold(gl);
        spin_lock(&file->f_lock);
        gfs2_holder_uninit(fl_gh);
        spin_unlock(&file->f_lock);
index df335c2..1a6c1eb 100644 (file)
@@ -186,10 +186,11 @@ void gfs2_glock_free(struct gfs2_glock *gl)
  *
  */
 
-void gfs2_glock_hold(struct gfs2_glock *gl)
+struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl)
 {
        GLOCK_BUG_ON(gl, __lockref_is_dead(&gl->gl_lockref));
        lockref_get(&gl->gl_lockref);
+       return gl;
 }
 
 /**
@@ -1256,13 +1257,12 @@ void __gfs2_holder_init(struct gfs2_glock *gl, unsigned int state, u16 flags,
                        struct gfs2_holder *gh, unsigned long ip)
 {
        INIT_LIST_HEAD(&gh->gh_list);
-       gh->gh_gl = gl;
+       gh->gh_gl = gfs2_glock_hold(gl);
        gh->gh_ip = ip;
        gh->gh_owner_pid = get_pid(task_pid(current));
        gh->gh_state = state;
        gh->gh_flags = flags;
        gh->gh_iflags = 0;
-       gfs2_glock_hold(gl);
 }
 
 /**
index 0d068f4..76cd2fa 100644 (file)
@@ -196,7 +196,7 @@ static inline struct address_space *gfs2_glock2aspace(struct gfs2_glock *gl)
 extern int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
                          const struct gfs2_glock_operations *glops,
                          int create, struct gfs2_glock **glp);
-extern void gfs2_glock_hold(struct gfs2_glock *gl);
+extern struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl);
 extern void gfs2_glock_put(struct gfs2_glock *gl);
 extern void gfs2_glock_queue_put(struct gfs2_glock *gl);