diff options
author | Joe Thornber <ejt@redhat.com> | 2013-03-01 17:45:50 -0500 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2013-03-01 17:45:50 -0500 |
commit | 6beca5eb6e801aea810da6cbc4990d96e6c1c0bc (patch) | |
tree | 37586c9ecdd7bbc89ce4db07abde3ca32d6a8e1c /drivers/md/dm-bio-prison.h | |
parent | 4e7f1f9089660aec3b5ab2645ce62777c6f4c6a2 (diff) |
dm bio prison: pass cell memory in
Change the dm_bio_prison interface so that instead of allocating memory
internally, dm_bio_detain is supplied with a pre-allocated cell each
time it is called.
This enables a subsequent patch to move the allocation of the struct
dm_bio_prison_cell outside the thin target's mapping function so it can
no longer block there.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers/md/dm-bio-prison.h')
-rw-r--r-- | drivers/md/dm-bio-prison.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/drivers/md/dm-bio-prison.h b/drivers/md/dm-bio-prison.h index 53d1a7a84e2f..11af2182101b 100644 --- a/drivers/md/dm-bio-prison.h +++ b/drivers/md/dm-bio-prison.h | |||
@@ -35,17 +35,36 @@ struct dm_bio_prison *dm_bio_prison_create(unsigned nr_cells); | |||
35 | void dm_bio_prison_destroy(struct dm_bio_prison *prison); | 35 | void dm_bio_prison_destroy(struct dm_bio_prison *prison); |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * This may block if a new cell needs allocating. You must ensure that | 38 | * These two functions just wrap a mempool. This is a transitory step: |
39 | * cells will be unlocked even if the calling thread is blocked. | 39 | * Eventually all bio prison clients should manage their own cell memory. |
40 | * | 40 | * |
41 | * Returns 1 if the cell was already held, 0 if @inmate is the new holder. | 41 | * Like mempool_alloc(), dm_bio_prison_alloc_cell() can only fail if called |
42 | * in interrupt context or passed GFP_NOWAIT. | ||
42 | */ | 43 | */ |
43 | int dm_bio_detain(struct dm_bio_prison *prison, struct dm_cell_key *key, | 44 | struct dm_bio_prison_cell *dm_bio_prison_alloc_cell(struct dm_bio_prison *prison, |
44 | struct bio *inmate, struct dm_bio_prison_cell **ref); | 45 | gfp_t gfp); |
46 | void dm_bio_prison_free_cell(struct dm_bio_prison *prison, | ||
47 | struct dm_bio_prison_cell *cell); | ||
45 | 48 | ||
46 | void dm_cell_release(struct dm_bio_prison_cell *cell, struct bio_list *bios); | 49 | /* |
47 | void dm_cell_release_no_holder(struct dm_bio_prison_cell *cell, struct bio_list *inmates); | 50 | * An atomic op that combines retrieving a cell, and adding a bio to it. |
48 | void dm_cell_error(struct dm_bio_prison_cell *cell); | 51 | * |
52 | * Returns 1 if the cell was already held, 0 if @inmate is the new holder. | ||
53 | */ | ||
54 | int dm_bio_detain(struct dm_bio_prison *prison, | ||
55 | struct dm_cell_key *key, | ||
56 | struct bio *inmate, | ||
57 | struct dm_bio_prison_cell *cell_prealloc, | ||
58 | struct dm_bio_prison_cell **cell_result); | ||
59 | |||
60 | void dm_cell_release(struct dm_bio_prison *prison, | ||
61 | struct dm_bio_prison_cell *cell, | ||
62 | struct bio_list *bios); | ||
63 | void dm_cell_release_no_holder(struct dm_bio_prison *prison, | ||
64 | struct dm_bio_prison_cell *cell, | ||
65 | struct bio_list *inmates); | ||
66 | void dm_cell_error(struct dm_bio_prison *prison, | ||
67 | struct dm_bio_prison_cell *cell); | ||
49 | 68 | ||
50 | /*----------------------------------------------------------------*/ | 69 | /*----------------------------------------------------------------*/ |
51 | 70 | ||