mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
lvchange: vdo support compression deduplication change
Add basic support for changing compression and deduplication state of a VDO pool volume. Allowing to access it also via top-level VDO volume.
This commit is contained in:
parent
c58733ca15
commit
6206bd0e79
@ -221,6 +221,7 @@ OO_LVCHANGE: --autobackup Bool, --force, --ignoremonitoring,
|
||||
|
||||
OO_LVCHANGE_META: --addtag Tag, --deltag Tag,
|
||||
--alloc Alloc, --contiguous Bool,
|
||||
--compression Bool, --deduplication Bool,
|
||||
--detachprofile, --metadataprofile String, --profile String,
|
||||
--permission Permission, --readahead Readahead, --setactivationskip Bool,
|
||||
--errorwhenfull Bool, --discards Discards, --zero Bool,
|
||||
@ -308,7 +309,7 @@ OO: --major Number, --activate Active, --poll Bool, --monitor Bool, OO_LVCHANGE
|
||||
IO: --ignoreskippedcluster
|
||||
ID: lvchange_persistent
|
||||
DESC: Make the minor device number persistent for an LV.
|
||||
RULE: all not LV_thinpool LV_cachepool
|
||||
RULE: all not LV_thinpool LV_cachepool LV_vdopool
|
||||
|
||||
---
|
||||
|
||||
|
@ -934,6 +934,62 @@ static int _lvchange_activation_skip(struct logical_volume *lv, uint32_t *mr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvchange_compression(struct logical_volume *lv, uint32_t *mr)
|
||||
{
|
||||
struct cmd_context *cmd = lv->vg->cmd;
|
||||
unsigned compression = arg_uint_value(cmd, compression_ARG, 0);
|
||||
struct lv_segment *seg = first_seg(lv);
|
||||
|
||||
if (lv_is_vdo(lv))
|
||||
seg = first_seg(seg_lv(seg, 0));
|
||||
else if (!lv_is_vdo_pool(lv)) {
|
||||
log_error("Unable to change compression for non VDO volume %s.",
|
||||
display_lvname(lv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (compression == seg->vdo_params.use_compression) {
|
||||
log_error("Logical volume %s already uses --compression %c.",
|
||||
display_lvname(lv), compression ? 'y' : 'n');
|
||||
return 0;
|
||||
}
|
||||
|
||||
seg->vdo_params.use_compression = compression;
|
||||
|
||||
/* Request caller to commit and reload metadata */
|
||||
*mr |= MR_RELOAD;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvchange_deduplication(struct logical_volume *lv, uint32_t *mr)
|
||||
{
|
||||
struct cmd_context *cmd = lv->vg->cmd;
|
||||
unsigned deduplication = arg_uint_value(cmd, deduplication_ARG, 0);
|
||||
struct lv_segment *seg = first_seg(lv);
|
||||
|
||||
if (lv_is_vdo(lv))
|
||||
seg = first_seg(seg_lv(seg, 0));
|
||||
else if (!lv_is_vdo_pool(lv)) {
|
||||
log_error("Unable to change deduplication for non VDO volume %s.",
|
||||
display_lvname(lv));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (deduplication == seg->vdo_params.use_deduplication) {
|
||||
log_error("Logical volume %s already uses --deduplication %c.",
|
||||
display_lvname(lv), deduplication ? 'y' : 'n');
|
||||
return 0;
|
||||
}
|
||||
|
||||
seg->vdo_params.use_deduplication = deduplication;
|
||||
|
||||
/* Request caller to commit and reload metadata */
|
||||
*mr |= MR_RELOAD;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Update and reload or commit and/or backup metadata for @lv as requested by @mr */
|
||||
static int _commit_reload(struct logical_volume *lv, uint32_t mr)
|
||||
{
|
||||
@ -966,6 +1022,8 @@ static int _option_allows_group_commit(int opt_enum)
|
||||
permission_ARG,
|
||||
alloc_ARG,
|
||||
contiguous_ARG,
|
||||
compression_ARG,
|
||||
deduplication_ARG,
|
||||
errorwhenfull_ARG,
|
||||
readahead_ARG,
|
||||
persistent_ARG,
|
||||
@ -1117,6 +1175,16 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
|
||||
doit += _lvchange_activation_skip(lv, &mr);
|
||||
break;
|
||||
|
||||
case compression_ARG:
|
||||
docmds++;
|
||||
doit += _lvchange_compression(lv, &mr);
|
||||
break;
|
||||
|
||||
case deduplication_ARG:
|
||||
docmds++;
|
||||
doit += _lvchange_deduplication(lv, &mr);
|
||||
break;
|
||||
|
||||
default:
|
||||
log_error(INTERNAL_ERROR "Failed to check for option %s",
|
||||
arg_long_option_name(i));
|
||||
@ -1346,6 +1414,9 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lv_is_vdo_pool(lv) && !lv_is_named_arg)
|
||||
return 0; /* Skip VDO pool processing unless explicitely named */
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user