diff options
author | David Teigland <teigland@redhat.com> | 2019-04-16 16:28:10 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2019-04-17 13:00:04 -0500 |
commit | 20b9585899f5e4ca8512cb2441e3aa6cf008071e (patch) | |
tree | 2d925545886a9d686ab7b52655129eabb24973eb | |
parent | a8d73d28bff88bccce33e0af2fdc32157c040160 (diff) | |
download | lvm2-20b9585899f5e4ca8512cb2441e3aa6cf008071e.tar.gz |
lvconvert: add noflush option for splitcache
A failed cache may need to be detached without
being flushed.
-rw-r--r-- | lib/metadata/cache_manip.c | 10 | ||||
-rw-r--r-- | lib/metadata/lv_manip.c | 2 | ||||
-rw-r--r-- | lib/metadata/metadata-exported.h | 2 | ||||
-rw-r--r-- | tools/args.h | 3 | ||||
-rw-r--r-- | tools/command-lines.in | 2 | ||||
-rw-r--r-- | tools/lvconvert.c | 2 |
6 files changed, 13 insertions, 8 deletions
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c index 7ea2c0e2d..6450e0609 100644 --- a/lib/metadata/cache_manip.c +++ b/lib/metadata/cache_manip.c @@ -655,7 +655,7 @@ static int _lv_detach_cache_vol_while_active(struct cmd_context *cmd, struct log return 1; } -static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct logical_volume *cache_lv) +static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct logical_volume *cache_lv, int noflush) { struct lv_segment *cache_seg = first_seg(cache_lv); struct logical_volume *corigin_lv; @@ -673,7 +673,9 @@ static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct l * With these modes there is no flush needed so we can immediately * detach without temporarily activating the LV to flush it. */ - if ((cache_mode == CACHE_MODE_WRITETHROUGH) || (cache_mode == CACHE_MODE_PASSTHROUGH)) + if ((cache_mode == CACHE_MODE_WRITETHROUGH) || + (cache_mode == CACHE_MODE_PASSTHROUGH) || + noflush) goto detach; /* @@ -727,7 +729,7 @@ static int _lv_detach_cache_vol_while_inactive(struct cmd_context *cmd, struct l return 1; } -int lv_detach_cache_vol(struct logical_volume *cache_lv) +int lv_detach_cache_vol(struct logical_volume *cache_lv, int noflush) { struct cmd_context *cmd = cache_lv->vg->cmd; @@ -739,7 +741,7 @@ int lv_detach_cache_vol(struct logical_volume *cache_lv) if (lv_is_active(cache_lv)) return _lv_detach_cache_vol_while_active(cmd, cache_lv); else - return _lv_detach_cache_vol_while_inactive(cmd, cache_lv); + return _lv_detach_cache_vol_while_inactive(cmd, cache_lv, noflush); } /* diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 76d18b0d6..d135aff68 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -6248,7 +6248,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv, return_0; if (lv_is_cache(lv) && lv_is_cache_vol(first_seg(lv)->pool_lv)) { - if (!lv_detach_cache_vol(lv)) { + if (!lv_detach_cache_vol(lv, 1)) { log_error("Failed to detach cache from %s", display_lvname(lv)); return 0; } diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 9f3f550b8..a33d6055c 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -1284,7 +1284,7 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv, struct logical_volume *origin_lv); int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean); int lv_cache_remove(struct logical_volume *cache_lv); -int lv_detach_cache_vol(struct logical_volume *cache_lv); +int lv_detach_cache_vol(struct logical_volume *cache_lv, int noflush); int wipe_cache_pool(struct logical_volume *cache_pool_lv); /* -- metadata/cache_manip.c */ diff --git a/tools/args.h b/tools/args.h index 0f4da195e..f450b61d2 100644 --- a/tools/args.h +++ b/tools/args.h @@ -398,6 +398,9 @@ arg(nameprefixes_ARG, '\0', "nameprefixes", 0, 0, 0, "with --noheadings to produce a list of field=value pairs that can\n" "be used to set environment variables (for example, in udev rules).\n") +arg(noflush_ARG, '\0', "noflush", 0, 0, 0, + "Do not attempt to flush a cache when detaching it.\n") + arg(noheadings_ARG, '\0', "noheadings", 0, 0, 0, "Suppress the headings line that is normally the first line of output.\n" "Useful if grepping the output.\n") diff --git a/tools/command-lines.in b/tools/command-lines.in index 5d0d81969..e097b8ce2 100644 --- a/tools/command-lines.in +++ b/tools/command-lines.in @@ -590,7 +590,7 @@ FLAGS: SECONDARY_SYNTAX --- lvconvert --splitcache LV_cachepool_cache_thinpool_vdopool_writecache -OO: OO_LVCONVERT +OO: OO_LVCONVERT, --noflush ID: lvconvert_split_and_keep_cache DESC: Detach a cache from an LV. diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 5a4455bf0..b19fea5ad 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -1848,7 +1848,7 @@ static int _lvconvert_split_and_keep_cache(struct cmd_context *cmd, return_0; if (lv_is_cache_vol(cache_seg->pool_lv)) { - if (!lv_detach_cache_vol(lv)) + if (!lv_detach_cache_vol(lv, arg_is_set(cmd, noflush_ARG))) return_0; } else { if (!lv_cache_remove(lv)) |