History

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

Linus Torvalds committed 7 years ago

Commit b9bd6802 parents dd469a4 08f54396 files · +70 −23Browse files

Unified · Split

6 files
  1. MAINTAINERS +2 −2
  2. drivers/nvme/host/core.c +13 −1
  3. drivers/nvme/host/multipath.c +1 −0
  4. drivers/nvme/host/nvme.h +5 −0
  5. drivers/nvme/host/pci.c +2 −1
  6. fs/io_uring.c +47 −19
MAINTAINERS+2−2
@@ -14883,9 +14883,9 @@ F: include/linux/arm_sdei.h · 14882 unmodified lines
14883F: include/uapi/linux/arm_sdei.h14883F: include/uapi/linux/arm_sdei.h
14884 14884
14885SOFTWARE RAID (Multiple Disks) SUPPORT14885SOFTWARE RAID (Multiple Disks) SUPPORT
14886M: Shaohua Li <shli@kernel.org>14886M: Song Liu <song@kernel.org>
14887L: linux-raid@vger.kernel.org14887L: linux-raid@vger.kernel.org
14888T: git git://git.kernel.org/pub/scm/linux/kernel/git/shli/md.git14888T: git git://git.kernel.org/pub/scm/linux/kernel/git/song/md.git
14889S: Supported14889S: Supported
14890F: drivers/md/Makefile14890F: drivers/md/Makefile
14891F: drivers/md/Kconfig14891F: drivers/md/Kconfig
drivers/nvme/host/core.c+13−1
@@ -2257,6 +2257,16 @@ static const struct nvme_core_quirk_entry core_quirks[] = { · 2256 unmodified lines
2257 .vid = 0x1179,2257 .vid = 0x1179,
2258 .mn = "THNSF5256GPUK TOSHIBA",2258 .mn = "THNSF5256GPUK TOSHIBA",
2259 .quirks = NVME_QUIRK_NO_APST,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
@@ -2597,6 +2607,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 334 unmodified lines
2597 goto out_free;2607 goto out_free;
2598 }2608 }
2599 2609
2610 if (!(ctrl->ops->flags & NVME_F_FABRICS))
2611 ctrl->cntlid = le16_to_cpu(id->cntlid);
2612
2600 if (!ctrl->identified) {2613 if (!ctrl->identified) {
2601 int i;2614 int i;
2602 2615
@@ -2697,7 +2710,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 94 unmodified lines
2697 goto out_free;2710 goto out_free;
2698 }2711 }
2699 } else {2712 } else {
2700 ctrl->cntlid = le16_to_cpu(id->cntlid);
2701 ctrl->hmpre = le32_to_cpu(id->hmpre);2713 ctrl->hmpre = le32_to_cpu(id->hmpre);
2702 ctrl->hmmin = le32_to_cpu(id->hmmin);2714 ctrl->hmmin = le32_to_cpu(id->hmmin);
2703 ctrl->hmminds = le32_to_cpu(id->hmminds);2715 ctrl->hmminds = le32_to_cpu(id->hmminds);
drivers/nvme/host/multipath.c+1−0
@@ -428,6 +428,7 @@ static void nvme_mpath_set_live(struct nvme_ns *ns) · 427 unmodified lines
428 srcu_read_unlock(&head->srcu, srcu_idx);428 srcu_read_unlock(&head->srcu, srcu_idx);
429 }429 }
430 430
431 synchronize_srcu(&ns->head->srcu);
431 kblockd_schedule_work(&ns->head->requeue_work);432 kblockd_schedule_work(&ns->head->requeue_work);
432}433}
433 434
drivers/nvme/host/nvme.h+5−0
@@ -92,6 +92,11 @@ enum nvme_quirks { · 91 unmodified lines
92 * Broken Write Zeroes.92 * Broken Write Zeroes.
93 */93 */
94 NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9),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/*
drivers/nvme/host/pci.c+2−1
@@ -2876,7 +2876,8 @@ static int nvme_suspend(struct device *dev) · 2875 unmodified lines
2876 * state (which may not be possible if the link is up).2876 * state (which may not be possible if the link is up).
2877 */2877 */
2878 if (pm_suspend_via_firmware() || !ctrl->npss ||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 nvme_dev_disable(ndev, true);2881 nvme_dev_disable(ndev, true);
2881 return 0;2882 return 0;
2882 }2883 }
fs/io_uring.c+47−19
@@ -679,6 +679,13 @@ static void io_put_req(struct io_kiocb *req) · 678 unmodified lines
679 io_free_req(req);679 io_free_req(req);
680}680}
681 681
682static 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 * Find and free completed poll iocbs690 * Find and free completed poll iocbs
684 */691 */
@@ -771,7 +778,7 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, · 86 unmodified lines
771static int io_iopoll_getevents(struct io_ring_ctx *ctx, unsigned int *nr_events,778static int io_iopoll_getevents(struct io_ring_ctx *ctx, unsigned int *nr_events,
772 long min)779 long min)
773{780{
774 while (!list_empty(&ctx->poll_list)) {781 while (!list_empty(&ctx->poll_list) && !need_resched()) {
775 int ret;782 int ret;
776 783
777 ret = io_do_iopoll(ctx, nr_events, min);784 ret = io_do_iopoll(ctx, nr_events, min);
@@ -798,6 +805,12 @@ static void io_iopoll_reap_events(struct io_ring_ctx *ctx) · 20 unmodified lines
798 unsigned int nr_events = 0;805 unsigned int nr_events = 0;
799 806
800 io_iopoll_getevents(ctx, &nr_events, 1);807 io_iopoll_getevents(ctx, &nr_events, 1);
808
809 /*
810 * Ensure we allow local-to-the-cpu processing to take place,
811 * in this case we need to ensure that we reap all events.
812 */
813 cond_resched();
801 }814 }
802 mutex_unlock(&ctx->uring_lock);815 mutex_unlock(&ctx->uring_lock);
803}816}
@@ -805,11 +818,42 @@ static void io_iopoll_reap_events(struct io_ring_ctx *ctx) · 1 unmodified line
805static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events,818static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events,
806 long min)819 long min)
807{820{
808 int ret = 0;821 int iters, ret = 0;
809 822
823 /*
824 * We disallow the app entering submit/complete with polling, but we
825 * still need to lock the ring to prevent racing with polled issue
826 * that got punted to a workqueue.
827 */
828 mutex_lock(&ctx->uring_lock);
829
830 iters = 0;
810 do {831 do {
811 int tmin = 0;832 int tmin = 0;
812 833
834 /*
835 * Don't enter poll loop if we already have events pending.
836 * If we do, we can potentially be spinning for commands that
837 * already triggered a CQE (eg in error).
838 */
839 if (io_cqring_events(ctx->cq_ring))
840 break;
841
842 /*
843 * If a submit got punted to a workqueue, we can have the
844 * application entering polling for a command before it gets
845 * issued. That app will hold the uring_lock for the duration
846 * of the poll right here, so we need to take a breather every
847 * now and then to ensure that the issue has a chance to add
848 * the poll to the issued list. Otherwise we can spin here
849 * forever, while the workqueue is stuck trying to acquire the
850 * very same mutex.
851 */
852 if (!(++iters & 7)) {
853 mutex_unlock(&ctx->uring_lock);
854 mutex_lock(&ctx->uring_lock);
855 }
856
813 if (*nr_events < min)857 if (*nr_events < min)
814 tmin = min - *nr_events;858 tmin = min - *nr_events;
815 859
@@ -819,6 +863,7 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events, · 3 unmodified lines
819 ret = 0;863 ret = 0;
820 } while (min && !*nr_events && !need_resched());864 } while (min && !*nr_events && !need_resched());
821 865
866 mutex_unlock(&ctx->uring_lock);
822 return ret;867 return ret;
823}868}
824 869
@@ -2280,15 +2325,7 @@ static int io_sq_thread(void *data) · 1455 unmodified lines
2280 unsigned nr_events = 0;2325 unsigned nr_events = 0;
2281 2326
2282 if (ctx->flags & IORING_SETUP_IOPOLL) {2327 if (ctx->flags & IORING_SETUP_IOPOLL) {
2283 /*
2284 * We disallow the app entering submit/complete
2285 * with polling, but we still need to lock the
2286 * ring to prevent racing with polled issue
2287 * that got punted to a workqueue.
2288 */
2289 mutex_lock(&ctx->uring_lock);
2290 io_iopoll_check(ctx, &nr_events, 0);2328 io_iopoll_check(ctx, &nr_events, 0);
2291 mutex_unlock(&ctx->uring_lock);
2292 } else {2329 } else {
2293 /*2330 /*
2294 * Normal IO, just pretend everything completed.2331 * Normal IO, just pretend everything completed.
@@ -2433,13 +2470,6 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit) · 138 unmodified lines
2433 return submit;2470 return submit;
2434}2471}
2435 2472
2436static unsigned io_cqring_events(struct io_cq_ring *ring)
2437{
2438 /* See comment at the top of this file */
2439 smp_rmb();
2440 return READ_ONCE(ring->r.tail) - READ_ONCE(ring->r.head);
2441}
2442
2443/*2473/*
2444 * Wait until events become available, if we don't already have some. The2474 * Wait until events become available, if we don't already have some. The
2445 * application must reap them itself, as they reside on the shared cq ring.2475 * application must reap them itself, as they reside on the shared cq ring.
@@ -3190,9 +3220,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit, · 744 unmodified lines
3190 min_complete = min(min_complete, ctx->cq_entries);3220 min_complete = min(min_complete, ctx->cq_entries);
3191 3221
3192 if (ctx->flags & IORING_SETUP_IOPOLL) {3222 if (ctx->flags & IORING_SETUP_IOPOLL) {
3193 mutex_lock(&ctx->uring_lock);
3194 ret = io_iopoll_check(ctx, &nr_events, min_complete);3223 ret = io_iopoll_check(ctx, &nr_events, min_complete);
3195 mutex_unlock(&ctx->uring_lock);
3196 } else {3224 } else {
3197 ret = io_cqring_wait(ctx, min_complete, sig, sigsz);3225 ret = io_cqring_wait(ctx, min_complete, sig, sigsz);
3198 }3226 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t