Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140154
b: refs/heads/master
c: 2913808
h: refs/heads/master
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Apr 2, 2009
1 parent f925178 commit 09b792d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 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: b64b6bf4fd8b678a9f8477c11773c38a0a246a6d
refs/heads/master: 2913808eb56a6445a7b277eb8d17651c8defb035
52 changes: 28 additions & 24 deletions trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,17 @@ static void start_copy(struct dm_snap_pending_exception *pe)
&src, 1, &dest, 0, copy_callback, pe);
}

static struct dm_snap_pending_exception *
__lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk)
{
struct dm_snap_exception *e = lookup_exception(&s->pending, chunk);

if (!e)
return NULL;

return container_of(e, struct dm_snap_pending_exception, e);
}

/*
* Looks to see if this snapshot already has a pending exception
* for this chunk, otherwise it allocates a new one and inserts
Expand All @@ -983,20 +994,9 @@ static void start_copy(struct dm_snap_pending_exception *pe)
static struct dm_snap_pending_exception *
__find_pending_exception(struct dm_snapshot *s, struct bio *bio)
{
struct dm_snap_exception *e;
struct dm_snap_pending_exception *pe;
struct dm_snap_pending_exception *pe, *pe2;
chunk_t chunk = sector_to_chunk(s, bio->bi_sector);

/*
* Is there a pending exception for this already ?
*/
e = lookup_exception(&s->pending, chunk);
if (e) {
/* cast the exception to a pending exception */
pe = container_of(e, struct dm_snap_pending_exception, e);
goto out;
}

/*
* Create a new pending exception, we don't want
* to hold the lock while we do this.
Expand All @@ -1010,11 +1010,10 @@ __find_pending_exception(struct dm_snapshot *s, struct bio *bio)
return NULL;
}

e = lookup_exception(&s->pending, chunk);
if (e) {
pe2 = __lookup_pending_exception(s, chunk);
if (pe2) {
free_pending_exception(pe);
pe = container_of(e, struct dm_snap_pending_exception, e);
goto out;
return pe2;
}

pe->e.old_chunk = chunk;
Expand All @@ -1032,7 +1031,6 @@ __find_pending_exception(struct dm_snapshot *s, struct bio *bio)
get_pending_exception(pe);
insert_exception(&s->pending, &pe->e);

out:
return pe;
}

Expand Down Expand Up @@ -1083,11 +1081,14 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
* writeable.
*/
if (bio_rw(bio) == WRITE) {
pe = __find_pending_exception(s, bio);
pe = __lookup_pending_exception(s, chunk);
if (!pe) {
__invalidate_snapshot(s, -ENOMEM);
r = -EIO;
goto out_unlock;
pe = __find_pending_exception(s, bio);
if (!pe) {
__invalidate_snapshot(s, -ENOMEM);
r = -EIO;
goto out_unlock;
}
}

remap_exception(s, &pe->e, bio, chunk);
Expand Down Expand Up @@ -1217,10 +1218,13 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
if (e)
goto next_snapshot;

pe = __find_pending_exception(snap, bio);
pe = __lookup_pending_exception(snap, chunk);
if (!pe) {
__invalidate_snapshot(snap, -ENOMEM);
goto next_snapshot;
pe = __find_pending_exception(snap, bio);
if (!pe) {
__invalidate_snapshot(snap, -ENOMEM);
goto next_snapshot;
}
}

if (!primary_pe) {
Expand Down

0 comments on commit 09b792d

Please sign in to comment.