master - pvmove: use toollib
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d7dc87cb35616...
Commit: 6d7dc87cb356162f912b13c8a0cd198037c0226b
Parent: 5cd4d46f303ecf5212b5de0eb96c0a356453d289
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 12 14:57:52 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jan 18 14:48:30 2016 -0600
pvmove: use toollib
Previously, pvmove used the function find_pv_in_vg() which did the
equivalent of process_each_pv() by doing:
find_pv_by_name() -> get_pvs() ->
get_pvs_internal() -> _get_pvs() -> get_vgids() ->
/* equivalent to process_each_pv */
dm_list_iterate_items(vgids)
vg = vg_read_internal()
dm_list_iterate_items(&vg->pvs)
With the found 'pv', it would do vg_read() on pv_vg_name(pv),
and then do the actual pvmove processing.
This commit simplifies by using process_each_pv() and putting
the actual pvmove processing into the "single" function.
This eliminates both find_pv_by_name() and the vg_read().
The processing code that followed vg_read remains the same.
The return code for the pvmove command is not based on the
process_each_pv return code, but is based on the success/fail
conditions in the existing code.
---
tools/pvmove.c | 232 ++++++++++++++++++++++++++-----------------------------
tools/toollib.h | 2 +-
2 files changed, 110 insertions(+), 124 deletions(-)
diff --git a/tools/pvmove.c b/tools/pvmove.c
index d3eb1ab..be2fab5 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -22,6 +22,21 @@
#define PVMOVE_FIRST_TIME 0x00000001 /* Called for first time */
+struct pvmove_params {
+ char *pv_name_arg; /* original unmodified arg */
+ char *lv_name_arg; /* original unmodified arg */
+ alloc_policy_t alloc;
+ int pv_count;
+ char **pv_names;
+
+ union lvid *lvid;
+ char *id_vg_name;
+ char *id_lv_name;
+ unsigned in_progress;
+ int setup_result;
+ int found_pv;
+};
+
static int _pvmove_target_present(struct cmd_context *cmd, int clustered)
{
const struct segment_type *segtype;
@@ -586,63 +601,39 @@ static int _copy_id_components(struct cmd_context *cmd,
return 1;
}
-static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
- int argc, char **argv, union lvid *lvid, char **vg_name_copy,
- char **lv_mirr_name)
+static int _pvmove_setup_single(struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct physical_volume *pv,
+ struct processing_handle *handle)
{
+ struct pvmove_params *pp = (struct pvmove_params *) handle->custom_handle;
const char *lv_name = NULL;
- const char *vg_name;
- char *pv_name_arg;
- struct volume_group *vg;
struct dm_list *source_pvl;
struct dm_list *allocatable_pvs;
- alloc_policy_t alloc;
struct dm_list *lvs_changed;
- struct physical_volume *pv;
struct logical_volume *lv_mirr;
- uint32_t lockd_state = 0;
+ const char *pv_name = pv_dev_name(pv);
unsigned flags = PVMOVE_FIRST_TIME;
unsigned exclusive;
int r = ECMD_FAILED;
- pv_name_arg = argv[0];
- argc--;
- argv++;
-
- /* Find PV (in VG) */
- if (!(pv = find_pv_by_name(cmd, pv_name, 0, 0))) {
- stack;
- return EINVALID_CMD_LINE;
- }
-
- vg_name = pv_vg_name(pv);
+ pp->found_pv = 1;
+ pp->setup_result = ECMD_FAILED;
- if (arg_count(cmd, name_ARG)) {
- if (!(lv_name = _extract_lvname(cmd, vg_name, arg_value(cmd, name_ARG)))) {
- stack;
- free_pv_fid(pv);
- return EINVALID_CMD_LINE;
+ if (pp->lv_name_arg) {
+ if (!(lv_name = _extract_lvname(cmd, vg->name, pp->lv_name_arg))) {
+ log_error("Failed to find an LV name.");
+ pp->setup_result = EINVALID_CMD_LINE;
+ return ECMD_FAILED;
}
if (!validate_name(lv_name)) {
log_error("Logical volume name %s is invalid", lv_name);
- free_pv_fid(pv);
- return EINVALID_CMD_LINE;
+ pp->setup_result = EINVALID_CMD_LINE;
+ return ECMD_FAILED;
}
}
- /* Read VG */
- log_verbose("Finding volume group \"%s\"", vg_name);
-
- if (!lockd_vg(cmd, vg_name, "ex", 0, &lockd_state))
- return_ECMD_FAILED;
-
- vg = vg_read(cmd, vg_name, NULL, READ_FOR_UPDATE, lockd_state);
- if (vg_read_error(vg)) {
- release_vg(vg);
- goto out_ret;
- }
-
/*
* We cannot move blocks from under the sanlock leases, so disallow
* pvmoving any PVs used by the lvmlock LV.
@@ -657,8 +648,8 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if (seg_type(lvseg, s) == AREA_PV) {
sanlock_pv = seg_pv(lvseg, s);
if (sanlock_pv->dev == pv->dev) {
- log_error("Cannot pvmove device %s used for sanlock leases.", pv_dev_name(pv));
- goto out;
+ log_error("Cannot pvmove device %s used for sanlock leases.", pv_name);
+ return ECMD_FAILED;
}
}
}
@@ -669,7 +660,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
log_print_unless_silent("Detected pvmove in progress for %s", pv_name);
- if (argc || lv_name)
+ if (pp->pv_count || lv_name)
log_error("Ignoring remaining command line arguments");
if (!(lvs_changed = lvs_using_lv(cmd, vg, lv_mirr))) {
@@ -687,23 +678,22 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
} else {
/* Determine PE ranges to be moved */
if (!(source_pvl = create_pv_list(cmd->mem, vg, 1,
- &pv_name_arg, 0)))
+ &pp->pv_name_arg, 0)))
goto_out;
- alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
- if (alloc == ALLOC_INHERIT)
- alloc = vg->alloc;
+ if (pp->alloc == ALLOC_INHERIT)
+ pp->alloc = vg->alloc;
/* Get PVs we can use for allocation */
- if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
- vg, pv, alloc)))
+ if (!(allocatable_pvs = _get_allocatable_pvs(cmd, pp->pv_count, pp->pv_names,
+ vg, pv, pp->alloc)))
goto_out;
if (!archive(vg))
goto_out;
if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, source_pvl, lv_name,
- allocatable_pvs, alloc,
+ allocatable_pvs, pp->alloc,
&lvs_changed, &exclusive)))
goto_out;
}
@@ -716,7 +706,7 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
/* init_pvmove(1); */
/* vg->status |= PVMOVE; */
- if (!_copy_id_components(cmd, lv_mirr, vg_name_copy, lv_mirr_name, lvid))
+ if (!_copy_id_components(cmd, lv_mirr, &pp->id_vg_name, &pp->id_lv_name, pp->lvid))
goto out;
if (flags & PVMOVE_FIRST_TIME)
@@ -724,70 +714,33 @@ static int _set_up_pvmove(struct cmd_context *cmd, const char *pv_name,
goto_out;
/* LVs are all in status LOCKED */
+ pp->setup_result = ECMD_PROCESSED;
r = ECMD_PROCESSED;
out:
- free_pv_fid(pv);
- unlock_and_release_vg(cmd, vg, vg_name);
-out_ret:
- /*
- * Release explicitly because the command may continue running
- * for some time monitoring the progress, and we don not want
- * or need the lockd lock held over that.
- */
- if (!lockd_vg(cmd, vg_name, "un", 0, &lockd_state))
- stack;
-
return r;
}
-static int _read_poll_id_from_pvname(struct cmd_context *cmd, const char *pv_name,
- union lvid *lvid, char **vg_name_copy,
- char **lv_name_copy, unsigned *in_progress)
+static int _pvmove_read_single(struct cmd_context *cmd,
+ struct volume_group *vg,
+ struct physical_volume *pv,
+ struct processing_handle *handle)
{
- int ret = 0;
- const char *vg_name;
+ struct pvmove_params *pp = (struct pvmove_params *) handle->custom_handle;
struct logical_volume *lv;
- struct physical_volume *pv;
- struct volume_group *vg;
- uint32_t lockd_state = 0;
-
- if (!pv_name) {
- log_error(INTERNAL_ERROR "Invalid PV name parameter.");
- return 0;
- }
+ int ret = ECMD_FAILED;
- if (!(pv = find_pv_by_name(cmd, pv_name, 0, 0)))
- return_0;
-
- vg_name = pv_vg_name(pv);
-
- if (!lockd_vg(cmd, vg_name, "sh", 0, &lockd_state))
- return_0;
-
- /* need read-only access */
- vg = vg_read(cmd, vg_name, NULL, 0, lockd_state);
- if (vg_read_error(vg)) {
- log_error("ABORTING: Can't read VG for %s.", pv_name);
- release_vg(vg);
- ret = 0;
- goto out;
- }
+ pp->found_pv = 1;
if (!(lv = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) {
log_print_unless_silent("%s: No pvmove in progress - already finished or aborted.",
- pv_name);
- ret = 1;
- *in_progress = 0;
- } else if (_copy_id_components(cmd, lv, vg_name_copy, lv_name_copy, lvid)) {
- ret = 1;
- *in_progress = 1;
+ pv_dev_name(pv));
+ ret = ECMD_PROCESSED;
+ pp->in_progress = 0;
+ } else if (_copy_id_components(cmd, lv, &pp->id_vg_name, &pp->id_lv_name, pp->lvid)) {
+ ret = ECMD_PROCESSED;
+ pp->in_progress = 1;
}
- unlock_and_release_vg(cmd, vg, vg_name);
-out:
- if (!lockd_vg(cmd, vg_name, "un", 0, &lockd_state))
- stack;
- free_pv_fid(pv);
return ret;
}
@@ -859,11 +812,12 @@ int pvmove_poll(struct cmd_context *cmd, const char *pv_name,
int pvmove(struct cmd_context *cmd, int argc, char **argv)
{
- char *colon;
- int ret;
- unsigned in_progress = 1;
+ struct pvmove_params pp = { 0 };
+ struct processing_handle *handle = NULL;
union lvid *lvid = NULL;
- char *pv_name = NULL, *vg_name = NULL, *lv_name = NULL;
+ char *pv_name = NULL;
+ char *colon;
+ unsigned is_abort = arg_is_set(cmd, abort_ARG);
/* dm raid1 target must be present in every case */
if (!_pvmove_target_present(cmd, 0)) {
@@ -895,6 +849,12 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
log_error("Failed to allocate lvid.");
return ECMD_FAILED;
}
+ pp.lvid = lvid;
+
+ if (!(pp.pv_name_arg = dm_pool_strdup(cmd->mem, argv[0]))) {
+ log_error("Failed to clone PV name.");
+ return ECMD_FAILED;
+ }
if (!(pv_name = dm_pool_strdup(cmd->mem, argv[0]))) {
log_error("Failed to clone PV name.");
@@ -907,31 +867,56 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
if (colon)
*colon = '\0';
- /*
- * To do a reverse mapping from PV name to VG name, we need the
- * correct global mapping of PVs to VGs.
- */
- if (!lockd_gl(cmd, "sh", 0)) {
- stack;
+ argc--;
+ argv++;
+
+ pp.pv_count = argc;
+ pp.pv_names = argv;
+
+ if (arg_count(cmd, name_ARG)) {
+ if (!(pp.lv_name_arg = dm_pool_strdup(cmd->mem, arg_value(cmd, name_ARG)))) {
+ log_error("Failed to clone LV name.");
+ return ECMD_FAILED;
+ }
+ }
+
+ pp.alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
+
+ pp.in_progress = 1;
+
+ /* Normal pvmove setup requires ex lock from lvmlockd. */
+ if (is_abort)
+ cmd->lockd_vg_default_sh = 1;
+
+ if (!(handle = init_processing_handle(cmd))) {
+ log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
}
- /*
- * FIXME: use process_each_pv() where the "single" function
- * depends on the abort arg. The single functions would not
- * need to use find_pv_by_name() (which includes a hidden
- * equivalent of process_each_pv), or vg_read().
- */
- if (!arg_count(cmd, abort_ARG)) {
- if ((ret = _set_up_pvmove(cmd, pv_name, argc, argv, lvid, &vg_name, &lv_name)) != ECMD_PROCESSED) {
+ handle->custom_handle = &pp;
+
+ process_each_pv(cmd, 1, &pv_name, NULL,
+ is_abort ? 0 : READ_FOR_UPDATE,
+ handle,
+ is_abort ? &_pvmove_read_single : &_pvmove_setup_single);
+
+ destroy_processing_handle(cmd, handle);
+
+ if (!is_abort) {
+ if (!pp.found_pv) {
+ stack;
+ return EINVALID_CMD_LINE;
+ }
+
+ if (pp.setup_result != ECMD_PROCESSED) {
stack;
- return ret;
+ return pp.setup_result;
}
} else {
- if (!_read_poll_id_from_pvname(cmd, pv_name, lvid, &vg_name, &lv_name, &in_progress))
+ if (!pp.found_pv)
return_ECMD_FAILED;
- if (!in_progress)
+ if (!pp.in_progress)
return ECMD_PROCESSED;
}
@@ -943,6 +928,7 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
lockd_gl(cmd, "un", 0);
}
- return pvmove_poll(cmd, pv_name, lvid ? lvid->s : NULL, vg_name, lv_name,
+ return pvmove_poll(cmd, pv_name, lvid ? lvid->s : NULL,
+ pp.id_vg_name, pp.id_lv_name,
arg_is_set(cmd, background_ARG));
}
diff --git a/tools/toollib.h b/tools/toollib.h
index 400bac5..e1ac323 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -102,7 +102,7 @@ int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
process_single_vg_fn_t process_single_vg);
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
- const char *vg_name, uint32_t lock_type,
+ const char *vg_name, uint32_t read_flags,
struct processing_handle *handle,
process_single_pv_fn_t process_single_pv);
8 years, 4 months
master - Revert "Revert "process_each_pv: remove unnecessary workaround""
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5cd4d46f303ecf...
Commit: 5cd4d46f303ecf5212b5de0eb96c0a356453d289
Parent: 06346eab849b272bcd99196a9b594da29abdb19a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 14 13:47:44 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jan 18 09:36:55 2016 -0600
Revert "Revert "process_each_pv: remove unnecessary workaround""
This reverts commit 6d09c8c2c45ea1dea243134b8badc841a87cc979.
Try again to remove the workaround.
---
tools/toollib.c | 17 +----------------
1 files changed, 1 insertions(+), 16 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 728e61d..97cc1bf 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3033,7 +3033,6 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
const char *pv_name;
int selected;
int process_pv;
- int dev_found;
int ret_max = ECMD_PROCESSED;
int ret = 0;
@@ -3087,21 +3086,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
else
log_very_verbose("Processing PV %s in VG %s.", pv_name, vg->name);
- dev_found = _device_list_remove(all_devices, pv->dev);
-
- /*
- * FIXME PVs with no mdas may turn up in an orphan VG when
- * not using lvmetad as well as their correct VG. They
- * will be missing from all_devices the second time
- * around but must not be processed twice or trigger a message.
- *
- * Missing PVs will also need processing even though they are
- * not present in all_devices.
- */
- if (!dev_found && !is_missing_pv(pv)) {
- log_verbose("Skipping PV %s in VG %s: not in device list.", pv_name, vg->name);
- continue;
- }
+ _device_list_remove(all_devices, pv->dev);
if (!skip) {
ret = process_single_pv(cmd, vg, pv, handle);
8 years, 4 months
master - lvmlockd: cosemtic improvements to logging
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=06346eab849b27...
Commit: 06346eab849b272bcd99196a9b594da29abdb19a
Parent: 95ead96004c303f4285acfc223bba58e82e3ee87
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jan 15 15:34:49 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jan 18 09:35:21 2016 -0600
lvmlockd: cosemtic improvements to logging
Also pass our name to sanlock so it appears in
the sanlock status output.
---
daemons/lvmlockd/lvmlockd-core.c | 20 +-------------------
daemons/lvmlockd/lvmlockd-internal.h | 17 +++++++++++++++++
daemons/lvmlockd/lvmlockd-sanlock.c | 17 +++++++++++------
3 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 53fc0d5..4cd3284 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -741,24 +741,6 @@ static const char *op_str(int x)
};
}
-static const char *mode_str(int x)
-{
- switch (x) {
- case LD_LK_IV:
- return "iv";
- case LD_LK_UN:
- return "un";
- case LD_LK_NL:
- return "nl";
- case LD_LK_SH:
- return "sh";
- case LD_LK_EX:
- return "ex";
- default:
- return ".";
- };
-}
-
int last_string_from_args(char *args_in, char *last)
{
const char *args = args_in;
@@ -1365,7 +1347,7 @@ static int res_convert(struct lockspace *ls, struct resource *r,
r->last_client_id = act->client_id;
- log_debug("S %s R %s res_convert cl %u mode %d", ls->name, r->name, act->client_id, act->mode);
+ log_debug("S %s R %s res_convert cl %u mode %s", ls->name, r->name, act->client_id, mode_str(act->mode));
if (act->mode == LD_LK_EX && lk->mode == LD_LK_SH && r->sh_count > 1)
return -EAGAIN;
diff --git a/daemons/lvmlockd/lvmlockd-internal.h b/daemons/lvmlockd/lvmlockd-internal.h
index 3afa75a..2e21981 100644
--- a/daemons/lvmlockd/lvmlockd-internal.h
+++ b/daemons/lvmlockd/lvmlockd-internal.h
@@ -351,6 +351,23 @@ int lockspaces_empty(void);
int last_string_from_args(char *args_in, char *last);
int version_from_args(char *args, unsigned int *major, unsigned int *minor, unsigned int *patch);
+static inline const char *mode_str(int x)
+{
+ switch (x) {
+ case LD_LK_IV:
+ return "iv";
+ case LD_LK_UN:
+ return "un";
+ case LD_LK_NL:
+ return "nl";
+ case LD_LK_SH:
+ return "sh";
+ case LD_LK_EX:
+ return "ex";
+ default:
+ return ".";
+ };
+}
#ifdef LOCKDDLM_SUPPORT
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index 6f287b9..6694652 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -1324,6 +1324,7 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
struct rd_sanlock *rds = (struct rd_sanlock *)r->lm_data;
struct sanlk_resource *rs;
+ struct sanlk_options opt;
uint64_t lock_lv_offset;
uint32_t flags = 0;
struct val_blk vb;
@@ -1397,8 +1398,8 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
rs->flags |= SANLK_RES_PERSISTENT;
- log_debug("S %s R %s lock_san acquire %s:%llu",
- ls->name, r->name, rs->disks[0].path,
+ log_debug("S %s R %s lock_san %s at %s:%llu",
+ ls->name, r->name, mode_str(ld_mode), rs->disks[0].path,
(unsigned long long)rs->disks[0].offset);
if (daemon_test) {
@@ -1424,7 +1425,10 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
flags |= SANLK_ACQUIRE_OWNER_NOWAIT;
#endif
- rv = sanlock_acquire(lms->sock, -1, flags, 1, &rs, NULL);
+ memset(&opt, 0, sizeof(opt));
+ sprintf(opt.owner_name, "%s", "lvmlockd");
+
+ rv = sanlock_acquire(lms->sock, -1, flags, 1, &rs, &opt);
if (rv == -EAGAIN) {
/*
@@ -1584,7 +1588,8 @@ int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
uint32_t flags = 0;
int rv;
- log_debug("S %s R %s convert_san", ls->name, r->name);
+ log_debug("S %s R %s convert_san %s to %s",
+ ls->name, r->name, mode_str(r->mode), mode_str(ld_mode));
if (daemon_test)
goto rs_flag;
@@ -1688,8 +1693,8 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
struct val_blk vb;
int rv;
- log_debug("S %s R %s unlock_san r_version %u flags %x",
- ls->name, r->name, r_version, lmu_flags);
+ log_debug("S %s R %s unlock_san %s r_version %u flags %x",
+ ls->name, r->name, mode_str(r->mode), r_version, lmu_flags);
if (daemon_test) {
if (rds->vb && r_version && (r->mode == LD_LK_EX)) {
8 years, 4 months
master - lvmlockd: fix lvb validation for conversion
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95ead96004c303...
Commit: 95ead96004c303f4285acfc223bba58e82e3ee87
Parent: 54b41dcd53d99059b691f72eb6e7556d4341634d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jan 15 15:31:13 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jan 18 09:35:20 2016 -0600
lvmlockd: fix lvb validation for conversion
Make the lvb validation rules for convert match
those for unlock (even though it would be very
unlikely or impossible for convert to deal with
zero lvb.)
---
daemons/lvmlockd/lvmlockd-core.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 093021d..53fc0d5 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -1379,12 +1379,16 @@ static int res_convert(struct lockspace *ls, struct resource *r,
r->version++;
lk->version = r->version;
r_version = r->version;
+ r->version_zero_valid = 0;
+
log_debug("S %s R %s res_convert r_version inc %u",
ls->name, r->name, r_version);
} else if ((r->type == LD_RT_VG) && (r->mode == LD_LK_EX) && (lk->version > r->version)) {
r->version = lk->version;
r_version = r->version;
+ r->version_zero_valid = 0;
+
log_debug("S %s R %s res_convert r_version new %u", ls->name, r->name, r_version);
} else {
r_version = 0;
8 years, 4 months
master - pvchange, pvresize: fix lockd_gl() usage
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=54b41dcd53d990...
Commit: 54b41dcd53d99059b691f72eb6e7556d4341634d
Parent: 1ee6af344bd805d4fa847b95b326c2fe1e52d7cd
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jan 15 15:18:25 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jan 18 09:35:06 2016 -0600
pvchange, pvresize: fix lockd_gl() usage
When an orphan PV is changed/resized, the
lvmlockd global lock is converted from sh
to ex. If the command is changing two
orphan PVs, the conversion to ex should
be done only once.
---
tools/pvchange.c | 7 +++++--
tools/pvresize.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 91e93c1..fad28d1 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -87,8 +87,11 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
* i.e. the global lock is only needed for orphans.
* Convert sh to ex.
*/
- if (is_orphan(pv) && !lockd_gl(cmd, "ex", 0))
- return_ECMD_FAILED;
+ if (is_orphan(pv)) {
+ if (!lockd_gl(cmd, "ex", 0))
+ return_ECMD_FAILED;
+ cmd->lockd_gl_disable = 1;
+ }
if (tagargs) {
/* tag or deltag */
diff --git a/tools/pvresize.c b/tools/pvresize.c
index 0b055e6..ad59bae 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -41,8 +41,11 @@ static int _pvresize_single(struct cmd_context *cmd,
* i.e. the global lock is only needed for orphans.
* Convert sh to ex.
*/
- if (is_orphan(pv) && !lockd_gl(cmd, "ex", 0))
- return_ECMD_FAILED;
+ if (is_orphan(pv)) {
+ if (!lockd_gl(cmd, "ex", 0))
+ return_ECMD_FAILED;
+ cmd->lockd_gl_disable = 1;
+ }
if (!pv_resize_single(cmd, vg, pv, params->new_size))
return_ECMD_FAILED;
8 years, 4 months
master - report: add kernel_cache_settings field
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1ee6af344bd805...
Commit: 1ee6af344bd805d4fa847b95b326c2fe1e52d7cd
Parent: 7f627770412c7edd08aa5e5376fad58bca0b6c36
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jan 18 14:32:17 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jan 18 14:42:29 2016 +0100
report: add kernel_cache_settings field
Existing cache_settings field displays the settings which are
saved in metadata. Add new kernel_cache_settings fields to display
the settings which are currently used by kernel, including fields
for which default values are used.
This way users have complete view of the set of cache settings
supported (and which they can set) and their values which are used
at the moment by kernel.
For example:
$ lvs -o name,cache_policy,cache_settings,kernel_cache_settings vg
LV Cache Policy Cache Settings KCache Settings
cached1 mq migration_threshold=1024,write_promote_adjustment=2 migration_threshold=1024,random_threshold=4,sequential_threshold=512,discard_promote_adjustment=1,read_promote_adjustment=4,write_promote_adjustment=2
cached2 smq migration_threshold=1024 migration_threshold=1024
cached3 smq migration_threshold=2048
---
WHATS_NEW | 1 +
lib/report/columns.h | 1 +
lib/report/properties.c | 2 +
lib/report/report.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 72 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 65f845f..0499469 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.141 -
====================================
+ Add kernel_cache_settings report field for cache LV settings used in kernel.
Version 2.02.140 - 16th January 2016
====================================
diff --git a/lib/report/columns.h b/lib/report/columns.h
index e097fec..9bd9fd4 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -112,6 +112,7 @@ FIELD(LVSSTATUS, lv, NUM, "CacheReadHits", lvid, 16, cache_read_hits, cache_read
FIELD(LVSSTATUS, lv, NUM, "CacheReadMisses", lvid, 16, cache_read_misses, cache_read_misses, "Cache read misses.", 0)
FIELD(LVSSTATUS, lv, NUM, "CacheWriteHits", lvid, 16, cache_write_hits, cache_write_hits, "Cache write hits.", 0)
FIELD(LVSSTATUS, lv, NUM, "CacheWriteMisses", lvid, 16, cache_write_misses, cache_write_misses, "Cache write misses.", 0)
+FIELD(LVSSTATUS, lv, STR_LIST, "KCache Settings", lvid, 18, kernel_cache_settings, kernel_cache_settings, "Cache settings/parameters as set in kernel, including default values (cached segments only).", 0)
FIELD(LVSSTATUS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0)
FIELD(LVSSTATUS, lv, STR, "KDiscards", lvid, 8, kdiscards, kernel_discards, "For thin pools, how discards are handled in kernel.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 705a9b9..6218835 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -481,6 +481,8 @@ GET_LVSEG_STR_PROPERTY_FN(seg_monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, l
#define _cache_policy_set prop_not_implemented_set
#define _cache_settings_get prop_not_implemented_get
#define _cache_settings_set prop_not_implemented_set
+#define _kernel_cache_settings_get prop_not_implemented_get
+#define _kernel_cache_settings_set prop_not_implemented_set
/* PVSEG */
GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe)
diff --git a/lib/report/report.c b/lib/report/report.c
index 53ff753..c03469a 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1412,6 +1412,74 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_string_list(rh, field, result, private, 0);
}
+static int _do_get_kernel_cache_settings_list(struct dm_pool *mem,
+ int cache_argc, char **cache_argv,
+ struct dm_list *result)
+{
+ const char *key, *value;
+ char *buf;
+ size_t buf_len;
+ int i;
+
+ for (i = 0; i+1 < cache_argc; i += 2) {
+ key = cache_argv[i];
+ value = cache_argv[i+1];
+ /* +1 for "=" char and +1 for trailing zero */
+ buf_len = strlen(key) + strlen(value) + 2;
+ if (!(buf = dm_pool_alloc(mem, buf_len)))
+ return_0;
+ dm_snprintf(buf, buf_len, "%s=%s", key, value);
+ if (!str_list_add_no_dup_check(mem, result, buf))
+ return_0;
+ }
+
+ return 1;
+}
+
+static int _get_kernel_cache_settings_list(struct dm_pool *mem,
+ struct dm_status_cache *cache_status,
+ struct dm_list **result)
+{
+ if (!(*result = str_list_create(mem)))
+ return_0;
+
+ if (!_do_get_kernel_cache_settings_list(mem, cache_status->core_argc,
+ cache_status->core_argv, *result))
+ return_0;
+
+ if (!_do_get_kernel_cache_settings_list(mem, cache_status->policy_argc,
+ cache_status->policy_argv, *result))
+ return_0;
+
+ return 1;
+}
+
+static int _kernel_cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
+ struct dm_list dummy_list; /* dummy list to display "nothing" */
+ struct dm_list *result;
+ int r = 0;
+
+ if (lvdm->seg_status.type != SEG_STATUS_CACHE) {
+ dm_list_init(&dummy_list);
+ return _field_set_string_list(rh, field, &dummy_list, private, 0);
+ }
+
+ if (!(mem = dm_pool_create("reporter_pool", 1024)))
+ return_0;
+
+ if (!_get_kernel_cache_settings_list(mem, lvdm->seg_status.cache, &result))
+ goto_out;
+
+ r = _field_set_string_list(rh, field, result, private, 0);
+out:
+ dm_pool_destroy(mem);
+ return r;
+}
+
static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
8 years, 4 months
v2_02_140 annotated tag has been created
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b77933b1036c5d...
Commit: b77933b1036c5d96b103eef04ea57558ea418f9f
Parent: 0000000000000000000000000000000000000000
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: 2016-01-16 02:11 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: 2016-01-16 02:11 +0000
annotated tag: v2_02_140 has been created
at b77933b1036c5d96b103eef04ea57558ea418f9f (tag)
tagging 0faa27d4f55abcda5fa94ef92343eb44e95ada89 (commit)
replaces v2_02_139
Release 2.02.140.
49 files changed, 828 insertions(+), 448 deletions(-)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
iEYEABECAAYFAlaZpt0ACgkQIoGRwVZ+LBcFzACg7Z0algrfyu0ifBFqFlvwAhbt
t14AmgISR9XyLbWcS5PKBKrxQwRw3Er7
=AOPY
-----END PGP SIGNATURE-----
Alasdair G Kergon (3):
post-release
vgcfgrestore: Retain allocatable PV attribute.
pre-release
David Teigland (8):
pvmove: disallow moving PVs under sanlock leases
man lvmlockd: mention pvmove restriction
process_each_pv: remove unnecessary workaround
lvmlockd: fix exit code
vgchange: fix lockd_gl results
Revert "process_each_pv: remove unnecessary workaround"
Revert "lvmcache: skip drop when vg_write lock is not held"
lvmlockd: fixes for test mode
Ondrej Kozina (4):
pvscan: restore polling in autoactivation handler
test: add test for autoactivation regression
vgchange: drop redundant check
test: conditional skip of auto-activation bg polling test
Peter Rajnoha (25):
report: fix invalid memory read when reporting cache LV policy name
cleanup: use _field_set_value and _string_disp consistently in report.c
report: use brackets to signify LVs which are not visible when reporting lv_parent
report: use proper string reference in _string_disp call for _cache_policy_disp fn
lv: add common lv_convert_lv fn for use in report and dup, use brackets for invisible devices
lv: add common lv_origin_lv fn for use in report and dup, use brackets for invisible devices
lv: add common lv_mirror_log_lv for use in report and dup, use brackets for invisible devices
lv: add common lv_data_lv fn for use in report and dup, use brackets for invisible devices
lv: add common lv_metadata_lv fn for use in report and dup, use brackets for invisible devices
lv: add common lv_pool_lv fn for use in report and dup, use brackets for invisible devices
lv: use brackets for invisible devices when formatting device segments
conf: add report/mark_invisible_devices
conf: regenerate
conf: update command_profile_template.profile.in
cleanup: cleanup lv.h and put fns into categories for better readability
tests: update tests to deal with invisible devices consistently
test: add report-invisible.sh test
WHATS_NEW: reports and invisible devices
cleanup: rename 'invisible devices' to 'hidden devices'
cleanup: rename 'invisible devices' to 'hidden devices'
conf: fix 'the volume list' vs 'volume list' and '@*'
cleanup: rename 'invisible devices' to 'hidden devices'
lv: fix check for NULL origin_lv in _do_lv_origin_dup, cleanup _do_lvconvert_lv_dup
report: add kernel_discards report field to display thin pool discard used in kernel
lvm2app: fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported}
Zdenek Kabelac (11):
lvmanip: add lv_is_snapshot
lvresize: check for poolmetadatasize arg earlier
segtype: check for activation
snapshot: relocate alloc_snapshot_seg
cleanup: more readable check
cleanup: simplier formula
cleanup: explicit prohibition for virtual segs
cleanup: replace log_warn
cleanup: spaces
cleanup: order ac members
lvmanip: fix last commit and drop else
8 years, 4 months
master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f627770412c7e...
Commit: 7f627770412c7edd08aa5e5376fad58bca0b6c36
Parent: 0faa27d4f55abcda5fa94ef92343eb44e95ada89
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jan 16 02:12:10 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jan 16 02:12:10 2016 +0000
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index 9b00fee..5bdba32 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.140(2)-git (2016-01-16)
+2.02.141(2)-git (2016-01-16)
diff --git a/VERSION_DM b/VERSION_DM
index 6ef4620..dcf06e1 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.114-git (2016-01-16)
+1.02.115-git (2016-01-16)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2bb3493..65f845f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.141 -
+====================================
+
Version 2.02.140 - 16th January 2016
====================================
Fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported}.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 4ab492a..e5480e1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.115 -
+=====================================
+
Version 1.02.114 - 14th December 2015
=====================================
Better support for dmsetup static linkage.
8 years, 4 months
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0faa27d4f55abc...
Commit: 0faa27d4f55abcda5fa94ef92343eb44e95ada89
Parent: 7559af2334a619bc3dcbf558152841b2695c8616
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Jan 16 02:11:21 2016 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Jan 16 02:11:21 2016 +0000
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 4 ++--
WHATS_NEW_DM | 3 ---
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/VERSION b/VERSION
index 37dcbe0..9b00fee 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.140(2)-git (2016-01-08)
+2.02.140(2)-git (2016-01-16)
diff --git a/VERSION_DM b/VERSION_DM
index 43446ef..6ef4620 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.115-git (2016-01-08)
+1.02.114-git (2016-01-16)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7023510..2bb3493 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,5 @@
-Version 2.02.140 -
-===================================
+Version 2.02.140 - 16th January 2016
+====================================
Fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported}.
Add kernel_discards report field to display thin pool discard used in kernel.
Correct checking of target presence when driver access is disabled.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f9c808f..4ab492a 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,6 +1,3 @@
-Version 1.02.115 -
-=====================================
-
Version 1.02.114 - 14th December 2015
=====================================
Better support for dmsetup static linkage.
8 years, 4 months
master - lvm2app: fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered, exported}
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7559af2334a619...
Commit: 7559af2334a619bc3dcbf558152841b2695c8616
Parent: 1752f5c31e8fc1801cbc694939a16f0eb6695bcd
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jan 15 14:39:43 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jan 15 14:42:18 2016 +0100
lvm2app: fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported}
Fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported},
including internal functions pvseg_is_allocated and vg_is_resizeable
which are not yet exposed in lvm2app but make them consistent with the
rest.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b64f725..7023510 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.140 -
===================================
+ Fix lvm2app to return either 0 or 1 for lvm_vg_is_{clustered,exported}.
Add kernel_discards report field to display thin pool discard used in kernel.
Correct checking of target presence when driver access is disabled.
Eval poolmetadatasize arg earlier in lvresize.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index a118fa8..4f25f7d 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -305,7 +305,7 @@ struct pv_segment {
uint32_t lv_area; /* Index to area in LV segment */
};
-#define pvseg_is_allocated(pvseg) ((pvseg)->lvseg)
+#define pvseg_is_allocated(pvseg) ((pvseg)->lvseg ? 1 : 0)
/*
* Properties of each format instance type.
@@ -1204,9 +1204,9 @@ int pv_change_metadataignore(struct physical_volume *pv, uint32_t mda_ignore);
int vg_flag_write_locked(struct volume_group *vg);
int vg_check_write_mode(struct volume_group *vg);
-#define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
-#define vg_is_exported(vg) (vg_status((vg)) & EXPORTED_VG)
-#define vg_is_resizeable(vg) (vg_status((vg)) & RESIZEABLE_VG)
+#define vg_is_clustered(vg) ((vg_status((vg)) & CLUSTERED) ? 1 : 0)
+#define vg_is_exported(vg) ((vg_status((vg)) & EXPORTED_VG) ? 1 : 0)
+#define vg_is_resizeable(vg) ((vg_status((vg)) & RESIZEABLE_VG) ? 1 : 0)
int lv_has_unknown_segments(const struct logical_volume *lv);
int vg_has_unknown_segments(const struct volume_group *vg);
8 years, 4 months