Skip to content

Commit

Permalink
dm snapshot: lock snapshot while supplying status
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Oct 16, 2009
1 parent 0e8c4e4 commit 4c6fff4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -1183,6 +1185,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type,
break;
}

up_write(&snap->lock);

return 0;
}

Expand Down

0 comments on commit 4c6fff4

Please sign in to comment.