public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools lvresize.c
@ 2011-11-08 12:19 zkabelac
  0 siblings, 0 replies; 9+ messages in thread
From: zkabelac @ 2011-11-08 12:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-08 12:19:53

Modified files:
	tools          : lvresize.c 

Log message:
	Thin ensure pool table is update after resize
	
	Always make sure table gets reloaded.
	For now activate and deactivate pool volume if it's not active.
	
	FIXME: we could do this only if we are sure some thin volume is alive.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143

--- LVM2/tools/lvresize.c	2011/11/07 10:58:13	1.142
+++ LVM2/tools/lvresize.c	2011/11/08 12:19:53	1.143
@@ -781,6 +781,20 @@
 
 	backup(vg);
 
+	/*
+	 * Update lvm pool metadata (drop messages) if the pool has been
+	 * resumed and do a pool active/deactivate in other case.
+	 *
+	 * Note: Active thin pool can be waiting for resize.
+	 *
+	 * FIXME: Activate only when thin volume is active
+	 */
+	if (lv_is_thin_pool(lv) &&
+	    !update_pool_lv(lv, !lv_is_active(lv))) {
+		stack;
+		return ECMD_FAILED;
+	}
+
 	log_print("Logical volume %s successfully resized", lp->lv_name);
 
 	if (lp->resizefs && (lp->resize == LV_EXTEND) &&


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2012-04-12 15:11 agk
  0 siblings, 0 replies; 9+ messages in thread
From: agk @ 2012-04-12 15:11 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-04-12 15:11:21

Modified files:
	tools          : lvresize.c 

Log message:
	Remove 'up' from rounding message that sometimes rounds down.
	Detect reduction of 0 after rounding for stripes and avoid warning of potential data loss.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.154&r2=1.155

--- LVM2/tools/lvresize.c	2012/04/11 12:40:04	1.154
+++ LVM2/tools/lvresize.c	2012/04/12 15:11:21	1.155
@@ -454,6 +454,12 @@
 
 	alloc = (alloc_policy_t) arg_uint_value(cmd, alloc_ARG, lv->alloc);
 
+	/*
+	 * First adjust to an exact multiple of extent size.
+	 * When extending by a relative amount we round that amount up.
+	 * When reducing by a relative amount we remove at most that amount.
+	 * When changing to an absolute size, we round that size up.
+	 */
 	if (lp->size) {
 		if (lp->size % vg->extent_size) {
 			if (lp->sign == SIGN_MINUS)
@@ -462,7 +468,7 @@
 				lp->size += vg->extent_size -
 				    (lp->size % vg->extent_size);
 
-			log_print("Rounding up size to full physical extent %s",
+			log_print("Rounding size to boundary between physical extents: %s",
 				  display_size(cmd, lp->size));
 		}
 
@@ -714,6 +720,15 @@
 			return EINVALID_CMD_LINE;
 		}
 		lp->resize = LV_EXTEND;
+	} else if (lp->extents == lv->le_count) {
+		if (use_policy)
+			return ECMD_PROCESSED; /* Nothing to do. */
+		if (!lp->resizefs) {
+			log_error("New size (%d extents) matches existing size "
+				  "(%d extents)", lp->extents, lv->le_count);
+			return EINVALID_CMD_LINE;
+		}
+		lp->resize = LV_EXTEND;
 	}
 
 	if (lv_is_origin(lv)) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2012-04-11 12:30 zkabelac
  0 siblings, 0 replies; 9+ messages in thread
From: zkabelac @ 2012-04-11 12:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-04-11 12:30:49

Modified files:
	tools          : lvresize.c 

Log message:
	Move check for min strip size
	
	and remove few asigns that are not needed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.151&r2=1.152

--- LVM2/tools/lvresize.c	2012/03/05 15:05:25	1.151
+++ LVM2/tools/lvresize.c	2012/04/11 12:30:48	1.152
@@ -367,12 +367,12 @@
 {
 	struct logical_volume *lv;
 	struct lvinfo info;
-	uint32_t stripesize_extents = 0;
-	uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
+	uint32_t stripesize_extents;
+	uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size;
 	uint32_t seg_mirrors = 0;
-	uint32_t extents_used = 0;
+	uint32_t extents_used;
 	uint32_t size_rest;
-	uint32_t pv_extent_count = 0;
+	uint32_t pv_extent_count;
 	alloc_policy_t alloc;
 	struct logical_volume *lock_lv;
 	struct lv_list *lvl;
@@ -665,6 +665,12 @@
 	}
 
 	if (lp->stripes > 1) {
+		if (lp->stripe_size < STRIPE_SIZE_MIN) {
+			log_error("Invalid stripe size %s",
+				  display_size(cmd, (uint64_t) lp->stripe_size));
+			return EINVALID_CMD_LINE;
+		}
+
 		if (!(stripesize_extents = lp->stripe_size / vg->extent_size))
 			stripesize_extents = 1;
 
@@ -684,11 +690,6 @@
 			lp->extents = lp->extents - size_rest;
 		}
 
-		if (lp->stripe_size < STRIPE_SIZE_MIN) {
-			log_error("Invalid stripe size %s",
-				  display_size(cmd, (uint64_t) lp->stripe_size));
-			return EINVALID_CMD_LINE;
-		}
 	}
 
 	if (lp->extents < lv->le_count) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2011-06-15 10:56 mbroz
  0 siblings, 0 replies; 9+ messages in thread
From: mbroz @ 2011-06-15 10:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-06-15 10:56:52

Modified files:
	tools          : lvresize.c 

Log message:
	Fix lvreduce stripe rounding up from previous commit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133

--- LVM2/tools/lvresize.c	2011/06/09 19:38:56	1.132
+++ LVM2/tools/lvresize.c	2011/06/15 10:56:52	1.133
@@ -609,8 +609,10 @@
 		if (size_rest && lp->resize == LV_REDUCE) {
 			log_print("Rounding size (%d extents) up to stripe "
 				  "boundary size for segment (%d extents)",
-				  lp->extents, lp->extents + size_rest);
-			lp->extents = lp->extents + size_rest;
+				  lp->extents, lp->extents - size_rest +
+				  (lp->stripes * stripesize_extents));
+			lp->extents = lp->extents - size_rest +
+				      (lp->stripes * stripesize_extents);
 		} else if (size_rest) {
 			log_print("Rounding size (%d extents) down to stripe "
 				  "boundary size for segment (%d extents)",


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2009-02-28 19:43 agk
  0 siblings, 0 replies; 9+ messages in thread
From: agk @ 2009-02-28 19:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-02-28 19:43:42

Modified files:
	tools          : lvresize.c 

Log message:
	.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105

--- LVM2/tools/lvresize.c	2009/02/28 00:54:07	1.104
+++ LVM2/tools/lvresize.c	2009/02/28 19:43:42	1.105
@@ -579,7 +579,7 @@
 	if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
 	    !_request_confirmation(cmd, vg, lv, lp)) {
 		stack;
-		// return ECMD_FAILED;
+		return ECMD_FAILED;
 	}
 
 	if (lp->resizefs) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2009-02-27 23:55 agk
  0 siblings, 0 replies; 9+ messages in thread
From: agk @ 2009-02-27 23:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-02-27 23:55:15

Modified files:
	tools          : lvresize.c 

Log message:
	.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103

--- LVM2/tools/lvresize.c	2009/02/27 23:40:12	1.102
+++ LVM2/tools/lvresize.c	2009/02/27 23:55:15	1.103
@@ -579,7 +579,7 @@
 	if ((lp->resizefs || (lp->resize == LV_REDUCE)) &&
 	    !_request_confirmation(cmd, vg, lv, lp)) {
 		stack;
-		// return ECMD_FAILED;
+		return ECMD_FAILED;
 	}
 
 	if (lp->resizefs) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2007-09-06 22:35 wysochanski
  0 siblings, 0 replies; 9+ messages in thread
From: wysochanski @ 2007-09-06 22:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-09-06 22:35:01

Modified files:
	tools          : lvresize.c 

Log message:
	Fix last checkin

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82

--- LVM2/tools/lvresize.c	2007/09/06 21:08:16	1.81
+++ LVM2/tools/lvresize.c	2007/09/06 22:35:01	1.82
@@ -132,7 +132,6 @@
 }
 
 static int do_resizefs_reduce(struct cmd_context *cmd, struct volume_group *vg,
-			      struct logical_volume *lv,
 			      struct lvresize_params *lp)
 {
 	char lv_path[PATH_MAX];
@@ -552,7 +551,7 @@
 	}
 
 	if (lp->resizefs) {
-		if (!do_resizefs_reduce(cmd, vg, lv_path, lp))
+		if (!do_resizefs_reduce(cmd, vg, lp))
 		    return ECMD_FAILED;
 	}
 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2007-09-06 21:08 wysochanski
  0 siblings, 0 replies; 9+ messages in thread
From: wysochanski @ 2007-09-06 21:08 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-09-06 21:08:16

Modified files:
	tools          : lvresize.c 

Log message:
	Fixup _lvresize error return codes and modularize function

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81

--- LVM2/tools/lvresize.c	2007/08/20 20:55:30	1.80
+++ LVM2/tools/lvresize.c	2007/09/06 21:08:16	1.81
@@ -46,6 +46,128 @@
 	char **argv;
 };
 
+static int validate_stripesize(struct cmd_context *cmd,
+			       struct volume_group *vg,
+			       struct lvresize_params *lp)
+{
+	if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
+		log_error("Stripesize may not be negative.");
+		return 0;
+	}
+
+	if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
+		log_error("Stripe size cannot be larger than %s",
+			  display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
+		return 0;
+	}
+
+	if (!(vg->fid->fmt->features & FMT_SEGMENTS))
+		log_warn("Varied stripesize not supported. Ignoring.");
+	else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
+		log_error("Reducing stripe size %s to maximum, "
+			  "physical extent size %s",
+			  display_size(cmd,
+				       (uint64_t) arg_uint_value(cmd, stripesize_ARG, 0) * 2),
+			  display_size(cmd, (uint64_t) vg->extent_size));
+		lp->stripe_size = vg->extent_size;
+	} else
+		lp->stripe_size = 2 * arg_uint_value(cmd,
+						     stripesize_ARG, 0);
+
+	if (lp->mirrors) {
+		log_error("Mirrors and striping cannot be combined yet.");
+		return 0;
+	}
+	if (lp->stripe_size & (lp->stripe_size - 1)) {
+		log_error("Stripe size must be power of 2");
+		return 0;
+	}
+
+	return 1;
+}
+
+static int confirm_resizefs_reduce(struct cmd_context *cmd,
+				   struct volume_group *vg,
+				   struct logical_volume *lv,
+				   struct lvresize_params *lp)
+{
+	struct lvinfo info;
+
+	memset(&info, 0, sizeof(info));
+
+	if (!lv_info(cmd, lv, &info, 1) && driver_version(NULL, 0)) {
+		log_error("lv_info failed: aborting");
+		return 0;
+	}
+
+	if (lp->resizefs && !info.exists) {
+		log_error("Logical volume %s must be activated "
+			  "before resizing filesystem", lp->lv_name);
+		return 0;
+	}
+
+	if (info.exists && !lp->resizefs && (lp->resize == LV_REDUCE)) {
+		log_warn("WARNING: Reducing active%s logical volume "
+			 "to %s", info.open_count ? " and open" : "",
+			 display_size(cmd, (uint64_t) lp->extents *
+				      vg->extent_size));
+
+		log_warn("THIS MAY DESTROY YOUR DATA "
+			 "(filesystem etc.)");
+
+		if (!arg_count(cmd, force_ARG)) {
+			if (yes_no_prompt("Do you really want to "
+					  "reduce %s? [y/n]: ",
+					  lp->lv_name) == 'n') {
+				log_print("Logical volume %s NOT "
+					  "reduced", lp->lv_name);
+				return 0;
+			}
+			if (sigint_caught())
+				return 0;
+		}
+	}
+
+	return 1;
+}
+
+static int do_resizefs_reduce(struct cmd_context *cmd, struct volume_group *vg,
+			      struct logical_volume *lv,
+			      struct lvresize_params *lp)
+{
+	char lv_path[PATH_MAX];
+	char size_buf[SIZE_BUF];
+
+	if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir,
+			lp->vg_name, lp->lv_name) < 0) {
+		log_error("Couldn't create LV path for %s",
+			  lp->lv_name);
+		return 0;
+	}
+
+	if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64,
+			(uint64_t) lp->extents * vg->extent_size / 2) < 0) {
+		log_error("Couldn't generate new LV size string");
+		return 0;
+	}
+
+	if (!lp->nofsck) {
+		if (!exec_cmd("fsadm", "check", lv_path, NULL)) {
+			stack;
+			return 0;
+		}
+	}
+
+	if (lp->resize == LV_REDUCE) {
+		if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
+			stack;
+			return 0;
+		}
+	}
+
+	return 1;
+}
+
 static int _lvresize_params(struct cmd_context *cmd, int argc, char **argv,
 			    struct lvresize_params *lp)
 {
@@ -165,43 +287,13 @@
 			log_warn("Mirrors not supported. Ignoring.");
 		if (arg_sign_value(cmd, mirrors_ARG, 0) == SIGN_MINUS) {
 			log_error("Mirrors argument may not be negative");
-			return 0;
+			return EINVALID_CMD_LINE;
 		}
 	}
 
 	if (arg_count(cmd, stripesize_ARG)) {
-		if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
-			log_error("Stripesize may not be negative.");
-			return ECMD_FAILED;
-		}
-
-		if (arg_uint_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT) {
-			log_error("Stripe size cannot be larger than %s",
-				  display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
-			return 0;
-		}
-
-		if (!(vg->fid->fmt->features & FMT_SEGMENTS))
-			log_warn("Varied stripesize not supported. Ignoring.");
-		else if (arg_uint_value(cmd, stripesize_ARG, 0) > vg->extent_size) {
-                	log_error("Reducing stripe size %s to maximum, "
-				  "physical extent size %s",
-				  display_size(cmd,
-					(uint64_t) arg_uint_value(cmd, stripesize_ARG, 0) * 2),
-	                          display_size(cmd, (uint64_t) vg->extent_size));
-                	lp->stripe_size = vg->extent_size;
-        	} else
-			lp->stripe_size = 2 * arg_uint_value(cmd,
-							     stripesize_ARG, 0);
-
-		if (lp->mirrors) {
-			log_error("Mirrors and striping cannot be combined yet.");
-			return ECMD_FAILED;
-		}
-		if (lp->stripe_size & (lp->stripe_size - 1)) {
-			log_error("Stripe size must be power of 2");
-			return 0;
-		}
+		if (!validate_stripesize(cmd, vg, lp))
+			return EINVALID_CMD_LINE;
 	}
 
 	lv = lvl->lv;
@@ -393,7 +485,7 @@
 		if (lp->stripe_size < STRIPE_SIZE_MIN) {
 			log_error("Invalid stripe size %s",
 				  display_size(cmd, (uint64_t) lp->stripe_size));
-			return 0;
+			return EINVALID_CMD_LINE;
 		}
 	}
 
@@ -455,70 +547,13 @@
 	}
 
 	if (lp->resize == LV_REDUCE || lp->resizefs) {
-		memset(&info, 0, sizeof(info));
-
-		if (!lv_info(cmd, lv, &info, 1) && driver_version(NULL, 0)) {
-			log_error("lv_info failed: aborting");
-			return ECMD_FAILED;
-		}
-
-		if (lp->resizefs && !info.exists) {
-			log_error("Logical volume %s must be activated "
-				  "before resizing filesystem", lp->lv_name);
+		if (!confirm_resizefs_reduce(cmd, vg, lv, lp))
 			return ECMD_FAILED;
-		}
-
-		if (info.exists && !lp->resizefs && (lp->resize == LV_REDUCE)) {
-			log_warn("WARNING: Reducing active%s logical volume "
-				  "to %s", info.open_count ? " and open" : "",
-				  display_size(cmd, (uint64_t) lp->extents *
-						    vg->extent_size));
-
-			log_warn("THIS MAY DESTROY YOUR DATA "
-				 "(filesystem etc.)");
-
-			if (!arg_count(cmd, force_ARG)) {
-				if (yes_no_prompt("Do you really want to "
-						  "reduce %s? [y/n]: ",
-						  lp->lv_name) == 'n') {
-					log_print("Logical volume %s NOT "
-						  "reduced", lp->lv_name);
-					return ECMD_FAILED;
-				}
-				if (sigint_caught())
-					return ECMD_FAILED;
-			}
-		}
 	}
 
 	if (lp->resizefs) {
-		if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir,
-				 lp->vg_name, lp->lv_name) < 0) {
-			log_error("Couldn't create LV path for %s",
-				  lp->lv_name);
-			return ECMD_FAILED;
-		}
-
-		if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64,
-				 (uint64_t) lp->extents * vg->extent_size / 2)
-				 < 0) {
-			log_error("Couldn't generate new LV size string");
-			return ECMD_FAILED;
-		}
-
-		if (!lp->nofsck) {
-			if (!exec_cmd("fsadm", "check", lv_path, NULL)) {
-				stack;
-				return ECMD_FAILED;
-			}
-		}
-
-		if (lp->resize == LV_REDUCE) {
-			if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) {
-				stack;
-				return ECMD_FAILED;
-			}
-		}
+		if (!do_resizefs_reduce(cmd, vg, lv_path, lp))
+		    return ECMD_FAILED;
 	}
 
 	if (!archive(vg)) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* LVM2/tools lvresize.c
@ 2005-06-03 22:26 agk
  0 siblings, 0 replies; 9+ messages in thread
From: agk @ 2005-06-03 22:26 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-06-03 22:26:10

Modified files:
	tools          : lvresize.c 

Log message:
	prevent active mirror resize for now

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-12 15:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-08 12:19 LVM2/tools lvresize.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-04-12 15:11 agk
2012-04-11 12:30 zkabelac
2011-06-15 10:56 mbroz
2009-02-28 19:43 agk
2009-02-27 23:55 agk
2007-09-06 22:35 wysochanski
2007-09-06 21:08 wysochanski
2005-06-03 22:26 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).