All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
@ 2010-10-13 18:53 Mike Snitzer
  2010-10-13 19:06 ` Milan Broz
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Snitzer @ 2010-10-13 18:53 UTC (permalink / raw)
  To: lvm-devel

Convey need for snapshot-merge target in lvconvert error message and man
page.

Add ->target_name to segtype_handler to allow a more specific target
name to be returned based on the state of the segment.

Before:
# lvconvert --merge vg/snap
  Can't expand LV lv: snapshot target support missing from kernel?
  Failed to suspend origin lv

After:
# lvconvert --merge vg/snap
  Can't process LV lv: snapshot-merge target support missing from kernel?
  Failed to suspend origin lv
  Unable to merge LV "snap" into it's origin.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
---
 lib/activate/dev_manager.c |   10 +++++++---
 lib/metadata/segtype.h     |    1 +
 lib/snapshot/snapshot.c    |    9 +++++++++
 man/lvconvert.8.in         |    6 ++++--
 tools/lvconvert.c          |    2 +-
 5 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index cee8f10..841bfc1 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1350,19 +1350,23 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
 	uint32_t s;
 	struct dm_list *snh;
 	struct lv_segment *seg_present;
+	const char *target_name;
 
 	/* Ensure required device-mapper targets are loaded */
 	seg_present = find_cow(seg->lv) ? : seg;
+	target_name = (seg_present->segtype->ops->target_name ?
+		       seg_present->segtype->ops->target_name(seg_present) :
+		       seg_present->segtype->name);
 
 	log_debug("Checking kernel supports %s segment type for %s%s%s",
-		  seg_present->segtype->name, seg->lv->name,
+		  target_name, seg->lv->name,
 		  layer ? "-" : "", layer ? : "");
 
 	if (seg_present->segtype->ops->target_present &&
 	    !seg_present->segtype->ops->target_present(seg_present->lv->vg->cmd,
 						       seg_present, NULL)) {
-		log_error("Can't expand LV %s: %s target support missing "
-			  "from kernel?", seg->lv->name, seg_present->segtype->name);
+		log_error("Can't process LV %s: %s target support missing "
+			  "from kernel?", seg->lv->name, target_name);
 		return 0;
 	}
 
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index d15df8b..c31cf32 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -66,6 +66,7 @@ struct segment_type {
 
 struct segtype_handler {
 	const char *(*name) (const struct lv_segment * seg);
+	const char *(*target_name) (const struct lv_segment * seg);
 	void (*display) (const struct lv_segment * seg);
 	int (*text_export) (const struct lv_segment * seg,
 			    struct formatter * f);
diff --git a/lib/snapshot/snapshot.c b/lib/snapshot/snapshot.c
index 92f8911..30e78d4 100644
--- a/lib/snapshot/snapshot.c
+++ b/lib/snapshot/snapshot.c
@@ -28,6 +28,14 @@ static const char *_snap_name(const struct lv_segment *seg)
 	return seg->segtype->name;
 }
 
+static const char *_snap_target_name(const struct lv_segment *seg)
+{
+	if (seg->status & MERGING)
+		return "snapshot-merge";
+
+	return _snap_name(seg);
+}
+
 static int _snap_text_import(struct lv_segment *seg, const struct config_node *sn,
 			struct dm_hash_table *pv_hash __attribute__((unused)))
 {
@@ -217,6 +225,7 @@ static void _snap_destroy(const struct segment_type *segtype)
 
 static struct segtype_handler _snapshot_ops = {
 	.name = _snap_name,
+	.target_name = _snap_target_name,
 	.text_import = _snap_text_import,
 	.text_export = _snap_text_export,
 	.target_status_compatible = _snap_target_status_compatible,
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 3d4ba20..8e48793 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -135,8 +135,10 @@ Controls zeroing of the first KB of data in the snapshot.
 If the volume is read-only the snapshot will not be zeroed.
 .TP
 .I \-\-merge
-Merges a snapshot into its origin volume. If both the origin and snapshot volume
-are not open the merge will start immediately.  Otherwise, the merge will start
+Merges a snapshot into its origin volume.  To check if your kernel
+supports this feature, look for 'snapshot-merge' in the output
+of 'dmsetup targets'.  If both the origin and snapshot volume are not
+open the merge will start immediately.  Otherwise, the merge will start
 the first time either the origin or snapshot are activated and both are closed.
 Merging a snapshot into an origin that cannot be closed, for example a root
 filesystem, is deferred until the next time the origin volume is activated.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d39030b..4f02806 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -1561,7 +1561,7 @@ static int _lvconvert_single(struct cmd_context *cmd, struct logical_volume *lv,
 			return ECMD_FAILED;
 		}
 		if (!lvconvert_merge(cmd, lv, lp)) {
-			stack;
+			log_error("Unable to merge LV \"%s\" into it's origin.", lv->name);
 			return ECMD_FAILED;
 		}
 	} else if (lp->snapshot) {



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
  2010-10-13 18:53 [PATCH] lvconvert: provide useful error when snapshot-merge target missing Mike Snitzer
@ 2010-10-13 19:06 ` Milan Broz
  2010-10-13 19:55   ` Mike Snitzer
  2010-10-13 21:42   ` [PATCH] " Alasdair G Kergon
  0 siblings, 2 replies; 10+ messages in thread
From: Milan Broz @ 2010-10-13 19:06 UTC (permalink / raw)
  To: lvm-devel

On 10/13/2010 08:53 PM, Mike Snitzer wrote:
> Convey need for snapshot-merge target in lvconvert error message and man
> page.

> --- a/lib/metadata/segtype.h
> +++ b/lib/metadata/segtype.h
> @@ -66,6 +66,7 @@ struct segment_type {
>  
>  struct segtype_handler {
>  	const char *(*name) (const struct lv_segment * seg);
> +	const char *(*target_name) (const struct lv_segment * seg);
>  	void (*display) (const struct lv_segment * seg);
>  	int (*text_export) (const struct lv_segment * seg,
>  			    struct formatter * f);

I think this will break shared (external) segment module ABI.
Nobody uses that but worth to mention it.
(See e.g. lib/mirror and --with-mirrors=shared)

Otherwise ack.

Milan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* lvconvert: provide useful error when snapshot-merge target missing
  2010-10-13 19:06 ` Milan Broz
@ 2010-10-13 19:55   ` Mike Snitzer
  2010-10-13 20:20     ` Milan Broz
  2010-10-13 21:42   ` [PATCH] " Alasdair G Kergon
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Snitzer @ 2010-10-13 19:55 UTC (permalink / raw)
  To: lvm-devel

On Wed, Oct 13 2010 at  3:06pm -0400,
Milan Broz <mbroz@redhat.com> wrote:

> On 10/13/2010 08:53 PM, Mike Snitzer wrote:
> > Convey need for snapshot-merge target in lvconvert error message and man
> > page.
> 
> > --- a/lib/metadata/segtype.h
> > +++ b/lib/metadata/segtype.h
> > @@ -66,6 +66,7 @@ struct segment_type {
> >  
> >  struct segtype_handler {
> >  	const char *(*name) (const struct lv_segment * seg);
> > +	const char *(*target_name) (const struct lv_segment * seg);
> >  	void (*display) (const struct lv_segment * seg);
> >  	int (*text_export) (const struct lv_segment * seg,
> >  			    struct formatter * f);
> 
> I think this will break shared (external) segment module ABI.
> Nobody uses that but worth to mention it.
> (See e.g. lib/mirror and --with-mirrors=shared)

OK, I'm not familiar with that ABI concern.  Any ideas on how I avoid
this breakage?  Add function pointer to end of struct?  Or any change
to struct will be taken as breakage?

Mike



^ permalink raw reply	[flat|nested] 10+ messages in thread

* lvconvert: provide useful error when snapshot-merge target missing
  2010-10-13 19:55   ` Mike Snitzer
@ 2010-10-13 20:20     ` Milan Broz
  0 siblings, 0 replies; 10+ messages in thread
From: Milan Broz @ 2010-10-13 20:20 UTC (permalink / raw)
  To: lvm-devel

On 10/13/2010 09:55 PM, Mike Snitzer wrote:
> On Wed, Oct 13 2010 at  3:06pm -0400,
> Milan Broz <mbroz@redhat.com> wrote:
> 
>> On 10/13/2010 08:53 PM, Mike Snitzer wrote:
>>> Convey need for snapshot-merge target in lvconvert error message and man
>>> page.
>>
>>> --- a/lib/metadata/segtype.h
>>> +++ b/lib/metadata/segtype.h
>>> @@ -66,6 +66,7 @@ struct segment_type {
>>>  
>>>  struct segtype_handler {
>>>  	const char *(*name) (const struct lv_segment * seg);
>>> +	const char *(*target_name) (const struct lv_segment * seg);
>>>  	void (*display) (const struct lv_segment * seg);
>>>  	int (*text_export) (const struct lv_segment * seg,
>>>  			    struct formatter * f);
>>
>> I think this will break shared (external) segment module ABI.
>> Nobody uses that but worth to mention it.
>> (See e.g. lib/mirror and --with-mirrors=shared)
> 
> OK, I'm not familiar with that ABI concern.  Any ideas on how I avoid
> this breakage?  Add function pointer to end of struct?  Or any change
> to struct will be taken as breakage?

Well, git history shows that it was broken several times already...

So ignore it and just add the function there ;-)

Milan



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
  2010-10-13 19:06 ` Milan Broz
  2010-10-13 19:55   ` Mike Snitzer
@ 2010-10-13 21:42   ` Alasdair G Kergon
  2010-10-14  9:04     ` Zdenek Kabelac
  1 sibling, 1 reply; 10+ messages in thread
From: Alasdair G Kergon @ 2010-10-13 21:42 UTC (permalink / raw)
  To: lvm-devel

On Wed, Oct 13, 2010 at 09:06:53PM +0200, Milan Broz wrote:
> I think this will break shared (external) segment module ABI.

Indeed - we make no guarantees for that ABI and don't even bother 
versioning it.  We don't believe there are any out-of-tree users.

Alasdair



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
  2010-10-13 21:42   ` [PATCH] " Alasdair G Kergon
@ 2010-10-14  9:04     ` Zdenek Kabelac
  2010-10-14 11:24       ` Alasdair G Kergon
  2010-10-14 12:53       ` Mike Snitzer
  0 siblings, 2 replies; 10+ messages in thread
From: Zdenek Kabelac @ 2010-10-14  9:04 UTC (permalink / raw)
  To: lvm-devel

Dne 13.10.2010 23:42, Alasdair G Kergon napsal(a):
> On Wed, Oct 13, 2010 at 09:06:53PM +0200, Milan Broz wrote:
>> I think this will break shared (external) segment module ABI.
> 
> Indeed - we make no guarantees for that ABI and don't even bother 
> versioning it.  We don't believe there are any out-of-tree users.
> 

I'd propose to drop/turn off this feature completely - targets usually cannot
work without heavy tweaking through the rest of the code anyway. So in fact we
rather 'pretend' there is such functionality.

Zdenek



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
  2010-10-14  9:04     ` Zdenek Kabelac
@ 2010-10-14 11:24       ` Alasdair G Kergon
  2010-10-14 12:45         ` Zdenek Kabelac
  2010-10-14 12:53       ` Mike Snitzer
  1 sibling, 1 reply; 10+ messages in thread
From: Alasdair G Kergon @ 2010-10-14 11:24 UTC (permalink / raw)
  To: lvm-devel

On Thu, Oct 14, 2010 at 11:04:02AM +0200, Zdenek Kabelac wrote:
> I'd propose to drop/turn off this feature completely - targets usually cannot
> work without heavy tweaking through the rest of the code anyway. So in fact we
> rather 'pretend' there is such functionality.

The reason for the shared libraries is so that a distro can ship support
for older formats like LVM1 or pool but people who know they don't need
it don't have to have it loaded it all the time.

There's no problem to fix here IMHO, but if there was, we'd simply
attach the full version (2.02.72) to the soname of those libraries to
enforce the requirement to recompile.
 
Alasdair



^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lvconvert: provide useful error when snapshot-merge target missing
  2010-10-14 11:24       ` Alasdair G Kergon
@ 2010-10-14 12:45         ` Zdenek Kabelac
  0 siblings, 0 replies; 10+ messages in thread
From: Zdenek Kabelac @ 2010-10-14 12:45 UTC (permalink / raw)
  To: lvm-devel

Dne 14.10.2010 13:24, Alasdair G Kergon napsal(a):
> On Thu, Oct 14, 2010 at 11:04:02AM +0200, Zdenek Kabelac wrote:
>> I'd propose to drop/turn off this feature completely - targets usually cannot
>> work without heavy tweaking through the rest of the code anyway. So in fact we
>> rather 'pretend' there is such functionality.
> 
> The reason for the shared libraries is so that a distro can ship support
> for older formats like LVM1 or pool but people who know they don't need
> it don't have to have it loaded it all the time.
> 

Those object files take like 30KB and we are memory locking a lot of MB of
various glibc and other libs wasteful code...

The main problem I can see is - that things like support of snapshot are not
concentrated in one little object file - but in a lot of other places. So we
do not have clean enough border for this API.

And in effect we would actually consume quite few KB more in case those libs
would be used dynamically and while we extend lvm library with user API - we
actually waste probably far more space - which is not commonly needed.

Zdenek



^ permalink raw reply	[flat|nested] 10+ messages in thread

* lvconvert: provide useful error when snapshot-merge target missing
  2010-10-14  9:04     ` Zdenek Kabelac
  2010-10-14 11:24       ` Alasdair G Kergon
@ 2010-10-14 12:53       ` Mike Snitzer
  2010-10-14 12:57         ` Milan Broz
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Snitzer @ 2010-10-14 12:53 UTC (permalink / raw)
  To: lvm-devel

On Thu, Oct 14 2010 at  5:04am -0400,
Zdenek Kabelac <zkabelac@redhat.com> wrote:

> Dne 13.10.2010 23:42, Alasdair G Kergon napsal(a):
> > On Wed, Oct 13, 2010 at 09:06:53PM +0200, Milan Broz wrote:
> >> I think this will break shared (external) segment module ABI.
> > 
> > Indeed - we make no guarantees for that ABI and don't even bother 
> > versioning it.  We don't believe there are any out-of-tree users.
> > 
> 
> I'd propose to drop/turn off this feature completely - targets usually cannot
> work without heavy tweaking through the rest of the code anyway. So in fact we
> rather 'pretend' there is such functionality.

I'm not following what you're saying.  There is no pretending here...

The feature fails gracefully with an informative error message.

What's the problem?

Mike



^ permalink raw reply	[flat|nested] 10+ messages in thread

* lvconvert: provide useful error when snapshot-merge target missing
  2010-10-14 12:53       ` Mike Snitzer
@ 2010-10-14 12:57         ` Milan Broz
  0 siblings, 0 replies; 10+ messages in thread
From: Milan Broz @ 2010-10-14 12:57 UTC (permalink / raw)
  To: lvm-devel

On 10/14/2010 02:53 PM, Mike Snitzer wrote:
> On Thu, Oct 14 2010 at  5:04am -0400,
> Zdenek Kabelac <zkabelac@redhat.com> wrote:
> 
>> Dne 13.10.2010 23:42, Alasdair G Kergon napsal(a):
>>> On Wed, Oct 13, 2010 at 09:06:53PM +0200, Milan Broz wrote:
>>>> I think this will break shared (external) segment module ABI.
>>>
>>> Indeed - we make no guarantees for that ABI and don't even bother 
>>> versioning it.  We don't believe there are any out-of-tree users.
>>>
>>
>> I'd propose to drop/turn off this feature completely - targets usually cannot
>> work without heavy tweaking through the rest of the code anyway. So in fact we
>> rather 'pretend' there is such functionality.
> 
> I'm not following what you're saying.  There is no pretending here...
> 
> The feature fails gracefully with an informative error message.
> 
> What's the problem?

I hope just misunderstanding:)

I think Zdenek means shared segment feature,
not your patch & snapshot merge.

If not, I just added my 2 Eurocents to confusion:-)

Milan



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-10-14 12:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-13 18:53 [PATCH] lvconvert: provide useful error when snapshot-merge target missing Mike Snitzer
2010-10-13 19:06 ` Milan Broz
2010-10-13 19:55   ` Mike Snitzer
2010-10-13 20:20     ` Milan Broz
2010-10-13 21:42   ` [PATCH] " Alasdair G Kergon
2010-10-14  9:04     ` Zdenek Kabelac
2010-10-14 11:24       ` Alasdair G Kergon
2010-10-14 12:45         ` Zdenek Kabelac
2010-10-14 12:53       ` Mike Snitzer
2010-10-14 12:57         ` Milan Broz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.