Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38092
b: refs/heads/master
c: 9d493fa
h: refs/heads/master
v: v3
  • Loading branch information
Alasdair G Kergon authored and Linus Torvalds committed Oct 3, 2006
1 parent eb15ce7 commit 4631e2f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 47 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: ba40a2aa6e6f3d084cf35c8b872fc9f18f91231f
refs/heads/master: 9d493fa8c943ed4ec6e42b7ebfd8f0b7657d54f8
76 changes: 30 additions & 46 deletions trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,26 +609,6 @@ static void error_bios(struct bio *bio)
}
}

static inline void error_snapshot_bios(struct pending_exception *pe)
{
error_bios(bio_list_get(&pe->snapshot_bios));
}

static struct bio *__flush_bios(struct pending_exception *pe)
{
/*
* If this pe is involved in a write to the origin and
* it is the last sibling to complete then release
* the bios for the original write to the origin.
*/

if (pe->primary_pe &&
atomic_dec_and_test(&pe->primary_pe->sibling_count))
return bio_list_get(&pe->primary_pe->origin_bios);

return NULL;
}

static void __invalidate_snapshot(struct dm_snapshot *s,
struct pending_exception *pe, int err)
{
Expand Down Expand Up @@ -656,58 +636,55 @@ static void pending_complete(struct pending_exception *pe, int success)
struct exception *e;
struct pending_exception *primary_pe;
struct dm_snapshot *s = pe->snap;
struct bio *flush = NULL;
struct bio *origin_bios = NULL;
struct bio *snapshot_bios = NULL;
int error = 0;

if (!success) {
/* Read/write error - snapshot is unusable */
down_write(&s->lock);
__invalidate_snapshot(s, pe, -EIO);
flush = __flush_bios(pe);
up_write(&s->lock);

error_snapshot_bios(pe);
error = 1;
goto out;
}

e = alloc_exception();
if (!e) {
down_write(&s->lock);
__invalidate_snapshot(s, pe, -ENOMEM);
flush = __flush_bios(pe);
up_write(&s->lock);

error_snapshot_bios(pe);
error = 1;
goto out;
}
*e = pe->e;

/*
* Add a proper exception, and remove the
* in-flight exception from the list.
*/
down_write(&s->lock);
if (!s->valid) {
flush = __flush_bios(pe);
up_write(&s->lock);

free_exception(e);

error_snapshot_bios(pe);
error = 1;
goto out;
}

/*
* Add a proper exception, and remove the
* in-flight exception from the list.
*/
insert_exception(&s->complete, e);
remove_exception(&pe->e);
flush = __flush_bios(pe);

up_write(&s->lock);

/* Submit any pending write bios */
flush_bios(bio_list_get(&pe->snapshot_bios));

out:
snapshot_bios = bio_list_get(&pe->snapshot_bios);

primary_pe = pe->primary_pe;

/*
* If this pe is involved in a write to the origin and
* it is the last sibling to complete then release
* the bios for the original write to the origin.
*/
if (primary_pe &&
atomic_dec_and_test(&primary_pe->sibling_count))
origin_bios = bio_list_get(&primary_pe->origin_bios);

/*
* Free the pe if it's not linked to an origin write or if
* it's not itself a primary pe.
Expand All @@ -721,8 +698,15 @@ static void pending_complete(struct pending_exception *pe, int success)
if (primary_pe && !atomic_read(&primary_pe->sibling_count))
free_pending_exception(primary_pe);

if (flush)
flush_bios(flush);
up_write(&s->lock);

/* Submit any pending write bios */
if (error)
error_bios(snapshot_bios);
else
flush_bios(snapshot_bios);

flush_bios(origin_bios);
}

static void commit_callback(void *context, int success)
Expand Down

0 comments on commit 4631e2f

Please sign in to comment.