summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Rockai <prockai@redhat.com>2014-11-19 18:38:30 +0100
committerPetr Rockai <prockai@redhat.com>2014-11-20 16:51:06 +0100
commitd22ffd8c289f570b3406f684212b6e7821179710 (patch)
tree13971a73ffdf94682260a723ba8d760663e766c7
parent0050480c0eced1da98ffc76d5010cef605c776eb (diff)
downloadlvm2-d22ffd8c289f570b3406f684212b6e7821179710.tar.gz
cache: Add lv_cache_setpolicy to cache_manip.c.
-rw-r--r--lib/metadata/cache_manip.c18
-rw-r--r--lib/metadata/metadata-exported.h1
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index fb5346d64..f7b1b995d 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -395,6 +395,24 @@ int lv_is_cache_origin(const struct logical_volume *lv)
return seg && lv_is_cache(seg->lv) && !lv_is_pending_delete(seg->lv) && (seg_lv(seg, 0) == lv);
}
+int lv_cache_setpolicy(struct logical_volume *lv, struct dm_config_tree *policy)
+{
+ struct lv_segment *seg = first_seg(lv);
+ const char *name;
+
+ if (lv_is_cache(lv))
+ seg = first_seg(seg->pool_lv);
+
+ if (!(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, policy->root, 0)))
+ return_0;
+
+ if ((name = dm_config_find_str(policy->root, "policy", NULL)) &&
+ !(seg->policy_name = dm_pool_strdup(lv->vg->vgmem, name)))
+ return_0;
+
+ return 1;
+}
+
/*
* Wipe cache pool metadata area before use.
*
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index c472f41a7..d960e1fbf 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1109,6 +1109,7 @@ int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
int lv_cache_remove(struct logical_volume *cache_lv);
+int lv_cache_setpolicy(struct logical_volume *cache_lv, struct dm_config_tree *pol);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */