main - writecache: allow attaching to thin pool data
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6b00c8c9109b0b6111d4adb9918cccc407ac448f Commit: 6b00c8c9109b0b6111d4adb9918cccc407ac448f Parent: 92fcfc59b2b0a81121771cab3b21ec5dde797510 Author: David Teigland <[email protected]> AuthorDate: Thu May 6 16:18:50 2021 -0500 Committer: David Teigland <[email protected]> CommitterDate: Thu May 6 16:23:03 2021 -0500
writecache: allow attaching to thin pool data
--- tools/command-lines.in | 4 ++-- tools/lvconvert.c | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
tools/command-lines.in +2 -2
@@ -493,7 +493,7 @@ AUTOTYPE: cache --- -lvconvert --type writecache --cachevol LV LV_linear_striped_raid +lvconvert --type writecache --cachevol LV LV_linear_striped_raid_thinpool OO: OO_LVCONVERT, --cachesettings String ID: lvconvert_to_writecache DESC: Attach a writecache to an LV, converts the LV to type writecache.
@@ -520,7 +520,7 @@ FLAGS: SECONDARY_SYNTAX --- -lvconvert --type writecache --cachedevice PV LV_linear_striped_raid +lvconvert --type writecache --cachedevice PV LV_linear_striped_raid_thinpool OO: OO_LVCONVERT, --cachesize SizeMB, --cachesettings String ID: lvconvert_to_writecache_with_device DESC: Add a writecache to an LV, using a specified cache device.
tools/lvconvert.c +12 -2
@@ -6106,6 +6106,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd, struct processing_handle *handle) {struct volume_group *vg = lv->vg; +struct logical_volume *lv_update;struct logical_volume *lv_wcorig;struct logical_volume *lv_fast;struct writecache_settings settings = {0 };
@@ -6228,6 +6229,15 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd, lv_fast->status |=LV_CACHE_VOL ; +/* When the lv arg is a thinpool, redirect update to data sub lv. */ + +if (lv_is_thin_pool (lv)) { + lv_update =seg_lv (first_seg (lv),0 ); +log_verbose ("Redirecting operation to data sub LV %s." ,display_lvname (lv_update)); + }else { + lv_update = lv; + } +/* * Changes the vg struct to match the desired state. *
@@ -6240,7 +6250,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,* gets new id, becomes hidden, gets segments from lv. */ -if (!(lv_wcorig =_lv_writecache_create (cmd, lv, lv_fast, block_size_sectors, &settings))) +if (!(lv_wcorig =_lv_writecache_create (cmd, lv_update, lv_fast, block_size_sectors, &settings))) goto_bad;/*
@@ -6248,7 +6258,7 @@ int lvconvert_writecache_attach_single(struct cmd_context *cmd,* where the old LV is suspended and the new LV is resumed. */ -if (!lv_update_and_reload (lv)) +if (!lv_update_and_reload (lv_update)) goto_bad;lockd_lv (cmd, lv,"un" ,0 );