summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2014-09-17 05:17:39 -0400
committerMike Snitzer <snitzer@redhat.com>2014-11-10 15:25:30 -0500
commit5f274d886598c9fd26d2499bf3f68306f170e9db (patch)
treeaf0ded19382c65e832ea51e2b01efb40581c81dd /drivers/md
parentf1afb36a6102b52949c2c6d8eb250eddcce3fc5f (diff)
dm bio prison: introduce support for locking ranges of blocks
Ranges will be placed in the same cell if they overlap. Range locking is a prerequisite for more efficient multi-block discard support in both the cache and thin-provisioning targets. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-bio-prison.c4
-rw-r--r--drivers/md/dm-bio-prison.h12
-rw-r--r--drivers/md/dm-cache-target.c3
-rw-r--r--drivers/md/dm-thin.c6
4 files changed, 16 insertions, 9 deletions
diff --git a/drivers/md/dm-bio-prison.c b/drivers/md/dm-bio-prison.c
index bbe22a5dc06b..be065300e93c 100644
--- a/drivers/md/dm-bio-prison.c
+++ b/drivers/md/dm-bio-prison.c
@@ -95,10 +95,10 @@ static int cmp_keys(struct dm_cell_key *lhs,
95 if (lhs->dev > rhs->dev) 95 if (lhs->dev > rhs->dev)
96 return 1; 96 return 1;
97 97
98 if (lhs->block < rhs->block) 98 if (lhs->block_end <= rhs->block_begin)
99 return -1; 99 return -1;
100 100
101 if (lhs->block > rhs->block) 101 if (lhs->block_begin >= rhs->block_end)
102 return 1; 102 return 1;
103 103
104 return 0; 104 return 0;
diff --git a/drivers/md/dm-bio-prison.h b/drivers/md/dm-bio-prison.h
index b03988667740..74cf01144b1f 100644
--- a/drivers/md/dm-bio-prison.h
+++ b/drivers/md/dm-bio-prison.h
@@ -23,11 +23,14 @@
23 */ 23 */
24struct dm_bio_prison; 24struct dm_bio_prison;
25 25
26/* FIXME: this needs to be more abstract */ 26/*
27 * Keys define a range of blocks within either a virtual or physical
28 * device.
29 */
27struct dm_cell_key { 30struct dm_cell_key {
28 int virtual; 31 int virtual;
29 dm_thin_id dev; 32 dm_thin_id dev;
30 dm_block_t block; 33 dm_block_t block_begin, block_end;
31}; 34};
32 35
33/* 36/*
@@ -59,7 +62,7 @@ void dm_bio_prison_free_cell(struct dm_bio_prison *prison,
59 struct dm_bio_prison_cell *cell); 62 struct dm_bio_prison_cell *cell);
60 63
61/* 64/*
62 * Creates, or retrieves a cell for the given key. 65 * Creates, or retrieves a cell that overlaps the given key.
63 * 66 *
64 * Returns 1 if pre-existing cell returned, zero if new cell created using 67 * Returns 1 if pre-existing cell returned, zero if new cell created using
65 * @cell_prealloc. 68 * @cell_prealloc.
@@ -70,7 +73,8 @@ int dm_get_cell(struct dm_bio_prison *prison,
70 struct dm_bio_prison_cell **cell_result); 73 struct dm_bio_prison_cell **cell_result);
71 74
72/* 75/*
73 * An atomic op that combines retrieving a cell, and adding a bio to it. 76 * An atomic op that combines retrieving or creating a cell, and adding a
77 * bio to it.
74 * 78 *
75 * Returns 1 if the cell was already held, 0 if @inmate is the new holder. 79 * Returns 1 if the cell was already held, 0 if @inmate is the new holder.
76 */ 80 */
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 69de8b43ca12..890e2fff4074 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -436,7 +436,8 @@ static void build_key(dm_oblock_t oblock, struct dm_cell_key *key)
436{ 436{
437 key->virtual = 0; 437 key->virtual = 0;
438 key->dev = 0; 438 key->dev = 0;
439 key->block = from_oblock(oblock); 439 key->block_begin = from_oblock(oblock);
440 key->block_end = key->block_begin + 1ULL;
440} 441}
441 442
442/* 443/*
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index fb05f6a4bbfd..8c5504c0e894 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -115,7 +115,8 @@ static void build_data_key(struct dm_thin_device *td,
115{ 115{
116 key->virtual = 0; 116 key->virtual = 0;
117 key->dev = dm_thin_dev_id(td); 117 key->dev = dm_thin_dev_id(td);
118 key->block = b; 118 key->block_begin = b;
119 key->block_end = b + 1ULL;
119} 120}
120 121
121static void build_virtual_key(struct dm_thin_device *td, dm_block_t b, 122static void build_virtual_key(struct dm_thin_device *td, dm_block_t b,
@@ -123,7 +124,8 @@ static void build_virtual_key(struct dm_thin_device *td, dm_block_t b,
123{ 124{
124 key->virtual = 1; 125 key->virtual = 1;
125 key->dev = dm_thin_dev_id(td); 126 key->dev = dm_thin_dev_id(td);
126 key->block = b; 127 key->block_begin = b;
128 key->block_end = b + 1ULL;
127} 129}
128 130
129/*----------------------------------------------------------------*/ 131/*----------------------------------------------------------------*/