master - cleanup: indent spaces
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a508786664f225...
Commit: a508786664f225d22c3549739abe7a749fc10960
Parent: c651c614ec758702cc63a8ac96aac1ddfd45a067
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 14 20:46:55 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:36:53 2014 +0100
cleanup: indent spaces
---
libdm/libdevmapper.h | 66 ++++++++++++++++++++++++------------------------
libdm/libdm-deptree.c | 52 +++++++++++++++++++-------------------
2 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index cbd86d4..dd57457 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -557,10 +557,10 @@ struct dm_tree_node *dm_tree_add_new_dev_with_udev_flags(struct dm_tree *tree,
* Set major and minor to 0 or uuid to NULL to get the root node.
*/
struct dm_tree_node *dm_tree_find_node(struct dm_tree *tree,
- uint32_t major,
- uint32_t minor);
+ uint32_t major,
+ uint32_t minor);
struct dm_tree_node *dm_tree_find_node_by_uuid(struct dm_tree *tree,
- const char *uuid);
+ const char *uuid);
/*
* Use this to walk through all children of a given node.
@@ -592,8 +592,8 @@ int dm_tree_node_num_children(const struct dm_tree_node *node, uint32_t inverted
* Ignores devices that don't have a uuid starting with uuid_prefix.
*/
int dm_tree_deactivate_children(struct dm_tree_node *dnode,
- const char *uuid_prefix,
- size_t uuid_prefix_len);
+ const char *uuid_prefix,
+ size_t uuid_prefix_len);
/*
* Preload/create a device plus all dependencies.
* Ignores devices that don't have a uuid starting with uuid_prefix.
@@ -615,8 +615,8 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
* Ignores devices that don't have a uuid starting with uuid_prefix.
*/
int dm_tree_suspend_children(struct dm_tree_node *dnode,
- const char *uuid_prefix,
- size_t uuid_prefix_len);
+ const char *uuid_prefix,
+ size_t uuid_prefix_len);
/*
* Skip the filesystem sync when suspending.
@@ -646,36 +646,36 @@ void dm_tree_retry_remove(struct dm_tree_node *dnode);
* Returns 1 if the tree walk has to be aborted.
*/
int dm_tree_children_use_uuid(struct dm_tree_node *dnode,
- const char *uuid_prefix,
- size_t uuid_prefix_len);
+ const char *uuid_prefix,
+ size_t uuid_prefix_len);
/*
* Construct tables for new nodes before activating them.
*/
int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode,
- uint64_t size,
- const char *origin_uuid);
+ uint64_t size,
+ const char *origin_uuid);
int dm_tree_node_add_snapshot_target(struct dm_tree_node *node,
- uint64_t size,
- const char *origin_uuid,
- const char *cow_uuid,
- int persistent,
- uint32_t chunk_size);
+ uint64_t size,
+ const char *origin_uuid,
+ const char *cow_uuid,
+ int persistent,
+ uint32_t chunk_size);
int dm_tree_node_add_snapshot_merge_target(struct dm_tree_node *node,
- uint64_t size,
- const char *origin_uuid,
- const char *cow_uuid,
- const char *merge_uuid,
- uint32_t chunk_size);
+ uint64_t size,
+ const char *origin_uuid,
+ const char *cow_uuid,
+ const char *merge_uuid,
+ uint32_t chunk_size);
int dm_tree_node_add_error_target(struct dm_tree_node *node,
- uint64_t size);
+ uint64_t size);
int dm_tree_node_add_zero_target(struct dm_tree_node *node,
- uint64_t size);
+ uint64_t size);
int dm_tree_node_add_linear_target(struct dm_tree_node *node,
- uint64_t size);
+ uint64_t size);
int dm_tree_node_add_striped_target(struct dm_tree_node *node,
- uint64_t size,
- uint32_t stripe_size);
+ uint64_t size,
+ uint32_t stripe_size);
#define DM_CRYPT_IV_DEFAULT UINT64_C(-1) /* iv_offset == seg offset */
/*
@@ -692,7 +692,7 @@ int dm_tree_node_add_crypt_target(struct dm_tree_node *node,
uint64_t iv_offset,
const char *key);
int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
- uint64_t size);
+ uint64_t size);
/* Mirror log flags */
#define DM_NOSYNC 0x00000001 /* Known already in sync */
@@ -701,11 +701,11 @@ int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
#define DM_CORELOG 0x00000008 /* In-memory log */
int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
- uint32_t region_size,
- unsigned clustered,
- const char *log_uuid,
- unsigned area_count,
- uint32_t flags);
+ uint32_t region_size,
+ unsigned clustered,
+ const char *log_uuid,
+ unsigned area_count,
+ uint32_t flags);
int dm_tree_node_add_raid_target(struct dm_tree_node *node,
uint64_t size,
@@ -1149,7 +1149,7 @@ void dm_hash_remove(struct dm_hash_table *t, const char *key);
void *dm_hash_lookup_binary(struct dm_hash_table *t, const void *key, uint32_t len);
int dm_hash_insert_binary(struct dm_hash_table *t, const void *key, uint32_t len,
- void *data);
+ void *data);
void dm_hash_remove_binary(struct dm_hash_table *t, const void *key, uint32_t len);
unsigned dm_hash_get_num_entries(struct dm_hash_table *t);
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 0834f38..6d45e08 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -538,7 +538,7 @@ static struct dm_tree_node *_find_dm_tree_node(struct dm_tree *dtree,
dev_t dev = MKDEV((dev_t)major, minor);
return dm_hash_lookup_binary(dtree->devs, (const char *) &dev,
- sizeof(dev));
+ sizeof(dev));
}
static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
@@ -707,8 +707,8 @@ static int _children_suspended(struct dm_tree_node *node,
* Set major and minor to zero for root of tree.
*/
struct dm_tree_node *dm_tree_find_node(struct dm_tree *dtree,
- uint32_t major,
- uint32_t minor)
+ uint32_t major,
+ uint32_t minor)
{
if (!major && !minor)
return &dtree->root;
@@ -720,7 +720,7 @@ struct dm_tree_node *dm_tree_find_node(struct dm_tree *dtree,
* Set uuid to NULL for root of tree.
*/
struct dm_tree_node *dm_tree_find_node_by_uuid(struct dm_tree *dtree,
- const char *uuid)
+ const char *uuid)
{
if (!uuid || !*uuid)
return &dtree->root;
@@ -2801,8 +2801,8 @@ static struct load_segment *_add_segment(struct dm_tree_node *dnode, unsigned ty
}
int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode,
- uint64_t size,
- const char *origin_uuid)
+ uint64_t size,
+ const char *origin_uuid)
{
struct load_segment *seg;
struct dm_tree_node *origin_node;
@@ -2832,12 +2832,12 @@ int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode,
}
static int _add_snapshot_target(struct dm_tree_node *node,
- uint64_t size,
- const char *origin_uuid,
- const char *cow_uuid,
- const char *merge_uuid,
- int persistent,
- uint32_t chunk_size)
+ uint64_t size,
+ const char *origin_uuid,
+ const char *cow_uuid,
+ const char *merge_uuid,
+ int persistent,
+ uint32_t chunk_size)
{
struct load_segment *seg;
struct dm_tree_node *origin_node, *cow_node, *merge_node;
@@ -2950,7 +2950,7 @@ int dm_get_status_snapshot(struct dm_pool *mem, const char *params,
}
int dm_tree_node_add_error_target(struct dm_tree_node *node,
- uint64_t size)
+ uint64_t size)
{
if (!_add_segment(node, SEG_ERROR, size))
return_0;
@@ -2959,7 +2959,7 @@ int dm_tree_node_add_error_target(struct dm_tree_node *node,
}
int dm_tree_node_add_zero_target(struct dm_tree_node *node,
- uint64_t size)
+ uint64_t size)
{
if (!_add_segment(node, SEG_ZERO, size))
return_0;
@@ -2968,7 +2968,7 @@ int dm_tree_node_add_zero_target(struct dm_tree_node *node,
}
int dm_tree_node_add_linear_target(struct dm_tree_node *node,
- uint64_t size)
+ uint64_t size)
{
if (!_add_segment(node, SEG_LINEAR, size))
return_0;
@@ -2977,8 +2977,8 @@ int dm_tree_node_add_linear_target(struct dm_tree_node *node,
}
int dm_tree_node_add_striped_target(struct dm_tree_node *node,
- uint64_t size,
- uint32_t stripe_size)
+ uint64_t size,
+ uint32_t stripe_size)
{
struct load_segment *seg;
@@ -3013,11 +3013,11 @@ int dm_tree_node_add_crypt_target(struct dm_tree_node *node,
}
int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
- uint32_t region_size,
- unsigned clustered,
- const char *log_uuid,
- unsigned area_count,
- uint32_t flags)
+ uint32_t region_size,
+ unsigned clustered,
+ const char *log_uuid,
+ unsigned area_count,
+ uint32_t flags)
{
struct dm_tree_node *log_node = NULL;
struct load_segment *seg;
@@ -3065,7 +3065,7 @@ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
}
int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
- uint64_t size)
+ uint64_t size)
{
if (!_add_segment(node, SEG_MIRRORED, size))
return_0;
@@ -3887,9 +3887,9 @@ static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct
}
int dm_tree_node_add_target_area(struct dm_tree_node *node,
- const char *dev_name,
- const char *uuid,
- uint64_t offset)
+ const char *dev_name,
+ const char *uuid,
+ uint64_t offset)
{
struct load_segment *seg;
struct stat info;
10 years, 3 months
master - cache: using unsigned argc
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c651c614ec7587...
Commit: c651c614ec758702cc63a8ac96aac1ddfd45a067
Parent: da268eb4cc297d42d123821df3ce441fa4bec293
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 14 22:33:09 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:36:53 2014 +0100
cache: using unsigned argc
Convert using unsigned for _argc.
---
lib/cache_segtype/cache.c | 22 ++++++++++------------
lib/metadata/metadata-exported.h | 4 ++--
libdm/libdevmapper.h | 4 ++--
libdm/libdm-deptree.c | 17 +++++++++--------
4 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 78a23d7..90ed40e 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -96,8 +96,7 @@ static int _cache_pool_text_import(struct lv_segment *seg,
if (!dm_config_has_node(sn, "core_argv"))
return SEG_LOG_ERROR("not all core arguments defined in");
- if (!dm_config_get_uint32(sn, "core_argc",
- (uint32_t *)&seg->core_argc))
+ if (!dm_config_get_uint32(sn, "core_argc", &seg->core_argc))
return SEG_LOG_ERROR("Unable to read core_argc in");
str = dm_config_find_str(sn, "core_argv", NULL);
@@ -110,8 +109,8 @@ static int _cache_pool_text_import(struct lv_segment *seg,
return_0;
if (str &&
(!(argv_str = dm_pool_strdup(mem, str)) ||
- (seg->core_argc != dm_split_words(argv_str, seg->core_argc,
- 0, seg->core_argv))))
+ ((int)seg->core_argc != dm_split_words(argv_str, seg->core_argc,
+ 0, seg->core_argv))))
return SEG_LOG_ERROR("core_argc and core_argv do"
" not match in");
}
@@ -135,8 +134,7 @@ static int _cache_pool_text_import(struct lv_segment *seg,
return SEG_LOG_ERROR("policy_name must be a string in");
seg->policy_name = dm_pool_strdup(mem, str);
- if (!dm_config_get_uint32(sn, "policy_argc",
- (uint32_t *)&seg->policy_argc))
+ if (!dm_config_get_uint32(sn, "policy_argc", &seg->policy_argc))
return SEG_LOG_ERROR("Unable to read policy_argc in");
str = dm_config_find_str(sn, "policy_argv", NULL);
@@ -149,9 +147,9 @@ static int _cache_pool_text_import(struct lv_segment *seg,
return_0;
if (str &&
(!(argv_str = dm_pool_strdup(mem, str)) ||
- (seg->policy_argc != dm_split_words(argv_str,
- seg->policy_argc,
- 0, seg->policy_argv))))
+ ((int)seg->policy_argc != dm_split_words(argv_str,
+ seg->policy_argc,
+ 0, seg->policy_argv))))
return SEG_LOG_ERROR("policy_argc and policy_argv do"
" not match in");
}
@@ -176,7 +174,7 @@ static int _cache_pool_text_import_area_count(const struct dm_config_node *sn,
static int _cache_pool_text_export(const struct lv_segment *seg,
struct formatter *f)
{
- int i;
+ unsigned i;
char buf[256]; //FIXME: IS THERE AN 'outf' THAT DOESN'T DO NEWLINE?!?
uint32_t feature_flags = seg->feature_flags;
@@ -199,7 +197,7 @@ static int _cache_pool_text_export(const struct lv_segment *seg,
}
if (seg->core_argc) {
- outf(f, "core_argc = %d", seg->core_argc);
+ outf(f, "core_argc = %u", seg->core_argc);
outf(f, "core_argv = \"");
for (i = 0; i < seg->core_argc; i++)
outf(f, "%s%s", i ? " " : "", seg->core_argv[i]);
@@ -208,7 +206,7 @@ static int _cache_pool_text_export(const struct lv_segment *seg,
if (seg->policy_name) {
outf(f, "policy_name = \"%s\"", seg->policy_name);
- outf(f, "policy_argc = %d", seg->policy_argc);
+ outf(f, "policy_argc = %u", seg->policy_argc);
buf[0] = '\0';
for (i = 0; i < seg->policy_argc; i++)
sprintf(buf, "%s%s", i ? " " : "", seg->policy_argv[i]);
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 6ca4309..438f5b2 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -397,10 +397,10 @@ struct lv_segment {
uint32_t device_id; /* For thin, 24bit */
uint32_t feature_flags; /* For cache */
- int core_argc; /* For cache */
+ unsigned core_argc; /* For cache */
char **core_argv; /* For cache */
char *policy_name; /* For cache */
- int policy_argc; /* For cache */
+ unsigned policy_argc; /* For cache */
char **policy_argv; /* For cache */
struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 112ec27..cbd86d4 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -772,10 +772,10 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
const char *origin_uuid,
uint32_t chunk_size,
uint32_t feature_flags, /* DM_CACHE_FEATURE_* */
- int core_argc,
+ unsigned core_argc,
char **core_argv,
char *policy_name,
- int policy_argc,
+ unsigned policy_argc,
char **policy_argv);
/*
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index d2a54eb..0834f38 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -172,10 +172,10 @@ struct load_segment {
uint32_t flags; /* Mirror + raid + Cache */
char *uuid; /* Clustered mirror log */
- int core_argc; /* Cache */
+ unsigned core_argc; /* Cache */
char **core_argv; /* Cache */
char *policy_name; /* Cache */
- int policy_argc; /* Cache */
+ unsigned policy_argc; /* Cache */
char **policy_argv; /* Cache */
const char *cipher; /* Crypt */
@@ -2274,7 +2274,8 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
struct load_segment *seg,
char *params, size_t paramsize)
{
- int i, pos = 0;
+ int pos = 0;
+ unsigned i = 0;
unsigned feature_count;
struct seg_area *area;
char data[DM_FORMAT_DEV_BUFSIZE];
@@ -2302,7 +2303,7 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
/* Features */
feature_count = hweight32(seg->flags);
- EMIT_PARAMS(pos, " %d", feature_count);
+ EMIT_PARAMS(pos, " %u", feature_count);
if (seg->flags & DM_CACHE_FEATURE_WRITETHROUGH)
EMIT_PARAMS(pos, " writethrough");
else if (seg->flags & DM_CACHE_FEATURE_WRITEBACK)
@@ -2310,7 +2311,7 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
/* Core Arguments (like 'migration_threshold') */
if (seg->core_argc) {
- EMIT_PARAMS(pos, " %d", seg->core_argc);
+ EMIT_PARAMS(pos, " %u", seg->core_argc);
for (i = 0; i < seg->core_argc; i++)
EMIT_PARAMS(pos, " %s", seg->core_argv[i]);
}
@@ -2319,7 +2320,7 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
if (!seg->policy_name)
EMIT_PARAMS(pos, " default 0");
else {
- EMIT_PARAMS(pos, " %s %d", seg->policy_name, seg->policy_argc);
+ EMIT_PARAMS(pos, " %s %u", seg->policy_name, seg->policy_argc);
if (seg->policy_argc % 2) {
log_error(INTERNAL_ERROR
"Cache policy arguments must be in "
@@ -3206,10 +3207,10 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
const char *origin_uuid,
uint32_t chunk_size,
uint32_t feature_flags, /* DM_CACHE_FEATURE_* */
- int core_argc,
+ unsigned core_argc,
char **core_argv,
char *policy_name,
- int policy_argc,
+ unsigned policy_argc,
char **policy_argv)
{
int i;
10 years, 3 months
master - cache: convert libdm to use plain function call
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da268eb4cc297d...
Commit: da268eb4cc297d42d123821df3ce441fa4bec293
Parent: 7ec8e691c40e0b42a328366e3201cf4264108434
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 14 22:09:39 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:36:53 2014 +0100
cache: convert libdm to use plain function call
Avoid introducing libdm structure allocated in library user.
Use direct call with all currently supported args.
When new arg is added, new function will cover it.
---
lib/cache_segtype/cache.c | 37 ++++++++++++++++---------------------
libdm/libdevmapper.h | 29 ++++++++++-------------------
libdm/libdm-deptree.c | 44 +++++++++++++++++++++++++++-----------------
3 files changed, 53 insertions(+), 57 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 2217922..78a23d7 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -359,34 +359,29 @@ static int _cache_add_target_line(struct dev_manager *dm,
struct dm_tree_node *node, uint64_t len,
uint32_t *pvmove_mirror_count __attribute__((unused)))
{
- struct logical_volume *data, *metadata, *origin;
struct lv_segment *cache_pool_seg = first_seg(seg->pool_lv);
- struct dm_tree_node_cache_params params = {
- .chunk_size = cache_pool_seg->chunk_size,
-
- /* Cache features, core args, and policy are stored in the cache_pool */
- .feature_flags = cache_pool_seg->feature_flags,
- .core_argc = cache_pool_seg->core_argc,
- .core_argv = cache_pool_seg->core_argv,
- .policy_name = cache_pool_seg->policy_name,
- .policy_argc = cache_pool_seg->policy_argc,
- .policy_argv = cache_pool_seg->policy_argv
- };
-
- data = seg_lv(cache_pool_seg, 0);
- metadata = cache_pool_seg->metadata_lv;
- origin = seg_lv(seg, 0);
-
- if (!(params.data_uuid = build_dm_uuid(mem, data->lvid.s, NULL)))
+ char *metadata_uuid, *data_uuid, *origin_uuid;
+
+ if (!(metadata_uuid = build_dm_uuid(mem, cache_pool_seg->metadata_lv->lvid.s, NULL)))
return_0;
- if (!(params.metadata_uuid = build_dm_uuid(mem, metadata->lvid.s, NULL)))
+ if (!(data_uuid = build_dm_uuid(mem, seg_lv(cache_pool_seg, 0)->lvid.s, NULL)))
return_0;
- if (!(params.origin_uuid = build_dm_uuid(mem, origin->lvid.s, NULL)))
+ if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0)->lvid.s, NULL)))
return_0;
- if (!dm_tree_node_add_cache_target(node, len, ¶ms))
+ if (!dm_tree_node_add_cache_target(node, len,
+ metadata_uuid,
+ data_uuid,
+ origin_uuid,
+ cache_pool_seg->chunk_size,
+ cache_pool_seg->feature_flags,
+ cache_pool_seg->core_argc,
+ cache_pool_seg->core_argv,
+ cache_pool_seg->policy_name,
+ cache_pool_seg->policy_argc,
+ cache_pool_seg->policy_argv))
return_0;
return add_areas_line(dm, seg, node, 0u, seg->area_count);
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index b50501e..112ec27 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -764,28 +764,19 @@ int dm_tree_node_add_raid_target_with_params(struct dm_tree_node *node,
/* Cache feature_flags */
#define DM_CACHE_FEATURE_WRITEBACK 0x00000001
#define DM_CACHE_FEATURE_WRITETHROUGH 0x00000002
-struct dm_tree_node_cache_params {
- uint32_t version;
-
- uint32_t chunk_size;
- uint32_t feature_flags; /* DM_CACHE_FEATURE_* */
-
- int core_argc;
- char **core_argv;
-
- char *policy_name;
- int policy_argc;
- char **policy_argv;
-
- const char *data_uuid;
- const char *metadata_uuid;
- const char *origin_uuid;
- /* 'version == 0' end */
-};
int dm_tree_node_add_cache_target(struct dm_tree_node *node,
uint64_t size,
- struct dm_tree_node_cache_params *p);
+ const char *metadata_uuid,
+ const char *data_uuid,
+ const char *origin_uuid,
+ uint32_t chunk_size,
+ uint32_t feature_flags, /* DM_CACHE_FEATURE_* */
+ int core_argc,
+ char **core_argv,
+ char *policy_name,
+ int policy_argc,
+ char **policy_argv);
/*
* Replicator operation mode
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 72c30a2..d2a54eb 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2284,19 +2284,18 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
/* Metadata Dev */
if (!_build_dev_string(metadata, sizeof(metadata), seg->metadata))
return_0;
- EMIT_PARAMS(pos, " %s", metadata);
/* Cache Dev */
if (!_build_dev_string(data, sizeof(origin), seg->pool))
return_0;
- EMIT_PARAMS(pos, " %s", data);
/* Origin Dev */
dm_list_iterate_items(area, &seg->areas)
break; /* There is only ever 1 area */
if (!_build_dev_string(origin, sizeof(data), area->dev_node))
return_0;
- EMIT_PARAMS(pos, " %s", origin);
+
+ EMIT_PARAMS(pos, " %s %s %s", metadata, data, origin);
/* Chunk size */
EMIT_PARAMS(pos, " %u", seg->chunk_size);
@@ -3202,7 +3201,16 @@ bad:
int dm_tree_node_add_cache_target(struct dm_tree_node *node,
uint64_t size,
- struct dm_tree_node_cache_params *p)
+ const char *metadata_uuid,
+ const char *data_uuid,
+ const char *origin_uuid,
+ uint32_t chunk_size,
+ uint32_t feature_flags, /* DM_CACHE_FEATURE_* */
+ int core_argc,
+ char **core_argv,
+ char *policy_name,
+ int policy_argc,
+ char **policy_argv)
{
int i;
struct load_segment *seg = NULL;
@@ -3218,33 +3226,35 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
return_0;
if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree,
- p->data_uuid))) {
- log_error("Missing cache's data uuid, %s",
- p->data_uuid);
+ data_uuid))) {
+ log_error("Missing cache's data uuid %s.",
+ data_uuid);
return 0;
}
if (!_link_tree_nodes(node, seg->pool))
return_0;
if (!(seg->metadata = dm_tree_find_node_by_uuid(node->dtree,
- p->metadata_uuid))) {
- log_error("Missing cache's metadata uuid, %s",
- p->metadata_uuid);
+ metadata_uuid))) {
+ log_error("Missing cache's metadata uuid %s.",
+ metadata_uuid);
return 0;
}
if (!_link_tree_nodes(node, seg->metadata))
return_0;
- seg->chunk_size = p->chunk_size;
+ seg->chunk_size = chunk_size;
+
+ seg->flags = feature_flags;
- seg->flags = p->feature_flags;
+ /* FIXME: validation missing */
- seg->core_argc = p->core_argc;
- seg->core_argv = p->core_argv;
+ seg->core_argc = core_argc;
+ seg->core_argv = core_argv;
- seg->policy_name = p->policy_name;
- seg->policy_argc = p->policy_argc;
- seg->policy_argv = p->policy_argv;
+ seg->policy_name = policy_name;
+ seg->policy_argc = policy_argc;
+ seg->policy_argv = policy_argv;
return 1;
}
10 years, 3 months
master - libdm: use 64bit type for raid index
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7ec8e691c40e0b...
Commit: 7ec8e691c40e0b42a328366e3201cf4264108434
Parent: f0f4248333a6dfa017d84dfd7bb298a3321a6ec2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Feb 14 21:13:41 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:36:37 2014 +0100
libdm: use 64bit type for raid index
Used properly signed 64bit constant for shifting.
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 827e994..3d7c734 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.85 -
===================================
+ Use correctly signed 64b constant when working with raid volumes.
Exit dmeventd with pidfile cleanup instead of raising SIGKILL on DIE request.
Add new DM_EVENT_GET_PARAMETERS request to dmeventd protocol.
Do not use systemd's reload for dmeventd restart, use dmeventd -R instead.
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 32d53be..72c30a2 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2243,11 +2243,11 @@ static int _raid_emit_segment_line(struct dm_task *dmt, uint32_t major,
EMIT_PARAMS(pos, " region_size %u", seg->region_size);
for (i = 0; i < (seg->area_count / 2); i++)
- if (seg->rebuilds & (1 << i))
+ if (seg->rebuilds & (1ULL << i))
EMIT_PARAMS(pos, " rebuild %u", i);
for (i = 0; i < (seg->area_count / 2); i++)
- if (seg->writemostly & (1 << i))
+ if (seg->writemostly & (1ULL << i))
EMIT_PARAMS(pos, " write_mostly %u", i);
if (seg->writebehind)
10 years, 3 months
master - activation: drop test r/w vg state for activing LV
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0f4248333a6df...
Commit: f0f4248333a6dfa017d84dfd7bb298a3321a6ec2
Parent: fa4812bf7b336cf1a301ec7218f905894422e61e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Feb 13 14:42:29 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sat Feb 15 11:34:54 2014 +0100
activation: drop test r/w vg state for activing LV
VG status read/write is meant to influence only VG metadata.
It's not related to the read/write status of the LV itself.
---
WHATS_NEW | 1 +
lib/activate/dev_manager.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e2a33b5..17b79ba 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Do not use VG read/write state for LV read/write state.
Use --ignoreskippedcluster in activation systemd units if use_lvmetad=0.
Allow approximate allocation when specifying size in percentage terms.
Add basic LVM support for cache[pool] segment types.
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 9a10e74..fe36149 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -63,7 +63,7 @@ struct lv_layer {
int read_only_lv(struct logical_volume *lv, struct lv_activate_opts *laopts)
{
- return (laopts->read_only || !(lv->vg->status & LVM_WRITE) || !(lv->status & LVM_WRITE));
+ return (laopts->read_only || !(lv->status & LVM_WRITE));
}
/*
10 years, 3 months
master - cache: Fix cache LV not being instantiated in kernel
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa4812bf7b336c...
Commit: fa4812bf7b336cf1a301ec7218f905894422e61e
Parent: 554159d519ba5c523d506785d61d10374456a020
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Feb 14 16:03:23 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Feb 14 16:04:31 2014 -0600
cache: Fix cache LV not being instantiated in kernel
When an origin exists and the 'lvcreate' command is used to create
a cache pool + cache LV, the table is loaded into the kernel but
never instantiated (suspend/resume was never called). A user running
LVM commands would never know that the kernel did not have the
proper state unless they also ran the dmsetup 'table/status' command.
The solution is to suspend/resume the cache LV to make the loaded
tables become active.
---
lib/metadata/lv_manip.c | 20 +++++++++++++++++++-
test/shell/lvcreate-cache.sh | 2 ++
2 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d38dd7c..6b4c9a8 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6282,7 +6282,25 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (lp->temporary)
lv->status |= LV_TEMPORARY;
- if (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) {
+ if (lv_is_cache_type(lv)) {
+ if (!lv_is_active(lv)) {
+ if (!activate_lv_excl(cmd, lv)) {
+ log_error("Failed to activate pool %s.",
+ lv->name);
+ goto deactivate_and_revert_new_lv;
+ }
+ } else {
+ if (!suspend_lv(cmd, lv)) {
+ log_error("Failed to suspend pool %s.",
+ lv->name);
+ goto deactivate_and_revert_new_lv;
+ }
+ if (!resume_lv(cmd, lv)) {
+ log_error("Failed to resume pool %s.", lv->name);
+ goto deactivate_and_revert_new_lv;
+ }
+ }
+ } else if (lv_is_thin_pool(lv)) {
if (is_change_activating(lp->activate)) {
if (vg_is_clustered(lv->vg)) {
if (!activate_lv_excl(cmd, lv)) {
diff --git a/test/shell/lvcreate-cache.sh b/test/shell/lvcreate-cache.sh
index 39f95c1..01e6f51 100644
--- a/test/shell/lvcreate-cache.sh
+++ b/test/shell/lvcreate-cache.sh
@@ -48,6 +48,7 @@ lvremove -ff $vg
# Create cache_pool, then origin with cache, then remove all
lvcreate --type cache_pool -l 1 -n ${lv}_cache_pool $vg
lvcreate --type cache -l 2 $vg/${lv}_cache_pool -n $lv1
+dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
lvremove -ff $vg
# Create cache_pool, then origin with cache, then remove cache_pool/cache
@@ -75,6 +76,7 @@ lvremove -ff $vg/${lv}_cache_pool
# Create origin, then cache_pool and cache
lvcreate -l 2 -n $lv1 $vg
lvcreate --type cache -l 1 $vg/$lv1
+dmsetup table ${vg}-$lv1 | grep cache # ensure it is loaded in kernel
lvremove -ff $vg
# Shorthand CLI (origin exists, create cache_pool and cache)
10 years, 3 months
master - systemd: do not use default dependencies for clvmd/cmirrord units
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=554159d519ba5c...
Commit: 554159d519ba5c523d506785d61d10374456a020
Parent: 4210219a8bba1aee6a16d16f4c158fa46395b9dd
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Feb 14 14:37:19 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Feb 14 14:37:19 2014 +0100
systemd: do not use default dependencies for clvmd/cmirrord units
Do not use default dependencies that systemd adds to the units
so we have better control of when the service is started/stopped
and we don't end up with unexpected behaviour.
---
...2_cluster_activation_systemd_red_hat.service.in | 3 ++-
scripts/lvm2_clvmd_systemd_red_hat.service.in | 2 ++
scripts/lvm2_cmirrord_systemd_red_hat.service.in | 2 ++
3 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/scripts/lvm2_cluster_activation_systemd_red_hat.service.in b/scripts/lvm2_cluster_activation_systemd_red_hat.service.in
index 03ed9d2..970e93a 100644
--- a/scripts/lvm2_cluster_activation_systemd_red_hat.service.in
+++ b/scripts/lvm2_cluster_activation_systemd_red_hat.service.in
@@ -3,7 +3,8 @@ Description=Clustered LVM volumes activation service
Requires=lvm2-clvmd.service
After=lvm2-clvmd.service lvm2-cmirrord.service
OnFailure=lvm2-clvmd.service
-DefaultDependencies=false
+DefaultDependencies=no
+Conflicts=shutdown.target
[Service]
Type=simple
diff --git a/scripts/lvm2_clvmd_systemd_red_hat.service.in b/scripts/lvm2_clvmd_systemd_red_hat.service.in
index c10bdc4..2978d21 100644
--- a/scripts/lvm2_clvmd_systemd_red_hat.service.in
+++ b/scripts/lvm2_clvmd_systemd_red_hat.service.in
@@ -7,6 +7,8 @@ Requires=network.target dlm.service corosync.service
RefuseManualStart=true
RefuseManualStop=true
StopWhenUnneeded=true
+DefaultDependencies=no
+Conflicts=shutdown.target
[Service]
Type=forking
diff --git a/scripts/lvm2_cmirrord_systemd_red_hat.service.in b/scripts/lvm2_cmirrord_systemd_red_hat.service.in
index 4ca3eea..16d38ce 100644
--- a/scripts/lvm2_cmirrord_systemd_red_hat.service.in
+++ b/scripts/lvm2_cmirrord_systemd_red_hat.service.in
@@ -4,6 +4,8 @@ Documentation=man:cmirrord(8)
Requires=corosync.service
After=corosync.service
Before=remote-fs.target
+DefaultDependencies=no
+Conflicts=shutdown.target
[Service]
Type=forking
10 years, 3 months
master - systemd: Use --ignoreskippedcluster in generated activation systemd units
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4210219a8bba1a...
Commit: 4210219a8bba1aee6a16d16f4c158fa46395b9dd
Parent: 94d8779ae241a2742ed43acc7bb0f98b7b2da25c
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Feb 14 11:59:12 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Feb 14 11:59:12 2014 +0100
systemd: Use --ignoreskippedcluster in generated activation systemd units
When the activation units are generated if use_lvmetad=0 (no
autoactivation), use --ignoreskippedcluster option for vgchange calls
since the cluster with cLVM is set up by separate units.
This avoids a situation in which the generated activation units are
improperly in failed state just because of the vgchange return value
when clustered VGs are encountered while the activation of non-clustered
VGs does proceed normally.
---
WHATS_NEW | 1 +
.../lvm2_activation_generator_systemd_red_hat.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 01fa616..e2a33b5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Use --ignoreskippedcluster in activation systemd units if use_lvmetad=0.
Allow approximate allocation when specifying size in percentage terms.
Add basic LVM support for cache[pool] segment types.
Use local exclusive activation for creation of raid in cluster.
diff --git a/scripts/lvm2_activation_generator_systemd_red_hat.c b/scripts/lvm2_activation_generator_systemd_red_hat.c
index f2e2e49..07a2563 100644
--- a/scripts/lvm2_activation_generator_systemd_red_hat.c
+++ b/scripts/lvm2_activation_generator_systemd_red_hat.c
@@ -150,7 +150,7 @@ static int generate_unit(const char *dir, int unit)
"[Service]\n", f);
}
- fputs("ExecStart=" LVM_PATH " vgchange -aay --sysinit\n"
+ fputs("ExecStart=" LVM_PATH " vgchange -aay --sysinit --ignoreskippedcluster\n"
"Type=oneshot\n", f);
if (fclose(f) < 0) {
10 years, 3 months
master - Update WHATS_NEW for approximate allocation check-in
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=94d8779ae241a2...
Commit: 94d8779ae241a2742ed43acc7bb0f98b7b2da25c
Parent: 4b6e3b5e5ea682b4b6f7c77a447ccadc7f3c99c3
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Thu Feb 13 21:12:28 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Thu Feb 13 21:12:28 2014 -0600
Update WHATS_NEW for approximate allocation check-in
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index a089d7c..01fa616 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.106 -
====================================
+ Allow approximate allocation when specifying size in percentage terms.
Add basic LVM support for cache[pool] segment types.
Use local exclusive activation for creation of raid in cluster.
Use correctly signed 64b constant when selecting raid volumes.
10 years, 3 months
master - allocation: Allow approximate allocation when specifying size in percent
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4b6e3b5e5ea682...
Commit: 4b6e3b5e5ea682b4b6f7c77a447ccadc7f3c99c3
Parent: f4658b53d7f3292c802f33f5fd0cca807870049f
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Thu Feb 13 21:10:28 2014 -0600
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Thu Feb 13 21:10:28 2014 -0600
allocation: Allow approximate allocation when specifying size in percent
Introduce a new parameter called "approx_alloc" that is set when the
desired size of a new LV is specified in percentage terms. If set,
the allocation code tries to get as much space as it can but does not
fail if can at least get some.
One of the practical implications is that users can now specify 100%FREE
when creating RAID LVs, like this:
~> lvcreate --type raid5 -i 2 -l 100%FREE -n lv vg
---
lib/metadata/lv_alloc.h | 2 +-
lib/metadata/lv_manip.c | 75 ++++++++++++++++++++++++----------
lib/metadata/metadata-exported.h | 4 +-
lib/metadata/mirror.c | 6 +-
lib/metadata/raid_manip.c | 4 +-
lib/metadata/thin_manip.c | 2 +-
test/shell/lvcreate-raid.sh | 84 ++++++++++++++++++++++++++++++++++++++
test/shell/lvcreate-raid10.sh | 8 ++++
tools/lvcreate.c | 2 +
9 files changed, 157 insertions(+), 30 deletions(-)
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
index acfebca..395420d 100644
--- a/lib/metadata/lv_alloc.h
+++ b/lib/metadata/lv_alloc.h
@@ -54,7 +54,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
uint32_t mirrors, uint32_t log_count,
uint32_t log_region_size, uint32_t extents,
struct dm_list *allocatable_pvs,
- alloc_policy_t alloc,
+ alloc_policy_t alloc, int approx_alloc,
struct dm_list *parallel_areas);
int lv_add_segment(struct alloc_handle *ah,
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 826dbb2..d38dd7c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -918,6 +918,7 @@ struct alloc_handle {
struct dm_pool *mem;
alloc_policy_t alloc; /* Overall policy */
+ int approx_alloc; /* get as much as possible up to new_extents */
uint32_t new_extents; /* Number of new extents required */
uint32_t area_count; /* Number of parallel areas */
uint32_t parity_count; /* Adds to area_count, but not area_multiple */
@@ -1041,7 +1042,7 @@ static uint32_t mirror_log_extents(uint32_t region_size, uint32_t pe_size, uint3
static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
struct dm_pool *mem,
const struct segment_type *segtype,
- alloc_policy_t alloc,
+ alloc_policy_t alloc, int approx_alloc,
uint32_t new_extents,
uint32_t mirrors,
uint32_t stripes,
@@ -1194,6 +1195,7 @@ static struct alloc_handle *_alloc_init(struct cmd_context *cmd,
ah->maximise_cling = find_config_tree_bool(cmd, allocation_maximise_cling_CFG, NULL);
+ ah->approx_alloc = approx_alloc;
return ah;
}
@@ -1214,10 +1216,18 @@ static int _sufficient_pes_free(struct alloc_handle *ah, struct dm_list *pvms,
uint32_t free_pes = pv_maps_size(pvms);
if (total_extents_needed > free_pes) {
- log_error("Insufficient free space: %" PRIu32 " extents needed,"
- " but only %" PRIu32 " available",
- total_extents_needed, free_pes);
- return 0;
+ if (!ah->approx_alloc) {
+ log_error("Insufficient free space: %" PRIu32
+ " extents needed,"
+ " but only %" PRIu32 " available",
+ total_extents_needed, free_pes);
+
+ return 0;
+ }
+ log_verbose("Insufficient free space: %" PRIu32
+ " extents needed, but only %" PRIu32
+ " available: amount will be reduced",
+ total_extents_needed, free_pes);
}
return 1;
@@ -2006,7 +2016,8 @@ static void _report_needed_allocation_space(struct alloc_handle *ah,
metadata_count = alloc_state->log_area_count_still_needed;
}
- log_debug_alloc("Still need %" PRIu32 " total extents:",
+ log_debug_alloc("Still need %s%" PRIu32 " total extents:",
+ ah->approx_alloc ? "up to " : "",
parallel_area_size * parallel_areas_count + metadata_size * metadata_count);
log_debug_alloc(" %" PRIu32 " (%" PRIu32 " data/%" PRIu32
" parity) parallel areas of %" PRIu32 " extents each",
@@ -2414,19 +2425,29 @@ static int _allocate(struct alloc_handle *ah,
if (!_find_max_parallel_space_for_one_policy(ah, &alloc_parms, pvms, &alloc_state))
goto_out;
- if ((alloc_state.allocated == ah->new_extents && !alloc_state.log_area_count_still_needed) ||
+ if ((alloc_state.allocated == ah->new_extents &&
+ !alloc_state.log_area_count_still_needed) ||
(!can_split && (alloc_state.allocated != old_allocated)))
break;
}
if (alloc_state.allocated != ah->new_extents) {
- log_error("Insufficient suitable %sallocatable extents "
- "for logical volume %s: %u more required",
- can_split ? "" : "contiguous ",
- lv ? lv->name : "",
- (ah->new_extents - alloc_state.allocated) * ah->area_count
- / ah->area_multiple);
- goto out;
+ if (!ah->approx_alloc) {
+ log_error("Insufficient suitable %sallocatable extents "
+ "for logical volume %s: %u more required",
+ can_split ? "" : "contiguous ",
+ lv ? lv->name : "",
+ (ah->new_extents - alloc_state.allocated) *
+ ah->area_count / ah->area_multiple);
+ goto out;
+ }
+ log_verbose("Insufficient suitable %sallocatable extents "
+ "for logical volume %s: size reduced by %u extents",
+ can_split ? "" : "contiguous ",
+ lv ? lv->name : "",
+ (ah->new_extents - alloc_state.allocated) *
+ ah->area_count / ah->area_multiple);
+ ah->new_extents = alloc_state.allocated;
}
if (alloc_state.log_area_count_still_needed) {
@@ -2503,7 +2524,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
uint32_t mirrors, uint32_t log_count,
uint32_t region_size, uint32_t extents,
struct dm_list *allocatable_pvs,
- alloc_policy_t alloc,
+ alloc_policy_t alloc, int approx_alloc,
struct dm_list *parallel_areas)
{
struct alloc_handle *ah;
@@ -2533,7 +2554,7 @@ struct alloc_handle *allocate_extents(struct volume_group *vg,
alloc = vg->alloc;
new_extents = (lv ? lv->le_count : 0) + extents;
- if (!(ah = _alloc_init(vg->cmd, vg->cmd->mem, segtype, alloc,
+ if (!(ah = _alloc_init(vg->cmd, vg->cmd->mem, segtype, alloc, approx_alloc,
new_extents, mirrors, stripes, log_count,
vg->extent_size, region_size,
parallel_areas)))
@@ -2999,7 +3020,8 @@ int lv_extend(struct logical_volume *lv,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t region_size,
uint32_t extents, const char *thin_pool_name,
- struct dm_list *allocatable_pvs, alloc_policy_t alloc)
+ struct dm_list *allocatable_pvs, alloc_policy_t alloc,
+ int approx_alloc)
{
int r = 1;
int log_count = 0;
@@ -3027,9 +3049,18 @@ int lv_extend(struct logical_volume *lv,
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
log_count, region_size, extents,
- allocatable_pvs, alloc, NULL)))
+ allocatable_pvs, alloc, approx_alloc, NULL)))
return_0;
+ if (ah->approx_alloc) {
+ extents = ah->new_extents;
+ if (segtype_is_raid(segtype)) {
+ log_error("Extents before: %u", extents);
+ extents -= ah->log_len * ah->area_multiple;
+ log_error("Extents after : %u", extents);
+ }
+ }
+
if (segtype_is_thin_pool(segtype) || segtype_is_cache_pool(segtype)) {
if (lv->le_count) {
/* lv_resize abstracts properly _tdata */
@@ -3646,7 +3677,7 @@ static int _lvresize_poolmetadata(struct cmd_context *cmd, struct volume_group *
seg_mirrors,
mseg->region_size,
lp->poolmetadataextents - lv->le_count, NULL,
- pvh, alloc))
+ pvh, alloc, 0))
return_0;
return 1;
@@ -4159,7 +4190,7 @@ static struct logical_volume *_lvresize_volume(struct cmd_context *cmd,
lp->stripes, lp->stripe_size,
lp->mirrors, first_seg(lv)->region_size,
lp->extents - lv->le_count, NULL,
- pvh, alloc))
+ pvh, alloc, 0))
return_NULL;
if (lock_lv) {
@@ -5596,7 +5627,7 @@ static struct logical_volume *_create_virtual_origin(struct cmd_context *cmd,
return_NULL;
if (!lv_extend(lv, segtype, 1, 0, 1, 0, voriginextents,
- NULL, NULL, ALLOC_INHERIT))
+ NULL, NULL, ALLOC_INHERIT, 0))
return_NULL;
/* store vg on disk(s) */
@@ -6110,7 +6141,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
(seg_is_thin_pool(lp) || seg_is_cache_pool(lp)) ?
lp->poolmetadataextents : lp->region_size,
seg_is_thin_volume(lp) ? lp->voriginextents : lp->extents,
- thin_name, lp->pvh, lp->alloc))
+ thin_name, lp->pvh, lp->alloc, lp->approx_alloc))
return_NULL;
if (seg_is_cache_pool(lp)) {
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index faa8217..6ca4309 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -672,7 +672,8 @@ int lv_extend(struct logical_volume *lv,
uint32_t stripes, uint32_t stripe_size,
uint32_t mirrors, uint32_t region_size,
uint32_t extents, const char *thin_pool_name,
- struct dm_list *allocatable_pvs, alloc_policy_t alloc);
+ struct dm_list *allocatable_pvs, alloc_policy_t alloc,
+ int approx_alloc);
/* lv must be part of lv->vg->lvs */
int lv_remove(struct logical_volume *lv);
@@ -810,6 +811,7 @@ struct lvcreate_params {
uint32_t permission; /* all */
uint32_t read_ahead; /* all */
+ int approx_alloc; /* all */
alloc_policy_t alloc; /* all */
struct dm_list tags; /* all */
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 5d99c50..86ec4ca 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -1676,7 +1676,7 @@ int add_mirrors_to_segments(struct cmd_context *cmd, struct logical_volume *lv,
region_size);
if (!(ah = allocate_extents(lv->vg, NULL, segtype, 1, mirrors, 0, 0,
- lv->le_count, allocatable_pvs, alloc,
+ lv->le_count, allocatable_pvs, alloc, 0,
parallel_areas))) {
log_error("Unable to allocate mirror extents for %s.", lv->name);
return 0;
@@ -1944,7 +1944,7 @@ int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
ah = allocate_extents(lv->vg, NULL, segtype,
0, 0, log_count - old_log_count, region_size,
lv->le_count, allocatable_pvs,
- alloc, parallel_areas);
+ alloc, 0, parallel_areas);
if (!ah) {
log_error("Unable to allocate extents for mirror log.");
return 0;
@@ -2008,7 +2008,7 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv,
ah = allocate_extents(lv->vg, NULL, segtype,
stripes, mirrors, log_count, region_size, lv->le_count,
- allocatable_pvs, alloc, parallel_areas);
+ allocatable_pvs, alloc, 0, parallel_areas);
if (!ah) {
log_error("Unable to allocate extents for mirror(s).");
return 0;
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 3f2b043..d1759ae 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -419,7 +419,7 @@ static int _alloc_image_components(struct logical_volume *lv,
if (!(ah = allocate_extents(lv->vg, NULL, segtype, 0, count, count,
region_size, extents, pvs,
- lv->alloc, parallel_areas)))
+ lv->alloc, 0, parallel_areas)))
return_0;
for (s = 0; s < count; s++) {
@@ -483,7 +483,7 @@ static int _alloc_rmeta_for_lv(struct logical_volume *data_lv,
if (!(ah = allocate_extents(data_lv->vg, NULL, seg->segtype, 0, 1, 0,
seg->region_size,
1 /*RAID_METADATA_AREA_LEN*/,
- &allocatable_pvs, data_lv->alloc, NULL)))
+ &allocatable_pvs, data_lv->alloc, 0, NULL)))
return_0;
if (!_alloc_image_component(data_lv, base_name, ah, 0,
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index c3f8e56..1ae893a 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -677,7 +677,7 @@ int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
seg_mirrors,
seg->region_size,
extents - lv->le_count, NULL,
- pvh, lv->alloc))
+ pvh, lv->alloc, 0))
return_0;
return 1;
diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh
index 214b162..2a1ed6d 100644
--- a/test/shell/lvcreate-raid.sh
+++ b/test/shell/lvcreate-raid.sh
@@ -70,3 +70,87 @@ for i in raid4 \
aux wait_for_sync $vg $lv1
lvremove -ff $vg
done
+
+# Create RAID using 100%FREE
+############################
+# 6 PVs with 18.5m in each PV.
+# 1 metadata LV = 1 extent = .5m
+# 1 image = 36+37+37 extents = 55.00m = lv_size
+lvcreate --type raid1 -m 1 -l 100%FREE -n raid1 $vg
+check lv_field $vg/raid1 size "55.00m"
+lvremove -ff $vg
+
+# 1 metadata LV = 1 extent
+# 1 image = 36 extents
+# 5 images = 180 extents = 90.00m = lv_size
+lvcreate --type raid5 -i 5 -l 100%FREE -n raid5 $vg
+check lv_field $vg/raid5 size "90.00m"
+lvremove -ff $vg
+
+# 1 image = 36+37 extents
+# 2 images = 146 extents = 73.00m = lv_size
+lvcreate --type raid5 -i 2 -l 100%FREE -n raid5 $vg
+check lv_field $vg/raid5 size "73.00m"
+lvremove -ff $vg
+
+# 1 image = 36 extents
+# 4 images = 144 extents = 72.00m = lv_size
+lvcreate --type raid6 -i 4 -l 100%FREE -n raid6 $vg
+check lv_field $vg/raid6 size "72.00m"
+lvremove -ff $vg
+
+# Eat 18 of 37 extents from dev1, leaving 19
+lvcreate -l 18 -n lv $vg $dev1
+# Using 100% free should take the rest of dev1 and equal from dev2
+# 1 meta takes 1 extent
+# 1 image = 18 extents = 9.00m = lv_size
+lvcreate --type raid1 -m 1 -l 100%FREE -n raid1 $vg $dev1 $dev2
+check lv_field $vg/raid1 size "9.00m"
+# Ensure image size is the same as the RAID1 size
+check lv_field $vg/raid1 size `lvs --noheadings -o size $vg/raid1_rimage_0`
+# Amount remaining in dev2 should equal the amount taken by 'lv' in dev1
+check pv_field "$dev2" pv_free `lvs --noheadings -o size $vg/lv`
+lvremove -ff $vg
+
+# Eat 18 of 37 extents from dev1, leaving 19
+lvcreate -l 18 -n lv $vg $dev1
+# Using 100% free should take the rest of dev1 and equal amount from the rest
+# 1 meta takes 1 extent
+# 1 image = 18 extents = 9.00m
+# 5 images = 90 extents = 45.00m = lv_size
+lvcreate --type raid5 -i 5 -l 100%FREE -n raid5 $vg
+check lv_field $vg/raid5 size "45.00m"
+# Amount remaining in dev6 should equal the amount taken by 'lv' in dev1
+check pv_field "$dev6" pv_free `lvs --noheadings -o size $vg/lv`
+lvremove -ff $vg
+
+# Eat 18 of 37 extents from dev1, leaving 19
+lvcreate -l 18 -n lv $vg $dev1
+# Using 100% free should take the rest of dev1, an equal amount
+# from 2 more devs, and all extents from 3 additional devs
+# 1 meta takes 1 extent
+# 1 image = 18+37 extents
+# 2 images = 110 extents = 55.00m = lv_size
+lvcreate --type raid5 -i 2 -l 100%FREE -n raid5 $vg
+check lv_field $vg/raid5 size "55.00m"
+lvremove -ff $vg
+
+# Let's do some stripe tests too
+# Eat 18 of 37 extents from dev1, leaving 19
+lvcreate -l 18 -n lv $vg $dev1
+# Using 100% free should take the rest of dev1 and an equal amount from rest
+# 1 image = 19 extents
+# 6 images = 114 extents = 57.00m = lv_size
+lvcreate -i 6 -l 100%FREE -n stripe $vg
+check lv_field $vg/stripe size "57.00m"
+lvremove -ff $vg
+
+# Eat 18 of 37 extents from dev1, leaving 19
+lvcreate -l 18 -n lv $vg $dev1
+# Using 100% free should take the rest of dev1, an equal amount from
+# one more dev, and all of the remaining 4
+# 1 image = 19+37+37 extents
+# 2 images = 186 extents = 93.00m = lv_size
+lvcreate -i 2 -l 100%FREE -n stripe $vg
+check lv_field $vg/stripe size "93.00m"
+lvremove -ff $vg
diff --git a/test/shell/lvcreate-raid10.sh b/test/shell/lvcreate-raid10.sh
index 143e869..0ee18b8 100644
--- a/test/shell/lvcreate-raid10.sh
+++ b/test/shell/lvcreate-raid10.sh
@@ -46,6 +46,14 @@ aux wait_for_sync $vg $lv2
lvremove -ff $vg
+# Test 100%FREE option
+# 37 extents / device
+# 1 image = 36 extents (1 for meta)
+# 3 images = 108 extents = 54.00m
+lvcreate --type raid10 -i 3 -l 100%FREE -n raid10 $vg
+check lv_field $vg/raid10 size "54.00m"
+lvremove -ff $vg
+
#
# FIXME: Add tests that specify particular PVs to use for creation
#
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index bf719fe..b413f34 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -363,6 +363,8 @@ static int _update_extents_params(struct volume_group *vg,
} else
lp->pvh = &vg->pvs;
+ if (lcp->percent)
+ lp->approx_alloc = 1;
switch(lcp->percent) {
case PERCENT_VG:
lp->extents = percent_of_extents(lp->extents, vg->extent_count, 0);
10 years, 3 months