mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
libdm: cache target arg validation
Add some arg validation for dm_tree_node_add_cache_target().
This commit is contained in:
parent
9edd2258ff
commit
08f047eb51
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.105 -
|
Version 1.02.105 -
|
||||||
===================================
|
===================================
|
||||||
|
Add more arg validation for dm_tree_node_add_cache_target().
|
||||||
|
|
||||||
Version 1.02.104 - 10th August 2015
|
Version 1.02.104 - 10th August 2015
|
||||||
===================================
|
===================================
|
||||||
|
@ -3358,6 +3358,32 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
|
|||||||
struct dm_config_node *cn;
|
struct dm_config_node *cn;
|
||||||
struct load_segment *seg;
|
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)))
|
if (!(seg = _add_segment(node, SEG_CACHE, size)))
|
||||||
return_0;
|
return_0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user