Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 118123
b: refs/heads/master
c: 879129d
h: refs/heads/master
i:
  118121: 6807a55
  118119: 5b2d384
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Oct 30, 2008
1 parent 8405ff6 commit 0090779
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 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: 60c856c8e2f57a3f69c505735ef66e3719ea0bd6
refs/heads/master: 879129d208f725267366296b631aef31409cf304
16 changes: 15 additions & 1 deletion trunk/drivers/md/dm-snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,14 +370,19 @@ static struct dm_snap_pending_exception *alloc_pending_exception(struct dm_snaps
struct dm_snap_pending_exception *pe = mempool_alloc(s->pending_pool,
GFP_NOIO);

atomic_inc(&s->pending_exceptions_count);
pe->snap = s;

return pe;
}

static void free_pending_exception(struct dm_snap_pending_exception *pe)
{
mempool_free(pe, pe->snap->pending_pool);
struct dm_snapshot *s = pe->snap;

mempool_free(pe, s->pending_pool);
smp_mb__before_atomic_dec();
atomic_dec(&s->pending_exceptions_count);
}

static void insert_completed_exception(struct dm_snapshot *s,
Expand Down Expand Up @@ -602,6 +607,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)

s->valid = 1;
s->active = 0;
atomic_set(&s->pending_exceptions_count, 0);
init_rwsem(&s->lock);
spin_lock_init(&s->pe_lock);
s->ti = ti;
Expand Down Expand Up @@ -728,6 +734,14 @@ static void snapshot_dtr(struct dm_target *ti)
/* After this returns there can be no new kcopyd jobs. */
unregister_snapshot(s);

while (atomic_read(&s->pending_exceptions_count))
yield();
/*
* Ensure instructions in mempool_destroy aren't reordered
* before atomic_read.
*/
smp_mb();

#ifdef CONFIG_DM_DEBUG
for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++)
BUG_ON(!hlist_empty(&s->tracked_chunk_hash[i]));
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/md/dm-snap.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ struct dm_snapshot {

mempool_t *pending_pool;

atomic_t pending_exceptions_count;

struct exception_table pending;
struct exception_table complete;

Expand Down

0 comments on commit 0090779

Please sign in to comment.