master - lvmlockd: fixes for test mode
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1752f5c31e8fc1...
Commit: 1752f5c31e8fc1801cbc694939a16f0eb6695bcd
Parent: e710bac03d2625a50131ac325ad90f0d4f6f3d51
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 14 15:57:09 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jan 14 16:01:29 2016 -0600
lvmlockd: fixes for test mode
Get the test mode working (lvmlockd running with no
lock manager).
---
daemons/lvmlockd/lvmlockd-core.c | 2 +-
daemons/lvmlockd/lvmlockd-dlm.c | 15 ++++++++-
daemons/lvmlockd/lvmlockd-sanlock.c | 63 ++++++++++++++++++++++++++++-------
3 files changed, 66 insertions(+), 14 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index c4def0b..093021d 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -6042,7 +6042,7 @@ int main(int argc, char *argv[])
else if (lm == LD_LM_SANLOCK && lm_support_sanlock())
gl_use_sanlock = 1;
else {
- fprintf(stderr, "invalid gl-type option");
+ fprintf(stderr, "invalid gl-type option\n");
exit(EXIT_FAILURE);
}
break;
diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c
index 2cf2c20..280cf2b 100644
--- a/daemons/lvmlockd/lvmlockd-dlm.c
+++ b/daemons/lvmlockd/lvmlockd-dlm.c
@@ -163,6 +163,9 @@ int lm_prepare_lockspace_dlm(struct lockspace *ls)
struct lm_dlm *lmd;
int rv;
+ if (daemon_test)
+ goto skip_args;
+
memset(sys_clustername, 0, sizeof(sys_clustername));
memset(arg_clustername, 0, sizeof(arg_clustername));
@@ -470,7 +473,11 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
log_debug("S %s R %s lock_dlm", ls->name, r->name);
if (daemon_test) {
- memset(vb_out, 0, sizeof(struct val_blk));
+ if (rdd->vb) {
+ vb_out->version = le16_to_cpu(rdd->vb->version);
+ vb_out->flags = le16_to_cpu(rdd->vb->flags);
+ vb_out->r_version = le32_to_cpu(rdd->vb->r_version);
+ }
return 0;
}
@@ -686,6 +693,9 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
DIR *ls_dir;
int count = 0;
+ if (daemon_test)
+ return 0;
+
memset(ls_nodes_path, 0, sizeof(ls_nodes_path));
snprintf(ls_nodes_path, PATH_MAX-1, "%s/%s/nodes",
DLM_LOCKSPACES_PATH, ls->name);
@@ -754,6 +764,9 @@ int lm_is_running_dlm(void)
char sys_clustername[MAX_ARGS+1];
int rv;
+ if (daemon_test)
+ return gl_use_dlm;
+
memset(sys_clustername, 0, sizeof(sys_clustername));
rv = read_cluster_name(sys_clustername);
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index 3f1f3e9..6f287b9 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -206,6 +206,8 @@ int lm_data_size_sanlock(void)
#define VG_LOCK_BEGIN UINT64_C(66)
#define LV_LOCK_BEGIN UINT64_C(67)
+static unsigned int daemon_test_lv_count;
+
static int lock_lv_name_from_args(char *vg_args, char *lock_lv_name)
{
return last_string_from_args(vg_args, lock_lv_name);
@@ -338,6 +340,7 @@ int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_ar
if (daemon_test) {
if (!gl_lsname_sanlock[0])
strncpy(gl_lsname_sanlock, ls_name, MAX_NAME);
+ snprintf(vg_args, MAX_ARGS, "%s:%s", lock_args_version, lock_lv_name);
return 0;
}
@@ -489,6 +492,15 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name,
snprintf(lock_args_version, MAX_ARGS, "%u.%u.%u",
LV_LOCK_ARGS_MAJOR, LV_LOCK_ARGS_MINOR, LV_LOCK_ARGS_PATCH);
+ if (daemon_test) {
+ align_size = 1048576;
+ snprintf(lv_args, MAX_ARGS, "%s:%llu",
+ lock_args_version,
+ (unsigned long long)((align_size * LV_LOCK_BEGIN) + (align_size * daemon_test_lv_count)));
+ daemon_test_lv_count++;
+ return 0;
+ }
+
strncpy(rd.rs.lockspace_name, ls_name, SANLK_NAME_LEN);
rd.rs.num_disks = 1;
snprintf(rd.rs.disks[0].path, SANLK_PATH_LEN-1, "/dev/mapper/%s-%s", vg_name, lock_lv_name);
@@ -505,12 +517,6 @@ int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name,
offset = align_size * LV_LOCK_BEGIN;
rd.rs.disks[0].offset = offset;
- if (daemon_test) {
- snprintf(lv_args, MAX_ARGS, "%s:%llu",
- lock_args_version, (unsigned long long)1111);
- return 0;
- }
-
while (1) {
rd.rs.disks[0].offset = offset;
@@ -759,6 +765,9 @@ int lm_ex_disable_gl_sanlock(struct lockspace *ls)
struct sanlk_resource **rs_args;
int rv;
+ if (daemon_test)
+ return 0;
+
rs_args = malloc(2 * sizeof(struct sanlk_resource *));
if (!rs_args)
return -ENOMEM;
@@ -828,6 +837,9 @@ int lm_able_gl_sanlock(struct lockspace *ls, int enable)
else
gl_name = R_NAME_GL_DISABLED;
+ if (daemon_test)
+ goto out;
+
memset(&rd, 0, sizeof(rd));
strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
@@ -843,7 +855,7 @@ int lm_able_gl_sanlock(struct lockspace *ls, int enable)
ls->name, enable, rv, rd.rs.disks[0].path);
return rv;
}
-
+out:
log_debug("S %s able_gl %s", ls->name, gl_name);
ls->sanlock_gl_enabled = enable;
@@ -864,6 +876,9 @@ static int gl_is_enabled(struct lockspace *ls, struct lm_sanlock *lms)
uint64_t offset;
int rv;
+ if (daemon_test)
+ return 1;
+
memset(&rd, 0, sizeof(rd));
strncpy(rd.rs.lockspace_name, ls->name, SANLK_NAME_LEN);
@@ -922,8 +937,10 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset)
uint64_t offset;
int rv;
- if (daemon_test)
+ if (daemon_test) {
+ *free_offset = (1048576 * LV_LOCK_BEGIN) + (1048576 * (daemon_test_lv_count + 1));
return 0;
+ }
memset(&rd, 0, sizeof(rd));
@@ -1172,6 +1189,11 @@ int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt)
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
int rv;
+ if (daemon_test) {
+ sleep(2);
+ goto out;
+ }
+
rv = sanlock_add_lockspace_timeout(&lms->ss, 0, sanlock_io_timeout);
if (rv == -EEXIST && adopt) {
/* We could alternatively just skip the sanlock call for adopt. */
@@ -1240,10 +1262,10 @@ int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
ls->name, rv, lms->ss.host_id_disk.path);
}
}
-out:
+
if (close(lms->sock))
log_error("failed to close sanlock daemon socket connection");
-
+out:
free(lms);
ls->lm_data = NULL;
@@ -1380,7 +1402,11 @@ int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
(unsigned long long)rs->disks[0].offset);
if (daemon_test) {
- memset(vb_out, 0, sizeof(struct val_blk));
+ if (rds->vb) {
+ vb_out->version = le16_to_cpu(rds->vb->version);
+ vb_out->flags = le16_to_cpu(rds->vb->flags);
+ vb_out->r_version = le32_to_cpu(rds->vb->r_version);
+ }
return 0;
}
@@ -1665,8 +1691,15 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
log_debug("S %s R %s unlock_san r_version %u flags %x",
ls->name, r->name, r_version, lmu_flags);
- if (daemon_test)
+ if (daemon_test) {
+ if (rds->vb && r_version && (r->mode == LD_LK_EX)) {
+ if (!rds->vb->version)
+ rds->vb->version = cpu_to_le16(VAL_BLK_VERSION);
+ if (r_version)
+ rds->vb->r_version = cpu_to_le32(r_version);
+ }
return 0;
+ }
if (rds->vb && r_version && (r->mode == LD_LK_EX)) {
if (!rds->vb->version) {
@@ -1716,6 +1749,9 @@ int lm_hosts_sanlock(struct lockspace *ls, int notify)
int found_others = 0;
int i, rv;
+ if (daemon_test)
+ return 0;
+
rv = sanlock_get_hosts(ls->name, 0, &hss, &hss_count, 0);
if (rv < 0) {
log_error("S %s hosts_san get_hosts error %d", ls->name, rv);
@@ -1815,6 +1851,9 @@ int lm_is_running_sanlock(void)
uint32_t daemon_proto;
int rv;
+ if (daemon_test)
+ return gl_use_sanlock;
+
rv = sanlock_version(0, &daemon_version, &daemon_proto);
if (rv < 0)
return 0;
8 years, 3 months
master - Revert "lvmcache: skip drop when vg_write lock is not held"
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e710bac03d2625...
Commit: e710bac03d2625a50131ac325ad90f0d4f6f3d51
Parent: b82d5ee0926acee37356f5a322edbb4694081699
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 14 13:26:15 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jan 14 13:34:36 2016 -0600
Revert "lvmcache: skip drop when vg_write lock is not held"
This reverts e28e22b9e1e4f7243608aa24ddf43ec63afd1751
The problem that that commit was fixing (pytest failure)
no longer appears with the current code, so the commit is
not needed.
That commit is a problem for pvchange, because it prevents
lvmcache from retaining VG metadata even while the global
lock is held. pvchange holds the global lock to ensure
that VG metadata is kept in lvmcache throughout processing.
If the cache is not kept, a PV with zero MDAs will appear
first in its actual VG and then appear again in the orphan VG.
It wrongly appears a second time in the orphan VG only if
the actual VG is dropped from lvmcache.
---
lib/cache/lvmcache.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index 998ea6f..1363e93 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -332,7 +332,7 @@ void lvmcache_commit_metadata(const char *vgname)
void lvmcache_drop_metadata(const char *vgname, int drop_precommitted)
{
- if (lvmcache_vgname_is_locked(VG_GLOBAL) && !vg_write_lock_held())
+ if (lvmcache_vgname_is_locked(VG_GLOBAL))
return;
/* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */
8 years, 3 months
master - report: add kernel_discards report field to display thin pool discard used in kernel
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b82d5ee0926ace...
Commit: b82d5ee0926acee37356f5a322edbb4694081699
Parent: 6d09c8c2c45ea1dea243134b8badc841a87cc979
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jan 14 16:54:12 2016 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jan 14 16:54:12 2016 +0100
report: add kernel_discards report field to display thin pool discard used in kernel
Thin pool discard mode set in metadata can be different from the one
actually used if any device underneath does not support that mode. Add
kernel_discard report field to make it possible to see this difference.
---
WHATS_NEW | 1 +
lib/metadata/lv.c | 39 +++++++++++++++++++++++++++++++++++++++
lib/metadata/lv.h | 2 ++
lib/report/columns.h | 1 +
lib/report/properties.c | 2 ++
lib/report/report.c | 17 +++++++++++++++++
lib/report/values.h | 1 +
test/shell/discards-thin.sh | 27 +++++++++++++++++++++++++++
8 files changed, 90 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index ae70f5a..b64f725 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.140 -
===================================
+ Add kernel_discards report field to display thin pool discard used in kernel.
Correct checking of target presence when driver access is disabled.
Eval poolmetadatasize arg earlier in lvresize.
Fix vgcfgrestore to respect allocatable attribute of PVs.
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 6575cc9..49c195f 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -162,6 +162,45 @@ char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
return dm_pool_strdup(mem, get_pool_discards_name(seg->discards));
}
+char *lvseg_kernel_discards_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_with_info_and_seg_status *lvdm)
+{
+ const char *s = "";
+ char *ret;
+
+ if (lvdm->seg_status.type == SEG_STATUS_THIN_POOL)
+ s = get_pool_discards_name(lvdm->seg_status.thin_pool->discards);
+
+ if (!(ret = dm_pool_strdup(mem, s))) {
+ log_error("lvseg_kernel_discards_dup_with_info_and_seg_status: dm_pool_strdup failed");
+ return NULL;
+ }
+
+ return ret;
+}
+
+char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
+{
+ char *ret = NULL;
+ struct lv_with_info_and_seg_status status = {
+ .seg_status.type = SEG_STATUS_NONE,
+ .seg_status.seg = seg
+ };
+
+ if (!lv_is_thin_pool(seg->lv))
+ return NULL;
+
+ if (!(status.seg_status.mem = dm_pool_create("reporter_pool", 1024)))
+ return_NULL;
+
+ if (!(status.info_ok = lv_info_with_seg_status(seg->lv->vg->cmd, seg->lv, seg, 1, &status, 0, 0)))
+ goto_bad;
+
+ ret = lvseg_kernel_discards_dup_with_info_and_seg_status(mem, &status);
+bad:
+ dm_pool_destroy(status.seg_status.mem);
+ return ret;
+}
+
char *lvseg_cachemode_dup(struct dm_pool *mem, const struct lv_segment *seg)
{
const char *name = get_cache_mode_name(seg);
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index bbd4564..18c662b 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -95,6 +95,7 @@ char *lvseg_seg_metadata_le_ranges(struct dm_pool *mem, const struct lv_segment
int lv_kernel_major(const struct logical_volume *lv);
int lv_kernel_minor(const struct logical_volume *lv);
uint32_t lv_kernel_read_ahead(const struct logical_volume *lv);
+char *lvseg_kernel_discards_dup(struct dm_pool *mem, const struct lv_segment *seg);
/* LV modification functions */
int lv_set_creation(struct logical_volume *lv,
@@ -137,4 +138,5 @@ char *lv_host_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_profile_dup(struct dm_pool *mem, const struct logical_volume *lv);
char *lv_lock_args_dup(struct dm_pool *mem, const struct logical_volume *lv);
+char *lvseg_kernel_discards_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_with_info_and_seg_status *lvdm);
#endif /* _LVM_LV_H */
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 41a03f4..e097fec 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -113,6 +113,7 @@ FIELD(LVSSTATUS, lv, NUM, "CacheReadMisses", lvid, 16, cache_read_misses, cache_
FIELD(LVSSTATUS, lv, NUM, "CacheWriteHits", lvid, 16, cache_write_hits, cache_write_hits, "Cache write hits.", 0)
FIELD(LVSSTATUS, lv, NUM, "CacheWriteMisses", lvid, 16, cache_write_misses, cache_write_misses, "Cache write misses.", 0)
FIELD(LVSSTATUS, lv, STR, "Health", lvid, 15, lvhealthstatus, lv_health_status, "LV health status.", 0)
+FIELD(LVSSTATUS, lv, STR, "KDiscards", lvid, 8, kdiscards, kernel_discards, "For thin pools, how discards are handled in kernel.", 0)
FIELD(LABEL, label, STR, "Fmt", type, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 7dafbe5..705a9b9 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -450,6 +450,8 @@ GET_LVSEG_NUM_PROPERTY_FN(thin_id, lvseg->device_id)
#define _thin_id_set prop_not_implemented_set
GET_LVSEG_STR_PROPERTY_FN(discards, lvseg_discards_dup(lvseg->lv->vg->vgmem, lvseg))
#define _discards_set prop_not_implemented_set
+GET_LVSEG_STR_PROPERTY_FN(kernel_discards, lvseg_kernel_discards_dup(lvseg->lv->vg->vgmem, lvseg))
+#define _kernel_discards_set prop_not_implemented_set
GET_LVSEG_STR_PROPERTY_FN(cachemode, lvseg_cachemode_dup(lvseg->lv->vg->vgmem, lvseg))
#define _cachemode_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(seg_start, (SECTOR_SIZE * lvseg_start(lvseg)))
diff --git a/lib/report/report.c b/lib/report/report.c
index 40fcdd8..53ff753 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2221,6 +2221,23 @@ static int _discards_disp(struct dm_report *rh, struct dm_pool *mem,
return _field_set_value(field, "", NULL);
}
+static int _kdiscards_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data;
+ const char *discards_str;
+
+ if (!(discards_str = lvseg_kernel_discards_dup_with_info_and_seg_status(mem, lvdm)))
+ return_0;
+
+ if (*discards_str)
+ return _field_set_value(field, discards_str, NULL);
+
+ return _field_set_value(field, GET_FIRST_RESERVED_NAME(seg_kernel_discards_undef),
+ GET_FIELD_RESERVED_VALUE(seg_kernel_discards_undef));
+}
+
static int _cachemode_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/lib/report/values.h b/lib/report/values.h
index 728760c..600f304 100644
--- a/lib/report/values.h
+++ b/lib/report/values.h
@@ -93,6 +93,7 @@ FIELD_RESERVED_VALUE(NAMED | RANGE | FUZZY | DYNAMIC, lv_time, lv_time_fuzzy, ""
FIELD_RESERVED_VALUE(NOFLAG, cache_policy, cache_policy_undef, "", "", "", "undefined")
FIELD_RESERVED_VALUE(NOFLAG, seg_monitor, seg_monitor_undef, "", "", "", "undefined")
FIELD_RESERVED_VALUE(NOFLAG, lv_health_status, health_undef, "", "", "", "undefined")
+FIELD_RESERVED_VALUE(NOFLAG, kernel_discards, seg_kernel_discards_undef, "", "", "", "undefined")
/* TODO the following 2 need STR_LIST support for reserved values
FIELD_RESERVED_VALUE(cache_settings, cache_settings_default, "", "default", "default")
FIELD_RESERVED_VALUE(cache_settings, cache_settings_undef, "", "undefined", "undefined") */
diff --git a/test/shell/discards-thin.sh b/test/shell/discards-thin.sh
index 95a5880..92146e3 100644
--- a/test/shell/discards-thin.sh
+++ b/test/shell/discards-thin.sh
@@ -26,15 +26,20 @@ aux have_thin 1 1 0 || skip
aux prepare_pvs 2 64
+aux extend_filter_LVMTEST
+
vgcreate $vg -s 64K $(cat DEVICES)
# Create named pool only
lvcreate -l1 --discards ignore -T $vg/pool
check lv_field $vg/pool discards "ignore"
+check lv_field $vg/pool kernel_discards "ignore"
lvcreate -l1 --discards nopassdown -T $vg/pool1
check lv_field $vg/pool1 discards "nopassdown"
+check lv_field $vg/pool1 kernel_discards "nopassdown"
lvcreate -l1 --discards passdown -T $vg/pool2
check lv_field $vg/pool2 discards "passdown"
+check lv_field $vg/pool2 discards "passdown"
lvchange --discards nopassdown $vg/pool2
@@ -66,3 +71,25 @@ lvchange --discards ignore $vg/pool1
check lv_field $vg/pool1 discards "ignore"
vgremove -ff $vg
+
+# Create thin pool with discards set to "ignore".
+# If we create a thin volume which we use for a PV
+# which we use to create another thin pool on top
+# with discards set to "passdown", the discards value
+# in metadata is still "passdown", but because the
+# device below does not support it, the kernel value
+# of discards actually used will be "nopassdown".
+# This is why we have "-o discards" and "-o kernel_discards".
+vgcreate -s 1m ${vg}_1 $(cat DEVICES)
+lvcreate -l 10 -T ${vg}_1/pool --discards ignore
+lvcreate -V 9m -T ${vg}_1/pool -n device_with_ignored_discards
+vgcreate -s 1m ${vg}_2 "$DM_DEV_DIR/${vg}_1/device_with_ignored_discards"
+lvcreate -l 1 -T ${vg}_2/pool --discards passdown
+lvcreate -V 1 -T ${vg}_2/pool
+check lv_field ${vg}_1/pool discards "ignore"
+check lv_field ${vg}_1/pool kernel_discards "ignore"
+check lv_field ${vg}_2/pool discards "passdown"
+check lv_field ${vg}_2/pool kernel_discards "nopassdown"
+
+vgremove -ff ${vg}_2
+vgremove -ff ${vg}_1
8 years, 3 months
master - Revert "process_each_pv: remove unnecessary workaround"
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6d09c8c2c45ea1...
Commit: 6d09c8c2c45ea1dea243134b8badc841a87cc979
Parent: 88400b599efa2a06fcc29c1c69ef450aa0c98524
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jan 14 09:12:57 2016 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jan 14 09:12:57 2016 -0600
Revert "process_each_pv: remove unnecessary workaround"
This reverts commit be1b1f3d8941543bcde2f42e65ed0f22fd07b122.
---
tools/toollib.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index 97cc1bf..728e61d 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3033,6 +3033,7 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
const char *pv_name;
int selected;
int process_pv;
+ int dev_found;
int ret_max = ECMD_PROCESSED;
int ret = 0;
@@ -3086,7 +3087,21 @@ static int _process_pvs_in_vg(struct cmd_context *cmd,
else
log_very_verbose("Processing PV %s in VG %s.", pv_name, vg->name);
- _device_list_remove(all_devices, pv->dev);
+ dev_found = _device_list_remove(all_devices, pv->dev);
+
+ /*
+ * FIXME PVs with no mdas may turn up in an orphan VG when
+ * not using lvmetad as well as their correct VG. They
+ * will be missing from all_devices the second time
+ * around but must not be processed twice or trigger a message.
+ *
+ * Missing PVs will also need processing even though they are
+ * not present in all_devices.
+ */
+ if (!dev_found && !is_missing_pv(pv)) {
+ log_verbose("Skipping PV %s in VG %s: not in device list.", pv_name, vg->name);
+ continue;
+ }
if (!skip) {
ret = process_single_pv(cmd, vg, pv, handle);
8 years, 3 months
master - lvmanip: fix last commit and drop else
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=88400b599efa2a...
Commit: 88400b599efa2a06fcc29c1c69ef450aa0c98524
Parent: 278c5509ee88b6384e0ccdb8b8da994b020ffe75
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 14 11:54:37 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:55:47 2016 +0100
lvmanip: fix last commit and drop else
In last commit when removing if() branch
this 'else' now has to be dropped.
---
lib/metadata/lv_manip.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index ca9e0a1..7ba52f9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3136,7 +3136,8 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
/* FIXME Caller should ensure this */
if (mirrors && !stripes)
stripes = 1;
- else if (mirrors > 1)
+
+ if (mirrors > 1)
area_count = mirrors * stripes;
else
area_count = stripes;
8 years, 3 months
master - cleanup: order ac members
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=278c5509ee88b6...
Commit: 278c5509ee88b6384e0ccdb8b8da994b020ffe75
Parent: c9a813bff8828e379f9be963a49a9201a3484ec6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jan 14 11:21:47 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100
cleanup: order ac members
---
lib/metadata/metadata-exported.h | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 8785f99..a118fa8 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -574,17 +574,16 @@ struct lvresize_params {
/* FIXME Deal with meaningless 'ac' */
/* Arg counts & values */
+ alloc_policy_t ac_alloc;
+ unsigned ac_force;
+ unsigned ac_mirrors;
+ uint32_t ac_mirrors_value;
+ unsigned ac_no_sync;
unsigned ac_policy;
unsigned ac_stripes;
uint32_t ac_stripes_value;
- unsigned ac_mirrors;
- uint32_t ac_mirrors_value;
unsigned ac_stripesize;
uint64_t ac_stripesize_value;
- alloc_policy_t ac_alloc;
- unsigned ac_no_sync;
- unsigned ac_force;
-
const char *ac_type;
};
8 years, 3 months
master - cleanup: spaces
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c9a813bff8828e...
Commit: c9a813bff8828e379f9be963a49a9201a3484ec6
Parent: 7d2b7f2bd8c318ed65097d4cb7141b3035e43e2f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jan 11 14:11:37 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100
cleanup: spaces
---
lib/metadata/lv_manip.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 99f3661..ca9e0a1 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1666,7 +1666,7 @@ static void _init_alloc_parms(struct alloc_handle *ah,
alloc_parms->flags |= A_PARTITION_BY_TAGS;
/*
- * For normal allocations, if any extents have already been found
+ * For normal allocations, if any extents have already been found
* for allocation, prefer to place further extents on the same disks as
* have already been used.
*/
@@ -2010,7 +2010,7 @@ static int _is_same_pv(struct pv_match *pvmatch __attribute((unused)), struct pv
}
/*
- * Does PV area have a tag listed in allocation/cling_tag_list that
+ * Does PV area have a tag listed in allocation/cling_tag_list that
* matches EITHER a tag of the PV of the existing segment OR a tag in pv_tags?
* If tags_list_str is set, then instead we generate a list of matching tags for printing.
*/
@@ -2166,7 +2166,7 @@ static int _pv_has_matching_tag(const struct dm_config_node *cling_tag_list_cn,
}
/*
- * Does PV area have a tag listed in allocation/cling_tag_list that
+ * Does PV area have a tag listed in allocation/cling_tag_list that
* matches a tag of the PV of the existing segment?
*/
static int _pvs_have_matching_tag(const struct dm_config_node *cling_tag_list_cn,
@@ -2205,8 +2205,8 @@ static void _reserve_area(struct alloc_handle *ah, struct alloc_state *alloc_sta
log_debug_alloc("%s allocation area %" PRIu32 " %s %s start PE %" PRIu32
" length %" PRIu32 " leaving %" PRIu32 "%s%s.",
- area_used->pva ? "Changing " : "Considering",
- ix_pva, area_used->pva ? "to" : "as",
+ area_used->pva ? "Changing " : "Considering",
+ ix_pva, area_used->pva ? "to" : "as",
dev_name(pva->map->pv->dev), pva->start, required, unreserved,
pv_tag_list ? " with PV tags: " : "",
pv_tag_list ? : "");
@@ -2468,7 +2468,7 @@ static uint32_t _calc_required_extents(struct alloc_handle *ah, struct pv_area *
uint32_t required = max_to_allocate / ah->area_multiple;
/*
- * Update amount unreserved - effectively splitting an area
+ * Update amount unreserved - effectively splitting an area
* into two or more parts. If the whole stripe doesn't fit,
* reduce amount we're looking for.
*/
@@ -2669,7 +2669,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
goto next_pv;
/*
- * Avoid PVs already set aside for log.
+ * Avoid PVs already set aside for log.
* We only reach here if there were enough PVs for the main areas but
* not enough for the logs.
*/
@@ -2697,7 +2697,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
*
* USE_AREA are stored for later, then sorted and chosen from.
*/
- switch(_check_pva(ah, pva, max_to_allocate,
+ switch(_check_pva(ah, pva, max_to_allocate,
alloc_state, already_found_one, iteration_count, log_iteration_count)) {
case PREFERRED:
@@ -2802,7 +2802,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
return 1;
/*
- * FIXME We should change the code to do separate calls for the log allocation
+ * FIXME We should change the code to do separate calls for the log allocation
* and the data allocation so that _limit_to_one_area_per_tag doesn't have to guess
* where the split is going to occur.
*/
@@ -2853,7 +2853,7 @@ static int _find_some_parallel_space(struct alloc_handle *ah,
}
/*
- * Choose sets of parallel areas to use, respecting any constraints
+ * Choose sets of parallel areas to use, respecting any constraints
* supplied in alloc_parms.
*/
static int _find_max_parallel_space_for_one_policy(struct alloc_handle *ah, struct alloc_parms *alloc_parms,
@@ -4600,7 +4600,7 @@ static int _lvresize_poolmetadata(struct cmd_context *cmd, struct volume_group *
return 1;
}
-static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv,
+static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv,
struct lvresize_params *lp)
{
struct volume_group *vg = lv->vg;
@@ -4674,7 +4674,7 @@ static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv
return 1;
}
-static int _lvresize_adjust_size(struct cmd_context *cmd, struct logical_volume *lv,
+static int _lvresize_adjust_size(struct cmd_context *cmd, struct logical_volume *lv,
struct lvresize_params *lp)
{
struct volume_group *vg = lv->vg;
@@ -4845,7 +4845,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
/* Initial decision on whether we are extending or reducing */
if (lp->sign == SIGN_MINUS ||
- (lp->sign == SIGN_NONE &&
+ (lp->sign == SIGN_NONE &&
((lp->extents_are_pes && lp->extents < existing_physical_extents) ||
(!lp->extents_are_pes && lp->extents < existing_logical_extents))))
reducing = 1;
@@ -4886,10 +4886,10 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
(!seg_is_raid(seg) || seg_is_mirrored(seg)) &&
!seg_is_raid10(seg))
continue;
-
+
sz = seg->stripe_size;
str = seg->area_count - lp->segtype->parity_devs;
-
+
if ((seg_stripesize && seg_stripesize != sz &&
sz && !lp->stripe_size) ||
(seg_stripes && seg_stripes != str && !lp->stripes)) {
@@ -4897,11 +4897,11 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
"stripes (-i) and stripesize (-I)");
return 0;
}
-
+
seg_stripesize = sz;
seg_stripes = str;
}
-
+
if (!lp->stripes)
lp->stripes = seg_stripes;
else if (seg_is_raid(first_seg(lv)) &&
@@ -4910,7 +4910,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
lvseg_name(first_seg(lv)));
return 0;
}
-
+
if (!lp->stripe_size && lp->stripes > 1) {
if (seg_stripesize) {
log_print_unless_silent("Using stripesize of last segment %s",
@@ -5022,7 +5022,7 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
}
}
}
- }
+ }
/* At this point, lp->extents should hold the correct NEW logical size required. */
@@ -5259,7 +5259,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
return lock_lv;
}
-int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
+int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
struct lvresize_params *lp, struct dm_list *pvh)
{
if (!_lvresize_check_lv(cmd, lv, lp))
@@ -5291,7 +5291,7 @@ int lv_resize_prepare(struct cmd_context *cmd, struct logical_volume *lv,
}
/* lv_resize_prepare MUST be called before this */
-int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
+int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
struct lvresize_params *lp, struct dm_list *pvh)
{
struct volume_group *vg = lv->vg;
@@ -5479,13 +5479,13 @@ struct logical_volume *lv_create_empty(const char *name,
if (!lv_set_creation(lv, NULL, 0))
goto_bad;
-
+
if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv))
goto_bad;
if (vg->fid->fmt->features & FMT_CONFIG_PROFILE)
lv->profile = vg->cmd->profile_params->global_metadata_profile;
-
+
return lv;
bad:
dm_pool_free(vg->vgmem, lv);
8 years, 3 months
master - cleanup: replace log_warn
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7d2b7f2bd8c318...
Commit: 7d2b7f2bd8c318ed65097d4cb7141b3035e43e2f
Parent: 2567d03e95bb4e46cd845c2ae8b518ec4989b939
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 8 11:08:07 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100
cleanup: replace log_warn
---
lib/metadata/lv_manip.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6897801..99f3661 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4631,14 +4631,14 @@ static int _lvresize_check_lv(struct cmd_context *cmd, struct logical_volume *lv
if (vg->fid->fmt->features & FMT_SEGMENTS)
lp->stripes = lp->ac_stripes_value;
else
- log_warn("Varied striping not supported. Ignoring.");
+ log_print_unless_silent("Varied striping not supported. Ignoring.");
}
if (lp->ac_mirrors) {
if (vg->fid->fmt->features & FMT_SEGMENTS)
lp->mirrors = lp->ac_mirrors_value;
else
- log_warn("Mirrors not supported. Ignoring.");
+ log_print_unless_silent("Mirrors not supported. Ignoring.");
}
if (lp->ac_stripesize && !_validate_stripesize(cmd, vg, lp))
8 years, 3 months
master - cleanup: explicit prohibition for virtual segs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2567d03e95bb4e...
Commit: 2567d03e95bb4e46cd845c2ae8b518ec4989b939
Parent: 4310dfd4e141bb83320148d245f3ab2cae778f6e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Jan 6 13:54:15 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100
cleanup: explicit prohibition for virtual segs
Internal _alloc_init() is only called from allocate_extents(),
which already does prevent usage of virtual segments.
So mark as internal error early and do not process it any further.
---
lib/metadata/lv_manip.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 1396b86..6897801 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3128,19 +3128,20 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
uint32_t s, area_count, alloc_count, parity_count, total_extents;
size_t size = 0;
+ if (segtype_is_virtual(segtype)) {
+ log_error(INTERNAL_ERROR "_alloc_init called for virtual segment.");
+ return NULL;
+ }
+
/* FIXME Caller should ensure this */
if (mirrors && !stripes)
stripes = 1;
-
- if (segtype_is_virtual(segtype))
- area_count = 0;
else if (mirrors > 1)
area_count = mirrors * stripes;
else
area_count = stripes;
- if (!segtype_is_virtual(segtype) &&
- !(area_count + metadata_area_count)) {
+ if (!(area_count + metadata_area_count)) {
log_error(INTERNAL_ERROR "_alloc_init called for non-virtual segment with no disk space.");
return NULL;
}
@@ -3186,10 +3187,6 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
ah->cmd = cmd;
ah->mem = mem;
-
- if (segtype_is_virtual(segtype))
- return ah;
-
ah->area_count = area_count;
ah->parity_count = parity_count;
ah->region_size = region_size;
8 years, 3 months
master - cleanup: simplier formula
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4310dfd4e141bb...
Commit: 4310dfd4e141bb83320148d245f3ab2cae778f6e
Parent: ebcfd09ba9631b52762b4932fbe06260326b9827
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Jan 8 11:07:47 2016 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jan 14 11:34:05 2016 +0100
cleanup: simplier formula
---
lib/metadata/lv_manip.c | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 62564c5..1396b86 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4950,21 +4950,14 @@ static int _lvresize_adjust_extents(struct cmd_context *cmd, struct logical_volu
log_print_unless_silent("Ignoring stripes, stripesize and mirrors "
"arguments when reducing.");
- if (lp->sign == SIGN_MINUS)
- if (lp->extents_are_pes) {
- if (lp->extents >= existing_physical_extents) {
- log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
- return 0;
- }
- new_extents = existing_physical_extents - lp->extents;
- } else {
- new_extents = existing_logical_extents - lp->extents;
- if (lp->extents >= existing_logical_extents) {
- log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
- return 0;
- }
+ if (lp->sign == SIGN_MINUS) {
+ new_extents = lp->extents_are_pes ? existing_physical_extents : existing_logical_extents;
+ if (lp->extents >= new_extents) {
+ log_error("Unable to reduce %s below 1 extent.", lp->lv_name);
+ return 0;
}
- else
+ new_extents -= lp->extents;
+ } else
new_extents = lp->extents;
dm_list_iterate_items(seg, &lv->segments) {
8 years, 3 months