Add thin lv and thin pool creation support
v3 cover Add thin lv and thin pool creation support
From: "M. Mohan Kumar" <[email protected]>
Add thin lv and thin pool creation support to lvm2app.
Changes from V2:
* Specify percentage for low water mark threshold instead of number of blocks
* man page update for lvcreate
Changes from previous version:
* Add support to specify data block size and low water mark thresold for newly created thin pool.
* Added support for specifying lowwatermark parameter to thin pool creation in lvcreate command
M. Mohan Kumar (2):
lvm2app: Add thin and thin pool lv creation
master - thin: Add low water mark parameter to pool creation
lib/metadata/lv_manip.c | 2 +- lib/metadata/metadata-exported.h | 1 + liblvm/lvm2app.h | 57 +++++++++++++++++++ liblvm/lvm_lv.c | 116 +++++++++++++++++++++++++++++++++++++++ man/lvcreate.8.in | 11 +++- tools/args.h | 1 + tools/commands.h | 6 +- tools/lvconvert.c | 1 + tools/lvcreate.c | 7 ++- tools/toollib.c | 11 ++++ tools/toollib.h | 1 + 11 files changed, 209 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.11.7
PATCH v3 1/2 lvm2app: Add thin and thin pool lv creation
From: "M. Mohan Kumar" <[email protected]>
Add thin and thin pool lv creation support to lvm library
--- lib/metadata/lv_manip.c | 2 +- lib/metadata/metadata-exported.h | 1 + liblvm/lvm2app.h | 57 +++++++++++++++++++ liblvm/lvm_lv.c | 116 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-)
lib/metadata/lv_manip.c +1 -1
@@ -4518,7 +4518,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct lfirst_seg (lv)->chunk_size = lp->chunk_size;first_seg (lv)->discards = lp->discards;/* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */ -first_seg (lv)->low_water_mark =0 ; +first_seg (lv)->low_water_mark = lp->low_water_mark; }else if (seg_is_thin_volume (lp)) { pool_lv =first_seg (lv)->pool_lv;
lib/metadata/metadata-exported.h +1 -0
@@ -617,6 +617,7 @@ struct lvcreate_params {uint64_t voriginsize;/* snapshot */ uint32_t poolmetadataextents;/* thin pool */ uint64_t poolmetadatasize;/* thin pool */ +uint64_t low_water_mark;/* thin_pool */ struct dm_list *pvh;/* all */ uint32_t permission;/* all */
liblvm/lvm2app.h +57 -0
63 lines not on this page · raw message
liblvm/lvm_lv.c +116 -0
119 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Dne 12.2.2013 18:24, M. Mohan Kumar napsal(a):
Quoted 17 lines
From: "M. Mohan Kumar" <[email protected]>
Add thin and thin pool lv creation support to lvm library
Signed-off-by M. Mohan Kumar <[email protected]>--- lib/metadata/lv_manip.c | 2 +- lib/metadata/metadata-exported.h | 1 + liblvm/lvm2app.h | 57 +++++++++++++++++++ liblvm/lvm_lv.c | 116 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 1 deletion(-)lib/metadata/lv_manip.c +0
-0
lib/metadata/lv_manip.c static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l · line 4521
Quoted 5 lines
lib/metadata/lv_manip.c +1
-1@@ -4518,7 +4518,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct lfirst_seg (lv)->chunk_size = lp->chunk_size;first_seg (lv)->discards = lp->discards;/* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */ -first_seg (lv)->low_water_mark =0 ; +first_seg (lv)->low_water_mark = lp->low_water_mark;
low_water_mark is not supported yet in the lvm2 stack, and there is not yet clear definition how is it going to be used.
For now dmeventd is based on 10sec polling interval.
However there needs to be made clean definition for various error path, and we have to also support 'clean' shutdown for those paths according to defined policy.
Quoted 26 lines
lib/metadata/lv_manip.c +26
-0+threshold specified in percentage, convert that into +number of blocks +*/ + lp.low_water_mark = size / chunk_size * threshold /100 ; +if (!lp.segtype) + return_NULL; +if (!lv_create_single (vg, &lp)) + return_NULL; +if (!(lvl =find_lv_in_vg (vg, pool))) +return NULL ; +return (lv_t ) lvl->lv; +} + +/* Set defaults for thin LV specific parameters */ +static void _lv_set_thin_params (struct lvcreate_params *lp, +vg_t vg,const char *pool, +const char *lvname, +uint64_t extents) +{ +_lv_set_default_params (lp, vg, lvname, extents); + + lp->thin =1 ; + lp->pool = pool; + lp->segtype =get_segtype_from_string (vg->cmd,"thin" ); + + lp->voriginsize = extents * vg->extent_size;
lib/metadata/lv_manip.c static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
Quoted 10 lines
lib/metadata/lv_manip.c +10
-0+ lp->voriginextents =extents_from_size (vg->cmd, lp->voriginsize, + vg->extent_size); + + lp->stripes =1 ; +} + +lv_t lvm_lv_thin (const vg_t vg,const char *pool, +const char *lvname,uint64_t size) +{ +struct lvcreate_params lp = {0 };
I think the lvm2app needs some extension here and rather make the 'lvcreate_params' structure a visible object with some methods, and use just one universal function call to create all types of LVs - so we can better match the internal lvm2 processing. i.e. there is going to be support for creation of thin
lvs with external origins - so adding lvm API call for every possible use case of thin pool is IMHO less clean then maintenance of 'lvcreate_params' object separately from lvm_lv_create() call.
Similar abstraction needs to be made for i.e. lvconvert command, which has an internal lvconvert_params.
Zdenek
PATCH v3 1/2 lvm2app: Add thin and thin pool lv creation
Quoted 10 lines · Zdenek Kabelac
Dne 12.2.2013 18:24, M. Mohan Kumar napsal(a):
lib/metadata/lv_manip.c static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l · line 4521
Quoted 5 lines
first_seg(lv)->chunk_size = lp->chunk_size; first_seg(lv)->discards = lp->discards; /* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */lib/metadata/lv_manip.c +1
-1-first_seg (lv)->low_water_mark =0 ; +first_seg (lv)->low_water_mark = lp->low_water_mark;
low_water_markis not supported yet in the lvm2 stack, and there is not yet clear definition how is it going to be used.
IMHO there is no harm in adding support to specify low water mark during thin pool creation.
Quoted 2 lines
For now dmeventd is based on 10sec polling interval.
Is it not possible to use the 'thin-pool' threshold dm-event instead of 10-sec polling in dmeventd?
Quoted 4 lines
However there needs to be made clean definition for various error path, and we have to also support 'clean' shutdown for those paths according to defined policy.
Could you please explain it further?
Quoted 5 lines
liblvm/lvm_lv.c lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name, uint64_t max_snap_siz · line 444
Quoted 4 lines
liblvm/lvm_lv.c +4
-0+lv_t lvm_lv_thin (const vg_t vg,const char *pool, +const char *lvname,uint64_t size) +{ +struct lvcreate_params lp = {0 };
Quoted 9 lines
I think the lvm2app needs some extension here and rather make the '
lvcreate_params' structure a visible object with some methods, and use just one universal function call to create all types of LVs - so we can better match the internal lvm2 processing. i.e. there is going to be support for creation of thin
lvs with external origins - so adding lvm API call for every possible use case of thin pool is IMHO less clean then maintenance of 'lvcreate_params' object separately fromlvm_lv_create()call.
I agree for a need of a single lv create function capable of creating any LV type and I already posted a RFC version of that patch a month ago.
But providing a simpler interface to create a specific type of LV may also be a valid usecase, where an user does not want to customize/specify each parameters in LV creation.
IIUC by 'support for creation of thin lvs with external origins' you mean creating a thin snapshot LV from a linear LV. In this case lvm_lv_snapshot function needs to be changed, while this function lvm_lv_thin creates only thin Lvs (not thin snapshots)
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Dne 28.2.2013 12:22, M. Mohan Kumar napsal(a):
Quoted 13 lines
Quoted 10 lines · Zdenek Kabelac
Dne 12.2.2013 18:24, M. Mohan Kumar napsal(a):
lib/metadata/lv_manip.c static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l · line 4521
Quoted 5 lines
first_seg(lv)->chunk_size = lp->chunk_size; first_seg(lv)->discards = lp->discards; /* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */lib/metadata/lv_manip.c +1
-1-first_seg (lv)->low_water_mark =0 ; +first_seg (lv)->low_water_mark = lp->low_water_mark;
low_water_markis not supported yet in the lvm2 stack, and there is not yet clear definition how is it going to be used.
Quoted 2 lines
IMHO there is no harm in adding support to specify low water mark during thin pool creation.
It's not yet even decided what would be the unit on lvm side. It could be percentage either as int - or percent_t, or the size in blocks or something like that.
Quoted 6 lines
Quoted 3 lines
For now dmeventd is based on 10sec polling interval.
Is it not possible to use the 'thin-pool' threshold dm-event instead of 10-sec polling in dmeventd?
That's the key problem here. We need to have policy defined - since i.e. if you set watermark on 75% and you start the pool already 80% full (and you don't know the fullness until pool is started) there would be no message -> no trial to expand the pool. On the other hand it's valid request to start thinpool which is above the threshold - but how it should behave in this case must be driven by some rules. There could be 'soft' watermark - to run even tools like 'fstrim' and then there could be 'hard' watermark to support activation only in 'read-only' mode or even avoid activation completely. As you can see there could be tons of options but on the other hand we should avoid creating some hardly configurable policies here where user would need to spend week to even understand them.
Quoted 6 lines
Quoted 4 lines
However there needs to be made clean definition for various error path, and we have to also support 'clean' shutdown for those paths according to defined policy.
Could you please explain it further?
One of current problems in lvm2 is if you have overfilled pool - it stays stuck awaiting on pool extension - and there is no way to shutdown machine 'cleanly' in this state (i.e. user has no drive to attach, or simply needs to reboot)
Quoted 7 lines
I agree for a need of a single lv create function capable of creating any LV type and I already posted a RFC version of that patch a month ago.
But providing a simpler interface to create a specific type of LV may also be a valid usecase, where an user does not want to customize/specify each parameters in LV creation.
Simplier interfaces have the problem - it could make the future extension of interface much harder if you want to keep them supported.
i.e. lot's of decision in lvm2 is currently based on lvm.conf.
But lvm2api is currently missing these - so this needs to be addressed as well.
Quoted 5 lines
IIUC by 'support for creation of thin lvs with external origins' you mean creating a thin snapshot LV from a linear LV. In this case
lvm_lv_snapshotfunction needs to be changed, while this functionlvm_lv_thincreates only thin Lvs (not thin snapshots)
As you could see yourself - it's getting to be a lvm2api user's problem to figure out, how to actually create a specific LV - API user would need to scan number of 'lvcreate' function and try to figure out which function to call, instead of having single call with 'lvcreate_params' - so IMHO I'd prefer to avoid creating this 'array' of 'simple' interfaces even though all those functions could be possible later turned into wrappers calling one universal function - but why not start directly with the proper way.
Zdenek
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Quoted 8 lines · Zdenek Kabelac
As you could see yourself - it's getting to be a lvm2api user's problem to figure out, how to actually create a specific LV - API user would need to scan number of 'lvcreate' function and try to figure out which function to call, instead of having single call with '
lvcreate_params'
- so IMHO I'd prefer to avoid creating this 'array' of 'simple' interfaces even though all those functions could be possible later turned into wrappers calling one universal function - but why not start directly with the proper way.
Obviously there are pros and cons to either approach. In my opinion having a single function call that takes 20 parameters is no easier to use than a 20 separate function calls. The complexity is present in both.
In my opinion it would be useful to have a simple function that satisfies 90% of what most users use and then have one or two addition functions that satisfy the other corner cases.
To date I believe the following options have been proposed (please correct):
1. Separate functions with varying amounts of increased functionality
2. One function that does everything
a. Expose large structure for parameters
b. Expose string with one or parameters embedded in it
c. Set/get functions on an opaque data structure which en-composes all
the options (eg. getsockopt/setsockopt)
I believe that whatever we choose needs to be able to accommodate future change as new things will be added over time.
For each of these options I see the following concerns:
1. No one seems particularly interested in this option, but it would work. Downside is big name space and complexity of figuring out which one you want.
2a. Exposing a large structure has the problem of how you extend it over time. Do you create a new structure and create a new function that takes that new structure or do you pass a void type with a size and select the structure based on size etc. Once you expose it, it can never change.
2b. Using a string for parameters introduces a different set of issues.
The client needs to be able to correctly create the string. The
library needs to parse the string. You lose type safety and you don't know until run-time that the parameters are correct/incorrect.
2c. This option requires more code, but allows you to change the implementation of the API and allows you to extend the API easily.
Obviously it is easy to see that I favor option 2c. This is also the suggested way by others as well (https://github.com/shepjeng/libabc).
Comments?
Regards,
Tony
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Dne 28.2.2013 21:33, Tony Asleson napsal(a):
Quoted 41 lines · Zdenek Kabelac
Quoted 8 lines
As you could see yourself - it's getting to be a lvm2api user's problem to figure out, how to actually create a specific LV - API user would need to scan number of 'lvcreate' function and try to figure out which function to call, instead of having single call with '
lvcreate_params'
- so IMHO I'd prefer to avoid creating this 'array' of 'simple' interfaces even though all those functions could be possible later turned into wrappers calling one universal function - but why not start directly with the proper way.Obviously there are pros and cons to either approach. In my opinion having a single function call that takes 20 parameters is no easier to use than a 20 separate function calls. The complexity is present in both.
In my opinion it would be useful to have a simple function that satisfies 90% of what most users use and then have one or two addition functions that satisfy the other corner cases.
To date I believe the following options have been proposed (please correct):
1. Separate functions with varying amounts of increased functionality
2. One function that does everything
a. Expose large structure for parameters
b. Expose string with one or parameters embedded in it
c. Set/get functions on an opaque data structure which en-composes all
the options (eg. getsockopt/setsockopt)I believe that whatever we choose needs to be able to accommodate future change as new things will be added over time.
2a. Exposing a large structure has the problem of how you extend it over time. Do you create a new structure and create a new function that takes that new structure or do you pass a void type with a size and select the structure based on size etc. Once you expose it, it can never change.
2b. Using a string for parameters introduces a different set of issues.
The client needs to be able to correctly create the string. The
library needs to parse the string. You lose type safety and you don't know until run-time that the parameters are correct/incorrect.
Quoted 5 lines
2c. This option requires more code, but allows you to change the implementation of the API and allows you to extend the API easily.
Obviously it is easy to see that I favor option 2c. This is also the suggested way by others as well (https://github.com/shepjeng/libabc).
API should never expose structure - only handlers, so obviously 2c is the only way.
My idea here would be - we may add multiple different functions how to create 'lvcreate_params' 'object'.
So there could be a simple function call to prepare such object for thin volume creation - or for snapshot of an LV.
And then having separate 'tiny' functions get/set for individual options we support.
But there should be one entrance to 'lvm_lvcreate' function with such object.
API should also be replaceable for the current API used by lvm commands, so those should be converted to use lvm library over the time as well.
So that's why I'm proposing to go with lvcreate_params way - since this way we may get relatively nice mapping.
Though the command are doing massive 'validation' of options - and the question is - is this validation supposed to be happing also with lvm2api? If so - that's another thing which will require some thinking.
Zdenek
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Quoted 47 lines · Zdenek Kabelac
Dne 28.2.2013 21:33, Tony Asleson napsal(a):
Quoted 46 lines · Zdenek Kabelac
Quoted 8 lines
As you could see yourself - it's getting to be a lvm2api user's problem to figure out, how to actually create a specific LV - API user would need to scan number of 'lvcreate' function and try to figure out which function to call, instead of having single call with '
lvcreate_params'
- so IMHO I'd prefer to avoid creating this 'array' of 'simple' interfaces even though all those functions could be possible later turned into wrappers calling one universal function - but why not start directly with the proper way.Obviously there are pros and cons to either approach. In my opinion having a single function call that takes 20 parameters is no easier to use than a 20 separate function calls. The complexity is present in both.
In my opinion it would be useful to have a simple function that satisfies 90% of what most users use and then have one or two addition functions that satisfy the other corner cases.
To date I believe the following options have been proposed (please correct):
1. Separate functions with varying amounts of increased functionality
2. One function that does everything
a. Expose large structure for parameters
b. Expose string with one or parameters embedded in it
c. Set/get functions on an opaque data structure which en-composes all
the options (eg. getsockopt/setsockopt)I believe that whatever we choose needs to be able to accommodate future change as new things will be added over time.
2a. Exposing a large structure has the problem of how you extend it over time. Do you create a new structure and create a new function that takes that new structure or do you pass a void type with a size and select the structure based on size etc. Once you expose it, it can never change.
2b. Using a string for parameters introduces a different set of issues.
The client needs to be able to correctly create the string. The
library needs to parse the string. You lose type safety and you don't know until run-time that the parameters are correct/incorrect.2c. This option requires more code, but allows you to change the implementation of the API and allows you to extend the API easily.
Quoted 8 lines
Quoted 2 lines
Obviously it is easy to see that I favor option 2c. This is also the suggested way by others as well (https://github.com/shepjeng/libabc).
API should never expose structure - only handlers, so obviously 2c is the only way.
My idea here would be - we may add multiple different functions how to create '
lvcreate_params' 'object'.
I initially was thinking the same way, but now I'm asking myself is it any easier to have a bunch of initializer functions to create an object that has to be passed to one function that does the work instead of number of functions? With this new object we have yet one more piece of memory on the heap that needs to be cleaned up to prevent leaks after the call is completed. Not a horrible requirement, but kind of a pain for the simple generic use cases.
Realistically, how many different default constructor/initializer are we looking at?
Quoted 4 lines
So there could be a simple function call to prepare such object for thin volume creation - or for snapshot of an LV.
And then having separate 'tiny' functions get/set for individual options we support.
In OOA/OOP having many get and set functions for a class can be indicative of a poor design. Ideally objects should have data and behavior. In this case we have an object for the sole purpose as an encapsulated parameter passer. Ideally the get/set functions would only be available for those options that are common to all lv parameters. Otherwise a user could be setting or getting a value that has absolutely no meaning in their context. We could achieve this by having the initializers functions take parameters that only pertain to them, but we are then creating complexity for non advanced use cases who just want to use the defaults.
We could also create a different object parameter type for each use case, but then we end up having more functions to pass the parameter too if we want to maintain type safety. However, we would ensure that get/set functions would not get called spuriously.
Quoted 6 lines
But there should be one entrance to '
lvm_lvcreate' function with such object.API should also be replaceable for the current API used by lvm commands, so those should be converted to use lvm library over the time as well.
Quoted 6 lines
So that's why I'm proposing to go with
lvcreate_paramsway - since this way we may get relatively nice mapping.Though the command are doing massive 'validation' of options - and the question is - is this validation supposed to be happing also with lvm2api? If so - that's another thing which will require some thinking.
The validation should be done in one spot for both. In my opinion the code should parse the arguments and then call the appropriate function which in turn validates the values. Otherwise we have duplicate code and more opportunities to fix the same bug more than once.
At the moment I've kind of exhausted everything I can think of. Does anyone else have any ideas that would lend itself to an API that can accommodate a plethora of configurable options, allow a sane default for common uses cases and not create any potential opportunities for incorrect use?
Regards,
Tony
PATCH 1/2 lvm2app: Add thin and thin pool lv creation
Quoted 5 lines · Tony Asleson
At the moment I've kind of exhausted everything I can think of. Does anyone else have any ideas that would lend itself to an API that can accommodate a plethora of configurable options, allow a sane default for common uses cases and not create any potential opportunities for incorrect use?
I just want an API so I can create thinp LVs from a pool from scratch, and create thinp LVs based on another thinp LV.
I don't care about options. Use the defaults. Let's get something going and then iterate.
-- Andy
PATCH v3 2/2 master - thin: Add low water mark parameter to pool creation
In reply to M. Mohan KumarFrom: "M. Mohan Kumar" <[email protected]>
Add --lowwatermark parameter to thin-pool creation. It enables sending dmevent when the percentage of free blocks in the pool reaches below this percent
--- man/lvcreate.8.in | 11 ++++++++++- tools/args.h | 1 + tools/commands.h | 6 ++++-- tools/lvconvert.c | 1 + tools/lvcreate.c | 7 ++++++- tools/toollib.c | 11 +++++++++++ tools/toollib.h | 1 + 7 files changed, 34 insertions(+), 4 deletions(-)
man/lvcreate.8.in +10 -1
@@ -57,7 +57,9 @@ lvcreate \- create a logical volume in an existing volume group .RB [ \-\-discards .RI { ignore | nopassdown | passdown }] .RB [ \-\-poolmetadatasize -.IR ThinPoolMetadataSize [ bBsSkKmMgG ]]] +.IR ThinPoolMetadataSize [ bBsSkKmMgG ]] +.RB [ \-\-lowwatermark +.IR ThinPoolLowWaterMarkThreshold in percentage ]] .RB [ \-\-thinpool .IR ThinPoolLogicalVolume { Name | Path }] .RB [ \-\-type
@@ -246,6 +248,13 @@ Supported value is in range between 2MiB and 16GiB. Default value is (Pool_LV_size / Pool_LV_chunk_size * 64b). Default unit is megabytes. .TP +.IR \fB\-\-lowwatermark " " ThinPoolLowWaterMarkThreshold in percentage +Set the low water mark threshold of thin pool logical volume. +Supported value is in range between 0 and 100. +Default value is 0, meaning a dm event will be generated only when +all blocks in the pool are consumed. A value of 25 means dm event will +be generated when percentage of free blocks in the pool becomes <= 25% +.TP .IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none } Set read ahead sector count of this logical volume. For volume groups with metadata in lvm1 format, this must
tools/args.h +1 -0
@@ -77,6 +77,7 @@ arg(force_long_ARG, '\0', "force", NULL, ARG_COUNTABLE) arg(stripes_long_ARG, '\0', "stripes", int_arg, 0) arg(sysinit_ARG, '\0', "sysinit", NULL, 0) arg(thinpool_ARG, '\0', "thinpool", string_arg, 0) +arg (lowwatermark_ARG,'\0' ,"lowwatermark" , int_arg,0 ) /* Allow some variations */arg (resizable_ARG,'\0' ,"resizable" , yes_no_arg,0 )
tools/commands.h +4 -2
@@ -185,7 +185,8 @@ xx(lvcreate,"\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[-R|--regionsize MirrorLogRegionSize]\n" "\t[-T|--thin [-c|--chunksize ChunkSize]\n" -"\t [--discards {ignore|nopassdown|passdown}]\n" +"\t [--discards {ignore|nopassdown|passdown}] \n" +"\t [--lowwatermark low_water_mark threshold in percentage of total number of blocks] \n" "\t [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]\n" "\t[--thinpool ThinPoolLogicalVolume{Name|Path}]\n" "\t[-t|--test]\n"
@@ -232,7 +233,8 @@ xx(lvcreate, monitor_ARG, name_ARG, nosync_ARG, 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, poolmetadatasize_ARG, virtualsize_ARG, zero_ARG) + virtualoriginsize_ARG, poolmetadatasize_ARG, virtualsize_ARG, zero_ARG, + lowwatermark_ARG) xx(lvdisplay, "Display information about a logical volume",
tools/lvconvert.c +1 -0
@@ -352,6 +352,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd, &lp->chunk_size, &lp->discards, &lp->poolmetadata_size, +NULL , &lp->zero)) return_0;
tools/lvcreate.c +6 -1
@@ -799,7 +799,8 @@ static int _lvcreate_params(struct lvcreate_params *lp, !get_stripe_params (cmd, &lp->stripes, &lp->stripe_size) || (lp->create_thin_pool && !get_pool_params (cmd, &lp->chunk_size, &lp->discards, - &lp->poolmetadatasize, &lp->zero)) || + &lp->poolmetadatasize, &lp->low_water_mark, + &lp->zero)) || !_read_mirror_params (lp, cmd) || !_read_raid_params(lp, cmd)) return_0;
@@ -926,6 +927,10 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_paramlog_error ("--zero may only be specified when allocating the thin pool." );return 0 ; } +if (arg_count (vg->cmd, lowwatermark_ARG)) { +log_error ("--lowwatermark may only be specified when allocating the thin pool." ); +return 0 ; + } }if (lp->create_thin_pool && lp->pool) {
tools/toollib.c +11 -0
@@ -1525,9 +1525,11 @@ int get_pool_params(struct cmd_context *cmd,uint32_t *chunk_size, thin_discards_t *discards, uint64_t *pool_metadata_size, + uint64_t *lowwatermark, int *zero) { const char *dstr; +int lwm;if (arg_count (cmd, zero_ARG)) { *zero =strcmp (arg_str_value (cmd, zero_ARG,"y" ),"n" );
@@ -1577,6 +1579,15 @@ int get_pool_params(struct cmd_context *cmd, } *pool_metadata_size =arg_uint64_value (cmd, poolmetadatasize_ARG,UINT64_C (0 )); +if (lowwatermark) { +if (arg_sign_value (cmd, lowwatermark_ARG,SIGN_NONE ) ==SIGN_MINUS ) { +log_error ("Negative low water mark threshold is invalid." ); +return 0 ; + } + + lwm =arg_uint_value (cmd, lowwatermark_ARG,UINT32_C (0 )); + *lowwatermark = *pool_metadata_size / *chunk_size * lwm *100 ; + }return 1 ; }
tools/toollib.h +1 -0
@@ -115,6 +115,7 @@ int get_pool_params(struct cmd_context *cmd,uint32_t *chunk_size, thin_discards_t *discards, uint64_t *pool_metadata_size, + uint64_t *lowwatermark, int *zero); int update_pool_params(struct cmd_context *cmd, unsigned attr, uint32_t data_extents, uint32_t extent_size,
Signature · 1 line
1.7.11.7