master - macros: Use is_power_of_2.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aed8bc8ae7b2f1c20a84470b033daababfb7c166 Commit: aed8bc8ae7b2f1c20a84470b033daababfb7c166 Parent: a8e39530efdffc42d21e9bc968ab3966b719876a Author: Alasdair G Kergon <[email protected]> AuthorDate: Thu Jun 30 17:59:44 2016 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Thu Jun 30 17:59:44 2016 +0100
macros: Use is_power_of_2.
--- WHATS_NEW | 1 + lib/format_pool/import_export.c | 2 +- lib/metadata/lv_manip.c | 4 ++-- lib/metadata/thin_manip.c | 2 +- lib/metadata/vg.c | 4 ++-- lib/thin/thin.c | 4 ++-- tools/lvconvert.c | 4 ++-- tools/lvcreate.c | 4 ++-- tools/toollib.c | 2 +- 9 files changed, 14 insertions(+), 13 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.159 - ================================= + Introduce and use is_power_of_2 macro. Support conversions between striped and raid0 segment types. Add infrastructure for raid takeover lvconvert options.
lib/format_pool/import_export.c +1 -1
@@ -181,7 +181,7 @@ static int _add_stripe_seg(struct dm_pool *mem,unsigned j;uint32_t area_len; -if (usp->striping & (usp->striping -1 )) { +if (!is_power_of_2 (usp->striping)) {log_error ("Stripe size must be a power of 2" );return 0 ; }
lib/metadata/lv_manip.c +2 -2
@@ -712,7 +712,7 @@ int get_default_region_size(struct cmd_context *cmd) {int region_size =_get_default_region_size (cmd); -if (region_size & (region_size -1 )) { +if (!is_power_of_2 (region_size)) { region_size =_round_down_pow2 (region_size);log_verbose ("Reducing region size to %u kiB (power of 2)." , region_size /2 );
@@ -4329,7 +4329,7 @@ static int _validate_stripesize(const struct volume_group *vg, lp->stripe_size = vg->extent_size; } -if (lp->stripe_size & (lp->stripe_size -1 )) { +if (!is_power_of_2 (lp->stripe_size)) {log_error ("Stripe size must be power of 2." );return 0 ; }
lib/metadata/thin_manip.c +1 -1
@@ -588,7 +588,7 @@ int update_thin_pool_params(const struct segment_type *segtype, *zero =find_config_tree_bool (cmd, allocation_thin_pool_zero_CFG, profile);if (!(attr &THIN_FEATURE_BLOCK_SIZE ) && - (*chunk_size & (*chunk_size -1 ))) { + !is_power_of_2 (*chunk_size)) {log_error ("Chunk size must be a power of 2 for this thin target version." );return 0 ; }
lib/metadata/vg.c +2 -2
@@ -379,7 +379,7 @@ int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_ }if ((fmt->features &FMT_NON_POWER2_EXTENTS )) { -if ((new_extent_size & (new_extent_size -1 )) && +if (!is_power_of_2 (new_extent_size) && (new_extent_size %MIN_NON_POWER2_EXTENT_SIZE )) {log_error ("Physical Extent size must be a multiple of %s when not a power of 2." ,display_size (fmt->cmd, (uint64_t )MIN_NON_POWER2_EXTENT_SIZE ));
@@ -389,7 +389,7 @@ int vg_check_new_extent_size(const struct format_type *fmt, uint32_t new_extent_ }/* Apply original format1 restrictions */ -if ((new_extent_size & (new_extent_size -1 ))) { +if (!is_power_of_2 (new_extent_size)) {log_error ("Metadata format only supports Physical Extent sizes that are powers of 2." );return 0 ; }
lib/thin/thin.c +2 -2
@@ -271,7 +271,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm, }if (!(attr &THIN_FEATURE_BLOCK_SIZE ) && - (seg->chunk_size & (seg->chunk_size -1 ))) { + !is_power_of_2 (seg->chunk_size)) {log_error ("Thin pool target does not support %s chunk size (needs" " kernel >= 3.6)." ,display_size (cmd, seg->chunk_size));return 0 ;
@@ -311,7 +311,7 @@ static int _thin_pool_add_target_line(struct dev_manager *dm,/* Use ignore for discards ignore or non-power-of-2 chunk_size and <1.5 target */ /* FIXME: Check whether underlying dev supports discards */ if (((!(attr &THIN_FEATURE_DISCARDS_NON_POWER_2 ) && - (seg->chunk_size & (seg->chunk_size -1 ))) || + !is_power_of_2 (seg->chunk_size)) || (seg->discards ==THIN_DISCARDS_IGNORE ))) {if (!dm_tree_node_set_thin_pool_discard (node,1 ,0 )) return_0;
tools/lvconvert.c +2 -2
@@ -650,7 +650,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv, lp->chunk_size =arg_uint_value (cmd, chunksize_ARG,8 );if (lp->chunk_size <8 || lp->chunk_size >1024 || - (lp->chunk_size & (lp->chunk_size -1 ))) { + !is_power_of_2 (lp->chunk_size)) {log_error ("Chunk size must be a power of 2 in the " "range 4K to 512K" );return 0 ;
@@ -724,7 +724,7 @@ static int _read_params(struct cmd_context *cmd, int argc, char **argv,return 0 ; } -if (lp->region_size & (lp->region_size -1 )) { +if (!is_power_of_2 (lp->region_size)) {log_error ("Region size (%" PRIu32") must be a power of 2" , lp->region_size);return 0 ;
tools/lvcreate.c +2 -2
@@ -555,7 +555,7 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,return 0 ; } -if (lp->region_size & (lp->region_size -1 )) { +if (!is_power_of_2 (lp->region_size)) {log_error ("Region size (%" PRIu32") must be a power of 2" , lp->region_size);return 0 ;
@@ -1036,7 +1036,7 @@ static int _lvcreate_params(struct cmd_context *cmd,if (lp->snapshot && (lp->extents || lcp->size)) { lp->chunk_size =arg_uint_value (cmd, chunksize_ARG,8 );if (lp->chunk_size <8 || lp->chunk_size >1024 || - (lp->chunk_size & (lp->chunk_size -1 ))) { + !is_power_of_2 (lp->chunk_size)) {log_error ("Chunk size must be a power of 2 in the " "range 4K to 512K." );return 0 ;
tools/toollib.c +1 -1
@@ -1294,7 +1294,7 @@ static int _validate_stripe_params(struct cmd_context *cmd, uint32_t *stripes, }if (*stripes >1 && (*stripe_size <STRIPE_SIZE_MIN || - *stripe_size & (*stripe_size -1 ))) { + !is_power_of_2 (*stripe_size))) {log_error ("Invalid stripe size %s." ,display_size (cmd, (uint64_t ) *stripe_size));return 0 ;