master - cleanup: use IEC KiB units
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ece758457de0c5...
Commit: ece758457de0c5a40b5b33b90cab2238de34d55e
Parent: 79e9bde0ea37abe04afa970972c6bf0504706766
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 16 14:03:48 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:15 2015 +0200
cleanup: use IEC KiB units
Reduce mixing of KB, kiB and use just KiB.
---
lib/config/config_settings.h | 36 ++++++++++++++++++------------------
1 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index c2bef27..54a50ab 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -314,7 +314,7 @@ cfg(devices_md_chunk_alignment_CFG, "md_chunk_alignment", devices_CFG_SECTION, 0
cfg(devices_default_data_alignment_CFG, "default_data_alignment", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_DATA_ALIGNMENT, vsn(2, 2, 75), NULL, 0, NULL,
"Default alignment of the start of a PV data area in MB.\n"
- "If set to 0, a value of 64KB will be used.\n"
+ "If set to 0, a value of 64KiB will be used.\n"
"Set to 1 for 1MiB, 2 for 2MiB, etc.\n")
cfg(devices_data_alignment_detection_CFG, "data_alignment_detection", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_DATA_ALIGNMENT_DETECTION, vsn(2, 2, 51), NULL, 0, NULL,
@@ -330,7 +330,7 @@ cfg(devices_data_alignment_detection_CFG, "data_alignment_detection", devices_CF
"This setting takes precedence over md_chunk_alignment.\n")
cfg(devices_data_alignment_CFG, "data_alignment", devices_CFG_SECTION, 0, CFG_TYPE_INT, 0, vsn(2, 2, 45), NULL, 0, NULL,
- "Alignment of the start of a PV data area in KB.\n"
+ "Alignment of the start of a PV data area in KiB.\n"
"If a PV is placed directly on an md device and\n"
"md_chunk_alignment or data_alignment_detection are enabled,\n"
"then this setting is ignored. Otherwise, md_chunk_alignment\n"
@@ -341,10 +341,10 @@ cfg(devices_data_alignment_offset_detection_CFG, "data_alignment_offset_detectio
"Detect PV data alignment offset based on sysfs device information.\n"
"The start of a PV aligned data area will be shifted by the\n"
"alignment_offset exposed in sysfs. This offset is often 0, but\n"
- "may be non-zero. Certain 4KB sector drives that compensate for\n"
+ "may be non-zero. Certain 4KiB sector drives that compensate for\n"
"windows partitioning will have an alignment_offset of 3584 bytes\n"
- "(sector 7 is the lowest aligned logical block, the 4KB sectors start\n"
- "at LBA -1, and consequently sector 63 is aligned on a 4KB boundary).\n"
+ "(sector 7 is the lowest aligned logical block, the 4KiB sectors start\n"
+ "at LBA -1, and consequently sector 63 is aligned on a 4KiB boundary).\n"
"pvcreate --dataalignmentoffset will skip this detection.\n")
cfg(devices_ignore_suspended_devices_CFG, "ignore_suspended_devices", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_IGNORE_SUSPENDED_DEVICES, vsn(1, 2, 19), NULL, 0, NULL,
@@ -384,9 +384,9 @@ cfg(devices_require_restorefile_with_uuid_CFG, "require_restorefile_with_uuid",
"Allow use of pvcreate --uuid without requiring --restorefile.\n")
cfg(devices_pv_min_size_CFG, "pv_min_size", devices_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_PV_MIN_SIZE_KB, vsn(2, 2, 85), NULL, 0, NULL,
- "Minimum size (in KB) of block devices which can be used as PVs.\n"
+ "Minimum size in KiB of block devices which can be used as PVs.\n"
"In a clustered environment all nodes must use the same value.\n"
- "Any value smaller than 512KB is ignored. The previous built-in\n"
+ "Any value smaller than 512KiB is ignored. The previous built-in\n"
"value was 512.\n")
cfg(devices_issue_discards_CFG, "issue_discards", devices_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_ISSUE_DISCARDS, vsn(2, 2, 85), NULL, 0, NULL,
@@ -440,7 +440,7 @@ cfg(allocation_wipe_signatures_when_zeroing_new_lvs_CFG, "wipe_signatures_when_z
"Look for and erase any signatures while zeroing a new LV.\n"
"Zeroing is controlled by the -Z/--zero option, and if not\n"
"specified, zeroing is used by default if possible.\n"
- "Zeroing simply overwrites the first 4 KiB of a new LV\n"
+ "Zeroing simply overwrites the first 4KiB of a new LV\n"
"with zeroes and does no signature detection or wiping.\n"
"Signature wiping goes beyond zeroing and detects exact\n"
"types and positions of signatures within the whole LV.\n"
@@ -490,7 +490,7 @@ cfg_section(policy_settings_CFG_SUBSECTION, "policy_settings", allocation_cache_
"Multiple subsections for different policies can be created.\n")
cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 106), 0, NULL,
- "The minimal chunk size (in kiB) for cache pool volumes.\n"
+ "The minimal chunk size in KiB for cache pool volumes.\n"
"Using a chunk_size that is too large can result in wasteful\n"
"use of the cache, where small reads and writes can cause\n"
"large sections of an LV to be mapped into the cache. However,\n"
@@ -498,8 +498,8 @@ cfg_runtime(allocation_cache_pool_chunk_size_CFG, "cache_pool_chunk_size", alloc
"overhead trying to manage the numerous chunks that become mapped\n"
"into the cache. The former is more of a problem than the latter\n"
"in most cases, so we default to a value that is on the smaller\n"
- "end of the spectrum. Supported values range from 32(kiB) to\n"
- "1048576 in multiples of 32.\n")
+ "end of the spectrum. Supported values range from 32KiB to\n"
+ "1GiB in multiples of 32.\n")
cfg(allocation_thin_pool_metadata_require_separate_pvs_CFG, "thin_pool_metadata_require_separate_pvs", allocation_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_THIN_POOL_METADATA_REQUIRE_SEPARATE_PVS, vsn(2, 2, 89), NULL, 0, NULL,
"Thin pool metdata and data will always use different PVs.\n")
@@ -525,16 +525,16 @@ cfg(allocation_thin_pool_chunk_size_policy_CFG, "thin_pool_chunk_size_policy", a
"The chunk size is always at least 512KiB.\n")
cfg_runtime(allocation_thin_pool_chunk_size_CFG, "thin_pool_chunk_size", allocation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_UNDEFINED, CFG_TYPE_INT, vsn(2, 2, 99), 0, NULL,
- "The minimal chunk size (in KB) for thin pool volumes.\n"
+ "The minimal chunk size in KiB for thin pool volumes.\n"
"Larger chunk sizes may improve performance for plain\n"
"thin volumes, however using them for snapshot volumes\n"
"is less efficient, as it consumes more space and takes\n"
"extra time for copying. When unset, lvm tries to estimate\n"
- "chunk size starting from 64KB. Supported values are in\n"
- "the range 64 to 1048576.\n")
+ "chunk size starting from 64KiB. Supported values are in\n"
+ "the range 64KiB to 1GiB.\n")
cfg(allocation_physical_extent_size_CFG, "physical_extent_size", allocation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_EXTENT_SIZE, vsn(2, 2, 112), NULL, 0, NULL,
- "Default physical extent size to use for new VGs (in KB).\n")
+ "Default physical extent size in KiB to use for new VGs.\n")
cfg(log_verbose_CFG, "verbose", log_CFG_SECTION, 0, CFG_TYPE_BOOL, DEFAULT_VERBOSE, vsn(1, 0, 0), NULL, 0, NULL,
"Controls the messages sent to stdout or stderr.\n")
@@ -1040,11 +1040,11 @@ cfg(activation_use_linear_target_CFG, "use_linear_target", activation_CFG_SECTIO
"that only handles a single stripe.\n")
cfg(activation_reserved_stack_CFG, "reserved_stack", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RESERVED_STACK, vsn(1, 0, 0), NULL, 0, NULL,
- "Stack size in KB to reserve for use while devices are suspended.\n"
+ "Stack size in KiB to reserve for use while devices are suspended.\n"
"Insufficent reserve risks I/O deadlock during device suspension.\n")
cfg(activation_reserved_memory_CFG, "reserved_memory", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RESERVED_MEMORY, vsn(1, 0, 0), NULL, 0, NULL,
- "Memory size in KB to reserve for use while devices are suspended.\n"
+ "Memory size in KiB to reserve for use while devices are suspended.\n"
"Insufficent reserve risks I/O deadlock during device suspension.\n")
cfg(activation_process_priority_CFG, "process_priority", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_PROCESS_PRIORITY, vsn(1, 0, 0), NULL, 0, NULL,
@@ -1111,7 +1111,7 @@ cfg_array(activation_read_only_volume_list_CFG, "read_only_volume_list", activat
cfg(activation_mirror_region_size_CFG, "mirror_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(1, 0, 0), NULL, vsn(2, 2, 99),
"This has been replaced by the activation/raid_region_size setting.\n",
- "Size (in KB) of each copy operation when mirroring.\n")
+ "Size in KiB of each copy operation when mirroring.\n")
cfg(activation_raid_region_size_CFG, "raid_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(2, 2, 99), NULL, 0, NULL,
"Size in KiB of each raid or mirror synchronization region.\n"
8 years, 8 months
master - libdm: rename to data_block_size
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=79e9bde0ea37ab...
Commit: 79e9bde0ea37abe04afa970972c6bf0504706766
Parent: 08f047eb51375f6b96b0612e766cc9e0edae6ca0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 11 13:30:02 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:15 2015 +0200
libdm: rename to data_block_size
Use common name for pool device - as we use data_block_size
for thin pool metadata, use same name for cache_pool.
This change does not affect API.
---
libdm/libdevmapper.h | 2 +-
libdm/libdm-deptree.c | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 1be8e4f..18df90a 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1308,7 +1308,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
const char *origin_uuid,
const char *policy_name,
const struct dm_config_node *policy_settings,
- uint32_t chunk_size);
+ uint32_t data_block_size);
/*
* FIXME Add individual cache policy pairs <key> = value, like:
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index bbbd2d8..040a826 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -159,7 +159,7 @@ struct load_segment {
uint32_t stripe_size; /* Striped + raid */
int persistent; /* Snapshot */
- uint32_t chunk_size; /* Snapshot + cache */
+ uint32_t chunk_size; /* Snapshot */
struct dm_tree_node *cow; /* Snapshot */
struct dm_tree_node *origin; /* Snapshot + Snapshot origin + Cache */
struct dm_tree_node *merge; /* Snapshot */
@@ -200,7 +200,7 @@ struct load_segment {
struct dm_list thin_messages; /* Thin_pool */
uint64_t transaction_id; /* Thin_pool */
uint64_t low_water_mark; /* Thin_pool */
- uint32_t data_block_size; /* Thin_pool */
+ uint32_t data_block_size; /* Thin_pool + cache */
unsigned skip_block_zeroing; /* Thin_pool */
unsigned ignore_discard; /* Thin_pool target vsn 1.1 */
unsigned no_discard_passdown; /* Thin_pool target vsn 1.1 */
@@ -2429,8 +2429,8 @@ static int _cache_emit_segment_line(struct dm_task *dmt,
EMIT_PARAMS(pos, " %s %s %s", metadata, data, origin);
- /* Chunk size */
- EMIT_PARAMS(pos, " %u", seg->chunk_size);
+ /* Data block size */
+ EMIT_PARAMS(pos, " %u", seg->data_block_size);
/* Features */
/* feature_count = hweight32(seg->flags); */
@@ -3353,7 +3353,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
const char *origin_uuid,
const char *policy_name,
const struct dm_config_node *policy_settings,
- uint32_t chunk_size)
+ uint32_t data_block_size)
{
struct dm_config_node *cn;
struct load_segment *seg;
@@ -3415,7 +3415,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
if (!_link_tree_nodes(node, seg->origin))
return_0;
- seg->chunk_size = chunk_size;
+ seg->data_block_size = data_block_size;
seg->flags = feature_flags;
seg->policy_name = policy_name;
8 years, 8 months
master - libdm: cache target arg validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=08f047eb51375f...
Commit: 08f047eb51375f6b96b0612e766cc9e0edae6ca0
Parent: 9edd2258ffc7ae7593a6e193760861090d0fb273
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 11 13:31:26 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:15 2015 +0200
libdm: cache target arg validation
Add some arg validation for dm_tree_node_add_cache_target().
---
WHATS_NEW_DM | 1 +
libdm/libdm-deptree.c | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index e857241..a72d3e0 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.105 -
===================================
+ Add more arg validation for dm_tree_node_add_cache_target().
Version 1.02.104 - 10th August 2015
===================================
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 36befff..bbbd2d8 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -3358,6 +3358,32 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
struct dm_config_node *cn;
struct load_segment *seg;
+ switch (feature_flags &
+ (DM_CACHE_FEATURE_PASSTHROUGH |
+ DM_CACHE_FEATURE_WRITETHROUGH |
+ DM_CACHE_FEATURE_WRITEBACK)) {
+ case DM_CACHE_FEATURE_PASSTHROUGH:
+ case DM_CACHE_FEATURE_WRITETHROUGH:
+ case DM_CACHE_FEATURE_WRITEBACK:
+ break;
+ default:
+ log_error("Invalid cache's feature flag " FMTu64 ".",
+ feature_flags);
+ return 0;
+ }
+
+ if (data_block_size < DM_CACHE_MIN_DATA_BLOCK_SIZE) {
+ log_error("Data block size %u is lower then %u sectors.",
+ data_block_size, DM_CACHE_MIN_DATA_BLOCK_SIZE);
+ return 0;
+ }
+
+ if (data_block_size > DM_CACHE_MAX_DATA_BLOCK_SIZE) {
+ log_error("Data block size %u is higher then %u sectors.",
+ data_block_size, DM_CACHE_MAX_DATA_BLOCK_SIZE);
+ return 0;
+ }
+
if (!(seg = _add_segment(node, SEG_CACHE, size)))
return_0;
8 years, 8 months
master - config: extend definition for Allocation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9edd2258ffc7ae...
Commit: 9edd2258ffc7ae7593a6e193760861090d0fb273
Parent: 13c7bbf8a9ff2fad2718ba6cb627d7fcef766900
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 23 14:20:29 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:15 2015 +0200
config: extend definition for Allocation
Extend comment for this section.
---
lib/config/config_settings.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index c8461f7..c2bef27 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -122,7 +122,8 @@ cfg_section(devices_CFG_SECTION, "devices", root_CFG_SECTION, 0, vsn(1, 0, 0), 0
"How LVM uses block devices.\n")
cfg_section(allocation_CFG_SECTION, "allocation", root_CFG_SECTION, CFG_PROFILABLE, vsn(2, 2, 77), 0, NULL,
- "How LVM selects free space for Logical Volumes.\n")
+ "How LVM selects free space for Logical Volumes and default\n"
+ "properties applied to new Logical Volumes of various types.\n")
cfg_section(log_CFG_SECTION, "log", root_CFG_SECTION, 0, vsn(1, 0, 0), 0, NULL,
"How LVM log information is reported.\n")
8 years, 8 months
master - config: support longer config paths
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=13c7bbf8a9ff2f...
Commit: 13c7bbf8a9ff2fad2718ba6cb627d7fcef766900
Parent: 533ac4d47dcecc976c05ba503acff11b9546b67c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 23 14:21:35 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:15 2015 +0200
config: support longer config paths
64 bytes might not be enough, so use larger buffer size.
---
lib/config/config.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/config/config.h b/lib/config/config.h
index fb39e6e..e112223 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -50,7 +50,7 @@ struct profile_params {
struct dm_list profiles; /* list of profiles which are loaded already and which are ready for use */
};
-#define CFG_PATH_MAX_LEN 64
+#define CFG_PATH_MAX_LEN 128
/*
* Structures used for definition of a configuration tree.
8 years, 8 months
master - cache: add more validation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=533ac4d47dcecc...
Commit: 533ac4d47dcecc976c05ba503acff11b9546b67c
Parent: f0c18fceb43d77b0a79685fc7b1c8bbe64df7e97
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 11 15:11:45 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:33:14 2015 +0200
cache: add more validation
---
WHATS_NEW | 1 +
lib/cache_segtype/cache.c | 3 +++
lib/metadata/lv_manip.c | 6 +++++-
lib/metadata/merge.c | 16 +++++++++++++++-
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7fcf49a..1e34e1c 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Check for valid cache mode in validation of cache segment.
Enhance internal API cache_set_mode() and cache_set_policy().
Enhance toollib's get_cache_params().
Runtime detect presence of cache smq policy.
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 0526173..53c867e 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -100,6 +100,9 @@ static int _cache_pool_text_import(struct lv_segment *seg,
* If the policy is not present, default policy is used.
*/
if ((sn = dm_config_find_node(sn, "policy_settings"))) {
+ if (!seg->policy_name)
+ return SEG_LOG_ERROR("policy_settings must have a policy_name in");
+
if (sn->v)
return SEG_LOG_ERROR("policy_settings must be a section in");
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index f13df1b..116f099 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7074,7 +7074,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
display_lvname(origin_lv));
return NULL;
}
- } else if (pool_lv && seg_is_cache(lp)) {
+ } else if (seg_is_cache(lp)) {
+ if (!pool_lv) {
+ log_error(INTERNAL_ERROR "Pool LV for cache is missing.");
+ return NULL;
+ }
if (!lv_is_cache_pool(pool_lv)) {
log_error("Logical volume %s is not a cache pool.",
display_lvname(pool_lv));
diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c
index e38cb53..a3e6af1 100644
--- a/lib/metadata/merge.c
+++ b/lib/metadata/merge.c
@@ -208,7 +208,21 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
}
}
- if (seg_is_cache_pool(seg)) {
+ if (seg_is_cache_pool(seg) &&
+ !dm_list_empty(&seg->lv->segs_using_this_lv)) {
+ switch (seg->feature_flags &
+ (DM_CACHE_FEATURE_PASSTHROUGH |
+ DM_CACHE_FEATURE_WRITETHROUGH |
+ DM_CACHE_FEATURE_WRITEBACK)) {
+ case DM_CACHE_FEATURE_PASSTHROUGH:
+ case DM_CACHE_FEATURE_WRITETHROUGH:
+ case DM_CACHE_FEATURE_WRITEBACK:
+ break;
+ default:
+ log_error("LV %s has invalid cache's feature flag.",
+ lv->name);
+ inc_error_count;
+ }
if (!seg->policy_name) {
log_error("LV %s is missing cache policy name.", lv->name);
inc_error_count;
8 years, 8 months
master - cache: api update
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0c18fceb43d77...
Commit: f0c18fceb43d77b0a79685fc7b1c8bbe64df7e97
Parent: 22a1337a9ba1ebf73c3f0b27f621d9d8917bf6cf
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 11 14:01:12 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:32:24 2015 +0200
cache: api update
Change logic and naming of some internal API functions.
cache_set_mode() and cache_set_policy() both take segment.
cache mode is now correctly 'masked-in'.
If the passed segment is 'cache' segment - it will automatically
try to find 'defaults' according to profiles if the are NOT
specified on command line or they are NOT already set for cache-pool.
These defaults are never set for cache-pool.
---
WHATS_NEW | 1 +
lib/cache_segtype/cache.c | 53 +++++++--------
lib/metadata/cache_manip.c | 129 ++++++++++++++++++++++++++++++--------
lib/metadata/lv.c | 2 +-
lib/metadata/lv_manip.c | 31 +++++++---
lib/metadata/metadata-exported.h | 9 ++-
lib/report/report.c | 2 +-
tools/lvchange.c | 2 +-
tools/lvconvert.c | 8 ++-
9 files changed, 166 insertions(+), 71 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7c35d13..7fcf49a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Enhance internal API cache_set_mode() and cache_set_policy().
Enhance toollib's get_cache_params().
Runtime detect presence of cache smq policy.
Add demo cache-mq and cache-smq profiles.
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index 93436a3..0526173 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -71,23 +71,15 @@ static int _cache_pool_text_import(struct lv_segment *seg,
if (dm_config_has_node(sn, "cache_mode")) {
if (!(str = dm_config_find_str(sn, "cache_mode", NULL)))
return SEG_LOG_ERROR("cache_mode must be a string in");
- if (!set_cache_pool_feature(&seg->feature_flags, str))
+ if (!cache_set_mode(seg, str))
return SEG_LOG_ERROR("Unknown cache_mode in");
- } else
- /* When missed in metadata, it's an old stuff - use writethrough */
- seg->feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
+ }
if (dm_config_has_node(sn, "policy")) {
if (!(str = dm_config_find_str(sn, "policy", NULL)))
return SEG_LOG_ERROR("policy must be a string in");
if (!(seg->policy_name = dm_pool_strdup(mem, str)))
return SEG_LOG_ERROR("Failed to duplicate policy in");
- } else {
- /* Cannot use 'just' default, so pick one */
- seg->policy_name = DEFAULT_CACHE_POLICY; /* FIXME make configurable */
- /* FIXME maybe here should be always 'mq' */
- log_warn("WARNING: cache_policy undefined, using default \"%s\" policy.",
- seg->policy_name);
}
/*
@@ -136,28 +128,33 @@ static int _cache_pool_text_export(const struct lv_segment *seg,
{
const char *cache_mode;
- if (!(cache_mode = get_cache_pool_cachemode_name(seg)))
- return_0;
-
- if (!seg->policy_name) {
- log_error(INTERNAL_ERROR "Policy name for %s is not defined.",
- display_lvname(seg->lv));
- return 0;
- }
-
outf(f, "data = \"%s\"", seg_lv(seg, 0)->name);
outf(f, "metadata = \"%s\"", seg->metadata_lv->name);
outf(f, "chunk_size = %" PRIu32, seg->chunk_size);
- outf(f, "cache_mode = \"%s\"", cache_mode);
- outf(f, "policy = \"%s\"", seg->policy_name);
- if (seg->policy_settings) {
- if (strcmp(seg->policy_settings->key, "policy_settings")) {
- log_error(INTERNAL_ERROR "Incorrect policy_settings tree, %s.",
- seg->policy_settings->key);
- return 0;
+ /*
+ * Cache pool used by a cache LV holds data. Not ideal,
+ * but not worth to break backward compatibility, by shifting
+ * content to cache segment
+ */
+ if (cache_mode_is_set(seg)) {
+ if (!(cache_mode = get_cache_mode_name(seg)))
+ return_0;
+ outf(f, "cache_mode = \"%s\"", cache_mode);
+ }
+
+ if (seg->policy_name) {
+ outf(f, "policy = \"%s\"", seg->policy_name);
+
+ if (seg->policy_settings) {
+ if (strcmp(seg->policy_settings->key, "policy_settings")) {
+ log_error(INTERNAL_ERROR "Incorrect policy_settings tree, %s.",
+ seg->policy_settings->key);
+ return 0;
+ }
+ if (seg->policy_settings->child)
+ out_config_node(f, seg->policy_settings);
}
- out_config_node(f, seg->policy_settings);
}
return 1;
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 91fcd3b..fbd0663 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -29,7 +29,17 @@
#define DM_HINT_OVERHEAD_PER_BLOCK 8 /* bytes */
#define DM_MAX_HINT_WIDTH (4+16) /* bytes. FIXME Configurable? */
-const char *get_cache_pool_cachemode_name(const struct lv_segment *seg)
+int cache_mode_is_set(const struct lv_segment *seg)
+{
+ if (seg_is_cache(seg))
+ seg = first_seg(seg->pool_lv);
+
+ return (seg->feature_flags & (DM_CACHE_FEATURE_WRITEBACK |
+ DM_CACHE_FEATURE_WRITETHROUGH |
+ DM_CACHE_FEATURE_PASSTHROUGH)) ? 1 : 0;
+}
+
+const char *get_cache_mode_name(const struct lv_segment *seg)
{
if (seg->feature_flags & DM_CACHE_FEATURE_WRITEBACK)
return "writeback";
@@ -46,19 +56,48 @@ const char *get_cache_pool_cachemode_name(const struct lv_segment *seg)
return NULL;
}
-int set_cache_pool_feature(uint64_t *feature_flags, const char *str)
+int cache_set_mode(struct lv_segment *seg, const char *str)
{
+ struct cmd_context *cmd = seg->lv->vg->cmd;
+ int id;
+ uint64_t mode;
+
+ if (!str && !seg_is_cache(seg))
+ return 1; /* Defaults only for cache */
+
+ if (seg_is_cache(seg))
+ seg = first_seg(seg->pool_lv);
+
+ if (!str) {
+ if (cache_mode_is_set(seg))
+ return 1; /* Default already set in cache pool */
+
+ id = allocation_cache_mode_CFG;
+
+ /* If present, check backward compatible settings */
+ if (!find_config_node(cmd, cmd->cft, id) &&
+ find_config_node(cmd, cmd->cft, allocation_cache_pool_cachemode_CFG))
+ id = allocation_cache_pool_cachemode_CFG;
+
+ str = find_config_tree_str(cmd, id, NULL);
+ }
+
if (!strcmp(str, "writeback"))
- *feature_flags |= DM_CACHE_FEATURE_WRITEBACK;
+ mode = DM_CACHE_FEATURE_WRITEBACK;
else if (!strcmp(str, "writethrough"))
- *feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
- else if (!strcmp(str, "passhrough"))
- *feature_flags |= DM_CACHE_FEATURE_PASSTHROUGH;
+ mode = DM_CACHE_FEATURE_WRITETHROUGH;
+ else if (!strcmp(str, "passthrough"))
+ mode = DM_CACHE_FEATURE_PASSTHROUGH;
else {
- log_error("Cache pool feature \"%s\" is unknown.", str);
+ log_error("Cannot set unknown cache mode \"%s\".", str);
return 0;
}
+ seg->feature_flags &= ~(DM_CACHE_FEATURE_WRITEBACK |
+ DM_CACHE_FEATURE_WRITETHROUGH |
+ DM_CACHE_FEATURE_PASSTHROUGH);
+ seg->feature_flags |= mode;
+
return 1;
}
@@ -395,36 +434,72 @@ 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_set_policy(struct logical_volume *lv, const char *name,
- const struct dm_config_tree *settings)
+int cache_set_policy(struct lv_segment *seg, const char *name,
+ const struct dm_config_tree *settings)
{
struct dm_config_node *cn;
+ const struct dm_config_node *cns;
struct dm_config_tree *old = NULL, *new = NULL, *tmp = NULL;
int r = 0;
- struct lv_segment *seg = first_seg(lv);
+ const int passed_seg_is_cache = seg_is_cache(seg);
- if (lv_is_cache(lv))
+ if (passed_seg_is_cache)
seg = first_seg(seg->pool_lv);
- if (seg->policy_settings) {
- if (!(old = dm_config_create()))
- goto_out;
- if (!(new = dm_config_create()))
- goto_out;
- new->root = settings->root;
- old->root = seg->policy_settings;
- new->cascade = old;
- if (!(tmp = dm_config_flatten(new)))
+ if (name) {
+ if (!(seg->policy_name = dm_pool_strdup(seg->lv->vg->vgmem, name))) {
+ log_error("Failed to duplicate policy name.");
+ return 0;
+ }
+ } else if (!seg->policy_name && passed_seg_is_cache)
+ seg->policy_name = find_config_tree_str(seg->lv->vg->cmd, allocation_cache_policy_CFG, NULL);
+
+ if (settings) {
+ if (!seg->policy_name) {
+ log_error(INTERNAL_ERROR "Can't set policy settings without policy name.");
+ return 0;
+ }
+
+ if (seg->policy_settings) {
+ if (!(old = dm_config_create()))
+ goto_out;
+ if (!(new = dm_config_create()))
+ goto_out;
+ new->root = settings->root;
+ old->root = seg->policy_settings;
+ new->cascade = old;
+ if (!(tmp = dm_config_flatten(new)))
+ goto_out;
+ }
+
+ if ((cn = dm_config_find_node((tmp) ? tmp->root : settings->root, "policy_settings")) &&
+ !(seg->policy_settings = dm_config_clone_node_with_mem(seg->lv->vg->vgmem, cn, 0)))
goto_out;
- }
+ } else if (passed_seg_is_cache && /* Look for command's profile cache_policies */
+ (cns = find_config_tree_node(seg->lv->vg->cmd, allocation_cache_settings_CFG_SECTION, NULL))) {
+ /* Try to find our section for given policy */
+ for (cn = cns->child; cn; cn = cn->sib) {
+ /* Only matching section names */
+ if (cn->v || strcmp(cn->key, seg->policy_name) != 0)
+ continue;
+
+ if (!cn->child)
+ break;
+
+ if (!(new = dm_config_create()))
+ goto_out;
- if ((cn = dm_config_find_node((tmp) ? tmp->root : settings->root, "policy_settings")) &&
- !(seg->policy_settings = dm_config_clone_node_with_mem(lv->vg->vgmem, cn, 0)))
- goto_out;
+ if (!(new->root = dm_config_clone_node_with_mem(new->mem,
+ cn->child, 1)))
+ goto_out;
- if (name && !(seg->policy_name = dm_pool_strdup(lv->vg->vgmem, name))) {
- log_error("Failed to duplicate policy name.");
- goto out;
+ if (!(seg->policy_settings = dm_config_create_node(new, "policy_settings")))
+ goto_out;
+
+ seg->policy_settings->child = new->root;
+
+ break; /* Only first match counts */
+ }
}
restart: /* remove any 'default" nodes */
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index df784c1..c775077 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -131,7 +131,7 @@ char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
char *lvseg_cachemode_dup(struct dm_pool *mem, const struct lv_segment *seg)
{
- const char *name = get_cache_pool_cachemode_name(seg);
+ const char *name = get_cache_mode_name(seg);
if (!name)
return_NULL;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b22773e..f13df1b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7264,17 +7264,26 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
memlock_unlock(vg->cmd);
if (seg_is_cache_pool(lp) || seg_is_cache(lp)) {
- pool_lv = pool_lv ? : lv;
- if (!lv_cache_set_policy(pool_lv, lp->policy_name, lp->policy_settings))
- return_NULL; /* revert? */
- first_seg(pool_lv)->chunk_size = lp->chunk_size;
- first_seg(pool_lv)->feature_flags = lp->feature_flags;
- /* TODO: some calc_policy solution for cache ? */
- if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, lp->passed_args,
- THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
+ if (!cache_set_mode(first_seg(lv), lp->cache_mode)) {
+ stack;
+ goto revert_new_lv;
+ }
+
+ if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings)) {
stack;
goto revert_new_lv;
}
+
+ pool_lv = pool_lv ? : lv;
+ if (lp->chunk_size) {
+ first_seg(pool_lv)->chunk_size = lp->chunk_size;
+ /* TODO: some calc_policy solution for cache ? */
+ if (!recalculate_pool_chunk_size_with_dev_hints(pool_lv, lp->passed_args,
+ THIN_CHUNK_SIZE_CALC_METHOD_GENERIC)) {
+ stack;
+ goto revert_new_lv;
+ }
+ }
} else if (seg_is_raid(lp)) {
first_seg(lv)->min_recovery_rate = lp->min_recovery_rate;
first_seg(lv)->max_recovery_rate = lp->max_recovery_rate;
@@ -7478,6 +7487,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
lv = tmp_lv;
+ if (!cache_set_mode(first_seg(lv), lp->cache_mode))
+ return_NULL; /* revert? */
+
+ if (!cache_set_policy(first_seg(lv), lp->policy_name, lp->policy_settings))
+ return_NULL; /* revert? */
+
if (!lv_update_and_reload(lv)) {
/* FIXME Do a better revert */
log_error("Aborting. Manual intervention required.");
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 03a866a..fff24f0 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1153,8 +1153,11 @@ struct lv_status_cache {
dm_percent_t dirty_usage;
};
-const char *get_cache_pool_cachemode_name(const struct lv_segment *seg);
-int set_cache_pool_feature(uint64_t *feature_flags, const char *str);
+const char *get_cache_mode_name(const struct lv_segment *cache_seg);
+int cache_mode_is_set(const struct lv_segment *seg);
+int cache_set_mode(struct lv_segment *cache_seg, const char *str);
+int cache_set_policy(struct lv_segment *cache_seg, const char *name,
+ const struct dm_config_tree *settings);
int update_cache_pool_params(const struct segment_type *segtype,
struct volume_group *vg, unsigned attr,
int passed_args, uint32_t pool_data_extents,
@@ -1165,8 +1168,6 @@ 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_set_policy(struct logical_volume *cache_lv, const char *name,
- const struct dm_config_tree *settings);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
diff --git a/lib/report/report.c b/lib/report/report.c
index c2ab991..a17af32 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2079,7 +2079,7 @@ static int _cachemode_disp(struct dm_report *rh, struct dm_pool *mem,
seg = first_seg(seg->pool_lv);
if (seg_is_cache_pool(seg)) {
- if (!(cachemode_str = get_cache_pool_cachemode_name(seg)))
+ if (!(cachemode_str = get_cache_mode_name(seg)))
return_0;
return dm_report_field_string(rh, field, &cachemode_str);
diff --git a/tools/lvchange.c b/tools/lvchange.c
index a6ad343..e24c07a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -692,7 +692,7 @@ static int _lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume
if (!get_cache_params(cmd, NULL, &name, &settings))
goto_out;
- if (!lv_cache_set_policy(lv, name, settings))
+ if (!cache_set_policy(first_seg(lv), name, settings))
goto_out;
if (!lv_update_and_reload(lv))
goto_out;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index d48af62..040272a 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3070,7 +3070,7 @@ mda_write:
seg->zero_new_blocks = lp->zero ? 1 : 0;
if ((lp->policy_name || lp->policy_settings) &&
- !lv_cache_set_policy(seg->lv, lp->policy_name, lp->policy_settings))
+ !cache_set_policy(seg, lp->policy_name, lp->policy_settings))
return_0;
/* Rename deactivated metadata LV to have _tmeta suffix */
@@ -3178,6 +3178,12 @@ static int _lvconvert_cache(struct cmd_context *cmd,
if (!(cache_lv = lv_cache_create(pool_lv, origin_lv)))
return_0;
+ if (!cache_set_mode(first_seg(cache_lv), lp->cache_mode))
+ return_0;
+
+ if (!cache_set_policy(first_seg(cache_lv), lp->policy_name, lp->policy_settings))
+ return_0;
+
if (!lv_update_and_reload(cache_lv))
return_0;
8 years, 8 months
master - cache: undefined policy is mq
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22a1337a9ba1eb...
Commit: 22a1337a9ba1ebf73c3f0b27f621d9d8917bf6cf
Parent: 969ee25a74b50c42f9a2626b7b8991a3d60f750f
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Aug 11 15:19:00 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:18 2015 +0200
cache: undefined policy is mq
If the policy_name is unspecified in metadata,
it's automatically 'mq'.
---
lib/cache_segtype/cache.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index d74fbf1..93436a3 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -378,7 +378,9 @@ static int _cache_add_target_line(struct dev_manager *dm,
metadata_uuid,
data_uuid,
origin_uuid,
- seg->cleaner_policy ? "cleaner" : cache_pool_seg->policy_name,
+ seg->cleaner_policy ? "cleaner" :
+ /* undefined policy name -> likely an old "mq" */
+ cache_pool_seg->policy_name ? : "mq",
seg->cleaner_policy ? NULL : cache_pool_seg->policy_settings,
cache_pool_seg->chunk_size))
return_0;
8 years, 8 months
master - toollib: get_cache_params
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=969ee25a74b50c...
Commit: 969ee25a74b50c42f9a2626b7b8991a3d60f750f
Parent: 6cde12a013f006c1b27b878593fe0f1e73a5f79a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Thu Jul 23 15:35:12 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:18 2015 +0200
toollib: get_cache_params
Enhance get_cache_params() to read common cache args.
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 2 +-
tools/lvchange.c | 2 +-
tools/lvconvert.c | 31 +++++++++----------------------
tools/lvcreate.c | 19 +++++--------------
tools/toollib.c | 18 +++++++++++++++---
tools/toollib.h | 7 ++++---
7 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index da0ef4d..7c35d13 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.128 -
===================================
+ Enhance toollib's get_cache_params().
Runtime detect presence of cache smq policy.
Add demo cache-mq and cache-smq profiles.
Add cmd profilable allocation/cache_policy,cache_settings,cache_mode.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 7c1752a..03a866a 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -901,7 +901,7 @@ struct lvcreate_params {
uint32_t min_recovery_rate; /* RAID */
uint32_t max_recovery_rate; /* RAID */
- uint64_t feature_flags; /* cache */
+ const char *cache_mode; /* cache */
const char *policy_name; /* cache */
struct dm_config_tree *policy_settings; /* cache */
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 22a407a..a6ad343 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -690,7 +690,7 @@ static int _lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume
goto out;
}
- if (!get_cache_policy_params(cmd, &name, &settings))
+ if (!get_cache_params(cmd, NULL, &name, &settings))
goto_out;
if (!lv_cache_set_policy(lv, name, settings))
goto_out;
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3a7f9ae..d48af62 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -50,7 +50,7 @@ struct lvconvert_params {
uint32_t stripes;
uint32_t stripe_size;
uint32_t read_ahead;
- uint64_t feature_flags; /* cache_pool */
+ const char *cache_mode; /* cache */
const char *policy_name; /* cache */
struct dm_config_tree *policy_settings; /* cache */
@@ -299,26 +299,14 @@ static int _read_pool_params(struct cmd_context *cmd, int *pargc, char ***pargv,
} else if (!strcmp(type_str, "thin-pool"))
thinpool = 1;
- if (cachepool) {
- const char *cachemode = arg_str_value(cmd, cachemode_ARG, NULL);
- if (!cachemode)
- cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
-
- if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
- return_0;
-
- if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
- log_error("Failed to parse cache policy and/or settings.");
- return 0;
- }
- } else {
- if (arg_from_list_is_set(cmd, "is valid only with cache pools",
- cachepool_ARG, cachemode_ARG, -1))
- return_0;
- if (lp->cache) {
- log_error("--cache requires --cachepool.");
- return 0;
- }
+ if (lp->cache && !cachepool) {
+ log_error("--cache requires --cachepool.");
+ return 0;
+ }
+ if ((lp->cache || cachepool) &&
+ !get_cache_params(cmd, &lp->cache_mode, &lp->policy_name, &lp->policy_settings)) {
+ log_error("Failed to parse cache policy and/or settings.");
+ return 0;
}
if (thinpool) {
@@ -3080,7 +3068,6 @@ mda_write:
seg->chunk_size = lp->chunk_size;
seg->discards = lp->discards;
seg->zero_new_blocks = lp->zero ? 1 : 0;
- seg->feature_flags = lp->feature_flags; /* cache-pool */
if ((lp->policy_name || lp->policy_settings) &&
!lv_cache_set_policy(seg->lv, lp->policy_name, lp->policy_settings))
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 12b5166..cc4ef20 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -567,21 +567,14 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
static int _read_cache_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
- const char *cachemode;
-
if (!seg_is_cache(lp) && !seg_is_cache_pool(lp))
return 1;
- if (!(cachemode = arg_str_value(cmd, cachemode_ARG, NULL)))
- cachemode = find_config_tree_str(cmd, allocation_cache_pool_cachemode_CFG, NULL);
-
- if (!set_cache_pool_feature(&lp->feature_flags, cachemode))
- return_0;
-
- if (!get_cache_policy_params(cmd, &lp->policy_name, &lp->policy_settings)) {
- log_error("Failed to parse cache policy and/or settings.");
- return 0;
- }
+ if (!get_cache_params(cmd,
+ &lp->cache_mode,
+ &lp->policy_name,
+ &lp->policy_settings))
+ return_NULL;
return 1;
}
@@ -1089,8 +1082,6 @@ static int _determine_cache_argument(struct volume_group *vg,
/* If cache args not given, use those from cache pool */
if (!arg_is_set(cmd, chunksize_ARG))
lp->chunk_size = first_seg(lv)->chunk_size;
- if (!arg_is_set(cmd, cachemode_ARG))
- lp->feature_flags = first_seg(lv)->feature_flags;
} else if (lv) {
/* Origin exists, create cache pool volume */
if (!validate_lv_cache_create_origin(lv))
diff --git a/tools/toollib.c b/tools/toollib.c
index 0d401e4..fde6c36 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1399,8 +1399,10 @@ static int _validate_cachepool_params(const char *name,
return 1;
}
-int get_cache_policy_params(struct cmd_context *cmd, const char **name,
- struct dm_config_tree **settings)
+int get_cache_params(struct cmd_context *cmd,
+ const char **mode,
+ const char **name,
+ struct dm_config_tree **settings)
{
const char *str;
struct arg_value_group_list *group;
@@ -1408,7 +1410,14 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
struct dm_config_node *cn;
int ok = 0;
- *name = arg_str_value(cmd, cachepolicy_ARG, DEFAULT_CACHE_POLICY);
+ if (mode)
+ *mode = arg_str_value(cmd, cachemode_ARG, NULL);
+
+ if (name)
+ *name = arg_str_value(cmd, cachepolicy_ARG, NULL);
+
+ if (!settings)
+ return 1;
dm_list_iterate_items(group, &cmd->arg_value_groups) {
if (!grouped_arg_is_set(group->arg_values, cachesettings_ARG))
@@ -1429,6 +1438,9 @@ int get_cache_policy_params(struct cmd_context *cmd, const char **name,
goto_out;
}
+ if (!current)
+ return 1;
+
if (!(result = dm_config_flatten(current)))
goto_out;
diff --git a/tools/toollib.h b/tools/toollib.h
index c57cb84..2dc5ad7 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -190,9 +190,10 @@ int get_pool_params(struct cmd_context *cmd,
int get_stripe_params(struct cmd_context *cmd, uint32_t *stripes,
uint32_t *stripe_size);
-int get_cache_policy_params(struct cmd_context *cmd,
- const char **name,
- struct dm_config_tree **settings);
+int get_cache_params(struct cmd_context *cmd,
+ const char **mode,
+ const char **name,
+ struct dm_config_tree **settings);
int change_tag(struct cmd_context *cmd, struct volume_group *vg,
struct logical_volume *lv, struct physical_volume *pv, int arg);
8 years, 8 months
master - cache: man updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6cde12a013f006...
Commit: 6cde12a013f006c1b27b878593fe0f1e73a5f79a
Parent: feb8e9a7907c91bd55769b4e3ae625434f2ba589
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 20 11:55:43 2015 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Aug 12 14:11:17 2015 +0200
cache: man updates
Better man for cachepolicy and cachesettings.
---
man/lvconvert.8.in | 17 ++++++++++++++++-
man/lvcreate.8.in | 24 +++++++++++++++---------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index 576859b..562de1e 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -162,6 +162,10 @@ lvconvert \(em convert a logical volume from linear to mirror or snapshot
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-cachemode
.RI { writeback | writethrough }]
+.RB [ \-\-cachepolicy
+.IR policy ]
+.RB [ \-\-cachesettings
+.IR key=value ]
.RB [ \-\-poolmetadata
.IR CachePoolMetadataLogicalVolume { Name | Path }
|
@@ -222,10 +226,21 @@ Converts logical volume to a cached LV with the use of cache pool
specified with \fB\-\-cachepool\fP.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
.TP
+.B \-\-cachepolicy \fIpolicy
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache policy. \fImq\fP is the basic policy name. \fIsqm\fP is more advanced
+version available in newer kernels.
+.TP
.BR \-\-cachepool " " \fICachePoolLV
This argument is necessary when converting a logical volume to a cache LV.
For more information on cache pool LVs and cache LVs, see \fBlvmcache\fP(7).
.TP
+.BR \-\-cachesettings " " \fIkey=value
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache tunable settings. In most use-cases, default values should be adequate.
+Special string value \fIdefault\fP switches setting back to its default kernel value
+and removes it from the list of settings stored in lvm2 metadata.
+.TP
.BR \-m ", " \-\-mirrors " " \fIMirrors
Specifies the degree of the mirror you wish to create.
For example, "\fB\-m 1\fP" would convert the original logical
@@ -496,7 +511,7 @@ See \fBlvmthin\fP(7) for more info about thin provisioning support.
Uncaches \fICacheLogicalVolume\fP.
Before the volume becomes uncached, cache is flushed.
Unlike with \fB\-\-splitcache\fP the cache pool volume is removed.
-This option could seen as an inverse of \fB\-\-cache\fP.
+This option could be seen as an inverse of \fB\-\-cache\fP.
.SH Examples
Converts the linear logical volume "vg00/lvol1" to a two-way mirror
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 5f5f74b..5f922b4 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -13,13 +13,13 @@ lvcreate \- create a logical volume in an existing volume group
.RI { y | n }]
.RB [ \-H | \-\-cache ]
.RB [ \-\-cachemode
-.RI { writeback | writethrough }]
+.RI { passthrough | writeback | writethrough }]
.RB [ \-\-cachepolicy
.IR policy ]
-.RB [ \-\-cachesettings
-.IR key=value ]
.RB [ \-\-cachepool
.IR CachePoolLogicalVolume { Name | Path }
+.RB [ \-\-cachesettings
+.IR key=value ]
.RB [ \-c | \-\-chunksize
.IR ChunkSize [ bBsSkKmMgG ]]
.RB [ \-\-commandprofile
@@ -188,7 +188,7 @@ See \fBlvmcache\fP(7) for more info about caching support.
Note that the cache segment type requires a dm-cache kernel module version
1.3.0 or greater.
.TP
-.IR \fB\-\-cachemode " {" writeback | writethrough }
+.IR \fB\-\-cachemode " {" passthrough | writeback | writethrough }
Specifying a cache mode determines when the writes to a cache LV
are considered complete. When \fIwriteback\fP is specified, a write is
considered complete as soon as it is stored in the cache pool LV.
@@ -198,10 +198,21 @@ While \fIwritethrough\fP may be slower for writes, it is more
resilient if something should happen to a device associated with the
cache pool LV.
.TP
+.B \-\-cachepolicy \fIpolicy
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache policy. \fImq\fP is the basic policy name. \fIsqm\fP is more advanced
+version available in newer kernels.
+.TP
.IR \fB\-\-cachepool " " CachePoolLogicalVolume { Name | Path }
Specifies the name of cache pool volume name. The other way to specify pool name
is to append name to Volume group name argument.
.TP
+.BR \-\-cachesettings " " \fIkey=value
+Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
+the cache tunable settings. In most use-cases, default values should be adequate.
+Special string value \fIdefault\fP switches setting back to its default kernel value
+and removes it from the list of settings stored in lvm2 metadata.
+.TP
.BR \-c ", " \-\-chunksize " " \fIChunkSize [ \fIbBsSkKmMgG ]
Gives the size of chunk for snapshot, cache pool and thin pool logical volumes.
Default unit is in kilobytes.
@@ -251,11 +262,6 @@ Ignore the flag to skip Logical Volumes during activation.
Use \fB\-\-setactivationskip\fP option to set or reset
activation skipping flag persistently for logical volume.
.TP
-.BR \-\-cachepolicy " " policy ", " \-\-cachesettings " " key=value
-Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
-the cache policy and its associated tunable settings. In most use-cases,
-default values should be adequate.
-.TP
.B \-\-ignoremonitoring
Make no attempt to interact with dmeventd unless \fB\-\-monitor\fP
is specified.
8 years, 8 months