From patchwork Fri Jul 20 22:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10538535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA84C602CA for ; Fri, 20 Jul 2018 22:19:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA07428A03 for ; Fri, 20 Jul 2018 22:19:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE98C29576; Fri, 20 Jul 2018 22:19:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71B3D28A03 for ; Fri, 20 Jul 2018 22:19:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728832AbeGTXJ0 (ORCPT ); Fri, 20 Jul 2018 19:09:26 -0400 Received: from mx143.netapp.com ([216.240.21.24]:49366 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbeGTXJ0 (ORCPT ); Fri, 20 Jul 2018 19:09:26 -0400 X-IronPort-AV: E=Sophos;i="5.51,381,1526367600"; d="scan'208";a="272298765" Received: from vmwexchts04-prd.hq.netapp.com ([10.122.105.32]) by mx143-out.netapp.com with ESMTP; 20 Jul 2018 15:19:10 -0700 Received: from smtp1.corp.netapp.com (10.122.76.128) by VMWEXCHTS04-PRD.hq.netapp.com (10.122.105.32) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 20 Jul 2018 15:19:10 -0700 Received: from localhost.localdomain ([10.249.134.220]) by smtp1.corp.netapp.com (8.14.9+Sun/8.13.1/NTAP-1.6) with ESMTP id w6KMJ1XW009200; Fri, 20 Jul 2018 15:19:09 -0700 (PDT) From: Olga Kornievskaia To: CC: Subject: [PATCH v10 8/9] NFSD support OFFLOAD_STATUS Date: Fri, 20 Jul 2018 18:19:24 -0400 Message-ID: <20180720221925.50744-9-kolga@netapp.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20180720221925.50744-1-kolga@netapp.com> References: <20180720221925.50744-1-kolga@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Search the list for the asynchronous copy based on the stateid, then lookup the number of bytes copied so far. Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4proc.c | 45 ++++++++++++++++++++++++++++++++------------- fs/nfsd/state.h | 2 ++ 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index c375520..c122153 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1275,6 +1275,23 @@ static int nfsd4_do_async_copy(void *data) goto out; } +struct nfsd4_copy * +find_async_copy(struct nfs4_client *clp, stateid_t *stateid) +{ + struct nfsd4_copy *copy; + + spin_lock(&clp->async_lock); + list_for_each_entry(copy, &clp->async_copies, copies) { + if (memcmp(©->cp_stateid, stateid, NFS4_STATEID_SIZE)) + continue; + refcount_inc(©->refcount); + spin_unlock(&clp->async_lock); + return copy; + } + spin_unlock(&clp->async_lock); + return NULL; +} + static __be32 nfsd4_offload_cancel(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, @@ -1283,20 +1300,10 @@ static int nfsd4_do_async_copy(void *data) struct nfsd4_offload_status *os = &u->offload_status; __be32 status = 0; struct nfsd4_copy *copy; - bool found = false; struct nfs4_client *clp = cstate->clp; - spin_lock(&clp->async_lock); - list_for_each_entry(copy, &clp->async_copies, copies) { - if (memcmp(©->cp_stateid, &os->stateid, - NFS4_STATEID_SIZE)) - continue; - found = true; - refcount_inc(©->refcount); - break; - } - spin_unlock(&clp->async_lock); - if (found) { + copy = find_async_copy(clp, &os->stateid); + if (copy) { set_tsk_thread_flag(copy->copy_task, TIF_SIGPENDING); kthread_stop(copy->copy_task); nfs4_put_copy(copy); @@ -1333,7 +1340,19 @@ static int nfsd4_do_async_copy(void *data) struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { - return nfserr_notsupp; + struct nfsd4_offload_status *os = &u->offload_status; + __be32 status = 0; + struct nfsd4_copy *copy; + struct nfs4_client *clp = cstate->clp; + + copy = find_async_copy(clp, &os->stateid); + if (copy) { + os->count = copy->cp_res.wr_bytes_written; + nfs4_put_copy(copy); + } else + status = nfserr_bad_stateid; + + return status; } static __be32 diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 0ee2ed3..0bd4329 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -642,6 +642,8 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(const char *name, struct nfs4_file *find_file(struct knfsd_fh *fh); void put_nfs4_file(struct nfs4_file *fi); extern void nfs4_put_copy(struct nfsd4_copy *copy); +extern struct nfsd4_copy * +find_async_copy(struct nfs4_client *clp, stateid_t *staetid); static inline void get_nfs4_file(struct nfs4_file *fi) { refcount_inc(&fi->fi_ref);