master - report: also display "mirror" keyword in lv_layout for mirrored mirror log and "cache" keyword in lv_layout for cached cache pool
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aec4d0c939653c...
Commit: aec4d0c939653cfc0dadcec43a9db98597154bcb
Parent: b80683616412b29a1dbd80641cae175696a9a761
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Aug 19 13:58:32 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Aug 19 13:58:32 2014 +0200
report: also display "mirror" keyword in lv_layout for mirrored mirror log and "cache" keyword in lv_layout for cached cache pool
$ lvs -a -o name,vg_name,attr,layout,type
LV VG Attr Layout Type
lvol0 vg mwi-a-m--- mirror mirror
[lvol0_mimage_0] vg iwi-aom--- linear image,mirror
[lvol0_mimage_1] vg iwi-aom--- linear image,mirror
[lvol0_mlog] vg mwi-aom--- mirror log,mirror
[lvol0_mlog_mimage_0] vg iwi-aom--- linear image,mirror
[lvol0_mlog_mimage_1] vg iwi-aom--- linear image,mirror
(lvol0_mlog properly displayed as "mirror" layout for mirrored mirror log)
$ lvs -a -o name,vg_name,attr,layout,type
LV VG Attr Layout Type
lvol0 vg Cwi---C--- cache,pool cache,pool
[lvol0_cdata] vg Cwi------- linear cache,data,pool
[lvol0_cmeta] vg ewi------- linear cache,metadata,pool
[lvol1_pmspare] vg ewi------- linear metadata,pool,spare
lvol2 vg Cwi---C--- cache,pool cache,pool
[lvol2_cdata] vg Cwi---C--- cache cache,data,pool
[lvol2_cdata_corig] vg owi---C--- linear cache,origin
[lvol2_cmeta] vg ewi------- linear cache,metadata,pool
(lvol2_cdata properly displayed as cached cache pool data)
---
lib/metadata/lv_manip.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f7cbfe7..dd0ba33 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -170,6 +170,9 @@ static int _lv_type_list_mirror(struct dm_pool *mem,
} else if (lv_is_mirror_log(lv)) {
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_LOG]))
goto_bad;
+ if (lv_is_mirrored(lv) &&
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_MIRROR]))
+ goto_bad;
top_level = 0;
} else if (lv->status & PVMOVE) {
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_PVMOVE]) ||
@@ -333,6 +336,9 @@ static int _lv_type_list_cache(struct dm_pool *mem,
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_POOL]) ||
!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_DATA]))
goto_bad;
+ if (lv_is_cache(lv) &&
+ !str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_CACHE]))
+ goto_bad;
top_level = 0;
}
9 years, 8 months
master - report: also display "mirror" keyword in lv_type for pvmove LV and display "multiple" for external origin used for more than one thin snapshot
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b80683616412b2...
Commit: b80683616412b29a1dbd80641cae175696a9a761
Parent: 90c47a49686431a097809d1d133a071a95a14e68
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Aug 19 09:41:41 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Aug 19 09:41:41 2014 +0200
report: also display "mirror" keyword in lv_type for pvmove LV and display "multiple" for external origin used for more than one thin snapshot
$ lvs -a -o name,vg_name,attr,layout,type
LV VG Attr Layout Type
lvol0 vg -wI-a----- linear linear
[pvmove0] vg p-C-aom--- mirror mirror,pvmove
(added "mirror" for pvmove LV)
$ lvs -a -o name,vg_name,attr,layout,type
LV VG Attr Layout Type
lvol0 vg ori------- linear external,multiple,origin,thin
[lvol1_pmspare] vg ewi------- linear metadata,pool,spare
lvol2 vg Vwi-a-tz-- thin snapshot,thin
lvol3 vg Vwi-a-tz-- thin snapshot,thin
pool vg twi-a-tz-- pool,thin pool,thin
[pool_tdata] vg Twi-ao---- linear data,pool,thin
[pool_tmeta] vg ewi-ao---- linear metadata,pool,thin
(added "multiple" for external origin used for more than one
thin snapshot - lvol0 in the example above)
---
lib/metadata/lv_manip.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 81001fd..f7cbfe7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -172,7 +172,8 @@ static int _lv_type_list_mirror(struct dm_pool *mem,
goto_bad;
top_level = 0;
} else if (lv->status & PVMOVE) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_PVMOVE]))
+ if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_PVMOVE]) ||
+ !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MIRROR]))
goto_bad;
}
@@ -384,6 +385,9 @@ int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
if (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_ORIGIN]) ||
!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_EXTERNAL]))
goto_bad;
+ if (lv->external_count > 1 &&
+ !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_MULTIPLE]))
+ goto_bad;
if (!lv_is_thin_volume(lv) &&
!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
9 years, 8 months
master - report: fix thin external snapshot identification for lv_layout and lv_type fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=90c47a49686431...
Commit: 90c47a49686431a097809d1d133a071a95a14e68
Parent: 4d45302e25f5fe1251bdd8f2c49c4a75a4a31d2e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Aug 18 15:58:48 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Aug 18 15:58:48 2014 +0200
report: fix thin external snapshot identification for lv_layout and lv_type fields
Thin snapshots having external origins missed the "snapshot" keyword for
lv_type field. Also, thin external origins which are thin devices (from
another pool) were not recognized properly.
For example, external origin itself can be either non-thin volume (lvol0
below) or it can be a thin volume from another pool (lvol3 below):
Before this patch:
$ lvs -o name,vg_name,attr,pool_lv,origin,layout,type
Internal error: Failed to properly detect layout and type for for LV vg/lvol3
Internal error: Failed to properly detect layout and type for for LV vg/lvol3
LV VG Attr Pool Origin Layout Type
lvol0 vg ori------- linear external,origin,thin
lvol2 vg Vwi-a-tz-- pool lvol0 thin thin
lvol3 vg ori---tz-- pool unknown external,origin,thin,thin
lvol4 vg Vwi-a-tz-- pool1 lvol3 thin thin
pool vg twi-a-tz-- pool,thin pool,thin
pool1 vg twi-a-tz-- pool,thin pool,thin
- lvol2 as well as lvol4 have missing "snapshot" in type field
- lvol3 has unrecognized layout (should be "thin"), but has double
"thin" in lv_type which is incorrect
- (also there's double "for" in the internal error message)
With this patch applied:
$ lvs -o name,vg_name,attr,pool_lv,origin,layout,type
LV VG Attr Pool Origin Layout Type
lvol0 vg ori------- linear external,origin,thin
lvol2 vg Vwi-a-tz-- pool lvol0 thin snapshot,thin
lvol3 vg ori---tz-- pool thin external,origin,thin
lvol4 vg Vwi-a-tz-- pool1 lvol3 thin snapshot,thin
pool vg twi-a-tz-- pool,thin pool,thin
pool1 vg twi-a-tz-- pool,thin pool,thin
---
lib/metadata/lv_manip.c | 23 +++++++++++++----------
1 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b2e927d..81001fd 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -267,6 +267,7 @@ static int _lv_type_list_thin(struct dm_pool *mem,
{
int top_level = 1;
unsigned snap_count;
+ struct lv_segment *seg;
if (lv_is_thin_pool(lv)) {
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]) ||
@@ -292,18 +293,11 @@ static int _lv_type_list_thin(struct dm_pool *mem,
if (snap_count > 1 &&
!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MULTIPLE]))
goto_bad;
- if (first_seg(lv)->origin)
+ if ((seg = first_seg(lv)) && (seg->origin || seg->external_lv))
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_SNAPSHOT]))
goto_bad;
}
- if (lv_is_external_origin(lv)) {
- if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_ORIGIN]) ||
- !str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_EXTERNAL]))
- goto_bad;
- top_level = 0;
- }
-
if (top_level) {
if (!str_list_add_no_dup_check(mem, layout, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
@@ -382,10 +376,19 @@ int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
goto_bad;
/* Thins and related */
- if ((lv_is_thin_type(lv) || lv_is_external_origin(lv)) &&
+ if (lv_is_thin_type(lv) &&
!_lv_type_list_thin(mem, lv, *layout, *type))
goto_bad;
+ if (lv_is_external_origin(lv)) {
+ if (!str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_ORIGIN]) ||
+ !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_EXTERNAL]))
+ goto_bad;
+ if (!lv_is_thin_volume(lv) &&
+ !str_list_add_no_dup_check(mem, *type, _lv_type_names[LV_TYPE_THIN]))
+ goto_bad;
+ }
+
/* Caches and related */
if (lv_is_cache_type(lv) &&
!_lv_type_list_cache(mem, lv, *layout, *type))
@@ -439,7 +442,7 @@ int lv_layout_and_type(struct dm_pool *mem, const struct logical_volume *lv,
*/
unknown = 1;
log_error(INTERNAL_ERROR "Failed to properly detect "
- "layout and type for for LV %s/%s",
+ "layout and type for LV %s/%s",
lv->vg->name, lv->name);
}
}
9 years, 8 months
master - RAID: Fail RAID4/5/6 creation if PE size is less than STRIPE_SIZE_MIN
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4d45302e25f5fe...
Commit: 4d45302e25f5fe1251bdd8f2c49c4a75a4a31d2e
Parent: 42e07d2bceaad21f197de5dde9ead69742425159
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Aug 15 21:15:34 2014 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Aug 15 21:15:34 2014 -0500
RAID: Fail RAID4/5/6 creation if PE size is less than STRIPE_SIZE_MIN
The maximum stripe size is equal to the volume group PE size. If that
size falls below the STRIPE_SIZE_MIN, the creation of RAID 4/5/6 volumes
becomes impossible. (The kernel will fail to load a RAID 4/5/6 mapping
table with a stripe size less than STRIPE_SIZE_MIN.) So, we report an
error if it is attempted.
This is very rare because reducing the PE size down that far limits the
size of the PV below that of modern devices.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 15 +++++++++++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a5daf80..2e2a064 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.110 -
==================================
+ Cleanly error when creating RAID with stripe size < PAGE_SIZE.
Print name of LV which on activation triggers delayed snapshot merge.
Add lv_layout and lv_type LV reporting fields.
Properly display lvs lv_attr volume type and target type bit for cache origin.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d86bdc1..b2e927d 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6364,6 +6364,21 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (lp->stripe_size > vg->extent_size) {
+ if (segtype_is_raid(lp->segtype) &&
+ (vg->extent_size < STRIPE_SIZE_MIN)) {
+ /*
+ * FIXME: RAID will simply fail to load the table if
+ * this is the case, but we should probably
+ * honor the stripe minimum for regular stripe
+ * volumes as well. Avoiding doing that now
+ * only to minimize the change.
+ */
+ log_error("The extent size in volume group %s is too"
+ " small to support striped RAID volumes.",
+ vg->name);
+ return NULL;
+ }
+
log_print_unless_silent("Reducing requested stripe size %s to maximum, "
"physical extent size %s.",
display_size(cmd, (uint64_t) lp->stripe_size),
9 years, 8 months
master - dmsetup: Support remove --deferred.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42e07d2bceaad2...
Commit: 42e07d2bceaad21f197de5dde9ead69742425159
Parent: ec41bd1920be119538cd9c98a8fc3d38e184803f
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Sat Aug 16 00:34:48 2014 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Sat Aug 16 00:34:48 2014 +0100
dmsetup: Support remove --deferred.
This patch adds a new flag --deferred to dmsetup remove. If this flag is
specified and the device is open, it is scheduled to be deleted on
close.
struct dm_info is extended.
The existing dm_task_get_info() is converted into a wrapper around the
new version dm_task_get_info_with_deferred_remove() so existing binaries
can still use the old smaller structure.
Recompiled code will pick up the new larger structure.
From: Mikulas Patocka <mpatocka(a)redhat.com>
---
WHATS_NEW_DM | 1 +
libdm/.exported_symbols | 1 +
libdm/ioctl/libdm-iface.c | 44 +++++++++++++++++++++++++++++++++++++++-
libdm/ioctl/libdm-targets.h | 1 +
libdm/libdevmapper.h | 5 ++++
man/dmsetup.8.in | 47 ++++++++++++++++++++++--------------------
tools/dmsetup.c | 14 ++++++++++--
7 files changed, 87 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 41aa89d..4a2c8b4 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.89 -
=================================
+ Support --deferred with dmsetup remove to defer removal of open devices.
Update dm-ioctl.h to include DM_DEFERRED_REMOVE flag.
Add support for selection to match string list subset, recognize { } operator.
Fix string list selection with '[value]' to not match list that's superset.
diff --git a/libdm/.exported_symbols b/libdm/.exported_symbols
index 3a69860..5bacc26 100644
--- a/libdm/.exported_symbols
+++ b/libdm/.exported_symbols
@@ -1,2 +1,3 @@
dm_log
dm_log_with_errno
+dm_task_get_info
diff --git a/libdm/ioctl/libdm-iface.c b/libdm/ioctl/libdm-iface.c
index 345651b..4f55ddf 100644
--- a/libdm/ioctl/libdm-iface.c
+++ b/libdm/ioctl/libdm-iface.c
@@ -17,6 +17,7 @@
#include "libdm-targets.h"
#include "libdm-common.h"
+#include <stddef.h>
#include <fcntl.h>
#include <dirent.h>
#include <sys/ioctl.h>
@@ -654,6 +655,7 @@ int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
info->live_table = dmt->dmi.v4->flags & DM_ACTIVE_PRESENT_FLAG ? 1 : 0;
info->inactive_table = dmt->dmi.v4->flags & DM_INACTIVE_PRESENT_FLAG ?
1 : 0;
+ info->deferred_remove = dmt->dmi.v4->flags & DM_DEFERRED_REMOVE;
info->target_count = dmt->dmi.v4->target_count;
info->open_count = dmt->dmi.v4->open_count;
info->event_nr = dmt->dmi.v4->event_nr;
@@ -862,6 +864,13 @@ int dm_task_retry_remove(struct dm_task *dmt)
return 1;
}
+int dm_task_deferred_remove(struct dm_task *dmt)
+{
+ dmt->deferred_remove = 1;
+
+ return 1;
+}
+
int dm_task_query_inactive_table(struct dm_task *dmt)
{
dmt->query_inactive_table = 1;
@@ -1137,6 +1146,9 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
dmi->flags |= DM_READONLY_FLAG;
if (dmt->skip_lockfs)
dmi->flags |= DM_SKIP_LOCKFS_FLAG;
+ if (dmt->deferred_remove && (dmt->type == DM_DEVICE_REMOVE || dmt->type == DM_DEVICE_REMOVE_ALL))
+ dmi->flags |= DM_DEFERRED_REMOVE;
+
if (dmt->secure_data) {
if (_dm_version_minor < 20)
log_verbose("Secure data flag unsupported by kernel. "
@@ -1732,7 +1744,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
}
log_debug_activation("dm %s %s%s %s%s%s %s%.0d%s%.0d%s"
- "%s%c%c%s%s%s%s%s%s %.0" PRIu64 " %s [%u] (*%u)",
+ "%s%c%c%s%s%s%s%s%s%s %.0" PRIu64 " %s [%u] (*%u)",
_cmd_data_v4[dmt->type].name,
dmt->new_uuid ? "UUID " : "",
dmi->name, dmi->uuid, dmt->newname ? " " : "",
@@ -1748,6 +1760,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
dmt->read_only ? "R" : "",
dmt->skip_lockfs ? "S " : "",
dmt->retry_remove ? "T " : "",
+ dmt->deferred_remove ? "D " : "",
dmt->secure_data ? "W " : "",
dmt->query_inactive_table ? "I " : "",
dmt->enable_checks ? "C" : "",
@@ -2006,3 +2019,32 @@ void dm_lib_exit(void)
_version_ok = 1;
_version_checked = 0;
}
+
+/*
+ * This following code is here to retain ABI compatibility after adding
+ * the field deferred_remove to struct dm_info in version 1.02.89.
+ *
+ * Binaries linked against version 1.02.88 of libdevmapper or earlier
+ * will use this function that returns dm_info without the
+ * deferred_remove field.
+ *
+ * Binaries compiled against version 1.02.89 onwards will use
+ * the new function dm_task_get_info_with_deferred_remove due to the
+ * #define.
+ *
+ * N.B. Keep this function at the end of the file to make sure that
+ * no code in this file accidentally calls it.
+ */
+#undef dm_task_get_info
+int dm_task_get_info(struct dm_task *dmt, struct dm_info *info);
+int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
+{
+ struct dm_info new_info;
+
+ if (!dm_task_get_info_with_deferred_remove(dmt, &new_info))
+ return 0;
+
+ memcpy(info, &new_info, offsetof(struct dm_info, deferred_remove));
+
+ return 1;
+}
diff --git a/libdm/ioctl/libdm-targets.h b/libdm/ioctl/libdm-targets.h
index 54223c7..100681f 100644
--- a/libdm/ioctl/libdm-targets.h
+++ b/libdm/ioctl/libdm-targets.h
@@ -65,6 +65,7 @@ struct dm_task {
int new_uuid;
int secure_data;
int retry_remove;
+ int deferred_remove;
int enable_checks;
int expected_errno;
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index e37ee39..bf8a658 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -149,6 +149,8 @@ struct dm_info {
int read_only; /* 0:read-write; 1:read-only */
int32_t target_count;
+
+ int deferred_remove;
};
struct dm_deps {
@@ -172,6 +174,8 @@ struct dm_versions {
int dm_get_library_version(char *version, size_t size);
int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
+
+#define dm_task_get_info dm_task_get_info_with_deferred_remove
int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
/*
@@ -222,6 +226,7 @@ int dm_task_query_inactive_table(struct dm_task *dmt);
int dm_task_suppress_identical_reload(struct dm_task *dmt);
int dm_task_secure_data(struct dm_task *dmt);
int dm_task_retry_remove(struct dm_task *dmt);
+int dm_task_deferred_remove(struct dm_task *dmt);
/*
* Enable checks for common mistakes such as issuing ioctls in an unsafe order.
diff --git a/man/dmsetup.8.in b/man/dmsetup.8.in
index b18b0b0..477e425 100644
--- a/man/dmsetup.8.in
+++ b/man/dmsetup.8.in
@@ -81,10 +81,12 @@ dmsetup \(em low level logical volume management
.B dmsetup remove
.RB [ \-f | \-\-force ]
.RB [ \-\-retry ]
+.RB [ \-\-deferred ]
.I device_name
.br
.B dmsetup remove_all
.RB [ \-f | \-\-force ]
+.RB [ \-\-deferred ]
.br
.B dmsetup rename
.I device_name new_name
@@ -436,34 +438,35 @@ reactivating it with proper mangling mode used (see also \fB\-\-manglename\fP).
.B remove
.RB [ \-f | \-\-force ]
.RB [ \-\-retry ]
+.RB [ \-\-deferred ]
.I device_name
.br
-Removes a device. It will no longer be visible to dmsetup.
-Open devices cannot be removed except with older kernels
-that contain a version of device-mapper prior to 4.8.0.
-In this case the device will be deleted when its open_count
-drops to zero. From version 4.8.0 onwards, if a device can't
-be removed because an uninterruptible process is waiting for
-I/O to return from it, adding \fB\-\-force\fP will replace the table
-with one that fails all I/O, which might allow the
-process to be killed. If an attempt to remove a device fails,
-perhaps because a process run from a quick udev rule
-temporarily opened the device, the \fB\-\-retry\fP option will cause
-the operation to be retried for a few seconds before failing.
-Do NOT combine \fB\-\-force\fP and \fB\-\-udevcookie\fP,
-as udev may start to process udev rules in the middle of error target
-replacement and result in nondeterministic result.
+Removes a device. It will no longer be visible to dmsetup. Open devices
+cannot be removed, but adding \fB\-\-force\fP will replace the table with one
+that fails all I/O. \fB\-\-deferred\fP will enable deferred removal of open
+devices - the device will be removed when the last user closes it. The deferred
+removal feature is supported since version 4.27.0 of the device-mapper
+driver available in upstream kernel version 3.13. (Use \fBdmsetup version\fP
+to check this.) If an attempt to remove a device fails, perhaps because a process run
+from a quick udev rule temporarily opened the device, the \fB\-\-retry\fP
+option will cause the operation to be retried for a few seconds before failing.
+Do NOT combine
+\fB\-\-force\fP and \fB\-\-udevcookie\fP, as udev may start to process udev
+rules in the middle of error target replacement and result in nondeterministic
+result.
.br
.HP
.B remove_all
.RB [ \-f | \-\-force ]
-.br
-Attempts to remove all device definitions i.e. reset the driver.
-Use with care! From version 4.8.0 onwards, if devices can't
-be removed because uninterruptible processes are waiting for
-I/O to return from them, adding \fB\-\-force\fP will replace the table
-with one that fails all I/O, which might allow the
-process to be killed. This also runs \fBmknodes\fP afterwards.
+.RB [ \-\-deferred ]
+.br
+Attempts to remove all device definitions i.e. reset the driver. This also runs
+\fBmknodes\fP afterwards. Use with care! Open devices cannot be removed, but
+adding \fB\-\-force\fP will replace the table with one that fails all I/O.
+\fB\-\-deferred\fP will enable deferred removal of open devices - the device
+will be removed when the last user closes it. The deferred removal feature is
+supported since version 4.27.0 of the device-mapper driver available in
+upstream kernel version 3.13.
.br
.HP
.B rename
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index c679c52..8f64bfc 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -120,6 +120,7 @@ enum {
ADD_NODE_ON_RESUME_ARG,
CHECKS_ARG,
COLS_ARG,
+ DEFERRED_ARG,
SELECT_ARG,
EXEC_ARG,
FORCE_ARG,
@@ -468,9 +469,10 @@ static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
printf("Name: %s\n", dm_task_get_name(dmt));
- printf("State: %s%s\n",
+ printf("State: %s%s%s\n",
info->suspended ? "SUSPENDED" : "ACTIVE",
- info->read_only ? " (READ-ONLY)" : "");
+ info->read_only ? " (READ-ONLY)" : "",
+ info->deferred_remove ? " (DEFERRED REMOVE)" : "");
/* FIXME Old value is being printed when it's being changed. */
if (dm_task_get_read_ahead(dmt, &read_ahead))
@@ -1321,6 +1323,9 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)
if (_switches[RETRY_ARG] && task == DM_DEVICE_REMOVE)
dm_task_retry_remove(dmt);
+ if (_switches[DEFERRED_ARG] && (task == DM_DEVICE_REMOVE || task == DM_DEVICE_REMOVE_ALL))
+ dm_task_deferred_remove(dmt);
+
r = dm_task_run(dmt);
out:
@@ -3071,7 +3076,7 @@ static struct command _commands[] = {
"\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
"\t [--notable | --table <table> | <table_file>]",
1, 2,0, _create},
- {"remove", "[-f|--force] <device>", 0, -1, 1, _remove},
+ {"remove", "[-f|--force] [--deferred] <device>", 0, -1, 1, _remove},
{"remove_all", "[-f|--force]", 0, 0, 0, _remove_all},
{"suspend", "[--noflush] <device>", 0, -1, 1, _suspend},
{"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, -1, 1, _resume},
@@ -3521,6 +3526,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
{"readonly", 0, &ind, READ_ONLY},
{"checks", 0, &ind, CHECKS_ARG},
{"columns", 0, &ind, COLS_ARG},
+ {"deferred", 0, &ind, DEFERRED_ARG},
{"select", 1, &ind, SELECT_ARG},
{"exec", 1, &ind, EXEC_ARG},
{"force", 0, &ind, FORCE_ARG},
@@ -3694,6 +3700,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
/* FIXME Accept modes as per chmod */
_int_args[MODE_ARG] = (int) strtol(optarg, NULL, 8);
}
+ if (ind == DEFERRED_ARG)
+ _switches[DEFERRED_ARG]++;
if (ind == EXEC_ARG) {
_switches[EXEC_ARG]++;
_command = optarg;
9 years, 8 months
master - cleanup: use display_lvname
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ec41bd1920be11...
Commit: ec41bd1920be119538cd9c98a8fc3d38e184803f
Parent: c894c3c87f7de3b1491455186fa49404685b2b10
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 15 15:52:01 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Aug 15 15:53:17 2014 +0200
cleanup: use display_lvname
Show more complete LV names.
---
tools/lvchange.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index db03176..42769c2 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1012,9 +1012,10 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!arg_count(cmd, yes_ARG) &&
(yes_no_prompt("Change of snapshot %s will also change its "
- "origin %s%s. Proceed? [y/n]: ", lv->name,
- origin->name, snaps_msg) == 'n')) {
- log_error("Logical volume %s not changed.", lv->name);
+ "origin %s%s. Proceed? [y/n]: ",
+ display_lvname(lv), display_lvname(origin),
+ snaps_msg) == 'n')) {
+ log_error("Logical volume %s not changed.", display_lvname(lv));
return ECMD_FAILED;
}
}
9 years, 8 months
master - cleanup: gcc warn fix
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c894c3c87f7de3...
Commit: c894c3c87f7de3b1491455186fa49404685b2b10
Parent: 8af23092310aeb02282f5082fba447586a1da0d3
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Aug 15 15:51:03 2014 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri Aug 15 15:53:17 2014 +0200
cleanup: gcc warn fix
Since gcc fail to see the origin has been already set under condition
above, just set origin again.
---
tools/lvchange.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 91c8087..db03176 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1000,6 +1000,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
if (lv_is_cow(lv) && arg_count(cmd, activate_ARG)) {
+ origin = origin_from_cow(lv);
if (origin->origin_count < 2)
snaps_msg[0] = '\0';
else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
9 years, 8 months
master - cleanup: gcc warning
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8af23092310aeb...
Commit: 8af23092310aeb02282f5082fba447586a1da0d3
Parent: 8e449ebd63228bb8728d7e62989dc1254138b153
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 15 15:43:42 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 15 15:43:42 2014 +0200
cleanup: gcc warning
One more:
metadata/thin_manip.c:503: warning: declaration of "snapshot_count" shadows a global declaration
---
lib/metadata/thin_manip.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index b4da500..ae42da1 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -500,13 +500,13 @@ const char *get_pool_discards_name(thin_discards_t discards)
return "unknown";
}
-int lv_is_thin_origin(const struct logical_volume *lv, unsigned int *snapshot_count)
+int lv_is_thin_origin(const struct logical_volume *lv, unsigned int *snap_count)
{
struct seg_list *segl;
int r = 0;
- if (snapshot_count)
- *snapshot_count = 0;
+ if (snap_count)
+ *snap_count = 0;
if (!lv_is_thin_volume(lv) ||
dm_list_empty(&lv->segs_using_this_lv))
@@ -515,8 +515,8 @@ int lv_is_thin_origin(const struct logical_volume *lv, unsigned int *snapshot_co
dm_list_iterate_items(segl, &lv->segs_using_this_lv) {
if (segl->seg->origin == lv) {
r = 1;
- if (snapshot_count)
- (*snapshot_count)++;
+ if (snap_count)
+ (*snap_count)++;
else
/* not interested in number of snapshots */
break;
9 years, 8 months
master - cleanup: gcc warning
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8e449ebd63228b...
Commit: 8e449ebd63228bb8728d7e62989dc1254138b153
Parent: d213758e5720f47d3a5781d958431c8d80afdda7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 15 15:32:04 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 15 15:32:04 2014 +0200
cleanup: gcc warning
metadata/lv_manip.c:269: warning: declaration of "snapshot_count" shadows a global declaration
There's existing function called "snapshot_count" so rename the
variable to "snap_count".
---
lib/metadata/lv_manip.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 35b898f..d86bdc1 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -266,7 +266,7 @@ static int _lv_type_list_thin(struct dm_pool *mem,
struct dm_list *type)
{
int top_level = 1;
- unsigned snapshot_count;
+ unsigned snap_count;
if (lv_is_thin_pool(lv)) {
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]) ||
@@ -286,10 +286,10 @@ static int _lv_type_list_thin(struct dm_pool *mem,
} else if (lv_is_thin_volume(lv)) {
if (!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_THIN]))
goto_bad;
- if (lv_is_thin_origin(lv, &snapshot_count) &&
+ if (lv_is_thin_origin(lv, &snap_count) &&
!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_ORIGIN]))
goto_bad;
- if (snapshot_count > 1 &&
+ if (snap_count > 1 &&
!str_list_add_no_dup_check(mem, type, _lv_type_names[LV_TYPE_MULTIPLE]))
goto_bad;
if (first_seg(lv)->origin)
9 years, 8 months
master - man: missing (C)ache in target type lv_attr description
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d213758e5720f4...
Commit: d213758e5720f47d3a5781d958431c8d80afdda7
Parent: 9534c21ead16dae8975fdaf1959b5534dc175f84
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Aug 15 15:21:15 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 15 15:21:15 2014 +0200
man: missing (C)ache in target type lv_attr description
---
man/lvs.8.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/man/lvs.8.in b/man/lvs.8.in
index 3ab4120..f268584 100644
--- a/man/lvs.8.in
+++ b/man/lvs.8.in
@@ -169,7 +169,7 @@ mapped (d)evice present without tables, mapped device present with (i)nactive ta
.IP 6 3
device (o)pen, (X) unknown
.IP 7 3
-Target type: (m)irror, (r)aid, (s)napshot, (t)hin, (u)nknown, (v)irtual.
+Target type: (C)ache, (m)irror, (r)aid, (s)napshot, (t)hin, (u)nknown, (v)irtual.
This groups logical volumes related to the same kernel target together. So,
for example, mirror images, mirror logs as well as mirrors themselves appear as
(m) if they use the original device-mapper mirror kernel driver; whereas the raid
9 years, 8 months