Skip to content

Commit

Permalink
dm snapshot: use merge origin if snapshot invalid
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Dec 10, 2009
1 parent d8ddb1c commit d2fdb77
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1699,11 +1699,9 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,

down_write(&s->lock);

/* Full snapshots are not usable */
if (!s->valid) {
r = -EIO;
goto out_unlock;
}
/* Full merging snapshots are redirected to the origin */
if (!s->valid)
goto redirect_to_origin;

/* If the block is already remapped - use that */
e = dm_lookup_exception(&s->complete, chunk);
Expand All @@ -1726,6 +1724,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
goto out_unlock;
}

redirect_to_origin:
bio->bi_bdev = s->origin->bdev;

if (bio_rw(bio) == WRITE) {
Expand Down

0 comments on commit d2fdb77

Please sign in to comment.