Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp51437ybg; Mon, 8 Jun 2020 16:10:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySfYRsL3XdlyxcMp89if5boMlQFiVcwIOxl9Km3z80cO3wzuhe+gWat0Jsm/kDwpnot+91 X-Received: by 2002:aa7:cb8d:: with SMTP id r13mr23381473edt.12.1591657848697; Mon, 08 Jun 2020 16:10:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591657848; cv=none; d=google.com; s=arc-20160816; b=cCbVpRyhm7FKGuZ1Ymv3zU0ntVUhbmYS9Gf32KWuDxSLtkt66KfRVdDftCLaHaCTLQ 1tGbO55oo2+nYTurymjSPrTJr38oeXZBOb7NDBlaZCP/eRb9V4btGXSaXxPjK3Dmycik DK3ua27TEu9P3Qhb8ynwiq/H6VSRJrR0gije5jJEzcjS120j42/lwkpApKHuJMx9xn7N AXz202xhQTyB3cJdsOjE96LGVFQbzHx+ouVMbXn9aaCLzHf9VRj+DEjj//eaPkpg3QuU iDiE4rVkxL8XcD2ZaPD0isPBA12byyeISBtTI4VTNfv8+QBGJSVDiC0HBcvL9ihfuYmk 0nUg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Uy9tuToYDJQs8vYxEvGAUAubr+qaVYTBqKr5XoV+RZ4=; b=iwxD/tRb4ecPQhx3BstAkV/hLnXKfdLwDMw8fi9Jq3c/Tqq2pMLoyPAuekOaYuN/o3 v5fYTT8f+GfYU+A0iBdOwwZzItYKeX04FWp6RyXUmkeBVt5XiaKL6mXfVWADWLaaZvUY CQst7iFfI4bO2oRgPgHLu+RRB/9uiYaKZ/pvXoVBykIAA3ERo1ctMxdBVH9pZiJI7oyv 2hGJIMi6b1NSPjurhhHOSLgYCUiwwNsWFtGQ/VvlG8Qe2m9FUE6pDDtd88V34H0o+IFh Zggcydw+r1sUyGdSjKlUUSm2VSKwiehSADlg/5WaAV6gOFPVqzZs4frDkPveudIc/tvF N6FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZVX7vW6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by19si9670079ejb.216.2020.06.08.16.10.26; Mon, 08 Jun 2020 16:10:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZVX7vW6v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbgFHXH6 (ORCPT + 99 others); Mon, 8 Jun 2020 19:07:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727833AbgFHXHO (ORCPT ); Mon, 8 Jun 2020 19:07:14 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 087F020890; Mon, 8 Jun 2020 23:07:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657633; bh=k4MFnelTjmAk2L09uBdFWuoRP2HDkQ+mXFg2HOps2v0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVX7vW6v8iqJHZXuGpNHWmisgS+lZK+pE0vkw0bdXQFEHRcqupt2uddSCKdrVPyW/ ex+aQmT6zIWtND/cBUF59+mu/AdVuYOMGmI3l6h9E191O4GHMOuUvNlYgftvvUrRiX DsGnaG1rT8mAbjquRTrnbbKfUo29RvWD9Ky7Oyrc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jens Axboe , Sasha Levin , linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 052/274] io_uring: cleanup io_poll_remove_one() logic Date: Mon, 8 Jun 2020 19:02:25 -0400 Message-Id: <20200608230607.3361041-52-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jens Axboe [ Upstream commit 3bfa5bcb26f0b52d7ae8416aa0618fff21aceaaf ] We only need apoll in the one section, do the juggling with the work restoration there. This removes a special case further down as well. No functional changes in this patch. Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index bb25e3997d41..03147b6694fd 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4344,32 +4344,31 @@ static bool __io_poll_remove_one(struct io_kiocb *req, do_complete = true; } spin_unlock(&poll->head->lock); + hash_del(&req->hash_node); return do_complete; } static bool io_poll_remove_one(struct io_kiocb *req) { - struct async_poll *apoll = NULL; bool do_complete; if (req->opcode == IORING_OP_POLL_ADD) { do_complete = __io_poll_remove_one(req, &req->poll); } else { - apoll = req->apoll; + struct async_poll *apoll = req->apoll; + /* non-poll requests have submit ref still */ - do_complete = __io_poll_remove_one(req, &req->apoll->poll); - if (do_complete) + do_complete = __io_poll_remove_one(req, &apoll->poll); + if (do_complete) { io_put_req(req); - } - - hash_del(&req->hash_node); - - if (do_complete && apoll) { - /* - * restore ->work because we need to call io_req_work_drop_env. - */ - memcpy(&req->work, &apoll->work, sizeof(req->work)); - kfree(apoll); + /* + * restore ->work because we will call + * io_req_work_drop_env below when dropping the + * final reference. + */ + memcpy(&req->work, &apoll->work, sizeof(req->work)); + kfree(apoll); + } } if (do_complete) { -- 2.25.1