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

Merge tag 'for-linus-20190823' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"Here's a set of fixes that should go into this release. This contains:

- Three minor fixes for NVMe.

- Three minor tweaks for the io_uring polling logic.

- Officially mark Song as the MD maintainer, after he's been filling
that role sucessfully for the last 6 months or so"

* tag 'for-linus-20190823' of git://git.kernel.dk/linux-block:
io_uring: add need_resched() check in inner poll loop
md: update MAINTAINERS info
io_uring: don't enter poll loop if we have CQEs pending
nvme: Add quirk for LiteON CL1 devices running FW 22301111
nvme: Fix cntlid validation when not using NVMEoF
nvme-multipath: fix possible I/O hang when paths are updated
io_uring: fix potential hang with polled IO

+70 -23
+2 -2
MAINTAINERS
··· 14883 14883 F: include/uapi/linux/arm_sdei.h 14884 14884 14885 14885 SOFTWARE RAID (Multiple Disks) SUPPORT 14886 - M: Shaohua Li <shli@kernel.org> 14886 + M: Song Liu <song@kernel.org> 14887 14887 L: linux-raid@vger.kernel.org 14888 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/shli/md.git 14888 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/song/md.git 14889 14889 S: Supported 14890 14890 F: drivers/md/Makefile 14891 14891 F: drivers/md/Kconfig
+13 -1
drivers/nvme/host/core.c
··· 2257 2257 .vid = 0x1179, 2258 2258 .mn = "THNSF5256GPUK TOSHIBA", 2259 2259 .quirks = NVME_QUIRK_NO_APST, 2260 + }, 2261 + { 2262 + /* 2263 + * This LiteON CL1-3D*-Q11 firmware version has a race 2264 + * condition associated with actions related to suspend to idle 2265 + * LiteON has resolved the problem in future firmware 2266 + */ 2267 + .vid = 0x14a4, 2268 + .fr = "22301111", 2269 + .quirks = NVME_QUIRK_SIMPLE_SUSPEND, 2260 2270 } 2261 2271 }; 2262 2272 ··· 2607 2597 goto out_free; 2608 2598 } 2609 2599 2600 + if (!(ctrl->ops->flags & NVME_F_FABRICS)) 2601 + ctrl->cntlid = le16_to_cpu(id->cntlid); 2602 + 2610 2603 if (!ctrl->identified) { 2611 2604 int i; 2612 2605 ··· 2710 2697 goto out_free; 2711 2698 } 2712 2699 } else { 2713 - ctrl->cntlid = le16_to_cpu(id->cntlid); 2714 2700 ctrl->hmpre = le32_to_cpu(id->hmpre); 2715 2701 ctrl->hmmin = le32_to_cpu(id->hmmin); 2716 2702 ctrl->hmminds = le32_to_cpu(id->hmminds);
+1
drivers/nvme/host/multipath.c
··· 428 428 srcu_read_unlock(&head->srcu, srcu_idx); 429 429 } 430 430 431 + synchronize_srcu(&ns->head->srcu); 431 432 kblockd_schedule_work(&ns->head->requeue_work); 432 433 } 433 434
+5
drivers/nvme/host/nvme.h
··· 92 92 * Broken Write Zeroes. 93 93 */ 94 94 NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9), 95 + 96 + /* 97 + * Force simple suspend/resume path. 98 + */ 99 + NVME_QUIRK_SIMPLE_SUSPEND = (1 << 10), 95 100 }; 96 101 97 102 /*
+2 -1
drivers/nvme/host/pci.c
··· 2876 2876 * state (which may not be possible if the link is up). 2877 2877 */ 2878 2878 if (pm_suspend_via_firmware() || !ctrl->npss || 2879 - !pcie_aspm_enabled(pdev)) { 2879 + !pcie_aspm_enabled(pdev) || 2880 + (ndev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND)) { 2880 2881 nvme_dev_disable(ndev, true); 2881 2882 return 0; 2882 2883 }
+47 -19
fs/io_uring.c
··· 679 679 io_free_req(req); 680 680 } 681 681 682 + static unsigned io_cqring_events(struct io_cq_ring *ring) 683 + { 684 + /* See comment at the top of this file */ 685 + smp_rmb(); 686 + return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head); 687 + } 688 + 682 689 /* 683 690 * Find and free completed poll iocbs 684 691 */ ··· 778 771 static int io_iopoll_getevents(struct io_ring_ctx *ctx, unsigned int *nr_events, 779 772 long min) 780 773 { 781 - while (!list_empty(&ctx->poll_list)) { 774 + while (!list_empty(&ctx->poll_list) && !need_resched()) { 782 775 int ret; 783 776 784 777 ret = io_do_iopoll(ctx, nr_events, min); ··· 805 798 unsigned int nr_events = 0; 806 799 807 800 io_iopoll_getevents(ctx, &nr_events, 1); 801 + 802 + /* 803 + * Ensure we allow local-to-the-cpu processing to take place, 804 + * in this case we need to ensure that we reap all events. 805 + */ 806 + cond_resched(); 808 807 } 809 808 mutex_unlock(&ctx->uring_lock); 810 809 } ··· 818 805 static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events, 819 806 long min) 820 807 { 821 - int ret = 0; 808 + int iters, ret = 0; 822 809 810 + /* 811 + * We disallow the app entering submit/complete with polling, but we 812 + * still need to lock the ring to prevent racing with polled issue 813 + * that got punted to a workqueue. 814 + */ 815 + mutex_lock(&ctx->uring_lock); 816 + 817 + iters = 0; 823 818 do { 824 819 int tmin = 0; 820 + 821 + /* 822 + * Don't enter poll loop if we already have events pending. 823 + * If we do, we can potentially be spinning for commands that 824 + * already triggered a CQE (eg in error). 825 + */ 826 + if (io_cqring_events(ctx->cq_ring)) 827 + break; 828 + 829 + /* 830 + * If a submit got punted to a workqueue, we can have the 831 + * application entering polling for a command before it gets 832 + * issued. That app will hold the uring_lock for the duration 833 + * of the poll right here, so we need to take a breather every 834 + * now and then to ensure that the issue has a chance to add 835 + * the poll to the issued list. Otherwise we can spin here 836 + * forever, while the workqueue is stuck trying to acquire the 837 + * very same mutex. 838 + */ 839 + if (!(++iters & 7)) { 840 + mutex_unlock(&ctx->uring_lock); 841 + mutex_lock(&ctx->uring_lock); 842 + } 825 843 826 844 if (*nr_events < min) 827 845 tmin = min - *nr_events; ··· 863 819 ret = 0; 864 820 } while (min && !*nr_events && !need_resched()); 865 821 822 + mutex_unlock(&ctx->uring_lock); 866 823 return ret; 867 824 } 868 825 ··· 2325 2280 unsigned nr_events = 0; 2326 2281 2327 2282 if (ctx->flags & IORING_SETUP_IOPOLL) { 2328 - /* 2329 - * We disallow the app entering submit/complete 2330 - * with polling, but we still need to lock the 2331 - * ring to prevent racing with polled issue 2332 - * that got punted to a workqueue. 2333 - */ 2334 - mutex_lock(&ctx->uring_lock); 2335 2283 io_iopoll_check(ctx, &nr_events, 0); 2336 - mutex_unlock(&ctx->uring_lock); 2337 2284 } else { 2338 2285 /* 2339 2286 * Normal IO, just pretend everything completed. ··· 2468 2431 io_submit_state_end(statep); 2469 2432 2470 2433 return submit; 2471 - } 2472 - 2473 - static unsigned io_cqring_events(struct io_cq_ring *ring) 2474 - { 2475 - /* See comment at the top of this file */ 2476 - smp_rmb(); 2477 - return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head); 2478 2434 } 2479 2435 2480 2436 /* ··· 3220 3190 min_complete = min(min_complete, ctx->cq_entries); 3221 3191 3222 3192 if (ctx->flags & IORING_SETUP_IOPOLL) { 3223 - mutex_lock(&ctx->uring_lock); 3224 3193 ret = io_iopoll_check(ctx, &nr_events, min_complete); 3225 - mutex_unlock(&ctx->uring_lock); 3226 3194 } else { 3227 3195 ret = io_cqring_wait(ctx, min_complete, sig, sigsz); 3228 3196 }