Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp13929390pxu; Mon, 4 Jan 2021 08:12:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJMvxaEkLoFRrIYhLTKy28fzjHu0SDZsXK2muIQhErZmeMUF6T6V8vdYR1x8WiPkReMMaB X-Received: by 2002:a05:6402:1d0f:: with SMTP id dg15mr64150635edb.1.1609776770908; Mon, 04 Jan 2021 08:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609776770; cv=none; d=google.com; s=arc-20160816; b=Ozap96mZD4R9r1N1EhNlmlxSZfnrPQwh/hi0sb5SonKJcMw3ny4DKr7YHfhhSlUTIx 8tn2h4vhfxReLGqciBiScEsW/veEeOtdNXVa9bSmq6qffohHKK+DXAUTqjFnFANC4zl1 M+IfSuNtMhm4K0zR0VapIXiD3umXuy6xnNzplXbvtvKsSnD29wWkFQPRZ0XTT+L9mDWh O1HE30MxZHzHMlhklfmA8s+aO3RUp2iCBf/q/51Ln7KoWMvgKgrpVX4Jza/LkQKFnRTU SYIKABwfi2WJhKK7UQS0zBW4/opOG6TDJAAI0D5FfFH5+0Zq5vp1exgUCa6jd+CfzCxm X2gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iMeYKHQR5FPcO6lTeGRcOnjkcoKa7mPjNtIhMH77r9k=; b=N7wgbiypDWm4jhblIczpOAKQgmfqoYACIwYiaJ1qAhj8DSqeI0GjcR8S0vQFWG5o+W lZpC98fAqIUL5s/FPb9U4ge8cGJOFHidnSmEezH5GbUn/O0YUZOCMHuglHkVxjGyM58G ZARCzaWzd+tq72EV7E+R+2A6wKw51qMxB60w1+NuhjiwPGs/L2quW08QuKs4abGKxaDQ hhkKtd36lNOxvZETpXwuH1Giw41mdHAWdy8qcVCtgWGBdlFpjbti43GWnw73SAb5iQZp Avzz+R3jYqRXPyXgrbmR/QB0mo6UuOdjvzX6QsreFJ+LpiPu78vUem/9fjErXajOH0bw CmtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iwgztkKP; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si30844218edc.19.2021.01.04.08.12.27; Mon, 04 Jan 2021 08:12:50 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=iwgztkKP; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727525AbhADQKL (ORCPT + 99 others); Mon, 4 Jan 2021 11:10:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:38806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728666AbhADQBt (ORCPT ); Mon, 4 Jan 2021 11:01:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5602121D93; Mon, 4 Jan 2021 16:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609776093; bh=+XWpYRlH14aguLeK/2XmnIRiLYQgDpkgVIGis8LuEFk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iwgztkKPF9jqYhW6/CbAYet4f+fsiz8jMDcAmumjSBYGvrF9BQxumG0YSfX7eo1nL 41edqt/5ZnUDfuxhs64aqDsvDC5ot6qKNasihlYElZ9DOfimnB4vjsIOi1BAffJanB uBIrL6dkC9/7dyLgMiwt9u98c7S9321WJ0Vf5FjA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 5.10 19/63] io_uring: add a helper for setting a ref node Date: Mon, 4 Jan 2021 16:57:12 +0100 Message-Id: <20210104155709.749086373@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210104155708.800470590@linuxfoundation.org> References: <20210104155708.800470590@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Begunkov commit 1642b4450d20e31439c80c28256c8eee08684698 upstream. Setting a new reference node to a file data is not trivial, don't repeat it, add and use a helper. Cc: stable@vger.kernel.org # 5.6+ Signed-off-by: Pavel Begunkov Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6991,6 +6991,16 @@ static void io_file_ref_kill(struct perc complete(&data->done); } +static void io_sqe_files_set_node(struct fixed_file_data *file_data, + struct fixed_file_ref_node *ref_node) +{ + spin_lock_bh(&file_data->lock); + file_data->node = ref_node; + list_add_tail(&ref_node->node, &file_data->ref_list); + spin_unlock_bh(&file_data->lock); + percpu_ref_get(&file_data->refs); +} + static int io_sqe_files_unregister(struct io_ring_ctx *ctx) { struct fixed_file_data *data = ctx->file_data; @@ -7519,11 +7529,7 @@ static int io_sqe_files_register(struct return PTR_ERR(ref_node); } - file_data->node = ref_node; - spin_lock_bh(&file_data->lock); - list_add_tail(&ref_node->node, &file_data->ref_list); - spin_unlock_bh(&file_data->lock); - percpu_ref_get(&file_data->refs); + io_sqe_files_set_node(file_data, ref_node); return ret; out_fput: for (i = 0; i < ctx->nr_user_files; i++) { @@ -7679,11 +7685,7 @@ static int __io_sqe_files_update(struct if (needs_switch) { percpu_ref_kill(&data->node->refs); - spin_lock_bh(&data->lock); - list_add_tail(&ref_node->node, &data->ref_list); - data->node = ref_node; - spin_unlock_bh(&data->lock); - percpu_ref_get(&ctx->file_data->refs); + io_sqe_files_set_node(data, ref_node); } else destroy_fixed_file_ref_node(ref_node);