Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 140155
b: refs/heads/master
c: c662139
h: refs/heads/master
i:
  140153: f925178
  140151: 5548fac
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Apr 2, 2009
1 parent 09b792d commit ed398d7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 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: 2913808eb56a6445a7b277eb8d17651c8defb035
refs/heads/master: c66213921c816f6b1b16a84911618ba9a363b134
42 changes: 24 additions & 18 deletions trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,23 +992,10 @@ __lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk)
* this.
*/
static struct dm_snap_pending_exception *
__find_pending_exception(struct dm_snapshot *s, struct bio *bio)
__find_pending_exception(struct dm_snapshot *s,
struct dm_snap_pending_exception *pe, chunk_t chunk)
{
struct dm_snap_pending_exception *pe, *pe2;
chunk_t chunk = sector_to_chunk(s, bio->bi_sector);

/*
* Create a new pending exception, we don't want
* to hold the lock while we do this.
*/
up_write(&s->lock);
pe = alloc_pending_exception(s);
down_write(&s->lock);

if (!s->valid) {
free_pending_exception(pe);
return NULL;
}
struct dm_snap_pending_exception *pe2;

pe2 = __lookup_pending_exception(s, chunk);
if (pe2) {
Expand Down Expand Up @@ -1083,7 +1070,17 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
if (bio_rw(bio) == WRITE) {
pe = __lookup_pending_exception(s, chunk);
if (!pe) {
pe = __find_pending_exception(s, bio);
up_write(&s->lock);
pe = alloc_pending_exception(s);
down_write(&s->lock);

if (!s->valid) {
free_pending_exception(pe);
r = -EIO;
goto out_unlock;
}

pe = __find_pending_exception(s, pe, chunk);
if (!pe) {
__invalidate_snapshot(s, -ENOMEM);
r = -EIO;
Expand Down Expand Up @@ -1220,7 +1217,16 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)

pe = __lookup_pending_exception(snap, chunk);
if (!pe) {
pe = __find_pending_exception(snap, bio);
up_write(&snap->lock);
pe = alloc_pending_exception(snap);
down_write(&snap->lock);

if (!snap->valid) {
free_pending_exception(pe);
goto next_snapshot;
}

pe = __find_pending_exception(snap, pe, chunk);
if (!pe) {
__invalidate_snapshot(snap, -ENOMEM);
goto next_snapshot;
Expand Down

0 comments on commit ed398d7

Please sign in to comment.