From patchwork Thu Sep 28 17:29:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 9976479 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 A12BE6034B for ; Thu, 28 Sep 2017 17:29:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 879EC296CB for ; Thu, 28 Sep 2017 17:29:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7965E296CF; Thu, 28 Sep 2017 17:29:57 +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=-6.9 required=2.0 tests=BAYES_00,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 1DA51296CB for ; Thu, 28 Sep 2017 17:29:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752430AbdI1R3x (ORCPT ); Thu, 28 Sep 2017 13:29:53 -0400 Received: from mx141.netapp.com ([216.240.21.12]:2773 "EHLO mx141.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752299AbdI1R3w (ORCPT ); Thu, 28 Sep 2017 13:29:52 -0400 X-IronPort-AV: E=Sophos;i="5.42,450,1500966000"; d="scan'208";a="230521527" Received: from vmwexchts02-prd.hq.netapp.com ([10.122.105.23]) by mx141-out.netapp.com with ESMTP; 28 Sep 2017 10:05:21 -0700 Received: from smtp1.corp.netapp.com (10.122.76.128) by VMWEXCHTS02-PRD.hq.netapp.com (10.122.105.23) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Thu, 28 Sep 2017 10:29:51 -0700 Received: from Olgas-MBP-107.vpn.netapp.com (olgas-mbp-107.vpn.netapp.com [10.55.75.185]) by smtp1.corp.netapp.com (8.14.9+Sun/8.13.1/NTAP-1.6) with ESMTP id v8SHTjgi004534; Thu, 28 Sep 2017 10:29:51 -0700 (PDT) From: Olga Kornievskaia To: CC: Subject: [PATCH v4 09/10] NFSD support OFFLOAD_STATUS Date: Thu, 28 Sep 2017 13:29:44 -0400 Message-ID: <20170928172945.50780-10-kolga@netapp.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170928172945.50780-1-kolga@netapp.com> References: <20170928172945.50780-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 Update number of bytes copied in the copy state and query that value under lock if OFFLOAD_STATUS operation received. Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4proc.c | 16 +++++++++++++++- fs/nfsd/state.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index f4f3d93..74bfa4b 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1154,6 +1154,8 @@ static int _nfsd_copy_file_range(struct nfsd4_copy *copy) if (!copy->cp_synchronous) { spin_lock(©->cps->cp_lock); cancelled = copy->cps->cp_cancelled; + copy->cps->cp_bytes_copied = + copy->cp_res.wr_bytes_written; spin_unlock(©->cps->cp_lock); } } while (bytes_total > 0 && !copy->cp_synchronous && !cancelled); @@ -1321,7 +1323,19 @@ static void nfsd4_do_async_copy(struct work_struct *work) struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { - return nfserr_notsupp; + struct nfsd4_offload_status *os = &u->offload_status; + struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); + __be32 status; + struct nfs4_cp_state *state = NULL; + + status = find_cp_state(nn, &os->stateid, &state); + + if (state) { + spin_lock(&state->cp_lock); + os->count = state->cp_bytes_copied; + spin_unlock(&state->cp_lock); + } + return status; } static __be32 diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 7a070d5..c31025c 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -113,6 +113,7 @@ struct nfs4_cp_state { struct nfs4_stid *cp_p_stid; /* pointer to parent */ bool cp_cancelled; /* copy cancelled */ spinlock_t cp_lock; + ssize_t cp_bytes_copied;/* copy progress */ }; /*