]> sourceware.org Git - lvm2.git/commitdiff
Refactor lvchange_tag() to call lv_change_tag() library function.
authorDave Wysochanski <dwysocha@redhat.com>
Wed, 24 Feb 2010 18:15:49 +0000 (18:15 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Wed, 24 Feb 2010 18:15:49 +0000 (18:15 +0000)
Similar refactoring to vgchange - pull out common parts and put into
library function for reuse.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
tools/lvchange.c

index fae9551f08048daa124dba253885ecef00daf3c9..954028522f75789891d181eeedaa548b871e4203 100644 (file)
@@ -493,6 +493,8 @@ struct logical_volume *lv_create_empty(const char *name,
 int set_lv(struct cmd_context *cmd, struct logical_volume *lv,
            uint64_t sectors, int value);
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag);
+
 /* Reduce the size of an LV by extents */
 int lv_reduce(struct logical_volume *lv, uint32_t extents);
 
index 52bbc46cdf7132e505dfaadb50f7266f58023ebd..2b8a1be02207c1d30ee15e0a37223ab60d992994 100644 (file)
@@ -665,6 +665,30 @@ int vg_reduce(struct volume_group *vg, char *pv_name)
        return 0;
 }
 
+int lv_change_tag(struct logical_volume *lv, const char *tag, int add_tag)
+{
+       if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
+               log_error("Logical volume %s/%s does not support tags",
+                         lv->vg->name, lv->name);
+               return 0;
+       }
+
+       if (add_tag) {
+               if (!str_list_add(lv->vg->vgmem, &lv->tags, tag)) {
+                       log_error("Failed to add tag %s to %s/%s",
+                                 tag, lv->vg->name, lv->name);
+                       return 0;
+               }
+       } else {
+               if (!str_list_del(&lv->tags, tag)) {
+                       log_error("Failed to remove tag %s from %s/%s",
+                                 tag, lv->vg->name, lv->name);
+                       return 0;
+               }
+       }
+       return 1;
+}
+
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag)
 {
        if (!(vg->fid->fmt->features & FMT_TAGS)) {
index 5118e51085ac5ca1cea0eff3d4a642ce4638c73d..2d7955e81f6a6d01b7df45e8d9fe0d6c129b0408 100644 (file)
@@ -500,25 +500,8 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
                return 0;
        }
 
-       if (!(lv->vg->fid->fmt->features & FMT_TAGS)) {
-               log_error("Logical volume %s/%s does not support tags",
-                         lv->vg->name, lv->name);
-               return 0;
-       }
-
-       if ((arg == addtag_ARG)) {
-               if (!str_list_add(cmd->mem, &lv->tags, tag)) {
-                       log_error("Failed to add tag %s to %s/%s",
-                                 tag, lv->vg->name, lv->name);
-                       return 0;
-               }
-       } else {
-               if (!str_list_del(&lv->tags, tag)) {
-                       log_error("Failed to remove tag %s from %s/%s",
-                                 tag, lv->vg->name, lv->name);
-                       return 0;
-               }
-       }
+       if (!lv_change_tag(lv, tag, arg == addtag_ARG))
+               return_0;
 
        log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
 
This page took 0.045711 seconds and 5 git commands to generate.