1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-02 01:18:26 +03:00

cache: make syncing abortable by user

When user runs command like 'lvconvert --splitcache' the operation
might be actually either slow or not making any progress in kernel,
so lets give user a chance to abort such operation.

When user press 'Ctrl+C' device table is restored to pre-flushing state.
This commit is contained in:
Zdenek Kabelac 2017-06-22 17:08:47 +02:00
parent 2df9a78684
commit ca9e6cec61
2 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.172 -
===============================
Support aborting of flushing cache LV.
Reenable conversion of data and metadata thin-pool volumes to raid.
Improve raid status reporting with lvs.
No longer necessary to '--force' a repair for RAID1

View File

@ -22,6 +22,7 @@
#include "activate.h"
#include "defaults.h"
#include "lv_alloc.h"
#include "lvm-signal.h"
/* https://github.com/jthornber/thin-provisioning-tools/blob/master/caching/cache_metadata_size.cc */
#define DM_TRANSACTION_OVERHEAD 4096 /* KiB */
@ -431,6 +432,20 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
//FIXME: use polling to do this...
for (;;) {
sigint_allow();
sigint_restore();
if (sigint_caught()) {
sigint_clear();
log_error("Flushing of %s aborted.", display_lvname(cache_lv));
if (cache_seg->cleaner_policy) {
cache_seg->cleaner_policy = 0;
/* Restore normal table */
if (!lv_update_and_reload(cache_lv))
stack;
}
return 0;
}
if (!lv_cache_status(cache_lv, &status))
return_0;
@ -452,9 +467,12 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
log_print_unless_silent("Flushing " FMTu64 " blocks for cache %s.",
dirty_blocks, display_lvname(cache_lv));
if (cleaner_policy) {
/* TODO: Use centralized place */
sigint_allow();
usleep(500000);
sigint_restore();
continue;
}