Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176574
b: refs/heads/master
c: 10b8106
h: refs/heads/master
v: v3
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed Dec 10, 2009
1 parent 4c178fe commit 49af7fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3452c2a1eb5b93c1b9fb0d22bd5b07c0cee4dc29
refs/heads/master: 10b8106a70433e14153469ebbdd189776500e238
21 changes: 18 additions & 3 deletions trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,14 +709,20 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
int i;
int r = -EINVAL;
char *origin_path, *cow_path;
unsigned args_used;
unsigned args_used, num_flush_requests = 1;
fmode_t origin_mode = FMODE_READ;

if (argc != 4) {
ti->error = "requires exactly 4 arguments";
r = -EINVAL;
goto bad;
}

if (dm_target_is_snapshot_merge(ti)) {
num_flush_requests = 2;
origin_mode = FMODE_WRITE;
}

origin_path = argv[0];
argv++;
argc--;
Expand Down Expand Up @@ -750,7 +756,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
argv += args_used;
argc -= args_used;

r = dm_get_device(ti, origin_path, 0, ti->len, FMODE_READ, &s->origin);
r = dm_get_device(ti, origin_path, 0, ti->len, origin_mode, &s->origin);
if (r) {
ti->error = "Cannot get origin device";
goto bad_origin;
Expand Down Expand Up @@ -801,7 +807,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
INIT_WORK(&s->queued_bios_work, flush_queued_bios);

ti->private = s;
ti->num_flush_requests = 1;
ti->num_flush_requests = num_flush_requests;

/* Add snapshot to the list of snapshots for this origin */
/* Exceptions aren't triggered till snapshot_resume() is called */
Expand Down Expand Up @@ -1326,6 +1332,15 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
int r = DM_MAPIO_REMAPPED;
chunk_t chunk;

if (unlikely(bio_empty_barrier(bio))) {
if (!map_context->flush_request)
bio->bi_bdev = s->origin->bdev;
else
bio->bi_bdev = s->cow->bdev;
map_context->ptr = NULL;
return DM_MAPIO_REMAPPED;
}

chunk = sector_to_chunk(s->store, bio->bi_sector);

down_read(&s->lock);
Expand Down

0 comments on commit 49af7fb

Please sign in to comment.