diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2011-11-04 22:43:10 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2011-11-04 22:43:10 +0000 |
commit | b8cac455bdb5675a4502585d5a494cd23c899d02 (patch) | |
tree | e4fbd6a528fee313f01ece94bee0855606ba93a8 /tools | |
parent | 19e3f8c30ba814f98078cae6bcd749818b0b8faa (diff) | |
download | lvm2-b8cac455bdb5675a4502585d5a494cd23c899d02.tar.gz lvm2-b8cac455bdb5675a4502585d5a494cd23c899d02.tar.xz lvm2-b8cac455bdb5675a4502585d5a494cd23c899d02.zip |
Thin supports poolmetadatasize setting
Add option to set pool metadatasize.
For passing size parameter reuse region_size.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/args.h | 1 | ||||
-rw-r--r-- | tools/commands.h | 3 | ||||
-rw-r--r-- | tools/lvcreate.c | 58 |
3 files changed, 60 insertions, 2 deletions
diff --git a/tools/args.h b/tools/args.h index a6172910..9f0e5794 100644 --- a/tools/args.h +++ b/tools/args.h @@ -69,6 +69,7 @@ arg(dataalignmentoffset_ARG, '\0', "dataalignmentoffset", size_kb_arg, 0) arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0) arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0) arg(poll_ARG, '\0', "poll", yes_no_arg, 0) +arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0) arg(stripes_long_ARG, '\0', "stripes", int_arg, 0) arg(sysinit_ARG, '\0', "sysinit", NULL, 0) arg(thinpool_ARG, '\0', "thinpool", string_arg, 0) diff --git a/tools/commands.h b/tools/commands.h index bbc27854..ca6d9f48 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -192,6 +192,7 @@ xx(lvcreate, "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" "\t{-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |\n" "\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n" + "\t[--poolmetadatasize Size[bBsSkKmMgG]]\n" "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" "\t[-n|--name LogicalVolumeName]\n" "\t[--noudevsync]\n" @@ -210,7 +211,7 @@ xx(lvcreate, noudevsync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, thin_ARG, thinpool_ARG, type_ARG, virtualoriginsize_ARG, - virtualsize_ARG, zero_ARG) + poolmetadatasize_ARG, virtualsize_ARG, zero_ARG) xx(lvdisplay, "Display information about a logical volume", diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 9b55fd06..ee5eab9c 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -283,6 +283,17 @@ static int _update_extents_params(struct volume_group *vg, case PERCENT_NONE: break; } + + if (lp->create_thin_pool && !lp->poolmetadatasize) + /* Defaults to nr_pool_blocks * 64b */ + lp->poolmetadatasize = (uint64_t) lp->extents * vg->extent_size / + (uint64_t) lp->chunk_size * UINT64_C(64); + + if (lp->poolmetadatasize && + !(lp->poolmetadataextents = extents_from_size(vg->cmd, lp->poolmetadatasize, + vg->extent_size))) + return_0; + return 1; } @@ -323,6 +334,18 @@ static int _read_size_params(struct lvcreate_params *lp, if (lp->thin && (arg_count(cmd, size_ARG) || arg_count(cmd, extents_ARG))) lp->create_thin_pool = 1; + if (arg_count(cmd, poolmetadatasize_ARG)) { + if (!seg_is_thin(lp)) { + log_error("--poolmetadatasize may only be specified when allocating the thin pool."); + return 0; + } + if (arg_sign_value(cmd, poolmetadatasize_ARG, 0) == SIGN_MINUS) { + log_error("Negative poolmetadatasize is invalid."); + return 0; + } + lp->poolmetadatasize = arg_uint64_value(cmd, poolmetadatasize_ARG, UINT64_C(0)); + } + /* Size returned in kilobyte units; held in sectors */ if (arg_count(cmd, virtualsize_ARG)) { if (seg_is_thin_pool(lp)) { @@ -478,6 +501,33 @@ static int _read_raid_params(struct lvcreate_params *lp, return 1; } +static int _read_thin_params(struct lvcreate_params *lp, + struct cmd_context *cmd) +{ + if (!seg_is_thin(lp)) { + if (lp->poolmetadatasize) { + log_error("Pool metadata size option is only for pool creation."); + return 0; + } + return 1; + } + + if (lp->create_thin_pool) { + if (lp->poolmetadatasize > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) { + log_warn("WARNING: Maximum supported pool metadata size is 16GB."); + lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE; + } else if (lp->poolmetadatasize < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) + lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE; + log_verbose("Setting pool metadata size to %" PRIu64 " sectors.", + lp->poolmetadatasize); + } else if (lp->poolmetadatasize) { + log_error("Pool metadata size options is only for pool creation."); + return 0; + } + + return 1; +} + static int _read_activation_params(struct lvcreate_params *lp, struct cmd_context *cmd) { unsigned pagesize; @@ -677,7 +727,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, !_read_size_params(lp, lcp, cmd) || !get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) || !_read_mirror_params(lp, cmd) || - !_read_raid_params(lp, cmd)) + !_read_raid_params(lp, cmd) || + !_read_thin_params(lp, cmd)) return_0; if (lp->snapshot && lp->thin && arg_count(cmd, chunksize_ARG)) @@ -796,6 +847,11 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param return 0; } + if (arg_count(vg->cmd, poolmetadatasize_ARG)) { + log_error("--poolmetadatasize may only be specified when allocating the thin pool."); + return 0; + } + if (arg_count(vg->cmd, stripesize_ARG)) { log_error("--stripesize may only be specified when allocating the thin pool."); return 0; |