[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] (6/11) re-introduce vg_read



Hi,

this patch gets us back a function called vg_read, but this time it also does
locking -- by default it grabs a read lock, as vg_read_for_update should be
used when write lock is desired.

Yours,
   Petr.

Sat Jul 12 14:50:51 CEST 2008  me mornfall net
  * Add vg_read for read-only VG access and use it.
Thu Oct 30 18:17:09 CET 2008  Petr Rockai <me mornfall net>
  tagged base 8-4
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata.c new-lvmlib-b/lib/metadata/metadata.c
--- old-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:17:46.061837688 +0100
+++ new-lvmlib-b/lib/metadata/metadata.c	2008-10-30 18:17:46.125836744 +0100
@@ -2460,8 +2460,16 @@ vg_t *vg_read_for_update(struct cmd_cont
 	if (flags & KEEP_LOCK)
 		misc |= KEEP_LOCK;
 
-	return vg_lock_and_read(cmd, vg_name, vgid, lock,
-				status, misc);
+	return vg_lock_and_read(cmd, vg_name, vgid, lock, status, misc);
+}
+
+vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+	      const char *vgid, uint32_t flags)
+{
+	uint32_t status = CLUSTERED;
+	uint32_t lock = LCK_VG_READ;
+
+	return vg_lock_and_read(cmd, vg_name, vgid, lock, status, 0);
 }
 
 /*
diff -rN -p -u old-lvmlib-b/lib/metadata/metadata-exported.h new-lvmlib-b/lib/metadata/metadata-exported.h
--- old-lvmlib-b/lib/metadata/metadata-exported.h	2008-10-30 18:17:46.061837688 +0100
+++ new-lvmlib-b/lib/metadata/metadata-exported.h	2008-10-30 18:17:46.125836744 +0100
@@ -372,6 +372,10 @@ vg_t *vg_lock_and_read(struct cmd_contex
 		       const char *vgid,
 		       uint32_t lock_flags, uint32_t status_flags,
 		       uint32_t misc_flags);
+
+vg_t *vg_read(struct cmd_context *cmd, const char *vg_name,
+	      const char *vgid, uint32_t flags);
+
 vg_t *vg_read_for_update(struct cmd_context *cmd, const char *vg_name,
 			 const char *vgid, uint32_t flags);
 
diff -rN -p -u old-lvmlib-b/tools/pvdisplay.c new-lvmlib-b/tools/pvdisplay.c
--- old-lvmlib-b/tools/pvdisplay.c	2008-10-30 18:17:46.061837688 +0100
+++ new-lvmlib-b/tools/pvdisplay.c	2008-10-30 18:17:46.093837495 +0100
@@ -28,10 +28,11 @@ static int _pvdisplay_single(struct cmd_
 
 	if (!is_orphan(pv) && !vg) {
 		vg_name = pv_vg_name(pv);
-		if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid,
-					    LCK_VG_READ, CLUSTERED, 0))) {
+		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
+		if (!vg || vg->failed) {
 		 	log_error("Skipping volume group %s", vg_name);
-			/* FIXME If CLUSTERED should return ECMD_PROCESSED here */
+			if (vg->failed == FAILED_CLUSTERED)
+				return ECMD_PROCESSED;
 		 	return ECMD_FAILED;
 	 	}
 
diff -rN -p -u old-lvmlib-b/tools/reporter.c new-lvmlib-b/tools/reporter.c
--- old-lvmlib-b/tools/reporter.c	2008-10-30 18:17:46.061837688 +0100
+++ new-lvmlib-b/tools/reporter.c	2008-10-30 18:17:46.089836218 +0100
@@ -125,15 +125,15 @@ static int _pvs_single(struct cmd_contex
 	if (is_pv(pv) && !is_orphan(pv) && !vg) {
 		vg_name = pv_vg_name(pv);
 
-		if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid,
-					    LCK_VG_READ, CLUSTERED, 0))) {
+		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
+		if (!vg || vg->failed) {
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}
 
 		/*
 		 * Replace possibly incomplete PV structure with new one
-		 * allocated in vg_read_internal() path.
+		 * allocated in vg_read() path.
 		*/
 		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
 			log_error("Unable to find \"%s\" in volume group \"%s\"",
diff -rN -p -u old-lvmlib-b/tools/toollib.c new-lvmlib-b/tools/toollib.c
--- old-lvmlib-b/tools/toollib.c	2008-10-30 18:17:46.061837688 +0100
+++ new-lvmlib-b/tools/toollib.c	2008-10-30 18:17:46.093837495 +0100
@@ -427,8 +427,8 @@ int process_each_segment_in_pv(struct cm
 	if (!vg && !is_orphan(pv)) {
 		vg_name = pv_vg_name(pv);
 
-		if (!(vg = vg_lock_and_read(cmd, vg_name, NULL, LCK_VG_READ,
-					    CLUSTERED, 0))) {
+		vg = vg_read(cmd, vg_name, NULL, 0);
+		if (!vg || vg->failed) {
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}

-- 
Peter Rockai | me()mornfall!net | prockai()redhat!com
 http://blog.mornfall.net | http://web.mornfall.net

"In My Egotistical Opinion, most people's C programs should be
 indented six feet downward and covered with dirt."
     -- Blair P. Houghton on the subject of C program indentation

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]