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);
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)) {
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);