summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-10-16 23:18:16 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2009-11-09 16:22:06 -0800
commit651385e4bbbff823f111e4e8a68b2e1613c34c79 (patch)
treefb4b3ed8702f2a78754c4f58e6174e9f6f13eb38
parente61f48eb0ac00c6d73dd53b3d79abe2c578328dc (diff)
dm snapshot: lock snapshot while supplying status
commit 4c6fff445d7aa753957856278d4d93bcad6e2c14 upstream. 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. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/md/dm-snap.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 53f4063f7ea4..b9dd22ce47d4 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1147,6 +1147,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
unsigned sz = 0;
struct dm_snapshot *snap = ti->private;
+ down_write(&snap->lock);
+
switch (type) {
case STATUSTYPE_INFO:
if (!snap->valid)
@@ -1178,6 +1180,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
break;
}
+ up_write(&snap->lock);
+
return 0;
}