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
1488314883 F: include/uapi/linux/arm_sdei.h
1488414884
1488514885 SOFTWARE RAID (Multiple Disks) SUPPORT
14886−M: Shaohua Li <shli@kernel.org>
14886+M: Song Liu <song@kernel.org>
1488714887 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
1488914889 S: Supported
1489014890 F: drivers/md/Makefile
1489114891 F: 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
22572257 .vid = 0x1179,
22582258 .mn = "THNSF5256GPUK TOSHIBA",
22592259 .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,
22602270 }
22612271 };
22622272
@@ -2597,6 +2607,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 334 unmodified lines
25972607 goto out_free;
25982608 }
25992609
2610+ if (!(ctrl->ops->flags & NVME_F_FABRICS))
2611+ ctrl->cntlid = le16_to_cpu(id->cntlid);
2612+
26002613 if (!ctrl->identified) {
26012614 int i;
26022615
@@ -2697,7 +2710,6 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) · 94 unmodified lines
26972710 goto out_free;
26982711 }
26992712 } else {
2700− ctrl->cntlid = le16_to_cpu(id->cntlid);
27012713 ctrl->hmpre = le32_to_cpu(id->hmpre);
27022714 ctrl->hmmin = le32_to_cpu(id->hmmin);
27032715 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
428428 srcu_read_unlock(&head->srcu, srcu_idx);
429429 }
430430
431+ synchronize_srcu(&ns->head->srcu);
431432 kblockd_schedule_work(&ns->head->requeue_work);
432433 }
433434
drivers/nvme/host/nvme.h+5−0
@@ -92,6 +92,11 @@ enum nvme_quirks { · 91 unmodified lines
9292 * Broken Write Zeroes.
9393 */
9494 NVME_QUIRK_DISABLE_WRITE_ZEROES = (1 << 9),
95+
96+ /*
97+ * Force simple suspend/resume path.
98+ */
99+ NVME_QUIRK_SIMPLE_SUSPEND = (1 << 10),
95100 };
96101
97102 /*
drivers/nvme/host/pci.c+2−1
@@ -2876,7 +2876,8 @@ static int nvme_suspend(struct device *dev) · 2875 unmodified lines
28762876 * state (which may not be possible if the link is up).
28772877 */
28782878 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)) {
28802881 nvme_dev_disable(ndev, true);
28812882 return 0;
28822883 }
fs/io_uring.c+47−19
@@ -679,6 +679,13 @@ static void io_put_req(struct io_kiocb *req) · 678 unmodified lines
679679 io_free_req(req);
680680 }
681681
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+
682689 /*
683690 * Find and free completed poll iocbs
684691 */
@@ -771,7 +778,7 @@ static int io_do_iopoll(struct io_ring_ctx *ctx, unsigned int *nr_events, · 86 unmodified lines
771778 static int io_iopoll_getevents(struct io_ring_ctx *ctx, unsigned int *nr_events,
772779 long min)
773780 {
774− while (!list_empty(&ctx->poll_list)) {
781+ while (!list_empty(&ctx->poll_list) && !need_resched()) {
775782 int ret;
776783
777784 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
798805 unsigned int nr_events = 0;
799806
800807 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();
801814 }
802815 mutex_unlock(&ctx->uring_lock);
803816 }
@@ -805,11 +818,42 @@ static void io_iopoll_reap_events(struct io_ring_ctx *ctx) · 1 unmodified line
805818 static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events,
806819 long min)
807820 {
808− int ret = 0;
821+ int iters, ret = 0;
809822
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;
810831 do {
811832 int tmin = 0;
812833
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+
813857 if (*nr_events < min)
814858 tmin = min - *nr_events;
815859
@@ -819,6 +863,7 @@ static int io_iopoll_check(struct io_ring_ctx *ctx, unsigned *nr_events, · 3 unmodified lines
819863 ret = 0;
820864 } while (min && !*nr_events && !need_resched());
821865
866+ mutex_unlock(&ctx->uring_lock);
822867 return ret;
823868 }
824869
@@ -2280,15 +2325,7 @@ static int io_sq_thread(void *data) · 1455 unmodified lines
22802325 unsigned nr_events = 0;
22812326
22822327 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);
22902328 io_iopoll_check(ctx, &nr_events, 0);
2291− mutex_unlock(&ctx->uring_lock);
22922329 } else {
22932330 /*
22942331 * 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
24332470 return submit;
24342471 }
24352472
2436−static 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−
24432473 /*
24442474 * Wait until events become available, if we don't already have some. The
24452475 * 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
31903220 min_complete = min(min_complete, ctx->cq_entries);
31913221
31923222 if (ctx->flags & IORING_SETUP_IOPOLL) {
3193− mutex_lock(&ctx->uring_lock);
31943223 ret = io_iopoll_check(ctx, &nr_events, min_complete);
3195− mutex_unlock(&ctx->uring_lock);
31963224 } else {
31973225 ret = io_cqring_wait(ctx, min_complete, sig, sigsz);
31983226 }

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