From patchwork Fri Oct 19 15:28:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10649645 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D027613A4 for ; Fri, 19 Oct 2018 15:29:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF6D027F91 for ; Fri, 19 Oct 2018 15:29:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B408127F93; Fri, 19 Oct 2018 15:29:20 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,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 4E18627F91 for ; Fri, 19 Oct 2018 15:29:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727010AbeJSXfy (ORCPT ); Fri, 19 Oct 2018 19:35:54 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:38499 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726860AbeJSXfy (ORCPT ); Fri, 19 Oct 2018 19:35:54 -0400 Received: by mail-qt1-f196.google.com with SMTP id r22-v6so2160861qtm.5 for ; Fri, 19 Oct 2018 08:29:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MrfWI83dwuk5+P+ddPcjUo36DVq3EA6UNLgnKcNNlp4=; b=gKY1oFUewysSapgccbhu/6fKIWFeEeQCs/7SQ87ebCh1+nqERJLmPrSNEZ6VL0tGbp lz/xAtH/ZOW65YuoCEKICwsm0mwTSkkuGKMGLKExuLbzR5DNc7aDWI3RkAQEq5A/5+mm PLu62k9UwSE/4ZRsYVlRitp2IFgbvuS2hg9TGHlXUC+TnsYPTVc0dDmW6ob0wck2urtT HtorXQOil14qPiK4iM1yzi5G/xlB1ck2Vz2sResVm+s+UMPMbYZMfudhkZ65lQn9/AhP whErE0/iQmGpxB21uTZhymMV7+I/sJtJ2F3Ps1S1nyRX13GpFsGDIKLsDmul+OBJr1k5 dqgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MrfWI83dwuk5+P+ddPcjUo36DVq3EA6UNLgnKcNNlp4=; b=tg7KpS6nY8M0Jyt7dGnUEhpGmOahlnhyIhT80YcgjcxMuwuRuPD/cNu7diMyk5CWm3 PFItXd5XRs1cjlmWACUaa0snY1QtaIWDLGtsVID2tf9MwJxD4Ke74AFvQvB/5Xue5Ybo mhJgEiu+tiHuF3kFv5o4x+a+3MQYwldDrHyTLcVM7nZhKkJIQPRAx8Snj8EyOZCVddbC zKPbIXxu3A1660ct1pBv1mGTY+8dTka7lzd/ubKtB+Hgb7eHnL7SGu2vaqvZsOqLEbiO T8y5GuTWZVhOmAZiUC74Uly43NoekZlqjqebyr9lGApFpGp9oCfmEahZe876pDoLz1mC qxwQ== X-Gm-Message-State: ABuFfohxk7SsGpi1dIFkjj/eladJd7v5CarvF55VyjDjVWMeCfTyU3FF MMzZWBmq8UU9rW7rotxM9wM= X-Google-Smtp-Source: ACcGV61QD5b6CiR1j9pzANsbz1GoCVapVxGZF+ObszlE4TKxUkCAy2f1AxWZKX5ktvIPWin8E0czIQ== X-Received: by 2002:a0c:ac87:: with SMTP id m7mr30181334qvc.112.1539962958453; Fri, 19 Oct 2018 08:29:18 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id s17-v6sm18126231qtj.31.2018.10.19.08.29.17 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 19 Oct 2018 08:29:17 -0700 (PDT) From: Olga Kornievskaia To: bfields@redhat.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v1 07/13] NFSD add ca_source_server<> to COPY Date: Fri, 19 Oct 2018 11:28:59 -0400 Message-Id: <20181019152905.32418-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181019152905.32418-1-olga.kornievskaia@gmail.com> References: <20181019152905.32418-1-olga.kornievskaia@gmail.com> 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 Note: followed conventions and have struct nfsd4_compoundargs pointer as a parameter even though it is unused. Signed-off-by: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfsd/nfs4xdr.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- fs/nfsd/xdr4.h | 1 + 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 3de42a7..9f6886f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "idmap.h" #include "acl.h" @@ -1743,11 +1744,58 @@ static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, str DECODE_TAIL; } +static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp, + struct nl4_server *ns) +{ + DECODE_HEAD; + struct nfs42_netaddr *naddr; + + READ_BUF(4); + ns->nl4_type = be32_to_cpup(p++); + + /* currently support for 1 inter-server source server */ + switch (ns->nl4_type) { + case NL4_NAME: + case NL4_URL: + READ_BUF(4); + ns->u.nl4_str_sz = be32_to_cpup(p++); + if (ns->u.nl4_str_sz > NFS4_OPAQUE_LIMIT) + goto xdr_error; + + READ_BUF(ns->u.nl4_str_sz); + COPYMEM(ns->u.nl4_str, + ns->u.nl4_str_sz); + break; + case NL4_NETADDR: + naddr = &ns->u.nl4_addr; + + READ_BUF(4); + naddr->netid_len = be32_to_cpup(p++); + if (naddr->netid_len > RPCBIND_MAXNETIDLEN) + goto xdr_error; + + READ_BUF(naddr->netid_len + 4); /* 4 for uaddr len */ + COPYMEM(naddr->netid, naddr->netid_len); + + naddr->addr_len = be32_to_cpup(p++); + if (naddr->addr_len > RPCBIND_MAXUADDRLEN) + goto xdr_error; + + READ_BUF(naddr->addr_len); + COPYMEM(naddr->addr, naddr->addr_len); + break; + default: + goto xdr_error; + } + DECODE_TAIL; +} + static __be32 nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) { DECODE_HEAD; - unsigned int tmp; + struct nl4_server *ns; + int i, count; status = nfsd4_decode_stateid(argp, ©->cp_src_stateid); if (status) @@ -1762,8 +1810,24 @@ static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, str p = xdr_decode_hyper(p, ©->cp_count); p++; /* ca_consecutive: we always do consecutive copies */ copy->cp_synchronous = be32_to_cpup(p++); - tmp = be32_to_cpup(p); /* Source server list not supported */ + count = be32_to_cpup(p++); + + if (count == 0) /* intra-server copy */ + goto intra; + /* decode all the supplied server addresses but use first */ + copy->cp_src = kmalloc(count * sizeof(struct nl4_server), GFP_KERNEL); + if (copy->cp_src == NULL) + return nfserrno(-ENOMEM); + + ns = copy->cp_src; + for (i = 0; i < count; i++) { + status = nfsd4_decode_nl4_server(argp, ns); + if (status) + return status; + ns++; + } +intra: DECODE_TAIL; } @@ -4273,6 +4337,9 @@ static __be32 nfsd4_encode_readv(struct nfsd4_compoundres *resp, p = xdr_reserve_space(&resp->xdr, 4 + 4); *p++ = xdr_one; /* cr_consecutive */ *p++ = cpu_to_be32(copy->cp_synchronous); + + /* allocated in nfsd4_decode_copy */ + kfree(copy->cp_src); return 0; } diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index feeb6d4..b4d1140 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -521,6 +521,7 @@ struct nfsd4_copy { u64 cp_src_pos; u64 cp_dst_pos; u64 cp_count; + struct nl4_server *cp_src; /* both */ bool cp_synchronous;