diff mbox

Lock only when querying status, not table

Message ID Pine.LNX.4.64.0911301356260.26310@hs20-bc2-1.build.redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Alasdair Kergon
Headers show

Commit Message

Mikulas Patocka Nov. 30, 2009, 7:05 p.m. UTC
None
diff mbox

Patch

Index: linux-2.6.32-rc8-devel/drivers/md/dm-snap.c
===================================================================
--- linux-2.6.32-rc8-devel.orig/drivers/md/dm-snap.c	2009-11-30 17:56:06.000000000 +0100
+++ linux-2.6.32-rc8-devel/drivers/md/dm-snap.c	2009-11-30 18:00:44.000000000 +0100
@@ -1407,10 +1407,11 @@  static int snapshot_status(struct dm_tar
 	unsigned sz = 0;
 	struct dm_snapshot *snap = ti->private;
 
-	down_write(&snap->lock);
-
 	switch (type) {
 	case STATUSTYPE_INFO:
+
+		down_write(&snap->lock);
+
 		if (!snap->valid)
 			DMEMIT("Invalid");
 		else {
@@ -1429,6 +1430,9 @@  static int snapshot_status(struct dm_tar
 			else
 				DMEMIT("Unknown");
 		}
+
+		up_write(&snap->lock);
+
 		break;
 
 	case STATUSTYPE_TABLE:
@@ -1443,8 +1447,6 @@  static int snapshot_status(struct dm_tar
 		break;
 	}
 
-	up_write(&snap->lock);
-
 	return 0;
 }