summaryrefslogtreecommitdiff
path: root/lib/report
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2018-08-17 15:45:52 -0500
committerDavid Teigland <teigland@redhat.com>2018-11-06 13:44:54 -0600
commitcac4a9743acb826d785c0e51e9a752d8959ced80 (patch)
tree2ada17ff904271acb359530aaae015e214287758 /lib/report
parent8c9d9a744605e37799a2475932ae7dfd43831d08 (diff)
downloadlvm2-cac4a9743acb826d785c0e51e9a752d8959ced80.tar.gz
Allow dm-cache cache device to be standard LV
If a single, standard LV is specified as the cache, use it directly instead of converting it into a cache-pool object with two separate LVs (for data and metadata). With a single LV as the cache, lvm will use blocks at the beginning for metadata, and the rest for data. Separate dm linear devices are set up to point at the metadata and data areas of the LV. These dm devs are given to the dm-cache target to use. The single LV cache cannot be resized without recreating it. If the --poolmetadata option is used to specify an LV for metadata, then a cache pool will be created (with separate LVs for data and metadata.) Usage: $ lvcreate -n main -L 128M vg /dev/loop0 $ lvcreate -n fast -L 64M vg /dev/loop1 $ lvs -a vg LV VG Attr LSize Type Devices main vg -wi-a----- 128.00m linear /dev/loop0(0) fast vg -wi-a----- 64.00m linear /dev/loop1(0) $ lvconvert --type cache --cachepool fast vg/main $ lvs -a vg LV VG Attr LSize Origin Pool Type Devices [fast] vg Cwi---C--- 64.00m linear /dev/loop1(0) main vg Cwi---C--- 128.00m [main_corig] [fast] cache main_corig(0) [main_corig] vg owi---C--- 128.00m linear /dev/loop0(0) $ lvchange -ay vg/main $ dmsetup ls vg-fast_cdata (253:4) vg-fast_cmeta (253:5) vg-main_corig (253:6) vg-main (253:24) vg-fast (253:3) $ dmsetup table vg-fast_cdata: 0 98304 linear 253:3 32768 vg-fast_cmeta: 0 32768 linear 253:3 0 vg-main_corig: 0 262144 linear 7:0 2048 vg-main: 0 262144 cache 253:5 253:4 253:6 128 2 metadata2 writethrough mq 0 vg-fast: 0 131072 linear 7:1 2048 $ lvchange -an vg/min $ lvconvert --splitcache vg/main $ lvs -a vg LV VG Attr LSize Type Devices fast vg -wi------- 64.00m linear /dev/loop1(0) main vg -wi------- 128.00m linear /dev/loop0(0)
Diffstat (limited to 'lib/report')
-rw-r--r--lib/report/report.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/report/report.c b/lib/report/report.c
index 52baa6cbb..ecec0a320 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1430,7 +1430,10 @@ static int _cache_settings_disp(struct dm_report *rh, struct dm_pool *mem,
struct _str_list_append_baton baton;
struct dm_list dummy_list; /* dummy list to display "nothing" */
- if (seg_is_cache_pool(seg))
+ if (seg_is_cache(seg) && lv_is_cache_single(seg->pool_lv))
+ setting_seg = seg;
+
+ else if (seg_is_cache_pool(seg))
setting_seg = seg;
else if (seg_is_cache(seg))
@@ -1565,7 +1568,10 @@ static int _cache_policy_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_segment *seg = (const struct lv_segment *) data;
const struct lv_segment *setting_seg = NULL;
- if (seg_is_cache_pool(seg))
+ if (seg_is_cache(seg) && lv_is_cache_single(seg->pool_lv))
+ setting_seg = seg;
+
+ else if (seg_is_cache_pool(seg))
setting_seg = seg;
else if (seg_is_cache(seg))
@@ -2747,7 +2753,10 @@ static int _cachemetadataformat_disp(struct dm_report *rh, struct dm_pool *mem,
const struct lv_segment *setting_seg = NULL;
const uint64_t *fmt;
- if (seg_is_cache_pool(seg))
+ if (seg_is_cache(seg) && lv_is_cache_single(seg->pool_lv))
+ setting_seg = seg;
+
+ else if (seg_is_cache_pool(seg))
setting_seg = seg;
else if (seg_is_cache(seg))
@@ -3222,6 +3231,11 @@ static int _lvmetadatasize_disp(struct dm_report *rh, struct dm_pool *mem,
const struct logical_volume *lv = (const struct logical_volume *) data;
uint64_t size;
+ if (lv_is_cache(lv) && lv_is_cache_single(first_seg(lv)->pool_lv)) {
+ size = lv_metadata_size(lv);
+ return _size64_disp(rh, mem, field, &size, private);
+ }
+
if (lv_is_thin_pool(lv) || lv_is_cache_pool(lv)) {
size = lv_metadata_size(lv);
return _size64_disp(rh, mem, field, &size, private);