History

Merge tag 'dm-3.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-dm

Pull dm update from Alasdair G Kergon: "Miscellaneous device-mapper fixes, cleanups and performance improvements. Of particular note: - Disable broken WRITE SAME support in all targets except linear and striped. Use it when kcopyd is zeroing blocks. - Remove several mempools from targets by moving the data into the bio's new front_pad area(which dm calls 'per_bio_data'). - Fix a race in thin provisioning if discards are misused. - Prevent userspace from interfering with the ioctl parameters and use kmalloc for the data buffer if it's small instead of vmalloc. - Throttle some annoying error messages when I/O fails." * tag 'dm-3.8-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-dm: (36 commits) dm stripe: add WRITE SAME support dm: remove map_info dm snapshot: do not use map_context dm thin: dont use map_context dm raid1: dont use map_context dm flakey: dont use map_context dm raid1: rename read_record to bio_record dm: move target request nr to dm_target_io dm snapshot: use per_bio_data dm verity: use per_bio_data dm raid1: use per_bio_data dm: introduce per_bio_data dm kcopyd: add WRITE SAME support to dm_kcopyd_zero dm linear: add WRITE SAME support dm: add WRITE SAME support dm: prepare to support WRITE SAME dm ioctl: use kmalloc if possible dm ioctl: remove PF_MEMALLOC dm persistent data: improve improve space map block alloc failure message dm thin: use DMERR_LIMIT for errors ...

Linus Torvalds committed 13 years ago

Commit b49249d2 parents 10532b5 45e621d30 files · +522 −443Browse files

Unified · Split

30 files
  1. drivers/md/dm-bio-prison.c +0 −25
  2. drivers/md/dm-bio-prison.h +0 −1
  3. drivers/md/dm-crypt.c +2 −3
  4. drivers/md/dm-delay.c +2 −3
  5. drivers/md/dm-flakey.c +13 −8
  6. drivers/md/dm-io.c +18 −5
  7. drivers/md/dm-ioctl.c +43 −21
  8. drivers/md/dm-kcopyd.c +14 −4
  9. drivers/md/dm-linear.c +3 −3
  10. drivers/md/dm-raid.c +5 −3
  11. drivers/md/dm-raid1.c +23 −52
  12. drivers/md/dm-snap.c +34 −56
  13. drivers/md/dm-stripe.c +10 −10
  14. drivers/md/dm-table.c +40 −1
  15. drivers/md/dm-target.c +2 −3
  16. drivers/md/dm-thin-metadata.c +1 −1
  17. drivers/md/dm-thin.c +120 −114
  18. drivers/md/dm-verity.c +5 −20
  19. drivers/md/dm-zero.c +2 −3
  20. drivers/md/dm.c +58 −26
  21. drivers/md/dm.h +1 −1
  22. drivers/md/persistent-data/dm-block-manager.c +7 −5
  23. drivers/md/persistent-data/dm-btree-internal.h +8 −8
  24. drivers/md/persistent-data/dm-btree-remove.c +25 −25
  25. drivers/md/persistent-data/dm-btree-spine.c +10 −10
  26. drivers/md/persistent-data/dm-btree.c +18 −13
  27. drivers/md/persistent-data/dm-space-map-common.c +8 −8
  28. drivers/md/persistent-data/dm-space-map-metadata.c +1 −1
  29. include/linux/device-mapper.h +47 −8
  30. include/uapi/linux/dm-ioctl.h +2 −2
drivers/md/dm-bio-prison.c+0−25
@@ -207,31 +207,6 @@ void dm_cell_release(struct dm_bio_prison_cell *cell, struct bio_list *bios) · 206 unmodified lines
207207 }
208208 EXPORT_SYMBOL_GPL(dm_cell_release);
209209
210−/*
211− * There are a couple of places where we put a bio into a cell briefly
212− * before taking it out again. In these situations we know that no other
213− * bio may be in the cell. This function releases the cell, and also does
214− * a sanity check.
215− */
216−static void __cell_release_singleton(struct dm_bio_prison_cell *cell, struct bio *bio)
217−{
218− BUG_ON(cell->holder != bio);
219− BUG_ON(!bio_list_empty(&cell->bios));
220−
221− __cell_release(cell, NULL);
222−}
223−
224−void dm_cell_release_singleton(struct dm_bio_prison_cell *cell, struct bio *bio)
225−{
226− unsigned long flags;
227− struct dm_bio_prison *prison = cell->prison;
228−
229− spin_lock_irqsave(&prison->lock, flags);
230− __cell_release_singleton(cell, bio);
231− spin_unlock_irqrestore(&prison->lock, flags);
232−}
233−EXPORT_SYMBOL_GPL(dm_cell_release_singleton);
234−
235210 /*
236211 * Sometimes we don't want the holder, just the additional bios.
237212 */
drivers/md/dm-bio-prison.h+0−1
@@ -44,7 +44,6 @@ int dm_bio_detain(struct dm_bio_prison *prison, struct dm_cell_key *key, · 43 unmodified lines
4444 struct bio *inmate, struct dm_bio_prison_cell **ref);
4545
4646 void dm_cell_release(struct dm_bio_prison_cell *cell, struct bio_list *bios);
47−void dm_cell_release_singleton(struct dm_bio_prison_cell *cell, struct bio *bio); // FIXME: bio arg not needed
4847 void dm_cell_release_no_holder(struct dm_bio_prison_cell *cell, struct bio_list *inmates);
4948 void dm_cell_error(struct dm_bio_prison_cell *cell);
5049
drivers/md/dm-crypt.c+2−3
@@ -1689,8 +1689,7 @@ bad: · 1688 unmodified lines
16891689 return ret;
16901690 }
16911691
1692−static int crypt_map(struct dm_target *ti, struct bio *bio,
1693− union map_info *map_context)
1692+static int crypt_map(struct dm_target *ti, struct bio *bio)
16941693 {
16951694 struct dm_crypt_io *io;
16961695 struct crypt_config *cc = ti->private;
@@ -1846,7 +1845,7 @@ static int crypt_iterate_devices(struct dm_target *ti, · 149 unmodified lines
18461845
18471846 static struct target_type crypt_target = {
18481847 .name = "crypt",
1849− .version = {1, 11, 0},
1848+ .version = {1, 12, 0},
18501849 .module = THIS_MODULE,
18511850 .ctr = crypt_ctr,
18521851 .dtr = crypt_dtr,
drivers/md/dm-delay.c+2−3
@@ -274,8 +274,7 @@ static void delay_resume(struct dm_target *ti) · 273 unmodified lines
274274 atomic_set(&dc->may_delay, 1);
275275 }
276276
277−static int delay_map(struct dm_target *ti, struct bio *bio,
278− union map_info *map_context)
277+static int delay_map(struct dm_target *ti, struct bio *bio)
279278 {
280279 struct delay_c *dc = ti->private;
281280
@@ -338,7 +337,7 @@ out: · 56 unmodified lines
338337
339338 static struct target_type delay_target = {
340339 .name = "delay",
341− .version = {1, 1, 0},
340+ .version = {1, 2, 0},
342341 .module = THIS_MODULE,
343342 .ctr = delay_ctr,
344343 .dtr = delay_dtr,
drivers/md/dm-flakey.c+13−8
@@ -39,6 +39,10 @@ enum feature_flag_bits { · 38 unmodified lines
3939 DROP_WRITES
4040 };
4141
42+struct per_bio_data {
43+ bool bio_submitted;
44+};
45+
4246 static int parse_features(struct dm_arg_set *as, struct flakey_c *fc,
4347 struct dm_target *ti)
4448 {
@@ -214,6 +218,7 @@ static int flakey_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 169 unmodified lines
214218
215219 ti->num_flush_requests = 1;
216220 ti->num_discard_requests = 1;
221+ ti->per_bio_data_size = sizeof(struct per_bio_data);
217222 ti->private = fc;
218223 return 0;
219224
@@ -265,11 +270,12 @@ static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) · 45 unmodified lines
265270 }
266271 }
267272
268−static int flakey_map(struct dm_target *ti, struct bio *bio,
269− union map_info *map_context)
273+static int flakey_map(struct dm_target *ti, struct bio *bio)
270274 {
271275 struct flakey_c *fc = ti->private;
272276 unsigned elapsed;
277+ struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
278+ pb->bio_submitted = false;
273279
274280 /* Are we alive ? */
275281 elapsed = (jiffies - fc->start_time) / HZ;
@@ -277,7 +283,7 @@ static int flakey_map(struct dm_target *ti, struct bio *bio, · 1 unmodified line
277283 /*
278284 * Flag this bio as submitted while down.
279285 */
280− map_context->ll = 1;
286+ pb->bio_submitted = true;
281287
282288 /*
283289 * Map reads as normal.
@@ -314,17 +320,16 @@ map_bio: · 30 unmodified lines
314320 return DM_MAPIO_REMAPPED;
315321 }
316322
317−static int flakey_end_io(struct dm_target *ti, struct bio *bio,
318− int error, union map_info *map_context)
323+static int flakey_end_io(struct dm_target *ti, struct bio *bio, int error)
319324 {
320325 struct flakey_c *fc = ti->private;
321− unsigned bio_submitted_while_down = map_context->ll;
326+ struct per_bio_data *pb = dm_per_bio_data(bio, sizeof(struct per_bio_data));
322327
323328 /*
324329 * Corrupt successful READs while in down state.
325330 * If flags were specified, only corrupt those that match.
326331 */
327− if (fc->corrupt_bio_byte && !error && bio_submitted_while_down &&
332+ if (fc->corrupt_bio_byte && !error && pb->bio_submitted &&
328333 (bio_data_dir(bio) == READ) && (fc->corrupt_bio_rw == READ) &&
329334 all_corrupt_bio_flags_match(bio, fc))
330335 corrupt_bio_data(bio, fc);
@@ -406,7 +411,7 @@ static int flakey_iterate_devices(struct dm_target *ti, iterate_devices_callout_ · 75 unmodified lines
406411
407412 static struct target_type flakey_target = {
408413 .name = "flakey",
409− .version = {1, 2, 0},
414+ .version = {1, 3, 0},
410415 .module = THIS_MODULE,
411416 .ctr = flakey_ctr,
412417 .dtr = flakey_dtr,
drivers/md/dm-io.c+18−5
@@ -287,7 +287,8 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where, · 286 unmodified lines
287287 unsigned num_bvecs;
288288 sector_t remaining = where->count;
289289 struct request_queue *q = bdev_get_queue(where->bdev);
290− sector_t discard_sectors;
290+ unsigned short logical_block_size = queue_logical_block_size(q);
291+ sector_t num_sectors;
291292
292293 /*
293294 * where->count may be zero if rw holds a flush and we need to
@@ -297,7 +298,7 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where, · 3 unmodified lines
297298 /*
298299 * Allocate a suitably sized-bio.
299300 */
300− if (rw & REQ_DISCARD)
301+ if ((rw & REQ_DISCARD) || (rw & REQ_WRITE_SAME))
301302 num_bvecs = 1;
302303 else
303304 num_bvecs = min_t(int, bio_get_nr_vecs(where->bdev),
@@ -310,9 +311,21 @@ static void do_region(int rw, unsigned region, struct dm_io_region *where, · 6 unmodified lines
310311 store_io_and_region_in_bio(bio, io, region);
311312
312313 if (rw & REQ_DISCARD) {
313− discard_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
314− bio->bi_size = discard_sectors << SECTOR_SHIFT;
315− remaining -= discard_sectors;
314+ num_sectors = min_t(sector_t, q->limits.max_discard_sectors, remaining);
315+ bio->bi_size = num_sectors << SECTOR_SHIFT;
316+ remaining -= num_sectors;
317+ } else if (rw & REQ_WRITE_SAME) {
318+ /*
319+ * WRITE SAME only uses a single page.
320+ */
321+ dp->get_page(dp, &page, &len, &offset);
322+ bio_add_page(bio, page, logical_block_size, offset);
323+ num_sectors = min_t(sector_t, q->limits.max_write_same_sectors, remaining);
324+ bio->bi_size = num_sectors << SECTOR_SHIFT;
325+
326+ offset = 0;
327+ remaining -= num_sectors;
328+ dp->next_page(dp);
316329 } else while (remaining) {
317330 /*
318331 * Try and add as many pages as possible.
drivers/md/dm-ioctl.c+43−21
@@ -1543,7 +1543,21 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user) · 1542 unmodified lines
15431543 return r;
15441544 }
15451545
1546−static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
1546+#define DM_PARAMS_VMALLOC 0x0001 /* Params alloced with vmalloc not kmalloc */
1547+#define DM_WIPE_BUFFER 0x0010 /* Wipe input buffer before returning from ioctl */
1548+
1549+static void free_params(struct dm_ioctl *param, size_t param_size, int param_flags)
1550+{
1551+ if (param_flags & DM_WIPE_BUFFER)
1552+ memset(param, 0, param_size);
1553+
1554+ if (param_flags & DM_PARAMS_VMALLOC)
1555+ vfree(param);
1556+ else
1557+ kfree(param);
1558+}
1559+
1560+static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param, int *param_flags)
15471561 {
15481562 struct dm_ioctl tmp, *dmi;
15491563 int secure_data;
@@ -1556,7 +1570,21 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) · 6 unmodified lines
15561570
15571571 secure_data = tmp.flags & DM_SECURE_DATA_FLAG;
15581572
1559− dmi = vmalloc(tmp.data_size);
1573+ *param_flags = secure_data ? DM_WIPE_BUFFER : 0;
1574+
1575+ /*
1576+ * Try to avoid low memory issues when a device is suspended.
1577+ * Use kmalloc() rather than vmalloc() when we can.
1578+ */
1579+ dmi = NULL;
1580+ if (tmp.data_size <= KMALLOC_MAX_SIZE)
1581+ dmi = kmalloc(tmp.data_size, GFP_NOIO | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN);
1582+
1583+ if (!dmi) {
1584+ dmi = __vmalloc(tmp.data_size, GFP_NOIO | __GFP_REPEAT | __GFP_HIGH, PAGE_KERNEL);
1585+ *param_flags |= DM_PARAMS_VMALLOC;
1586+ }
1587+
15601588 if (!dmi) {
15611589 if (secure_data && clear_user(user, tmp.data_size))
15621590 return -EFAULT;
@@ -1566,6 +1594,14 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) · 3 unmodified lines
15661594 if (copy_from_user(dmi, user, tmp.data_size))
15671595 goto bad;
15681596
1597+ /*
1598+ * Abort if something changed the ioctl data while it was being copied.
1599+ */
1600+ if (dmi->data_size != tmp.data_size) {
1601+ DMERR("rejecting ioctl: data size modified while processing parameters");
1602+ goto bad;
1603+ }
1604+
15691605 /* Wipe the user buffer so we do not return it to userspace */
15701606 if (secure_data && clear_user(user, tmp.data_size))
15711607 goto bad;
@@ -1574,9 +1610,8 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) · 2 unmodified lines
15741610 return 0;
15751611
15761612 bad:
1577− if (secure_data)
1578− memset(dmi, 0, tmp.data_size);
1579− vfree(dmi);
1613+ free_params(dmi, tmp.data_size, *param_flags);
1614+
15801615 return -EFAULT;
15811616 }
15821617
@@ -1613,7 +1648,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param) · 30 unmodified lines
16131648 static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
16141649 {
16151650 int r = 0;
1616− int wipe_buffer;
1651+ int param_flags;
16171652 unsigned int cmd;
16181653 struct dm_ioctl *uninitialized_var(param);
16191654 ioctl_fn fn = NULL;
@@ -1648,25 +1683,15 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) · 28 unmodified lines
16481683 return -ENOTTY;
16491684 }
16501685
1651− /*
1652− * Trying to avoid low memory issues when a device is
1653− * suspended.
1654− */
1655− current->flags |= PF_MEMALLOC;
1656−
16571686 /*
16581687 * Copy the parameters into kernel space.
16591688 */
1660− r = copy_params(user, &param);
1661−
1662− current->flags &= ~PF_MEMALLOC;
1689+ r = copy_params(user, &param, &param_flags);
16631690
16641691 if (r)
16651692 return r;
16661693
16671694 input_param_size = param->data_size;
1668− wipe_buffer = param->flags & DM_SECURE_DATA_FLAG;
1669−
16701695 r = validate_params(cmd, param);
16711696 if (r)
16721697 goto out;
@@ -1681,10 +1706,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) · 8 unmodified lines
16811706 r = -EFAULT;
16821707
16831708 out:
1684− if (wipe_buffer)
1685− memset(param, 0, input_param_size);
1686−
1687− vfree(param);
1709+ free_params(param, input_param_size, param_flags);
16881710 return r;
16891711 }
16901712
drivers/md/dm-kcopyd.c+14−4
@@ -349,7 +349,7 @@ static void complete_io(unsigned long error, void *context) · 348 unmodified lines
349349 struct dm_kcopyd_client *kc = job->kc;
350350
351351 if (error) {
352− if (job->rw == WRITE)
352+ if (job->rw & WRITE)
353353 job->write_err |= error;
354354 else
355355 job->read_err = 1;
@@ -361,7 +361,7 @@ static void complete_io(unsigned long error, void *context) · 5 unmodified lines
361361 }
362362 }
363363
364− if (job->rw == WRITE)
364+ if (job->rw & WRITE)
365365 push(&kc->complete_jobs, job);
366366
367367 else {
@@ -432,7 +432,7 @@ static int process_jobs(struct list_head *jobs, struct dm_kcopyd_client *kc, · 64 unmodified lines
432432
433433 if (r < 0) {
434434 /* error this rogue job */
435− if (job->rw == WRITE)
435+ if (job->rw & WRITE)
436436 job->write_err = (unsigned long) -1L;
437437 else
438438 job->read_err = 1;
@@ -585,6 +585,7 @@ int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, · 146 unmodified lines
585585 unsigned int flags, dm_kcopyd_notify_fn fn, void *context)
586586 {
587587 struct kcopyd_job *job;
588+ int i;
588589
589590 /*
590591 * Allocate an array of jobs consisting of one master job
@@ -611,7 +612,16 @@ int dm_kcopyd_copy(struct dm_kcopyd_client *kc, struct dm_io_region *from, · 20 unmodified lines
611612 memset(&job->source, 0, sizeof job->source);
612613 job->source.count = job->dests[0].count;
613614 job->pages = &zero_page_list;
614− job->rw = WRITE;
615+
616+ /*
617+ * Use WRITE SAME to optimize zeroing if all dests support it.
618+ */
619+ job->rw = WRITE | REQ_WRITE_SAME;
620+ for (i = 0; i < job->num_dests; i++)
621+ if (!bdev_write_same(job->dests[i].bdev)) {
622+ job->rw = WRITE;
623+ break;
624+ }
615625 }
616626
617627 job->fn = fn;
drivers/md/dm-linear.c+3−3
@@ -55,6 +55,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 54 unmodified lines
5555
5656 ti->num_flush_requests = 1;
5757 ti->num_discard_requests = 1;
58+ ti->num_write_same_requests = 1;
5859 ti->private = lc;
5960 return 0;
6061
@@ -87,8 +88,7 @@ static void linear_map_bio(struct dm_target *ti, struct bio *bio) · 26 unmodified lines
8788 bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
8889 }
8990
90−static int linear_map(struct dm_target *ti, struct bio *bio,
91− union map_info *map_context)
91+static int linear_map(struct dm_target *ti, struct bio *bio)
9292 {
9393 linear_map_bio(ti, bio);
9494
@@ -155,7 +155,7 @@ static int linear_iterate_devices(struct dm_target *ti, · 60 unmodified lines
155155
156156 static struct target_type linear_target = {
157157 .name = "linear",
158− .version = {1, 1, 0},
158+ .version = {1, 2, 0},
159159 .module = THIS_MODULE,
160160 .ctr = linear_ctr,
161161 .dtr = linear_dtr,
drivers/md/dm-raid.c+5−3
@@ -295,9 +295,11 @@ static int validate_region_size(struct raid_set *rs, unsigned long region_size) · 294 unmodified lines
295295 * Choose a reasonable default. All figures in sectors.
296296 */
297297 if (min_region_size > (1 << 13)) {
298+ /* If not a power of 2, make it the next power of 2 */
299+ if (min_region_size & (min_region_size - 1))
300+ region_size = 1 << fls(region_size);
298301 DMINFO("Choosing default region size of %lu sectors",
299302 region_size);
300− region_size = min_region_size;
301303 } else {
302304 DMINFO("Choosing default region size of 4MiB");
303305 region_size = 1 << 13; /* sectors */
@@ -1216,7 +1218,7 @@ static void raid_dtr(struct dm_target *ti) · 912 unmodified lines
12161218 context_free(rs);
12171219 }
12181220
1219−static int raid_map(struct dm_target *ti, struct bio *bio, union map_info *map_context)
1221+static int raid_map(struct dm_target *ti, struct bio *bio)
12201222 {
12211223 struct raid_set *rs = ti->private;
12221224 struct mddev *mddev = &rs->md;
@@ -1430,7 +1432,7 @@ static void raid_resume(struct dm_target *ti) · 207 unmodified lines
14301432
14311433 static struct target_type raid_target = {
14321434 .name = "raid",
1433− .version = {1, 3, 1},
1435+ .version = {1, 4, 0},
14341436 .module = THIS_MODULE,
14351437 .ctr = raid_ctr,
14361438 .dtr = raid_dtr,
drivers/md/dm-raid1.c+23−52
@@ -61,7 +61,6 @@ struct mirror_set { · 60 unmodified lines
6161 struct dm_region_hash *rh;
6262 struct dm_kcopyd_client *kcopyd_client;
6363 struct dm_io_client *io_client;
64− mempool_t *read_record_pool;
6564
6665 /* recovery */
6766 region_t nr_regions;
@@ -139,14 +138,13 @@ static void dispatch_bios(void *context, struct bio_list *bio_list) · 71 unmodified lines
139138 queue_bio(ms, bio, WRITE);
140139 }
141140
142−#define MIN_READ_RECORDS 20
143−struct dm_raid1_read_record {
141+struct dm_raid1_bio_record {
144142 struct mirror *m;
143+ /* if details->bi_bdev == NULL, details were not saved */
145144 struct dm_bio_details details;
145+ region_t write_region;
146146 };
147147
148−static struct kmem_cache *_dm_raid1_read_record_cache;
149−
150148 /*
151149 * Every mirror should look like this one.
152150 */
@@ -876,19 +874,9 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, · 723 unmodified lines
876874 atomic_set(&ms->suspend, 0);
877875 atomic_set(&ms->default_mirror, DEFAULT_MIRROR);
878876
879− ms->read_record_pool = mempool_create_slab_pool(MIN_READ_RECORDS,
880− _dm_raid1_read_record_cache);
881−
882− if (!ms->read_record_pool) {
883− ti->error = "Error creating mirror read_record_pool";
884− kfree(ms);
885− return NULL;
886− }
887−
888877 ms->io_client = dm_io_client_create();
889878 if (IS_ERR(ms->io_client)) {
890879 ti->error = "Error creating dm_io client";
891− mempool_destroy(ms->read_record_pool);
892880 kfree(ms);
893881 return NULL;
894882 }
@@ -900,7 +888,6 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors, · 5 unmodified lines
900888 if (IS_ERR(ms->rh)) {
901889 ti->error = "Error creating dirty region hash";
902890 dm_io_client_destroy(ms->io_client);
903− mempool_destroy(ms->read_record_pool);
904891 kfree(ms);
905892 return NULL;
906893 }
@@ -916,7 +903,6 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, · 9 unmodified lines
916903
917904 dm_io_client_destroy(ms->io_client);
918905 dm_region_hash_destroy(ms->rh);
919− mempool_destroy(ms->read_record_pool);
920906 kfree(ms);
921907 }
922908
@@ -1088,6 +1074,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 165 unmodified lines
10881074
10891075 ti->num_flush_requests = 1;
10901076 ti->num_discard_requests = 1;
1077+ ti->per_bio_data_size = sizeof(struct dm_raid1_bio_record);
10911078 ti->discard_zeroes_data_unsupported = true;
10921079
10931080 ms->kmirrord_wq = alloc_workqueue("kmirrord",
@@ -1155,18 +1142,20 @@ static void mirror_dtr(struct dm_target *ti) · 61 unmodified lines
11551142 /*
11561143 * Mirror mapping function
11571144 */
1158−static int mirror_map(struct dm_target *ti, struct bio *bio,
1159− union map_info *map_context)
1145+static int mirror_map(struct dm_target *ti, struct bio *bio)
11601146 {
11611147 int r, rw = bio_rw(bio);
11621148 struct mirror *m;
11631149 struct mirror_set *ms = ti->private;
1164− struct dm_raid1_read_record *read_record = NULL;
11651150 struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh);
1151+ struct dm_raid1_bio_record *bio_record =
1152+ dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
1153+
1154+ bio_record->details.bi_bdev = NULL;
11661155
11671156 if (rw == WRITE) {
11681157 /* Save region for mirror_end_io() handler */
1169− map_context->ll = dm_rh_bio_to_region(ms->rh, bio);
1158+ bio_record->write_region = dm_rh_bio_to_region(ms->rh, bio);
11701159 queue_bio(ms, bio, rw);
11711160 return DM_MAPIO_SUBMITTED;
11721161 }
@@ -1194,33 +1183,29 @@ static int mirror_map(struct dm_target *ti, struct bio *bio, · 21 unmodified lines
11941183 if (unlikely(!m))
11951184 return -EIO;
11961185
1197− read_record = mempool_alloc(ms->read_record_pool, GFP_NOIO);
1198− if (likely(read_record)) {
1199− dm_bio_record(&read_record->details, bio);
1200− map_context->ptr = read_record;
1201− read_record->m = m;
1202− }
1186+ dm_bio_record(&bio_record->details, bio);
1187+ bio_record->m = m;
12031188
12041189 map_bio(m, bio);
12051190
12061191 return DM_MAPIO_REMAPPED;
12071192 }
12081193
1209−static int mirror_end_io(struct dm_target *ti, struct bio *bio,
1210− int error, union map_info *map_context)
1194+static int mirror_end_io(struct dm_target *ti, struct bio *bio, int error)
12111195 {
12121196 int rw = bio_rw(bio);
12131197 struct mirror_set *ms = (struct mirror_set *) ti->private;
12141198 struct mirror *m = NULL;
12151199 struct dm_bio_details *bd = NULL;
1216− struct dm_raid1_read_record *read_record = map_context->ptr;
1200+ struct dm_raid1_bio_record *bio_record =
1201+ dm_per_bio_data(bio, sizeof(struct dm_raid1_bio_record));
12171202
12181203 /*
12191204 * We need to dec pending if this was a write.
12201205 */
12211206 if (rw == WRITE) {
12221207 if (!(bio->bi_rw & (REQ_FLUSH | REQ_DISCARD)))
1223− dm_rh_dec(ms->rh, map_context->ll);
1208+ dm_rh_dec(ms->rh, bio_record->write_region);
12241209 return error;
12251210 }
12261211
@@ -1231,7 +1216,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, · 4 unmodified lines
12311216 goto out;
12321217
12331218 if (unlikely(error)) {
1234− if (!read_record) {
1219+ if (!bio_record->details.bi_bdev) {
12351220 /*
12361221 * There wasn't enough memory to record necessary
12371222 * information for a retry or there was no other
@@ -1241,7 +1226,7 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, · 3 unmodified lines
12411226 return -EIO;
12421227 }
12431228
1244− m = read_record->m;
1229+ m = bio_record->m;
12451230
12461231 DMERR("Mirror read failed from %s. Trying alternative device.",
12471232 m->dev->name);
@@ -1253,22 +1238,18 @@ static int mirror_end_io(struct dm_target *ti, struct bio *bio, · 5 unmodified lines
12531238 * mirror.
12541239 */
12551240 if (default_ok(m) || mirror_available(ms, bio)) {
1256− bd = &read_record->details;
1241+ bd = &bio_record->details;
12571242
12581243 dm_bio_restore(bd, bio);
1259− mempool_free(read_record, ms->read_record_pool);
1260− map_context->ptr = NULL;
1244+ bio_record->details.bi_bdev = NULL;
12611245 queue_bio(ms, bio, rw);
1262− return 1;
1246+ return DM_ENDIO_INCOMPLETE;
12631247 }
12641248 DMERR("All replicated volumes dead, failing I/O");
12651249 }
12661250
12671251 out:
1268− if (read_record) {
1269− mempool_free(read_record, ms->read_record_pool);
1270− map_context->ptr = NULL;
1271− }
1252+ bio_record->details.bi_bdev = NULL;
12721253
12731254 return error;
12741255 }
@@ -1422,7 +1403,7 @@ static int mirror_iterate_devices(struct dm_target *ti, · 147 unmodified lines
14221403
14231404 static struct target_type mirror_target = {
14241405 .name = "mirror",
1425− .version = {1, 12, 1},
1406+ .version = {1, 13, 1},
14261407 .module = THIS_MODULE,
14271408 .ctr = mirror_ctr,
14281409 .dtr = mirror_dtr,
@@ -1439,13 +1420,6 @@ static int __init dm_mirror_init(void) · 10 unmodified lines
14391420 {
14401421 int r;
14411422
1442− _dm_raid1_read_record_cache = KMEM_CACHE(dm_raid1_read_record, 0);
1443− if (!_dm_raid1_read_record_cache) {
1444− DMERR("Can't allocate dm_raid1_read_record cache");
1445− r = -ENOMEM;
1446− goto bad_cache;
1447− }
1448−
14491423 r = dm_register_target(&mirror_target);
14501424 if (r < 0) {
14511425 DMERR("Failed to register mirror target");
@@ -1455,15 +1429,12 @@ static int __init dm_mirror_init(void) · 3 unmodified lines
14551429 return 0;
14561430
14571431 bad_target:
1458− kmem_cache_destroy(_dm_raid1_read_record_cache);
1459−bad_cache:
14601432 return r;
14611433 }
14621434
14631435 static void __exit dm_mirror_exit(void)
14641436 {
14651437 dm_unregister_target(&mirror_target);
1466− kmem_cache_destroy(_dm_raid1_read_record_cache);
14671438 }
14681439
14691440 /* Module hooks */
drivers/md/dm-snap.c+34−56
@@ -79,7 +79,6 @@ struct dm_snapshot { · 78 unmodified lines
7979
8080 /* Chunks with outstanding reads */
8181 spinlock_t tracked_chunk_lock;
82− mempool_t *tracked_chunk_pool;
8382 struct hlist_head tracked_chunk_hash[DM_TRACKED_CHUNK_HASH_SIZE];
8483
8584 /* The on disk metadata handler */
@@ -191,35 +190,38 @@ struct dm_snap_tracked_chunk { · 105 unmodified lines
191190 chunk_t chunk;
192191 };
193192
194−static struct kmem_cache *tracked_chunk_cache;
193+static void init_tracked_chunk(struct bio *bio)
194+{
195+ struct dm_snap_tracked_chunk *c = dm_per_bio_data(bio, sizeof(struct dm_snap_tracked_chunk));
196+ INIT_HLIST_NODE(&c->node);
197+}
195198
196−static struct dm_snap_tracked_chunk *track_chunk(struct dm_snapshot *s,
197− chunk_t chunk)
199+static bool is_bio_tracked(struct bio *bio)
198200 {
199− struct dm_snap_tracked_chunk *c = mempool_alloc(s->tracked_chunk_pool,
200− GFP_NOIO);
201− unsigned long flags;
201+ struct dm_snap_tracked_chunk *c = dm_per_bio_data(bio, sizeof(struct dm_snap_tracked_chunk));
202+ return !hlist_unhashed(&c->node);
203+}
204+
205+static void track_chunk(struct dm_snapshot *s, struct bio *bio, chunk_t chunk)
206+{
207+ struct dm_snap_tracked_chunk *c = dm_per_bio_data(bio, sizeof(struct dm_snap_tracked_chunk));
202208
203209 c->chunk = chunk;
204210
205− spin_lock_irqsave(&s->tracked_chunk_lock, flags);
211+ spin_lock_irq(&s->tracked_chunk_lock);
206212 hlist_add_head(&c->node,
207213 &s->tracked_chunk_hash[DM_TRACKED_CHUNK_HASH(chunk)]);
208− spin_unlock_irqrestore(&s->tracked_chunk_lock, flags);
209−
210− return c;
214+ spin_unlock_irq(&s->tracked_chunk_lock);
211215 }
212216
213−static void stop_tracking_chunk(struct dm_snapshot *s,
214− struct dm_snap_tracked_chunk *c)
217+static void stop_tracking_chunk(struct dm_snapshot *s, struct bio *bio)
215218 {
219+ struct dm_snap_tracked_chunk *c = dm_per_bio_data(bio, sizeof(struct dm_snap_tracked_chunk));
216220 unsigned long flags;
217221
218222 spin_lock_irqsave(&s->tracked_chunk_lock, flags);
219223 hlist_del(&c->node);
220224 spin_unlock_irqrestore(&s->tracked_chunk_lock, flags);
221−
222− mempool_free(c, s->tracked_chunk_pool);
223225 }
224226
225227 static int __chunk_is_tracked(struct dm_snapshot *s, chunk_t chunk)
@@ -1120,14 +1122,6 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 894 unmodified lines
11201122 goto bad_pending_pool;
11211123 }
11221124
1123− s->tracked_chunk_pool = mempool_create_slab_pool(MIN_IOS,
1124− tracked_chunk_cache);
1125− if (!s->tracked_chunk_pool) {
1126− ti->error = "Could not allocate tracked_chunk mempool for "
1127− "tracking reads";
1128− goto bad_tracked_chunk_pool;
1129− }
1130−
11311125 for (i = 0; i < DM_TRACKED_CHUNK_HASH_SIZE; i++)
11321126 INIT_HLIST_HEAD(&s->tracked_chunk_hash[i]);
11331127
@@ -1135,6 +1129,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 1 unmodified line
11351129
11361130 ti->private = s;
11371131 ti->num_flush_requests = num_flush_requests;
1132+ ti->per_bio_data_size = sizeof(struct dm_snap_tracked_chunk);
11381133
11391134 /* Add snapshot to the list of snapshots for this origin */
11401135 /* Exceptions aren't triggered till snapshot_resume() is called */
@@ -1183,9 +1178,6 @@ bad_read_metadata: · 42 unmodified lines
11831178 unregister_snapshot(s);
11841179
11851180 bad_load_and_register:
1186− mempool_destroy(s->tracked_chunk_pool);
1187−
1188−bad_tracked_chunk_pool:
11891181 mempool_destroy(s->pending_pool);
11901182
11911183 bad_pending_pool:
@@ -1290,8 +1282,6 @@ static void snapshot_dtr(struct dm_target *ti) · 98 unmodified lines
12901282 BUG_ON(!hlist_empty(&s->tracked_chunk_hash[i]));
12911283 #endif
12921284
1293− mempool_destroy(s->tracked_chunk_pool);
1294−
12951285 __free_exceptions(s);
12961286
12971287 mempool_destroy(s->pending_pool);
@@ -1577,8 +1567,7 @@ static void remap_exception(struct dm_snapshot *s, struct dm_exception *e, · 279 unmodified lines
15771567 s->store->chunk_mask);
15781568 }
15791569
1580−static int snapshot_map(struct dm_target *ti, struct bio *bio,
1581− union map_info *map_context)
1570+static int snapshot_map(struct dm_target *ti, struct bio *bio)
15821571 {
15831572 struct dm_exception *e;
15841573 struct dm_snapshot *s = ti->private;
@@ -1586,6 +1575,8 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, · 1 unmodified line
15861575 chunk_t chunk;
15871576 struct dm_snap_pending_exception *pe = NULL;
15881577
1578+ init_tracked_chunk(bio);
1579+
15891580 if (bio->bi_rw & REQ_FLUSH) {
15901581 bio->bi_bdev = s->cow->bdev;
15911582 return DM_MAPIO_REMAPPED;
@@ -1670,7 +1661,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio, · 78 unmodified lines
16701661 }
16711662 } else {
16721663 bio->bi_bdev = s->origin->bdev;
1673− map_context->ptr = track_chunk(s, chunk);
1664+ track_chunk(s, bio, chunk);
16741665 }
16751666
16761667 out_unlock:
@@ -1691,20 +1682,20 @@ out: · 14 unmodified lines
16911682 * If merging is currently taking place on the chunk in question, the
16921683 * I/O is deferred by adding it to s->bios_queued_during_merge.
16931684 */
1694−static int snapshot_merge_map(struct dm_target *ti, struct bio *bio,
1695− union map_info *map_context)
1685+static int snapshot_merge_map(struct dm_target *ti, struct bio *bio)
16961686 {
16971687 struct dm_exception *e;
16981688 struct dm_snapshot *s = ti->private;
16991689 int r = DM_MAPIO_REMAPPED;
17001690 chunk_t chunk;
17011691
1692+ init_tracked_chunk(bio);
1693+
17021694 if (bio->bi_rw & REQ_FLUSH) {
1703− if (!map_context->target_request_nr)
1695+ if (!dm_bio_get_target_request_nr(bio))
17041696 bio->bi_bdev = s->origin->bdev;
17051697 else
17061698 bio->bi_bdev = s->cow->bdev;
1707− map_context->ptr = NULL;
17081699 return DM_MAPIO_REMAPPED;
17091700 }
17101701
@@ -1733,7 +1724,7 @@ static int snapshot_merge_map(struct dm_target *ti, struct bio *bio, · 22 unmodified lines
17331724 remap_exception(s, e, bio, chunk);
17341725
17351726 if (bio_rw(bio) == WRITE)
1736− map_context->ptr = track_chunk(s, chunk);
1727+ track_chunk(s, bio, chunk);
17371728 goto out_unlock;
17381729 }
17391730
@@ -1751,14 +1742,12 @@ out_unlock: · 11 unmodified lines
17511742 return r;
17521743 }
17531744
1754−static int snapshot_end_io(struct dm_target *ti, struct bio *bio,
1755− int error, union map_info *map_context)
1745+static int snapshot_end_io(struct dm_target *ti, struct bio *bio, int error)
17561746 {
17571747 struct dm_snapshot *s = ti->private;
1758− struct dm_snap_tracked_chunk *c = map_context->ptr;
17591748
1760− if (c)
1761− stop_tracking_chunk(s, c);
1749+ if (is_bio_tracked(bio))
1750+ stop_tracking_chunk(s, bio);
17621751
17631752 return 0;
17641753 }
@@ -2127,8 +2116,7 @@ static void origin_dtr(struct dm_target *ti) · 362 unmodified lines
21272116 dm_put_device(ti, dev);
21282117 }
21292118
2130−static int origin_map(struct dm_target *ti, struct bio *bio,
2131− union map_info *map_context)
2119+static int origin_map(struct dm_target *ti, struct bio *bio)
21322120 {
21332121 struct dm_dev *dev = ti->private;
21342122 bio->bi_bdev = dev->bdev;
@@ -2193,7 +2181,7 @@ static int origin_iterate_devices(struct dm_target *ti, · 58 unmodified lines
21932181
21942182 static struct target_type origin_target = {
21952183 .name = "snapshot-origin",
2196− .version = {1, 7, 1},
2184+ .version = {1, 8, 0},
21972185 .module = THIS_MODULE,
21982186 .ctr = origin_ctr,
21992187 .dtr = origin_dtr,
@@ -2206,7 +2194,7 @@ static struct target_type origin_target = { · 6 unmodified lines
22062194
22072195 static struct target_type snapshot_target = {
22082196 .name = "snapshot",
2209− .version = {1, 10, 0},
2197+ .version = {1, 11, 0},
22102198 .module = THIS_MODULE,
22112199 .ctr = snapshot_ctr,
22122200 .dtr = snapshot_dtr,
@@ -2220,7 +2208,7 @@ static struct target_type snapshot_target = { · 7 unmodified lines
22202208
22212209 static struct target_type merge_target = {
22222210 .name = dm_snapshot_merge_target_name,
2223− .version = {1, 1, 0},
2211+ .version = {1, 2, 0},
22242212 .module = THIS_MODULE,
22252213 .ctr = snapshot_ctr,
22262214 .dtr = snapshot_dtr,
@@ -2281,17 +2269,8 @@ static int __init dm_snapshot_init(void) · 54 unmodified lines
22812269 goto bad_pending_cache;
22822270 }
22832271
2284− tracked_chunk_cache = KMEM_CACHE(dm_snap_tracked_chunk, 0);
2285− if (!tracked_chunk_cache) {
2286− DMERR("Couldn't create cache to track chunks in use.");
2287− r = -ENOMEM;
2288− goto bad_tracked_chunk_cache;
2289− }
2290−
22912272 return 0;
22922273
2293−bad_tracked_chunk_cache:
2294− kmem_cache_destroy(pending_cache);
22952274 bad_pending_cache:
22962275 kmem_cache_destroy(exception_cache);
22972276 bad_exception_cache:
@@ -2317,7 +2296,6 @@ static void __exit dm_snapshot_exit(void) · 19 unmodified lines
23172296 exit_origin_hash();
23182297 kmem_cache_destroy(pending_cache);
23192298 kmem_cache_destroy(exception_cache);
2320− kmem_cache_destroy(tracked_chunk_cache);
23212299
23222300 dm_exception_store_exit();
23232301 }
drivers/md/dm-stripe.c+10−10
@@ -162,6 +162,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 161 unmodified lines
162162
163163 ti->num_flush_requests = stripes;
164164 ti->num_discard_requests = stripes;
165+ ti->num_write_same_requests = stripes;
165166
166167 sc->chunk_size = chunk_size;
167168 if (chunk_size & (chunk_size - 1))
@@ -251,8 +252,8 @@ static void stripe_map_range_sector(struct stripe_c *sc, sector_t sector, · 83 unmodified lines
251252 *result += sc->chunk_size; /* next chunk */
252253 }
253254
254−static int stripe_map_discard(struct stripe_c *sc, struct bio *bio,
255− uint32_t target_stripe)
255+static int stripe_map_range(struct stripe_c *sc, struct bio *bio,
256+ uint32_t target_stripe)
256257 {
257258 sector_t begin, end;
258259
@@ -271,23 +272,23 @@ static int stripe_map_discard(struct stripe_c *sc, struct bio *bio, · 12 unmodified lines
271272 }
272273 }
273274
274−static int stripe_map(struct dm_target *ti, struct bio *bio,
275− union map_info *map_context)
275+static int stripe_map(struct dm_target *ti, struct bio *bio)
276276 {
277277 struct stripe_c *sc = ti->private;
278278 uint32_t stripe;
279279 unsigned target_request_nr;
280280
281281 if (bio->bi_rw & REQ_FLUSH) {
282− target_request_nr = map_context->target_request_nr;
282+ target_request_nr = dm_bio_get_target_request_nr(bio);
283283 BUG_ON(target_request_nr >= sc->stripes);
284284 bio->bi_bdev = sc->stripe[target_request_nr].dev->bdev;
285285 return DM_MAPIO_REMAPPED;
286286 }
287− if (unlikely(bio->bi_rw & REQ_DISCARD)) {
288− target_request_nr = map_context->target_request_nr;
287+ if (unlikely(bio->bi_rw & REQ_DISCARD) ||
288+ unlikely(bio->bi_rw & REQ_WRITE_SAME)) {
289+ target_request_nr = dm_bio_get_target_request_nr(bio);
289290 BUG_ON(target_request_nr >= sc->stripes);
290− return stripe_map_discard(sc, bio, target_request_nr);
291+ return stripe_map_range(sc, bio, target_request_nr);
291292 }
292293
293294 stripe_map_sector(sc, bio->bi_sector, &stripe, &bio->bi_sector);
@@ -342,8 +343,7 @@ static int stripe_status(struct dm_target *ti, status_type_t type, · 48 unmodified lines
342343 return 0;
343344 }
344345
345−static int stripe_end_io(struct dm_target *ti, struct bio *bio,
346− int error, union map_info *map_context)
346+static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
347347 {
348348 unsigned i;
349349 char major_minor[16];
drivers/md/dm-table.c+40−1
@@ -967,13 +967,22 @@ bool dm_table_request_based(struct dm_table *t) · 966 unmodified lines
967967 int dm_table_alloc_md_mempools(struct dm_table *t)
968968 {
969969 unsigned type = dm_table_get_type(t);
970+ unsigned per_bio_data_size = 0;
971+ struct dm_target *tgt;
972+ unsigned i;
970973
971974 if (unlikely(type == DM_TYPE_NONE)) {
972975 DMWARN("no table type is set, can't allocate mempools");
973976 return -EINVAL;
974977 }
975978
976− t->mempools = dm_alloc_md_mempools(type, t->integrity_supported);
979+ if (type == DM_TYPE_BIO_BASED)
980+ for (i = 0; i < t->num_targets; i++) {
981+ tgt = t->targets + i;
982+ per_bio_data_size = max(per_bio_data_size, tgt->per_bio_data_size);
983+ }
984+
985+ t->mempools = dm_alloc_md_mempools(type, t->integrity_supported, per_bio_data_size);
977986 if (!t->mempools)
978987 return -ENOMEM;
979988
@@ -1414,6 +1423,33 @@ static bool dm_table_all_devices_attribute(struct dm_table *t, · 434 unmodified lines
14141423 return 1;
14151424 }
14161425
1426+static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
1427+ sector_t start, sector_t len, void *data)
1428+{
1429+ struct request_queue *q = bdev_get_queue(dev->bdev);
1430+
1431+ return q && !q->limits.max_write_same_sectors;
1432+}
1433+
1434+static bool dm_table_supports_write_same(struct dm_table *t)
1435+{
1436+ struct dm_target *ti;
1437+ unsigned i = 0;
1438+
1439+ while (i < dm_table_get_num_targets(t)) {
1440+ ti = dm_table_get_target(t, i++);
1441+
1442+ if (!ti->num_write_same_requests)
1443+ return false;
1444+
1445+ if (!ti->type->iterate_devices ||
1446+ !ti->type->iterate_devices(ti, device_not_write_same_capable, NULL))
1447+ return false;
1448+ }
1449+
1450+ return true;
1451+}
1452+
14171453 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
14181454 struct queue_limits *limits)
14191455 {
@@ -1445,6 +1481,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, · 25 unmodified lines
14451481 else
14461482 queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q);
14471483
1484+ if (!dm_table_supports_write_same(t))
1485+ q->limits.max_write_same_sectors = 0;
1486+
14481487 dm_table_set_integrity(t);
14491488
14501489 /*
drivers/md/dm-target.c+2−3
@@ -126,15 +126,14 @@ static void io_err_dtr(struct dm_target *tt) · 125 unmodified lines
126126 /* empty */
127127 }
128128
129−static int io_err_map(struct dm_target *tt, struct bio *bio,
130− union map_info *map_context)
129+static int io_err_map(struct dm_target *tt, struct bio *bio)
131130 {
132131 return -EIO;
133132 }
134133
135134 static struct target_type error_target = {
136135 .name = "error",
137− .version = {1, 0, 1},
136+ .version = {1, 1, 0},
138137 .ctr = io_err_ctr,
139138 .dtr = io_err_dtr,
140139 .map = io_err_map,
drivers/md/dm-thin-metadata.c+1−1
@@ -408,7 +408,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd) · 407 unmodified lines
408408
409409 pmd->tl_info.tm = pmd->tm;
410410 pmd->tl_info.levels = 1;
411− pmd->tl_info.value_type.context = &pmd->info;
411+ pmd->tl_info.value_type.context = &pmd->bl_info;
412412 pmd->tl_info.value_type.size = sizeof(__le64);
413413 pmd->tl_info.value_type.inc = subtree_inc;
414414 pmd->tl_info.value_type.dec = subtree_dec;
drivers/md/dm-thin.c+120−114
@@ -186,7 +186,6 @@ struct pool { · 185 unmodified lines
186186
187187 struct dm_thin_new_mapping *next_mapping;
188188 mempool_t *mapping_pool;
189− mempool_t *endio_hook_pool;
190189
191190 process_bio_fn process_bio;
192191 process_bio_fn process_discard;
@@ -304,7 +303,7 @@ static void __requeue_bio_list(struct thin_c *tc, struct bio_list *master) · 111 unmodified lines
304303 bio_list_init(master);
305304
306305 while ((bio = bio_list_pop(&bios))) {
307− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
306+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
308307
309308 if (h->tc == tc)
310309 bio_endio(bio, DM_ENDIO_REQUEUE);
@@ -368,6 +367,17 @@ static int bio_triggers_commit(struct thin_c *tc, struct bio *bio) · 57 unmodified lines
368367 dm_thin_changed_this_transaction(tc->td);
369368 }
370369
370+static void inc_all_io_entry(struct pool *pool, struct bio *bio)
371+{
372+ struct dm_thin_endio_hook *h;
373+
374+ if (bio->bi_rw & REQ_DISCARD)
375+ return;
376+
377+ h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
378+ h->all_io_entry = dm_deferred_entry_inc(pool->all_io_ds);
379+}
380+
371381 static void issue(struct thin_c *tc, struct bio *bio)
372382 {
373383 struct pool *pool = tc->pool;
@@ -474,7 +484,7 @@ static void copy_complete(int read_err, unsigned long write_err, void *context) · 100 unmodified lines
474484 static void overwrite_endio(struct bio *bio, int err)
475485 {
476486 unsigned long flags;
477− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
487+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
478488 struct dm_thin_new_mapping *m = h->overwrite_mapping;
479489 struct pool *pool = m->tc->pool;
480490
@@ -499,8 +509,7 @@ static void overwrite_endio(struct bio *bio, int err) · 18 unmodified lines
499509 /*
500510 * This sends the bios in the cell back to the deferred_bios list.
501511 */
502−static void cell_defer(struct thin_c *tc, struct dm_bio_prison_cell *cell,
503− dm_block_t data_block)
512+static void cell_defer(struct thin_c *tc, struct dm_bio_prison_cell *cell)
504513 {
505514 struct pool *pool = tc->pool;
506515 unsigned long flags;
@@ -513,17 +522,13 @@ static void cell_defer(struct thin_c *tc, struct dm_bio_prison_cell *cell, · 6 unmodified lines
513522 }
514523
515524 /*
516− * Same as cell_defer above, except it omits one particular detainee,
517− * a write bio that covers the block and has already been processed.
525+ * Same as cell_defer except it omits the original holder of the cell.
518526 */
519−static void cell_defer_except(struct thin_c *tc, struct dm_bio_prison_cell *cell)
527+static void cell_defer_no_holder(struct thin_c *tc, struct dm_bio_prison_cell *cell)
520528 {
521− struct bio_list bios;
522529 struct pool *pool = tc->pool;
523530 unsigned long flags;
524531
525− bio_list_init(&bios);
526−
527532 spin_lock_irqsave(&pool->lock, flags);
528533 dm_cell_release_no_holder(cell, &pool->deferred_bios);
529534 spin_unlock_irqrestore(&pool->lock, flags);
@@ -561,7 +566,7 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) · 31 unmodified lines
561566 */
562567 r = dm_thin_insert_block(tc->td, m->virt_block, m->data_block);
563568 if (r) {
564− DMERR("dm_thin_insert_block() failed");
569+ DMERR_LIMIT("dm_thin_insert_block() failed");
565570 dm_cell_error(m->cell);
566571 goto out;
567572 }
@@ -573,10 +578,10 @@ static void process_prepared_mapping(struct dm_thin_new_mapping *m) · 5 unmodified lines
573578 * the bios in the cell.
574579 */
575580 if (bio) {
576− cell_defer_except(tc, m->cell);
581+ cell_defer_no_holder(tc, m->cell);
577582 bio_endio(bio, 0);
578583 } else
579− cell_defer(tc, m->cell, m->data_block);
584+ cell_defer(tc, m->cell);
580585
581586 out:
582587 list_del(&m->list);
@@ -588,8 +593,8 @@ static void process_prepared_discard_fail(struct dm_thin_new_mapping *m) · 5 unmodified lines
588593 struct thin_c *tc = m->tc;
589594
590595 bio_io_error(m->bio);
591− cell_defer_except(tc, m->cell);
592− cell_defer_except(tc, m->cell2);
596+ cell_defer_no_holder(tc, m->cell);
597+ cell_defer_no_holder(tc, m->cell2);
593598 mempool_free(m, tc->pool->mapping_pool);
594599 }
595600
@@ -597,13 +602,15 @@ static void process_prepared_discard_passdown(struct dm_thin_new_mapping *m) · 1 unmodified line
597602 {
598603 struct thin_c *tc = m->tc;
599604
605+ inc_all_io_entry(tc->pool, m->bio);
606+ cell_defer_no_holder(tc, m->cell);
607+ cell_defer_no_holder(tc, m->cell2);
608+
600609 if (m->pass_discard)
601610 remap_and_issue(tc, m->bio, m->data_block);
602611 else
603612 bio_endio(m->bio, 0);
604613
605− cell_defer_except(tc, m->cell);
606− cell_defer_except(tc, m->cell2);
607614 mempool_free(m, tc->pool->mapping_pool);
608615 }
609616
@@ -614,7 +621,7 @@ static void process_prepared_discard(struct dm_thin_new_mapping *m) · 4 unmodified lines
614621
615622 r = dm_thin_remove_block(tc->td, m->virt_block);
616623 if (r)
617− DMERR("dm_thin_remove_block() failed");
624+ DMERR_LIMIT("dm_thin_remove_block() failed");
618625
619626 process_prepared_discard_passdown(m);
620627 }
@@ -706,11 +713,12 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, · 85 unmodified lines
706713 * bio immediately. Otherwise we use kcopyd to clone the data first.
707714 */
708715 if (io_overwrites_block(pool, bio)) {
709− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
716+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
710717
711718 h->overwrite_mapping = m;
712719 m->bio = bio;
713720 save_and_set_endio(bio, &m->saved_bi_end_io, overwrite_endio);
721+ inc_all_io_entry(pool, bio);
714722 remap_and_issue(tc, bio, data_dest);
715723 } else {
716724 struct dm_io_region from, to;
@@ -727,7 +735,7 @@ static void schedule_copy(struct thin_c *tc, dm_block_t virt_block, · 10 unmodified lines
727735 0, copy_complete, m);
728736 if (r < 0) {
729737 mempool_free(m, pool->mapping_pool);
730− DMERR("dm_kcopyd_copy() failed");
738+ DMERR_LIMIT("dm_kcopyd_copy() failed");
731739 dm_cell_error(cell);
732740 }
733741 }
@@ -775,11 +783,12 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, · 41 unmodified lines
775783 process_prepared_mapping(m);
776784
777785 else if (io_overwrites_block(pool, bio)) {
778− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
786+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
779787
780788 h->overwrite_mapping = m;
781789 m->bio = bio;
782790 save_and_set_endio(bio, &m->saved_bi_end_io, overwrite_endio);
791+ inc_all_io_entry(pool, bio);
783792 remap_and_issue(tc, bio, data_block);
784793 } else {
785794 int r;
@@ -792,7 +801,7 @@ static void schedule_zero(struct thin_c *tc, dm_block_t virt_block, · 6 unmodified lines
792801 r = dm_kcopyd_zero(pool->copier, 1, &to, 0, copy_complete, m);
793802 if (r < 0) {
794803 mempool_free(m, pool->mapping_pool);
795− DMERR("dm_kcopyd_zero() failed");
804+ DMERR_LIMIT("dm_kcopyd_zero() failed");
796805 dm_cell_error(cell);
797806 }
798807 }
@@ -804,7 +813,7 @@ static int commit(struct pool *pool) · 5 unmodified lines
804813
805814 r = dm_pool_commit_metadata(pool->pmd);
806815 if (r)
807− DMERR("commit failed, error = %d", r);
816+ DMERR_LIMIT("commit failed: error = %d", r);
808817
809818 return r;
810819 }
@@ -889,7 +898,7 @@ static int alloc_data_block(struct thin_c *tc, dm_block_t *result) · 78 unmodified lines
889898 */
890899 static void retry_on_resume(struct bio *bio)
891900 {
892− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
901+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
893902 struct thin_c *tc = h->tc;
894903 struct pool *pool = tc->pool;
895904 unsigned long flags;
@@ -936,7 +945,7 @@ static void process_discard(struct thin_c *tc, struct bio *bio) · 40 unmodified lines
936945 */
937946 build_data_key(tc->td, lookup_result.block, &key2);
938947 if (dm_bio_detain(tc->pool->prison, &key2, bio, &cell2)) {
939− dm_cell_release_singleton(cell, bio);
948+ cell_defer_no_holder(tc, cell);
940949 break;
941950 }
942951
@@ -962,13 +971,15 @@ static void process_discard(struct thin_c *tc, struct bio *bio) · 19 unmodified lines
962971 wake_worker(pool);
963972 }
964973 } else {
974+ inc_all_io_entry(pool, bio);
975+ cell_defer_no_holder(tc, cell);
976+ cell_defer_no_holder(tc, cell2);
977+
965978 /*
966979 * The DM core makes sure that the discard doesn't span
967980 * a block boundary. So we submit the discard of a
968981 * partial block appropriately.
969982 */
970− dm_cell_release_singleton(cell, bio);
971− dm_cell_release_singleton(cell2, bio);
972983 if ((!lookup_result.shared) && pool->pf.discard_passdown)
973984 remap_and_issue(tc, bio, lookup_result.block);
974985 else
@@ -980,13 +991,14 @@ static void process_discard(struct thin_c *tc, struct bio *bio) · 5 unmodified lines
980991 /*
981992 * It isn't provisioned, just forget it.
982993 */
983− dm_cell_release_singleton(cell, bio);
994+ cell_defer_no_holder(tc, cell);
984995 bio_endio(bio, 0);
985996 break;
986997
987998 default:
988− DMERR("discard: find block unexpectedly returned %d", r);
989− dm_cell_release_singleton(cell, bio);
999+ DMERR_LIMIT("%s: dm_thin_find_block() failed: error = %d",
1000+ __func__, r);
1001+ cell_defer_no_holder(tc, cell);
9901002 bio_io_error(bio);
9911003 break;
9921004 }
@@ -1012,7 +1024,8 @@ static void break_sharing(struct thin_c *tc, struct bio *bio, dm_block_t block, · 19 unmodified lines
10121024 break;
10131025
10141026 default:
1015− DMERR("%s: alloc_data_block() failed, error = %d", __func__, r);
1027+ DMERR_LIMIT("%s: alloc_data_block() failed: error = %d",
1028+ __func__, r);
10161029 dm_cell_error(cell);
10171030 break;
10181031 }
@@ -1037,11 +1050,12 @@ static void process_shared_bio(struct thin_c *tc, struct bio *bio, · 18 unmodified lines
10371050 if (bio_data_dir(bio) == WRITE && bio->bi_size)
10381051 break_sharing(tc, bio, block, &key, lookup_result, cell);
10391052 else {
1040− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
1053+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
10411054
10421055 h->shared_read_entry = dm_deferred_entry_inc(pool->shared_read_ds);
1056+ inc_all_io_entry(pool, bio);
1057+ cell_defer_no_holder(tc, cell);
10431058
1044− dm_cell_release_singleton(cell, bio);
10451059 remap_and_issue(tc, bio, lookup_result->block);
10461060 }
10471061 }
@@ -1056,7 +1070,9 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block · 8 unmodified lines
10561070 * Remap empty bios (flushes) immediately, without provisioning.
10571071 */
10581072 if (!bio->bi_size) {
1059− dm_cell_release_singleton(cell, bio);
1073+ inc_all_io_entry(tc->pool, bio);
1074+ cell_defer_no_holder(tc, cell);
1075+
10601076 remap_and_issue(tc, bio, 0);
10611077 return;
10621078 }
@@ -1066,7 +1082,7 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block · 3 unmodified lines
10661082 */
10671083 if (bio_data_dir(bio) == READ) {
10681084 zero_fill_bio(bio);
1069− dm_cell_release_singleton(cell, bio);
1085+ cell_defer_no_holder(tc, cell);
10701086 bio_endio(bio, 0);
10711087 return;
10721088 }
@@ -1085,7 +1101,8 @@ static void provision_block(struct thin_c *tc, struct bio *bio, dm_block_t block · 12 unmodified lines
10851101 break;
10861102
10871103 default:
1088− DMERR("%s: alloc_data_block() failed, error = %d", __func__, r);
1104+ DMERR_LIMIT("%s: alloc_data_block() failed: error = %d",
1105+ __func__, r);
10891106 set_pool_mode(tc->pool, PM_READ_ONLY);
10901107 dm_cell_error(cell);
10911108 break;
@@ -1111,34 +1128,31 @@ static void process_bio(struct thin_c *tc, struct bio *bio) · 19 unmodified lines
11111128 r = dm_thin_find_block(tc->td, block, 1, &lookup_result);
11121129 switch (r) {
11131130 case 0:
1114− /*
1115− * We can release this cell now. This thread is the only
1116− * one that puts bios into a cell, and we know there were
1117− * no preceding bios.
1118− */
1119− /*
1120− * TODO: this will probably have to change when discard goes
1121− * back in.
1122− */
1123− dm_cell_release_singleton(cell, bio);
1124−
1125− if (lookup_result.shared)
1131+ if (lookup_result.shared) {
11261132 process_shared_bio(tc, bio, block, &lookup_result);
1127− else
1133+ cell_defer_no_holder(tc, cell);
1134+ } else {
1135+ inc_all_io_entry(tc->pool, bio);
1136+ cell_defer_no_holder(tc, cell);
1137+
11281138 remap_and_issue(tc, bio, lookup_result.block);
1139+ }
11291140 break;
11301141
11311142 case -ENODATA:
11321143 if (bio_data_dir(bio) == READ && tc->origin_dev) {
1133− dm_cell_release_singleton(cell, bio);
1144+ inc_all_io_entry(tc->pool, bio);
1145+ cell_defer_no_holder(tc, cell);
1146+
11341147 remap_to_origin_and_issue(tc, bio);
11351148 } else
11361149 provision_block(tc, bio, block, cell);
11371150 break;
11381151
11391152 default:
1140− DMERR("dm_thin_find_block() failed, error = %d", r);
1141− dm_cell_release_singleton(cell, bio);
1153+ DMERR_LIMIT("%s: dm_thin_find_block() failed: error = %d",
1154+ __func__, r);
1155+ cell_defer_no_holder(tc, cell);
11421156 bio_io_error(bio);
11431157 break;
11441158 }
@@ -1156,8 +1170,10 @@ static void process_bio_read_only(struct thin_c *tc, struct bio *bio) · 11 unmodified lines
11561170 case 0:
11571171 if (lookup_result.shared && (rw == WRITE) && bio->bi_size)
11581172 bio_io_error(bio);
1159− else
1173+ else {
1174+ inc_all_io_entry(tc->pool, bio);
11601175 remap_and_issue(tc, bio, lookup_result.block);
1176+ }
11611177 break;
11621178
11631179 case -ENODATA:
@@ -1167,6 +1183,7 @@ static void process_bio_read_only(struct thin_c *tc, struct bio *bio) · 3 unmodified lines
11671183 }
11681184
11691185 if (tc->origin_dev) {
1186+ inc_all_io_entry(tc->pool, bio);
11701187 remap_to_origin_and_issue(tc, bio);
11711188 break;
11721189 }
@@ -1176,7 +1193,8 @@ static void process_bio_read_only(struct thin_c *tc, struct bio *bio) · 3 unmodified lines
11761193 break;
11771194
11781195 default:
1179− DMERR("dm_thin_find_block() failed, error = %d", r);
1196+ DMERR_LIMIT("%s: dm_thin_find_block() failed: error = %d",
1197+ __func__, r);
11801198 bio_io_error(bio);
11811199 break;
11821200 }
@@ -1207,7 +1225,7 @@ static void process_deferred_bios(struct pool *pool) · 24 unmodified lines
12071225 spin_unlock_irqrestore(&pool->lock, flags);
12081226
12091227 while ((bio = bio_list_pop(&bios))) {
1210− struct dm_thin_endio_hook *h = dm_get_mapinfo(bio)->ptr;
1228+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
12111229 struct thin_c *tc = h->tc;
12121230
12131231 /*
@@ -1340,32 +1358,30 @@ static void thin_defer_bio(struct thin_c *tc, struct bio *bio) · 126 unmodified lines
13401358 wake_worker(pool);
13411359 }
13421360
1343−static struct dm_thin_endio_hook *thin_hook_bio(struct thin_c *tc, struct bio *bio)
1361+static void thin_hook_bio(struct thin_c *tc, struct bio *bio)
13441362 {
1345− struct pool *pool = tc->pool;
1346− struct dm_thin_endio_hook *h = mempool_alloc(pool->endio_hook_pool, GFP_NOIO);
1363+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
13471364
13481365 h->tc = tc;
13491366 h->shared_read_entry = NULL;
1350− h->all_io_entry = bio->bi_rw & REQ_DISCARD ? NULL : dm_deferred_entry_inc(pool->all_io_ds);
1367+ h->all_io_entry = NULL;
13511368 h->overwrite_mapping = NULL;
1352−
1353− return h;
13541369 }
13551370
13561371 /*
13571372 * Non-blocking function called from the thin target's map function.
13581373 */
1359−static int thin_bio_map(struct dm_target *ti, struct bio *bio,
1360− union map_info *map_context)
1374+static int thin_bio_map(struct dm_target *ti, struct bio *bio)
13611375 {
13621376 int r;
13631377 struct thin_c *tc = ti->private;
13641378 dm_block_t block = get_bio_block(tc, bio);
13651379 struct dm_thin_device *td = tc->td;
13661380 struct dm_thin_lookup_result result;
1381+ struct dm_bio_prison_cell *cell1, *cell2;
1382+ struct dm_cell_key key;
13671383
1368− map_context->ptr = thin_hook_bio(tc, bio);
1384+ thin_hook_bio(tc, bio);
13691385
13701386 if (get_pool_mode(tc->pool) == PM_FAIL) {
13711387 bio_io_error(bio);
@@ -1400,12 +1416,25 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio, · 28 unmodified lines
14001416 * shared flag will be set in their case.
14011417 */
14021418 thin_defer_bio(tc, bio);
1403− r = DM_MAPIO_SUBMITTED;
1404− } else {
1405− remap(tc, bio, result.block);
1406− r = DM_MAPIO_REMAPPED;
1419+ return DM_MAPIO_SUBMITTED;
14071420 }
1408− break;
1421+
1422+ build_virtual_key(tc->td, block, &key);
1423+ if (dm_bio_detain(tc->pool->prison, &key, bio, &cell1))
1424+ return DM_MAPIO_SUBMITTED;
1425+
1426+ build_data_key(tc->td, result.block, &key);
1427+ if (dm_bio_detain(tc->pool->prison, &key, bio, &cell2)) {
1428+ cell_defer_no_holder(tc, cell1);
1429+ return DM_MAPIO_SUBMITTED;
1430+ }
1431+
1432+ inc_all_io_entry(tc->pool, bio);
1433+ cell_defer_no_holder(tc, cell2);
1434+ cell_defer_no_holder(tc, cell1);
1435+
1436+ remap(tc, bio, result.block);
1437+ return DM_MAPIO_REMAPPED;
14091438
14101439 case -ENODATA:
14111440 if (get_pool_mode(tc->pool) == PM_READ_ONLY) {
@@ -1414,8 +1443,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio, · 2 unmodified lines
14141443 * of doing so. Just error it.
14151444 */
14161445 bio_io_error(bio);
1417− r = DM_MAPIO_SUBMITTED;
1418− break;
1446+ return DM_MAPIO_SUBMITTED;
14191447 }
14201448 /* fall through */
14211449
@@ -1425,8 +1453,7 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio, · 3 unmodified lines
14251453 * provide the hint to load the metadata into cache.
14261454 */
14271455 thin_defer_bio(tc, bio);
1428− r = DM_MAPIO_SUBMITTED;
1429− break;
1456+ return DM_MAPIO_SUBMITTED;
14301457
14311458 default:
14321459 /*
@@ -1435,11 +1462,8 @@ static int thin_bio_map(struct dm_target *ti, struct bio *bio, · 2 unmodified lines
14351462 * pool is switched to fail-io mode.
14361463 */
14371464 bio_io_error(bio);
1438− r = DM_MAPIO_SUBMITTED;
1439− break;
1465+ return DM_MAPIO_SUBMITTED;
14401466 }
1441−
1442− return r;
14431467 }
14441468
14451469 static int pool_is_congested(struct dm_target_callbacks *cb, int bdi_bits)
@@ -1566,14 +1590,12 @@ static void __pool_destroy(struct pool *pool) · 120 unmodified lines
15661590 if (pool->next_mapping)
15671591 mempool_free(pool->next_mapping, pool->mapping_pool);
15681592 mempool_destroy(pool->mapping_pool);
1569− mempool_destroy(pool->endio_hook_pool);
15701593 dm_deferred_set_destroy(pool->shared_read_ds);
15711594 dm_deferred_set_destroy(pool->all_io_ds);
15721595 kfree(pool);
15731596 }
15741597
15751598 static struct kmem_cache *_new_mapping_cache;
1576−static struct kmem_cache *_endio_hook_cache;
15771599
15781600 static struct pool *pool_create(struct mapped_device *pool_md,
15791601 struct block_device *metadata_dev,
@@ -1667,13 +1689,6 @@ static struct pool *pool_create(struct mapped_device *pool_md, · 87 unmodified lines
16671689 goto bad_mapping_pool;
16681690 }
16691691
1670− pool->endio_hook_pool = mempool_create_slab_pool(ENDIO_HOOK_POOL_SIZE,
1671− _endio_hook_cache);
1672− if (!pool->endio_hook_pool) {
1673− *error = "Error creating pool's endio_hook mempool";
1674− err_p = ERR_PTR(-ENOMEM);
1675− goto bad_endio_hook_pool;
1676− }
16771692 pool->ref_count = 1;
16781693 pool->last_commit_jiffies = jiffies;
16791694 pool->pool_md = pool_md;
@@ -1682,8 +1697,6 @@ static struct pool *pool_create(struct mapped_device *pool_md, · 2 unmodified lines
16821697
16831698 return pool;
16841699
1685−bad_endio_hook_pool:
1686− mempool_destroy(pool->mapping_pool);
16871700 bad_mapping_pool:
16881701 dm_deferred_set_destroy(pool->all_io_ds);
16891702 bad_all_io_ds:
@@ -1966,8 +1979,7 @@ out_unlock: · 276 unmodified lines
19661979 return r;
19671980 }
19681981
1969−static int pool_map(struct dm_target *ti, struct bio *bio,
1970− union map_info *map_context)
1982+static int pool_map(struct dm_target *ti, struct bio *bio)
19711983 {
19721984 int r;
19731985 struct pool_c *pt = ti->private;
@@ -2358,7 +2370,9 @@ static int pool_status(struct dm_target *ti, status_type_t type, · 384 unmodified lines
23582370 else
23592371 DMEMIT("rw ");
23602372
2361− if (pool->pf.discard_enabled && pool->pf.discard_passdown)
2373+ if (!pool->pf.discard_enabled)
2374+ DMEMIT("ignore_discard");
2375+ else if (pool->pf.discard_passdown)
23622376 DMEMIT("discard_passdown");
23632377 else
23642378 DMEMIT("no_discard_passdown");
@@ -2454,7 +2468,7 @@ static struct target_type pool_target = { · 89 unmodified lines
24542468 .name = "thin-pool",
24552469 .features = DM_TARGET_SINGLETON | DM_TARGET_ALWAYS_WRITEABLE |
24562470 DM_TARGET_IMMUTABLE,
2457− .version = {1, 5, 0},
2471+ .version = {1, 6, 0},
24582472 .module = THIS_MODULE,
24592473 .ctr = pool_ctr,
24602474 .dtr = pool_dtr,
@@ -2576,6 +2590,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) · 115 unmodified lines
25762590
25772591 ti->num_flush_requests = 1;
25782592 ti->flush_supported = true;
2593+ ti->per_bio_data_size = sizeof(struct dm_thin_endio_hook);
25792594
25802595 /* In case the pool supports discards, pass them on. */
25812596 if (tc->pool->pf.discard_enabled) {
@@ -2609,20 +2624,17 @@ out_unlock: · 27 unmodified lines
26092624 return r;
26102625 }
26112626
2612−static int thin_map(struct dm_target *ti, struct bio *bio,
2613− union map_info *map_context)
2627+static int thin_map(struct dm_target *ti, struct bio *bio)
26142628 {
26152629 bio->bi_sector = dm_target_offset(ti, bio->bi_sector);
26162630
2617− return thin_bio_map(ti, bio, map_context);
2631+ return thin_bio_map(ti, bio);
26182632 }
26192633
2620−static int thin_endio(struct dm_target *ti,
2621− struct bio *bio, int err,
2622− union map_info *map_context)
2634+static int thin_endio(struct dm_target *ti, struct bio *bio, int err)
26232635 {
26242636 unsigned long flags;
2625− struct dm_thin_endio_hook *h = map_context->ptr;
2637+ struct dm_thin_endio_hook *h = dm_per_bio_data(bio, sizeof(struct dm_thin_endio_hook));
26262638 struct list_head work;
26272639 struct dm_thin_new_mapping *m, *tmp;
26282640 struct pool *pool = h->tc->pool;
@@ -2643,14 +2655,15 @@ static int thin_endio(struct dm_target *ti, · 14 unmodified lines
26432655 if (h->all_io_entry) {
26442656 INIT_LIST_HEAD(&work);
26452657 dm_deferred_entry_dec(h->all_io_entry, &work);
2646− spin_lock_irqsave(&pool->lock, flags);
2647− list_for_each_entry_safe(m, tmp, &work, list)
2648− list_add(&m->list, &pool->prepared_discards);
2649− spin_unlock_irqrestore(&pool->lock, flags);
2658+ if (!list_empty(&work)) {
2659+ spin_lock_irqsave(&pool->lock, flags);
2660+ list_for_each_entry_safe(m, tmp, &work, list)
2661+ list_add(&m->list, &pool->prepared_discards);
2662+ spin_unlock_irqrestore(&pool->lock, flags);
2663+ wake_worker(pool);
2664+ }
26502665 }
26512666
2652− mempool_free(h, pool->endio_hook_pool);
2653−
26542667 return 0;
26552668 }
26562669
@@ -2745,7 +2758,7 @@ static void thin_io_hints(struct dm_target *ti, struct queue_limits *limits) · 88 unmodified lines
27452758
27462759 static struct target_type thin_target = {
27472760 .name = "thin",
2748− .version = {1, 5, 0},
2761+ .version = {1, 6, 0},
27492762 .module = THIS_MODULE,
27502763 .ctr = thin_ctr,
27512764 .dtr = thin_dtr,
@@ -2779,14 +2792,8 @@ static int __init dm_thin_init(void) · 27 unmodified lines
27792792 if (!_new_mapping_cache)
27802793 goto bad_new_mapping_cache;
27812794
2782− _endio_hook_cache = KMEM_CACHE(dm_thin_endio_hook, 0);
2783− if (!_endio_hook_cache)
2784− goto bad_endio_hook_cache;
2785−
27862795 return 0;
27872796
2788−bad_endio_hook_cache:
2789− kmem_cache_destroy(_new_mapping_cache);
27902797 bad_new_mapping_cache:
27912798 dm_unregister_target(&pool_target);
27922799 bad_pool_target:
@@ -2801,7 +2808,6 @@ static void dm_thin_exit(void) · 8 unmodified lines
28012808 dm_unregister_target(&pool_target);
28022809
28032810 kmem_cache_destroy(_new_mapping_cache);
2804− kmem_cache_destroy(_endio_hook_cache);
28052811 }
28062812
28072813 module_init(dm_thin_init);
drivers/md/dm-verity.c+5−20
@@ -55,7 +55,6 @@ struct dm_verity { · 54 unmodified lines
5555 unsigned shash_descsize;/* the size of temporary space for crypto */
5656 int hash_failed; /* set to 1 if hash of any block failed */
5757
58− mempool_t *io_mempool; /* mempool of struct dm_verity_io */
5958 mempool_t *vec_mempool; /* mempool of bio vector */
6059
6160 struct workqueue_struct *verify_wq;
@@ -66,7 +65,6 @@ struct dm_verity { · 4 unmodified lines
6665
6766 struct dm_verity_io {
6867 struct dm_verity *v;
69− struct bio *bio;
7068
7169 /* original values of bio->bi_end_io and bio->bi_private */
7270 bio_end_io_t *orig_bi_end_io;
@@ -389,8 +387,8 @@ test_block_hash: · 316 unmodified lines
389387 */
390388 static void verity_finish_io(struct dm_verity_io *io, int error)
391389 {
392− struct bio *bio = io->bio;
393390 struct dm_verity *v = io->v;
391+ struct bio *bio = dm_bio_from_per_bio_data(io, v->ti->per_bio_data_size);
394392
395393 bio->bi_end_io = io->orig_bi_end_io;
396394 bio->bi_private = io->orig_bi_private;
@@ -398,8 +396,6 @@ static void verity_finish_io(struct dm_verity_io *io, int error) · 1 unmodified line
398396 if (io->io_vec != io->io_vec_inline)
399397 mempool_free(io->io_vec, v->vec_mempool);
400398
401− mempool_free(io, v->io_mempool);
402−
403399 bio_endio(bio, error);
404400 }
405401
@@ -462,8 +458,7 @@ no_prefetch_cluster: · 56 unmodified lines
462458 * Bio map function. It allocates dm_verity_io structure and bio vector and
463459 * fills them. Then it issues prefetches and the I/O.
464460 */
465−static int verity_map(struct dm_target *ti, struct bio *bio,
466− union map_info *map_context)
461+static int verity_map(struct dm_target *ti, struct bio *bio)
467462 {
468463 struct dm_verity *v = ti->private;
469464 struct dm_verity_io *io;
@@ -486,9 +481,8 @@ static int verity_map(struct dm_target *ti, struct bio *bio, · 16 unmodified lines
486481 if (bio_data_dir(bio) == WRITE)
487482 return -EIO;
488483
489− io = mempool_alloc(v->io_mempool, GFP_NOIO);
484+ io = dm_per_bio_data(bio, ti->per_bio_data_size);
490485 io->v = v;
491− io->bio = bio;
492486 io->orig_bi_end_io = bio->bi_end_io;
493487 io->orig_bi_private = bio->bi_private;
494488 io->block = bio->bi_sector >> (v->data_dev_block_bits - SECTOR_SHIFT);
@@ -610,9 +604,6 @@ static void verity_dtr(struct dm_target *ti) · 115 unmodified lines
610604 if (v->vec_mempool)
611605 mempool_destroy(v->vec_mempool);
612606
613− if (v->io_mempool)
614− mempool_destroy(v->io_mempool);
615−
616607 if (v->bufio)
617608 dm_bufio_client_destroy(v->bufio);
618609
@@ -841,13 +832,7 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) · 222 unmodified lines
841832 goto bad;
842833 }
843834
844− v->io_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE,
845− sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2);
846− if (!v->io_mempool) {
847− ti->error = "Cannot allocate io mempool";
848− r = -ENOMEM;
849− goto bad;
850− }
835+ ti->per_bio_data_size = roundup(sizeof(struct dm_verity_io) + v->shash_descsize + v->digest_size * 2, __alignof__(struct dm_verity_io));
851836
852837 v->vec_mempool = mempool_create_kmalloc_pool(DM_VERITY_MEMPOOL_SIZE,
853838 BIO_MAX_PAGES * sizeof(struct bio_vec));
@@ -875,7 +860,7 @@ bad: · 21 unmodified lines
875860
876861 static struct target_type verity_target = {
877862 .name = "verity",
878− .version = {1, 0, 0},
863+ .version = {1, 1, 0},
879864 .module = THIS_MODULE,
880865 .ctr = verity_ctr,
881866 .dtr = verity_dtr,
drivers/md/dm-zero.c+2−3
@@ -33,8 +33,7 @@ static int zero_ctr(struct dm_target *ti, unsigned int argc, char **argv) · 32 unmodified lines
3333 /*
3434 * Return zeros only on reads
3535 */
36−static int zero_map(struct dm_target *ti, struct bio *bio,
37− union map_info *map_context)
36+static int zero_map(struct dm_target *ti, struct bio *bio)
3837 {
3938 switch(bio_rw(bio)) {
4039 case READ:
@@ -56,7 +55,7 @@ static int zero_map(struct dm_target *ti, struct bio *bio, · 15 unmodified lines
5655
5756 static struct target_type zero_target = {
5857 .name = "zero",
59− .version = {1, 0, 0},
58+ .version = {1, 1, 0},
6059 .module = THIS_MODULE,
6160 .ctr = zero_ctr,
6261 .map = zero_map,
drivers/md/dm.c+58−26
@@ -62,18 +62,6 @@ struct dm_io { · 61 unmodified lines
6262 spinlock_t endio_lock;
6363 };
6464
65−/*
66− * For bio-based dm.
67− * One of these is allocated per target within a bio. Hopefully
68− * this will be simplified out one day.
69− */
70−struct dm_target_io {
71− struct dm_io *io;
72− struct dm_target *ti;
73− union map_info info;
74− struct bio clone;
75−};
76−
7765 /*
7866 * For request-based dm.
7967 * One of these is allocated per request.
@@ -657,7 +645,7 @@ static void clone_endio(struct bio *bio, int error) · 577 unmodified lines
657645 error = -EIO;
658646
659647 if (endio) {
660− r = endio(tio->ti, bio, error, &tio->info);
648+ r = endio(tio->ti, bio, error);
661649 if (r < 0 || r == DM_ENDIO_REQUEUE)
662650 /*
663651 * error and requeue request are handled
@@ -1016,7 +1004,7 @@ static void __map_bio(struct dm_target *ti, struct dm_target_io *tio) · 352 unmodified lines
10161004 */
10171005 atomic_inc(&tio->io->io_count);
10181006 sector = clone->bi_sector;
1019− r = ti->type->map(ti, clone, &tio->info);
1007+ r = ti->type->map(ti, clone);
10201008 if (r == DM_MAPIO_REMAPPED) {
10211009 /* the bio has been remapped so dispatch it */
10221010
@@ -1111,6 +1099,7 @@ static struct dm_target_io *alloc_tio(struct clone_info *ci, · 88 unmodified lines
11111099 tio->io = ci->io;
11121100 tio->ti = ti;
11131101 memset(&tio->info, 0, sizeof(tio->info));
1102+ tio->target_request_nr = 0;
11141103
11151104 return tio;
11161105 }
@@ -1121,7 +1110,7 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, · 4 unmodified lines
11211110 struct dm_target_io *tio = alloc_tio(ci, ti, ci->bio->bi_max_vecs);
11221111 struct bio *clone = &tio->clone;
11231112
1124− tio->info.target_request_nr = request_nr;
1113+ tio->target_request_nr = request_nr;
11251114
11261115 /*
11271116 * Discard requests require the bio's inline iovecs be initialized.
@@ -1174,7 +1163,28 @@ static void __clone_and_map_simple(struct clone_info *ci, struct dm_target *ti) · 46 unmodified lines
11741163 ci->sector_count = 0;
11751164 }
11761165
1177−static int __clone_and_map_discard(struct clone_info *ci)
1166+typedef unsigned (*get_num_requests_fn)(struct dm_target *ti);
1167+
1168+static unsigned get_num_discard_requests(struct dm_target *ti)
1169+{
1170+ return ti->num_discard_requests;
1171+}
1172+
1173+static unsigned get_num_write_same_requests(struct dm_target *ti)
1174+{
1175+ return ti->num_write_same_requests;
1176+}
1177+
1178+typedef bool (*is_split_required_fn)(struct dm_target *ti);
1179+
1180+static bool is_split_required_for_discard(struct dm_target *ti)
1181+{
1182+ return ti->split_discard_requests;
1183+}
1184+
1185+static int __clone_and_map_changing_extent_only(struct clone_info *ci,
1186+ get_num_requests_fn get_num_requests,
1187+ is_split_required_fn is_split_required)
11781188 {
11791189 struct dm_target *ti;
11801190 sector_t len;
@@ -1185,15 +1195,15 @@ static int __clone_and_map_discard(struct clone_info *ci) · 4 unmodified lines
11851195 return -EIO;
11861196
11871197 /*
1188− * Even though the device advertised discard support,
1189− * that does not mean every target supports it, and
1198+ * Even though the device advertised support for this type of
1199+ * request, that does not mean every target supports it, and
11901200 * reconfiguration might also have changed that since the
11911201 * check was performed.
11921202 */
1193− if (!ti->num_discard_requests)
1203+ if (!get_num_requests || !get_num_requests(ti))
11941204 return -EOPNOTSUPP;
11951205
1196− if (!ti->split_discard_requests)
1206+ if (is_split_required && !is_split_required(ti))
11971207 len = min(ci->sector_count, max_io_len_target_boundary(ci->sector, ti));
11981208 else
11991209 len = min(ci->sector_count, max_io_len(ci->sector, ti));
@@ -1206,6 +1216,17 @@ static int __clone_and_map_discard(struct clone_info *ci) · 6 unmodified lines
12061216 return 0;
12071217 }
12081218
1219+static int __clone_and_map_discard(struct clone_info *ci)
1220+{
1221+ return __clone_and_map_changing_extent_only(ci, get_num_discard_requests,
1222+ is_split_required_for_discard);
1223+}
1224+
1225+static int __clone_and_map_write_same(struct clone_info *ci)
1226+{
1227+ return __clone_and_map_changing_extent_only(ci, get_num_write_same_requests, NULL);
1228+}
1229+
12091230 static int __clone_and_map(struct clone_info *ci)
12101231 {
12111232 struct bio *bio = ci->bio;
@@ -1215,6 +1236,8 @@ static int __clone_and_map(struct clone_info *ci) · 3 unmodified lines
12151236
12161237 if (unlikely(bio->bi_rw & REQ_DISCARD))
12171238 return __clone_and_map_discard(ci);
1239+ else if (unlikely(bio->bi_rw & REQ_WRITE_SAME))
1240+ return __clone_and_map_write_same(ci);
12181241
12191242 ti = dm_table_find_target(ci->map, ci->sector);
12201243 if (!dm_target_is_valid(ti))
@@ -1946,13 +1969,20 @@ static void free_dev(struct mapped_device *md) · 725 unmodified lines
19461969
19471970 static void __bind_mempools(struct mapped_device *md, struct dm_table *t)
19481971 {
1949− struct dm_md_mempools *p;
1972+ struct dm_md_mempools *p = dm_table_get_md_mempools(t);
19501973
1951− if (md->io_pool && (md->tio_pool || dm_table_get_type(t) == DM_TYPE_BIO_BASED) && md->bs)
1952− /* the md already has necessary mempools */
1974+ if (md->io_pool && (md->tio_pool || dm_table_get_type(t) == DM_TYPE_BIO_BASED) && md->bs) {
1975+ /*
1976+ * The md already has necessary mempools. Reload just the
1977+ * bioset because front_pad may have changed because
1978+ * a different table was loaded.
1979+ */
1980+ bioset_free(md->bs);
1981+ md->bs = p->bs;
1982+ p->bs = NULL;
19531983 goto out;
1984+ }
19541985
1955− p = dm_table_get_md_mempools(t);
19561986 BUG_ON(!p || md->io_pool || md->tio_pool || md->bs);
19571987
19581988 md->io_pool = p->io_pool;
@@ -2711,7 +2741,7 @@ int dm_noflush_suspending(struct dm_target *ti) · 752 unmodified lines
27112741 }
27122742 EXPORT_SYMBOL_GPL(dm_noflush_suspending);
27132743
2714−struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity)
2744+struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity, unsigned per_bio_data_size)
27152745 {
27162746 struct dm_md_mempools *pools = kmalloc(sizeof(*pools), GFP_KERNEL);
27172747 unsigned int pool_size = (type == DM_TYPE_BIO_BASED) ? 16 : MIN_IOS;
@@ -2719,6 +2749,8 @@ struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity) · 1 unmodified line
27192749 if (!pools)
27202750 return NULL;
27212751
2752+ per_bio_data_size = roundup(per_bio_data_size, __alignof__(struct dm_target_io));
2753+
27222754 pools->io_pool = (type == DM_TYPE_BIO_BASED) ?
27232755 mempool_create_slab_pool(MIN_IOS, _io_cache) :
27242756 mempool_create_slab_pool(MIN_IOS, _rq_bio_info_cache);
@@ -2734,7 +2766,7 @@ struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity) · 9 unmodified lines
27342766
27352767 pools->bs = (type == DM_TYPE_BIO_BASED) ?
27362768 bioset_create(pool_size,
2737− offsetof(struct dm_target_io, clone)) :
2769+ per_bio_data_size + offsetof(struct dm_target_io, clone)) :
27382770 bioset_create(pool_size,
27392771 offsetof(struct dm_rq_clone_bio_info, clone));
27402772 if (!pools->bs)
drivers/md/dm.h+1−1
@@ -159,7 +159,7 @@ void dm_kcopyd_exit(void); · 158 unmodified lines
159159 /*
160160 * Mempool operations
161161 */
162−struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity);
162+struct dm_md_mempools *dm_alloc_md_mempools(unsigned type, unsigned integrity, unsigned per_bio_data_size);
163163 void dm_free_md_mempools(struct dm_md_mempools *pools);
164164
165165 #endif
drivers/md/persistent-data/dm-block-manager.c+7−5
@@ -428,15 +428,17 @@ static int dm_bm_validate_buffer(struct dm_block_manager *bm, · 427 unmodified lines
428428 if (!v)
429429 return 0;
430430 r = v->check(v, (struct dm_block *) buf, dm_bufio_get_block_size(bm->bufio));
431− if (unlikely(r))
431+ if (unlikely(r)) {
432+ DMERR_LIMIT("%s validator check failed for block %llu", v->name,
433+ (unsigned long long) dm_bufio_get_block_number(buf));
432434 return r;
435+ }
433436 aux->validator = v;
434437 } else {
435438 if (unlikely(aux->validator != v)) {
436− DMERR("validator mismatch (old=%s vs new=%s) for block %llu",
437− aux->validator->name, v ? v->name : "NULL",
438− (unsigned long long)
439− dm_bufio_get_block_number(buf));
439+ DMERR_LIMIT("validator mismatch (old=%s vs new=%s) for block %llu",
440+ aux->validator->name, v ? v->name : "NULL",
441+ (unsigned long long) dm_bufio_get_block_number(buf));
440442 return -EINVAL;
441443 }
442444 }
drivers/md/persistent-data/dm-btree-internal.h+8−8
@@ -36,13 +36,13 @@ struct node_header { · 35 unmodified lines
3636 __le32 padding;
3737 } __packed;
3838
39−struct node {
39+struct btree_node {
4040 struct node_header header;
4141 __le64 keys[0];
4242 } __packed;
4343
4444
45−void inc_children(struct dm_transaction_manager *tm, struct node *n,
45+void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
4646 struct dm_btree_value_type *vt);
4747
4848 int new_block(struct dm_btree_info *info, struct dm_block **result);
@@ -64,7 +64,7 @@ struct ro_spine { · 15 unmodified lines
6464 void init_ro_spine(struct ro_spine *s, struct dm_btree_info *info);
6565 int exit_ro_spine(struct ro_spine *s);
6666 int ro_step(struct ro_spine *s, dm_block_t new_child);
67−struct node *ro_node(struct ro_spine *s);
67+struct btree_node *ro_node(struct ro_spine *s);
6868
6969 struct shadow_spine {
7070 struct dm_btree_info *info;
@@ -98,17 +98,17 @@ int shadow_root(struct shadow_spine *s); · 27 unmodified lines
9898 /*
9999 * Some inlines.
100100 */
101−static inline __le64 *key_ptr(struct node *n, uint32_t index)
101+static inline __le64 *key_ptr(struct btree_node *n, uint32_t index)
102102 {
103103 return n->keys + index;
104104 }
105105
106−static inline void *value_base(struct node *n)
106+static inline void *value_base(struct btree_node *n)
107107 {
108108 return &n->keys[le32_to_cpu(n->header.max_entries)];
109109 }
110110
111−static inline void *value_ptr(struct node *n, uint32_t index)
111+static inline void *value_ptr(struct btree_node *n, uint32_t index)
112112 {
113113 uint32_t value_size = le32_to_cpu(n->header.value_size);
114114 return value_base(n) + (value_size * index);
@@ -117,7 +117,7 @@ static inline void *value_ptr(struct node *n, uint32_t index) · 2 unmodified lines
117117 /*
118118 * Assumes the values are suitably-aligned and converts to core format.
119119 */
120−static inline uint64_t value64(struct node *n, uint32_t index)
120+static inline uint64_t value64(struct btree_node *n, uint32_t index)
121121 {
122122 __le64 *values_le = value_base(n);
123123
@@ -127,7 +127,7 @@ static inline uint64_t value64(struct node *n, uint32_t index) · 3 unmodified lines
127127 /*
128128 * Searching for a key within a single node.
129129 */
130−int lower_bound(struct node *n, uint64_t key);
130+int lower_bound(struct btree_node *n, uint64_t key);
131131
132132 extern struct dm_block_validator btree_node_validator;
133133
drivers/md/persistent-data/dm-btree-remove.c+25−25
@@ -53,7 +53,7 @@ · 52 unmodified lines
5353 /*
5454 * Some little utilities for moving node data around.
5555 */
56−static void node_shift(struct node *n, int shift)
56+static void node_shift(struct btree_node *n, int shift)
5757 {
5858 uint32_t nr_entries = le32_to_cpu(n->header.nr_entries);
5959 uint32_t value_size = le32_to_cpu(n->header.value_size);
@@ -79,7 +79,7 @@ static void node_shift(struct node *n, int shift) · 19 unmodified lines
7979 }
8080 }
8181
82−static void node_copy(struct node *left, struct node *right, int shift)
82+static void node_copy(struct btree_node *left, struct btree_node *right, int shift)
8383 {
8484 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
8585 uint32_t value_size = le32_to_cpu(left->header.value_size);
@@ -108,7 +108,7 @@ static void node_copy(struct node *left, struct node *right, int shift) · 22 unmodified lines
108108 /*
109109 * Delete a specific entry from a leaf node.
110110 */
111−static void delete_at(struct node *n, unsigned index)
111+static void delete_at(struct btree_node *n, unsigned index)
112112 {
113113 unsigned nr_entries = le32_to_cpu(n->header.nr_entries);
114114 unsigned nr_to_copy = nr_entries - (index + 1);
@@ -128,7 +128,7 @@ static void delete_at(struct node *n, unsigned index) · 13 unmodified lines
128128 n->header.nr_entries = cpu_to_le32(nr_entries - 1);
129129 }
130130
131−static unsigned merge_threshold(struct node *n)
131+static unsigned merge_threshold(struct btree_node *n)
132132 {
133133 return le32_to_cpu(n->header.max_entries) / 3;
134134 }
@@ -136,7 +136,7 @@ static unsigned merge_threshold(struct node *n) · 1 unmodified line
136136 struct child {
137137 unsigned index;
138138 struct dm_block *block;
139− struct node *n;
139+ struct btree_node *n;
140140 };
141141
142142 static struct dm_btree_value_type le64_type = {
@@ -147,7 +147,7 @@ static struct dm_btree_value_type le64_type = { · 4 unmodified lines
147147 .equal = NULL
148148 };
149149
150−static int init_child(struct dm_btree_info *info, struct node *parent,
150+static int init_child(struct dm_btree_info *info, struct btree_node *parent,
151151 unsigned index, struct child *result)
152152 {
153153 int r, inc;
@@ -177,7 +177,7 @@ static int exit_child(struct dm_btree_info *info, struct child *c) · 23 unmodified lines
177177 return dm_tm_unlock(info->tm, c->block);
178178 }
179179
180−static void shift(struct node *left, struct node *right, int count)
180+static void shift(struct btree_node *left, struct btree_node *right, int count)
181181 {
182182 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
183183 uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
@@ -203,11 +203,11 @@ static void shift(struct node *left, struct node *right, int count) · 19 unmodified lines
203203 right->header.nr_entries = cpu_to_le32(nr_right + count);
204204 }
205205
206−static void __rebalance2(struct dm_btree_info *info, struct node *parent,
206+static void __rebalance2(struct dm_btree_info *info, struct btree_node *parent,
207207 struct child *l, struct child *r)
208208 {
209− struct node *left = l->n;
210− struct node *right = r->n;
209+ struct btree_node *left = l->n;
210+ struct btree_node *right = r->n;
211211 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
212212 uint32_t nr_right = le32_to_cpu(right->header.nr_entries);
213213 unsigned threshold = 2 * merge_threshold(left) + 1;
@@ -239,7 +239,7 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info, · 25 unmodified lines
239239 unsigned left_index)
240240 {
241241 int r;
242− struct node *parent;
242+ struct btree_node *parent;
243243 struct child left, right;
244244
245245 parent = dm_block_data(shadow_current(s));
@@ -270,9 +270,9 @@ static int rebalance2(struct shadow_spine *s, struct dm_btree_info *info, · 24 unmodified lines
270270 * in right, then rebalance2. This wastes some cpu, but I want something
271271 * simple atm.
272272 */
273−static void delete_center_node(struct dm_btree_info *info, struct node *parent,
273+static void delete_center_node(struct dm_btree_info *info, struct btree_node *parent,
274274 struct child *l, struct child *c, struct child *r,
275− struct node *left, struct node *center, struct node *right,
275+ struct btree_node *left, struct btree_node *center, struct btree_node *right,
276276 uint32_t nr_left, uint32_t nr_center, uint32_t nr_right)
277277 {
278278 uint32_t max_entries = le32_to_cpu(left->header.max_entries);
@@ -301,9 +301,9 @@ static void delete_center_node(struct dm_btree_info *info, struct node *parent, · 22 unmodified lines
301301 /*
302302 * Redistributes entries among 3 sibling nodes.
303303 */
304−static void redistribute3(struct dm_btree_info *info, struct node *parent,
304+static void redistribute3(struct dm_btree_info *info, struct btree_node *parent,
305305 struct child *l, struct child *c, struct child *r,
306− struct node *left, struct node *center, struct node *right,
306+ struct btree_node *left, struct btree_node *center, struct btree_node *right,
307307 uint32_t nr_left, uint32_t nr_center, uint32_t nr_right)
308308 {
309309 int s;
@@ -343,12 +343,12 @@ static void redistribute3(struct dm_btree_info *info, struct node *parent, · 33 unmodified lines
343343 *key_ptr(parent, r->index) = right->keys[0];
344344 }
345345
346−static void __rebalance3(struct dm_btree_info *info, struct node *parent,
346+static void __rebalance3(struct dm_btree_info *info, struct btree_node *parent,
347347 struct child *l, struct child *c, struct child *r)
348348 {
349− struct node *left = l->n;
350− struct node *center = c->n;
351− struct node *right = r->n;
349+ struct btree_node *left = l->n;
350+ struct btree_node *center = c->n;
351+ struct btree_node *right = r->n;
352352
353353 uint32_t nr_left = le32_to_cpu(left->header.nr_entries);
354354 uint32_t nr_center = le32_to_cpu(center->header.nr_entries);
@@ -371,7 +371,7 @@ static int rebalance3(struct shadow_spine *s, struct dm_btree_info *info, · 16 unmodified lines
371371 unsigned left_index)
372372 {
373373 int r;
374− struct node *parent = dm_block_data(shadow_current(s));
374+ struct btree_node *parent = dm_block_data(shadow_current(s));
375375 struct child left, center, right;
376376
377377 /*
@@ -421,7 +421,7 @@ static int get_nr_entries(struct dm_transaction_manager *tm, · 43 unmodified lines
421421 {
422422 int r;
423423 struct dm_block *block;
424− struct node *n;
424+ struct btree_node *n;
425425
426426 r = dm_tm_read_lock(tm, b, &btree_node_validator, &block);
427427 if (r)
@@ -438,7 +438,7 @@ static int rebalance_children(struct shadow_spine *s, · 10 unmodified lines
438438 {
439439 int i, r, has_left_sibling, has_right_sibling;
440440 uint32_t child_entries;
441− struct node *n;
441+ struct btree_node *n;
442442
443443 n = dm_block_data(shadow_current(s));
444444
@@ -483,7 +483,7 @@ static int rebalance_children(struct shadow_spine *s, · 38 unmodified lines
483483 return r;
484484 }
485485
486−static int do_leaf(struct node *n, uint64_t key, unsigned *index)
486+static int do_leaf(struct btree_node *n, uint64_t key, unsigned *index)
487487 {
488488 int i = lower_bound(n, key);
489489
@@ -506,7 +506,7 @@ static int remove_raw(struct shadow_spine *s, struct dm_btree_info *info, · 16 unmodified lines
506506 uint64_t key, unsigned *index)
507507 {
508508 int i = *index, r;
509− struct node *n;
509+ struct btree_node *n;
510510
511511 for (;;) {
512512 r = shadow_step(s, root, vt);
@@ -556,7 +556,7 @@ int dm_btree_remove(struct dm_btree_info *info, dm_block_t root, · 43 unmodified lines
556556 unsigned level, last_level = info->levels - 1;
557557 int index = 0, r = 0;
558558 struct shadow_spine spine;
559− struct node *n;
559+ struct btree_node *n;
560560
561561 init_shadow_spine(&spine, info);
562562 for (level = 0; level < info->levels; level++) {
drivers/md/persistent-data/dm-btree-spine.c+10−10
@@ -23,7 +23,7 @@ static void node_prepare_for_write(struct dm_block_validator *v, · 22 unmodified lines
2323 struct dm_block *b,
2424 size_t block_size)
2525 {
26− struct node *n = dm_block_data(b);
26+ struct btree_node *n = dm_block_data(b);
2727 struct node_header *h = &n->header;
2828
2929 h->blocknr = cpu_to_le64(dm_block_location(b));
@@ -38,15 +38,15 @@ static int node_check(struct dm_block_validator *v, · 8 unmodified lines
3838 struct dm_block *b,
3939 size_t block_size)
4040 {
41− struct node *n = dm_block_data(b);
41+ struct btree_node *n = dm_block_data(b);
4242 struct node_header *h = &n->header;
4343 size_t value_size;
4444 __le32 csum_disk;
4545 uint32_t flags;
4646
4747 if (dm_block_location(b) != le64_to_cpu(h->blocknr)) {
48− DMERR("node_check failed blocknr %llu wanted %llu",
49− le64_to_cpu(h->blocknr), dm_block_location(b));
48+ DMERR_LIMIT("node_check failed: blocknr %llu != wanted %llu",
49+ le64_to_cpu(h->blocknr), dm_block_location(b));
5050 return -ENOTBLK;
5151 }
5252
@@ -54,8 +54,8 @@ static int node_check(struct dm_block_validator *v, · 1 unmodified line
5454 block_size - sizeof(__le32),
5555 BTREE_CSUM_XOR));
5656 if (csum_disk != h->csum) {
57− DMERR("node_check failed csum %u wanted %u",
58− le32_to_cpu(csum_disk), le32_to_cpu(h->csum));
57+ DMERR_LIMIT("node_check failed: csum %u != wanted %u",
58+ le32_to_cpu(csum_disk), le32_to_cpu(h->csum));
5959 return -EILSEQ;
6060 }
6161
@@ -63,12 +63,12 @@ static int node_check(struct dm_block_validator *v, · 1 unmodified line
6363
6464 if (sizeof(struct node_header) +
6565 (sizeof(__le64) + value_size) * le32_to_cpu(h->max_entries) > block_size) {
66− DMERR("node_check failed: max_entries too large");
66+ DMERR_LIMIT("node_check failed: max_entries too large");
6767 return -EILSEQ;
6868 }
6969
7070 if (le32_to_cpu(h->nr_entries) > le32_to_cpu(h->max_entries)) {
71− DMERR("node_check failed, too many entries");
71+ DMERR_LIMIT("node_check failed: too many entries");
7272 return -EILSEQ;
7373 }
7474
@@ -77,7 +77,7 @@ static int node_check(struct dm_block_validator *v, · 2 unmodified lines
7777 */
7878 flags = le32_to_cpu(h->flags);
7979 if (!(flags & INTERNAL_NODE) && !(flags & LEAF_NODE)) {
80− DMERR("node_check failed, node is neither INTERNAL or LEAF");
80+ DMERR_LIMIT("node_check failed: node is neither INTERNAL or LEAF");
8181 return -EILSEQ;
8282 }
8383
@@ -164,7 +164,7 @@ int ro_step(struct ro_spine *s, dm_block_t new_child) · 80 unmodified lines
164164 return r;
165165 }
166166
167−struct node *ro_node(struct ro_spine *s)
167+struct btree_node *ro_node(struct ro_spine *s)
168168 {
169169 struct dm_block *block;
170170
drivers/md/persistent-data/dm-btree.c+18−13
@@ -38,7 +38,7 @@ static void array_insert(void *base, size_t elt_size, unsigned nr_elts, · 37 unmodified lines
3838 /*----------------------------------------------------------------*/
3939
4040 /* makes the assumption that no two keys are the same. */
41−static int bsearch(struct node *n, uint64_t key, int want_hi)
41+static int bsearch(struct btree_node *n, uint64_t key, int want_hi)
4242 {
4343 int lo = -1, hi = le32_to_cpu(n->header.nr_entries);
4444
@@ -58,12 +58,12 @@ static int bsearch(struct node *n, uint64_t key, int want_hi) · 13 unmodified lines
5858 return want_hi ? hi : lo;
5959 }
6060
61−int lower_bound(struct node *n, uint64_t key)
61+int lower_bound(struct btree_node *n, uint64_t key)
6262 {
6363 return bsearch(n, key, 0);
6464 }
6565
66−void inc_children(struct dm_transaction_manager *tm, struct node *n,
66+void inc_children(struct dm_transaction_manager *tm, struct btree_node *n,
6767 struct dm_btree_value_type *vt)
6868 {
6969 unsigned i;
@@ -77,7 +77,7 @@ void inc_children(struct dm_transaction_manager *tm, struct node *n, · 7 unmodified lines
7777 vt->inc(vt->context, value_ptr(n, i));
7878 }
7979
80−static int insert_at(size_t value_size, struct node *node, unsigned index,
80+static int insert_at(size_t value_size, struct btree_node *node, unsigned index,
8181 uint64_t key, void *value)
8282 __dm_written_to_disk(value)
8383 {
@@ -122,7 +122,7 @@ int dm_btree_empty(struct dm_btree_info *info, dm_block_t *root) · 38 unmodified lines
122122 {
123123 int r;
124124 struct dm_block *b;
125− struct node *n;
125+ struct btree_node *n;
126126 size_t block_size;
127127 uint32_t max_entries;
128128
@@ -154,7 +154,7 @@ EXPORT_SYMBOL_GPL(dm_btree_empty); · 25 unmodified lines
154154 #define MAX_SPINE_DEPTH 64
155155 struct frame {
156156 struct dm_block *b;
157− struct node *n;
157+ struct btree_node *n;
158158 unsigned level;
159159 unsigned nr_children;
160160 unsigned current_child;
@@ -230,6 +230,11 @@ static void pop_frame(struct del_stack *s) · 69 unmodified lines
230230 dm_tm_unlock(s->tm, f->b);
231231 }
232232
233+static bool is_internal_level(struct dm_btree_info *info, struct frame *f)
234+{
235+ return f->level < (info->levels - 1);
236+}
237+
233238 int dm_btree_del(struct dm_btree_info *info, dm_block_t root)
234239 {
235240 int r;
@@ -241,7 +246,7 @@ int dm_btree_del(struct dm_btree_info *info, dm_block_t root) · 5 unmodified lines
241246 s->tm = info->tm;
242247 s->top = -1;
243248
244− r = push_frame(s, root, 1);
249+ r = push_frame(s, root, 0);
245250 if (r)
246251 goto out;
247252
@@ -267,7 +272,7 @@ int dm_btree_del(struct dm_btree_info *info, dm_block_t root) · 19 unmodified lines
267272 if (r)
268273 goto out;
269274
270− } else if (f->level != (info->levels - 1)) {
275+ } else if (is_internal_level(info, f)) {
271276 b = value64(f->n, f->current_child);
272277 f->current_child++;
273278 r = push_frame(s, b, f->level + 1);
@@ -295,7 +300,7 @@ EXPORT_SYMBOL_GPL(dm_btree_del); · 21 unmodified lines
295300 /*----------------------------------------------------------------*/
296301
297302 static int btree_lookup_raw(struct ro_spine *s, dm_block_t block, uint64_t key,
298− int (*search_fn)(struct node *, uint64_t),
303+ int (*search_fn)(struct btree_node *, uint64_t),
299304 uint64_t *result_key, void *v, size_t value_size)
300305 {
301306 int i, r;
@@ -406,7 +411,7 @@ static int btree_split_sibling(struct shadow_spine *s, dm_block_t root, · 104 unmodified lines
406411 size_t size;
407412 unsigned nr_left, nr_right;
408413 struct dm_block *left, *right, *parent;
409− struct node *ln, *rn, *pn;
414+ struct btree_node *ln, *rn, *pn;
410415 __le64 location;
411416
412417 left = shadow_current(s);
@@ -491,7 +496,7 @@ static int btree_split_beneath(struct shadow_spine *s, uint64_t key) · 78 unmodified lines
491496 size_t size;
492497 unsigned nr_left, nr_right;
493498 struct dm_block *left, *right, *new_parent;
494− struct node *pn, *ln, *rn;
499+ struct btree_node *pn, *ln, *rn;
495500 __le64 val;
496501
497502 new_parent = shadow_current(s);
@@ -576,7 +581,7 @@ static int btree_insert_raw(struct shadow_spine *s, dm_block_t root, · 78 unmodified lines
576581 uint64_t key, unsigned *index)
577582 {
578583 int r, i = *index, top = 1;
579− struct node *node;
584+ struct btree_node *node;
580585
581586 for (;;) {
582587 r = shadow_step(s, root, vt);
@@ -643,7 +648,7 @@ static int insert(struct dm_btree_info *info, dm_block_t root, · 60 unmodified lines
643648 unsigned level, index = -1, last_level = info->levels - 1;
644649 dm_block_t block = root;
645650 struct shadow_spine spine;
646− struct node *n;
651+ struct btree_node *n;
647652 struct dm_btree_value_type le64_type;
648653
649654 le64_type.context = NULL;
drivers/md/persistent-data/dm-space-map-common.c+8−8
@@ -39,8 +39,8 @@ static int index_check(struct dm_block_validator *v, · 38 unmodified lines
3939 __le32 csum_disk;
4040
4141 if (dm_block_location(b) != le64_to_cpu(mi_le->blocknr)) {
42− DMERR("index_check failed blocknr %llu wanted %llu",
43− le64_to_cpu(mi_le->blocknr), dm_block_location(b));
42+ DMERR_LIMIT("index_check failed: blocknr %llu != wanted %llu",
43+ le64_to_cpu(mi_le->blocknr), dm_block_location(b));
4444 return -ENOTBLK;
4545 }
4646
@@ -48,8 +48,8 @@ static int index_check(struct dm_block_validator *v, · 1 unmodified line
4848 block_size - sizeof(__le32),
4949 INDEX_CSUM_XOR));
5050 if (csum_disk != mi_le->csum) {
51− DMERR("index_check failed csum %u wanted %u",
52− le32_to_cpu(csum_disk), le32_to_cpu(mi_le->csum));
51+ DMERR_LIMIT("index_check failed: csum %u != wanted %u",
52+ le32_to_cpu(csum_disk), le32_to_cpu(mi_le->csum));
5353 return -EILSEQ;
5454 }
5555
@@ -89,8 +89,8 @@ static int bitmap_check(struct dm_block_validator *v, · 33 unmodified lines
8989 __le32 csum_disk;
9090
9191 if (dm_block_location(b) != le64_to_cpu(disk_header->blocknr)) {
92− DMERR("bitmap check failed blocknr %llu wanted %llu",
93− le64_to_cpu(disk_header->blocknr), dm_block_location(b));
92+ DMERR_LIMIT("bitmap check failed: blocknr %llu != wanted %llu",
93+ le64_to_cpu(disk_header->blocknr), dm_block_location(b));
9494 return -ENOTBLK;
9595 }
9696
@@ -98,8 +98,8 @@ static int bitmap_check(struct dm_block_validator *v, · 1 unmodified line
9898 block_size - sizeof(__le32),
9999 BITMAP_CSUM_XOR));
100100 if (csum_disk != disk_header->csum) {
101− DMERR("bitmap check failed csum %u wanted %u",
102− le32_to_cpu(csum_disk), le32_to_cpu(disk_header->csum));
101+ DMERR_LIMIT("bitmap check failed: csum %u != wanted %u",
102+ le32_to_cpu(csum_disk), le32_to_cpu(disk_header->csum));
103103 return -EILSEQ;
104104 }
105105
drivers/md/persistent-data/dm-space-map-metadata.c+1−1
@@ -337,7 +337,7 @@ static int sm_metadata_new_block(struct dm_space_map *sm, dm_block_t *b) · 336 unmodified lines
337337 {
338338 int r = sm_metadata_new_block_(sm, b);
339339 if (r)
340− DMERR("out of metadata space");
340+ DMERR("unable to allocate new metadata block");
341341 return r;
342342 }
343343
include/linux/device-mapper.h+47−8
@@ -23,7 +23,6 @@ typedef enum { STATUSTYPE_INFO, STATUSTYPE_TABLE } status_type_t; · 22 unmodified lines
2323 union map_info {
2424 void *ptr;
2525 unsigned long long ll;
26− unsigned target_request_nr;
2726 };
2827
2928 /*
@@ -46,8 +45,7 @@ typedef void (*dm_dtr_fn) (struct dm_target *ti); · 16 unmodified lines
4645 * = 1: simple remap complete
4746 * = 2: The target wants to push back the io
4847 */
49−typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio,
50− union map_info *map_context);
48+typedef int (*dm_map_fn) (struct dm_target *ti, struct bio *bio);
5149 typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *clone,
5250 union map_info *map_context);
5351
@@ -60,8 +58,7 @@ typedef int (*dm_map_request_fn) (struct dm_target *ti, struct request *clone, · 6 unmodified lines
6058 * 2 : The target wants to push back the io
6159 */
6260 typedef int (*dm_endio_fn) (struct dm_target *ti,
63− struct bio *bio, int error,
64− union map_info *map_context);
61+ struct bio *bio, int error);
6562 typedef int (*dm_request_endio_fn) (struct dm_target *ti,
6663 struct request *clone, int error,
6764 union map_info *map_context);
@@ -193,18 +190,30 @@ struct dm_target { · 125 unmodified lines
193190 * A number of zero-length barrier requests that will be submitted
194191 * to the target for the purpose of flushing cache.
195192 *
196− * The request number will be placed in union map_info->target_request_nr.
193+ * The request number can be accessed with dm_bio_get_target_request_nr.
197194 * It is a responsibility of the target driver to remap these requests
198195 * to the real underlying devices.
199196 */
200197 unsigned num_flush_requests;
201198
202199 /*
203− * The number of discard requests that will be submitted to the
204− * target. map_info->request_nr is used just like num_flush_requests.
200+ * The number of discard requests that will be submitted to the target.
201+ * The request number can be accessed with dm_bio_get_target_request_nr.
205202 */
206203 unsigned num_discard_requests;
207204
205+ /*
206+ * The number of WRITE SAME requests that will be submitted to the target.
207+ * The request number can be accessed with dm_bio_get_target_request_nr.
208+ */
209+ unsigned num_write_same_requests;
210+
211+ /*
212+ * The minimum number of extra bytes allocated in each bio for the
213+ * target to use. dm_per_bio_data returns the data location.
214+ */
215+ unsigned per_bio_data_size;
216+
208217 /* target specific data */
209218 void *private;
210219
@@ -241,6 +250,36 @@ struct dm_target_callbacks { · 30 unmodified lines
241250 int (*congested_fn) (struct dm_target_callbacks *, int);
242251 };
243252
253+/*
254+ * For bio-based dm.
255+ * One of these is allocated for each bio.
256+ * This structure shouldn't be touched directly by target drivers.
257+ * It is here so that we can inline dm_per_bio_data and
258+ * dm_bio_from_per_bio_data
259+ */
260+struct dm_target_io {
261+ struct dm_io *io;
262+ struct dm_target *ti;
263+ union map_info info;
264+ unsigned target_request_nr;
265+ struct bio clone;
266+};
267+
268+static inline void *dm_per_bio_data(struct bio *bio, size_t data_size)
269+{
270+ return (char *)bio - offsetof(struct dm_target_io, clone) - data_size;
271+}
272+
273+static inline struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size)
274+{
275+ return (struct bio *)((char *)data + data_size + offsetof(struct dm_target_io, clone));
276+}
277+
278+static inline unsigned dm_bio_get_target_request_nr(const struct bio *bio)
279+{
280+ return container_of(bio, struct dm_target_io, clone)->target_request_nr;
281+}
282+
244283 int dm_register_target(struct target_type *t);
245284 void dm_unregister_target(struct target_type *t);
246285
include/uapi/linux/dm-ioctl.h+2−2
@@ -268,8 +268,8 @@ enum { · 267 unmodified lines
268268
269269 #define DM_VERSION_MAJOR 4
270270 #define DM_VERSION_MINOR 23
271−#define DM_VERSION_PATCHLEVEL 0
272−#define DM_VERSION_EXTRA "-ioctl (2012-07-25)"
271+#define DM_VERSION_PATCHLEVEL 1
272+#define DM_VERSION_EXTRA "-ioctl (2012-12-18)"
273273
274274 /* Status bits */
275275 #define DM_READONLY_FLAG (1 << 0) /* In/Out */