aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-snap.c
diff options
context:
space:
mode:
authorMikulas Patocka <mpatocka@redhat.com>2009-04-02 14:55:26 -0400
committerAlasdair G Kergon <agk@redhat.com>2009-04-02 14:55:26 -0400
commit35bf659b008e83e725dcd30f542e38461dbb867c (patch)
tree40be2f357f0905573bd4d21ff59e0db3cda26442 /drivers/md/dm-snap.c
parentc66213921c816f6b1b16a84911618ba9a363b134 (diff)
dm snapshot: avoid having two exceptions for the same chunk
We need to check if the exception was completed after dropping the lock. After regaining the lock, __find_pending_exception checks if the exception was already placed into &s->pending hash. But we don't check if the exception was already completed and placed into &s->complete hash. If the process waiting in alloc_pending_exception was delayed at this point because of a scheduling latency and the exception was meanwhile completed, we'd miss that and allocate another pending exception for already completed chunk. It would lead to a situation where two records for the same chunk exist and potential data corruption because multiple snapshot I/Os to the affected chunk could be redirected to different locations in the snapshot. Cc: stable@kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-snap.c')
-rw-r--r--drivers/md/dm-snap.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index eb7291a84203..462750c66319 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1080,6 +1080,13 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
1080 goto out_unlock; 1080 goto out_unlock;
1081 } 1081 }
1082 1082
1083 e = lookup_exception(&s->complete, chunk);
1084 if (e) {
1085 free_pending_exception(pe);
1086 remap_exception(s, e, bio, chunk);
1087 goto out_unlock;
1088 }
1089
1083 pe = __find_pending_exception(s, pe, chunk); 1090 pe = __find_pending_exception(s, pe, chunk);
1084 if (!pe) { 1091 if (!pe) {
1085 __invalidate_snapshot(s, -ENOMEM); 1092 __invalidate_snapshot(s, -ENOMEM);
@@ -1226,6 +1233,12 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
1226 goto next_snapshot; 1233 goto next_snapshot;
1227 } 1234 }
1228 1235
1236 e = lookup_exception(&snap->complete, chunk);
1237 if (e) {
1238 free_pending_exception(pe);
1239 goto next_snapshot;
1240 }
1241
1229 pe = __find_pending_exception(snap, pe, chunk); 1242 pe = __find_pending_exception(snap, pe, chunk);
1230 if (!pe) { 1243 if (!pe) {
1231 __invalidate_snapshot(snap, -ENOMEM); 1244 __invalidate_snapshot(snap, -ENOMEM);