From: Mikulas Patocka <[email-masked]>

This patch locks the snapshot when returning status.  It fixes a race 
when it could return an invalid number of free chunks if someone 
was simultaneously modifying it.

Cc: [email-masked]
Signed-off-by: Mikulas Patocka <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>

---
 drivers/md/dm-snap.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: linux-2.6.32-rc5/drivers/md/dm-snap.c
===================================================================
--- linux-2.6.32-rc5.orig/drivers/md/dm-snap.c
+++ linux-2.6.32-rc5/drivers/md/dm-snap.c
@@ -1152,6 +1152,8 @@ 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:
 		if (!snap->valid)
@@ -1183,6 +1185,8 @@ static int snapshot_status(struct dm_tar
 		break;
 	}
 
+	up_write(&snap->lock);
+
 	return 0;
 }