All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Rockai <prockai@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 2/8] Refactor and add code for (lv) 'lv_origin' get function.
Date: Wed, 20 Oct 2010 23:41:40 +0200	[thread overview]
Message-ID: <8762wwa6ej.fsf@twilight.int.mornfall.net.> (raw)
In-Reply-To: <1287487975-26572-3-git-send-email-dwysocha@redhat.com> (Dave Wysochanski's message of "Tue, 19 Oct 2010 07:32:49 -0400")

Dave Wysochanski <dwysocha@redhat.com> writes:

> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

> --- a/lib/metadata/lv.c
> +++ b/lib/metadata/lv.c
> @@ -20,6 +20,13 @@
>  #include "segtype.h"
>  #include "str_list.h"
>  
> +char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv)
> +{
> +	if (lv_is_cow(lv))
> +		return lv_name_dup(mem, origin_from_cow(lv));
> +	return NULL;
> +}
> +
>  char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv)
>  {
>  	return dm_pool_strdup(mem, lv->name);

> --- a/lib/metadata/lv.h
> +++ b/lib/metadata/lv.h
> @@ -61,5 +61,6 @@ int lv_kernel_minor(const struct logical_volume *lv);
>  char *lv_mirror_log_dup(struct dm_pool *mem, const struct logical_volume *lv);
>  char *lv_modules_dup(struct dm_pool *mem, const struct logical_volume *lv);
>  char *lv_name_dup(struct dm_pool *mem, const struct logical_volume *lv);
> +char *lv_origin_dup(struct dm_pool *mem, const struct logical_volume *lv);
>  
>  #endif
> diff --git a/lib/report/properties.c b/lib/report/properties.c
> index 8228193..250c7c9 100644
> --- a/lib/report/properties.c
> +++ b/lib/report/properties.c
> @@ -121,7 +121,7 @@ GET_LV_NUM_PROPERTY_FN(lv_size, lv->size * SECTOR_SIZE)
>  #define _lv_size_set _not_implemented_set
>  GET_LV_NUM_PROPERTY_FN(seg_count, dm_list_size(&lv->segments))
>  #define _seg_count_set _not_implemented_set
> -#define _origin_get _not_implemented_get
> +GET_LV_STR_PROPERTY_FN(origin, lv_origin_dup(lv->vg->vgmem, lv))
>  #define _origin_set _not_implemented_set
>  GET_LV_NUM_PROPERTY_FN(origin_size, lv_origin_size(lv))
>  #define _origin_size_set _not_implemented_set

> --- a/lib/report/report.c
> +++ b/lib/report/report.c
> @@ -356,9 +356,10 @@ static int _origin_disp(struct dm_report *rh, struct dm_pool *mem,
>  			const void *data, void *private)
>  {
>  	const struct logical_volume *lv = (const struct logical_volume *) data;
> +	const char *name;
>  
> -	if (lv_is_cow(lv))
> -		return _lvname_disp(rh, mem, field, origin_from_cow(lv), private);
> +	if ((name = lv_origin_dup(mem, lv)))
> +		return dm_report_field_string(rh, field, &name);
>  
>  	dm_report_field_set_value(field, "", NULL);
>  	return 1;

Now, this code is not equivalent for those cases where the origin is not
visible. I am not sure that can ever happen, though. I am also not sure
which behaviour is better. But it's something worth double-checking.

Other than this, looks OK.

Reviewed-by: Petr Rockai <prockai@redhat.com>

Yours,
   Petr.



  reply	other threads:[~2010-10-20 21:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-19 11:32 [PATCH 00/08] Add lvm lv properties for lvm2app, return struct Dave Wysochanski
2010-10-19 11:32 ` [PATCH 1/8] Refactor and add code for (lv) 'lv_name' get function Dave Wysochanski
2010-10-20 21:31   ` Petr Rockai
2010-10-19 11:32 ` [PATCH 2/8] Refactor and add code for (lv) 'lv_origin' " Dave Wysochanski
2010-10-20 21:41   ` Petr Rockai [this message]
2010-10-21 14:38     ` Dave Wysochanski
2010-10-19 11:32 ` [PATCH 3/8] Add lv_read_ahead and lv_kernel_read_ahead 'get' functions Dave Wysochanski
2010-10-20 21:43   ` Petr Rockai
2010-10-19 11:32 ` [PATCH 4/8] Rename fields in lvm_property_type Dave Wysochanski
2010-10-20 21:45   ` Petr Rockai
2010-10-19 11:32 ` [PATCH 5/8] Add lvm_vg_get_property() generic vg property function Dave Wysochanski
2010-10-20 21:51   ` Petr Rockai
2010-10-21 18:39     ` Dave Wysochanski
2010-10-24 12:04       ` Petr Rockai
2010-10-25 13:55         ` Dave Wysochanski
2010-10-19 11:32 ` [PATCH 6/8] Add lvm_pv_get_property() generic function to obtain value of any pv property Dave Wysochanski
2010-10-20 21:54   ` Petr Rockai
2010-10-19 11:32 ` [PATCH 7/8] Add lvm_lv_get_property() generic function to obtain value of any lv property Dave Wysochanski
2010-10-20 21:55   ` Petr Rockai
2010-10-19 11:32 ` [PATCH 8/8] Add interactive tests for lvm_{pv|vg|lv}_get_property() Dave Wysochanski
2010-10-20 21:57   ` Petr Rockai
  -- strict thread matches above, loose matches on Subject: below --
2010-10-19  4:02 [PATCH 00/08] Add lvm lv properties for lvm2app Dave Wysochanski
2010-10-19  4:02 ` [PATCH 2/8] Refactor and add code for (lv) 'lv_origin' get function Dave Wysochanski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8762wwa6ej.fsf@twilight.int.mornfall.net. \
    --to=prockai@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.