From 5081181b5d89886389758cd42adc9b8251da327d Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 9 Sep 2011 01:15:18 +0000 Subject: [PATCH] Append z to lv_attr if new blocks will be zeroed. --- lib/metadata/lv.c | 10 +++++++++- lib/metadata/metadata.h | 2 +- lib/metadata/thin_manip.c | 2 +- man/lvs.8.in | 2 ++ 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c index 322727ebf..8434e45c7 100644 --- a/lib/metadata/lv.c +++ b/lib/metadata/lv.c @@ -308,9 +308,10 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) { percent_t snap_percent; struct lvinfo info; + struct lv_segment *seg; char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 8))) { + if (!(repstr = dm_pool_zalloc(mem, 9))) { log_error("dm_pool_alloc failed"); return 0; } @@ -405,6 +406,13 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv) else repstr[6] = '-'; + if ((lv_is_thin_volume(lv) && (seg = first_seg(lv)) && seg->pool_lv && (seg = first_seg(seg->pool_lv))) || + (lv_is_thin_pool(lv) && (seg = first_seg(lv))) && + seg->zero_new_blocks) + repstr[7] = 'z'; + else + repstr[7] = '-'; + out: return repstr; } diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index 87e260477..e984ba83d 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -372,7 +372,7 @@ struct pv_list *find_pv_in_pv_list(const struct dm_list *pl, struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le); /* Find pool LV segment given a thin pool data or metadata segment. */ -struct lv_segment *find_pool_seg(struct lv_segment *seg); +struct lv_segment *find_pool_seg(const struct lv_segment *seg); /* * Remove a dev_dir if present. diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c index e8bf48c3d..2412db6c3 100644 --- a/lib/metadata/thin_manip.c +++ b/lib/metadata/thin_manip.c @@ -61,7 +61,7 @@ int detach_pool_lv(struct lv_segment *seg) return remove_seg_from_segs_using_this_lv(seg->pool_lv, seg); } -struct lv_segment *find_pool_seg(struct lv_segment *seg) +struct lv_segment *find_pool_seg(const struct lv_segment *seg) { struct lv_segment *pool_seg; diff --git a/man/lvs.8.in b/man/lvs.8.in index 7ed72703b..cc4970939 100644 --- a/man/lvs.8.in +++ b/man/lvs.8.in @@ -94,6 +94,8 @@ for example, mirror images, mirror logs as well as mirrors themselves appear as equivalents using the md raid kernel driver all appear as (r). Snapshots using the original device-mapper driver appear as (s); whereas snapshots of thin volumes using the new thin provisioning driver appear as (t). +.IP 8 3 +Newly-allocated data blocks are overwritten with blocks of (z)eroes before use. .RE .TP .I \-\-segments -- 2.43.5