dm snapshot: use merge origin if snapshot invalid

If the snapshot we are merging became invalid (e.g. it ran out of
space) redirect all I/O directly to the origin device.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
Mikulas Patocka
2009-12-10 23:52:36 +00:00
committed by Alasdair G Kergon
parent d8ddb1cfff
commit d2fdb776e0

View File

@@ -1699,11 +1699,9 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
down_write(&s->lock); down_write(&s->lock);
/* Full snapshots are not usable */ /* Full merging snapshots are redirected to the origin */
if (!s->valid) { if (!s->valid)
r = -EIO; goto redirect_to_origin;
goto out_unlock;
}
/* If the block is already remapped - use that */ /* If the block is already remapped - use that */
e = dm_lookup_exception(&s->complete, chunk); e = dm_lookup_exception(&s->complete, chunk);
@@ -1726,6 +1724,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
goto out_unlock; goto out_unlock;
} }
redirect_to_origin:
bio->bi_bdev = s->origin->bdev; bio->bi_bdev = s->origin->bdev;
if (bio_rw(bio) == WRITE) { if (bio_rw(bio) == WRITE) {