mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 11:46:19 +00:00
dm snapshot: lock snapshot while supplying status
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: stable@kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
parent
0e8c4e4e3e
commit
4c6fff445d
1 changed files with 4 additions and 0 deletions
|
@ -1152,6 +1152,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)
|
||||
|
@ -1183,6 +1185,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
|
|||
break;
|
||||
}
|
||||
|
||||
up_write(&snap->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue