main - lvmdevices: add deviceidtype option
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=440d6ae79fb4df92c79...
Commit: 440d6ae79fb4df92c7992d3c1689ba4f2d242d6a
Parent: 8331321070899507b904d8a0ec78b413c826ae32
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 8 14:49:34 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jun 11 13:27:18 2021 -0500
lvmdevices: add deviceidtype option
When adding a device to the devices file with --adddev, lvm
by default chooses the best device ID type for the new device.
The new --deviceidtype option allows the user to override the
built in preference. This is useful if there's a problem with
the default type, or if a secondary type is preferrable.
If the specified deviceidtype does not produce a device ID,
then lvm falls back to the preference it would otherwise use.
---
lib/device/device_id.c | 32 ++++++++++++++----------
man/lvmdevices.8_des | 68 +++++++++++++++++++++++++++++++++++++++-----------
tools/args.h | 5 ++++
tools/command-lines.in | 1 +
tools/lvmdevices.c | 7 ++++--
5 files changed, 84 insertions(+), 29 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 1b98487ab..f158e4f06 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -931,6 +931,7 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
/*
* Choose the device_id type for the device being added.
*
+ * 0. use an idtype specified by the user
* 1. use an idtype specific to a special/virtual device type
* e.g. loop, mpath, crypt, lvmlv, md, etc.
* 2. use an idtype specified by user option.
@@ -939,6 +940,24 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
* 5. use devname as the last resort.
*/
+ if (idtype_arg) {
+ if (!(idtype = idtype_from_str(idtype_arg)))
+ log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
+ else {
+ if (id_arg) {
+ if ((idname = strdup(id_arg)))
+ goto id_done;
+ log_warn("WARNING: ignoring device_id name %s.", id_arg);
+ }
+
+ if ((idname = device_id_system_read(cmd, dev, idtype)))
+ goto id_done;
+
+ log_warn("WARNING: ignoring deviceidtype %s which is not available for device.", idtype_arg);
+ idtype = 0;
+ }
+ }
+
if (MAJOR(dev->dev) == cmd->dev_types->device_mapper_major) {
if (_dev_has_mpath_uuid(cmd, dev, &idname)) {
idtype = DEV_ID_TYPE_MPATH_UUID;
@@ -972,19 +991,6 @@ int device_id_add(struct cmd_context *cmd, struct device *dev, const char *pvid_
log_warn("Missing support for DRBD idtype");
}
- if (idtype_arg) {
- if (!(idtype = idtype_from_str(idtype_arg)))
- log_warn("WARNING: ignoring unknown device_id type %s.", idtype_arg);
- else {
- if (id_arg) {
- if (!(idname = strdup(id_arg)))
- stack;
- goto id_done;
- }
- goto id_name;
- }
- }
-
/*
* No device-specific, existing, or user-specified idtypes,
* so use first available of sys_wwid / sys_serial / devname.
diff --git a/man/lvmdevices.8_des b/man/lvmdevices.8_des
index 015aa1122..2335456ad 100644
--- a/man/lvmdevices.8_des
+++ b/man/lvmdevices.8_des
@@ -9,18 +9,18 @@ remove it from the devices file with lvmdevices --deldev. The
vgimportdevices(8) command adds all PVs from a VG to the devices file,
and updates the VG metadata to include device IDs of the PVs.
.P
-Commands adding new devices to the devices file necessarily look outside
-the existing devices file to find the devices to add. pvcreate, vgcreate,
-and vgextend also look outside the devices file to create new PVs and add
-them to the devices file.
+Commands that add new devices to the devices file necessarily look outside
+the existing devices file to find the devices being added. pvcreate,
+vgcreate, and vgextend also look outside the devices file to create new
+PVs and add those PVs to the devices file.
.P
LVM records devices in the devices file using hardware-specific IDs, such
as the WWID, and attempts to use subsystem-specific IDs for virtual device
-types (which also aim to be as unique and stable as possible.)
-These device IDs are also written in the VG metadata. When no hardware or
+types (which also aim to be as unique and stable as possible.) These
+device IDs are also written in the VG metadata. When no hardware or
virtual ID is available, lvm falls back using the unstable device name as
-the device ID. When devnames are used, lvm performs extra scanning to
-find devices if their devname changes, e.g. after reboot.
+the device ID. When devnames are used as IDs, lvm performs extra scanning
+to find devices if their devname changes, e.g. after reboot.
.P
When proper device IDs are used, an lvm command will not look at devices
outside the devices file, but when devnames are used as a fallback, lvm
@@ -34,12 +34,13 @@ overriding the devices file. The listed devices act as a sort of devices
file in terms of limiting which devices lvm will see and use. Devices
that are not listed will appear to be missing to the lvm command.
.P
-Multiple devices files can be kept in \fI#DEFAULT_SYS_DIR#/devices\fP, which allows lvm
-to be used with different sets of devices, e.g. system devices do not need
-to be exposed to a specific application, and the application can use lvm on
-its own devices that are not exposed to the system. The option
---devicesfile <filename> is used to select the devices file to use with the
-command. Without the option set, the default system devices file is used.
+Multiple devices files can be kept \fI#DEFAULT_SYS_DIR#/devices\fP, which
+allows lvm to be used with different sets of devices. For example, system
+devices do not need to be exposed to a specific application, and the
+application can use lvm on its own devices that are not exposed to the
+system. The option --devicesfile <filename> is used to select the devices
+file to use with the command. Without the option set, the default system
+devices file is used.
.P
Setting --devicesfile "" causes lvm to not use a devices file.
.P
@@ -59,3 +60,42 @@ if it does not yet exist.
.P
It is recommended to use lvm commands to make changes to the devices file to
ensure proper updates.
+.P
+The device ID and device ID type are included in the VG metadata and can
+be reported with pvs -o deviceid,deviceidtype. (Note that the lvmdevices
+command does not update VG metadata, but subsequent lvm commands modifying
+the metadata will include the device ID.)
+.P
+Possible device ID types are:
+.br
+.IP \[bu] 2
+.B sys_wwid
+uses the wwid reported by sysfs. This is the first choice for non-virtual
+devices.
+.IP \[bu] 2
+.B sys_serial
+uses the serial number reported by sysfs. This is the second choice for
+non-virtual devices.
+.IP \[bu] 2
+.B mpath_uuid
+is used for dm multipath devices, reported by sysfs.
+.IP \[bu] 2
+.B crypt_uuid
+is used for dm crypt devices, reported by sysfs.
+.IP \[bu] 2
+.B md_uuid
+is used for md devices, reported by sysfs.
+.B lvmlv_uuid
+is used if a PV is placed on top of an lvm LV, reported by sysfs.
+.IP \[bu] 2
+.B loop_file
+is used for loop devices, the backing file name repored by sysfs.
+.IP \[bu] 2
+.B devname
+the device name is used if no other type applies.
+.P
+
+The default choice for device ID type can be overriden using lvmdevices
+--addev --deviceidtype <type>. If the specified type is available for the
+device it will be used, otherwise the device will be added using the type
+that would otherwise be chosen.
diff --git a/tools/args.h b/tools/args.h
index 741c82b9f..d4f23f849 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -228,6 +228,11 @@ arg(detachprofile_ARG, '\0', "detachprofile", 0, 0, 0,
"Detaches a metadata profile from a VG or LV.\n"
"See \\fBlvm.conf\\fP(5) for more information about profiles.\n")
+arg(deviceidtype_ARG, '\0', "deviceidtype", string_VAL, 0, 0,
+ "The type of device ID to use for the device.\n"
+ "If the specified type is available for the device,\n"
+ "then it will override the default type that lvm would use.\n")
+
arg(devices_ARG, '\0', "devices", pv_VAL, ARG_GROUPABLE, 0,
"Devices that the command can use. This option can be repeated\n"
"or accepts a comma separated list of devices. This overrides\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 67c37ffd0..8607305cb 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -1430,6 +1430,7 @@ ID: lvmdevices_update
DESC: Update the devices file to fix incorrect values.
lvmdevices --adddev PV
+OO: --deviceidtype String
ID: lvmdevices_edit
DESC: Add a device to the devices file.
diff --git a/tools/lvmdevices.c b/tools/lvmdevices.c
index 6b3e05683..3448bdd14 100644
--- a/tools/lvmdevices.c
+++ b/tools/lvmdevices.c
@@ -265,6 +265,7 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, adddev_ARG)) {
const char *devname;
+ const char *deviceidtype;
if (!(devname = arg_str_value(cmd, adddev_ARG, NULL)))
goto_bad;
@@ -311,8 +312,10 @@ int lvmdevices(struct cmd_context *cmd, int argc, char **argv)
dev_name(dev), dev_filtered_reason(dev));
}
- /* allow deviceidtype_ARG/deviceid_ARG ? */
- if (!device_id_add(cmd, dev, dev->pvid, NULL, NULL))
+ /* also allow deviceid_ARG ? */
+ deviceidtype = arg_str_value(cmd, deviceidtype_ARG, NULL);
+
+ if (!device_id_add(cmd, dev, dev->pvid, deviceidtype, NULL))
goto_bad;
if (!device_ids_write(cmd))
goto_bad;
2 years, 10 months
main - pvck: add lock_global() before clean_hint_file()
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8331321070899507b90...
Commit: 8331321070899507b904d8a0ec78b413c826ae32
Parent: 17b27464868ac7049624d9b90f68c59200866997
Author: Wu Guanghao <wuguanghao3(a)huawei.com>
AuthorDate: Fri Jun 11 10:18:56 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jun 11 10:21:07 2021 -0500
pvck: add lock_global() before clean_hint_file()
Signed-off-by: Wu Guanghao <wuguanghao3(a)huawei.com>
---
tools/pvck.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/pvck.c b/tools/pvck.c
index 74663ec43..aba6a9cc8 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -3037,6 +3037,9 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, repairtype_ARG) || arg_is_set(cmd, repair_ARG)) {
pv_name = argv[0];
+ if (!lock_global(cmd, "ex"))
+ return ECMD_FAILED;
+
clear_hint_file(cmd);
if (!setup_device(cmd, pv_name)) {
2 years, 10 months
main - archive: avoid abuse of internal flag
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=17b27464868ac704962...
Commit: 17b27464868ac7049624d9b90f68c59200866997
Parent: bb45e33518b56a06df8a52226e383ca9ce938d0d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jun 9 16:16:26 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jun 9 16:18:20 2021 +0200
archive: avoid abuse of internal flag
Since archive is now postponned we use internal variable 'changed'
to mark we need to commit new metadata.
---
WHATS_NEW | 1 +
tools/vgchange.c | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 04c6dcdf2..2c4704310 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.03.13 -
===============================
+ Simplified handling of archive() and backup() internal calls.
Fix load of kvdo target when it is not present in memory (2.03.12).
Version 2.03.12 - 07th May 2021
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 9f972acdb..22038ba9b 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -640,6 +640,7 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
int ret = ECMD_PROCESSED;
unsigned i;
activation_change_t activate;
+ int changed = 0;
static const struct {
int arg;
@@ -677,10 +678,11 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (arg_is_set(cmd, _vgchange_args[i].arg)) {
if (!_vgchange_args[i].fn(cmd, vg))
return_ECMD_FAILED;
+ changed = 1;
}
}
- if (vg_is_archived(vg)) {
+ if (changed) {
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
2 years, 10 months
main - backup: automatically store data on vg_unlock
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bb45e33518b56a06df8...
Commit: bb45e33518b56a06df8a52226e383ca9ce938d0d
Parent: ba3707d9539f9cc2e72c5368388ae795776379af
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 8 19:39:15 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jun 9 14:56:13 2021 +0200
backup: automatically store data on vg_unlock
Previously there have been necessary explicit call of backup (often
either forgotten or over-used). With this patch the necessity to
store backup is remember at vg_commit and once the VG is unlocked,
the committed metadata are automatically store in backup file.
This may possibly alter some printed messages from command when the
backup is now taken later.
---
lib/format_text/archiver.c | 1 -
lib/locking/locking.h | 7 +++++--
lib/metadata/lv_manip.c | 17 +----------------
lib/metadata/metadata.c | 4 ++--
lib/metadata/pv_manip.c | 1 -
lib/metadata/raid_manip.c | 12 ------------
lib/metadata/vg.c | 11 +++++++++--
lib/metadata/vg.h | 1 +
tools/lvconvert.c | 25 -------------------------
tools/pvmove_poll.c | 3 ---
tools/toollib.c | 2 --
tools/vgchange.c | 6 ------
tools/vgcreate.c | 2 --
tools/vgexport.c | 2 --
tools/vgextend.c | 4 ----
tools/vgimport.c | 2 --
tools/vgimportdevices.c | 1 -
tools/vgreduce.c | 1 -
tools/vgrename.c | 2 --
19 files changed, 18 insertions(+), 86 deletions(-)
diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
index 68117f7dc..f1590b460 100644
--- a/lib/format_text/archiver.c
+++ b/lib/format_text/archiver.c
@@ -279,7 +279,6 @@ int backup_locally(struct volume_group *vg)
int backup(struct volume_group *vg)
{
- vg->needs_backup = 0;
/* Unlock memory if possible */
memlock_unlock(vg->cmd);
diff --git a/lib/locking/locking.h b/lib/locking/locking.h
index 3e8ae6f0c..a60935d52 100644
--- a/lib/locking/locking.h
+++ b/lib/locking/locking.h
@@ -56,8 +56,11 @@ int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags, const str
#define unlock_vg(cmd, vg, vol) \
do { \
- if (is_real_vg(vol) && !sync_local_dev_names(cmd)) \
- stack; \
+ if (is_real_vg(vol)) { \
+ if (!sync_local_dev_names(cmd)) \
+ stack; \
+ vg_backup_if_needed(vg); \
+ } \
if (!lock_vol(cmd, vol, LCK_VG_UNLOCK, NULL)) \
stack; \
} while (0)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 899297f28..eb92d6eca 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6178,8 +6178,6 @@ int lv_resize(struct logical_volume *lv,
/* Update lvm pool metadata (drop messages). */
if (!update_pool_lv(lock_lv, 0))
goto_bad;
-
- backup(vg);
}
/* Check for over provisioning when extended */
@@ -7024,7 +7022,7 @@ no_remove:
static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
{
struct volume_group *vg = lv->vg;
- int do_backup = 0, r = 0;
+ int r = 0;
const struct logical_volume *lock_lv = lv_lock_holder(lv);
log_very_verbose("Updating logical volume %s on disk(s)%s.",
@@ -7048,8 +7046,6 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
return 0;
} else if (!(r = vg_commit(vg)))
stack; /* !vg_commit() has implict vg_revert() */
- else
- do_backup = 1;
log_very_verbose("Updating logical volume %s in kernel.",
display_lvname(lock_lv));
@@ -7060,9 +7056,6 @@ static int _lv_update_and_reload(struct logical_volume *lv, int origin_only)
r = 0;
}
- if (do_backup && !critical_section())
- backup(vg);
-
return r;
}
@@ -8595,8 +8588,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
/* Pool created metadata LV, but better avoid recover when vg_write/commit fails */
return_NULL;
- backup(vg);
-
if (test_mode()) {
log_verbose("Test mode: Skipping activation, zeroing and signature wiping.");
goto out;
@@ -8607,8 +8598,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!lv_add_integrity_to_raid(lv, &lp->integrity_settings, lp->pvh, NULL))
goto revert_new_lv;
-
- backup(vg);
}
/* Do not scan this LV until properly zeroed/wiped. */
@@ -8708,7 +8697,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto revert_new_lv;
}
}
- backup(vg);
if (!lv_active_change(cmd, lv, lp->activate)) {
log_error("Failed to activate thin %s.", lv->name);
@@ -8829,7 +8817,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (!vg_write(vg) || !vg_commit(vg))
return_NULL; /* Metadata update fails, deep troubles */
- backup(vg);
/*
* FIXME We do not actually need snapshot-origin as an active device,
* as virtual origin is already 'hidden' private device without
@@ -8873,8 +8860,6 @@ revert_new_lv:
!lv_remove(lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
return NULL;
}
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 6852d2a2a..d5b28a58f 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -991,6 +991,7 @@ static void _vg_move_cached_precommitted_to_committed(struct volume_group *vg)
release_vg(vg->vg_committed);
vg->vg_committed = vg->vg_precommitted;
vg->vg_precommitted = NULL;
+ vg->needs_backup = 1;
}
int lv_has_unknown_segments(const struct logical_volume *lv)
@@ -3165,8 +3166,7 @@ int vg_commit(struct volume_group *vg)
dm_list_init(&vg->msg_list);
vg->needs_write_and_commit = 0;
}
- vg->needs_backup = 0;
- }
+ }
/* If at least one mda commit succeeded, it was committed */
return ret;
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index fd97bbbc2..cfc983174 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -687,7 +687,6 @@ int pv_resize_single(struct cmd_context *cmd,
"volume group \"%s\"", pv_name, vg_name);
goto out;
}
- backup(vg);
}
log_print_unless_silent("Physical volume \"%s\" changed", pv_name);
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 74adf0231..f0d401cde 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -2210,9 +2210,6 @@ static int _vg_write_lv_suspend_commit_backup(struct volume_group *vg,
} else if (!(r = vg_commit(vg)))
stack; /* !vg_commit() has implicit vg_revert() */
- if (r && do_backup)
- backup(vg);
-
return r;
}
@@ -2221,8 +2218,6 @@ static int _vg_write_commit_backup(struct volume_group *vg)
if (!vg_write(vg) || !vg_commit(vg))
return_0;
- backup(vg);
-
return 1;
}
@@ -2847,7 +2842,6 @@ static int _raid_add_images(struct logical_volume *lv,
display_lvname(lv));
return 0;
}
- backup(lv->vg);
}
return 1;
@@ -3172,8 +3166,6 @@ static int _raid_remove_images(struct logical_volume *lv, int yes,
if (!lv_update_and_reload_origin(lv))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -3431,8 +3423,6 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -3915,8 +3905,6 @@ static int _eliminate_extracted_lvs_optional_write_vg(struct volume_group *vg,
if (vg_write_requested) {
if (!vg_write(vg) || !vg_commit(vg))
return_0;
-
- backup(vg);
}
/* Wait for events following any deactivation. */
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 428e5dca7..85482552a 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -739,8 +739,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
goto bad;
}
- backup(vg);
-
log_print_unless_silent("Removed \"%s\" from volume group \"%s\"",
name, vg->name);
}
@@ -752,3 +750,12 @@ bad:
release_vg(orphan_vg);
return r;
}
+
+void vg_backup_if_needed(struct volume_group *vg)
+{
+ if (!vg || !vg->needs_backup)
+ return;
+
+ vg->needs_backup = 0;
+ backup(vg->vg_committed);
+}
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index 36d1ed155..8ce57acdc 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -170,6 +170,7 @@ uint32_t vg_mda_used_count(const struct volume_group *vg);
uint32_t vg_mda_copies(const struct volume_group *vg);
int vg_set_mda_copies(struct volume_group *vg, uint32_t mda_copies);
char *vg_profile_dup(const struct volume_group *vg);
+void vg_backup_if_needed(struct volume_group *vg);
/*
* Returns visible LV count - number of LVs from user perspective
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c40031fe4..e19c445b1 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1263,8 +1263,6 @@ static int _lvconvert_mirrors(struct cmd_context *cmd,
new_mimage_count, new_log_count, lp->pvh))
return_0;
- backup(lv->vg);
-
if (!lp->need_polling)
log_print_unless_silent("Logical volume %s converted.",
display_lvname(lv));
@@ -1866,8 +1864,6 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
if (!vg_remove_snapshot(cow))
return_0;
- backup(vg);
-
log_print_unless_silent("Logical Volume %s split from its origin.", display_lvname(cow));
return 1;
@@ -1941,8 +1937,6 @@ static int _lvconvert_split_and_keep_cachevol(struct cmd_context *cmd,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
return 1;
}
@@ -1989,8 +1983,6 @@ static int _lvconvert_split_and_keep_cachepool(struct cmd_context *cmd,
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
-
log_print_unless_silent("Logical volume %s is not cached and %s is unused.",
display_lvname(lv), display_lvname(lv_fast));
@@ -2224,7 +2216,6 @@ static int _lvconvert_merge_old_snapshot(struct cmd_context *cmd,
/* Store and commit vg but skip starting the merge */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
- backup(lv->vg);
} else {
/* Perform merge */
if (!lv_update_and_reload(origin))
@@ -2335,8 +2326,6 @@ static int _lvconvert_merge_thin_snapshot(struct cmd_context *cmd,
log_print_unless_silent("Merging of thin snapshot %s will occur on "
"next activation of %s.",
display_lvname(lv), display_lvname(origin));
- backup(lv->vg);
-
return 1;
}
@@ -2860,8 +2849,6 @@ revert_new_lv:
if (!lv_remove(thin_lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
return 0;
}
@@ -2999,7 +2986,6 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
if (!vg_write(vg) || !vg_commit(vg))
return_0;
- backup(vg);
return 1;
}
@@ -3472,8 +3458,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
r = 1;
out:
- backup(vg);
-
if (r)
log_print_unless_silent("Converted %s to %s pool.",
converted_names, to_cachepool ? "cache" : "thin");
@@ -3509,8 +3493,6 @@ revert_new_lv:
if (!lv_remove(metadata_lv) || !vg_write(vg) || !vg_commit(vg))
log_error("Manual intervention may be required to remove "
"abandoned LV(s) before retrying.");
- else
- backup(vg);
}
return 0;
@@ -5701,8 +5683,6 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
if (!lv_detach_writecache_cachevol(lv, noflush))
return_0;
- backup(lv->vg);
-
log_print_unless_silent("Logical volume %s writecache has been detached.",
display_lvname(lv));
return 1;
@@ -5827,7 +5807,6 @@ static int _lvconvert_detach_writecache_when_clean(struct cmd_context *cmd,
}
ret = 1;
- backup(vg);
out_release:
if (ret)
@@ -6320,8 +6299,6 @@ static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_v
if (!ret)
return_0;
- backup(vg);
-
log_print_unless_silent("Logical volume %s has removed integrity.", display_lvname(lv));
return 1;
}
@@ -6354,8 +6331,6 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
if (!ret)
return_0;
- backup(vg);
-
log_print_unless_silent("Logical volume %s has added integrity.", display_lvname(lv));
return 1;
}
diff --git a/tools/pvmove_poll.c b/tools/pvmove_poll.c
index d379596f2..751313cd7 100644
--- a/tools/pvmove_poll.c
+++ b/tools/pvmove_poll.c
@@ -120,8 +120,5 @@ int pvmove_finish(struct cmd_context *cmd, struct volume_group *vg,
return 0;
}
- /* FIXME backup positioning */
- backup(vg);
-
return 1;
}
diff --git a/tools/toollib.c b/tools/toollib.c
index f337f9fcf..338551015 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3224,8 +3224,6 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (vg->needs_write_and_commit && (ret_max == ECMD_PROCESSED) &&
(!vg_write(vg) || !vg_commit(vg)))
ret_max = ECMD_FAILED;
- else if (vg->needs_backup)
- backup(vg);
if (lvargs_supplied) {
/*
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 625b68d46..9f972acdb 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -684,8 +684,6 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
}
@@ -1006,8 +1004,6 @@ static int _vgchange_locktype_single(struct cmd_context *cmd, const char *vg_nam
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
/*
* When init_vg_sanlock is called for vgcreate, the lockspace remains
* started and lvmlock remains active, but when called for
@@ -1202,8 +1198,6 @@ static int _vgchange_systemid_single(struct cmd_context *cmd, const char *vg_nam
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully changed", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index d6d6bb61d..dde3f1eac 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -167,8 +167,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
unlock_vg(cmd, vg, vp_new.vg_name);
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully created%s%s",
vg->name,
vg->system_id ? " with system ID " : "", vg->system_id ? : "");
diff --git a/tools/vgexport.c b/tools/vgexport.c
index 15cc3dd75..526ffed7d 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -54,8 +54,6 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully exported", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgextend.c b/tools/vgextend.c
index b0f49569f..0856b4c78 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -72,8 +72,6 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
if (!vg_write(vg) || !vg_commit(vg))
return_ECMD_FAILED;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully extended", vg_name);
return ECMD_PROCESSED;
@@ -116,8 +114,6 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
if (!vg_write(vg) || !vg_commit(vg))
goto_out;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully extended", vg_name);
ret = ECMD_PROCESSED;
out:
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 4b25b468f..84b76bd8d 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -46,8 +46,6 @@ static int _vgimport_single(struct cmd_context *cmd,
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
-
log_print_unless_silent("Volume group \"%s\" successfully imported", vg->name);
return ECMD_PROCESSED;
diff --git a/tools/vgimportdevices.c b/tools/vgimportdevices.c
index af0e618aa..1cf7ad31a 100644
--- a/tools/vgimportdevices.c
+++ b/tools/vgimportdevices.c
@@ -72,7 +72,6 @@ static int _vgimportdevices_single(struct cmd_context *cmd,
if (updated_pvs) {
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
- backup(vg);
}
return ECMD_PROCESSED;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index c759c6643..f500b553a 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -169,7 +169,6 @@ static int _vgreduce_repair_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- backup(vg);
return ECMD_PROCESSED;
}
diff --git a/tools/vgrename.c b/tools/vgrename.c
index 71b4e1677..d627bd056 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -141,8 +141,6 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
lockd_rename_vg_final(cmd, vg, 1);
- if (!backup(vg))
- stack;
if (!backup_remove(cmd, vg_name))
stack;
2 years, 10 months
main - archiving: take archive automatically
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ba3707d9539f9cc2e72...
Commit: ba3707d9539f9cc2e72c5368388ae795776379af
Parent: df27392c8c9ec5d1efd92c2214805471473f2a06
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 8 19:02:07 2021 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jun 9 14:56:13 2021 +0200
archiving: take archive automatically
Instead of calling explicit archive with command processing logic,
move this step towards 1st. vg_write() call, which will automatically
store archive of committed metadata.
This slightly changes some error path where the error in archiving
was detected earlier in the command, while now some on going command
'actions' might have been, but will be simply scratched in case
of error (since even new metadata would not have been even written).
So general effect should be only some command message ordering.
---
lib/metadata/lv_manip.c | 15 ---------------
lib/metadata/metadata.c | 6 +++---
lib/metadata/pv_manip.c | 3 ---
lib/metadata/vg.c | 3 ---
tools/lvconvert.c | 30 ------------------------------
tools/pvchange.c | 2 --
tools/pvmove.c | 3 ---
tools/vgchange.c | 8 --------
tools/vgcreate.c | 3 ---
tools/vgexport.c | 4 ----
tools/vgextend.c | 6 ------
tools/vgimport.c | 3 ---
tools/vgimportclone.c | 3 ---
tools/vgreduce.c | 3 ---
tools/vgrename.c | 3 ---
15 files changed, 3 insertions(+), 92 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 37dd3611d..899297f28 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4834,9 +4834,6 @@ int lv_rename_update(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (update_mda && !archive(vg))
- return_0;
-
if (old_lv_is_historical) {
/*
* Historical LVs have neither sub LVs nor any
@@ -6146,9 +6143,6 @@ int lv_resize(struct logical_volume *lv,
if (!lockd_lv_resize(cmd, lock_lv, "ex", 0, lp))
return_0;
- if (!archive(vg))
- return_0;
-
/* Remove any striped raid reshape space for LV resizing */
if (aux_lv && first_seg(aux_lv)->reshape_len)
if (!lv_raid_free_reshape_space(aux_lv))
@@ -6719,9 +6713,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (!archive(vg))
- return_0;
-
if (!lv_detach_writecache_cachevol(lv, 1)) {
log_error("Failed to detach writecache from %s", display_lvname(lv));
return 0;
@@ -6742,9 +6733,6 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
/* FIXME Review and fix the snapshot error paths! */
return_0;
- if (!archive(vg))
- return_0;
-
/* Special case removing a striped raid LV with allocated reshape space */
if (seg && seg->reshape_len) {
if (!(seg->segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_STRIPED)))
@@ -8458,9 +8446,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
- if (!archive(vg))
- return_NULL;
-
if (pool_lv && segtype_is_thin_volume(create_segtype)) {
/* Ensure all stacked messages are submitted */
if ((pool_is_active(pool_lv) || is_change_activating(lp->activate)) &&
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 0b284435b..6852d2a2a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -614,9 +614,6 @@ int vg_remove_check(struct volume_group *vg)
return 0;
}
- if (!archive(vg))
- return 0;
-
return 1;
}
@@ -2978,6 +2975,9 @@ int vg_write(struct volume_group *vg)
if (vg->cmd->wipe_outdated_pvs)
_wipe_outdated_pvs(vg->cmd, vg);
+ if (!vg_is_archived(vg) && vg->vg_committed && !archive(vg->vg_committed))
+ return_0;
+
if (critical_section())
log_error(INTERNAL_ERROR
"Writing metadata in critical section.");
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 5fd80a2ce..fd97bbbc2 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -623,9 +623,6 @@ int pv_resize_single(struct cmd_context *cmd,
const char *vg_name = pv->vg_name;
int vg_needs_pv_write = 0;
- if (!archive(vg))
- goto out;
-
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
pv_name);
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 3f9ec8d35..428e5dca7 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -694,9 +694,6 @@ int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
pvl = find_pv_in_vg(vg, name);
- if (!archive(vg))
- goto_bad;
-
log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
if (pvl)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 71f7a7627..c40031fe4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1861,9 +1861,6 @@ static int _lvconvert_splitsnapshot(struct cmd_context *cmd, struct logical_volu
}
}
- if (!archive(vg))
- return_0;
-
log_verbose("Splitting snapshot %s from its origin.", display_lvname(cow));
if (!vg_remove_snapshot(cow))
@@ -2796,9 +2793,6 @@ static int _lvconvert_to_thin_with_external(struct cmd_context *cmd,
if (!(lvc.segtype = get_segtype_from_string(cmd, SEG_TYPE_NAME_THIN)))
return_0;
- if (!archive(vg))
- return_0;
-
/*
* New thin LV needs to be created (all messages sent to pool) In this
* case thin volume is created READ-ONLY and also warn about not
@@ -2979,9 +2973,6 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
return 0;
}
- if (!archive(vg))
- return_0;
-
/* Swap names between old and new metadata LV */
if (!detach_pool_metadata_lv(seg, &prev_metadata_lv))
@@ -3286,9 +3277,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
meta_readahead = arg_uint_value(cmd, readahead_ARG, cmd->default_settings.read_ahead);
meta_alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, ALLOC_INHERIT);
- if (!archive(vg))
- goto_bad;
-
if (!(metadata_lv = alloc_pool_metadata(lv,
meta_name,
meta_readahead,
@@ -3305,9 +3293,6 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
goto bad;
}
- if (!archive(vg))
- goto_bad;
-
if (zero_metadata) {
metadata_lv->status |= LV_ACTIVATION_SKIP;
if (!activate_lv(cmd, metadata_lv)) {
@@ -3556,9 +3541,6 @@ static int _cache_vol_attach(struct cmd_context *cmd,
if (!get_cache_params(cmd, &chunk_size, &cache_metadata_format, &cache_mode, &policy_name, &policy_settings))
goto_out;
- if (!archive(vg))
- goto_out;
-
/*
* lv/cache_lv keeps the same lockd lock it had before, the lock for
* lv_fast is kept but is not used while it's attached, and
@@ -5525,9 +5507,6 @@ static int _lvconvert_to_vdopool_single(struct cmd_context *cmd,
}
}
- if (!archive(vg))
- goto_out;
-
if (!convert_vdo_pool_lv(lv, &vdo_params, &lvc.virtual_extents, zero_vdopool))
goto_out;
@@ -6198,9 +6177,6 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,
if (fast_name && !lockd_lv(cmd, lv_fast, "ex", 0))
goto_bad;
- if (!archive(vg))
- goto_bad;
-
/*
* lv keeps the same lockd lock it had before, the lock for
* lv_fast is kept but is not used while it's attached, and
@@ -6339,9 +6315,6 @@ static int _lvconvert_integrity_remove(struct cmd_context *cmd, struct logical_v
if (!lockd_lv(cmd, lv, "ex", 0))
return_0;
- if (!archive(vg))
- return_0;
-
if (lv_is_raid(lv))
ret = lv_remove_integrity_from_raid(lv);
if (!ret)
@@ -6371,9 +6344,6 @@ static int _lvconvert_integrity_add(struct cmd_context *cmd, struct logical_volu
} else
use_pvh = &vg->pvs;
- if (!archive(vg))
- return_0;
-
if (lv_is_partial(lv)) {
log_error("Cannot add integrity while LV is missing PVs.");
return 0;
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 04cbb428d..8b4a0643d 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -65,8 +65,6 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
"logical volumes", pv_name);
goto bad;
}
- if (!archive(vg))
- goto_bad;
} else {
if (tagargs) {
log_error("Can't change tag on Physical Volume %s not "
diff --git a/tools/pvmove.c b/tools/pvmove.c
index bb372f7dc..ed92f3ce4 100644
--- a/tools/pvmove.c
+++ b/tools/pvmove.c
@@ -709,9 +709,6 @@ static int _pvmove_setup_single(struct cmd_context *cmd,
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, pp->alloc,
&lvs_changed, &exclusive)))
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 032f3efcf..625b68d46 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -675,8 +675,6 @@ static int _vgchange_single(struct cmd_context *cmd, const char *vg_name,
for (i = 0; i < DM_ARRAY_SIZE(_vgchange_args); ++i) {
if (arg_is_set(cmd, _vgchange_args[i].arg)) {
- if (!archive(vg))
- return_ECMD_FAILED;
if (!_vgchange_args[i].fn(cmd, vg))
return_ECMD_FAILED;
}
@@ -1002,9 +1000,6 @@ static int _vgchange_locktype_single(struct cmd_context *cmd, const char *vg_nam
struct volume_group *vg,
struct processing_handle *handle)
{
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!_vgchange_locktype(cmd, vg))
return_ECMD_FAILED;
@@ -1201,9 +1196,6 @@ static int _vgchange_systemid_single(struct cmd_context *cmd, const char *vg_nam
struct volume_group *vg,
struct processing_handle *handle)
{
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!_vgchange_system_id(cmd, vg))
return_ECMD_FAILED;
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index f9c40e86d..d6d6bb61d 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -148,9 +148,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
}
}
- if (!archive(vg))
- goto_bad;
-
/* Store VG on disk(s) */
if (!vg_write(vg) || !vg_commit(vg))
goto_bad;
diff --git a/tools/vgexport.c b/tools/vgexport.c
index 86dad3abb..15cc3dd75 100644
--- a/tools/vgexport.c
+++ b/tools/vgexport.c
@@ -45,10 +45,6 @@ static int vgexport_single(struct cmd_context *cmd __attribute__((unused)),
}
}
-
- if (!archive(vg))
- goto_bad;
-
vg->status |= EXPORTED_VG;
vg->system_id = NULL;
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 04d37f886..b0f49569f 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -60,9 +60,6 @@ static int _vgextend_restoremissing(struct cmd_context *cmd __attribute__((unuse
int fixed = 0;
unsigned i;
- if (!archive(vg))
- return_0;
-
for (i = 0; i < pp->pv_count; i++)
if (_restore_pv(vg, pp->pv_names[i]))
fixed++;
@@ -99,9 +96,6 @@ static int _vgextend_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (!vg_extend_each_pv(vg, pp))
goto_out;
diff --git a/tools/vgimport.c b/tools/vgimport.c
index 0d8b0f215..4b25b468f 100644
--- a/tools/vgimport.c
+++ b/tools/vgimport.c
@@ -33,9 +33,6 @@ static int _vgimport_single(struct cmd_context *cmd,
goto bad;
}
- if (!archive(vg))
- goto_bad;
-
vg->status &= ~EXPORTED_VG;
if (!vg_is_shared(vg))
diff --git a/tools/vgimportclone.c b/tools/vgimportclone.c
index 1e6bb2d69..a47782771 100644
--- a/tools/vgimportclone.c
+++ b/tools/vgimportclone.c
@@ -110,9 +110,6 @@ static int _update_vg(struct cmd_context *cmd, struct volume_group *vg,
* Write changes.
*/
- if (!archive(vg))
- goto_bad;
-
if (vp->import_vg)
vg->status &= ~EXPORTED_VG;
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 4a4202e86..c759c6643 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -157,9 +157,6 @@ static int _vgreduce_repair_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_PROCESSED;
}
- if (!archive(vg))
- return_ECMD_FAILED;
-
if (vp->force) {
if (!_make_vg_consistent(cmd, vg))
return_ECMD_FAILED;
diff --git a/tools/vgrename.c b/tools/vgrename.c
index f442f731f..71b4e1677 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -103,9 +103,6 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
dev_dir = cmd->dev_dir;
- if (!archive(vg))
- goto error;
-
if (!lockd_rename_vg_before(cmd, vg)) {
stack;
goto error;
2 years, 10 months
main - man/help: fix common option listing
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=df27392c8c9ec5d1efd...
Commit: df27392c8c9ec5d1efd92c2214805471473f2a06
Parent: ca930bd936de2e7d4a83fa64add800baf6cfd116
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 8 14:07:39 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 8 14:07:39 2021 -0500
man/help: fix common option listing
---
tools/command.c | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/tools/command.c b/tools/command.c
index 1de739aaa..7205969e1 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2146,6 +2146,7 @@ void print_usage_common_lvm(struct command_name *cname, struct command *cmd)
void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
{
int oo, opt_enum;
+ int found_common_command = 0;
/*
* when there's more than one variant, options that
@@ -2155,6 +2156,18 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf(" Common options for command:");
/* print options with short opts */
@@ -2213,7 +2226,7 @@ void print_usage_common_cmd(struct command_name *cname, struct command *cmd)
printf(" ]");
}
- printf(".P\n");
+ printf("\n\n");
}
void print_usage_notes(struct command_name *cname)
@@ -2994,6 +3007,7 @@ static void _print_man_usage_common_cmd(struct command *cmd)
{
struct command_name *cname;
int i, sep, oo, opt_enum;
+ int found_common_command = 0;
if (!(cname = _find_command_name(cmd->name)))
return;
@@ -3001,6 +3015,18 @@ static void _print_man_usage_common_cmd(struct command *cmd)
if (cname->variants < 2)
return;
+ for (opt_enum = 0; opt_enum < ARG_COUNT; opt_enum++) {
+ if (!cname->common_options[opt_enum])
+ continue;
+ if (_is_lvm_all_opt(opt_enum))
+ continue;
+ found_common_command = 1;
+ break;
+ }
+
+ if (!found_common_command)
+ return;
+
printf("Common options for command:\n");
printf(".\n");
2 years, 10 months
main - devices: don't use deleted loop backing file for device id
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ca930bd936de2e7d4a8...
Commit: ca930bd936de2e7d4a83fa64add800baf6cfd116
Parent: 5e17203ff5dd4296760e5dad683e4cc84df2801d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 8 12:16:06 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 8 12:16:06 2021 -0500
devices: don't use deleted loop backing file for device id
check for "(deleted)" in the backing_file string and
fall back to devname for id.
$ cat /sys/block/loop0/loop/backing_file
/root/looptmp (deleted)
---
lib/device/device_id.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 67f72e51b..1b98487ab 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -325,8 +325,12 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
else if (idtype == DEV_ID_TYPE_MD_UUID)
_read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf));
- else if (idtype == DEV_ID_TYPE_LOOP_FILE)
+ else if (idtype == DEV_ID_TYPE_LOOP_FILE) {
_read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf));
+ /* if backing file is deleted, fall back to devname */
+ if (strstr(sysbuf, "(deleted)"))
+ sysbuf[0] = '\0';
+ }
else if (idtype == DEV_ID_TYPE_DEVNAME) {
if (!(idname = strdup(dev_name(dev))))
2 years, 10 months
main - lvmlockd: Fix the compilation warning
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5e17203ff5dd4296760...
Commit: 5e17203ff5dd4296760e5dad683e4cc84df2801d
Parent: 9759f915e78044667681de395bf2694bd5c7f393
Author: Leo Yan <leo.yan(a)linaro.org>
AuthorDate: Tue Jun 8 14:45:09 2021 +0800
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 8 09:33:26 2021 -0500
lvmlockd: Fix the compilation warning
As SUSE build tool reports the warning:
lvmlockd-core.c: In function 'client_thread_main':
lvmlockd-core.c:4959:37: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
snprintf(buf, sizeof(buf), "path[%d]", i);
^~
lvmlockd-core.c:4959:31: note: directive argument in the range [0, 2147483647]
snprintf(buf, sizeof(buf), "path[%d]", i);
^~~~~~~~~~
To dismiss the compilation warning, enlarge the array "buf" to 17
bytes to support the max signed integer: string format 6 bytes + signed
integer 10 bytes + terminal char "\0".
Reported-by: Heming Zhao <heming.zhao(a)suse.com>
Signed-off-by: Leo Yan <leo.yan(a)linaro.org>
---
daemons/lvmlockd/lvmlockd-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index ea76f2214..fef9589b9 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -4780,7 +4780,7 @@ static void client_recv_action(struct client *cl)
const char *path;
const char *str;
struct pvs pvs;
- char buf[11]; /* p a t h [ x x x x ] \0 */
+ char buf[17]; /* "path[%d]\0", %d outputs signed integer so max to 10 bytes */
int64_t val;
uint32_t opts = 0;
int result = 0;
2 years, 10 months
main - tests: add writecache-cache-blocksize-2
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9759f915e7804466768...
Commit: 9759f915e78044667681de395bf2694bd5c7f393
Parent: ff677aa69f8fc31e5733b0650e2324c826ce0794
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 7 15:40:40 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 7 15:40:40 2021 -0500
tests: add writecache-cache-blocksize-2
inconsistent physical block size of devs used
for main LV and cache
---
test/shell/writecache-cache-blocksize-2.sh | 232 +++++++++++++++++++++++++++++
1 file changed, 232 insertions(+)
diff --git a/test/shell/writecache-cache-blocksize-2.sh b/test/shell/writecache-cache-blocksize-2.sh
new file mode 100644
index 000000000..af4f60e1d
--- /dev/null
+++ b/test/shell/writecache-cache-blocksize-2.sh
@@ -0,0 +1,232 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+# Test dm-writecache and dm-cache with different block size combinations
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+mnt="mnt"
+mkdir -p $mnt
+
+awk 'BEGIN { while (z++ < 16384) printf "A" }' > fileA
+awk 'BEGIN { while (z++ < 16384) printf "B" }' > fileB
+awk 'BEGIN { while (z++ < 16384) printf "C" }' > fileC
+
+# generate random data
+dd if=/dev/urandom of=randA bs=512K count=2
+dd if=/dev/urandom of=randB bs=512K count=3
+dd if=/dev/urandom of=randC bs=512K count=4
+
+_add_new_data_to_mnt() {
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp randA $mnt
+ cp randB $mnt
+ cp randC $mnt
+ mkdir $mnt/1
+ cp fileA $mnt/1
+ cp fileB $mnt/1
+ cp fileC $mnt/1
+ mkdir $mnt/2
+ cp fileA $mnt/2
+ cp fileB $mnt/2
+ cp fileC $mnt/2
+ sync
+}
+
+_add_more_data_to_mnt() {
+ mkdir $mnt/more
+ cp fileA $mnt/more
+ cp fileB $mnt/more
+ cp fileC $mnt/more
+ cp randA $mnt/more
+ cp randB $mnt/more
+ cp randC $mnt/more
+ sync
+}
+
+_verify_data_on_mnt() {
+ diff randA $mnt/randA
+ diff randB $mnt/randB
+ diff randC $mnt/randC
+ diff fileA $mnt/1/fileA
+ diff fileB $mnt/1/fileB
+ diff fileC $mnt/1/fileC
+ diff fileA $mnt/2/fileA
+ diff fileB $mnt/2/fileB
+ diff fileC $mnt/2/fileC
+}
+
+_verify_more_data_on_mnt() {
+ diff randA $mnt/more/randA
+ diff randB $mnt/more/randB
+ diff randC $mnt/more/randC
+ diff fileA $mnt/more/fileA
+ diff fileB $mnt/more/fileB
+ diff fileC $mnt/more/fileC
+}
+
+_verify_data_on_lv() {
+ lvchange -ay $vg/$lv1
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+ _verify_data_on_mnt
+ rm $mnt/randA
+ rm $mnt/randB
+ rm $mnt/randC
+ rm -rf $mnt/1
+ rm -rf $mnt/2
+ umount $mnt
+ lvchange -an $vg/$lv1
+}
+
+# Check that the LBS ($1) and PBS ($2) are accurately reported.
+_check_env() {
+
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "$1"
+ check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "$2"
+
+ blockdev --getss "$dev1"
+ blockdev --getpbsz "$dev1"
+ blockdev --getss "$dev2"
+ blockdev --getpbsz "$dev2"
+}
+
+#
+# _run_test $BD1 $BD2 $type $optname "..."
+#
+# $BD1: device to place the main LV on
+# $BD2: device to place the cache on
+# $type is cache or writecache to use in lvconvert --type $type
+# $optname is either --cachevol or --cachepool to use in lvconvert
+# "..." a sector size option to use in mkfs.xfs
+#
+
+_run_test() {
+ vgcreate $SHARED $vg "$1"
+ vgextend $vg "$2"
+ lvcreate -n $lv1 -l 8 -an $vg "$1"
+ lvcreate -n $lv2 -l 4 -an $vg "$2"
+ lvchange -ay $vg/$lv1
+ mkfs.xfs -f $5 "$DM_DEV_DIR/$vg/$lv1" |tee out
+ _add_new_data_to_mnt
+ lvconvert --yes --type $3 $4 $lv2 $vg/$lv1
+
+ # TODO: check expected LBS of LV1
+ # blockdev --getss "$DM_DEV_DIR/$vg/$lv1" |tee out
+ # grep "$N" out
+ # TODO: check expected PBS of LV1
+ # blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1" |tee out
+ # grep "$N" out
+
+ _add_more_data_to_mnt
+ _verify_data_on_mnt
+ lvconvert --splitcache $vg/$lv1
+ check lv_field $vg/$lv1 segtype linear
+ blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+ blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+ _verify_data_on_mnt
+ _verify_more_data_on_mnt
+ umount $mnt
+ lvchange -an $vg/$lv1
+ lvchange -an $vg/$lv2
+ _verify_data_on_lv
+ lvremove $vg/$lv1
+ lvremove $vg/$lv2
+ vgremove $vg
+}
+
+# Setup: dev1 LBS 512, PBS 4096 (using scsi-debug)
+# dev2 LBS 512, PBS 4096 (using scsi-debug)
+# dev3 LBS 512, PBS 512 (using loop)
+# dev4 LBS 512, PBS 512 (using loop)
+#
+
+aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
+aux prepare_devs 2 64
+
+# loopa/loopb have LBS 512 PBS 512
+which fallocate || skip
+fallocate -l 64M loopa
+fallocate -l 64M loopb
+
+for i in {1..5}; do
+ LOOP1=$(losetup -f loopa --show || true)
+ test -n "$LOOP1" && break
+done
+for i in {1..5} ; do
+ LOOP2=$(losetup -f loopb --show || true)
+ test -n "$LOOP2" && break
+done
+
+# prepare devX mapping so it works for real & fake dev dir
+d=3
+for i in "$LOOP1" "$LOOP2"; do
+ echo "$i"
+ m=${i##*loop}
+ test -e "$DM_DEV_DIR/loop$m" || mknod "$DM_DEV_DIR/loop$m" b 7 "$m"
+ eval "dev$d=\"$DM_DEV_DIR/loop$m\""
+ d=$(( d + 1 ))
+done
+
+# verify dev1/dev2 have LBS 512 PBS 4096
+_check_env "512" "4096"
+
+# verify dev3/dev4 have LBS 512 PBS 512
+blockdev --getss "$LOOP1" | grep 512
+blockdev --getss "$LOOP2" | grep 512
+blockdev --getpbsz "$LOOP1" | grep 512
+blockdev --getpbsz "$LOOP2" | grep 512
+
+aux extend_filter "a|$dev3|" "a|$dev4|"
+
+# place main LV on dev1 with LBS 512, PBS 4096
+# and the cache on dev3 with LBS 512, PBS 512
+
+_run_test "$dev1" "$dev3" "writecache" "--cachevol" ""
+_run_test "$dev1" "$dev3" "cache" "--cachevol" ""
+_run_test "$dev1" "$dev3" "cache" "--cachepool" ""
+
+# place main LV on dev3 with LBS 512, PBS 512
+# and the cache on dev1 with LBS 512, PBS 4096
+
+_run_test "$dev3" "$dev1" "writecache" "--cachevol" ""
+_run_test "$dev3" "$dev1" "cache" "--cachevol" ""
+_run_test "$dev3" "$dev1" "cache" "--cachepool" ""
+
+# place main LV on dev1 with LBS 512, PBS 4096
+# and the cache on dev3 with LBS 512, PBS 512
+# and force xfs sectsz 512
+
+_run_test "$dev1" "$dev3" "writecache" "--cachevol" "-s size=512"
+_run_test "$dev1" "$dev3" "cache" "--cachevol" "-s size=512"
+_run_test "$dev1" "$dev3" "cache" "--cachepool" "-s size=512"
+
+# place main LV on dev3 with LBS 512, PBS 512
+# and the cache on dev1 with LBS 512, PBS 4096
+# and force xfs sectsz 4096
+
+_run_test "$dev3" "$dev1" "writecache" "--cachevol" "-s size=4096"
+_run_test "$dev3" "$dev1" "cache" "--cachevol" "-s size=4096"
+_run_test "$dev3" "$dev1" "cache" "--cachepool" "-s size=4096"
+
+
+losetup -d "$LOOP1" || true
+losetup -d "$LOOP2" || true
+rm loopa loopb
+
+aux cleanup_scsi_debug_dev
2 years, 10 months
main - tests: rename test
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ff677aa69f8fc31e573...
Commit: ff677aa69f8fc31e5733b0650e2324c826ce0794
Parent: a7f334a53269ee6967417a01d37b7f9592637cfc
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 7 12:12:33 2021 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 7 12:12:33 2021 -0500
tests: rename test
---
test/shell/{writecache-blocksize.sh => writecache-cache-blocksize.sh} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
diff --git a/test/shell/writecache-blocksize.sh b/test/shell/writecache-cache-blocksize.sh
similarity index 100%
rename from test/shell/writecache-blocksize.sh
rename to test/shell/writecache-cache-blocksize.sh
2 years, 10 months