Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Joe Thornber and committed by
Mike Snitzer
5f274d88 f1afb36a

+16 -9
+2 -2
drivers/md/dm-bio-prison.c
··· 95 95 if (lhs->dev > rhs->dev) 96 96 return 1; 97 97 98 - if (lhs->block < rhs->block) 98 + if (lhs->block_end <= rhs->block_begin) 99 99 return -1; 100 100 101 - if (lhs->block > rhs->block) 101 + if (lhs->block_begin >= rhs->block_end) 102 102 return 1; 103 103 104 104 return 0;
+8 -4
drivers/md/dm-bio-prison.h
··· 23 23 */ 24 24 struct 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 + */ 27 30 struct dm_cell_key { 28 31 int virtual; 29 32 dm_thin_id dev; 30 - dm_block_t block; 33 + dm_block_t block_begin, block_end; 31 34 }; 32 35 33 36 /* ··· 62 59 struct dm_bio_prison_cell *cell); 63 60 64 61 /* 65 - * Creates, or retrieves a cell for the given key. 62 + * Creates, or retrieves a cell that overlaps the given key. 66 63 * 67 64 * Returns 1 if pre-existing cell returned, zero if new cell created using 68 65 * @cell_prealloc. ··· 73 70 struct dm_bio_prison_cell **cell_result); 74 71 75 72 /* 76 - * An atomic op that combines retrieving a cell, and adding a bio to it. 73 + * An atomic op that combines retrieving or creating a cell, and adding a 74 + * bio to it. 77 75 * 78 76 * Returns 1 if the cell was already held, 0 if @inmate is the new holder. 79 77 */
+2 -1
drivers/md/dm-cache-target.c
··· 436 436 { 437 437 key->virtual = 0; 438 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 /*
+4 -2
drivers/md/dm-thin.c
··· 115 115 { 116 116 key->virtual = 0; 117 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 121 122 static void build_virtual_key(struct dm_thin_device *td, dm_block_t b, ··· 124 123 { 125 124 key->virtual = 1; 126 125 key->dev = dm_thin_dev_id(td); 127 - key->block = b; 126 + key->block_begin = b; 127 + key->block_end = b + 1ULL; 128 128 } 129 129 130 130 /*----------------------------------------------------------------*/