Commit 651385e4 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Greg Kroah-Hartman

dm snapshot: lock snapshot while supplying status

commit 4c6fff44 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: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e61f48eb
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment