All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Wysochanski <dwysocha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 05/14] Refactor and add code for (lv) 'convert_lv' get function.
Date: Tue, 12 Oct 2010 11:14:22 -0400	[thread overview]
Message-ID: <1286896462.15299.16.camel@f12-work> (raw)
In-Reply-To: <87hbgs37u1.fsf@twilight.int.mornfall.net.>

On Mon, 2010-10-11 at 20:25 +0200, Petr Rockai wrote:
> Dave Wysochanski <dwysocha@redhat.com> writes:
> 
> > Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
> Reviewed-By: Petr Rockai <prockai@redhat.com>
> 
> > --- a/lib/metadata/lv.c
> > +++ b/lib/metadata/lv.c
> > @@ -18,6 +18,26 @@
> >  #include "activate.h"
> >  #include "toolcontext.h"
> >  
> > +char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
> > +{
> > +	struct lv_segment *seg;
> > +	const char *name = NULL;
> > +
> > +	if (lv->status & CONVERTING) {
> > +		if (lv->status & MIRRORED) {
> > +			seg = first_seg(lv);
> > +
> > +			/* Temporary mirror is always area_num == 0 */
> > +			if (seg_type(seg, 0) == AREA_LV &&
> > +			    is_temporary_mirror_layer(seg_lv(seg, 0)))
> > +				name = seg_lv(seg, 0)->name;
> > +		}
> > +	}
> > +	if (name)
> > +		return dm_pool_strndup(mem, name, strlen(name) + 1);
> > +	return NULL;
> > +}
> strndup/strdup again, use of "name" can be eliminated as well...
> 

Done.  I also simplified the lv->status checks:

+char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv)
+{
+       struct lv_segment *seg;
+
+       if (lv->status & (CONVERTING|MIRRORED)) {
+               seg = first_seg(lv);
+
+               /* Temporary mirror is always area_num == 0 */
+               if (seg_type(seg, 0) == AREA_LV &&
+                   is_temporary_mirror_layer(seg_lv(seg, 0)))
+                       return dm_pool_strdup(mem, seg_lv(seg, 0)->name);
+       }
+       return NULL;
+}


> > +
> >  char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv)
> >  {
> >  	const char *name;
> 
> > --- a/lib/metadata/lv.h
> > +++ b/lib/metadata/lv.h
> > @@ -55,5 +55,6 @@ char *lv_tags_dup(const struct logical_volume *lv);
> >  char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv);
> >  uint64_t lv_origin_size(const struct logical_volume *lv);
> >  char *lv_move_pv_dup(struct dm_pool *mem, const struct logical_volume *lv);
> > +char *lv_convert_lv_dup(struct dm_pool *mem, const struct logical_volume *lv);
> >  
> >  #endif
> 
> > --- a/lib/report/properties.c
> > +++ b/lib/report/properties.c
> > @@ -131,7 +131,7 @@ GET_LV_NUM_PROPERTY_FN(origin_size, lv_origin_size(lv))
> >  #define _copy_percent_set _not_implemented_set
> >  GET_LV_STR_PROPERTY_FN(move_pv, lv_move_pv_dup(lv->vg->vgmem, lv))
> >  #define _move_pv_set _not_implemented_set
> > -#define _convert_lv_get _not_implemented_get
> > +GET_LV_STR_PROPERTY_FN(convert_lv, lv_convert_lv_dup(lv->vg->vgmem, lv))
> >  #define _convert_lv_set _not_implemented_set
> >  GET_LV_STR_PROPERTY_FN(lv_tags, lv_tags_dup(lv))
> >  #define _lv_tags_set _not_implemented_set
> 
> > --- a/lib/report/report.c
> > +++ b/lib/report/report.c
> > @@ -392,19 +392,8 @@ static int _convertlv_disp(struct dm_report *rh, struct dm_pool *mem __attribute
> >  {
> >  	const struct logical_volume *lv = (const struct logical_volume *) data;
> >  	const char *name = NULL;
> > -	struct lv_segment *seg;
> > -
> > -	if (lv->status & CONVERTING) {
> > -		if (lv->status & MIRRORED) {
> > -			seg = first_seg(lv);
> > -
> > -			/* Temporary mirror is always area_num == 0 */
> > -			if (seg_type(seg, 0) == AREA_LV &&
> > -			    is_temporary_mirror_layer(seg_lv(seg, 0)))
> > -				name = seg_lv(seg, 0)->name;
> > -		}
> > -	}
> >  
> > +	name = lv_convert_lv_dup(mem, lv);
> >  	if (name)
> >  		return dm_report_field_string(rh, field, &name);
> 
> Ok. Although we don't need a string duplicate here. On the other hand,
> having a non-dup version of the above code and the dup version
> implemented in terms of that would be overkill, I guess...
> 
> Yours,
>    Petr.
> 
> --
> lvm-devel mailing list
> lvm-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/lvm-devel




  reply	other threads:[~2010-10-12 15:14 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-11 15:14 [PATCH 00/14] Add lvm lv properties and lvm2app interfaces for pv/vg/lv Dave Wysochanski
2010-10-11 15:14 ` [PATCH 01/14] Add some lv 'get' functions that require no refactoring Dave Wysochanski
2010-10-11 18:00   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 02/14] Refactor and add code for (lv) 'lv_path' get function Dave Wysochanski
2010-10-11 18:09   ` Petr Rockai
2010-10-12 14:29     ` Dave Wysochanski
2010-10-12 15:52       ` Petr Rockai
2010-10-11 15:14 ` [PATCH 03/14] Refactor and add code for (lv) 'origin_size' " Dave Wysochanski
2010-10-11 18:13   ` Petr Rockai
2010-10-12 14:22     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 04/14] Refactor and add code for (lv) 'move_pv' " Dave Wysochanski
2010-10-11 18:21   ` Petr Rockai
2010-10-12 14:52     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 05/14] Refactor and add code for (lv) 'convert_lv' " Dave Wysochanski
2010-10-11 18:25   ` Petr Rockai
2010-10-12 15:14     ` Dave Wysochanski [this message]
2010-10-12 15:55       ` Petr Rockai
2010-10-12 16:09         ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 06/14] Refactor and add code for (lv) 'lv_kernel_{major|minor}' get functions Dave Wysochanski
2010-10-11 18:27   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 07/14] Refactor and add code for (lv) 'mirror_log' get function Dave Wysochanski
2010-10-11 18:29   ` Petr Rockai
2010-10-12 15:28     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 08/14] Refactor and add code for (lv) 'modules' " Dave Wysochanski
2010-10-11 15:14 ` [PATCH 09/14] Refactor and add code for (lv) 'lv_name' " Dave Wysochanski
2010-10-11 18:36   ` Petr Rockai
2010-10-12 15:43     ` Dave Wysochanski
2010-10-11 15:14 ` [PATCH 10/14] Refactor and add code for (lv) 'lv_origin' " Dave Wysochanski
2010-10-11 15:14 ` [PATCH 11/14] Add lvm_vg_get_property() generic vg property function Dave Wysochanski
2010-10-12  8:40   ` Zdenek Kabelac
2010-10-12 10:51     ` Petr Rockai
2010-10-12 11:05     ` Petr Rockai
2010-10-15 14:18       ` Dave Wysochanski
2010-10-12 11:04   ` Petr Rockai
2010-10-11 15:14 ` [PATCH 12/14] Add lvm_pv_get_property() generic function to obtain value of any pv property Dave Wysochanski
2010-10-11 15:14 ` [PATCH 13/14] Add lvm_lv_get_property() generic function to obtain value of any lv property Dave Wysochanski
2010-10-11 15:14 ` [PATCH 14/14] Add interactive tests for lvm_{pv|vg|lv}_get_property() 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=1286896462.15299.16.camel@f12-work \
    --to=dwysocha@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.