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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-4.16/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:

- Fix an uninitialized variable false warning in dm bufio

- Fix DM's passthrough ioctl support to be race free against an
underlying device being removed.

- Fix corner-case of DM raid resync reporting if/when the raid becomes
degraded during resync; otherwise automated raid repair will fail.

- A few DM multipath fixes to make non-SCSI optimizations, that were
introduced during the 4.16 merge, useful for all non-SCSI devices,
rather than narrowly define this non-SCSI mode in terms of "nvme".

This allows the removal of "queue_mode nvme" that really didn't need
to be introduced. Instead DM core will internalize whether
nvme-specific IO submission optimizations are doable and DM multipath
will only do SCSI-specific device handler operations if SCSI is in
use.

* tag 'for-4.16/dm-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
dm table: allow upgrade from bio-based to specialized bio-based variant
dm mpath: remove unnecessary NVMe branching in favor of scsi_dh checks
dm table: fix "nvme" test
dm raid: fix incorrect sync_ratio when degraded
dm: use blkdev_get rather than bdgrab when issuing pass-through ioctl
dm bufio: avoid false-positive Wmaybe-uninitialized warning

+65 -75
+6 -10
drivers/md/dm-bufio.c
··· 386 386 static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask, 387 387 enum data_mode *data_mode) 388 388 { 389 - unsigned noio_flag; 390 - void *ptr; 391 - 392 389 if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) { 393 390 *data_mode = DATA_MODE_SLAB; 394 391 return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask); ··· 409 412 * all allocations done by this process (including pagetables) are done 410 413 * as if GFP_NOIO was specified. 411 414 */ 415 + if (gfp_mask & __GFP_NORETRY) { 416 + unsigned noio_flag = memalloc_noio_save(); 417 + void *ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL); 412 418 413 - if (gfp_mask & __GFP_NORETRY) 414 - noio_flag = memalloc_noio_save(); 415 - 416 - ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL); 417 - 418 - if (gfp_mask & __GFP_NORETRY) 419 419 memalloc_noio_restore(noio_flag); 420 + return ptr; 421 + } 420 422 421 - return ptr; 423 + return __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL); 422 424 } 423 425 424 426 /*
+29 -37
drivers/md/dm-mpath.c
··· 22 22 #include <linux/time.h> 23 23 #include <linux/workqueue.h> 24 24 #include <linux/delay.h> 25 + #include <scsi/scsi_device.h> 25 26 #include <scsi/scsi_dh.h> 26 27 #include <linux/atomic.h> 27 28 #include <linux/blk-mq.h> ··· 212 211 else 213 212 m->queue_mode = DM_TYPE_REQUEST_BASED; 214 213 215 - } else if (m->queue_mode == DM_TYPE_BIO_BASED || 216 - m->queue_mode == DM_TYPE_NVME_BIO_BASED) { 214 + } else if (m->queue_mode == DM_TYPE_BIO_BASED) { 217 215 INIT_WORK(&m->process_queued_bios, process_queued_bios); 218 - 219 - if (m->queue_mode == DM_TYPE_BIO_BASED) { 220 - /* 221 - * bio-based doesn't support any direct scsi_dh management; 222 - * it just discovers if a scsi_dh is attached. 223 - */ 224 - set_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags); 225 - } 226 - } 227 - 228 - if (m->queue_mode != DM_TYPE_NVME_BIO_BASED) { 229 - set_bit(MPATHF_QUEUE_IO, &m->flags); 230 - atomic_set(&m->pg_init_in_progress, 0); 231 - atomic_set(&m->pg_init_count, 0); 232 - m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT; 233 - init_waitqueue_head(&m->pg_init_wait); 216 + /* 217 + * bio-based doesn't support any direct scsi_dh management; 218 + * it just discovers if a scsi_dh is attached. 219 + */ 220 + set_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags); 234 221 } 235 222 236 223 dm_table_set_type(ti->table, m->queue_mode); ··· 326 337 { 327 338 m->current_pg = pg; 328 339 329 - if (m->queue_mode == DM_TYPE_NVME_BIO_BASED) 330 - return; 331 - 332 340 /* Must we initialise the PG first, and queue I/O till it's ready? */ 333 341 if (m->hw_handler_name) { 334 342 set_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); 335 343 set_bit(MPATHF_QUEUE_IO, &m->flags); 336 344 } else { 345 + /* FIXME: not needed if no scsi_dh is attached */ 337 346 clear_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); 338 347 clear_bit(MPATHF_QUEUE_IO, &m->flags); 339 348 } ··· 372 385 unsigned bypassed = 1; 373 386 374 387 if (!atomic_read(&m->nr_valid_paths)) { 375 - if (m->queue_mode != DM_TYPE_NVME_BIO_BASED) 376 - clear_bit(MPATHF_QUEUE_IO, &m->flags); 388 + clear_bit(MPATHF_QUEUE_IO, &m->flags); 377 389 goto failed; 378 390 } 379 391 ··· 585 599 return pgpath; 586 600 } 587 601 588 - static struct pgpath *__map_bio_nvme(struct multipath *m, struct bio *bio) 602 + static struct pgpath *__map_bio_fast(struct multipath *m, struct bio *bio) 589 603 { 590 604 struct pgpath *pgpath; 591 605 unsigned long flags; ··· 620 634 { 621 635 struct pgpath *pgpath; 622 636 623 - if (m->queue_mode == DM_TYPE_NVME_BIO_BASED) 624 - pgpath = __map_bio_nvme(m, bio); 637 + if (!m->hw_handler_name) 638 + pgpath = __map_bio_fast(m, bio); 625 639 else 626 640 pgpath = __map_bio(m, bio); 627 641 ··· 661 675 { 662 676 if (m->queue_mode == DM_TYPE_MQ_REQUEST_BASED) 663 677 dm_mq_kick_requeue_list(dm_table_get_md(m->ti->table)); 664 - else if (m->queue_mode == DM_TYPE_BIO_BASED || 665 - m->queue_mode == DM_TYPE_NVME_BIO_BASED) 678 + else if (m->queue_mode == DM_TYPE_BIO_BASED) 666 679 queue_work(kmultipathd, &m->process_queued_bios); 667 680 } 668 681 ··· 823 838 */ 824 839 kfree(m->hw_handler_name); 825 840 m->hw_handler_name = attached_handler_name; 841 + 842 + /* 843 + * Init fields that are only used when a scsi_dh is attached 844 + */ 845 + if (!test_and_set_bit(MPATHF_QUEUE_IO, &m->flags)) { 846 + atomic_set(&m->pg_init_in_progress, 0); 847 + atomic_set(&m->pg_init_count, 0); 848 + m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT; 849 + init_waitqueue_head(&m->pg_init_wait); 850 + } 826 851 } 827 852 } 828 853 ··· 868 873 int r; 869 874 struct pgpath *p; 870 875 struct multipath *m = ti->private; 876 + struct scsi_device *sdev; 871 877 872 878 /* we need at least a path arg */ 873 879 if (as->argc < 1) { ··· 887 891 goto bad; 888 892 } 889 893 890 - if (m->queue_mode != DM_TYPE_NVME_BIO_BASED) { 894 + sdev = scsi_device_from_queue(bdev_get_queue(p->path.dev->bdev)); 895 + if (sdev) { 896 + put_device(&sdev->sdev_gendev); 891 897 INIT_DELAYED_WORK(&p->activate_path, activate_path_work); 892 898 r = setup_scsi_dh(p->path.dev->bdev, m, &ti->error); 893 899 if (r) { ··· 999 1001 if (!hw_argc) 1000 1002 return 0; 1001 1003 1002 - if (m->queue_mode == DM_TYPE_BIO_BASED || 1003 - m->queue_mode == DM_TYPE_NVME_BIO_BASED) { 1004 + if (m->queue_mode == DM_TYPE_BIO_BASED) { 1004 1005 dm_consume_args(as, hw_argc); 1005 1006 DMERR("bio-based multipath doesn't allow hardware handler args"); 1006 1007 return 0; ··· 1088 1091 1089 1092 if (!strcasecmp(queue_mode_name, "bio")) 1090 1093 m->queue_mode = DM_TYPE_BIO_BASED; 1091 - else if (!strcasecmp(queue_mode_name, "nvme")) 1092 - m->queue_mode = DM_TYPE_NVME_BIO_BASED; 1093 1094 else if (!strcasecmp(queue_mode_name, "rq")) 1094 1095 m->queue_mode = DM_TYPE_REQUEST_BASED; 1095 1096 else if (!strcasecmp(queue_mode_name, "mq")) ··· 1188 1193 ti->num_discard_bios = 1; 1189 1194 ti->num_write_same_bios = 1; 1190 1195 ti->num_write_zeroes_bios = 1; 1191 - if (m->queue_mode == DM_TYPE_BIO_BASED || m->queue_mode == DM_TYPE_NVME_BIO_BASED) 1196 + if (m->queue_mode == DM_TYPE_BIO_BASED) 1192 1197 ti->per_io_data_size = multipath_per_bio_data_size(); 1193 1198 else 1194 1199 ti->per_io_data_size = sizeof(struct dm_mpath_io); ··· 1724 1729 switch(m->queue_mode) { 1725 1730 case DM_TYPE_BIO_BASED: 1726 1731 DMEMIT("queue_mode bio "); 1727 - break; 1728 - case DM_TYPE_NVME_BIO_BASED: 1729 - DMEMIT("queue_mode nvme "); 1730 1732 break; 1731 1733 case DM_TYPE_MQ_REQUEST_BASED: 1732 1734 DMEMIT("queue_mode mq ");
+4 -3
drivers/md/dm-raid.c
··· 3408 3408 set_bit(RT_FLAG_RS_IN_SYNC, &rs->runtime_flags); 3409 3409 3410 3410 } else { 3411 - if (test_bit(MD_RECOVERY_NEEDED, &recovery) || 3412 - test_bit(MD_RECOVERY_RESHAPE, &recovery) || 3413 - test_bit(MD_RECOVERY_RUNNING, &recovery)) 3411 + if (!test_bit(MD_RECOVERY_INTR, &recovery) && 3412 + (test_bit(MD_RECOVERY_NEEDED, &recovery) || 3413 + test_bit(MD_RECOVERY_RESHAPE, &recovery) || 3414 + test_bit(MD_RECOVERY_RUNNING, &recovery))) 3414 3415 r = mddev->curr_resync_completed; 3415 3416 else 3416 3417 r = mddev->recovery_cp;
+6 -10
drivers/md/dm-table.c
··· 942 942 943 943 if (t->type != DM_TYPE_NONE) { 944 944 /* target already set the table's type */ 945 - if (t->type == DM_TYPE_BIO_BASED) 946 - return 0; 947 - else if (t->type == DM_TYPE_NVME_BIO_BASED) { 948 - if (!dm_table_does_not_support_partial_completion(t)) { 949 - DMERR("nvme bio-based is only possible with devices" 950 - " that don't support partial completion"); 951 - return -EINVAL; 952 - } 953 - /* Fallthru, also verify all devices are blk-mq */ 945 + if (t->type == DM_TYPE_BIO_BASED) { 946 + /* possibly upgrade to a variant of bio-based */ 947 + goto verify_bio_based; 954 948 } 955 949 BUG_ON(t->type == DM_TYPE_DAX_BIO_BASED); 950 + BUG_ON(t->type == DM_TYPE_NVME_BIO_BASED); 956 951 goto verify_rq_based; 957 952 } 958 953 ··· 980 985 } 981 986 982 987 if (bio_based) { 988 + verify_bio_based: 983 989 /* We must use this table as bio-based */ 984 990 t->type = DM_TYPE_BIO_BASED; 985 991 if (dm_table_supports_dax(t) || ··· 1751 1755 char b[BDEVNAME_SIZE]; 1752 1756 1753 1757 /* For now, NVMe devices are the only devices of this class */ 1754 - return (strncmp(bdevname(dev->bdev, b), "nvme", 3) == 0); 1758 + return (strncmp(bdevname(dev->bdev, b), "nvme", 4) == 0); 1755 1759 } 1756 1760 1757 1761 static bool dm_table_does_not_support_partial_completion(struct dm_table *t)
+20 -15
drivers/md/dm.c
··· 458 458 return dm_get_geometry(md, geo); 459 459 } 460 460 461 - static int dm_grab_bdev_for_ioctl(struct mapped_device *md, 462 - struct block_device **bdev, 463 - fmode_t *mode) 461 + static char *_dm_claim_ptr = "I belong to device-mapper"; 462 + 463 + static int dm_get_bdev_for_ioctl(struct mapped_device *md, 464 + struct block_device **bdev, 465 + fmode_t *mode) 464 466 { 465 467 struct dm_target *tgt; 466 468 struct dm_table *map; ··· 492 490 goto out; 493 491 494 492 bdgrab(*bdev); 493 + r = blkdev_get(*bdev, *mode, _dm_claim_ptr); 494 + if (r < 0) 495 + goto out; 496 + 495 497 dm_put_live_table(md, srcu_idx); 496 498 return r; 497 499 ··· 514 508 struct mapped_device *md = bdev->bd_disk->private_data; 515 509 int r; 516 510 517 - r = dm_grab_bdev_for_ioctl(md, &bdev, &mode); 511 + r = dm_get_bdev_for_ioctl(md, &bdev, &mode); 518 512 if (r < 0) 519 513 return r; 520 514 ··· 534 528 535 529 r = __blkdev_driver_ioctl(bdev, mode, cmd, arg); 536 530 out: 537 - bdput(bdev); 531 + blkdev_put(bdev, mode); 538 532 return r; 539 533 } 540 534 ··· 714 708 static int open_table_device(struct table_device *td, dev_t dev, 715 709 struct mapped_device *md) 716 710 { 717 - static char *_claim_ptr = "I belong to device-mapper"; 718 711 struct block_device *bdev; 719 712 720 713 int r; 721 714 722 715 BUG_ON(td->dm_dev.bdev); 723 716 724 - bdev = blkdev_get_by_dev(dev, td->dm_dev.mode | FMODE_EXCL, _claim_ptr); 717 + bdev = blkdev_get_by_dev(dev, td->dm_dev.mode | FMODE_EXCL, _dm_claim_ptr); 725 718 if (IS_ERR(bdev)) 726 719 return PTR_ERR(bdev); 727 720 ··· 3016 3011 fmode_t mode; 3017 3012 int r; 3018 3013 3019 - r = dm_grab_bdev_for_ioctl(md, &bdev, &mode); 3014 + r = dm_get_bdev_for_ioctl(md, &bdev, &mode); 3020 3015 if (r < 0) 3021 3016 return r; 3022 3017 ··· 3026 3021 else 3027 3022 r = -EOPNOTSUPP; 3028 3023 3029 - bdput(bdev); 3024 + blkdev_put(bdev, mode); 3030 3025 return r; 3031 3026 } 3032 3027 ··· 3037 3032 fmode_t mode; 3038 3033 int r; 3039 3034 3040 - r = dm_grab_bdev_for_ioctl(md, &bdev, &mode); 3035 + r = dm_get_bdev_for_ioctl(md, &bdev, &mode); 3041 3036 if (r < 0) 3042 3037 return r; 3043 3038 ··· 3047 3042 else 3048 3043 r = -EOPNOTSUPP; 3049 3044 3050 - bdput(bdev); 3045 + blkdev_put(bdev, mode); 3051 3046 return r; 3052 3047 } 3053 3048 ··· 3059 3054 fmode_t mode; 3060 3055 int r; 3061 3056 3062 - r = dm_grab_bdev_for_ioctl(md, &bdev, &mode); 3057 + r = dm_get_bdev_for_ioctl(md, &bdev, &mode); 3063 3058 if (r < 0) 3064 3059 return r; 3065 3060 ··· 3069 3064 else 3070 3065 r = -EOPNOTSUPP; 3071 3066 3072 - bdput(bdev); 3067 + blkdev_put(bdev, mode); 3073 3068 return r; 3074 3069 } 3075 3070 ··· 3080 3075 fmode_t mode; 3081 3076 int r; 3082 3077 3083 - r = dm_grab_bdev_for_ioctl(md, &bdev, &mode); 3078 + r = dm_get_bdev_for_ioctl(md, &bdev, &mode); 3084 3079 if (r < 0) 3085 3080 return r; 3086 3081 ··· 3090 3085 else 3091 3086 r = -EOPNOTSUPP; 3092 3087 3093 - bdput(bdev); 3088 + blkdev_put(bdev, mode); 3094 3089 return r; 3095 3090 } 3096 3091