diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2009-10-16 18:18:16 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2009-10-16 18:18:16 -0400 |
commit | 4c6fff445d7aa753957856278d4d93bcad6e2c14 (patch) | |
tree | 56ac3d262699fe5a42f76fe9f992277a6a7a2934 | |
parent | 0e8c4e4e3ebb15756ddc4170a88149a2cd323cfe (diff) |
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>
-rw-r--r-- | drivers/md/dm-snap.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 9cb392b3e920..9bc814aa2bbd 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, | |||
1152 | unsigned sz = 0; | 1152 | unsigned sz = 0; |
1153 | struct dm_snapshot *snap = ti->private; | 1153 | struct dm_snapshot *snap = ti->private; |
1154 | 1154 | ||
1155 | down_write(&snap->lock); | ||
1156 | |||
1155 | switch (type) { | 1157 | switch (type) { |
1156 | case STATUSTYPE_INFO: | 1158 | case STATUSTYPE_INFO: |
1157 | if (!snap->valid) | 1159 | if (!snap->valid) |
@@ -1183,6 +1185,8 @@ static int snapshot_status(struct dm_target *ti, status_type_t type, | |||
1183 | break; | 1185 | break; |
1184 | } | 1186 | } |
1185 | 1187 | ||
1188 | up_write(&snap->lock); | ||
1189 | |||
1186 | return 0; | 1190 | return 0; |
1187 | } | 1191 | } |
1188 | 1192 | ||