Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp63514ybp; Thu, 3 Oct 2019 10:12:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzh/wESfFC+5fyCmoVeZnXEqC7B7AlnkNJQalX7phieDSqG7yK+pqlRumV02e90fGZSgQRN X-Received: by 2002:a50:9e65:: with SMTP id z92mr10733510ede.49.1570122766488; Thu, 03 Oct 2019 10:12:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570122766; cv=none; d=google.com; s=arc-20160816; b=sKSd2hKn/ZShN4ajP7S0Z0sKqrT1WmbzkVRUY3NabRBWa8qb/LEhfvikGjDEhCy1Xi Ku6TJPfy1onMjvugAomJ5U2lfFjEBR/+LS7N2NW14XektaNJ4CBzP4P9YyyKV6eEVxfC F4y/CxYFhjFzUyBPPvV9MH8rHxePy9XluNGQO4IEbFaIxl/ZbebyG0hYJa23fnG12gI0 33bt43ml+6PS1/8RATG9xBuYAFKDyH3hn9YRmIPULwnNKv396+mbYWtmTYUPWF4wBcpk pexADZq++f6L5L8y7tBMiMmKiwbfZbBucbUs0abAGYqCmaqNnioMtDBCkt40BosXRkQv Jovw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SXcDZX2sY95/ydhDiZRK+g4wuEl5ZqKXvye+/Q3ICIw=; b=ZghPNgdOJeNOabJ5tRWRLt8fylHsR/lagVaYsch0vXnkHFZfvsmAM0CA4aS+jjCjVU I/FGfQyE6G/EO36iIAj08Yl/P7leujS2SSvaKbw4zXa5HqxVOoVHdpXAOeAHngLDCq5R MbkxNTbbWDe7dRnP2VBxeeIV/laSJFyApiiQHDV14VslbE/8/b9eU1AzSnqxVV7/NeTK KjdXMlujzFJBm5UIh9bkOZxB365kEABlWa2ZDwplOyqsXOlKwWRAAcQ1t8IB9I4uf6ej VMGUJxQyJDI/Xo06eTx7XfILncHy2LlQCS4cUVtVucIRMa/HC7538QPDGCIoqJ7KNfcE neyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V7ChofLc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si1548978eju.100.2019.10.03.10.12.21; Thu, 03 Oct 2019 10:12:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V7ChofLc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391916AbfJCQcZ (ORCPT + 99 others); Thu, 3 Oct 2019 12:32:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:39872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391903AbfJCQcV (ORCPT ); Thu, 3 Oct 2019 12:32:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F4FB215EA; Thu, 3 Oct 2019 16:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570120341; bh=PO6/JpMM8870A6I/uwuOSfPrmhKU+aElITomc83RwyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V7ChofLcCuyIvEvAIuuRtfox4T4gIsTnOqgsvM2VhYp3aKPHeKqitKA+qZkmMmh41 r2xtismJgGAGB9PmYYTW2fAbfiA2X7TRFyEZvv1VwUDRSEyxzKbO3YOYQ3UHeMCdUy +1O47idurCYf9y8pd0vmy0HtN7xlz9SglQLb+40I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jackie Liu , Jens Axboe , Sasha Levin Subject: [PATCH 5.2 186/313] io_uring: fix wrong sequence setting logic Date: Thu, 3 Oct 2019 17:52:44 +0200 Message-Id: <20191003154551.305735543@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154533.590915454@linuxfoundation.org> References: <20191003154533.590915454@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jackie Liu [ Upstream commit 8776f3fa15a5cd213c4dfab7ddaf557983374ea6 ] Sqo_thread will get sqring in batches, which will cause ctx->cached_sq_head to be added in batches. if one of these sqes is set with the DRAIN flag, then he will never get a chance to process, and finally sqo_thread will not exit. Fixes: de0617e4671 ("io_uring: add support for marking commands as draining") Signed-off-by: Jackie Liu Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 03cd8f5bba850..701936f2bde39 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -288,6 +288,7 @@ struct io_ring_ctx { struct sqe_submit { const struct io_uring_sqe *sqe; unsigned short index; + u32 sequence; bool has_user; bool needs_lock; bool needs_fixed_file; @@ -1894,7 +1895,7 @@ static int io_req_set_file(struct io_ring_ctx *ctx, const struct sqe_submit *s, if (flags & IOSQE_IO_DRAIN) { req->flags |= REQ_F_IO_DRAIN; - req->sequence = ctx->cached_sq_head - 1; + req->sequence = s->sequence; } if (!io_op_needs_file(s->sqe)) @@ -2050,6 +2051,7 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s) if (head < ctx->sq_entries) { s->index = head; s->sqe = &ctx->sq_sqes[head]; + s->sequence = ctx->cached_sq_head; ctx->cached_sq_head++; return true; } -- 2.20.1