| .. | .. |
|---|
| 20 | 20 | #include <linux/pagemap.h> |
|---|
| 21 | 21 | #include <linux/slab.h> |
|---|
| 22 | 22 | #include <linux/time.h> |
|---|
| 23 | +#include <linux/timer.h> |
|---|
| 23 | 24 | #include <linux/workqueue.h> |
|---|
| 24 | 25 | #include <linux/delay.h> |
|---|
| 25 | 26 | #include <scsi/scsi_dh.h> |
|---|
| .. | .. |
|---|
| 29 | 30 | #define DM_MSG_PREFIX "multipath" |
|---|
| 30 | 31 | #define DM_PG_INIT_DELAY_MSECS 2000 |
|---|
| 31 | 32 | #define DM_PG_INIT_DELAY_DEFAULT ((unsigned) -1) |
|---|
| 33 | +#define QUEUE_IF_NO_PATH_TIMEOUT_DEFAULT 0 |
|---|
| 34 | + |
|---|
| 35 | +static unsigned long queue_if_no_path_timeout_secs = QUEUE_IF_NO_PATH_TIMEOUT_DEFAULT; |
|---|
| 32 | 36 | |
|---|
| 33 | 37 | /* Path properties */ |
|---|
| 34 | 38 | struct pgpath { |
|---|
| .. | .. |
|---|
| 91 | 95 | |
|---|
| 92 | 96 | struct work_struct process_queued_bios; |
|---|
| 93 | 97 | struct bio_list queued_bios; |
|---|
| 98 | + |
|---|
| 99 | + struct timer_list nopath_timer; /* Timeout for queue_if_no_path */ |
|---|
| 94 | 100 | }; |
|---|
| 95 | 101 | |
|---|
| 96 | 102 | /* |
|---|
| .. | .. |
|---|
| 108 | 114 | static void activate_or_offline_path(struct pgpath *pgpath); |
|---|
| 109 | 115 | static void activate_path_work(struct work_struct *work); |
|---|
| 110 | 116 | static void process_queued_bios(struct work_struct *work); |
|---|
| 117 | +static void queue_if_no_path_timeout_work(struct timer_list *t); |
|---|
| 111 | 118 | |
|---|
| 112 | 119 | /*----------------------------------------------- |
|---|
| 113 | 120 | * Multipath state flags. |
|---|
| .. | .. |
|---|
| 120 | 127 | #define MPATHF_PG_INIT_DISABLED 4 /* pg_init is not currently allowed */ |
|---|
| 121 | 128 | #define MPATHF_PG_INIT_REQUIRED 5 /* pg_init needs calling? */ |
|---|
| 122 | 129 | #define MPATHF_PG_INIT_DELAY_RETRY 6 /* Delay pg_init retry? */ |
|---|
| 130 | + |
|---|
| 131 | +static bool mpath_double_check_test_bit(int MPATHF_bit, struct multipath *m) |
|---|
| 132 | +{ |
|---|
| 133 | + bool r = test_bit(MPATHF_bit, &m->flags); |
|---|
| 134 | + |
|---|
| 135 | + if (r) { |
|---|
| 136 | + unsigned long flags; |
|---|
| 137 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 138 | + r = test_bit(MPATHF_bit, &m->flags); |
|---|
| 139 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 140 | + } |
|---|
| 141 | + |
|---|
| 142 | + return r; |
|---|
| 143 | +} |
|---|
| 123 | 144 | |
|---|
| 124 | 145 | /*----------------------------------------------- |
|---|
| 125 | 146 | * Allocation routines |
|---|
| .. | .. |
|---|
| 195 | 216 | |
|---|
| 196 | 217 | m->ti = ti; |
|---|
| 197 | 218 | ti->private = m; |
|---|
| 219 | + |
|---|
| 220 | + timer_setup(&m->nopath_timer, queue_if_no_path_timeout_work, 0); |
|---|
| 198 | 221 | } |
|---|
| 199 | 222 | |
|---|
| 200 | 223 | return m; |
|---|
| .. | .. |
|---|
| 203 | 226 | static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m) |
|---|
| 204 | 227 | { |
|---|
| 205 | 228 | if (m->queue_mode == DM_TYPE_NONE) { |
|---|
| 206 | | - /* |
|---|
| 207 | | - * Default to request-based. |
|---|
| 208 | | - */ |
|---|
| 209 | | - if (dm_use_blk_mq(dm_table_get_md(ti->table))) |
|---|
| 210 | | - m->queue_mode = DM_TYPE_MQ_REQUEST_BASED; |
|---|
| 211 | | - else |
|---|
| 212 | | - m->queue_mode = DM_TYPE_REQUEST_BASED; |
|---|
| 213 | | - |
|---|
| 229 | + m->queue_mode = DM_TYPE_REQUEST_BASED; |
|---|
| 214 | 230 | } else if (m->queue_mode == DM_TYPE_BIO_BASED) { |
|---|
| 215 | 231 | INIT_WORK(&m->process_queued_bios, process_queued_bios); |
|---|
| 216 | 232 | /* |
|---|
| .. | .. |
|---|
| 333 | 349 | |
|---|
| 334 | 350 | static void __switch_pg(struct multipath *m, struct priority_group *pg) |
|---|
| 335 | 351 | { |
|---|
| 352 | + lockdep_assert_held(&m->lock); |
|---|
| 353 | + |
|---|
| 336 | 354 | m->current_pg = pg; |
|---|
| 337 | 355 | |
|---|
| 338 | 356 | /* Must we initialise the PG first, and queue I/O till it's ready? */ |
|---|
| .. | .. |
|---|
| 380 | 398 | unsigned bypassed = 1; |
|---|
| 381 | 399 | |
|---|
| 382 | 400 | if (!atomic_read(&m->nr_valid_paths)) { |
|---|
| 401 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 383 | 402 | clear_bit(MPATHF_QUEUE_IO, &m->flags); |
|---|
| 403 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 384 | 404 | goto failed; |
|---|
| 385 | 405 | } |
|---|
| 386 | 406 | |
|---|
| .. | .. |
|---|
| 420 | 440 | continue; |
|---|
| 421 | 441 | pgpath = choose_path_in_pg(m, pg, nr_bytes); |
|---|
| 422 | 442 | if (!IS_ERR_OR_NULL(pgpath)) { |
|---|
| 423 | | - if (!bypassed) |
|---|
| 443 | + if (!bypassed) { |
|---|
| 444 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 424 | 445 | set_bit(MPATHF_PG_INIT_DELAY_RETRY, &m->flags); |
|---|
| 446 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 447 | + } |
|---|
| 425 | 448 | return pgpath; |
|---|
| 426 | 449 | } |
|---|
| 427 | 450 | } |
|---|
| .. | .. |
|---|
| 437 | 460 | } |
|---|
| 438 | 461 | |
|---|
| 439 | 462 | /* |
|---|
| 440 | | - * dm_report_EIO() is a macro instead of a function to make pr_debug() |
|---|
| 463 | + * dm_report_EIO() is a macro instead of a function to make pr_debug_ratelimited() |
|---|
| 441 | 464 | * report the function name and line number of the function from which |
|---|
| 442 | 465 | * it has been invoked. |
|---|
| 443 | 466 | */ |
|---|
| 444 | 467 | #define dm_report_EIO(m) \ |
|---|
| 445 | 468 | do { \ |
|---|
| 446 | | - struct mapped_device *md = dm_table_get_md((m)->ti->table); \ |
|---|
| 447 | | - \ |
|---|
| 448 | | - pr_debug("%s: returning EIO; QIFNP = %d; SQIFNP = %d; DNFS = %d\n", \ |
|---|
| 449 | | - dm_device_name(md), \ |
|---|
| 450 | | - test_bit(MPATHF_QUEUE_IF_NO_PATH, &(m)->flags), \ |
|---|
| 451 | | - test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &(m)->flags), \ |
|---|
| 452 | | - dm_noflush_suspending((m)->ti)); \ |
|---|
| 469 | + DMDEBUG_LIMIT("%s: returning EIO; QIFNP = %d; SQIFNP = %d; DNFS = %d", \ |
|---|
| 470 | + dm_table_device_name((m)->ti->table), \ |
|---|
| 471 | + test_bit(MPATHF_QUEUE_IF_NO_PATH, &(m)->flags), \ |
|---|
| 472 | + test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &(m)->flags), \ |
|---|
| 473 | + dm_noflush_suspending((m)->ti)); \ |
|---|
| 453 | 474 | } while (0) |
|---|
| 454 | 475 | |
|---|
| 455 | 476 | /* |
|---|
| 456 | 477 | * Check whether bios must be queued in the device-mapper core rather |
|---|
| 457 | 478 | * than here in the target. |
|---|
| 458 | | - * |
|---|
| 459 | | - * If MPATHF_QUEUE_IF_NO_PATH and MPATHF_SAVED_QUEUE_IF_NO_PATH hold |
|---|
| 460 | | - * the same value then we are not between multipath_presuspend() |
|---|
| 461 | | - * and multipath_resume() calls and we have no need to check |
|---|
| 462 | | - * for the DMF_NOFLUSH_SUSPENDING flag. |
|---|
| 463 | 479 | */ |
|---|
| 464 | | -static bool __must_push_back(struct multipath *m, unsigned long flags) |
|---|
| 480 | +static bool __must_push_back(struct multipath *m) |
|---|
| 465 | 481 | { |
|---|
| 466 | | - return ((test_bit(MPATHF_QUEUE_IF_NO_PATH, &flags) != |
|---|
| 467 | | - test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &flags)) && |
|---|
| 468 | | - dm_noflush_suspending(m->ti)); |
|---|
| 482 | + return dm_noflush_suspending(m->ti); |
|---|
| 469 | 483 | } |
|---|
| 470 | 484 | |
|---|
| 471 | | -/* |
|---|
| 472 | | - * Following functions use READ_ONCE to get atomic access to |
|---|
| 473 | | - * all m->flags to avoid taking spinlock |
|---|
| 474 | | - */ |
|---|
| 475 | 485 | static bool must_push_back_rq(struct multipath *m) |
|---|
| 476 | 486 | { |
|---|
| 477 | | - unsigned long flags = READ_ONCE(m->flags); |
|---|
| 478 | | - return test_bit(MPATHF_QUEUE_IF_NO_PATH, &flags) || __must_push_back(m, flags); |
|---|
| 479 | | -} |
|---|
| 487 | + unsigned long flags; |
|---|
| 488 | + bool ret; |
|---|
| 480 | 489 | |
|---|
| 481 | | -static bool must_push_back_bio(struct multipath *m) |
|---|
| 482 | | -{ |
|---|
| 483 | | - unsigned long flags = READ_ONCE(m->flags); |
|---|
| 484 | | - return __must_push_back(m, flags); |
|---|
| 490 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 491 | + ret = (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags) || __must_push_back(m)); |
|---|
| 492 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 493 | + |
|---|
| 494 | + return ret; |
|---|
| 485 | 495 | } |
|---|
| 486 | 496 | |
|---|
| 487 | 497 | /* |
|---|
| .. | .. |
|---|
| 501 | 511 | |
|---|
| 502 | 512 | /* Do we need to select a new pgpath? */ |
|---|
| 503 | 513 | pgpath = READ_ONCE(m->current_pgpath); |
|---|
| 504 | | - if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags)) |
|---|
| 514 | + if (!pgpath || !mpath_double_check_test_bit(MPATHF_QUEUE_IO, m)) |
|---|
| 505 | 515 | pgpath = choose_pgpath(m, nr_bytes); |
|---|
| 506 | 516 | |
|---|
| 507 | 517 | if (!pgpath) { |
|---|
| .. | .. |
|---|
| 509 | 519 | return DM_MAPIO_DELAY_REQUEUE; |
|---|
| 510 | 520 | dm_report_EIO(m); /* Failed */ |
|---|
| 511 | 521 | return DM_MAPIO_KILL; |
|---|
| 512 | | - } else if (test_bit(MPATHF_QUEUE_IO, &m->flags) || |
|---|
| 513 | | - test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) { |
|---|
| 522 | + } else if (mpath_double_check_test_bit(MPATHF_QUEUE_IO, m) || |
|---|
| 523 | + mpath_double_check_test_bit(MPATHF_PG_INIT_REQUIRED, m)) { |
|---|
| 514 | 524 | pg_init_all_paths(m); |
|---|
| 515 | 525 | return DM_MAPIO_DELAY_REQUEUE; |
|---|
| 516 | 526 | } |
|---|
| .. | .. |
|---|
| 537 | 547 | * get the queue busy feedback (via BLK_STS_RESOURCE), |
|---|
| 538 | 548 | * otherwise I/O merging can suffer. |
|---|
| 539 | 549 | */ |
|---|
| 540 | | - if (q->mq_ops) |
|---|
| 541 | | - return DM_MAPIO_REQUEUE; |
|---|
| 542 | | - else |
|---|
| 543 | | - return DM_MAPIO_DELAY_REQUEUE; |
|---|
| 550 | + return DM_MAPIO_REQUEUE; |
|---|
| 544 | 551 | } |
|---|
| 545 | 552 | clone->bio = clone->biotail = NULL; |
|---|
| 546 | 553 | clone->rq_disk = bdev->bd_disk; |
|---|
| .. | .. |
|---|
| 568 | 575 | if (pgpath && pgpath->pg->ps.type->end_io) |
|---|
| 569 | 576 | pgpath->pg->ps.type->end_io(&pgpath->pg->ps, |
|---|
| 570 | 577 | &pgpath->path, |
|---|
| 571 | | - mpio->nr_bytes); |
|---|
| 578 | + mpio->nr_bytes, |
|---|
| 579 | + clone->io_start_time_ns); |
|---|
| 572 | 580 | } |
|---|
| 573 | 581 | |
|---|
| 574 | 582 | blk_put_request(clone); |
|---|
| .. | .. |
|---|
| 578 | 586 | * Map cloned bios (bio-based multipath) |
|---|
| 579 | 587 | */ |
|---|
| 580 | 588 | |
|---|
| 589 | +static void __multipath_queue_bio(struct multipath *m, struct bio *bio) |
|---|
| 590 | +{ |
|---|
| 591 | + /* Queue for the daemon to resubmit */ |
|---|
| 592 | + bio_list_add(&m->queued_bios, bio); |
|---|
| 593 | + if (!test_bit(MPATHF_QUEUE_IO, &m->flags)) |
|---|
| 594 | + queue_work(kmultipathd, &m->process_queued_bios); |
|---|
| 595 | +} |
|---|
| 596 | + |
|---|
| 597 | +static void multipath_queue_bio(struct multipath *m, struct bio *bio) |
|---|
| 598 | +{ |
|---|
| 599 | + unsigned long flags; |
|---|
| 600 | + |
|---|
| 601 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 602 | + __multipath_queue_bio(m, bio); |
|---|
| 603 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 604 | +} |
|---|
| 605 | + |
|---|
| 581 | 606 | static struct pgpath *__map_bio(struct multipath *m, struct bio *bio) |
|---|
| 582 | 607 | { |
|---|
| 583 | 608 | struct pgpath *pgpath; |
|---|
| 584 | 609 | unsigned long flags; |
|---|
| 585 | | - bool queue_io; |
|---|
| 586 | 610 | |
|---|
| 587 | 611 | /* Do we need to select a new pgpath? */ |
|---|
| 588 | 612 | pgpath = READ_ONCE(m->current_pgpath); |
|---|
| 589 | | - if (!pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags)) |
|---|
| 613 | + if (!pgpath || !mpath_double_check_test_bit(MPATHF_QUEUE_IO, m)) |
|---|
| 590 | 614 | pgpath = choose_pgpath(m, bio->bi_iter.bi_size); |
|---|
| 591 | 615 | |
|---|
| 592 | | - /* MPATHF_QUEUE_IO might have been cleared by choose_pgpath. */ |
|---|
| 593 | | - queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags); |
|---|
| 594 | | - |
|---|
| 595 | | - if ((pgpath && queue_io) || |
|---|
| 596 | | - (!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) { |
|---|
| 597 | | - /* Queue for the daemon to resubmit */ |
|---|
| 616 | + if (!pgpath) { |
|---|
| 598 | 617 | spin_lock_irqsave(&m->lock, flags); |
|---|
| 599 | | - bio_list_add(&m->queued_bios, bio); |
|---|
| 618 | + if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 619 | + __multipath_queue_bio(m, bio); |
|---|
| 620 | + pgpath = ERR_PTR(-EAGAIN); |
|---|
| 621 | + } |
|---|
| 600 | 622 | spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 601 | 623 | |
|---|
| 602 | | - /* PG_INIT_REQUIRED cannot be set without QUEUE_IO */ |
|---|
| 603 | | - if (queue_io || test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) |
|---|
| 604 | | - pg_init_all_paths(m); |
|---|
| 605 | | - else if (!queue_io) |
|---|
| 606 | | - queue_work(kmultipathd, &m->process_queued_bios); |
|---|
| 607 | | - |
|---|
| 624 | + } else if (mpath_double_check_test_bit(MPATHF_QUEUE_IO, m) || |
|---|
| 625 | + mpath_double_check_test_bit(MPATHF_PG_INIT_REQUIRED, m)) { |
|---|
| 626 | + multipath_queue_bio(m, bio); |
|---|
| 627 | + pg_init_all_paths(m); |
|---|
| 608 | 628 | return ERR_PTR(-EAGAIN); |
|---|
| 609 | 629 | } |
|---|
| 610 | 630 | |
|---|
| .. | .. |
|---|
| 620 | 640 | return DM_MAPIO_SUBMITTED; |
|---|
| 621 | 641 | |
|---|
| 622 | 642 | if (!pgpath) { |
|---|
| 623 | | - if (must_push_back_bio(m)) |
|---|
| 643 | + if (__must_push_back(m)) |
|---|
| 624 | 644 | return DM_MAPIO_REQUEUE; |
|---|
| 625 | 645 | dm_report_EIO(m); |
|---|
| 626 | 646 | return DM_MAPIO_KILL; |
|---|
| .. | .. |
|---|
| 650 | 670 | |
|---|
| 651 | 671 | static void process_queued_io_list(struct multipath *m) |
|---|
| 652 | 672 | { |
|---|
| 653 | | - if (m->queue_mode == DM_TYPE_MQ_REQUEST_BASED) |
|---|
| 673 | + if (m->queue_mode == DM_TYPE_REQUEST_BASED) |
|---|
| 654 | 674 | dm_mq_kick_requeue_list(dm_table_get_md(m->ti->table)); |
|---|
| 655 | 675 | else if (m->queue_mode == DM_TYPE_BIO_BASED) |
|---|
| 656 | 676 | queue_work(kmultipathd, &m->process_queued_bios); |
|---|
| .. | .. |
|---|
| 695 | 715 | bio_endio(bio); |
|---|
| 696 | 716 | break; |
|---|
| 697 | 717 | case DM_MAPIO_REMAPPED: |
|---|
| 698 | | - generic_make_request(bio); |
|---|
| 718 | + submit_bio_noacct(bio); |
|---|
| 699 | 719 | break; |
|---|
| 700 | 720 | case DM_MAPIO_SUBMITTED: |
|---|
| 701 | 721 | break; |
|---|
| .. | .. |
|---|
| 710 | 730 | * If we run out of usable paths, should we queue I/O or error it? |
|---|
| 711 | 731 | */ |
|---|
| 712 | 732 | static int queue_if_no_path(struct multipath *m, bool queue_if_no_path, |
|---|
| 713 | | - bool save_old_value) |
|---|
| 733 | + bool save_old_value, const char *caller) |
|---|
| 714 | 734 | { |
|---|
| 715 | 735 | unsigned long flags; |
|---|
| 736 | + bool queue_if_no_path_bit, saved_queue_if_no_path_bit; |
|---|
| 737 | + const char *dm_dev_name = dm_table_device_name(m->ti->table); |
|---|
| 738 | + |
|---|
| 739 | + DMDEBUG("%s: %s caller=%s queue_if_no_path=%d save_old_value=%d", |
|---|
| 740 | + dm_dev_name, __func__, caller, queue_if_no_path, save_old_value); |
|---|
| 716 | 741 | |
|---|
| 717 | 742 | spin_lock_irqsave(&m->lock, flags); |
|---|
| 718 | | - assign_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags, |
|---|
| 719 | | - (save_old_value && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) || |
|---|
| 720 | | - (!save_old_value && queue_if_no_path)); |
|---|
| 743 | + |
|---|
| 744 | + queue_if_no_path_bit = test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); |
|---|
| 745 | + saved_queue_if_no_path_bit = test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); |
|---|
| 746 | + |
|---|
| 747 | + if (save_old_value) { |
|---|
| 748 | + if (unlikely(!queue_if_no_path_bit && saved_queue_if_no_path_bit)) { |
|---|
| 749 | + DMERR("%s: QIFNP disabled but saved as enabled, saving again loses state, not saving!", |
|---|
| 750 | + dm_dev_name); |
|---|
| 751 | + } else |
|---|
| 752 | + assign_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags, queue_if_no_path_bit); |
|---|
| 753 | + } else if (!queue_if_no_path && saved_queue_if_no_path_bit) { |
|---|
| 754 | + /* due to "fail_if_no_path" message, need to honor it. */ |
|---|
| 755 | + clear_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); |
|---|
| 756 | + } |
|---|
| 721 | 757 | assign_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags, queue_if_no_path); |
|---|
| 758 | + |
|---|
| 759 | + DMDEBUG("%s: after %s changes; QIFNP = %d; SQIFNP = %d; DNFS = %d", |
|---|
| 760 | + dm_dev_name, __func__, |
|---|
| 761 | + test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags), |
|---|
| 762 | + test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags), |
|---|
| 763 | + dm_noflush_suspending(m->ti)); |
|---|
| 764 | + |
|---|
| 722 | 765 | spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 723 | 766 | |
|---|
| 724 | 767 | if (!queue_if_no_path) { |
|---|
| .. | .. |
|---|
| 727 | 770 | } |
|---|
| 728 | 771 | |
|---|
| 729 | 772 | return 0; |
|---|
| 773 | +} |
|---|
| 774 | + |
|---|
| 775 | +/* |
|---|
| 776 | + * If the queue_if_no_path timeout fires, turn off queue_if_no_path and |
|---|
| 777 | + * process any queued I/O. |
|---|
| 778 | + */ |
|---|
| 779 | +static void queue_if_no_path_timeout_work(struct timer_list *t) |
|---|
| 780 | +{ |
|---|
| 781 | + struct multipath *m = from_timer(m, t, nopath_timer); |
|---|
| 782 | + |
|---|
| 783 | + DMWARN("queue_if_no_path timeout on %s, failing queued IO", |
|---|
| 784 | + dm_table_device_name(m->ti->table)); |
|---|
| 785 | + queue_if_no_path(m, false, false, __func__); |
|---|
| 786 | +} |
|---|
| 787 | + |
|---|
| 788 | +/* |
|---|
| 789 | + * Enable the queue_if_no_path timeout if necessary. |
|---|
| 790 | + * Called with m->lock held. |
|---|
| 791 | + */ |
|---|
| 792 | +static void enable_nopath_timeout(struct multipath *m) |
|---|
| 793 | +{ |
|---|
| 794 | + unsigned long queue_if_no_path_timeout = |
|---|
| 795 | + READ_ONCE(queue_if_no_path_timeout_secs) * HZ; |
|---|
| 796 | + |
|---|
| 797 | + lockdep_assert_held(&m->lock); |
|---|
| 798 | + |
|---|
| 799 | + if (queue_if_no_path_timeout > 0 && |
|---|
| 800 | + atomic_read(&m->nr_valid_paths) == 0 && |
|---|
| 801 | + test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 802 | + mod_timer(&m->nopath_timer, |
|---|
| 803 | + jiffies + queue_if_no_path_timeout); |
|---|
| 804 | + } |
|---|
| 805 | +} |
|---|
| 806 | + |
|---|
| 807 | +static void disable_nopath_timeout(struct multipath *m) |
|---|
| 808 | +{ |
|---|
| 809 | + del_timer_sync(&m->nopath_timer); |
|---|
| 730 | 810 | } |
|---|
| 731 | 811 | |
|---|
| 732 | 812 | /* |
|---|
| .. | .. |
|---|
| 793 | 873 | struct request_queue *q = bdev_get_queue(bdev); |
|---|
| 794 | 874 | int r; |
|---|
| 795 | 875 | |
|---|
| 796 | | - if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) { |
|---|
| 876 | + if (mpath_double_check_test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, m)) { |
|---|
| 797 | 877 | retain: |
|---|
| 798 | 878 | if (*attached_handler_name) { |
|---|
| 799 | 879 | /* |
|---|
| .. | .. |
|---|
| 1042 | 1122 | argc--; |
|---|
| 1043 | 1123 | |
|---|
| 1044 | 1124 | if (!strcasecmp(arg_name, "queue_if_no_path")) { |
|---|
| 1045 | | - r = queue_if_no_path(m, true, false); |
|---|
| 1125 | + r = queue_if_no_path(m, true, false, __func__); |
|---|
| 1046 | 1126 | continue; |
|---|
| 1047 | 1127 | } |
|---|
| 1048 | 1128 | |
|---|
| .. | .. |
|---|
| 1071 | 1151 | |
|---|
| 1072 | 1152 | if (!strcasecmp(queue_mode_name, "bio")) |
|---|
| 1073 | 1153 | m->queue_mode = DM_TYPE_BIO_BASED; |
|---|
| 1074 | | - else if (!strcasecmp(queue_mode_name, "rq")) |
|---|
| 1154 | + else if (!strcasecmp(queue_mode_name, "rq") || |
|---|
| 1155 | + !strcasecmp(queue_mode_name, "mq")) |
|---|
| 1075 | 1156 | m->queue_mode = DM_TYPE_REQUEST_BASED; |
|---|
| 1076 | | - else if (!strcasecmp(queue_mode_name, "mq")) |
|---|
| 1077 | | - m->queue_mode = DM_TYPE_MQ_REQUEST_BASED; |
|---|
| 1078 | 1157 | else { |
|---|
| 1079 | 1158 | ti->error = "Unknown 'queue_mode' requested"; |
|---|
| 1080 | 1159 | r = -EINVAL; |
|---|
| .. | .. |
|---|
| 1103 | 1182 | struct dm_arg_set as; |
|---|
| 1104 | 1183 | unsigned pg_count = 0; |
|---|
| 1105 | 1184 | unsigned next_pg_num; |
|---|
| 1185 | + unsigned long flags; |
|---|
| 1106 | 1186 | |
|---|
| 1107 | 1187 | as.argc = argc; |
|---|
| 1108 | 1188 | as.argv = argv; |
|---|
| .. | .. |
|---|
| 1167 | 1247 | goto bad; |
|---|
| 1168 | 1248 | } |
|---|
| 1169 | 1249 | |
|---|
| 1250 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1251 | + enable_nopath_timeout(m); |
|---|
| 1252 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1253 | + |
|---|
| 1170 | 1254 | ti->num_flush_bios = 1; |
|---|
| 1171 | 1255 | ti->num_discard_bios = 1; |
|---|
| 1172 | 1256 | ti->num_write_same_bios = 1; |
|---|
| .. | .. |
|---|
| 1201 | 1285 | static void flush_multipath_work(struct multipath *m) |
|---|
| 1202 | 1286 | { |
|---|
| 1203 | 1287 | if (m->hw_handler_name) { |
|---|
| 1204 | | - set_bit(MPATHF_PG_INIT_DISABLED, &m->flags); |
|---|
| 1205 | | - smp_mb__after_atomic(); |
|---|
| 1288 | + unsigned long flags; |
|---|
| 1206 | 1289 | |
|---|
| 1207 | | - flush_workqueue(kmpath_handlerd); |
|---|
| 1208 | | - multipath_wait_for_pg_init_completion(m); |
|---|
| 1290 | + if (!atomic_read(&m->pg_init_in_progress)) |
|---|
| 1291 | + goto skip; |
|---|
| 1209 | 1292 | |
|---|
| 1210 | | - clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags); |
|---|
| 1211 | | - smp_mb__after_atomic(); |
|---|
| 1293 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1294 | + if (atomic_read(&m->pg_init_in_progress) && |
|---|
| 1295 | + !test_and_set_bit(MPATHF_PG_INIT_DISABLED, &m->flags)) { |
|---|
| 1296 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1297 | + |
|---|
| 1298 | + flush_workqueue(kmpath_handlerd); |
|---|
| 1299 | + multipath_wait_for_pg_init_completion(m); |
|---|
| 1300 | + |
|---|
| 1301 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1302 | + clear_bit(MPATHF_PG_INIT_DISABLED, &m->flags); |
|---|
| 1303 | + } |
|---|
| 1304 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1212 | 1305 | } |
|---|
| 1213 | | - |
|---|
| 1214 | | - flush_workqueue(kmultipathd); |
|---|
| 1306 | +skip: |
|---|
| 1307 | + if (m->queue_mode == DM_TYPE_BIO_BASED) |
|---|
| 1308 | + flush_work(&m->process_queued_bios); |
|---|
| 1215 | 1309 | flush_work(&m->trigger_event); |
|---|
| 1216 | 1310 | } |
|---|
| 1217 | 1311 | |
|---|
| .. | .. |
|---|
| 1219 | 1313 | { |
|---|
| 1220 | 1314 | struct multipath *m = ti->private; |
|---|
| 1221 | 1315 | |
|---|
| 1316 | + disable_nopath_timeout(m); |
|---|
| 1222 | 1317 | flush_multipath_work(m); |
|---|
| 1223 | 1318 | free_multipath(m); |
|---|
| 1224 | 1319 | } |
|---|
| .. | .. |
|---|
| 1236 | 1331 | if (!pgpath->is_active) |
|---|
| 1237 | 1332 | goto out; |
|---|
| 1238 | 1333 | |
|---|
| 1239 | | - DMWARN("Failing path %s.", pgpath->path.dev->name); |
|---|
| 1334 | + DMWARN("%s: Failing path %s.", |
|---|
| 1335 | + dm_table_device_name(m->ti->table), |
|---|
| 1336 | + pgpath->path.dev->name); |
|---|
| 1240 | 1337 | |
|---|
| 1241 | 1338 | pgpath->pg->ps.type->fail_path(&pgpath->pg->ps, &pgpath->path); |
|---|
| 1242 | 1339 | pgpath->is_active = false; |
|---|
| .. | .. |
|---|
| 1251 | 1348 | pgpath->path.dev->name, atomic_read(&m->nr_valid_paths)); |
|---|
| 1252 | 1349 | |
|---|
| 1253 | 1350 | schedule_work(&m->trigger_event); |
|---|
| 1351 | + |
|---|
| 1352 | + enable_nopath_timeout(m); |
|---|
| 1254 | 1353 | |
|---|
| 1255 | 1354 | out: |
|---|
| 1256 | 1355 | spin_unlock_irqrestore(&m->lock, flags); |
|---|
| .. | .. |
|---|
| 1273 | 1372 | if (pgpath->is_active) |
|---|
| 1274 | 1373 | goto out; |
|---|
| 1275 | 1374 | |
|---|
| 1276 | | - DMWARN("Reinstating path %s.", pgpath->path.dev->name); |
|---|
| 1375 | + DMWARN("%s: Reinstating path %s.", |
|---|
| 1376 | + dm_table_device_name(m->ti->table), |
|---|
| 1377 | + pgpath->path.dev->name); |
|---|
| 1277 | 1378 | |
|---|
| 1278 | 1379 | r = pgpath->pg->ps.type->reinstate_path(&pgpath->pg->ps, &pgpath->path); |
|---|
| 1279 | 1380 | if (r) |
|---|
| .. | .. |
|---|
| 1301 | 1402 | dm_table_run_md_queue_async(m->ti->table); |
|---|
| 1302 | 1403 | process_queued_io_list(m); |
|---|
| 1303 | 1404 | } |
|---|
| 1405 | + |
|---|
| 1406 | + if (pgpath->is_active) |
|---|
| 1407 | + disable_nopath_timeout(m); |
|---|
| 1304 | 1408 | |
|---|
| 1305 | 1409 | return r; |
|---|
| 1306 | 1410 | } |
|---|
| .. | .. |
|---|
| 1455 | 1559 | break; |
|---|
| 1456 | 1560 | case SCSI_DH_RETRY: |
|---|
| 1457 | 1561 | /* Wait before retrying. */ |
|---|
| 1458 | | - delay_retry = 1; |
|---|
| 1459 | | - /* fall through */ |
|---|
| 1562 | + delay_retry = true; |
|---|
| 1563 | + fallthrough; |
|---|
| 1460 | 1564 | case SCSI_DH_IMM_RETRY: |
|---|
| 1461 | 1565 | case SCSI_DH_RES_TEMP_UNAVAIL: |
|---|
| 1462 | 1566 | if (pg_init_limit_reached(m, pgpath)) |
|---|
| .. | .. |
|---|
| 1556 | 1660 | if (pgpath) |
|---|
| 1557 | 1661 | fail_path(pgpath); |
|---|
| 1558 | 1662 | |
|---|
| 1559 | | - if (atomic_read(&m->nr_valid_paths) == 0 && |
|---|
| 1663 | + if (!atomic_read(&m->nr_valid_paths) && |
|---|
| 1560 | 1664 | !must_push_back_rq(m)) { |
|---|
| 1561 | 1665 | if (error == BLK_STS_IOERR) |
|---|
| 1562 | 1666 | dm_report_EIO(m); |
|---|
| .. | .. |
|---|
| 1569 | 1673 | struct path_selector *ps = &pgpath->pg->ps; |
|---|
| 1570 | 1674 | |
|---|
| 1571 | 1675 | if (ps->type->end_io) |
|---|
| 1572 | | - ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes); |
|---|
| 1676 | + ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes, |
|---|
| 1677 | + clone->io_start_time_ns); |
|---|
| 1573 | 1678 | } |
|---|
| 1574 | 1679 | |
|---|
| 1575 | 1680 | return r; |
|---|
| .. | .. |
|---|
| 1590 | 1695 | if (pgpath) |
|---|
| 1591 | 1696 | fail_path(pgpath); |
|---|
| 1592 | 1697 | |
|---|
| 1593 | | - if (atomic_read(&m->nr_valid_paths) == 0 && |
|---|
| 1594 | | - !test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 1595 | | - if (must_push_back_bio(m)) { |
|---|
| 1596 | | - r = DM_ENDIO_REQUEUE; |
|---|
| 1597 | | - } else { |
|---|
| 1598 | | - dm_report_EIO(m); |
|---|
| 1599 | | - *error = BLK_STS_IOERR; |
|---|
| 1698 | + if (!atomic_read(&m->nr_valid_paths)) { |
|---|
| 1699 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1700 | + if (!test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 1701 | + if (__must_push_back(m)) { |
|---|
| 1702 | + r = DM_ENDIO_REQUEUE; |
|---|
| 1703 | + } else { |
|---|
| 1704 | + dm_report_EIO(m); |
|---|
| 1705 | + *error = BLK_STS_IOERR; |
|---|
| 1706 | + } |
|---|
| 1707 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1708 | + goto done; |
|---|
| 1600 | 1709 | } |
|---|
| 1601 | | - goto done; |
|---|
| 1710 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1602 | 1711 | } |
|---|
| 1603 | 1712 | |
|---|
| 1604 | | - spin_lock_irqsave(&m->lock, flags); |
|---|
| 1605 | | - bio_list_add(&m->queued_bios, clone); |
|---|
| 1606 | | - spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1607 | | - if (!test_bit(MPATHF_QUEUE_IO, &m->flags)) |
|---|
| 1608 | | - queue_work(kmultipathd, &m->process_queued_bios); |
|---|
| 1609 | | - |
|---|
| 1713 | + multipath_queue_bio(m, clone); |
|---|
| 1610 | 1714 | r = DM_ENDIO_INCOMPLETE; |
|---|
| 1611 | 1715 | done: |
|---|
| 1612 | 1716 | if (pgpath) { |
|---|
| 1613 | 1717 | struct path_selector *ps = &pgpath->pg->ps; |
|---|
| 1614 | 1718 | |
|---|
| 1615 | 1719 | if (ps->type->end_io) |
|---|
| 1616 | | - ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes); |
|---|
| 1720 | + ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes, |
|---|
| 1721 | + dm_start_time_ns_from_clone(clone)); |
|---|
| 1617 | 1722 | } |
|---|
| 1618 | 1723 | |
|---|
| 1619 | 1724 | return r; |
|---|
| 1620 | 1725 | } |
|---|
| 1621 | 1726 | |
|---|
| 1622 | 1727 | /* |
|---|
| 1623 | | - * Suspend can't complete until all the I/O is processed so if |
|---|
| 1624 | | - * the last path fails we must error any remaining I/O. |
|---|
| 1625 | | - * Note that if the freeze_bdev fails while suspending, the |
|---|
| 1626 | | - * queue_if_no_path state is lost - userspace should reset it. |
|---|
| 1728 | + * Suspend with flush can't complete until all the I/O is processed |
|---|
| 1729 | + * so if the last path fails we must error any remaining I/O. |
|---|
| 1730 | + * - Note that if the freeze_bdev fails while suspending, the |
|---|
| 1731 | + * queue_if_no_path state is lost - userspace should reset it. |
|---|
| 1732 | + * Otherwise, during noflush suspend, queue_if_no_path will not change. |
|---|
| 1627 | 1733 | */ |
|---|
| 1628 | 1734 | static void multipath_presuspend(struct dm_target *ti) |
|---|
| 1629 | 1735 | { |
|---|
| 1630 | 1736 | struct multipath *m = ti->private; |
|---|
| 1631 | 1737 | |
|---|
| 1632 | | - queue_if_no_path(m, false, true); |
|---|
| 1738 | + /* FIXME: bio-based shouldn't need to always disable queue_if_no_path */ |
|---|
| 1739 | + if (m->queue_mode == DM_TYPE_BIO_BASED || !dm_noflush_suspending(m->ti)) |
|---|
| 1740 | + queue_if_no_path(m, false, true, __func__); |
|---|
| 1633 | 1741 | } |
|---|
| 1634 | 1742 | |
|---|
| 1635 | 1743 | static void multipath_postsuspend(struct dm_target *ti) |
|---|
| .. | .. |
|---|
| 1650 | 1758 | unsigned long flags; |
|---|
| 1651 | 1759 | |
|---|
| 1652 | 1760 | spin_lock_irqsave(&m->lock, flags); |
|---|
| 1653 | | - assign_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags, |
|---|
| 1654 | | - test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)); |
|---|
| 1761 | + if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 1762 | + set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); |
|---|
| 1763 | + clear_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); |
|---|
| 1764 | + } |
|---|
| 1765 | + |
|---|
| 1766 | + DMDEBUG("%s: %s finished; QIFNP = %d; SQIFNP = %d", |
|---|
| 1767 | + dm_table_device_name(m->ti->table), __func__, |
|---|
| 1768 | + test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags), |
|---|
| 1769 | + test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)); |
|---|
| 1770 | + |
|---|
| 1655 | 1771 | spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1656 | 1772 | } |
|---|
| 1657 | 1773 | |
|---|
| .. | .. |
|---|
| 1707 | 1823 | switch(m->queue_mode) { |
|---|
| 1708 | 1824 | case DM_TYPE_BIO_BASED: |
|---|
| 1709 | 1825 | DMEMIT("queue_mode bio "); |
|---|
| 1710 | | - break; |
|---|
| 1711 | | - case DM_TYPE_MQ_REQUEST_BASED: |
|---|
| 1712 | | - DMEMIT("queue_mode mq "); |
|---|
| 1713 | 1826 | break; |
|---|
| 1714 | 1827 | default: |
|---|
| 1715 | 1828 | WARN_ON_ONCE(true); |
|---|
| .. | .. |
|---|
| 1803 | 1916 | struct dm_dev *dev; |
|---|
| 1804 | 1917 | struct multipath *m = ti->private; |
|---|
| 1805 | 1918 | action_fn action; |
|---|
| 1919 | + unsigned long flags; |
|---|
| 1806 | 1920 | |
|---|
| 1807 | 1921 | mutex_lock(&m->work_mutex); |
|---|
| 1808 | 1922 | |
|---|
| .. | .. |
|---|
| 1813 | 1927 | |
|---|
| 1814 | 1928 | if (argc == 1) { |
|---|
| 1815 | 1929 | if (!strcasecmp(argv[0], "queue_if_no_path")) { |
|---|
| 1816 | | - r = queue_if_no_path(m, true, false); |
|---|
| 1930 | + r = queue_if_no_path(m, true, false, __func__); |
|---|
| 1931 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1932 | + enable_nopath_timeout(m); |
|---|
| 1933 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1817 | 1934 | goto out; |
|---|
| 1818 | 1935 | } else if (!strcasecmp(argv[0], "fail_if_no_path")) { |
|---|
| 1819 | | - r = queue_if_no_path(m, false, false); |
|---|
| 1936 | + r = queue_if_no_path(m, false, false, __func__); |
|---|
| 1937 | + disable_nopath_timeout(m); |
|---|
| 1820 | 1938 | goto out; |
|---|
| 1821 | 1939 | } |
|---|
| 1822 | 1940 | } |
|---|
| .. | .. |
|---|
| 1864 | 1982 | struct block_device **bdev) |
|---|
| 1865 | 1983 | { |
|---|
| 1866 | 1984 | struct multipath *m = ti->private; |
|---|
| 1867 | | - struct pgpath *current_pgpath; |
|---|
| 1985 | + struct pgpath *pgpath; |
|---|
| 1986 | + unsigned long flags; |
|---|
| 1868 | 1987 | int r; |
|---|
| 1869 | 1988 | |
|---|
| 1870 | | - current_pgpath = READ_ONCE(m->current_pgpath); |
|---|
| 1871 | | - if (!current_pgpath || !test_bit(MPATHF_QUEUE_IO, &m->flags)) |
|---|
| 1872 | | - current_pgpath = choose_pgpath(m, 0); |
|---|
| 1989 | + pgpath = READ_ONCE(m->current_pgpath); |
|---|
| 1990 | + if (!pgpath || !mpath_double_check_test_bit(MPATHF_QUEUE_IO, m)) |
|---|
| 1991 | + pgpath = choose_pgpath(m, 0); |
|---|
| 1873 | 1992 | |
|---|
| 1874 | | - if (current_pgpath) { |
|---|
| 1875 | | - if (!test_bit(MPATHF_QUEUE_IO, &m->flags)) { |
|---|
| 1876 | | - *bdev = current_pgpath->path.dev->bdev; |
|---|
| 1993 | + if (pgpath) { |
|---|
| 1994 | + if (!mpath_double_check_test_bit(MPATHF_QUEUE_IO, m)) { |
|---|
| 1995 | + *bdev = pgpath->path.dev->bdev; |
|---|
| 1877 | 1996 | r = 0; |
|---|
| 1878 | 1997 | } else { |
|---|
| 1879 | 1998 | /* pg_init has not started or completed */ |
|---|
| .. | .. |
|---|
| 1881 | 2000 | } |
|---|
| 1882 | 2001 | } else { |
|---|
| 1883 | 2002 | /* No path is available */ |
|---|
| 2003 | + r = -EIO; |
|---|
| 2004 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1884 | 2005 | if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) |
|---|
| 1885 | 2006 | r = -ENOTCONN; |
|---|
| 1886 | | - else |
|---|
| 1887 | | - r = -EIO; |
|---|
| 2007 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1888 | 2008 | } |
|---|
| 1889 | 2009 | |
|---|
| 1890 | 2010 | if (r == -ENOTCONN) { |
|---|
| .. | .. |
|---|
| 1892 | 2012 | /* Path status changed, redo selection */ |
|---|
| 1893 | 2013 | (void) choose_pgpath(m, 0); |
|---|
| 1894 | 2014 | } |
|---|
| 2015 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 1895 | 2016 | if (test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) |
|---|
| 1896 | | - pg_init_all_paths(m); |
|---|
| 2017 | + (void) __pg_init_all_paths(m); |
|---|
| 2018 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 1897 | 2019 | dm_table_run_md_queue_async(m->ti->table); |
|---|
| 1898 | 2020 | process_queued_io_list(m); |
|---|
| 1899 | 2021 | } |
|---|
| .. | .. |
|---|
| 1953 | 2075 | return true; |
|---|
| 1954 | 2076 | |
|---|
| 1955 | 2077 | /* no paths available, for blk-mq: rely on IO mapping to delay requeue */ |
|---|
| 1956 | | - if (!atomic_read(&m->nr_valid_paths) && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) |
|---|
| 1957 | | - return (m->queue_mode != DM_TYPE_MQ_REQUEST_BASED); |
|---|
| 2078 | + if (!atomic_read(&m->nr_valid_paths)) { |
|---|
| 2079 | + unsigned long flags; |
|---|
| 2080 | + spin_lock_irqsave(&m->lock, flags); |
|---|
| 2081 | + if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) { |
|---|
| 2082 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 2083 | + return (m->queue_mode != DM_TYPE_REQUEST_BASED); |
|---|
| 2084 | + } |
|---|
| 2085 | + spin_unlock_irqrestore(&m->lock, flags); |
|---|
| 2086 | + } |
|---|
| 1958 | 2087 | |
|---|
| 1959 | 2088 | /* Guess which priority_group will be used at next mapping time */ |
|---|
| 1960 | 2089 | pg = READ_ONCE(m->current_pg); |
|---|
| .. | .. |
|---|
| 2005 | 2134 | *---------------------------------------------------------------*/ |
|---|
| 2006 | 2135 | static struct target_type multipath_target = { |
|---|
| 2007 | 2136 | .name = "multipath", |
|---|
| 2008 | | - .version = {1, 13, 0}, |
|---|
| 2137 | + .version = {1, 14, 0}, |
|---|
| 2009 | 2138 | .features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE | |
|---|
| 2010 | 2139 | DM_TARGET_PASSES_INTEGRITY, |
|---|
| 2011 | 2140 | .module = THIS_MODULE, |
|---|
| .. | .. |
|---|
| 2079 | 2208 | module_init(dm_multipath_init); |
|---|
| 2080 | 2209 | module_exit(dm_multipath_exit); |
|---|
| 2081 | 2210 | |
|---|
| 2211 | +module_param_named(queue_if_no_path_timeout_secs, |
|---|
| 2212 | + queue_if_no_path_timeout_secs, ulong, S_IRUGO | S_IWUSR); |
|---|
| 2213 | +MODULE_PARM_DESC(queue_if_no_path_timeout_secs, "No available paths queue IO timeout in seconds"); |
|---|
| 2214 | + |
|---|
| 2082 | 2215 | MODULE_DESCRIPTION(DM_NAME " multipath target"); |
|---|
| 2083 | 2216 | MODULE_AUTHOR("Sistina Software <dm-devel@redhat.com>"); |
|---|
| 2084 | 2217 | MODULE_LICENSE("GPL"); |
|---|