Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7f1f7ad694201533c04dd…
Commit: 7f1f7ad694201533c04ddfbe9ba047f832b38750
Parent: 89cec5b65af5533bcde358d8d4f7d1d5701a341b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jan 18 17:33:53 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
lvcreate: code move
---
tools/lvcreate.c | 48 ++++++++++++++++++++++--------------------------
1 file changed, 22 insertions(+), 26 deletions(-)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 2c519d555..b58fd62bb 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1851,30 +1851,28 @@ static int _lvcreate_and_attach_writecache_single(struct cmd_context *cmd,
int lvcreate_and_attach_writecache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle = NULL;
- struct processing_params pp;
struct lvcreate_params lp = {
.major = -1,
.minor = -1,
+ /*
+ * Tell lvcreate to ignore --type since we are using lvcreate
+ * to create a linear LV and using lvconvert to add cache.
+ * (Would be better if lvcreate code was split up so we could
+ * call a specific function that just created a linear/striped LV.)
+ */
+ .ignore_type = 1,
};
struct lvcreate_cmdline_params lcp = { 0 };
+ struct processing_params pp = {
+ .lp = &lp,
+ .lcp = &lcp,
+ };
int ret;
-
- /*
- * Tell lvcreate to ignore --type since we are using lvcreate
- * to create a linear LV and using lvconvert to add cache.
- * (Would be better if lvcreate code was split up so we could
- * call a specific function that just created a linear/striped LV.)
- */
- lp.ignore_type = 1;
-
if (!_lvcreate_params(cmd, argc, argv, &lp, &lcp)) {
stack;
return EINVALID_CMD_LINE;
}
- pp.lp = &lp;
- pp.lcp = &lcp;
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -1925,30 +1923,29 @@ static int _lvcreate_and_attach_cache_single(struct cmd_context *cmd,
int lvcreate_and_attach_cache_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct processing_handle *handle = NULL;
- struct processing_params pp;
struct lvcreate_params lp = {
.major = -1,
.minor = -1,
+ /*
+ * Tell lvcreate to ignore --type since we are using lvcreate
+ * to create a linear LV and using lvconvert to add cache.
+ * (Would be better if lvcreate code was split up so we could
+ * call a specific function that just created a linear/striped LV.)
+ */
+ .ignore_type = 1,
};
struct lvcreate_cmdline_params lcp = { 0 };
+ struct processing_params pp = {
+ .lp = &lp,
+ .lcp = &lcp,
+ };
int ret;
- /*
- * Tell lvcreate to ignore --type since we are using lvcreate
- * to create a linear LV and using lvconvert to add cache.
- * (Would be better if lvcreate code was split up so we could
- * call a specific function that just created a linear/striped LV.)
- */
- lp.ignore_type = 1;
-
if (!_lvcreate_params(cmd, argc, argv, &lp, &lcp)) {
stack;
return EINVALID_CMD_LINE;
}
- pp.lp = &lp;
- pp.lcp = &lcp;
-
if (!(handle = init_processing_handle(cmd, NULL))) {
log_error("Failed to initialize processing handle.");
return ECMD_FAILED;
@@ -1963,4 +1960,3 @@ int lvcreate_and_attach_cache_cmd(struct cmd_context *cmd, int argc, char **argv
destroy_processing_handle(cmd, handle);
return ret;
}
-
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b95506815fa149cf13568…
Commit: b95506815fa149cf135687cbe047b7bdfcd6e00f
Parent: d8dbabb28e674e9f2aac2716b235f27f1d333e1a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 24 14:50:09 2022 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Jan 26 15:09:58 2022 +0100
man: doc writecache profile support
---
man/lvmcache.7_main | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main
index 48cf7b492..8d7d3d17b 100644
--- a/man/lvmcache.7_main
+++ b/man/lvmcache.7_main
@@ -299,6 +299,39 @@ perform. If not done beforehand, the splitcache command enables the
cleaner mode and waits for flushing to complete before detaching the
writecache. Adding cleaner=0 to the splitcache command will skip the
cleaner mode, and any required flushing is performed in device suspend.
+
+.SS dm-writecache using metadata profiles
+
+Writecache allows to set a variety of options. Lots of these settings
+can be specified in lvm.conf or profile settings. You can prepare
+a number of different profiles in the \fI#DEFAULT_SYS_DIR#/profile\fP directory
+and just specify the metadata profile file name when writecaching LV.
+.P
+.I Example
+.nf
+# cat <<EOF > #DEFAULT_SYS_DIR#/profile/cache_writecache.profile
+allocation {
+.RS
+cache_settings {
+.RS
+writecache {
+.RS
+high_watermark=60
+writeback_jobs=1024
+.RE
+}
+.RE
+}
+.RE
+}
+EOF
+.P
+
+# lvcreate -an -L10G --name wcache vg /dev/fast_ssd
+# lvcreate --type writecache -L10G --name main --cachevol wcache \\
+ --metadataprofile cache_writecache vg /dev/slow_hdd
+.fi
+
.
.SS dm-cache with separate data and metadata LVs
.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9e9f02acf04a1dd002709…
Commit: 9e9f02acf04a1dd002709b2239a28ac56dd76aba
Parent: de7892f0af275615d2db0c7e6a4bbc56cd4962e8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jan 25 10:47:50 2022 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jan 25 10:47:50 2022 -0600
device_id: fix search for renamed device when the wwid is ignored
When a device has a wwid (from sysfs), but lvm ignores the wwid,
e.g. because it contains an unreliable "QEMU" value, then lvm
falls back to using IDTYPE=devname (the device name) as the
device id. If the device name changes after reboot, then lvm
automatically searches for the PV on other devices to find the
new device name and correct system.devices. When searching for
the PV, lvm skips looking at devices that would use other id types,
e.g. if a device would use a wwid and not a devname, then it
skips checking it. However, it failed to account for the fact
that a device may have wwid that was ignored, in which case it
should be checked.
---
lib/device/device_id.c | 39 ++++++++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 9 deletions(-)
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index ad9694b8a..ecf89918d 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -315,7 +315,6 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
/* qemu wwid begins "t10.ATA QEMU HARDDISK ..." */
if (strstr(sysbuf, "QEMU HARDDISK"))
sysbuf[0] = '\0';
-
}
else if (idtype == DEV_ID_TYPE_SYS_SERIAL)
@@ -366,7 +365,6 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
return idname;
bad:
- log_debug("No idtype %s for %s", idtype_to_str(idtype), dev_name(dev));
return NULL;
}
@@ -378,20 +376,40 @@ static int _dev_has_stable_id(struct cmd_context *cmd, struct device *dev)
{
char sysbuf[PATH_MAX] = { 0 };
struct dev_id *id;
+ const char *idname;
+ /*
+ * An idtype other than DEVNAME is stable, i.e. it doesn't change after
+ * reboot or device reattach.
+ * An id on dev->ids with idtype set and !idname means that idtype does
+ * not exist for the dev. (Optimization to avoid repeated negative
+ * system_read.)
+ */
dm_list_iterate_items(id, &dev->ids) {
- if (id->idtype != DEV_ID_TYPE_DEVNAME)
+ if ((id->idtype != DEV_ID_TYPE_DEVNAME) && id->idname)
return 1;
}
- if (read_sys_block(cmd, dev, "device/wwid", sysbuf, sizeof(sysbuf)))
+ /*
+ * Use device_id_system_read() instead of read_sys_block() when
+ * system_read ignores some values from sysfs.
+ */
+
+ if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_WWID))) {
+ free((void*)idname);
return 1;
+ }
- if (read_sys_block(cmd, dev, "wwid", sysbuf, sizeof(sysbuf)))
+ if ((idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_SYS_SERIAL))) {
+ free((void*)idname);
return 1;
+ }
- if (read_sys_block(cmd, dev, "device/serial", sysbuf, sizeof(sysbuf)))
+ if ((MAJOR(dev->dev) == cmd->dev_types->loop_major) &&
+ (idname = device_id_system_read(cmd, dev, DEV_ID_TYPE_LOOP_FILE))) {
+ free((void*)idname);
return 1;
+ }
if ((MAJOR(dev->dev) == cmd->dev_types->device_mapper_major)) {
if (!read_sys_block(cmd, dev, "dm/uuid", sysbuf, sizeof(sysbuf)))
@@ -409,9 +427,6 @@ static int _dev_has_stable_id(struct cmd_context *cmd, struct device *dev)
read_sys_block(cmd, dev, "md/uuid", sysbuf, sizeof(sysbuf)))
return 1;
- if ((MAJOR(dev->dev) == cmd->dev_types->loop_major) &&
- read_sys_block(cmd, dev, "loop/backing_file", sysbuf, sizeof(sysbuf)))
- return 1;
out:
/* DEV_ID_TYPE_DEVNAME would be used for this dev. */
return 0;
@@ -2169,6 +2184,12 @@ void device_ids_find_renamed_devs(struct cmd_context *cmd, struct dm_list *dev_l
*
* TODO: in auto mode should we look in other non-system
* devices files and skip any devs included in those?
+ *
+ * Note that a user can override a stable id type and use
+ * devname for a device's id, in which case this optimization
+ * can prevent a search from finding a renamed dev. So, if a
+ * user forces a devname id, then they should probably also
+ * set search_for_devnames=all.
*/
if (search_auto && _dev_has_stable_id(cmd, dev)) {
other_idtype++;