All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - lvreduce: require active LV when no fs option is used
Date: Tue, 11 Oct 2022 17:49:44 +0000 (GMT)	[thread overview]
Message-ID: <20221011174944.08F073858D39@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f6f2737015746b1b6c7fbd0d297a4596c584749b
Commit:        f6f2737015746b1b6c7fbd0d297a4596c584749b
Parent:        fc52e87f06959f542ea78b75df104bc6c85fd973
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Tue Oct 11 11:50:47 2022 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Tue Oct 11 12:48:31 2022 -0500

lvreduce: require active LV when no fs option is used

Without an --fs option set, make lvreduce of an inactive LV
fail and report that the LV must be active.
---
 lib/metadata/lv_manip.c   | 4 ++++
 test/shell/lvresize-fs.sh | 7 ++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d6452e849..db97a019c 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6873,6 +6873,10 @@ int lv_resize(struct cmd_context *cmd, struct logical_volume *lv,
 	is_active = lv_is_active(lv_top);
 
 	if (is_reduce && !is_active && !strcmp(lp->fsopt, "checksize")) {
+		if (!lp->user_set_fs) {
+			log_error("The LV must be active to safely reduce, or use --fs checksize.");
+			goto out;
+		}
 		lv_top->status |= LV_TEMPORARY;
 		if (!activate_lv(cmd, lv_top)) {
 			log_error("Failed to activate %s to check for fs.", display_lvname(lv_top));
diff --git a/test/shell/lvresize-fs.sh b/test/shell/lvresize-fs.sh
index d4b6484c0..0be6911a0 100644
--- a/test/shell/lvresize-fs.sh
+++ b/test/shell/lvresize-fs.sh
@@ -473,7 +473,8 @@ lvremove $vg/$lv
 lvcreate -n $lv -L 456M $vg
 aux wipefs_a "$DM_DEV_DIR/$vg/$lv"
 lvchange -an $vg/$lv
-lvreduce -L-200M $vg/$lv
+not lvreduce -L-200M $vg/$lv
+lvreduce --fs checksize -L-200M $vg/$lv
 check lv_field $vg/$lv lv_size "256.00m"
 lvremove $vg/$lv
 
@@ -1145,7 +1146,7 @@ df --output=size "$mount_dir" |tee df1
 umount "$mount_dir"
 lvchange -an $vg/$lv
 # no fs reduce is needed
-lvreduce -L200M $vg/$lv
+lvreduce --fs checksize -L200M $vg/$lv
 check lv_field $vg/$lv lv_size "200.00m"
 lvchange -ay $vg/$lv
 mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir"
@@ -1167,7 +1168,7 @@ df --output=size "$mount_dir" |tee df1
 umount "$mount_dir"
 lvchange -an $vg/$lv
 # fs is 200M, reduced size is 216M, so no fs reduce is needed
-lvreduce -L216M $vg/$lv
+lvreduce --fs checksize -L216M $vg/$lv
 check lv_field $vg/$lv lv_size "216.00m"
 lvchange -ay $vg/$lv
 mount "$DM_DEV_DIR/$vg/$lv" "$mount_dir"


                 reply	other threads:[~2022-10-11 17:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221011174944.08F073858D39@sourceware.org \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.