Skip to content

Commit 3781ec9

Browse files
author
Andreas Gruenbacher
committed
gfs2: Uninline and improve glock_{set,clear}_object
Those functions have reached a size at which having them inline isn't useful anymore, so uninline them. In addition, report the glock name on assertion failures. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent fe1bff6 commit 3781ec9

File tree

2 files changed

+45
-26
lines changed

2 files changed

+45
-26
lines changed

fs/gfs2/glock.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,48 @@ __acquires(&gl->gl_lockref.lock)
928928
return;
929929
}
930930

931+
/**
932+
* glock_set_object - set the gl_object field of a glock
933+
* @gl: the glock
934+
* @object: the object
935+
*/
936+
void glock_set_object(struct gfs2_glock *gl, void *object)
937+
{
938+
void *prev_object;
939+
940+
spin_lock(&gl->gl_lockref.lock);
941+
prev_object = gl->gl_object;
942+
gl->gl_object = object;
943+
spin_unlock(&gl->gl_lockref.lock);
944+
if (gfs2_assert_warn(gl->gl_name.ln_sbd, prev_object == NULL)) {
945+
pr_warn("glock=%u/%llx\n",
946+
gl->gl_name.ln_type,
947+
(unsigned long long)gl->gl_name.ln_number);
948+
gfs2_dump_glock(NULL, gl, true);
949+
}
950+
}
951+
952+
/**
953+
* glock_clear_object - clear the gl_object field of a glock
954+
* @gl: the glock
955+
*/
956+
void glock_clear_object(struct gfs2_glock *gl, void *object)
957+
{
958+
void *prev_object;
959+
960+
spin_lock(&gl->gl_lockref.lock);
961+
prev_object = gl->gl_object;
962+
gl->gl_object = NULL;
963+
spin_unlock(&gl->gl_lockref.lock);
964+
if (gfs2_assert_warn(gl->gl_name.ln_sbd,
965+
prev_object == object || prev_object == NULL)) {
966+
pr_warn("glock=%u/%llx\n",
967+
gl->gl_name.ln_type,
968+
(unsigned long long)gl->gl_name.ln_number);
969+
gfs2_dump_glock(NULL, gl, true);
970+
}
971+
}
972+
931973
void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation)
932974
{
933975
struct gfs2_inode_lvb *ri = (void *)gl->gl_lksb.sb_lvbptr;

fs/gfs2/glock.h

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ extern void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp);
288288
extern void gfs2_register_debugfs(void);
289289
extern void gfs2_unregister_debugfs(void);
290290

291+
extern void glock_set_object(struct gfs2_glock *gl, void *object);
292+
extern void glock_clear_object(struct gfs2_glock *gl, void *object);
293+
291294
extern const struct lm_lockops gfs2_dlm_ops;
292295

293296
static inline void gfs2_holder_mark_uninitialized(struct gfs2_holder *gh)
@@ -305,32 +308,6 @@ static inline bool gfs2_holder_queued(struct gfs2_holder *gh)
305308
return !list_empty(&gh->gh_list);
306309
}
307310

308-
/**
309-
* glock_set_object - set the gl_object field of a glock
310-
* @gl: the glock
311-
* @object: the object
312-
*/
313-
static inline void glock_set_object(struct gfs2_glock *gl, void *object)
314-
{
315-
spin_lock(&gl->gl_lockref.lock);
316-
if (gfs2_assert_warn(gl->gl_name.ln_sbd, gl->gl_object == NULL))
317-
gfs2_dump_glock(NULL, gl, true);
318-
gl->gl_object = object;
319-
spin_unlock(&gl->gl_lockref.lock);
320-
}
321-
322-
/**
323-
* glock_clear_object - clear the gl_object field of a glock
324-
* @gl: the glock
325-
*/
326-
static inline void glock_clear_object(struct gfs2_glock *gl, void *object)
327-
{
328-
spin_lock(&gl->gl_lockref.lock);
329-
if (gl->gl_object == object)
330-
gl->gl_object = NULL;
331-
spin_unlock(&gl->gl_lockref.lock);
332-
}
333-
334311
static inline void gfs2_holder_allow_demote(struct gfs2_holder *gh)
335312
{
336313
struct gfs2_glock *gl = gh->gh_gl;

0 commit comments

Comments
 (0)