Add thin lv and thin pool creation support
v2 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 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 | 53 +++++++++++++++++++ liblvm/lvm_lv.c | 107 +++++++++++++++++++++++++++++++++++++++ tools/args.h | 1 + tools/commands.h | 6 ++- tools/lvconvert.c | 1 + tools/lvcreate.c | 7 ++- tools/toollib.c | 4 ++ tools/toollib.h | 1 + 10 files changed, 179 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.11.7
PATCH v2 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 | 53 +++++++++++++++++++ liblvm/lvm_lv.c | 107 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 162 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 +53 -0
59 lines not on this page · raw message
liblvm/lvm_lv.c +107 -0
110 lines not on this page · raw message
Signature · 1 line
1.7.11.7
PATCH v2 2/2 master - thin: Add lowwatermark 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 number of free blocks in the pool reaches below this number.
--- tools/args.h | 1 + tools/commands.h | 6 ++++-- tools/lvconvert.c | 1 + tools/lvcreate.c | 7 ++++++- tools/toollib.c | 4 ++++ tools/toollib.h | 1 + 6 files changed, 17 insertions(+), 3 deletions(-)
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 thresold] \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 +4 -0
@@ -1525,6 +1525,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) { const char *dstr;
@@ -1577,6 +1578,9 @@ int get_pool_params(struct cmd_context *cmd, } *pool_metadata_size =arg_uint64_value (cmd, poolmetadatasize_ARG,UINT64_C (0 )); +if (lowwatermark) + *lowwatermark =arg_uint64_value (cmd, lowwatermark_ARG,UINT64_C (0 )); +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
v2 cover Add thin lv and thin pool creation support
In reply to M. Mohan KumarQuoted 9 lines · M. Mohan Kumar
From: "M. Mohan Kumar" <[email protected]>
Add thin lv and thin pool creation support to lvm2app.
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
OK, so the block size if specified as 0 results in a default value being selected as before, which is what I believe we want. The default low water mark was 0, which is what we believe disables event creation. This doesn't appear to be a safe default behavior?
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Once we have defined what the default values are, I can modify my python bindings patch to use these default values.
Thanks,
Tony
v2 cover Add thin lv and thin pool creation support
Dne 31.1.2013 22:04, Tony Asleson napsal(a):
Quoted 24 lines · M. Mohan Kumar
Quoted 9 lines
From: "M. Mohan Kumar" <[email protected]>
Add thin lv and thin pool creation support to lvm2app.
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 commandOK, so the block size if specified as 0 results in a default value being selected as before, which is what I believe we want. The default low water mark was 0, which is what we believe disables event creation. This doesn't appear to be a safe default behavior?
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Quoted 3 lines
Once we have defined what the default values are, I can modify my python bindings patch to use these default values.
Currently the lowwatermark setting are unused by dm driver - since we need to first resolve policies.
Reason why they are not yet support (and dmeventd only does pooling) is, that we have to make sure during all activations, we are not starting thinpool which is past the threshold - and there are many ways how to deal with this state.
Also - for now - there is no per-pool threshold setting - IMHO this should be improved - and it's the same problem lvm2 has with i.e. mirror/raid, where many setting are currently set only via lvm.conf - while there is no option for LV override - this should be probably resolved at global level.
Zdenek
v2 cover Add thin lv and thin pool creation support
Quoted 30 lines · Zdenek Kabelac
Dne 31.1.2013 22:04, Tony Asleson napsal(a):
Quoted 27 lines · M. Mohan Kumar
Quoted 9 lines
From: "M. Mohan Kumar" <[email protected]>
Add thin lv and thin pool creation support to lvm2app.
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 commandOK, so the block size if specified as 0 results in a default value being selected as before, which is what I believe we want. The default low water mark was 0, which is what we believe disables event creation. This doesn't appear to be a safe default behavior?
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Once we have defined what the default values are, I can modify my python bindings patch to use these default values.
Hi Zdenek,
Quoted 2 lines
Currently the lowwatermark setting are unused by dm driver - since we need to first resolve policies.
dm-thin target checks for current free block vs low water threshold blocks and sends dm event
dm-thin.c:alloc_data_block()
if (free_blocks <= pool->low_water_blocks &&
!pool->low_water_triggered) {
DMWARN("%s: reached low water mark, sending event.",
dm_device_name(pool->pool_md));And when I tested my api to create a thin pool & thin LV (with a certain low water mark threshold) and when number of free blocks in that pool reached lower than that thresold there was a event generated. I am attaching part of my dmesg output here.
device-mapper: thin: 253:8: reached low water mark, sending event.
Quoted 5 lines
Reason why they are not yet support (and dmeventd only does pooling) is, that we have to make sure during all activations, we are not starting thinpool which is past the threshold - and there are many ways how to deal with this state.
Thats right, but IMHO its not related to APIs for creating thin lv and thin pool.
Quoted 5 lines
Also - for now - there is no per-pool threshold setting - IMHO this should be improved - and it's the same problem lvm2 has with i.e. mirror/raid, where many setting are currently set only via lvm.conf - while there is no option for LV override - this should be probably resolved at global level.
IIUC this thresold is per pool setting as per the code that I pasted above.
v2 cover Add thin lv and thin pool creation support
In reply to Tony AslesonQuoted 16 lines · Tony Asleson
Quoted 9 lines · M. Mohan Kumar
From: "M. Mohan Kumar" <[email protected]>
Add thin lv and thin pool creation support to lvm2app.
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 commandOK, so the block size if specified as 0 results in a default value being selected as before, which is what I believe we want. The default low water mark was 0, which is what we believe disables event creation. This doesn't appear to be a safe default behavior?
Quoted 7 lines
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
IMHO specifying the % in threshold is a good idea. You suggest to assume some default threshold for newly created thin pool if user is not passing anything. May be we can document this in lvm2app.h mentioning if '0' passed as percentage it will be treated as the default thresold and 100% means no event will be generated. What do you think about this policy?
Quoted 6 lines
Once we have defined what the default values are, I can modify my python bindings patch to use these default values.
Thanks,
Tony
v2 cover Add thin lv and thin pool creation support
Quoted 9 lines · M. Mohan Kumar
Quoted 7 lines · Tony Asleson
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Quoted 5 lines
IMHO specifying the % in threshold is a good idea. You suggest to assume some default threshold for newly created thin pool if user is not passing anything. May be we can document this in
lvm2app.hmentioning if '0' passed as percentage it will be treated as the default thresold and 100% means no event will be generated. What do you think about this policy?
This would be fine too. As long as we clearly document what the value represents and what the special values which denote disable and select default we should be good.
Do we know what a reasonable threshold value should be?
Thanks,
Tony
v2 cover Add thin lv and thin pool creation support
Quoted 16 lines · Tony Asleson
Quoted 9 lines · M. Mohan Kumar
Quoted 7 lines · Tony Asleson
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Quoted 5 lines
IMHO specifying the % in threshold is a good idea. You suggest to assume some default threshold for newly created thin pool if user is not passing anything. May be we can document this in
lvm2app.hmentioning if '0' passed as percentage it will be treated as the default thresold and 100% means no event will be generated. What do you think about this policy?
Quoted 5 lines
This would be fine too. As long as we clearly document what the value represents and what the special values which denote disable and select default we should be good.
Do we know what a reasonable threshold value should be?
I am not sure about the threshold value, should it bring it to dm folks?
v2 cover Add thin lv and thin pool creation support
In reply to Tony AslesonQuoted 16 lines · Tony Asleson
Quoted 9 lines · M. Mohan Kumar
Quoted 7 lines · Tony Asleson
One option would be to change the type to a signed integer and change the meaning from number of blocks free to percentage free and then treat -1 as pick a sane default. Thus 0 would be no events and 30 would indicate when 30% blocks free is remaining to generate an event. We could also use an unsigned value and use 100 as please pick a sane default as this value and values close to it really wouldn't make much sense.
Quoted 5 lines
IMHO specifying the % in threshold is a good idea. You suggest to assume some default threshold for newly created thin pool if user is not passing anything. May be we can document this in
lvm2app.hmentioning if '0' passed as percentage it will be treated as the default thresold and 100% means no event will be generated. What do you think about this policy?
Quoted 5 lines
This would be fine too. As long as we clearly document what the value represents and what the special values which denote disable and select default we should be good.
Do we know what a reasonable threshold value should be?
Oops I meant, should we discuss with dm folks about default threshold?
v2 cover Add thin lv and thin pool creation support
Quoted 4 lines · M. Mohan Kumar
Quoted 1 line · Tony Asleson
Do we know what a reasonable threshold value should be?
Oops I meant, should we discuss with dm folks about default threshold?
Sure, please do. I was hoping that some dm folks were lurking on this list and would shout out :-)
Regards,
Tony