main - WHATS_NEW: updates
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d280999b62c61b9769e...
Commit: d280999b62c61b9769eb5c3a01a19fa54461259d
Parent: d422aa79249a069317ef71e872da42d6e2e6c344
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 8 23:16:54 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
WHATS_NEW: updates
---
WHATS_NEW | 2 ++
1 file changed, 2 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 42ea4f550..bf2c5806c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.03.12 -
===================================
+ Support resize of cached volumes.
+ Disable autoactivation with global/event_activation=0.
Check if lvcreate passes read_only_volume_list with tags and skips zeroing.
Allocation prints better error when metadata cannot fit on a single PV.
Pvmove can better resolve full thin-pool tree move.
2 years, 7 months
main - dev-type: convert to use log_warn
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d422aa79249a069317e...
Commit: d422aa79249a069317ef71e872da42d6e2e6c344
Parent: 3bf2ca11d9ce4ce205a98828ec4bfe8169c33403
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 14:06:12 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
dev-type: convert to use log_warn
Keep log_error designated only for 'erroring' condition of command
and replace these errors with log_warn() WARNING.
Also do some indent changes.
---
lib/device/bcache.c | 27 +++++++++++++--------------
lib/device/dev-cache.c | 6 +++---
lib/device/dev-io.c | 9 +++++----
lib/device/dev-type.c | 34 +++++++++++++++++-----------------
4 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/lib/device/bcache.c b/lib/device/bcache.c
index 2451eda2b..a3803befb 100644
--- a/lib/device/bcache.c
+++ b/lib/device/bcache.c
@@ -42,7 +42,7 @@ static int *_fd_table;
static void log_sys_warn(const char *call)
{
- log_warn("%s failed: %s", call, strerror(errno));
+ log_warn("WARNING: %s failed: %s.", call, strerror(errno));
}
// Assumes the list is not empty.
@@ -92,7 +92,7 @@ static void _cb_set_destroy(struct cb_set *cbs)
// never be in flight IO.
if (!dm_list_empty(&cbs->allocated)) {
// bail out
- log_error("async io still in flight");
+ log_warn("WARNING: async io still in flight.");
return;
}
@@ -1351,26 +1351,26 @@ static bool _writeback_v(struct radix_tree_iterator *it,
struct block *b = v.ptr;
if (_test_flags(b, BF_DIRTY))
- _issue_write(b);
+ _issue_write(b);
- return true;
+ return true;
}
static bool _invalidate_v(struct radix_tree_iterator *it,
uint8_t *kb, uint8_t *ke, union radix_value v)
{
struct block *b = v.ptr;
- struct invalidate_iterator *iit = container_of(it, struct invalidate_iterator, it);
+ struct invalidate_iterator *iit = container_of(it, struct invalidate_iterator, it);
if (b->error || _test_flags(b, BF_DIRTY)) {
- log_warn("bcache_invalidate: block (%d, %llu) still dirty",
- b->di, (unsigned long long) b->index);
- iit->success = false;
- return true;
+ log_warn("WARNING: bcache_invalidate: block (%d, %llu) still dirty.",
+ b->di, (unsigned long long) b->index);
+ iit->success = false;
+ return true;
}
if (b->ref_count) {
- log_warn("bcache_invalidate: block (%d, %llu) still held",
+ log_warn("WARNING: bcache_invalidate: block (%d, %llu) still held.",
b->di, (unsigned long long) b->index);
iit->success = false;
return true;
@@ -1386,7 +1386,7 @@ static bool _invalidate_v(struct radix_tree_iterator *it,
bool bcache_invalidate_di(struct bcache *cache, int di)
{
- union key k;
+ union key k;
struct invalidate_iterator it;
k.parts.di = di;
@@ -1429,7 +1429,7 @@ static bool _abort_v(struct radix_tree_iterator *it,
void bcache_abort_di(struct bcache *cache, int di)
{
- union key k;
+ union key k;
struct radix_tree_iterator it;
k.parts.di = di;
@@ -1512,10 +1512,9 @@ int bcache_change_fd(int di, int fd)
if (di >= _fd_table_size)
return 0;
if (di < 0) {
- log_error(INTERNAL_ERROR "Cannot change not openned DI with FD:%d", fd);
+ log_error(INTERNAL_ERROR "Cannot change not opened DI with FD:%d", fd);
return 0;
}
_fd_table[di] = fd;
return 1;
}
-
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 517b9e6f8..2783d4acc 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -403,7 +403,7 @@ static int _get_sysfs_value(const char *path, char *buf, size_t buf_size, int er
r = 1;
out:
if (fclose(fp))
- log_sys_error("fclose", path);
+ log_sys_debug("fclose", path);
return r;
}
@@ -930,7 +930,7 @@ static int _dev_cache_iterate_sysfs_for_index(const char *path)
r = !partial_failure;
if (closedir(d))
- log_sys_error("closedir", path);
+ log_sys_debug("closedir", path);
return r;
}
@@ -956,7 +956,7 @@ int dev_cache_index_devs(void)
return 1;
}
- log_sys_error("stat", path);
+ log_sys_debug("stat", path);
return 0;
}
} else if (!sysfs_has_dev_block)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 4f52954fd..9b007dcaa 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -104,7 +104,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
}
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
- log_sys_error("ioctl BLKGETSIZE64", name);
+ log_warn("WARNING: %s: ioctl BLKGETSIZE64 %s", name, strerror(errno));
if (do_close && !dev_close_immediate(dev))
stack;
return 0;
@@ -132,12 +132,13 @@ static int _dev_read_ahead_dev(struct device *dev, uint32_t *read_ahead)
}
if (!dev_open_readonly_quiet(dev)) {
- log_error("Failed to open to get readahead %s", dev_name(dev));
+ log_warn("WARNING: Failed to open %s to get readahead %s.",
+ dev_name(dev), strerror(errno));
return 0;
}
if (ioctl(dev->fd, BLKRAGET, &read_ahead_long) < 0) {
- log_sys_error("ioctl BLKRAGET", dev_name(dev));
+ log_warn("WARNING: %s: ioctl BLKRAGET %s.", dev_name(dev), strerror(errno));
if (!dev_close_immediate(dev))
stack;
return 0;
@@ -170,7 +171,7 @@ static int _dev_discard_blocks(struct device *dev, uint64_t offset_bytes, uint64
test_mode() ? " (test mode - suppressed)" : "");
if (!test_mode() && ioctl(dev->fd, BLKDISCARD, &discard_range) < 0) {
- log_error("%s: BLKDISCARD ioctl at offset %" PRIu64 " size %" PRIu64 " failed: %s.",
+ log_warn("WARNING: %s: ioctl BLKDISCARD at offset %" PRIu64 " size %" PRIu64 " failed: %s.",
dev_name(dev), offset_bytes, size_bytes, strerror(errno));
if (!dev_close_immediate(dev))
stack;
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index c9f12d793..11add4b6b 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -211,7 +211,7 @@ struct dev_types *create_dev_types(const char *proc_dir,
log_error("Expecting string in devices/types "
"in config file");
if (fclose(pd))
- log_sys_error("fclose", proc_devices);
+ log_sys_debug("fclose", proc_devices);
goto bad;
}
dev_len = strlen(cv->v.str);
@@ -222,7 +222,7 @@ struct dev_types *create_dev_types(const char *proc_dir,
"in devices/types in config file",
name);
if (fclose(pd))
- log_sys_error("fclose", proc_devices);
+ log_sys_debug("fclose", proc_devices);
goto bad;
}
if (!cv->v.i) {
@@ -230,7 +230,7 @@ struct dev_types *create_dev_types(const char *proc_dir,
"%s in devices/types in config file",
name);
if (fclose(pd))
- log_sys_error("fclose", proc_devices);
+ log_sys_debug("fclose", proc_devices);
goto bad;
}
if (dev_len <= strlen(line + i) &&
@@ -391,13 +391,13 @@ static int _has_sys_partition(struct device *dev)
/* check if dev is a partition */
if (dm_snprintf(path, sizeof(path), "%s/dev/block/%d:%d/partition",
dm_sysfs_dir(), major, minor) < 0) {
- log_error("dm_snprintf partition failed");
+ log_warn("WARNING: %s: partition path is too long.", dev_name(dev));
return 0;
}
if (stat(path, &info) == -1) {
if (errno != ENOENT)
- log_sys_error("stat", path);
+ log_sys_debug("stat", path);
return 0;
}
return 1;
@@ -563,7 +563,6 @@ int dev_is_partitioned(struct dev_types *dt, struct device *dev)
*/
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
{
- const char *sysfs_dir = dm_sysfs_dir();
int major = (int) MAJOR(dev->dev);
int minor = (int) MINOR(dev->dev);
char path[PATH_MAX];
@@ -616,24 +615,25 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
* Parent's 'dev' sysfs attribute = /sys/block/md0/dev
*/
if ((size = readlink(dirname(path), temp_path, sizeof(temp_path) - 1)) < 0) {
- log_sys_error("readlink", path);
+ log_warn("WARNING: Readlink of %s failed.", path);
goto out;
}
temp_path[size] = '\0';
if (dm_snprintf(path, sizeof(path), "%s/block/%s/dev",
- sysfs_dir, basename(dirname(temp_path))) < 0) {
- log_error("dm_snprintf dev failed");
+ dm_sysfs_dir(), basename(dirname(temp_path))) < 0) {
+ log_warn("WARNING: sysfs path for %s is too long.",
+ basename(dirname(temp_path)));
goto out;
}
/* finally, parse 'dev' attribute and create corresponding dev_t */
if (!(fp = fopen(path, "r"))) {
if (errno == ENOENT)
- log_error("sysfs file %s does not exist.", path);
+ log_debug("sysfs file %s does not exist.", path);
else
- log_sys_error("fopen", path);
+ log_sys_debug("fopen", path);
goto out;
}
@@ -643,7 +643,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
}
if (sscanf(buffer, "%d:%d", &major, &minor) != 2) {
- log_error("sysfs file %s not in expected MAJ:MIN format: %s",
+ log_warn("WARNING: sysfs file %s not in expected MAJ:MIN format: %s",
path, buffer);
goto out;
}
@@ -651,7 +651,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
ret = 2;
out:
if (fp && fclose(fp))
- log_sys_error("fclose", path);
+ log_sys_debug("fclose", path);
return ret;
}
@@ -713,7 +713,7 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
return 0;
}
- log_error("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
+ log_warn("WARNING: " MSG_FAILED_SIG_OFFSET MSG_WIPING_SKIPPED, type, name);
return 2;
}
if (blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len)) {
@@ -911,9 +911,9 @@ int wipe_known_signatures(struct cmd_context *cmd, struct device *dev,
yes, force, wiped);
#endif
if (blkid_wiping_enabled) {
- log_warn("allocation/use_blkid_wiping=1 configuration setting is set "
+ log_warn("WARNING: allocation/use_blkid_wiping=1 configuration setting is set "
"while LVM is not compiled with blkid wiping support.");
- log_warn("Falling back to native LVM signature detection.");
+ log_warn("WARNING: Falling back to native LVM signature detection.");
}
return _wipe_known_signatures_with_lvm(dev, name,
types_to_exclude,
@@ -929,7 +929,7 @@ static int _snprintf_attr(char *buf, size_t buf_size, const char *sysfs_dir,
if (dm_snprintf(buf, buf_size, "%s/dev/block/%d:%d/%s", sysfs_dir,
(int)MAJOR(dev), (int)MINOR(dev),
attribute) < 0) {
- log_warn("dm_snprintf %s failed.", attribute);
+ log_warn("WARNING: sysfs path for %s attribute is too long.", attribute);
return 0;
}
2 years, 7 months
main - dev-type: use fopen for sysfs file
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3bf2ca11d9ce4ce205a...
Commit: 3bf2ca11d9ce4ce205a98828ec4bfe8169c33403
Parent: e429e69b6593fa688727fb632d7050f05cd27317
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 14:07:17 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
dev-type: use fopen for sysfs file
Directly open sysfs files and save extra stat() call which
is not adding any extra safety in sysfs dir.
---
lib/device/dev-type.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index dca81d8d1..c9f12d793 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -944,8 +944,7 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
const char *sysfs_dir = dm_sysfs_dir();
char path[PATH_MAX], buffer[64];
FILE *fp;
- struct stat info;
- dev_t uninitialized_var(primary);
+ dev_t primary = 0;
unsigned long result = default_value;
unsigned long value = 0UL;
@@ -963,9 +962,9 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
* - if not: either the kernel doesn't have topology support
* or the device could be a partition
*/
- if (stat(path, &info) == -1) {
+ if (!(fp = fopen(path, "r"))) {
if (errno != ENOENT) {
- log_sys_debug("stat", path);
+ log_sys_debug("fopen", path);
goto out;
}
if (!dev_get_primary_dev(dt, dev, &primary))
@@ -975,25 +974,20 @@ static unsigned long _dev_topology_attribute(struct dev_types *dt,
if (!_snprintf_attr(path, sizeof(path), sysfs_dir, attribute, primary))
goto_out;
- if (stat(path, &info) == -1) {
+ if (!(fp = fopen(path, "r"))) {
if (errno != ENOENT)
- log_sys_debug("stat", path);
+ log_sys_debug("fopen", path);
goto out;
}
}
- if (!(fp = fopen(path, "r"))) {
- log_sys_debug("fopen", path);
- goto out;
- }
-
if (!fgets(buffer, sizeof(buffer), fp)) {
log_sys_debug("fgets", path);
goto out_close;
}
if (sscanf(buffer, "%lu", &value) != 1) {
- log_warn("sysfs file %s not in expected format: %s", path, buffer);
+ log_warn("WARNING: sysfs file %s not in expected format: %s", path, buffer);
goto out_close;
}
2 years, 7 months
main - dev-type: dev_is_pmem reuses topology read code
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e429e69b6593fa68872...
Commit: e429e69b6593fa688727fb632d7050f05cd27317
Parent: 2c597c73a837e9d259ee620f167b08ebf1b14a9e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 15:03:13 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
dev-type: dev_is_pmem reuses topology read code
---
lib/device/dev-type.c | 45 ++++++++++++---------------------------------
lib/device/dev-type.h | 2 +-
lib/metadata/metadata.c | 8 ++++----
3 files changed, 17 insertions(+), 38 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 8eacbf096..dca81d8d1 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -35,39 +35,6 @@
#include <libgen.h>
#include <ctype.h>
-/*
- * dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1
- */
-
-int dev_is_pmem(struct device *dev)
-{
- FILE *fp;
- char path[PATH_MAX];
- int is_pmem = 0;
-
- if (dm_snprintf(path, sizeof(path), "%sdev/block/%d:%d/queue/dax",
- dm_sysfs_dir(),
- (int) MAJOR(dev->dev),
- (int) MINOR(dev->dev)) < 0) {
- log_warn("Sysfs path for %s dax is too long.", dev_name(dev));
- return 0;
- }
-
- if (!(fp = fopen(path, "r")))
- return 0;
-
- if (fscanf(fp, "%d", &is_pmem) != 1)
- log_warn("Failed to parse DAX %s.", path);
-
- if (is_pmem)
- log_debug("%s is pmem", dev_name(dev));
-
- if (fclose(fp))
- log_sys_debug("fclose", path);
-
- return is_pmem ? 1 : 0;
-}
-
/*
* An nvme device has major number 259 (BLKEXT), minor number <minor>,
* and reading /sys/dev/block/259:<minor>/device/dev shows a character
@@ -1078,6 +1045,13 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
{
return (int) _dev_topology_attribute(dt, "queue/rotational", dev, 1UL);
}
+
+/* dev is pmem if /sys/dev/block/<major>:<minor>/queue/dax is 1 */
+int dev_is_pmem(struct dev_types *dt, struct device *dev)
+{
+ return (int) _dev_topology_attribute(dt, "queue/dax", dev, 0UL);
+}
+
#else
int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
@@ -1114,6 +1088,11 @@ int dev_is_rotational(struct dev_types *dt, struct device *dev)
{
return 1;
}
+
+int dev_is_pmem(struct dev_types *dt, struct device *dev)
+{
+ return 0;
+}
#endif
#ifdef UDEV_SYNC_SUPPORT
diff --git a/lib/device/dev-type.h b/lib/device/dev-type.h
index 8b94b7997..f96b67ca3 100644
--- a/lib/device/dev-type.h
+++ b/lib/device/dev-type.h
@@ -93,7 +93,7 @@ unsigned long dev_discard_granularity(struct dev_types *dt, struct device *dev);
int dev_is_rotational(struct dev_types *dt, struct device *dev);
-int dev_is_pmem(struct device *dev);
+int dev_is_pmem(struct dev_types *dt, struct device *dev);
int dev_is_nvme(struct dev_types *dt, struct device *dev);
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index d83cf21a6..692094ec8 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4436,11 +4436,11 @@ int lv_on_pmem(struct logical_volume *lv)
for (s = 0; s < seg->area_count; s++) {
pv = seg_pv(seg, s);
- if (dev_is_pmem(pv->dev)) {
- log_debug("LV %s dev %s is pmem.", lv->name, dev_name(pv->dev));
+ if (dev_is_pmem(lv->vg->cmd->dev_types, pv->dev)) {
+ log_debug("LV %s dev %s is pmem.", display_lvname(lv), dev_name(pv->dev));
pmem_devs++;
} else {
- log_debug("LV %s dev %s not pmem.", lv->name, dev_name(pv->dev));
+ log_debug("LV %s dev %s not pmem.", display_lvname(lv), dev_name(pv->dev));
other_devs++;
}
}
@@ -4452,7 +4452,7 @@ int lv_on_pmem(struct logical_volume *lv)
}
if (pmem_devs) {
- log_debug("LV %s on pmem", lv->name);
+ log_debug("LV %s on pmem", display_lvname(lv));
return 1;
}
2 years, 7 months
main - dev-cache: better code reuse for _add_alias
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c597c73a837e9d259e...
Commit: 2c597c73a837e9d259ee620f167b08ebf1b14a9e
Parent: be9b731f440243df8fb42f6f2a506bf27de5ac64
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 19:30:26 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
dev-cache: better code reuse for _add_alias
Move path copying into _add_alish together with hashing.
Remove duplicated code.
---
lib/device/dev-cache.c | 112 ++++++++++++++++---------------------------------
1 file changed, 35 insertions(+), 77 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index a93600965..517b9e6f8 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -321,20 +321,33 @@ static int _compare_paths(const char *path0, const char *path1)
return 1;
}
-static int _add_alias(struct device *dev, const char *path)
+enum add_hash {
+ NO_HASH,
+ HASH,
+ REHASH
+};
+
+static int _add_alias(struct device *dev, const char *path, enum add_hash hash)
{
struct dm_str_list *sl = _zalloc(sizeof(*sl));
struct dm_str_list *strl;
const char *oldpath;
int prefer_old = 1;
- if (!sl)
- return_0;
+ if (hash == REHASH)
+ dm_hash_remove(_cache.names, path);
/* Is name already there? */
- dm_list_iterate_items(strl, &dev->aliases) {
- if (!strcmp(strl->str, path))
- return 1;
+ dm_list_iterate_items(strl, &dev->aliases)
+ if (!strcmp(strl->str, path)) {
+ path = strl->str;
+ goto out;
+ }
+
+ if (!(path = dm_pool_strdup(_cache.mem, path)) ||
+ !(sl = _zalloc(sizeof(*sl)))) {
+ log_error("Failed to add allias to dev cache.");
+ return 0;
}
if (!strncmp(path, "/dev/nvme", 9)) {
@@ -353,6 +366,12 @@ static int _add_alias(struct device *dev, const char *path)
dm_list_add(&dev->aliases, &sl->list);
else
dm_list_add_h(&dev->aliases, &sl->list);
+out:
+ if ((hash != NO_HASH) &&
+ !dm_hash_insert(_cache.names, path, dev)) {
+ log_error("Couldn't add name to hash in dev cache.");
+ return 0;
+ }
return 1;
}
@@ -428,7 +447,6 @@ static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
static struct device _fake_dev = { .flags = DEV_USED_FOR_LV };
struct stat stat0;
char path[PATH_MAX];
- char *path_copy;
struct device *dev;
if (dm_snprintf(path, sizeof(path), "%s%s", _cache.dev_dir, devname) < 0) {
@@ -446,15 +464,9 @@ static struct device *_insert_sysfs_dev(dev_t devno, const char *devname)
if (!(dev = _dev_create(devno)))
return_NULL;
- if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
- log_error("_insert_sysfs_dev: %s: dm_pool_strdup failed", devname);
- return NULL;
- }
-
- if (!_add_alias(dev, path_copy)) {
- log_error("Couldn't add alias to dev cache.");
+ if (!_add_alias(dev, path, NO_HASH)) {
_free(dev);
- return NULL;
+ return_NULL;
}
if (!btree_insert(_cache.sysfs_only_devices, (uint32_t) devno, dev)) {
@@ -696,7 +708,6 @@ static int _insert_dev(const char *path, dev_t d)
struct device *dev;
struct device *dev_by_devt;
struct device *dev_by_path;
- char *path_copy;
dev_by_devt = (struct device *) btree_lookup(_cache.devices, (uint32_t) d);
dev_by_path = (struct device *) dm_hash_lookup(_cache.names, path);
@@ -730,20 +741,8 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
- if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
- log_error("Failed to duplicate path string.");
- return 0;
- }
-
- if (!_add_alias(dev, path_copy)) {
- log_error("Couldn't add alias to dev cache.");
- return 0;
- }
-
- if (!dm_hash_insert(_cache.names, path_copy, dev)) {
- log_error("Couldn't add name to hash in dev cache.");
- return 0;
- }
+ if (!_add_alias(dev, path, HASH))
+ return_0;
return 1;
}
@@ -755,20 +754,8 @@ static int _insert_dev(const char *path, dev_t d)
log_debug_devs("Found dev %d:%d %s - new alias.",
(int)MAJOR(d), (int)MINOR(d), path);
- if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
- log_error("Failed to duplicate path string.");
- return 0;
- }
-
- if (!_add_alias(dev, path_copy)) {
- log_error("Couldn't add alias to dev cache.");
- return 0;
- }
-
- if (!dm_hash_insert(_cache.names, path_copy, dev)) {
- log_error("Couldn't add name to hash in dev cache.");
- return 0;
- }
+ if (!_add_alias(dev, path, HASH))
+ return_0;
return 1;
}
@@ -794,25 +781,10 @@ static int _insert_dev(const char *path, dev_t d)
return 0;
}
- if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
- log_error("Failed to duplicate path string.");
- return 0;
- }
-
- if (!_add_alias(dev, path_copy)) {
- log_error("Couldn't add alias to dev cache.");
- return 0;
- }
-
- dm_hash_remove(_cache.names, path);
-
- if (!dm_hash_insert(_cache.names, path_copy, dev)) {
- log_error("Couldn't add name to hash in dev cache.");
- return 0;
- }
+ if (!_add_alias(dev, path, REHASH))
+ return_0;
return 1;
-
}
/*
@@ -824,22 +796,8 @@ static int _insert_dev(const char *path, dev_t d)
(int)MAJOR(d), (int)MINOR(d), path,
(int)MAJOR(dev_by_path->dev), (int)MINOR(dev_by_path->dev));
- if (!(path_copy = dm_pool_strdup(_cache.mem, path))) {
- log_error("Failed to duplicate path string.");
- return 0;
- }
-
- if (!_add_alias(dev, path_copy)) {
- log_error("Couldn't add alias to dev cache.");
- return 0;
- }
-
- dm_hash_remove(_cache.names, path);
-
- if (!dm_hash_insert(_cache.names, path_copy, dev)) {
- log_error("Couldn't add name to hash in dev cache.");
- return 0;
- }
+ if (!_add_alias(dev, path, REHASH))
+ return_0;
return 1;
}
2 years, 7 months
main - dev-cache: check for nvme name while adding alias
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=be9b731f440243df8fb...
Commit: be9b731f440243df8fb42f6f2a506bf27de5ac64
Parent: 9b173bb931426cd1d35beb5ec5151289112b2568
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 14:04:58 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
dev-cache: check for nvme name while adding alias
Instead of repeated list retest, compare name once during add of alias.
---
lib/device/dev-cache.c | 5 +++++
lib/device/dev-type.c | 14 +-------------
2 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c
index 8082efac4..a93600965 100644
--- a/lib/device/dev-cache.c
+++ b/lib/device/dev-cache.c
@@ -337,6 +337,11 @@ static int _add_alias(struct device *dev, const char *path)
return 1;
}
+ if (!strncmp(path, "/dev/nvme", 9)) {
+ log_debug("Found nvme device %s", dev_name(dev));
+ dev->flags |= DEV_IS_NVME;
+ }
+
sl->str = path;
if (!dm_list_empty(&dev->aliases)) {
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 379afa89c..8eacbf096 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -78,19 +78,7 @@ int dev_is_pmem(struct device *dev)
int dev_is_nvme(struct dev_types *dt, struct device *dev)
{
- struct dm_str_list *strl;
-
- if (dev->flags & DEV_IS_NVME)
- return 1;
-
- dm_list_iterate_items(strl, &dev->aliases) {
- if (!strncmp(strl->str, "/dev/nvme", 9)) {
- log_debug("Found nvme device %s", dev_name(dev));
- dev->flags |= DEV_IS_NVME;
- return 1;
- }
- }
- return 0;
+ return (dev->flags & DEV_IS_NVME) ? 1 : 0;
}
int dev_is_lv(struct device *dev)
2 years, 7 months
main - targets: use target_present_version
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9b173bb931426cd1d35...
Commit: 9b173bb931426cd1d35beb5ec5151289112b2568
Parent: 6373f3909252e312ca2b25d42a46a712099ae7fc
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 21:48:18 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
targets: use target_present_version
Skip duplicated dm version ioctl() on every startup.
---
lib/integrity/integrity.c | 5 ++---
lib/mirror/mirrored.c | 3 ++-
lib/raid/raid.c | 6 ++----
lib/snapshot/snapshot.c | 8 ++++----
lib/thin/thin.c | 6 ++----
lib/vdo/vdo.c | 2 +-
lib/writecache/writecache.c | 12 ++----------
7 files changed, 15 insertions(+), 27 deletions(-)
diff --git a/lib/integrity/integrity.c b/lib/integrity/integrity.c
index d5ad86b63..7423e04ae 100644
--- a/lib/integrity/integrity.c
+++ b/lib/integrity/integrity.c
@@ -240,9 +240,8 @@ static int _target_present(struct cmd_context *cmd,
if (!_integrity_checked) {
_integrity_checked = 1;
- _integrity_present = target_present(cmd, TARGET_NAME_INTEGRITY, 1);
-
- if (!target_version(TARGET_NAME_INTEGRITY, &maj, &min, &patchlevel))
+ if (!(_integrity_present = target_present_version(cmd, TARGET_NAME_INTEGRITY, 1,
+ &maj, &min, &patchlevel)))
return 0;
if (maj < 1 || min < 6) {
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index 75893a6f6..64b470a98 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -405,7 +405,8 @@ static int _mirrored_target_present(struct cmd_context *cmd,
if (!_mirrored_checked) {
_mirrored_checked = 1;
- if (!(_mirrored_present = target_present(cmd, TARGET_NAME_MIRROR, 1)))
+ if (!(_mirrored_present = target_present_version(cmd, TARGET_NAME_MIRROR, 1,
+ &maj, &min, &patchlevel)))
return 0;
/*
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 6344200f5..a0f00637a 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -551,10 +551,8 @@ static int _raid_target_present(struct cmd_context *cmd,
if (!_raid_checked) {
_raid_checked = 1;
- if (!(_raid_present = target_present(cmd, TARGET_NAME_RAID, 1)))
- return 0;
-
- if (!target_version("raid", &maj, &min, &patchlevel))
+ if (!(_raid_present = target_present_version(cmd, TARGET_NAME_RAID, 1,
+ &maj, &min, &patchlevel)))
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 3c30b3576..b832f890d 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -152,12 +152,12 @@ static int _snap_target_present(struct cmd_context *cmd,
if (!_snap_checked) {
_snap_checked = 1;
- if (!(_snap_present = target_present(cmd, TARGET_NAME_SNAPSHOT, 1) &&
- target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
+ if (!(_snap_present = (target_present_version(cmd, TARGET_NAME_SNAPSHOT, 1,
+ &maj, &min, &patchlevel) &&
+ target_present(cmd, TARGET_NAME_SNAPSHOT_ORIGIN, 0)))
return 0;
- if (target_version(TARGET_NAME_SNAPSHOT, &maj, &min, &patchlevel) &&
- (maj > 1 ||
+ if ((maj > 1 ||
(maj == 1 && (min >= 12 || (min == 10 && patchlevel >= 2)))))
_snap_attrs |= SNAPSHOT_FEATURE_FIXED_LEAK;
else
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index 51bc269ae..5f3015026 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -690,12 +690,10 @@ static int _thin_target_present(struct cmd_context *cmd,
if (!_checked) {
_checked = 1;
- if (!(_present = target_present(cmd, _thin_pool_module, 1)))
+ if (!(_present = target_present_version(cmd, _thin_pool_module, 1,
+ &maj, &min, &patchlevel)))
return 0;
- if (!target_version(_thin_pool_module, &maj, &min, &patchlevel))
- return_0;
-
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
if ((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min))
diff --git a/lib/vdo/vdo.c b/lib/vdo/vdo.c
index bb7c78449..f26874ce5 100644
--- a/lib/vdo/vdo.c
+++ b/lib/vdo/vdo.c
@@ -419,7 +419,7 @@ static int _vdo_target_present(struct cmd_context *cmd,
/* Try to load kmod VDO module */
if (!module_present(cmd, MODULE_NAME_VDO) ||
!target_version(TARGET_NAME_VDO, &maj, &min, &patchlevel))
- return_0;
+ return 0;
}
if (maj < 6 || (maj == 6 && min < 2)) {
diff --git a/lib/writecache/writecache.c b/lib/writecache/writecache.c
index 2cef9f26e..d114d698c 100644
--- a/lib/writecache/writecache.c
+++ b/lib/writecache/writecache.c
@@ -238,17 +238,9 @@ static int _target_present(struct cmd_context *cmd,
if (!_writecache_checked) {
_writecache_checked = 1;
- _writecache_present = target_present(cmd, TARGET_NAME_WRITECACHE, 1);
-
- if (!_writecache_present) {
- log_error("dm-writecache module not found in kernel.");
+ if (!(_writecache_present = target_present_version(cmd, TARGET_NAME_WRITECACHE, 1.
+ &maj, &min, &patchlevel)))
return 0;
- }
-
- if (!target_version(TARGET_NAME_WRITECACHE, &maj, &min, &patchlevel)) {
- log_error("dm-writecache module version not found.");
- return_0;
- }
if (maj < 1) {
log_error("dm-writecache module version older than minimum 1.0.0");
2 years, 7 months
main - tests: check event_activation can be disabled
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6373f3909252e312ca2...
Commit: 6373f3909252e312ca2b25d42a46a712099ae7fc
Parent: b86eb913c18ca67415521b8003c04adf41a5496c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Feb 8 22:27:59 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
tests: check event_activation can be disabled
---
test/shell/pvscan-autoactivate.sh | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/test/shell/pvscan-autoactivate.sh b/test/shell/pvscan-autoactivate.sh
index 9f7fc2ee7..153939d34 100644
--- a/test/shell/pvscan-autoactivate.sh
+++ b/test/shell/pvscan-autoactivate.sh
@@ -31,6 +31,10 @@ _clear_online_files() {
aux prepare_devs 8 16
+# Check 'pvscan' is ignored when event_activation is 0
+pvscan --cache -aay -v --config 'global/event_activation=0' 2>&1 | tee out
+grep "Ignoring pvscan" out
+
vgcreate $vg1 "$dev1" "$dev2"
lvcreate -n $lv1 -l 4 -a n $vg1
2 years, 7 months
main - tests: support for resized cached LVs
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b86eb913c18ca674155...
Commit: b86eb913c18ca67415521b8003c04adf41a5496c
Parent: 5ec24dfb0bb0c9e48d59d6fbb83262a7087964e1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 18:45:43 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:38 2021 +0100
tests: support for resized cached LVs
Support for cached LVs is now enabled.
---
test/shell/lvextend-thin-cache.sh | 19 +++++++++++++------
test/shell/lvextend-thin.sh | 18 +++++++++++++++++-
2 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/test/shell/lvextend-thin-cache.sh b/test/shell/lvextend-thin-cache.sh
index f7bbfd992..40c213b21 100644
--- a/test/shell/lvextend-thin-cache.sh
+++ b/test/shell/lvextend-thin-cache.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-# Copyright (C) 2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2017-2020 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
@@ -22,15 +22,22 @@ export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
aux have_thin 1 0 0 || skip
aux have_cache 1 3 0 || skip
-aux prepare_vg 2
+aux prepare_vg 2 20000
-lvcreate -l2 -T $vg/pool
+lvcreate -l1 -T $vg/pool
# Caching of thin-pool's dataLV
lvcreate -H -L10 $vg/pool
-# Resize is unsupported
-not lvextend -l+2 $vg/pool 2>&1 | tee out
+lvextend -l+2 $vg/pool
-grep "Unable to resize" out
+check lv_first_seg_field $vg/pool seg_size_pe "3"
+
+lvextend -L10G $vg/pool
+
+# Check data are resized and its metadata are matching data size
+check lv_field $vg/pool size "10.00g"
+check lv_field $vg/pool_tdata size "10.00g"
+check lv_field $vg/pool_tdata_corig size "10.00g"
+check lv_field $vg/pool_tmeta size "10.00m"
vgremove -ff $vg
diff --git a/test/shell/lvextend-thin.sh b/test/shell/lvextend-thin.sh
index 3e39ea3eb..d1efd4798 100644
--- a/test/shell/lvextend-thin.sh
+++ b/test/shell/lvextend-thin.sh
@@ -22,6 +22,22 @@ aux have_thin 1 0 0 || skip
aux prepare_vg 3
lvcreate -i2 -l2 -T $vg/pool2
lvextend -l+2 $vg/pool2 "$dev2" "$dev3"
-should lvextend -l+100%FREE $vg/pool2
+lvextend -l+100%FREE $vg/pool2
+
+lvremove -f $vg
+
+lvcreate -L1 -n pool $vg
+# Does work only with thin-pools
+not lvextend --poolmetadatasize +1 $vg/pool
+lvconvert -y --thinpool $vg/pool --poolmetadatasize 2
+
+# _tdata cannot be used with --poolmetadata
+not lvextend --poolmetadatasize +1 $vg/pool_tdata
+lvextend --poolmetadatasize +1 $vg/pool_tmeta
+lvextend --poolmetadatasize +1 --size +1 $vg/pool
+check lv_field $vg/pool_tmeta size "4.00m"
+check lv_field $vg/lvol0_pmspare size "4.00m"
+
+not lvresize --poolmetadatasize -1 $vg/pool
vgremove -ff $vg
2 years, 7 months
main - lv_resize: support resizing of cached volumes
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5ec24dfb0bb0c9e48d5...
Commit: 5ec24dfb0bb0c9e48d59d6fbb83262a7087964e1
Parent: 39dec265084c05aaa086288863710148d28d1ccb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Feb 7 20:12:00 2021 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Feb 8 23:43:10 2021 +0100
lv_resize: support resizing of cached volumes
Automatically figure out resizable layer in the LV stack and
resize it online.
Split check for reshaped raids and postpone removal of
unused space after finished reshaping after metadata archiving.
Drop warning about unsupported automatic resize of monitored thin-pool.
Currently there is not yet support for resize of writecache.
---
lib/metadata/cache_manip.c | 5 --
lib/metadata/lv_manip.c | 182 +++++++++++++++++++++++++++------------------
2 files changed, 110 insertions(+), 77 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 90ebd9404..f29442358 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -169,11 +169,6 @@ void cache_check_for_warns(const struct lv_segment *seg)
first_seg(seg->pool_lv)->cache_mode == CACHE_MODE_WRITEBACK)
log_warn("WARNING: Data redundancy could be lost with writeback "
"caching of raid logical volume!");
-
- if (lv_is_thin_pool_data(seg->lv)) {
- log_warn("WARNING: thin pool data will not be automatically extended when cached.");
- log_warn("WARNING: manual splitcache is required before extending thin pool data.");
- }
}
/*
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 346a50ca5..833d7f8c5 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1458,6 +1458,48 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
return 1;
}
+/* Find the bottommost resizable LV in the stack.
+ * It does not matter which LV is used in this stack for cmdline tool. */
+static struct logical_volume *_get_resizable_layer_lv(struct logical_volume *lv)
+{
+ while (lv_is_cache(lv) || /* _corig */
+ lv_is_integrity(lv) ||
+ lv_is_thin_pool(lv) || /* _tdata */
+ lv_is_vdo_pool(lv)) /* _vdata */
+ lv = seg_lv(first_seg(lv), 0); /* component-level down */
+
+ return lv;
+}
+
+/* Check if LV is component of resizable LV.
+ * When resize changes size of LV this also changes the size whole stack upward.
+ * Support syntax suggar - so user can pick any LV in stack for resize. */
+static int _is_layered_lv(struct logical_volume *lv)
+{
+ return (lv_is_cache_origin(lv) ||
+ lv_is_integrity_origin(lv) ||
+ lv_is_thin_pool_data(lv) ||
+ lv_is_vdo_pool_data(lv));
+}
+
+/* Find the topmost LV in the stack - usually such LV is visible. */
+static struct logical_volume *_get_top_layer_lv(struct logical_volume *lv)
+{
+ struct lv_segment *seg;
+
+ while (_is_layered_lv(lv)) {
+ if (!(seg = get_only_segment_using_this_lv(lv))) {
+ log_error(INTERNAL_ERROR "No single component user of logical volume %s.",
+ display_lvname(lv));
+ return NULL;
+ }
+ lv = seg->lv; /* component-level up */
+ }
+
+ return lv;
+}
+
+
/* Handles also stacking */
static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
{
@@ -1466,17 +1508,15 @@ static int _setup_lv_size(struct logical_volume *lv, uint32_t extents)
lv->le_count = extents;
lv->size = (uint64_t) extents * lv->vg->extent_size;
- if (lv->size &&
- (lv_is_thin_pool_data(lv) ||
- lv_is_vdo_pool_data(lv))) {
+ while (lv->size && _is_layered_lv(lv)) {
if (!(seg = get_only_segment_using_this_lv(lv)))
return_0;
- /* Update pool segment from the layered LV */
seg->lv->le_count =
seg->len =
seg->area_len = lv->le_count;
seg->lv->size = lv->size;
+ lv = seg->lv;
}
return 1;
@@ -5160,7 +5200,7 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (seg && (seg_is_raid4(seg) || seg_is_any_raid5(seg)) && seg->area_count < 3) {
+ if ((seg_is_raid4(seg) || seg_is_any_raid5(seg)) && seg->area_count < 3) {
log_error("Cannot resize %s LV %s. Convert to more stripes first.",
lvseg_name(seg), display_lvname(lv));
return 0;
@@ -5179,20 +5219,6 @@ static int _lvresize_check(struct logical_volume *lv,
}
}
- if (lp->use_policies &&
- !lv_is_cow(lv) &&
- !lv_is_thin_pool(lv) &&
- !lv_is_vdo_pool(lv)) {
- log_error("Policy-based resize is supported only for snapshot, thin pool and vdo pool volumes.");
- return 0;
- }
-
- if (lv_is_cache_type(lv) ||
- (lv_is_thin_pool(lv) && lv_is_cache_type(seg_lv(first_seg(lv), 0)))) {
- log_error("Unable to resize logical volumes of cache type.");
- return 0;
- }
-
if (!lv_is_visible(lv) &&
!lv_is_thin_pool_metadata(lv) &&
!lv_is_vdo_pool_data(lv) &&
@@ -5212,11 +5238,6 @@ static int _lvresize_check(struct logical_volume *lv,
return 0;
}
- if (!lv_is_thin_pool(lv) && lp->poolmetadata_size) {
- log_error("--poolmetadatasize can be used only with thin pools.");
- return 0;
- }
-
if (lp->stripe_size) {
if (!(vg->fid->fmt->features & FMT_SEGMENTS)) {
log_print_unless_silent("Varied stripesize not supported. Ignoring.");
@@ -5665,8 +5686,8 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
return 0;
}
- if (lp->extents == existing_logical_extents) {
- if (!lp->resizefs) {
+ if ((lp->extents == existing_logical_extents) && !lp->use_policies) {
+ if (!lp->resizefs && !lp->poolmetadata_size) {
log_error("New size (%d extents) matches existing size (%d extents).",
lp->extents, existing_logical_extents);
return 0;
@@ -5726,7 +5747,7 @@ static int _lvresize_adjust_extents(struct logical_volume *lv,
}
lp->resize = LV_EXTEND;
} else if ((lp->extents == existing_logical_extents) && !lp->use_policies) {
- if (!lp->resizefs) {
+ if (!lp->resizefs && !lp->poolmetadata_size) {
log_error("New size (%d extents) matches existing size "
"(%d extents)", lp->extents, existing_logical_extents);
return 0;
@@ -5800,6 +5821,12 @@ static int _lvresize_check_type(const struct logical_volume *lv,
}
}
+ /* Prevent resizing on out-of-sync reshapable raid */
+ if (first_seg(lv)->reshape_len && !lv_raid_in_sync(lv)) {
+ log_error("Can't resize reshaping LV %s.", display_lvname(lv));
+ return 0;
+ }
+
return 1;
}
@@ -5848,28 +5875,26 @@ static int _lvresize_volume(struct logical_volume *lv,
return 1;
}
-static int _lvresize_prepare(struct logical_volume **lv,
+static int _lvresize_prepare(struct logical_volume *lv,
struct lvresize_params *lp,
struct dm_list *pvh)
{
- struct volume_group *vg = (*lv)->vg;
-
- if (lv_is_thin_pool(*lv) || lv_is_vdo_pool(*lv))
- *lv = seg_lv(first_seg(*lv), 0); /* switch to data LV */
-
- if (lv_is_integrity(*lv))
- *lv = seg_lv(first_seg(*lv), 0);
-
/* Resolve extents from size */
- if (lp->size && !_lvresize_adjust_size(vg, lp->size, lp->sign, &lp->extents))
+ if (lp->size && !_lvresize_adjust_size(lv->vg, lp->size, lp->sign, &lp->extents))
return_0;
- else if (lp->extents && !_lvresize_extents_from_percent(*lv, lp, pvh))
+ else if (lp->extents && !_lvresize_extents_from_percent(lv, lp, pvh))
return_0;
- if (!_lvresize_adjust_extents(*lv, lp, pvh))
+ /* Ensure stripe boundary extents! */
+ if (!lp->percent && lv_is_raid(lv))
+ lp->extents =_round_to_stripe_boundary(lv->vg, lp->extents,
+ seg_is_raid1(first_seg(lv)) ? 0 : _raid_stripes_count(first_seg(lv)),
+ lp->resize == LV_REDUCE ? 0 : 1);
+
+ if (!_lvresize_adjust_extents(lv, lp, pvh))
return_0;
- if (!_lvresize_check_type(*lv, lp))
+ if (!_lvresize_check_type(lv, lp))
return_0;
return 1;
@@ -5900,6 +5925,7 @@ int lv_resize(struct logical_volume *lv,
struct cmd_context *cmd = vg->cmd;
struct logical_volume *lock_lv = (struct logical_volume*) lv_lock_holder(lv);
struct logical_volume *aux_lv = NULL; /* Note: aux_lv never resizes fs */
+ struct logical_volume *resizable_layer_lv;
struct lvresize_params aux_lp;
struct lv_segment *seg = first_seg(lv);
int activated = 0;
@@ -5908,21 +5934,14 @@ int lv_resize(struct logical_volume *lv,
struct device *dev;
char name[PATH_MAX];
- if (!_lvresize_check(lv, lp))
- return_0;
-
- if (seg->reshape_len) {
- /* Prevent resizing on out-of-sync reshapable raid */
- if (!lv_raid_in_sync(lv)) {
- log_error("Can't resize reshaping LV %s.", display_lvname(lv));
+ if (lp->use_policies) {
+ if (!lv_is_cow(lv) &&
+ !lv_is_thin_pool(lv) &&
+ !lv_is_vdo_pool(lv)) {
+ log_error("Policy-based resize is supported only for snapshot, thin pool and vdo pool volumes.");
return 0;
}
- /* Remove any striped raid reshape space for LV resizing */
- if (!lv_raid_free_reshape_space(lv))
- return_0;
- }
- if (lp->use_policies) {
lp->extents = 0;
lp->sign = SIGN_PLUS;
lp->percent = PERCENT_LV;
@@ -5935,57 +5954,68 @@ int lv_resize(struct logical_volume *lv,
if (!aux_lp.extents)
return 1; /* Nothing to do */
/* Resize thin-pool metadata as mainlv */
- lv = first_seg(lv)->metadata_lv; /* metadata LV */
+ lv = seg->metadata_lv; /* metadata LV */
lp->extents = aux_lp.extents;
} else if (aux_lp.extents) {
/* Also resize thin-pool metadata */
- aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
}
} else if (lp->poolmetadata_size) {
+ /* Validate --poolmetadata_size supported volumes here */
+ if (!lv_is_thin_pool(lv) && !lv_is_thin_pool_metadata(lv)) {
+ log_error("--poolmetadatasize can be used only with thin pools.");
+ return 0;
+ }
if (!lp->extents && !lp->size) {
- /* When only --poolmetadatasize given and not --size
+ /* When only --poolmetadatasize given and any size option
* switch directly to resize metadata LV */
- lv = first_seg(lv)->metadata_lv;
+ if (lv_is_thin_pool(lv))
+ lv = seg->metadata_lv;
lp->size = lp->poolmetadata_size;
lp->sign = lp->poolmetadata_sign;
- } else {
+ lp->poolmetadata_size = 0;
+ } else if (lv_is_thin_pool(lv)) {
aux_lp = *lp;
- aux_lv = _lvresize_setup_aux(first_seg(lv)->metadata_lv, &aux_lp);
+ aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
aux_lp.size = lp->poolmetadata_size;
aux_lp.sign = lp->poolmetadata_sign;
+ } else {
+ log_error("--poolmetadatasize for thin-pool metadata cannot be used with size.");
+ return 0;
}
}
- /* Ensure stripe boundary extents! */
- if (!lp->percent && lv_is_raid(lv))
- lp->extents =_round_to_stripe_boundary(lv->vg, lp->extents,
- seg_is_raid1(seg) ? 0 : _raid_stripes_count(seg),
- lp->resize == LV_REDUCE ? 0 : 1);
- if (aux_lv && !_lvresize_prepare(&aux_lv, &aux_lp, pvh))
+ resizable_layer_lv = _get_resizable_layer_lv(lv);
+ if (!(lv = _get_top_layer_lv(lv)))
+ return_0;
+
+ if (!_lvresize_check(lv, lp))
return_0;
/* Always should have lp->size or lp->extents */
- if (!_lvresize_prepare(&lv, lp, pvh))
+ if (!_lvresize_prepare(resizable_layer_lv, lp, pvh))
return_0;
- if (lp->resize != LV_REDUCE && !aux_lv && !lp->poolmetadata_size &&
- &lv->vg->pvs == pvh && lv_is_thin_pool_data(lv)) {
+ if ((lp->resize != LV_REDUCE) && !aux_lv && !lp->poolmetadata_size &&
+ (&vg->pvs == pvh) && lv_is_thin_pool(lv)) {
/* When thin-pool data part is extended, automatically extend also metadata part
* to have the metadata chunks for adressing all data blocks
* Do this only when PV list is not defined and --poolmetadatasize is unspecified */
aux_lp = *lp;
- seg = get_only_segment_using_this_lv(lv);
- aux_lp.size = estimate_thin_pool_metadata_size(lp->extents, lv->vg->extent_size, seg->chunk_size);
+ seg = first_seg(lv);
+ aux_lp.size = estimate_thin_pool_metadata_size(lp->extents, vg->extent_size, seg->chunk_size);
if (aux_lp.size > seg->metadata_lv->size) {
log_verbose("Also going to resize thin-pool metadata to match bigger data.");
aux_lv = _lvresize_setup_aux(seg->metadata_lv, &aux_lp);
aux_lp.sign = SIGN_NONE;
- if (!_lvresize_prepare(&aux_lv, &aux_lp, pvh))
- return_0;
} else
aux_lp.size = 0;
}
+ if (aux_lv && (aux_lv = _get_resizable_layer_lv(aux_lv)) &&
+ !_lvresize_prepare(aux_lv, &aux_lp, pvh))
+ return_0;
+
if (((lp->resize == LV_REDUCE) ||
(aux_lv && aux_lp.resize == LV_REDUCE)) &&
(pvh != &vg->pvs))
@@ -6090,6 +6120,14 @@ int lv_resize(struct logical_volume *lv,
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))
+ return_0;
+ if (first_seg(resizable_layer_lv)->reshape_len)
+ if (!lv_raid_free_reshape_space(resizable_layer_lv))
+ return_0;
+
if (aux_lv) {
if (!_lvresize_volume(aux_lv, &aux_lp, pvh))
goto_bad;
@@ -6099,7 +6137,7 @@ int lv_resize(struct logical_volume *lv,
goto_bad;
}
- if (!_lvresize_volume(lv, lp, pvh))
+ if (!_lvresize_volume(resizable_layer_lv, lp, pvh))
goto_bad;
/* store vg on disk(s) */
2 years, 7 months