.RB [ \-d | \-\-debug ]
.RB [ \-\-deltag
.IR Tag ]
+.RB [ \-\-discard
+.RI { ignore | nopassdown | passdown }]
.RB [ \-\-resync ]
.RB [ \-h | \-? | \-\-help ]
.RB [ \-\-ignorelockingfailure ]
.RI { ReadAheadSectors | auto | none }]
.RB [ \-\-refresh ]
.RB [ \-t | \-\-test ]
-.RB [ \-v | \-\-verbose]
+.RB [ \-v | \-\-verbose ]
+.RB [ \-Z | \-\-zero
+.RI { y | n }]
.I LogicalVolumePath
.RI [ LogicalVolumePath ...]
.SH DESCRIPTION
logical volume's allocation policy to contiguous, if all of the
allocated physical extents are already contiguous.
.TP
+.BR \-\-discard " {" \fIignore | \fInopassdown | \fIpassdown }
+Change discard behavior.
+.TP
.B \-\-resync
Forces the complete resynchronization of a mirror. In normal
circumstances you should not need this option because synchronization
This is not necessary in normal operation, but may be useful
if something has gone wrong or if you're doing clustering
manually without a clustered lock manager.
+.TP
+.BR \-Z ", " \-\-zero " {" \fIy | \fIn }
+Set zeroing mode for thin pool. Note: already provisioned blocks from pool
+in non-zero mode are not cleared in unwritten parts when setting zero to
+\fIy\fP.
.SH Examples
Changes the permission on volume lvol1 in volume group vg00 to be read-only:
.sp
"\t[--deltag Tag]\n"
"\t[-f|--force]\n"
"\t[-h|--help]\n"
+ "\t[--discard {ignore|nopassdown|passdown}]\n"
"\t[--ignorelockingfailure]\n"
"\t[--ignoremonitoring]\n"
"\t[--monitor {y|n}]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
"\t[-y|--yes]\n"
- "\t[--version]" "\n"
+ "\t[--version]\n"
+ "\t[-Z|--zero {y|n}]\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
alloc_ARG, autobackup_ARG, activate_ARG, available_ARG, contiguous_ARG,
force_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG,
minor_ARG, monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG,
persistent_ARG, poll_ARG, readahead_ARG, resync_ARG, refresh_ARG,
- addtag_ARG, deltag_ARG, sysinit_ARG, test_ARG, yes_ARG)
+ addtag_ARG, deltag_ARG, sysinit_ARG, test_ARG, yes_ARG,
+ discard_ARG, zero_ARG)
xx(lvconvert,
"Change logical volume layout",
return r;
}
+static int lvchange_pool_update(struct cmd_context *cmd,
+ struct logical_volume *lv)
+{
+ int r = 0;
+ int update = 0;
+ unsigned val;
+ thin_discard_t discard;
+
+ if (!lv_is_thin_pool(lv)) {
+ log_error("Logical volume \"%s\" is not a thinpool.", lv->name);
+ return 0;
+ }
+
+ if (arg_count(cmd, discard_ARG)) {
+ discard = arg_uint_value(cmd, discard_ARG, 0);
+ if (discard != first_seg(lv)->discard) {
+ if (((discard == THIN_DISCARD_IGNORE) ||
+ (first_seg(lv)->discard == THIN_DISCARD_IGNORE)) &&
+ lv_is_active(lv))
+ log_error("Cannot change discard state for active "
+ "logical volume \"%s\".", lv->name);
+ else {
+ first_seg(lv)->discard = discard;
+ update++;
+ }
+ } else
+ log_error("Logical volume \"%s\" already uses discard %s.",
+ lv->name, get_pool_discard_name(discard));
+ }
+
+ if (arg_count(cmd, zero_ARG)) {
+ val = arg_uint_value(cmd, zero_ARG, 1);
+ if (val != first_seg(lv)->zero_new_blocks) {
+ first_seg(lv)->zero_new_blocks = val;
+ update++;
+ } else
+ log_error("Logical volume \"%s\" already %szero new blocks.",
+ lv->name, val ? "" : "does not ");
+ }
+
+ if (!update)
+ return 0;
+
+ log_very_verbose("Updating logical volume \"%s\" on disk(s).", lv->name);
+ if (!vg_write(lv->vg))
+ return_0;
+
+ if (!suspend_lv_origin(cmd, lv)) {
+ log_error("Failed to update active %s/%s (deactivation is needed).",
+ lv->vg->name, lv->name);
+ vg_revert(lv->vg);
+ goto out;
+ }
+
+ if (!vg_commit(lv->vg)) {
+ if (!resume_lv_origin(cmd, lv))
+ stack;
+ goto_out;
+ }
+
+ if (!resume_lv_origin(cmd, lv)) {
+ log_error("Problem reactivating %s.", lv->name);
+ goto out;
+ }
+
+ r = 1;
+out:
+ backup(lv->vg);
+ return r;
+}
+
static int lvchange_monitoring(struct cmd_context *cmd,
struct logical_volume *lv)
{
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, discard_ARG) ||
+ arg_count(cmd, zero_ARG) ||
arg_count(cmd, alloc_ARG))) {
log_error("Only -a permitted with read-only volume "
"group \"%s\"", lv->vg->name);
}
}
+ if (arg_count(cmd, discard_ARG) ||
+ arg_count(cmd, zero_ARG)) {
+ if (!archived && !archive(lv->vg)) {
+ stack;
+ return ECMD_FAILED;
+ }
+ archived = 1;
+ doit += lvchange_pool_update(cmd, lv);
+ docmds++;
+ }
+
/* add tag */
if (arg_count(cmd, addtag_ARG)) {
if (!archived && !archive(lv->vg)) {
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, resync_ARG) || arg_count(cmd, alloc_ARG);
+ arg_count(cmd, resync_ARG) || arg_count(cmd, alloc_ARG) ||
+ arg_count(cmd, discard_ARG) ||
+ arg_count(cmd, zero_ARG);
if (!update &&
!arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&