From: Mikulas Patocka Date: Fri, 16 Oct 2009 22:18:16 +0000 (+0100) Subject: dm snapshot: lock snapshot while supplying status X-Git-Tag: upstream/snapshot3+hdmi~16785^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4c6fff445d7aa753957856278d4d93bcad6e2c14;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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 Signed-off-by: Alasdair G Kergon --- diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 9cb392b..9bc814a 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c @@ -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; }