Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp509203imn; Wed, 27 Jul 2022 12:09:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uKNOPVhWfI1InOgAUJtjBMB0vd9gHMX2WnxDiKLjMUg4uJ9pTW8aAJrKKokZdGg9tnljQi X-Received: by 2002:a17:907:7ea6:b0:72b:4afb:e8b with SMTP id qb38-20020a1709077ea600b0072b4afb0e8bmr19530065ejc.205.1658948988211; Wed, 27 Jul 2022 12:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658948988; cv=none; d=google.com; s=arc-20160816; b=QdbW0lOfCrMRmlxukWdUaO6LHrQX3EL9YM6FbyKNNHEzKzEujpEkgVWkDEHHMdQKqz oC6wPLGnSziSlirvVp5HolidYCVQ/EpldQmVal9+oKhYX/S0/BpUDBDV4pyaPMfjNQFh d8kKmHXyOPkIDQeDyeOn3qAQ9pxLMDN3pARSqSwyBN/vsyO1xKYjKgNSIBh9g4eNnR5M tEacjhtpBWvhRqbwy5y65u+5Ub00N/Di6t7yqYJkt/6fQCbT1Qvr8nPQBVBmC2t499NJ iijZblgK5+us1tXjPpNfQiNDJNrpUPgg29hhfCSIAkS9lcPnWOSc8AXAiuji8g7OHNwU 6Gwg== 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:to:from:subject; bh=zDtLvxnLySnqVwMvIDtxTbsEDFW3NKAYan+vxYuhgHU=; b=slLa7RiXVb9hEoCQlfGqh/pK9bCeNjh5IxIaEjLbC2kw1SWccRuzOtMwT8xCfuoaxD q6zha1JCVOKT8sdpSxoZWa9YLfKlbf7D+QI5ZHw/Qgrf49tzn/0aJYUcuN3rih2goCEy grrPCYDZBXWdlIB1iVzM0uW07E5T5/JDe+QfFXaVbCBeKOB1FLUNy30FiBV4sqUykeH7 /MRcVofplC+u4ufwEkh25QIT5ERbAL69xre03YVOJ9/VVThglBvymaSqB7yyJZsOqqEP ZYA/LQHa5P/X1uGVgrodyCZJMaDDLmzL1HbQwYovQ3QqvG6X2Ce/gfwtPvfJV3o9n3u/ Wb2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a056402270d00b0043c375f06fdsi7059197edd.252.2022.07.27.12.09.23; Wed, 27 Jul 2022 12:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235254AbiG0THl (ORCPT + 99 others); Wed, 27 Jul 2022 15:07:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232084AbiG0THX (ORCPT ); Wed, 27 Jul 2022 15:07:23 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F00B28B for ; Wed, 27 Jul 2022 11:41:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 45CB8619C5 for ; Wed, 27 Jul 2022 18:41:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 940ACC433C1 for ; Wed, 27 Jul 2022 18:41:13 +0000 (UTC) Subject: [PATCH v2 12/13] NFSD: Add nfsd4_send_cb_offload() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Wed, 27 Jul 2022 14:41:12 -0400 Message-ID: <165894727256.11193.4397590214956949570.stgit@manet.1015granger.net> In-Reply-To: <165894669884.11193.6386905165076468843.stgit@manet.1015granger.net> References: <165894669884.11193.6386905165076468843.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for legibility. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 336fdfae2230..479dc03d286e 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1763,6 +1763,27 @@ static void cleanup_async_copy(struct nfsd4_copy *copy) nfs4_put_copy(copy); } +static void nfsd4_send_cb_offload(struct nfsd4_copy *copy) +{ + struct nfsd4_copy *cb_copy; + + cb_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL); + if (!cb_copy) + return; + + refcount_set(&cb_copy->refcount, 1); + memcpy(&cb_copy->cp_res, ©->cp_res, sizeof(copy->cp_res)); + cb_copy->cp_clp = copy->cp_clp; + cb_copy->nfserr = copy->nfserr; + memcpy(&cb_copy->fh, ©->fh, sizeof(copy->fh)); + + nfsd4_init_cb(&cb_copy->cp_cb, cb_copy->cp_clp, + &nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD); + trace_nfsd_cb_offload(copy->cp_clp, ©->cp_res.cb_stateid, + ©->fh, copy->cp_count, copy->nfserr); + nfsd4_run_cb(&cb_copy->cp_cb); +} + /** * nfsd4_do_async_copy - kthread function for background server-side COPY * @data: arguments for COPY operation @@ -1773,7 +1794,6 @@ static void cleanup_async_copy(struct nfsd4_copy *copy) static int nfsd4_do_async_copy(void *data) { struct nfsd4_copy *copy = (struct nfsd4_copy *)data; - struct nfsd4_copy *cb_copy; if (nfsd4_ssc_is_inter(copy)) { struct file *filp; @@ -1795,20 +1815,7 @@ static int nfsd4_do_async_copy(void *data) } do_callback: - cb_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL); - if (!cb_copy) - goto out; - refcount_set(&cb_copy->refcount, 1); - memcpy(&cb_copy->cp_res, ©->cp_res, sizeof(copy->cp_res)); - cb_copy->cp_clp = copy->cp_clp; - cb_copy->nfserr = copy->nfserr; - memcpy(&cb_copy->fh, ©->fh, sizeof(copy->fh)); - nfsd4_init_cb(&cb_copy->cp_cb, cb_copy->cp_clp, - &nfsd4_cb_offload_ops, NFSPROC4_CLNT_CB_OFFLOAD); - trace_nfsd_cb_offload(copy->cp_clp, ©->cp_res.cb_stateid, - ©->fh, copy->cp_count, copy->nfserr); - nfsd4_run_cb(&cb_copy->cp_cb); -out: + nfsd4_send_cb_offload(copy); cleanup_async_copy(copy); return 0; }