Skip to contentSkip to conversation

LVM2 ./WHATS_NEW tools/pvdisplay.c tools/pvres ...

PATCH [email protected] 1 participant 1 message Nov 14, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2007-11-14 18:41:05

Modified files:
. : WHATS_NEW
tools : pvdisplay.c pvresize.c reporter.c toollib.c
toollib.h vgreduce.c

Log message:
Avoid nested vg_reads when processing PVs in VGs and fix associated locking.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.734&r2=1.735
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70

WHATS_NEW +1 -0
@@ -1,5 +1,6 @@
 Version 2.02.29 -
 ==================================
+  Avoid nested vg_reads when processing PVs in VGs and fix associated locking.
   Accept sizes with --readahead argument.
   Store size arguments as sectors internally.
   Attempt to remove incomplete LVs with lvcreate zeroing/activation problems.
tools/pvdisplay.c +22 -21

61 lines not on this page · raw message

tools/pvresize.c +2 -1
@@ -61,7 +61,8 @@
 	params.done = 0;
 	params.total = 0;
 
-	ret = process_each_pv(cmd, argc, argv, NULL, &params, _pvresize_single);
+	ret = process_each_pv(cmd, argc, argv, NULL, LCK_VG_WRITE, &params,
+			      _pvresize_single);
 
 	log_print("%d physical volume(s) resized / %d physical volume(s) "
 		  "not resized", params.done, params.total - params.done);
tools/reporter.c +6 -24
@@ -54,33 +54,15 @@
 	return ECMD_PROCESSED;
 }
 
-static int _pvsegs_sub_single(struct cmd_context *cmd, struct volume_group *vg,
+static int _pvsegs_sub_single(struct cmd_context *cmd __attribute((unused)),
+			      struct volume_group *vg,
 			      struct pv_segment *pvseg, void *handle)
 {
-	int consistent = 0;
-	struct physical_volume *pv = pvseg->pv;
 	int ret = ECMD_PROCESSED;
 
-	if (!lock_vol(cmd, pv_vg_name(pv), LCK_VG_READ)) {
-		log_error("Can't lock %s: skipping", pv_vg_name(pv));
-		return ECMD_FAILED;
-	}
-
-	if (!(vg = vg_read(cmd, pv_vg_name(pv), NULL, &consistent))) {
-		log_error("Can't read %s: skipping", pv_vg_name(pv));
-		goto out;
-	}
-
-	if (!vg_check_status(vg, CLUSTERED)) {
+	if (!report_object(handle, vg, NULL, pvseg->pv, NULL, pvseg))
 		ret = ECMD_FAILED;
-		goto out;
-	}
 
-	if (!report_object(handle, vg, NULL, pv, NULL, pvseg))
-		ret = ECMD_FAILED;
-
-out:
-	unlock_vg(cmd, pv_vg_name(pv));
 	return ret;
 }
 
@@ -108,7 +90,7 @@
 	int ret = ECMD_PROCESSED;
 	const char *vg_name = NULL;
 
-	if (!is_orphan(pv)) {
+	if (!is_orphan(pv) && !vg) {
 		vg_name = pv_vg_name(pv);
 
 		if (!lock_vol(cmd, vg_name, LCK_VG_READ)) {
@@ -334,7 +316,7 @@
 		break;
 	case PVS:
 		if (args_are_pvs)
-			r = process_each_pv(cmd, argc, argv, NULL,
+			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
 					    report_handle, &_pvs_single);
 		else
 			r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0,
@@ -346,7 +328,7 @@
 		break;
 	case PVSEGS:
 		if (args_are_pvs)
-			r = process_each_pv(cmd, argc, argv, NULL,
+			r = process_each_pv(cmd, argc, argv, NULL, LCK_VG_READ,
 					    report_handle, &_pvsegs_single);
 		else
 			r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0,
tools/toollib.c +39 -3

80 lines not on this page · raw message

tools/toollib.h +1 -1
@@ -34,7 +34,7 @@
 					   int consistent, void *handle));
 
 int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
-		    struct volume_group *vg, void *handle,
+		    struct volume_group *vg, uint32_t lock_type, void *handle,
 		    int (*process_single) (struct cmd_context * cmd,
 					   struct volume_group * vg,
 					   struct physical_volume * pv,
tools/vgreduce.c +1 -1
@@ -539,7 +539,7 @@
 
 		/* FIXME: Pass private struct through to all these functions */
 		/* and update in batch here? */
-		ret = process_each_pv(cmd, argc, argv, vg, NULL,
+		ret = process_each_pv(cmd, argc, argv, vg, LCK_VG_WRITE, NULL,
 				      _vgreduce_single);
 
 	}