Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 142897
b: refs/heads/master
c: 340cd44
h: refs/heads/master
i:
  142895: 281cb7a
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed Apr 8, 2009
1 parent 9137b11 commit cec9074
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 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: 73830857bca6f6c9dbd48e906daea50bea42d676
refs/heads/master: 340cd44451fb0bfa542365e6b4b565bbd44836e2
17 changes: 11 additions & 6 deletions trunk/drivers/md/dm-kcopyd.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,16 @@ static void segment_complete(int read_err, unsigned long write_err,
} else if (atomic_dec_and_test(&job->sub_jobs)) {

/*
* To avoid a race we must keep the job around
* until after the notify function has completed.
* Otherwise the client may try and stop the job
* after we've completed.
* Queue the completion callback to the kcopyd thread.
*
* Some callers assume that all the completions are called
* from a single thread and don't race with each other.
*
* We must not call the callback directly here because this
* code may not be executing in the thread.
*/
job->fn(read_err, write_err, job->context);
mempool_free(job, job->kc->job_pool);
push(&kc->complete_jobs, job);
wake(kc);
}
}

Expand All @@ -530,6 +533,8 @@ static void split_job(struct kcopyd_job *job)
{
int i;

atomic_inc(&job->kc->nr_jobs);

atomic_set(&job->sub_jobs, SPLIT_COUNT);
for (i = 0; i < SPLIT_COUNT; i++)
segment_complete(0, 0u, job);
Expand Down

0 comments on commit cec9074

Please sign in to comment.