Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3803322ybi; Mon, 29 Jul 2019 12:57:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmtMcKDtXgRmPpcy7G5w8Sep0kcEnKgFxs7FfoEue6bT/N4m+GDvfdNFQnTZCrvGZMD2rJ X-Received: by 2002:a17:90a:8d0c:: with SMTP id c12mr109524255pjo.140.1564430243632; Mon, 29 Jul 2019 12:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430243; cv=none; d=google.com; s=arc-20160816; b=l7Wk1J2fr3QxG2IPlvTbafyqueQlUK+5F/nxepd4EKG5s8E+l3QdGGXExKu9UoJhUO DXuqloY0o3YAVbdsaO+UwGpZbtm+yTFcHEyhuopjJr4HesZuWXc/mYurmuDT9rwGCBHE jB6Gz5xfjQTg3qyR/IgSEORPPCNHyEd5fTk53ER9NtxR9r2SaLs4A0abQsg35xZwrNPZ Pyl9cxIlNq8R7eqn8fr9nXyshde8Gb+LkgYa6ZZc/rUQd8S1LM6Vi+wMD37nYt7McmtV uknCvLXQeVbciJqFH2DuihUs2Pl8w2jYdrD3/WBZugCTCkVLLLLGNjH5WnSeomIEizmo 4yGg== 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=1PmJ/dcWd7ihFkdGO7yOMvjjw+oPuubw/z93ku5Z9RY=; b=HhDGVILnee8vtkFBzBUPuGtrMkLUen0gfhkn9We82Ju9vDnSSK99Mc1/UJ4MikPgom S3YcGCANl2+SDxIjr+zYqjNpQE4HmfEyOIDmdjJ6bfAuOCTO3g92bajAYTSlbEx46OZP oC/+63W12h4IhooDDM3VTaCxm7yXyyv7ADgH+Rw6+lF7KeaJZ++irQHfYJRbV4cSEL4C BSeKG/BFWjXjgEyaRDR9sN7UYmtNbrcXsS3yJ7Du+zRNwjIcnEVsemm6oVOFeeEs0mM4 PpBqOgy+pxugryZU0yrtbqEzwbbcWz5ACnZ88Y9KhrGTDuIAOkI0HsKH+nhhTmv+v5x1 Gm1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xY5aNFEs; 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 b35si27003407plb.249.2019.07.29.12.57.08; Mon, 29 Jul 2019 12:57:23 -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=xY5aNFEs; 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 S2404280AbfG2Tz6 (ORCPT + 99 others); Mon, 29 Jul 2019 15:55:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:48732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404209AbfG2Tzx (ORCPT ); Mon, 29 Jul 2019 15:55:53 -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 6F5F521655; Mon, 29 Jul 2019 19:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430152; bh=CE4tJhHZBKHyEGCRqLRINiu4ABLaoH6P3gMjy31Nk0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xY5aNFEs7ocjv5PVYaX89K/e3w/Gn7PUPkKFEX7aOBWdWldgrsHqvkurvQiHkZ6pj kvWUO+RS4UNyRW2RS36qzaOuwyHBjh/RiaLL6eBuio4FKUCCezuj32lqgkM8LUK2fs Y1Lpmbh+apeNbKX1KN1K4CRRhubExN++F8QXuBc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhengyuan Liu , Jens Axboe Subject: [PATCH 5.2 214/215] io_uring: fix counter inc/dec mismatch in async_list Date: Mon, 29 Jul 2019 21:23:30 +0200 Message-Id: <20190729190816.978581666@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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: Zhengyuan Liu commit f7b76ac9d17e16e44feebb6d2749fec92bfd6dd4 upstream. We could queue a work for each req in defer and link list without increasing async_list->cnt, so we shouldn't decrease it while exiting from workqueue as well if we didn't process the req in async list. Thanks to Jens Axboe for his guidance. Fixes: 31b515106428 ("io_uring: allow workqueue item to handle multiple buffered requests") Signed-off-by: Zhengyuan Liu Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -331,6 +331,9 @@ struct io_kiocb { #define REQ_F_SEQ_PREV 8 /* sequential with previous */ #define REQ_F_IO_DRAIN 16 /* drain existing IO first */ #define REQ_F_IO_DRAINED 32 /* drain done */ +#define REQ_F_LINK 64 /* linked sqes */ +#define REQ_F_LINK_DONE 128 /* linked sqes done */ +#define REQ_F_FAIL_LINK 256 /* fail rest of links */ u64 user_data; u32 error; /* iopoll result from callback */ u32 sequence; @@ -1698,6 +1701,10 @@ restart: /* async context always use a copy of the sqe */ kfree(sqe); + /* req from defer and link list needn't decrease async cnt */ + if (req->flags & (REQ_F_IO_DRAINED | REQ_F_LINK_DONE)) + goto out; + if (!async_list) break; if (!list_empty(&req_list)) { @@ -1745,6 +1752,7 @@ restart: } } +out: if (cur_mm) { set_fs(old_fs); unuse_mm(cur_mm);