From c047ff61f68d1b853569b153251f8bc5f88e23cd Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 21 Feb 2022 16:09:57 -0600 Subject: [PATCH 34/54] writecache: display block size from lvs lvs was missing the ability to display writecache block size. now possible with lvs -o writecache_block_size --- lib/report/columns.h | 1 + lib/report/properties.c | 2 ++ lib/report/report.c | 20 ++++++++++++++++++++ man/lvmcache.7_main | 4 ++++ test/shell/writecache-cache-blocksize.sh | 2 ++ 5 files changed, 29 insertions(+) diff --git a/lib/report/columns.h b/lib/report/columns.h index 12b78b766..7e450dace 100644 --- a/lib/report/columns.h +++ b/lib/report/columns.h @@ -108,6 +108,7 @@ FIELD(LVS, lv, TIM, "RTime", lvid, 26, lvtimeremoved, lv_time_removed, "Removal FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0) FIELD(LVS, lv, STR_LIST, "Modules", lvid, 0, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0) FIELD(LVS, lv, BIN, "Historical", lvid, 0, lvhistorical, lv_historical, "Set if the LV is historical.", 0) +FIELD(LVS, lv, NUM, "WCacheBlkSize", lvid, 0, writecache_block_size, writecache_block_size, "The writecache block size", 0) /* * End of LVS type fields */ diff --git a/lib/report/properties.c b/lib/report/properties.c index 12ea890f4..6f302360f 100644 --- a/lib/report/properties.c +++ b/lib/report/properties.c @@ -353,6 +353,8 @@ GET_PV_STR_PROPERTY_FN(pv_device_id_type, pv->device_id_type) #define _writecache_writeback_blocks_get prop_not_implemented_get #define _writecache_error_set prop_not_implemented_set #define _writecache_error_get prop_not_implemented_get +#define _writecache_block_size_set prop_not_implemented_set +#define _writecache_block_size_get prop_not_implemented_get #define _vdo_operating_mode_set prop_not_implemented_set #define _vdo_operating_mode_get prop_not_implemented_get diff --git a/lib/report/report.c b/lib/report/report.c index 60df417a4..c06b22674 100644 --- a/lib/report/report.c +++ b/lib/report/report.c @@ -3346,6 +3346,26 @@ static int _integritymismatches_disp(struct dm_report *rh __attribute__((unused) return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64)); } +static int _writecache_block_size_disp(struct dm_report *rh __attribute__((unused)), + struct dm_pool *mem, + struct dm_report_field *field, + const void *data, + void *private __attribute__((unused))) +{ + struct logical_volume *lv = (struct logical_volume *) data; + uint32_t bs = 0; + + if (lv_is_writecache(lv)) { + struct lv_segment *seg = first_seg(lv); + bs = seg->writecache_block_size; + } + + if (!bs) + return dm_report_field_int32(rh, field, &GET_TYPE_RESERVED_VALUE(num_undef_32)); + + return dm_report_field_uint32(rh, field, &bs); +} + static int _datapercent_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) diff --git a/man/lvmcache.7_main b/man/lvmcache.7_main index 73680235b..519e352cb 100644 --- a/man/lvmcache.7_main +++ b/man/lvmcache.7_main @@ -241,6 +241,10 @@ It is also possible to specify a sector size of 4096 to mkfs.xfs when creating the file system. In this case the writecache block size of 4096 can be used. .P +The writecache block size is displayed by the command: +.br +lvs -o writecacheblocksize VG/LV +.P .SS dm-writecache memory usage .P The amount of main system memory used by dm-writecache can be a factor diff --git a/test/shell/writecache-cache-blocksize.sh b/test/shell/writecache-cache-blocksize.sh index 2579ef7b7..4e17effe5 100644 --- a/test/shell/writecache-cache-blocksize.sh +++ b/test/shell/writecache-cache-blocksize.sh @@ -222,6 +222,8 @@ vgextend $vg "$dev2" lvcreate -n $lv1 -l 8 -an $vg "$dev1" lvcreate -n $lv2 -l 4 -an $vg "$dev2" lvconvert --yes --type writecache --cachevol $lv2 --cachesettings "block_size=4096" $vg/$lv1 +lvs -o writecacheblocksize $vg/$lv1 |tee out +grep 4096 out lvchange -ay $vg/$lv1 mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1" |tee out grep "sectsz=4096" out -- 2.34.3