Skip to content

Commit dba2d70

Browse files
teiglandswhiteho
authored andcommitted
GFS2: only use lvb on glocks that need it
Save the effort of allocating, reading and writing the lvb for most glocks that do not use it. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent fb6791d commit dba2d70

4 files changed

Lines changed: 32 additions & 13 deletions

File tree

‎fs/gfs2/glock.c‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ static void gfs2_glock_dealloc(struct rcu_head *rcu)
105105
{
106106
struct gfs2_glock *gl = container_of(rcu, struct gfs2_glock, gl_rcu);
107107

108-
if (gl->gl_ops->go_flags & GLOF_ASPACE)
108+
if (gl->gl_ops->go_flags & GLOF_ASPACE) {
109109
kmem_cache_free(gfs2_glock_aspace_cachep, gl);
110-
else
110+
} else {
111+
kfree(gl->gl_lvb);
111112
kmem_cache_free(gfs2_glock_cachep, gl);
113+
}
112114
}
113115

114116
void gfs2_glock_free(struct gfs2_glock *gl)
@@ -545,7 +547,10 @@ __acquires(&gl->gl_spin)
545547
if (sdp->sd_lockstruct.ls_ops->lm_lock) {
546548
/* lock_dlm */
547549
ret = sdp->sd_lockstruct.ls_ops->lm_lock(gl, target, lck_flags);
548-
GLOCK_BUG_ON(gl, ret);
550+
if (ret) {
551+
printk(KERN_ERR "GFS2: lm_lock ret %d\n", ret);
552+
GLOCK_BUG_ON(gl, 1);
553+
}
549554
} else { /* lock_nolock */
550555
finish_xmote(gl, target);
551556
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
@@ -734,6 +739,18 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
734739
if (!gl)
735740
return -ENOMEM;
736741

742+
memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
743+
gl->gl_lvb = NULL;
744+
745+
if (glops->go_flags & GLOF_LVB) {
746+
gl->gl_lvb = kzalloc(GFS2_MIN_LVB_SIZE, GFP_KERNEL);
747+
if (!gl->gl_lvb) {
748+
kmem_cache_free(cachep, gl);
749+
return -ENOMEM;
750+
}
751+
gl->gl_lksb.sb_lvbptr = gl->gl_lvb;
752+
}
753+
737754
atomic_inc(&sdp->sd_glock_disposal);
738755
gl->gl_sbd = sdp;
739756
gl->gl_flags = 0;
@@ -751,9 +768,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
751768
preempt_enable();
752769
gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0;
753770
gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0;
754-
memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
755-
memset(gl->gl_lvb, 0, 32 * sizeof(char));
756-
gl->gl_lksb.sb_lvbptr = gl->gl_lvb;
757771
gl->gl_tchange = jiffies;
758772
gl->gl_object = NULL;
759773
gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
@@ -775,6 +789,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
775789
tmp = search_bucket(hash, sdp, &name);
776790
if (tmp) {
777791
spin_unlock_bucket(hash);
792+
kfree(gl->gl_lvb);
778793
kmem_cache_free(cachep, gl);
779794
atomic_dec(&sdp->sd_glock_disposal);
780795
gl = tmp;

‎fs/gfs2/glops.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ const struct gfs2_glock_operations gfs2_rgrp_glops = {
552552
.go_unlock = gfs2_rgrp_go_unlock,
553553
.go_dump = gfs2_rgrp_dump,
554554
.go_type = LM_TYPE_RGRP,
555-
.go_flags = GLOF_ASPACE,
555+
.go_flags = GLOF_ASPACE | GLOF_LVB,
556556
};
557557

558558
const struct gfs2_glock_operations gfs2_trans_glops = {
@@ -577,6 +577,7 @@ const struct gfs2_glock_operations gfs2_nondisk_glops = {
577577

578578
const struct gfs2_glock_operations gfs2_quota_glops = {
579579
.go_type = LM_TYPE_QUOTA,
580+
.go_flags = GLOF_LVB,
580581
};
581582

582583
const struct gfs2_glock_operations gfs2_journal_glops = {

‎fs/gfs2/incore.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ struct gfs2_glock_operations {
216216
const int go_type;
217217
const unsigned long go_flags;
218218
#define GLOF_ASPACE 1
219+
#define GLOF_LVB 2
219220
};
220221

221222
enum {
@@ -321,7 +322,7 @@ struct gfs2_glock {
321322
ktime_t gl_dstamp;
322323
struct gfs2_lkstats gl_stats;
323324
struct dlm_lksb gl_lksb;
324-
char gl_lvb[32];
325+
char *gl_lvb;
325326
unsigned long gl_tchange;
326327
void *gl_object;
327328

‎fs/gfs2/lock_dlm.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static void gdlm_ast(void *arg)
120120
gfs2_update_reply_times(gl);
121121
BUG_ON(gl->gl_lksb.sb_flags & DLM_SBF_DEMOTED);
122122

123-
if (gl->gl_lksb.sb_flags & DLM_SBF_VALNOTVALID)
123+
if (gl->gl_lksb.sb_flags & DLM_SBF_VALNOTVALID && gl->gl_lvb)
124124
memset(gl->gl_lvb, 0, GDLM_LVB_SIZE);
125125

126126
switch (gl->gl_lksb.sb_status) {
@@ -203,8 +203,10 @@ static int make_mode(const unsigned int lmstate)
203203
static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags,
204204
const int req)
205205
{
206-
u32 lkf = DLM_LKF_VALBLK;
207-
u32 lkid = gl->gl_lksb.sb_lkid;
206+
u32 lkf = 0;
207+
208+
if (gl->gl_lvb)
209+
lkf |= DLM_LKF_VALBLK;
208210

209211
if (gfs_flags & LM_FLAG_TRY)
210212
lkf |= DLM_LKF_NOQUEUE;
@@ -228,7 +230,7 @@ static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags,
228230
BUG();
229231
}
230232

231-
if (lkid != 0) {
233+
if (gl->gl_lksb.sb_lkid != 0) {
232234
lkf |= DLM_LKF_CONVERT;
233235
if (test_bit(GLF_BLOCKING, &gl->gl_flags))
234236
lkf |= DLM_LKF_QUECVT;
@@ -292,7 +294,7 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
292294

293295
/* don't want to skip dlm_unlock writing the lvb when lock is ex */
294296
if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
295-
gl->gl_state != LM_ST_EXCLUSIVE) {
297+
gl->gl_lvb && gl->gl_state != LM_ST_EXCLUSIVE) {
296298
gfs2_glock_free(gl);
297299
return;
298300
}

0 commit comments

Comments
 (0)