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

Merge tag 'for-4.21/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper updates from Mike Snitzer:

- Eliminate a couple indirect calls from bio-based DM core.

- Fix DM to allow reads that exceed readahead limits by setting
io_pages in the backing_dev_info.

- A couple code cleanups in request-based DM.

- Fix various DM targets to check for device sector overflow if
CONFIG_LBDAF is not set.

- Use u64 instead of sector_t to store iv_offset in DM crypt; sector_t
isn't large enough on 32bit when CONFIG_LBDAF is not set.

- Performance fixes to DM's kcopyd and the snapshot target focused on
limiting memory use and workqueue stalls.

- Fix typos in the integrity and writecache targets.

- Log which algorithm is used for dm-crypt's encryption and
dm-integrity's hashing.

- Fix false -EBUSY errors in DM raid target's handling of check/repair
messages.

- Fix DM flakey target's corrupt_bio_byte feature to reliably corrupt
the Nth byte in a bio's payload.

* tag 'for-4.21/dm-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm: do not allow readahead to limit IO size
dm raid: fix false -EBUSY when handling check/repair message
dm rq: cleanup leftover code from recently removed q->mq_ops branching
dm verity: log the hash algorithm implementation
dm crypt: log the encryption algorithm implementation
dm integrity: fix spelling mistake in workqueue name
dm flakey: Properly corrupt multi-page bios.
dm: Check for device sector overflow if CONFIG_LBDAF is not set
dm crypt: use u64 instead of sector_t to store iv_offset
dm kcopyd: Fix bug causing workqueue stalls
dm snapshot: Fix excessive memory usage and workqueue stalls
dm bufio: update comment in dm-bufio.c
dm writecache: fix typo in error msg for creating writecache_flush_thread
dm: remove indirect calls from __send_changing_extent_only()
dm mpath: only flush workqueue when needed
dm rq: remove unused arguments from rq_completed()
dm: avoid indirect call in __dm_make_request

+121 -82
+6 -6
drivers/md/dm-bufio.c
··· 65 65 66 66 /* 67 67 * Linking of buffers: 68 - * All buffers are linked to cache_hash with their hash_list field. 68 + * All buffers are linked to buffer_tree with their node field. 69 69 * 70 70 * Clean buffers that are not being written (B_WRITING not set) 71 71 * are linked to lru[LIST_CLEAN] with their lru_list field. ··· 457 457 } 458 458 459 459 /* 460 - * Link buffer to the hash list and clean or dirty queue. 460 + * Link buffer to the buffer tree and clean or dirty queue. 461 461 */ 462 462 static void __link_buffer(struct dm_buffer *b, sector_t block, int dirty) 463 463 { ··· 472 472 } 473 473 474 474 /* 475 - * Unlink buffer from the hash list and dirty or clean queue. 475 + * Unlink buffer from the buffer tree and dirty or clean queue. 476 476 */ 477 477 static void __unlink_buffer(struct dm_buffer *b) 478 478 { ··· 993 993 994 994 /* 995 995 * We've had a period where the mutex was unlocked, so need to 996 - * recheck the hash table. 996 + * recheck the buffer tree. 997 997 */ 998 998 b = __find(c, block); 999 999 if (b) { ··· 1327 1327 EXPORT_SYMBOL_GPL(dm_bufio_write_dirty_buffers); 1328 1328 1329 1329 /* 1330 - * Use dm-io to send and empty barrier flush the device. 1330 + * Use dm-io to send an empty barrier to flush the device. 1331 1331 */ 1332 1332 int dm_bufio_issue_flush(struct dm_bufio_client *c) 1333 1333 { ··· 1356 1356 * Then, we write the buffer to the original location if it was dirty. 1357 1357 * 1358 1358 * Then, if we are the only one who is holding the buffer, relink the buffer 1359 - * in the hash queue for the new location. 1359 + * in the buffer tree for the new location. 1360 1360 * 1361 1361 * If there was someone else holding the buffer, we write it to the new 1362 1362 * location but not relink it, because that other user needs to have the buffer
+13 -4
drivers/md/dm-crypt.c
··· 49 49 struct bio *bio_out; 50 50 struct bvec_iter iter_in; 51 51 struct bvec_iter iter_out; 52 - sector_t cc_sector; 52 + u64 cc_sector; 53 53 atomic_t cc_pending; 54 54 union { 55 55 struct skcipher_request *req; ··· 81 81 struct convert_context *ctx; 82 82 struct scatterlist sg_in[4]; 83 83 struct scatterlist sg_out[4]; 84 - sector_t iv_sector; 84 + u64 iv_sector; 85 85 }; 86 86 87 87 struct crypt_config; ··· 160 160 struct iv_lmk_private lmk; 161 161 struct iv_tcw_private tcw; 162 162 } iv_gen_private; 163 - sector_t iv_offset; 163 + u64 iv_offset; 164 164 unsigned int iv_size; 165 165 unsigned short int sector_size; 166 166 unsigned char sector_shift; ··· 1885 1885 } 1886 1886 } 1887 1887 1888 + /* 1889 + * dm-crypt performance can vary greatly depending on which crypto 1890 + * algorithm implementation is used. Help people debug performance 1891 + * problems by logging the ->cra_driver_name. 1892 + */ 1893 + DMINFO("%s using implementation \"%s\"", ciphermode, 1894 + crypto_skcipher_alg(any_tfm(cc))->base.cra_driver_name); 1888 1895 return 0; 1889 1896 } 1890 1897 ··· 1910 1903 return err; 1911 1904 } 1912 1905 1906 + DMINFO("%s using implementation \"%s\"", ciphermode, 1907 + crypto_aead_alg(any_tfm_aead(cc))->base.cra_driver_name); 1913 1908 return 0; 1914 1909 } 1915 1910 ··· 2790 2781 } 2791 2782 2792 2783 ret = -EINVAL; 2793 - if (sscanf(argv[4], "%llu%c", &tmpll, &dummy) != 1) { 2784 + if (sscanf(argv[4], "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { 2794 2785 ti->error = "Invalid device sector"; 2795 2786 goto bad; 2796 2787 }
+1 -1
drivers/md/dm-delay.c
··· 141 141 unsigned long long tmpll; 142 142 char dummy; 143 143 144 - if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1) { 144 + if (sscanf(argv[1], "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { 145 145 ti->error = "Invalid device sector"; 146 146 return -EINVAL; 147 147 }
+23 -12
drivers/md/dm-flakey.c
··· 213 213 devname = dm_shift_arg(&as); 214 214 215 215 r = -EINVAL; 216 - if (sscanf(dm_shift_arg(&as), "%llu%c", &tmpll, &dummy) != 1) { 216 + if (sscanf(dm_shift_arg(&as), "%llu%c", &tmpll, &dummy) != 1 || tmpll != (sector_t)tmpll) { 217 217 ti->error = "Invalid device sector"; 218 218 goto bad; 219 219 } ··· 287 287 288 288 static void corrupt_bio_data(struct bio *bio, struct flakey_c *fc) 289 289 { 290 - unsigned bio_bytes = bio_cur_bytes(bio); 291 - char *data = bio_data(bio); 290 + unsigned int corrupt_bio_byte = fc->corrupt_bio_byte - 1; 291 + 292 + struct bvec_iter iter; 293 + struct bio_vec bvec; 294 + 295 + if (!bio_has_data(bio)) 296 + return; 292 297 293 298 /* 294 - * Overwrite the Nth byte of the data returned. 299 + * Overwrite the Nth byte of the bio's data, on whichever page 300 + * it falls. 295 301 */ 296 - if (data && bio_bytes >= fc->corrupt_bio_byte) { 297 - data[fc->corrupt_bio_byte - 1] = fc->corrupt_bio_value; 298 - 299 - DMDEBUG("Corrupting data bio=%p by writing %u to byte %u " 300 - "(rw=%c bi_opf=%u bi_sector=%llu cur_bytes=%u)\n", 301 - bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, 302 - (bio_data_dir(bio) == WRITE) ? 'w' : 'r', bio->bi_opf, 303 - (unsigned long long)bio->bi_iter.bi_sector, bio_bytes); 302 + bio_for_each_segment(bvec, bio, iter) { 303 + if (bio_iter_len(bio, iter) > corrupt_bio_byte) { 304 + char *segment = (page_address(bio_iter_page(bio, iter)) 305 + + bio_iter_offset(bio, iter)); 306 + segment[corrupt_bio_byte] = fc->corrupt_bio_value; 307 + DMDEBUG("Corrupting data bio=%p by writing %u to byte %u " 308 + "(rw=%c bi_opf=%u bi_sector=%llu size=%u)\n", 309 + bio, fc->corrupt_bio_value, fc->corrupt_bio_byte, 310 + (bio_data_dir(bio) == WRITE) ? 'w' : 'r', bio->bi_opf, 311 + (unsigned long long)bio->bi_iter.bi_sector, bio->bi_iter.bi_size); 312 + break; 313 + } 314 + corrupt_bio_byte -= bio_iter_len(bio, iter); 304 315 } 305 316 } 306 317
+1 -1
drivers/md/dm-integrity.c
··· 3460 3460 ti->error = "Recalculate is only valid with internal hash"; 3461 3461 goto bad; 3462 3462 } 3463 - ic->recalc_wq = alloc_workqueue("dm-intergrity-recalc", WQ_MEM_RECLAIM, 1); 3463 + ic->recalc_wq = alloc_workqueue("dm-integrity-recalc", WQ_MEM_RECLAIM, 1); 3464 3464 if (!ic->recalc_wq ) { 3465 3465 ti->error = "Cannot allocate workqueue"; 3466 3466 r = -ENOMEM;
+14 -5
drivers/md/dm-kcopyd.c
··· 56 56 atomic_t nr_jobs; 57 57 58 58 /* 59 - * We maintain three lists of jobs: 59 + * We maintain four lists of jobs: 60 60 * 61 61 * i) jobs waiting for pages 62 62 * ii) jobs that have pages, and are waiting for the io to be issued. 63 - * iii) jobs that have completed. 63 + * iii) jobs that don't need to do any IO and just run a callback 64 + * iv) jobs that have completed. 64 65 * 65 - * All three of these are protected by job_lock. 66 + * All four of these are protected by job_lock. 66 67 */ 67 68 spinlock_t job_lock; 69 + struct list_head callback_jobs; 68 70 struct list_head complete_jobs; 69 71 struct list_head io_jobs; 70 72 struct list_head pages_jobs; ··· 627 625 struct dm_kcopyd_client *kc = container_of(work, 628 626 struct dm_kcopyd_client, kcopyd_work); 629 627 struct blk_plug plug; 628 + unsigned long flags; 630 629 631 630 /* 632 631 * The order that these are called is *very* important. ··· 636 633 * list. io jobs call wake when they complete and it all 637 634 * starts again. 638 635 */ 636 + spin_lock_irqsave(&kc->job_lock, flags); 637 + list_splice_tail_init(&kc->callback_jobs, &kc->complete_jobs); 638 + spin_unlock_irqrestore(&kc->job_lock, flags); 639 + 639 640 blk_start_plug(&plug); 640 641 process_jobs(&kc->complete_jobs, kc, run_complete_job); 641 642 process_jobs(&kc->pages_jobs, kc, run_pages_job); ··· 657 650 struct dm_kcopyd_client *kc = job->kc; 658 651 atomic_inc(&kc->nr_jobs); 659 652 if (unlikely(!job->source.count)) 660 - push(&kc->complete_jobs, job); 653 + push(&kc->callback_jobs, job); 661 654 else if (job->pages == &zero_page_list) 662 655 push(&kc->io_jobs, job); 663 656 else ··· 865 858 job->read_err = read_err; 866 859 job->write_err = write_err; 867 860 868 - push(&kc->complete_jobs, job); 861 + push(&kc->callback_jobs, job); 869 862 wake(kc); 870 863 } 871 864 EXPORT_SYMBOL(dm_kcopyd_do_callback); ··· 895 888 return ERR_PTR(-ENOMEM); 896 889 897 890 spin_lock_init(&kc->job_lock); 891 + INIT_LIST_HEAD(&kc->callback_jobs); 898 892 INIT_LIST_HEAD(&kc->complete_jobs); 899 893 INIT_LIST_HEAD(&kc->io_jobs); 900 894 INIT_LIST_HEAD(&kc->pages_jobs); ··· 947 939 /* Wait for completion of all jobs submitted by this client. */ 948 940 wait_event(kc->destroyq, !atomic_read(&kc->nr_jobs)); 949 941 942 + BUG_ON(!list_empty(&kc->callback_jobs)); 950 943 BUG_ON(!list_empty(&kc->complete_jobs)); 951 944 BUG_ON(!list_empty(&kc->io_jobs)); 952 945 BUG_ON(!list_empty(&kc->pages_jobs));
+1 -1
drivers/md/dm-linear.c
··· 45 45 } 46 46 47 47 ret = -EINVAL; 48 - if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1) { 48 + if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 || tmp != (sector_t)tmp) { 49 49 ti->error = "Invalid device sector"; 50 50 goto bad; 51 51 }
+4 -2
drivers/md/dm-mpath.c
··· 1211 1211 set_bit(MPATHF_PG_INIT_DISABLED, &m->flags); 1212 1212 smp_mb__after_atomic(); 1213 1213 1214 - flush_workqueue(kmpath_handlerd); 1214 + if (atomic_read(&m->pg_init_in_progress)) 1215 + flush_workqueue(kmpath_handlerd); 1215 1216 multipath_wait_for_pg_init_completion(m); 1216 1217 1217 1218 clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags); 1218 1219 smp_mb__after_atomic(); 1219 1220 } 1220 1221 1221 - flush_workqueue(kmultipathd); 1222 + if (m->queue_mode == DM_TYPE_BIO_BASED) 1223 + flush_work(&m->process_queued_bios); 1222 1224 flush_work(&m->trigger_event); 1223 1225 } 1224 1226
+1 -2
drivers/md/dm-raid.c
··· 3690 3690 set_bit(MD_RECOVERY_INTR, &mddev->recovery); 3691 3691 md_reap_sync_thread(mddev); 3692 3692 } 3693 - } else if (test_bit(MD_RECOVERY_RUNNING, &mddev->recovery) || 3694 - test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) 3693 + } else if (decipher_sync_action(mddev, mddev->recovery) != st_idle) 3695 3694 return -EBUSY; 3696 3695 else if (!strcasecmp(argv[0], "resync")) 3697 3696 ; /* MD_RECOVERY_NEEDED set below */
+2 -1
drivers/md/dm-raid1.c
··· 943 943 char dummy; 944 944 int ret; 945 945 946 - if (sscanf(argv[1], "%llu%c", &offset, &dummy) != 1) { 946 + if (sscanf(argv[1], "%llu%c", &offset, &dummy) != 1 || 947 + offset != (sector_t)offset) { 947 948 ti->error = "Invalid offset"; 948 949 return -EINVAL; 949 950 }
+6 -12
drivers/md/dm-rq.c
··· 128 128 * the md may be freed in dm_put() at the end of this function. 129 129 * Or do dm_get() before calling this function and dm_put() later. 130 130 */ 131 - static void rq_completed(struct mapped_device *md, int rw, bool run_queue) 131 + static void rq_completed(struct mapped_device *md) 132 132 { 133 133 /* nudge anyone waiting on suspend queue */ 134 134 if (unlikely(waitqueue_active(&md->wait))) ··· 147 147 */ 148 148 static void dm_end_request(struct request *clone, blk_status_t error) 149 149 { 150 - int rw = rq_data_dir(clone); 151 150 struct dm_rq_target_io *tio = clone->end_io_data; 152 151 struct mapped_device *md = tio->md; 153 152 struct request *rq = tio->orig; ··· 156 157 157 158 rq_end_stats(md, rq); 158 159 blk_mq_end_request(rq, error); 159 - rq_completed(md, rw, true); 160 + rq_completed(md); 160 161 } 161 162 162 163 static void __dm_mq_kick_requeue_list(struct request_queue *q, unsigned long msecs) ··· 180 181 { 181 182 struct mapped_device *md = tio->md; 182 183 struct request *rq = tio->orig; 183 - int rw = rq_data_dir(rq); 184 184 unsigned long delay_ms = delay_requeue ? 100 : 0; 185 185 186 186 rq_end_stats(md, rq); ··· 189 191 } 190 192 191 193 dm_mq_delay_requeue_request(rq, delay_ms); 192 - rq_completed(md, rw, false); 194 + rq_completed(md); 193 195 } 194 196 195 197 static void dm_done(struct request *clone, blk_status_t error, bool mapped) ··· 244 246 bool mapped = true; 245 247 struct dm_rq_target_io *tio = tio_from_request(rq); 246 248 struct request *clone = tio->clone; 247 - int rw; 248 249 249 250 if (!clone) { 250 251 struct mapped_device *md = tio->md; 251 252 252 253 rq_end_stats(md, rq); 253 - rw = rq_data_dir(rq); 254 254 blk_mq_end_request(rq, tio->error); 255 - rq_completed(md, rw, false); 255 + rq_completed(md); 256 256 return; 257 257 } 258 258 ··· 372 376 blk_status_t ret; 373 377 374 378 r = ti->type->clone_and_map_rq(ti, rq, &tio->info, &clone); 375 - check_again: 376 379 switch (r) { 377 380 case DM_MAPIO_SUBMITTED: 378 381 /* The target has taken the I/O to submit by itself later */ ··· 391 396 blk_rq_unprep_clone(clone); 392 397 tio->ti->type->release_clone_rq(clone); 393 398 tio->clone = NULL; 394 - r = DM_MAPIO_REQUEUE; 395 - goto check_again; 399 + return DM_MAPIO_REQUEUE; 396 400 } 397 401 break; 398 402 case DM_MAPIO_REQUEUE: ··· 501 507 if (map_request(tio) == DM_MAPIO_REQUEUE) { 502 508 /* Undo dm_start_request() before requeuing */ 503 509 rq_end_stats(md, rq); 504 - rq_completed(md, rq_data_dir(rq), false); 510 + rq_completed(md); 505 511 return BLK_STS_RESOURCE; 506 512 } 507 513
+22
drivers/md/dm-snap.c
··· 19 19 #include <linux/vmalloc.h> 20 20 #include <linux/log2.h> 21 21 #include <linux/dm-kcopyd.h> 22 + #include <linux/semaphore.h> 22 23 23 24 #include "dm.h" 24 25 ··· 106 105 /* The on disk metadata handler */ 107 106 struct dm_exception_store *store; 108 107 108 + /* Maximum number of in-flight COW jobs. */ 109 + struct semaphore cow_count; 110 + 109 111 struct dm_kcopyd_client *kcopyd_client; 110 112 111 113 /* Wait for events based on state_bits */ ··· 148 144 */ 149 145 #define RUNNING_MERGE 0 150 146 #define SHUTDOWN_MERGE 1 147 + 148 + /* 149 + * Maximum number of chunks being copied on write. 150 + * 151 + * The value was decided experimentally as a trade-off between memory 152 + * consumption, stalling the kernel's workqueues and maintaining a high enough 153 + * throughput. 154 + */ 155 + #define DEFAULT_COW_THRESHOLD 2048 156 + 157 + static int cow_threshold = DEFAULT_COW_THRESHOLD; 158 + module_param_named(snapshot_cow_threshold, cow_threshold, int, 0644); 159 + MODULE_PARM_DESC(snapshot_cow_threshold, "Maximum number of chunks being copied on write"); 151 160 152 161 DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(snapshot_copy_throttle, 153 162 "A percentage of time allocated for copy on write"); ··· 1207 1190 goto bad_hash_tables; 1208 1191 } 1209 1192 1193 + sema_init(&s->cow_count, (cow_threshold > 0) ? cow_threshold : INT_MAX); 1194 + 1210 1195 s->kcopyd_client = dm_kcopyd_client_create(&dm_kcopyd_throttle); 1211 1196 if (IS_ERR(s->kcopyd_client)) { 1212 1197 r = PTR_ERR(s->kcopyd_client); ··· 1594 1575 rb_link_node(&pe->out_of_order_node, parent, p); 1595 1576 rb_insert_color(&pe->out_of_order_node, &s->out_of_order_tree); 1596 1577 } 1578 + up(&s->cow_count); 1597 1579 } 1598 1580 1599 1581 /* ··· 1618 1598 dest.count = src.count; 1619 1599 1620 1600 /* Hand over to kcopyd */ 1601 + down(&s->cow_count); 1621 1602 dm_kcopyd_copy(s->kcopyd_client, &src, 1, &dest, 0, copy_callback, pe); 1622 1603 } 1623 1604 ··· 1638 1617 pe->full_bio = bio; 1639 1618 pe->full_bio_end_io = bio->bi_end_io; 1640 1619 1620 + down(&s->cow_count); 1641 1621 callback_data = dm_kcopyd_prepare_callback(s->kcopyd_client, 1642 1622 copy_callback, pe); 1643 1623
+3
drivers/md/dm-table.c
··· 1927 1927 */ 1928 1928 if (blk_queue_is_zoned(q)) 1929 1929 blk_revalidate_disk_zones(t->md->disk); 1930 + 1931 + /* Allow reads to exceed readahead limits */ 1932 + q->backing_dev_info->io_pages = limits->max_sectors >> (PAGE_SHIFT - 9); 1930 1933 } 1931 1934 1932 1935 unsigned int dm_table_get_num_targets(struct dm_table *t)
+1 -1
drivers/md/dm-unstripe.c
··· 78 78 goto err; 79 79 } 80 80 81 - if (sscanf(argv[4], "%llu%c", &start, &dummy) != 1) { 81 + if (sscanf(argv[4], "%llu%c", &start, &dummy) != 1 || start != (sector_t)start) { 82 82 ti->error = "Invalid striped device offset"; 83 83 goto err; 84 84 }
+9
drivers/md/dm-verity-target.c
··· 1040 1040 v->tfm = NULL; 1041 1041 goto bad; 1042 1042 } 1043 + 1044 + /* 1045 + * dm-verity performance can vary greatly depending on which hash 1046 + * algorithm implementation is used. Help people debug performance 1047 + * problems by logging the ->cra_driver_name. 1048 + */ 1049 + DMINFO("%s using implementation \"%s\"", v->alg_name, 1050 + crypto_hash_alg_common(v->tfm)->base.cra_driver_name); 1051 + 1043 1052 v->digest_size = crypto_ahash_digestsize(v->tfm); 1044 1053 if ((1 << v->hash_dev_block_bits) < v->digest_size * 2) { 1045 1054 ti->error = "Digest size too big";
+1 -1
drivers/md/dm-writecache.c
··· 2061 2061 if (IS_ERR(wc->flush_thread)) { 2062 2062 r = PTR_ERR(wc->flush_thread); 2063 2063 wc->flush_thread = NULL; 2064 - ti->error = "Couldn't spawn endio thread"; 2064 + ti->error = "Couldn't spawn flush thread"; 2065 2065 goto bad; 2066 2066 } 2067 2067 wake_up_process(wc->flush_thread);
+13 -33
drivers/md/dm.c
··· 1486 1486 } 1487 1487 1488 1488 static int __send_changing_extent_only(struct clone_info *ci, struct dm_target *ti, 1489 - get_num_bios_fn get_num_bios, 1490 - is_split_required_fn is_split_required) 1489 + unsigned num_bios, bool is_split_required) 1491 1490 { 1492 1491 unsigned len; 1493 - unsigned num_bios; 1494 1492 1495 1493 /* 1496 1494 * Even though the device advertised support for this type of ··· 1496 1498 * reconfiguration might also have changed that since the 1497 1499 * check was performed. 1498 1500 */ 1499 - num_bios = get_num_bios ? get_num_bios(ti) : 0; 1500 1501 if (!num_bios) 1501 1502 return -EOPNOTSUPP; 1502 1503 1503 - if (is_split_required && !is_split_required(ti)) 1504 + if (!is_split_required) 1504 1505 len = min((sector_t)ci->sector_count, max_io_len_target_boundary(ci->sector, ti)); 1505 1506 else 1506 1507 len = min((sector_t)ci->sector_count, max_io_len(ci->sector, ti)); ··· 1514 1517 1515 1518 static int __send_discard(struct clone_info *ci, struct dm_target *ti) 1516 1519 { 1517 - return __send_changing_extent_only(ci, ti, get_num_discard_bios, 1518 - is_split_required_for_discard); 1520 + return __send_changing_extent_only(ci, ti, get_num_discard_bios(ti), 1521 + is_split_required_for_discard(ti)); 1519 1522 } 1520 1523 1521 1524 static int __send_secure_erase(struct clone_info *ci, struct dm_target *ti) 1522 1525 { 1523 - return __send_changing_extent_only(ci, ti, get_num_secure_erase_bios, NULL); 1526 + return __send_changing_extent_only(ci, ti, get_num_secure_erase_bios(ti), false); 1524 1527 } 1525 1528 1526 1529 static int __send_write_same(struct clone_info *ci, struct dm_target *ti) 1527 1530 { 1528 - return __send_changing_extent_only(ci, ti, get_num_write_same_bios, NULL); 1531 + return __send_changing_extent_only(ci, ti, get_num_write_same_bios(ti), false); 1529 1532 } 1530 1533 1531 1534 static int __send_write_zeroes(struct clone_info *ci, struct dm_target *ti) 1532 1535 { 1533 - return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios, NULL); 1536 + return __send_changing_extent_only(ci, ti, get_num_write_zeroes_bios(ti), false); 1534 1537 } 1535 1538 1536 1539 static bool __process_abnormal_io(struct clone_info *ci, struct dm_target *ti, ··· 1713 1716 return ret; 1714 1717 } 1715 1718 1716 - typedef blk_qc_t (process_bio_fn)(struct mapped_device *, struct dm_table *, struct bio *); 1717 - 1718 - static blk_qc_t __dm_make_request(struct request_queue *q, struct bio *bio, 1719 - process_bio_fn process_bio) 1719 + static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio) 1720 1720 { 1721 1721 struct mapped_device *md = q->queuedata; 1722 1722 blk_qc_t ret = BLK_QC_T_NONE; ··· 1733 1739 return ret; 1734 1740 } 1735 1741 1736 - ret = process_bio(md, map, bio); 1742 + if (dm_get_md_type(md) == DM_TYPE_NVME_BIO_BASED) 1743 + ret = __process_bio(md, map, bio); 1744 + else 1745 + ret = __split_and_process_bio(md, map, bio); 1737 1746 1738 1747 dm_put_live_table(md, srcu_idx); 1739 1748 return ret; 1740 - } 1741 - 1742 - /* 1743 - * The request function that remaps the bio to one target and 1744 - * splits off any remainder. 1745 - */ 1746 - static blk_qc_t dm_make_request(struct request_queue *q, struct bio *bio) 1747 - { 1748 - return __dm_make_request(q, bio, __split_and_process_bio); 1749 - } 1750 - 1751 - static blk_qc_t dm_make_request_nvme(struct request_queue *q, struct bio *bio) 1752 - { 1753 - return __dm_make_request(q, bio, __process_bio); 1754 1749 } 1755 1750 1756 1751 static int dm_any_congested(void *congested_data, int bdi_bits) ··· 2229 2246 break; 2230 2247 case DM_TYPE_BIO_BASED: 2231 2248 case DM_TYPE_DAX_BIO_BASED: 2232 - dm_init_normal_md_queue(md); 2233 - blk_queue_make_request(md->queue, dm_make_request); 2234 - break; 2235 2249 case DM_TYPE_NVME_BIO_BASED: 2236 2250 dm_init_normal_md_queue(md); 2237 - blk_queue_make_request(md->queue, dm_make_request_nvme); 2251 + blk_queue_make_request(md->queue, dm_make_request); 2238 2252 break; 2239 2253 case DM_TYPE_NONE: 2240 2254 WARN_ON_ONCE(true);