1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

thin: fix property discard for lvm2api

Discards property is string and may have these values:
  ignore, nopassdown, passdown
This commit is contained in:
Zdenek Kabelac 2012-11-27 11:02:49 +01:00
parent 09b7ceea95
commit 0387e70d76
7 changed files with 20 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Fix lvm2api and return lvseg discards property as string.
Allow forced vgcfgrestore of lvm2 metadata with thin volumes.
Recognise STEC skd devices in filter.
Recognise Violin Memory vtms devices in filter.

View File

@ -123,6 +123,11 @@ char *lvseg_segtype_dup(struct dm_pool *mem, const struct lv_segment *seg)
return dm_pool_strdup(mem, seg->segtype->ops->name(seg));
}
char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg)
{
return dm_pool_strdup(mem, get_pool_discards_name(seg->discards));
}
uint64_t lvseg_chunksize(const struct lv_segment *seg)
{
uint64_t size;

View File

@ -74,6 +74,7 @@ uint64_t lvseg_start(const struct lv_segment *seg);
uint64_t lvseg_size(const struct lv_segment *seg);
uint64_t lvseg_chunksize(const struct lv_segment *seg);
char *lvseg_segtype_dup(struct dm_pool *mem, const struct lv_segment *seg);
char *lvseg_discards_dup(struct dm_pool *mem, const struct lv_segment *seg);
char *lvseg_tags_dup(const struct lv_segment *seg);
char *lvseg_devices(struct dm_pool *mem, const struct lv_segment *seg);
char *lvseg_seg_pe_ranges(struct dm_pool *mem, const struct lv_segment *seg);

View File

@ -141,7 +141,7 @@ FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, region_size, "For mirror
FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunksize, "For snapshots, the unit of data used when tracking changes.", 0)
FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, chunk_size, "For snapshots, the unit of data used when tracking changes.", 0)
FIELD(SEGS, seg, NUM, "#Thins", list, 4, thincount, thin_count, "For thin pools, the number of thin volumes in this pool.", 0)
FIELD(SEGS, seg, NUM, "Discards", list, 8, discards, discards, "For thin pools, how discards are handled.", 0)
FIELD(SEGS, seg, STR, "Discards", list, 8, discards, discards, "For thin pools, how discards are handled.", 0)
FIELD(SEGS, seg, NUM, "Zero", list, 4, thinzero, zero, "For thin pools, if zeroing is enabled.", 0)
FIELD(SEGS, seg, NUM, "TransId", list, 4, transactionid, transaction_id, "For thin pools, the transaction id.", 0)
FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, seg_start, "Offset within the LV to the start of the segment in current units.", 0)

View File

@ -287,7 +287,7 @@ GET_LVSEG_NUM_PROPERTY_FN(zero, lvseg->zero_new_blocks)
#define _zero_set _not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(transaction_id, lvseg->transaction_id)
#define _transaction_id_set _not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(discards, lvseg->discards)
GET_LVSEG_STR_PROPERTY_FN(discards, lvseg_discards_dup(lvseg->lv->vg->vgmem, lvseg))
#define _discards_set _not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(seg_start, lvseg_start(lvseg))
#define _seg_start_set _not_implemented_set

View File

@ -23,6 +23,8 @@ int main(int argc, char *argv[])
vg_t vg;
lv_t lv;
struct lvm_property_value v;
struct dm_list *lvsegs;
struct lvm_lvseg_list *lvl;
handle = lvm_init(NULL);
assert(handle);
@ -33,6 +35,14 @@ int main(int argc, char *argv[])
lv = lvm_lv_from_name(vg, "pool");
assert(lv);
lvsegs = lvm_lv_list_lvsegs(lv);
assert(lvsegs && (dm_list_size(lvsegs) == 1));
dm_list_iterate_items(lvl, lvsegs) {
v = lvm_lvseg_get_property(lvl->lvseg, "discards");
assert(v.is_valid && v.is_string);
assert(strcmp(v.value.string, "passdown") == 0);
}
v = lvm_lv_get_property(lv, "data_percent");
assert(v.is_valid);
assert(v.value.integer == 25 * PERCENT_1);

View File

@ -30,7 +30,7 @@ dd if=/dev/urandom of="$DM_DEV_DIR/$vg/thin" count=2 bs=256K
lvcreate -s $vg/thin -n snap
dd if=/dev/urandom of="$DM_DEV_DIR/$vg/snap" count=3 bs=256K
lvs $vg
lvs -o+discards $vg
aux apitest thin_percent $vg