Skip to content

Commit

Permalink
lvmlockd: disable lvb for sanlock
Browse files Browse the repository at this point in the history
The lvb is used to hold lock versions, but lock verions are
no longer used (since the removal of lvmetad), so the lvb
is not actually useful.  Disable their use for sanlock to
avoid the extra i/o required to maintain the lvb.
  • Loading branch information
teigland committed Jun 27, 2024
1 parent 58e75f6 commit 55687b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions daemons/lvmlockd/lvmlockd-client.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#define LVMLOCKD_SOCKET DEFAULT_RUN_DIR "/lvmlockd.socket"
#define LVMLOCKD_ADOPT_FILE DEFAULT_RUN_DIR "/lvmlockd.adopt"

#define LVMLOCKD_USE_SANLOCK_LVB 0

/* Wrappers to open/close connection */

static inline __attribute__((always_inline))
Expand Down
2 changes: 2 additions & 0 deletions daemons/lvmlockd/lvmlockd-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,9 @@ static int res_lock(struct lockspace *ls, struct resource *r, struct action *act
* once someone uses the lock and writes a new lvb value.
* Do nothing.
*/
/*
log_debug("S %s R %s res_lock version_zero_valid still zero", ls->name, r->name);
*/

} else if (r->version_zero_valid && vb.r_version) {
/*
Expand Down
11 changes: 8 additions & 3 deletions daemons/lvmlockd/lvmlockd-sanlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1610,12 +1610,17 @@ static int lm_add_resource_sanlock(struct lockspace *ls, struct resource *r)

/* LD_RT_LV offset is set in each lm_lock call from lv_args. */

/*
* Disable sanlock lvb since lock versions are not currently used for
* anything, and it's nice to avoid the extra i/o used for lvb's.
*/
#if LVMLOCKD_USE_SANLOCK_LVB
if (r->type == LD_RT_GL || r->type == LD_RT_VG) {
rds->vb = zalloc(sizeof(struct val_blk));
if (!rds->vb)
return -ENOMEM;
}

#endif
return 0;
}

Expand All @@ -1624,9 +1629,9 @@ int lm_rem_resource_sanlock(struct lockspace *ls, struct resource *r)
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;

/* FIXME: assert r->mode == UN or unlock if it's not? */

#ifdef LVMLOCKD_USE_SANLOCK_LVB
free(rds->vb);

#endif
memset(rds, 0, sizeof(struct rd_sanlock));
r->lm_init = 0;
return 0;
Expand Down
14 changes: 12 additions & 2 deletions lib/locking/lvmlockd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,12 +2301,22 @@ int lockd_vg_update(struct volume_group *vg)
int result;
int ret;

if (!vg_is_shared(vg))
return 1;
if (!_use_lvmlockd)
return 0;
if (!_lvmlockd_connected)
return 0;
if (!vg_is_shared(vg))
return 1;

#if !LVMLOCKD_USE_SANLOCK_LVB
/*
* lvb (for lock version) is disabled for sanlock since
* lock versions are not used any more, and it's more
* costly for sanlock to implement (extra i/o.)
*/
if (!strcmp(vg->lock_type, "sanlock"))
return 1;
#endif

reply = _lockd_send("vg_update",
"pid = " FMTd64, (int64_t) getpid(),
Expand Down

0 comments on commit 55687b6

Please sign in to comment.