master - cleanup: use log_debug_activation
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2a2efab0b11b7b...
Commit: 2a2efab0b11b7bfeef1a60b6cfd61c8bceb67164
Parent: c81005dcc46bc55d0d4e5094f6ef99e36cecd486
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 27 00:01:08 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Apr 27 00:01:08 2016 +0200
cleanup: use log_debug_activation
---
lib/activate/activate.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index f554f19..5a7e99e 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -615,7 +615,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
path[i] = '_'; /* replace '-' with '_' */
if ((lstat(path, &st) == 0) && S_ISDIR(st.st_mode)) {
- log_debug("Module directory %s exists.", path);
+ log_debug_activation("Module directory %s exists.", path);
return 1;
}
}
7 years, 7 months
master - cleanup: smaller timeout
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c81005dcc46bc5...
Commit: c81005dcc46bc55d0d4e5094f6ef99e36cecd486
Parent: 07d92322c13e942b8a47b4370a82b70d33a6f0c8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 26 23:59:20 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:59:20 2016 +0200
cleanup: smaller timeout
1s -> 0.5s
Also indent fix.
---
lib/metadata/cache_manip.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index bf3d405..e998670 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -314,10 +314,11 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
break;
if (cleaner_policy) {
- log_print_unless_silent(FMTu64 " blocks must still be flushed.",
- dirty_blocks);
- sleep(1);
- continue;
+ log_print_unless_silent(FMTu64 " blocks must still be flushed.",
+ dirty_blocks);
+ /* TODO: Use centralized place */
+ usleep(500000);
+ continue;
}
/* Switch to cleaner policy to flush the cache */
@@ -326,7 +327,7 @@ int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
cache_seg->cleaner_policy = 1;
/* Reaload kernel with "cleaner" policy */
if (!lv_update_and_reload_origin(cache_lv))
- return_0;
+ return_0;
}
*is_clean = 1;
7 years, 7 months
master - man: lvcreate doc passthrough
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=07d92322c13e94...
Commit: 07d92322c13e942b8a47b4370a82b70d33a6f0c8
Parent: d90d99b23d94dea41b65166f8bb19cb2883e527c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 25 13:38:24 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:29:58 2016 +0200
man: lvcreate doc passthrough
Add few more words about passthough mode.
---
man/lvcreate.8.in | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index f6bb14f..fd8b3a7 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -219,7 +219,10 @@ If \fBwritethough\fP is specified, a write is considered complete only
when it has been stored in the cache pool LV and on the origin LV.
While \fBwritethrough\fP may be slower for writes, it is more
resilient if something should happen to a device associated with the
-cache pool LV.
+cache pool LV. With \fBpassthrough\fP mode, all reads are served
+from origin LV (all reads miss the cache) and all writes are
+forwarded to the origin LV; additionally, write hits cause cache
+block invalidates. See \fBlvmcache(7)\fP for more details.
.
.HP
.BR \-\-cachepolicy
7 years, 7 months
master - man: lvchange updates
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d90d99b23d94de...
Commit: d90d99b23d94dea41b65166f8bb19cb2883e527c
Parent: e77b6968b6b420a4d0d9f14af1386f28761f055b
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Apr 24 11:40:59 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:29:58 2016 +0200
man: lvchange updates
Drop never existing --degrade.
---
man/lvchange.8.in | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/man/lvchange.8.in b/man/lvchange.8.in
index fb16530..34ce583 100644
--- a/man/lvchange.8.in
+++ b/man/lvchange.8.in
@@ -26,15 +26,14 @@ lvchange \(em change attributes of a logical volume
.RB [ \-A | \-\-autobackup
.RB { y | n }]
.RB [ \-\-cachepolicy
-.IR policy ]
+.IR Policy ]
.RB [ \-\-cachesettings
-.IR key \fB= value ]
+.IR Key \fB= Value ]
.RB [ \-\-commandprofile
.IR ProfileName ]
.RB [ \-C | \-\-contiguous
.RB { y | n }]
.RB [ \-d | \-\-debug ]
-.RB [ \-\-degraded ]
.RB [ \-\-deltag
.IR Tag ]
.RB [ \-\-detachprofile ]
@@ -57,9 +56,9 @@ lvchange \(em change attributes of a logical volume
.RB [ \-M | \-\-persistent
.RB { y | n }
.RB [ \-\-major
-.IR major ]
+.IR Major ]
.RB [ \-\-minor
-.IR minor ]]
+.IR Minor ]]
.RB [ \-\-poll
.RB { y | n }]
.RB [ \-\- [ raid ] maxrecoveryrate
@@ -188,9 +187,9 @@ of the flag is reported within \fBlv_attr\fP bits.
.
.HP
.BR \-\-cachepolicy
-.IR policy ,
+.IR Policy ,
.BR \-\-cachesettings
-.IR key \fB= value
+.IR Key \fB= Value
.br
Only applicable to cached LVs; see also \fBlvmcache(7)\fP. Sets
the cache policy and its associated tunable settings. In most use-cases,
@@ -240,7 +239,7 @@ Do not use this if dmeventd is already monitoring a device.
.
.HP
.BR \-\-major
-.IR major
+.IR Major
.br
Sets the major number. This option is supported only on older systems
(kernel version 2.4) and is ignored on modern Linux systems where major
@@ -248,7 +247,7 @@ numbers are dynamically assigned.
.
.HP
.BR \-\-minor
-.IR minor
+.IR Minor
.br
Set the minor number.
.
7 years, 7 months
master - lvchange: use better arg functions
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e77b6968b6b420...
Commit: e77b6968b6b420a4d0d9f14af1386f28761f055b
Parent: c215e1be5ce35177a0491c0d6495865efbe34b51
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 26 22:04:19 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:29:58 2016 +0200
lvchange: use better arg functions
---
tools/lvchange.c | 77 ++++++++++++++++++++++++++++++++---------------------
1 files changed, 46 insertions(+), 31 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 6a6a619..83da6bc 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -911,21 +911,32 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
if (!(lv->vg->status & LVM_WRITE) &&
- (arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
- arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
- arg_count(cmd, discards_ARG) || arg_count(cmd, zero_ARG) ||
- arg_count(cmd, alloc_ARG) || arg_count(cmd, profile_ARG) ||
- arg_count(cmd, metadataprofile_ARG))) {
+ arg_from_list_is_set(cmd, NULL,
+ alloc_ARG,
+ contiguous_ARG,
+ discards_ARG,
+ metadataprofile_ARG,
+ permission_ARG,
+ persistent_ARG,
+ profile_ARG,
+ readahead_ARG,
+ zero_ARG,
+ -1)) {
log_error("Only -a permitted with read-only volume "
"group \"%s\"", lv->vg->name);
return ECMD_FAILED;
}
if (lv_is_origin(lv) && !lv_is_thin_volume(lv) &&
- (arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
- arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
- arg_count(cmd, alloc_ARG) || arg_count(cmd, profile_ARG) ||
- arg_count(cmd, metadataprofile_ARG))) {
+ arg_from_list_is_set(cmd, NULL,
+ alloc_ARG,
+ contiguous_ARG,
+ metadataprofile_ARG,
+ permission_ARG,
+ persistent_ARG,
+ profile_ARG,
+ readahead_ARG,
+ -1)) {
log_error("Can't change logical volume \"%s\" under snapshot",
lv->name);
return ECMD_FAILED;
@@ -1173,29 +1184,33 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
* --monitor or --poll).
*/
int update_partial_safe = /* options safe to update if partial */
- arg_count(cmd, contiguous_ARG) ||
- arg_count(cmd, permission_ARG) ||
- arg_count(cmd, readahead_ARG) ||
- arg_count(cmd, persistent_ARG) ||
- arg_count(cmd, addtag_ARG) ||
- arg_count(cmd, deltag_ARG) ||
- arg_count(cmd, metadataprofile_ARG) ||
- arg_count(cmd, profile_ARG) ||
- arg_count(cmd, detachprofile_ARG) ||
- arg_count(cmd, setactivationskip_ARG);
+ arg_from_list_is_set(cmd, NULL,
+ addtag_ARG,
+ contiguous_ARG,
+ deltag_ARG,
+ detachprofile_ARG,
+ metadataprofile_ARG,
+ permission_ARG,
+ persistent_ARG,
+ profile_ARG,
+ readahead_ARG,
+ setactivationskip_ARG,
+ -1);
int update_partial_unsafe =
- arg_count(cmd, alloc_ARG) ||
- arg_count(cmd, discards_ARG) ||
- arg_count(cmd, errorwhenfull_ARG) ||
- arg_count(cmd, minrecoveryrate_ARG) ||
- arg_count(cmd, maxrecoveryrate_ARG) ||
- arg_count(cmd, resync_ARG) ||
- arg_count(cmd, syncaction_ARG) ||
- arg_count(cmd, cachepolicy_ARG) ||
- arg_count(cmd, cachesettings_ARG) ||
- arg_count(cmd, writebehind_ARG) ||
- arg_count(cmd, writemostly_ARG) ||
- arg_count(cmd, zero_ARG);
+ arg_from_list_is_set(cmd, NULL,
+ alloc_ARG,
+ cachepolicy_ARG,
+ cachesettings_ARG,
+ discards_ARG,
+ errorwhenfull_ARG,
+ maxrecoveryrate_ARG,
+ minrecoveryrate_ARG,
+ resync_ARG,
+ syncaction_ARG,
+ writebehind_ARG,
+ writemostly_ARG,
+ zero_ARG,
+ -1);
int update = update_partial_safe || update_partial_unsafe;
if (!update &&
7 years, 7 months
master - lvchange: always check for sigint
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c215e1be5ce351...
Commit: c215e1be5ce35177a0491c0d6495865efbe34b51
Parent: d8bdc7af3749cbdc9110057daa837d2fe19dcf72
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 25 13:44:42 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:29:08 2016 +0200
lvchange: always check for sigint
Check sigint() state during process_each_lv.
---
WHATS_NEW | 1 +
tools/lvchange.c | 5 +++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d557459..3f036e1 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.152 -
==================================
+ Improve support for interrupting procesing of volumes during lvchange.
Use failed command return code when lvchanging read-only volume.
Show creation transaction_id and zeroing state of pool with thin volume.
Stop checking for dm_cache_mq policy with cache target 1.9 (alias to smq).
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 0f46e2c..6a6a619 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -907,6 +907,9 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
struct logical_volume *origin;
char snaps_msg[128];
+ if (sigint_caught())
+ return_ECMD_FAILED;
+
if (!(lv->vg->status & LVM_WRITE) &&
(arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) ||
arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) ||
@@ -1062,8 +1065,6 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return_ECMD_FAILED;
doit += _lvchange_persistent(cmd, lv);
docmds++;
- if (sigint_caught())
- return_ECMD_FAILED;
}
if (arg_count(cmd, discards_ARG) ||
7 years, 7 months
master - lvchange: fix return code
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d8bdc7af3749cb...
Commit: d8bdc7af3749cbdc9110057daa837d2fe19dcf72
Parent: 84a5b19539483e5f06b4a1405bb76e46ce9226b2
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Apr 25 13:40:26 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:28:01 2016 +0200
lvchange: fix return code
We already opened VG for this - so not an invalid cmdline.
---
WHATS_NEW | 1 +
tools/lvchange.c | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index b6d9fd2..d557459 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.152 -
==================================
+ Use failed command return code when lvchanging read-only volume.
Show creation transaction_id and zeroing state of pool with thin volume.
Stop checking for dm_cache_mq policy with cache target 1.9 (alias to smq).
Check first /sys/module/dm_* dir existance before using modprobe.
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 631d7f8..0f46e2c 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -915,7 +915,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
arg_count(cmd, metadataprofile_ARG))) {
log_error("Only -a permitted with read-only volume "
"group \"%s\"", lv->vg->name);
- return EINVALID_CMD_LINE;
+ return ECMD_FAILED;
}
if (lv_is_origin(lv) && !lv_is_thin_volume(lv) &&
7 years, 7 months
master - thin: zero and transaction_id also with thin volumes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=84a5b19539483e...
Commit: 84a5b19539483e5f06b4a1405bb76e46ce9226b2
Parent: 8b5967e1e3313e8f9caa8065e170dd35ada8e57a
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Apr 23 21:08:46 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:24:51 2016 +0200
thin: zero and transaction_id also with thin volumes
Show trasaction_id when thin volume was created.
Also show zeroing state of thin-pool with thin volume (so user
doesn't need to lookup thin-pool).
---
WHATS_NEW | 1 +
lib/report/columns.h | 4 ++--
lib/report/report.c | 5 ++++-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 4b33913..b6d9fd2 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.152 -
==================================
+ Show creation transaction_id and zeroing state of pool with thin volume.
Stop checking for dm_cache_mq policy with cache target 1.9 (alias to smq).
Check first /sys/module/dm_* dir existance before using modprobe.
Remove mpath from 10-dm.rules, superseded by 11-dm-mpath.rules (mpath>=0.6.0).
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 7f5e11d..b31b3f1 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -191,8 +191,8 @@ FIELD(SEGS, seg, SIZ, "Chunk", list, 0, chunksize, chunk_size, "For snapshots, t
FIELD(SEGS, seg, NUM, "#Thins", list, 0, thincount, thin_count, "For thin pools, the number of thin volumes in this pool.", 0)
FIELD(SEGS, seg, STR, "Discards", list, 0, discards, discards, "For thin pools, how discards are handled.", 0)
FIELD(SEGS, seg, STR, "CacheMode", list, 0, cachemode, cache_mode, "For cache pools, how writes are cached.", 0)
-FIELD(SEGS, seg, BIN, "Zero", list, 0, thinzero, zero, "For thin pools, if zeroing is enabled.", 0)
-FIELD(SEGS, seg, NUM, "TransId", list, 0, transactionid, transaction_id, "For thin pools, the transaction id.", 0)
+FIELD(SEGS, seg, BIN, "Zero", list, 0, thinzero, zero, "For thin pools and volumes, if zeroing is enabled.", 0)
+FIELD(SEGS, seg, NUM, "TransId", list, 0, transactionid, transaction_id, "For thin pools, the transaction id and creation transaction id for thins.", 0)
FIELD(SEGS, seg, NUM, "ThId", list, 0, thinid, thin_id, "For thin volume, the thin device id.", 0)
FIELD(SEGS, seg, SIZ, "Start", list, 0, segstart, seg_start, "Offset within the LV to the start of the segment in current units.", 0)
FIELD(SEGS, seg, NUM, "Start", list, 0, segstartpe, seg_start_pe, "Offset within the LV to the start of the segment in physical extents.", 0)
diff --git a/lib/report/report.c b/lib/report/report.c
index abf6a9e..016d41d 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2446,7 +2446,7 @@ static int _transactionid_disp(struct dm_report *rh, struct dm_pool *mem,
{
const struct lv_segment *seg = (const struct lv_segment *) data;
- if (seg_is_thin_pool(seg))
+ if (seg_is_thin_pool(seg) || seg_is_thin_volume(seg))
return dm_report_field_uint64(rh, field, &seg->transaction_id);
return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_64));
@@ -3478,6 +3478,9 @@ static int _thinzero_disp(struct dm_report *rh, struct dm_pool *mem,
{
const struct lv_segment *seg = (const struct lv_segment *) data;
+ if (seg_is_thin_volume(seg))
+ seg = first_seg(seg->pool_lv);
+
if (seg_is_thin_pool(seg))
return _binary_disp(rh, mem, field, seg->zero_new_blocks, GET_FIRST_RESERVED_NAME(zero_y), private);
7 years, 7 months
master - cache: check for clean cache as separete function
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8b5967e1e3313e...
Commit: 8b5967e1e3313e8f9caa8065e170dd35ada8e57a
Parent: 588455d03ea40ffa37f466023691b0ec2bdf5e82
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 26 21:45:48 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:24:17 2016 +0200
cache: check for clean cache as separete function
---
lib/metadata/cache_manip.c | 98 ++++++++++++++++++++++----------------
lib/metadata/metadata-exported.h | 1 +
2 files changed, 58 insertions(+), 41 deletions(-)
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 46cb6a8..bf3d405 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -279,6 +279,61 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
}
/*
+ * Checks cache status and loops until there are not dirty blocks
+ * Set 1 to *is_clean when there are no dirty blocks on return.
+ */
+int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean)
+{
+ struct lv_segment *cache_seg = first_seg(cache_lv);
+ struct lv_status_cache *status;
+ int cleaner_policy;
+ uint64_t dirty_blocks;
+
+ *is_clean = 0;
+
+ //FIXME: use polling to do this...
+ for (;;) {
+ if (!lv_cache_status(cache_lv, &status))
+ return_0;
+ if (status->cache->fail) {
+ dm_pool_destroy(status->mem);
+ log_warn("WARNING: Skippping flush for failed cache.");
+ return 1;
+ }
+
+ cleaner_policy = !strcmp(status->cache->policy_name, "cleaner");
+ dirty_blocks = status->cache->dirty_blocks;
+
+ /* No clear policy and writeback mode means dirty */
+ if (!cleaner_policy &&
+ (status->cache->feature_flags & DM_CACHE_FEATURE_WRITEBACK))
+ dirty_blocks++;
+ dm_pool_destroy(status->mem);
+
+ if (!dirty_blocks)
+ break;
+
+ if (cleaner_policy) {
+ log_print_unless_silent(FMTu64 " blocks must still be flushed.",
+ dirty_blocks);
+ sleep(1);
+ continue;
+ }
+
+ /* Switch to cleaner policy to flush the cache */
+ log_print_unless_silent("Flushing cache for %s.",
+ display_lvname(cache_lv));
+ cache_seg->cleaner_policy = 1;
+ /* Reaload kernel with "cleaner" policy */
+ if (!lv_update_and_reload_origin(cache_lv))
+ return_0;
+ }
+
+ *is_clean = 1;
+
+ return 1;
+}
+/*
* lv_cache_remove
* @cache_lv
*
@@ -291,12 +346,10 @@ struct logical_volume *lv_cache_create(struct logical_volume *pool_lv,
*/
int lv_cache_remove(struct logical_volume *cache_lv)
{
- int is_cleaner;
- uint64_t dirty_blocks;
struct lv_segment *cache_seg = first_seg(cache_lv);
struct logical_volume *corigin_lv;
struct logical_volume *cache_pool_lv;
- struct lv_status_cache *status;
+ int is_clear;
if (!lv_is_cache(cache_lv)) {
log_error(INTERNAL_ERROR "LV %s is not cache volume.",
@@ -356,45 +409,8 @@ int lv_cache_remove(struct logical_volume *cache_lv)
* remove the cache_pool then without waiting for the flush to
* complete.
*/
- if (!lv_cache_status(cache_lv, &status))
+ if (!lv_cache_wait_for_clean(cache_lv, &is_clear))
return_0;
- if (!status->cache->fail) {
- is_cleaner = !strcmp(status->cache->policy_name, "cleaner");
- dirty_blocks = status->cache->dirty_blocks;
- if (!(status->cache->feature_flags & DM_CACHE_FEATURE_WRITETHROUGH))
- dirty_blocks++; /* Not writethrough - always dirty */
- } else {
- log_warn("WARNING: Skippping flush for failed cache.");
- is_cleaner = 0;
- dirty_blocks = 0;
- }
- dm_pool_destroy(status->mem);
-
- if (dirty_blocks && !is_cleaner) {
- /* Switch to cleaner policy to flush the cache */
- log_print_unless_silent("Flushing cache for %s.", cache_lv->name);
- cache_seg->cleaner_policy = 1;
- /* update the kernel to put the cleaner policy in place */
- if (!lv_update_and_reload_origin(cache_lv))
- return_0;
- }
-
- //FIXME: use polling to do this...
- while (dirty_blocks) {
- if (!lv_cache_status(cache_lv, &status))
- return_0;
- if (status->cache->fail) {
- log_warn("WARNING: Flushing of failing cache skipped.");
- break;
- }
- dirty_blocks = status->cache->dirty_blocks;
- dm_pool_destroy(status->mem);
- if (dirty_blocks) {
- log_print_unless_silent(FMTu64 " blocks must still be flushed.",
- dirty_blocks);
- sleep(1);
- }
- }
cache_pool_lv = cache_seg->pool_lv;
if (!detach_pool_lv(cache_seg))
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 039708e..8c4dfc3 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -1226,6 +1226,7 @@ int validate_lv_cache_create_pool(const struct logical_volume *pool_lv);
int validate_lv_cache_create_origin(const struct logical_volume *origin_lv);
struct logical_volume *lv_cache_create(struct logical_volume *pool,
struct logical_volume *origin);
+int lv_cache_wait_for_clean(struct logical_volume *cache_lv, int *is_clean);
int lv_cache_remove(struct logical_volume *cache_lv);
int wipe_cache_pool(struct logical_volume *cache_pool_lv);
/* -- metadata/cache_manip.c */
7 years, 7 months
master - cache: with cache target 1.9 mq is alias to smq
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=588455d03ea40f...
Commit: 588455d03ea40ffa37f466023691b0ec2bdf5e82
Parent: aa91fe3d3c3e6c2d8d96f5c0766b58375a44daa9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Apr 26 21:43:41 2016 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Apr 26 23:24:05 2016 +0200
cache: with cache target 1.9 mq is alias to smq
Avoid useless check for mq policy, it's loaded as smq
and aliased.
---
WHATS_NEW | 1 +
lib/cache_segtype/cache.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2a4fdd5..4b33913 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.152 -
==================================
+ Stop checking for dm_cache_mq policy with cache target 1.9 (alias to smq).
Check first /sys/module/dm_* dir existance before using modprobe.
Remove mpath from 10-dm.rules, superseded by 11-dm-mpath.rules (mpath>=0.6.0).
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index a65892e..be9a57e 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -211,8 +211,9 @@ static int _target_present(struct cmd_context *cmd,
const char feature[12];
const char module[12]; /* check dm-%s */
} _features[] = {
- { 1, 3, CACHE_FEATURE_POLICY_MQ, "policy_mq", "cache-mq" },
+ { 1, 9, CACHE_FEATURE_POLICY_SMQ | CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq" },
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, "policy_smq", "cache-smq" },
+ { 1, 3, CACHE_FEATURE_POLICY_MQ, "policy_mq", "cache-mq" },
};
static const char _lvmconf[] = "global/cache_disabled_features";
static unsigned _attrs = 0;
@@ -249,7 +250,9 @@ static int _target_present(struct cmd_context *cmd,
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i) {
if (((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) &&
- (!_features[i].module[0] || module_present(cmd, _features[i].module)))
+ (!_features[i].module[0] ||
+ (_attrs & _features[i].cache_feature) || /* already present */
+ module_present(cmd, _features[i].module)))
_attrs |= _features[i].cache_feature;
else
log_very_verbose("Target %s does not support %s.",
7 years, 7 months