Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2640836ybf; Mon, 2 Mar 2020 12:46:37 -0800 (PST) X-Google-Smtp-Source: ADFU+vsFa0+Tawgg70JaknftG9MF+SgxvGZfriFO/EqUtbeKFnrRdF8FrQ+OKPavwIjVhgTI3SUJ X-Received: by 2002:aca:4858:: with SMTP id v85mr187559oia.51.1583181997370; Mon, 02 Mar 2020 12:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583181997; cv=none; d=google.com; s=arc-20160816; b=QLRU1gLR8Fmoe/H/lTZZr7756OjaAQosgpxA9AiDnEwiD4+bANQjg7ycgGZwvfOC8A joiw/O3nqRRrtW6PqrbhmdSZYO/iON0DJ0HF5iSVN46KSd6M8o4NZuhHGWjCPzMAULPa XA1u6IwHWU03RUgRRGNJLPhRaxv3/NwJ0ge8HLmjob7BzdP/0l0bg2M7SW0SjIQAHLxE QCsiasQSgYSHGaKIv3oZ04XExV/1XsUpgSJ/+cDy+C06I+5OQU8pyRmAotS2dZHjuEYj 96yqNZlMG6Q6uU7XRxO/Us8mXq3qF5ZQpalXml1VeWgf9QFKKr1Y4a+12IGWIEYBxbYI uwWQ== 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:to:from :dkim-signature; bh=9LZRsEkKnJ2S97XhKeNcGIIBb8RD8P25Q7UYpYoF+Ic=; b=XRKHC+9/OcDdLkX1z12FxvQwrQBMET7JTimkm/zEE26SzFohS/BUAD2W4zaanx9Cgt 3jVc4X0bQEnmxoIHQ9fq2O9zAQcXUPFMCNdYwLaHBWItAixiMEiBKqSfydNE8OCOHkJJ MGnK2WBR/h5Cr5so8JH51hkFkjxfvhioQ00bG8E5k49DKg2b65pS5iEpAedaYp4Gjw0w JsPZI7rDyGIOCrFS2tXTEbPDN5SeuaEkn1NAx6vfnJpLgtgdizVzmGrHD6kzXmpjBGjJ kU9izrG1l/nqh2wf2w8xr1hh4ESTKKkvDmCjh8Y82dUud85aNv7RdcmGBf8wRrmiZ9eB W5zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HiOkxIL2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si1396642otm.54.2020.03.02.12.46.25; Mon, 02 Mar 2020 12:46:37 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=HiOkxIL2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726838AbgCBUqT (ORCPT + 99 others); Mon, 2 Mar 2020 15:46:19 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38976 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726700AbgCBUqS (ORCPT ); Mon, 2 Mar 2020 15:46:18 -0500 Received: by mail-wr1-f66.google.com with SMTP id y17so1558482wrn.6; Mon, 02 Mar 2020 12:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=9LZRsEkKnJ2S97XhKeNcGIIBb8RD8P25Q7UYpYoF+Ic=; b=HiOkxIL2wRxMFKWaZimnvK63CcgcFIHPIefLtJ3PTMEVizxfCrvIPmcOcanEmWCITD ZaVfpU0zJZhiQs1xATGNVLGvYQVGw8HdB7LzPrSxxchSwarccguokyWB3us54ypZkOVH QwfbA+5bwcXKUcIOGyGvznq1uot3weiSWqTGzk/4xvG0kpifdRTL1jHgON/EUTXV/UmG tbORqLJWqCkt5DNNU4LjtqDM+3eAAp4DF+1/+yKs1kR8LUqTVoLeeypo/WHizN6AjH8J VdSnXkjc3ZrLW7Os9R9+KPU8WO8kdvyWqNZw+E9DiQ2FWhZOoxojhnQZ64mKttJxl9Q5 kkNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9LZRsEkKnJ2S97XhKeNcGIIBb8RD8P25Q7UYpYoF+Ic=; b=SjvfsDnkWhI+OhkvAZa2vF/fGb/cFac9d6Ex1tEHAYYw6bHAmIk+dwsEi+vB1mn78L BATt7EUESpDpN7vnYnhC0+pXs+FjEVO5hUuimClnKeU6J1eHDUXRwHRLj4jIxaGQDYDT wp3nfTNHOMZ3MFnci86VtXxwcmTIt1Vdz8HOJpiTk1GQN4cFDu2fT2KY+WeZrlmnPzro cYu7o0a4l5xWiWkgsZaFXIEm0Y/OT0N/0O3HBnqL9utMpRI4GkRKsmzTLd9cV+gdi4Px rWfifxWJL0+219dapIYv0WkheqZyZWJcp/0UNLAHibwlr68GuD0ZxO+9FdFYcPzRwils FWxQ== X-Gm-Message-State: ANhLgQ15OKOx/H8MLn2kiM+V/kATxhrL2L12aAhp+4mQD+4okT0VnuPS b5u/oW+E9DpFSQwbgo/CxGKx5oY0 X-Received: by 2002:a5d:4984:: with SMTP id r4mr1248619wrq.137.1583181976509; Mon, 02 Mar 2020 12:46:16 -0800 (PST) Received: from localhost.localdomain ([109.126.130.242]) by smtp.gmail.com with ESMTPSA id b14sm20186549wrn.75.2020.03.02.12.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2020 12:46:16 -0800 (PST) From: Pavel Begunkov To: Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] io_uring: clean up io_close Date: Mon, 2 Mar 2020 23:45:16 +0300 Message-Id: X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't abuse labels for plain and straightworward code. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index fb8fe0bd5e18..ff6cc05b86c7 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3030,8 +3030,16 @@ static int io_close(struct io_kiocb *req, struct io_kiocb **nxt, return ret; /* if the file has a flush method, be safe and punt to async */ - if (req->close.put_file->f_op->flush && !io_wq_current_is_worker()) - goto eagain; + if (req->close.put_file->f_op->flush && force_nonblock) { + req->work.func = io_close_finish; + /* + * Do manual async queue here to avoid grabbing files - we don't + * need the files, and it'll cause io_close_finish() to close + * the file again and cause a double CQE entry for this request + */ + io_queue_async_work(req); + return 0; + } /* * No ->flush(), safely close from here and just punt the @@ -3039,15 +3047,6 @@ static int io_close(struct io_kiocb *req, struct io_kiocb **nxt, */ __io_close_finish(req, nxt); return 0; -eagain: - req->work.func = io_close_finish; - /* - * Do manual async queue here to avoid grabbing files - we don't - * need the files, and it'll cause io_close_finish() to close - * the file again and cause a double CQE entry for this request - */ - io_queue_async_work(req); - return 0; } static int io_prep_sfr(struct io_kiocb *req, const struct io_uring_sqe *sqe) -- 2.24.0