From patchwork Mon Jul 8 19:24:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035721 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 9286017EF for ; Mon, 8 Jul 2019 19:24:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8356928396 for ; Mon, 8 Jul 2019 19:24:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7741E2847B; Mon, 8 Jul 2019 19:24:45 +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 1981428516 for ; Mon, 8 Jul 2019 19:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391659AbfGHTYo (ORCPT ); Mon, 8 Jul 2019 15:24:44 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:45597 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbfGHTYo (ORCPT ); Mon, 8 Jul 2019 15:24:44 -0400 Received: by mail-io1-f68.google.com with SMTP id g20so16752427ioc.12 for ; Mon, 08 Jul 2019 12:24:44 -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=u4cDjbHMsQzeRKsi8cH8bry88PlBgp/Iza2eOmK8174=; b=YZ9gUHCMd71ERKQvOIKJ29438BP19yehjEBbrF/M7GWKQfr+6v6iiy9PUFioK9H/BX 0krvJGvE+FNFNZEReKV+U0eERiSl2+DC5+PDWg7vKbSdnTmDj1sPY4K+vN/vGhPTAVvd joPBVu8DAYSFPnqSVvG/Fo6wEH+of6mZ6eV7t/gu+priHaD6/8ZSu7e1VNMgdEPYi9Tz Gn6HdcmUxk+4mLovR+dwkIeaJfiUD/RRfrd5zIjV6WL51ugofEamP495BUcNLT3gOW/S jNBS6cS//g5eYc0IiODZ1T0s0ZhCQTtcD5pY/F57b15QUYtiT3W1UWH7yDmRkrjOu8RU 4nnw== 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=u4cDjbHMsQzeRKsi8cH8bry88PlBgp/Iza2eOmK8174=; b=lWFzGh/Ls71gKuVcVr/s13bvdQvM3ft38muvTw8baxtdZPQXWAhI40lQ68WdXNSW4y Y5SNjHqbGugR7QTMxPqR4TSsTPrPyFij8BkB3FVt2cwkJHKnaDDXCzk900bsd1pEWNMW boSiEXfZX5Fg5PJuG+VkZaI8B2f+Dwqnx6t/C3MLjwmOmu9DAmdxCvlEDpLypXFrrhfv iOzhJgVioD7A7pWbJmNX+fXoWP0ByUiLD4Lem3kLOJtiOGEX9VAWQsVMa4RlVN01FLrU CPEa5bWcd8R1+YiqAqhB/ORJEQ2KYGGyAM56frntKQa0fmpMfKUHbXwG2863eIrC0Ntq CQOQ== X-Gm-Message-State: APjAAAXMc+EEyTDu2JCtt0Cxue+szwu/Nea5lotB644EEA6Swl2UcWZE wBZYfyO+aiyqMNb98ZO+2GGMy7GCn4M= X-Google-Smtp-Source: APXvYqyOrgjZqFzZbRVmXD/DBcmPQ5IIYDny7MhYvqLTZ+wJeqes6gPvtLF5udNPcPOBrlWmIliaoA== X-Received: by 2002:a05:6638:517:: with SMTP id i23mr17716277jar.71.1562613883670; Mon, 08 Jul 2019 12:24:43 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.42 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:43 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 01/12] NFS NFSD: defining nl4_servers structure needed by both Date: Mon, 8 Jul 2019 15:24:33 -0400 Message-Id: <20190708192444.12664-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia These structures are needed by COPY_NOTIFY on the client and needed by the nfsd as well Reviewed-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- include/linux/nfs4.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 22494d170619..38612d7bd17e 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -16,6 +16,7 @@ #include #include #include +#include enum nfs4_acl_whotype { NFS4_ACL_WHO_NAMED = 0, @@ -673,4 +674,27 @@ struct nfs4_op_map { } u; }; +struct nfs42_netaddr { + char netid[RPCBIND_MAXNETIDLEN]; + char addr[RPCBIND_MAXUADDRLEN + 1]; + u32 netid_len; + u32 addr_len; +}; + +enum netloc_type4 { + NL4_NAME = 1, + NL4_URL = 2, + NL4_NETADDR = 3, +}; + +struct nl4_server { + enum netloc_type4 nl4_type; + union { + struct { /* NL4_NAME, NL4_URL */ + int nl4_str_sz; + char nl4_str[NFS4_OPAQUE_LIMIT + 1]; + }; + struct nfs42_netaddr nl4_addr; /* NL4_NETADDR */ + } u; +}; #endif From patchwork Mon Jul 8 19:24:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035723 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 B95A9112C for ; Mon, 8 Jul 2019 19:24:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A859728396 for ; Mon, 8 Jul 2019 19:24:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D10728516; Mon, 8 Jul 2019 19:24:47 +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 7E05628396 for ; Mon, 8 Jul 2019 19:24:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391661AbfGHTYq (ORCPT ); Mon, 8 Jul 2019 15:24:46 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:36464 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbfGHTYp (ORCPT ); Mon, 8 Jul 2019 15:24:45 -0400 Received: by mail-io1-f66.google.com with SMTP id o9so22279487iom.3 for ; Mon, 08 Jul 2019 12:24:45 -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=E5qI/RTBGiIw4YrUjA9WdULomMUjcL0zo5dMzLsowTc=; b=Fqyp8Tcu6x0sXKqgVS8NIhMI8AyO5cQcJGHZBDpMZznlmvfT89nDj6VLIQ9lL9licl GvQ1YaimQZyc19qpWLySfSA+2kqau7txwlvqTvopJqxzbGAwWoVPbJSqk6mJn1P6vEXa eqr07HzZYPg3iUsLllu/HsqMCIafB+bF3QrW71Ozn8SoNvAZGph3IgA++OPZdFxf+mJJ BsoKEvtn2+cjboT5Dvg+JpEsV3KO1AOHWawLeHrbwlxmNtPU51+wmgOIo9F24LyA8/Nv wJlumaEzXCAK00LF7BMX4NfpiW8osw4VsQjBz276qqDKWLDrxU5UaOjq6Qlyp01VyMPU 0rtA== 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=E5qI/RTBGiIw4YrUjA9WdULomMUjcL0zo5dMzLsowTc=; b=BpJzUmInKycvDwxb3UIuykEHeMeYA+BkMdZEJ3DXjWj4iqwHqh+vc7Ga4ep8t24saV oNA+rSKsd/JwZv9sOCOa4tLhMsUdV0e/dGqdjxX0dO7x8zgYVPrCl/I7I3quRUtHHV6Y rslT6L0DM+fQKF4DX9pVNb9zeMy4BzRzhyKc/6b539dth8socUinMKySutRUbZGB1Cg5 +JJyYhU3juGs2RO0u0ns0bQ4sVl30NRxOHyzF/yKn52aEPvcW1IMawEa9zjAuzapxT9L KVKUB0xGZLJEmWwe/AKvTgwGnFJslEEM9fqXIHMhPpSMSo83SEMhSTFc+4eCDwGJsz8J sgCg== X-Gm-Message-State: APjAAAWB8PuwdulI6OeOu8LMOhAqyIu+z24GwPrweeSFn0NS2h3zRpQd XOLhGyzVwH0QZiL0uQHynVM= X-Google-Smtp-Source: APXvYqzoVJd+J1VT/c3bE1ndZbbUWgJtYwXxcFEG1Dn2E6c7oW5ai+poqQWo1GBxUEGO9H3RkRvYyw== X-Received: by 2002:a5d:948a:: with SMTP id v10mr21114354ioj.103.1562613884651; Mon, 08 Jul 2019 12:24:44 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:44 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 02/12] NFS: add COPY_NOTIFY operation Date: Mon, 8 Jul 2019 15:24:34 -0400 Message-Id: <20190708192444.12664-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia Try using the delegation stateid, then the open stateid. Only NL4_NETATTR, No support for NL4_NAME and NL4_URL. Allow only one source server address to be returned for now. To distinguish between same server copy offload ("intra") and a copy between different server ("inter"), do a check of server owner identity and also make sure server is capable of doing a copy offload. Signed-off-by: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42.h | 12 +++ fs/nfs/nfs42proc.c | 91 +++++++++++++++++++ fs/nfs/nfs42xdr.c | 178 ++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4_fs.h | 2 + fs/nfs/nfs4client.c | 2 +- fs/nfs/nfs4file.c | 20 ++++- fs/nfs/nfs4proc.c | 1 + fs/nfs/nfs4xdr.c | 1 + include/linux/nfs4.h | 1 + include/linux/nfs_fs_sb.h | 1 + include/linux/nfs_xdr.h | 16 ++++ 11 files changed, 323 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h index 901cca7542f9..4995731a6714 100644 --- a/fs/nfs/nfs42.h +++ b/fs/nfs/nfs42.h @@ -13,6 +13,7 @@ #define PNFS_LAYOUTSTATS_MAXDEV (4) /* nfs4.2proc.c */ +#ifdef CONFIG_NFS_V4_2 int nfs42_proc_allocate(struct file *, loff_t, loff_t); ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t); int nfs42_proc_deallocate(struct file *, loff_t, loff_t); @@ -23,5 +24,16 @@ int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t); int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg, const struct nfs42_layout_error *errors, size_t n); +int nfs42_proc_copy_notify(struct file *, struct file *, + struct nfs42_copy_notify_res *); +static inline bool nfs42_files_from_same_server(struct file *in, + struct file *out) +{ + struct nfs_client *c_in = (NFS_SERVER(file_inode(in)))->nfs_client; + struct nfs_client *c_out = (NFS_SERVER(file_inode(out)))->nfs_client; + return nfs4_check_serverowner_major_id(c_in->cl_serverowner, + c_out->cl_serverowner); +} +#endif /* CONFIG_NFS_V4_2 */ #endif /* __LINUX_FS_NFS_NFS4_2_H */ diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 5196bfa7894d..6317dd89cf43 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -3,6 +3,7 @@ * Copyright (c) 2014 Anna Schumaker */ #include +#include #include #include #include @@ -15,10 +16,30 @@ #include "pnfs.h" #include "nfs4session.h" #include "internal.h" +#include "delegation.h" #define NFSDBG_FACILITY NFSDBG_PROC static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *std); +static void nfs42_set_netaddr(struct file *filep, struct nfs42_netaddr *naddr) +{ + struct nfs_client *clp = (NFS_SERVER(file_inode(filep)))->nfs_client; + unsigned short port = 2049; + + rcu_read_lock(); + naddr->netid_len = scnprintf(naddr->netid, + sizeof(naddr->netid), "%s", + rpc_peeraddr2str(clp->cl_rpcclient, + RPC_DISPLAY_NETID)); + naddr->addr_len = scnprintf(naddr->addr, + sizeof(naddr->addr), + "%s.%u.%u", + rpc_peeraddr2str(clp->cl_rpcclient, + RPC_DISPLAY_ADDR), + port >> 8, port & 255); + rcu_read_unlock(); +} + static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep, struct nfs_lock_context *lock, loff_t offset, loff_t len) { @@ -459,6 +480,76 @@ static int nfs42_do_offload_cancel_async(struct file *dst, return status; } +int _nfs42_proc_copy_notify(struct file *src, struct file *dst, + struct nfs42_copy_notify_args *args, + struct nfs42_copy_notify_res *res) +{ + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY_NOTIFY], + .rpc_argp = args, + .rpc_resp = res, + }; + int status; + struct nfs_open_context *ctx; + struct nfs_lock_context *l_ctx; + + ctx = get_nfs_open_context(nfs_file_open_context(src)); + l_ctx = nfs_get_lock_context(ctx); + if (IS_ERR(l_ctx)) + return PTR_ERR(l_ctx); + + status = nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx, + FMODE_READ); + nfs_put_lock_context(l_ctx); + if (status) + return status; + + status = nfs4_call_sync(src_server->client, src_server, &msg, + &args->cna_seq_args, &res->cnr_seq_res, 0); + if (status == -ENOTSUPP) + src_server->caps &= ~NFS_CAP_COPY_NOTIFY; + + put_nfs_open_context(nfs_file_open_context(src)); + return status; +} + +int nfs42_proc_copy_notify(struct file *src, struct file *dst, + struct nfs42_copy_notify_res *res) +{ + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); + struct nfs42_copy_notify_args *args; + struct nfs4_exception exception = { + .inode = file_inode(src), + }; + int status; + + if (!(src_server->caps & NFS_CAP_COPY_NOTIFY)) + return -EOPNOTSUPP; + + args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_NOFS); + if (args == NULL) + return -ENOMEM; + + args->cna_src_fh = NFS_FH(file_inode(src)), + args->cna_dst.nl4_type = NL4_NETADDR; + nfs42_set_netaddr(dst, &args->cna_dst.u.nl4_addr); + exception.stateid = &args->cna_src_stateid; + + do { + status = _nfs42_proc_copy_notify(src, dst, args, res); + if (status == -ENOTSUPP) { + status = -EOPNOTSUPP; + goto out; + } + status = nfs4_handle_exception(src_server, status, &exception); + } while (exception.retry); + +out: + kfree(args); + return status; +} + static loff_t _nfs42_proc_llseek(struct file *filep, struct nfs_lock_context *lock, loff_t offset, int whence) { diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index aed865a84629..ccabc0cd93dd 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -29,6 +29,16 @@ #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE)) #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz) +#define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \ + XDR_QUADLEN(NFS4_STATEID_SIZE) + \ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) +#define decode_copy_notify_maxsz (op_decode_hdr_maxsz + \ + 3 + /* cnr_lease_time */\ + XDR_QUADLEN(NFS4_STATEID_SIZE) + \ + 1 + /* Support 1 cnr_source_server */\ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \ encode_fallocate_maxsz) #define decode_deallocate_maxsz (op_decode_hdr_maxsz) @@ -99,6 +109,12 @@ decode_sequence_maxsz + \ decode_putfh_maxsz + \ decode_offload_cancel_maxsz) +#define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \ + encode_putfh_maxsz + \ + encode_copy_notify_maxsz) +#define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \ + decode_putfh_maxsz + \ + decode_copy_notify_maxsz) #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ @@ -166,6 +182,26 @@ static void encode_allocate(struct xdr_stream *xdr, encode_fallocate(xdr, args); } +static void encode_nl4_server(struct xdr_stream *xdr, + const struct nl4_server *ns) +{ + encode_uint32(xdr, ns->nl4_type); + switch (ns->nl4_type) { + case NL4_NAME: + case NL4_URL: + encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str); + break; + case NL4_NETADDR: + encode_string(xdr, ns->u.nl4_addr.netid_len, + ns->u.nl4_addr.netid); + encode_string(xdr, ns->u.nl4_addr.addr_len, + ns->u.nl4_addr.addr); + break; + default: + WARN_ON_ONCE(1); + } +} + static void encode_copy(struct xdr_stream *xdr, const struct nfs42_copy_args *args, struct compound_hdr *hdr) @@ -191,6 +227,15 @@ static void encode_offload_cancel(struct xdr_stream *xdr, encode_nfs4_stateid(xdr, &args->osa_stateid); } +static void encode_copy_notify(struct xdr_stream *xdr, + const struct nfs42_copy_notify_args *args, + struct compound_hdr *hdr) +{ + encode_op_hdr(xdr, OP_COPY_NOTIFY, decode_copy_notify_maxsz, hdr); + encode_nfs4_stateid(xdr, &args->cna_src_stateid); + encode_nl4_server(xdr, &args->cna_dst); +} + static void encode_deallocate(struct xdr_stream *xdr, const struct nfs42_falloc_args *args, struct compound_hdr *hdr) @@ -354,6 +399,25 @@ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req, encode_nops(&hdr); } +/* + * Encode COPY_NOTIFY request + */ +static void nfs4_xdr_enc_copy_notify(struct rpc_rqst *req, + struct xdr_stream *xdr, + const void *data) +{ + const struct nfs42_copy_notify_args *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->cna_seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->cna_seq_args, &hdr); + encode_putfh(xdr, args->cna_src_fh, &hdr); + encode_copy_notify(xdr, args, &hdr); + encode_nops(&hdr); +} + /* * Encode DEALLOCATE request */ @@ -490,6 +554,58 @@ static int decode_write_response(struct xdr_stream *xdr, return decode_verifier(xdr, &res->verifier.verifier); } +static int decode_nl4_server(struct xdr_stream *xdr, struct nl4_server *ns) +{ + struct nfs42_netaddr *naddr; + uint32_t dummy; + char *dummy_str; + __be32 *p; + int status; + + /* nl_type */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + ns->nl4_type = be32_to_cpup(p); + switch (ns->nl4_type) { + case NL4_NAME: + case NL4_URL: + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) + return -EIO; + memcpy(&ns->u.nl4_str, dummy_str, dummy); + ns->u.nl4_str_sz = dummy; + break; + case NL4_NETADDR: + naddr = &ns->u.nl4_addr; + + /* netid string */ + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > RPCBIND_MAXNETIDLEN)) + return -EIO; + naddr->netid_len = dummy; + memcpy(naddr->netid, dummy_str, naddr->netid_len); + + /* uaddr string */ + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > RPCBIND_MAXUADDRLEN)) + return -EIO; + naddr->addr_len = dummy; + memcpy(naddr->addr, dummy_str, naddr->addr_len); + break; + default: + WARN_ON_ONCE(1); + return -EIO; + } + return 0; +} + static int decode_copy_requirements(struct xdr_stream *xdr, struct nfs42_copy_res *res) { __be32 *p; @@ -529,6 +645,42 @@ static int decode_offload_cancel(struct xdr_stream *xdr, return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL); } +static int decode_copy_notify(struct xdr_stream *xdr, + struct nfs42_copy_notify_res *res) +{ + __be32 *p; + int status, count; + + status = decode_op_hdr(xdr, OP_COPY_NOTIFY); + if (status) + return status; + /* cnr_lease_time */ + p = xdr_inline_decode(xdr, 12); + if (unlikely(!p)) + return -EIO; + p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds); + res->cnr_lease_time.nseconds = be32_to_cpup(p); + + status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE); + if (unlikely(status)) + return -EIO; + + /* number of source addresses */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + + count = be32_to_cpup(p); + if (count > 1) + pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n", + __func__, count); + + status = decode_nl4_server(xdr, &res->cnr_src); + if (unlikely(status)) + return -EIO; + return 0; +} + static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_DEALLOCATE); @@ -656,6 +808,32 @@ static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp, return status; } +/* + * Decode COPY_NOTIFY response + */ +static int nfs4_xdr_dec_copy_notify(struct rpc_rqst *rqstp, + struct xdr_stream *xdr, + void *data) +{ + struct nfs42_copy_notify_res *res = data; + struct compound_hdr hdr; + int status; + + status = decode_compound_hdr(xdr, &hdr); + if (status) + goto out; + status = decode_sequence(xdr, &res->cnr_seq_res, rqstp); + if (status) + goto out; + status = decode_putfh(xdr); + if (status) + goto out; + status = decode_copy_notify(xdr, res); + +out: + return status; +} + /* * Decode DEALLOCATE request */ diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 8a38a254f516..d75fea7ecf12 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -457,6 +457,8 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, struct nfs_client **, const struct cred *); extern void nfs4_schedule_session_recovery(struct nfs4_session *, int); extern void nfs41_notify_server(struct nfs_client *); +bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, + struct nfs41_server_owner *o2); #else static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err) { diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 616393a01c06..6741ad4c4198 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -629,7 +629,7 @@ int nfs40_walk_client_list(struct nfs_client *new, /* * Returns true if the server major ids match */ -static bool +bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, struct nfs41_server_owner *o2) { diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index f4157eb1f69d..4e54432feb3b 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -133,6 +133,9 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t count, unsigned int flags) { + struct nfs42_copy_notify_res *cn_resp = NULL; + ssize_t ret; + /* Only offload copy if superblock is the same */ if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) return -EXDEV; @@ -140,7 +143,22 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, return -EOPNOTSUPP; if (file_inode(file_in) == file_inode(file_out)) return -EOPNOTSUPP; - return nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); + if (!nfs42_files_from_same_server(file_in, file_out)) { + cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res), + GFP_NOFS); + if (unlikely(cn_resp == NULL)) + return -ENOMEM; + + ret = nfs42_proc_copy_notify(file_in, file_out, cn_resp); + if (ret) { + ret = -EOPNOTSUPP; + goto out; + } + } + ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); +out: + kfree(cn_resp); + return ret; } static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4823c6f603d1..9bbd9bad5412 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9761,6 +9761,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { | NFS_CAP_ALLOCATE | NFS_CAP_COPY | NFS_CAP_OFFLOAD_CANCEL + | NFS_CAP_COPY_NOTIFY | NFS_CAP_DEALLOCATE | NFS_CAP_SEEK | NFS_CAP_LAYOUTSTATS diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 602446158bfb..fad36b9f9add 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7571,6 +7571,7 @@ const struct rpc_procinfo nfs4_procedures[] = { PROC42(CLONE, enc_clone, dec_clone), PROC42(COPY, enc_copy, dec_copy), PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), + PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), PROC(LOOKUPP, enc_lookupp, dec_lookupp), PROC42(LAYOUTERROR, enc_layouterror, dec_layouterror), }; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 38612d7bd17e..ec4420e12af7 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -537,6 +537,7 @@ enum { NFSPROC4_CLNT_CLONE, NFSPROC4_CLNT_COPY, NFSPROC4_CLNT_OFFLOAD_CANCEL, + NFSPROC4_CLNT_COPY_NOTIFY, NFSPROC4_CLNT_LOOKUPP, NFSPROC4_CLNT_LAYOUTERROR, diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index a87fe854f008..e1c8748e1e82 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -276,5 +276,6 @@ struct nfs_server { #define NFS_CAP_COPY (1U << 24) #define NFS_CAP_OFFLOAD_CANCEL (1U << 25) #define NFS_CAP_LAYOUTERROR (1U << 26) +#define NFS_CAP_COPY_NOTIFY (1U << 27) #endif diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 9b8324ec08f3..0a7af40026d7 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1463,6 +1463,22 @@ struct nfs42_offload_status_res { int osr_status; }; +struct nfs42_copy_notify_args { + struct nfs4_sequence_args cna_seq_args; + + struct nfs_fh *cna_src_fh; + nfs4_stateid cna_src_stateid; + struct nl4_server cna_dst; +}; + +struct nfs42_copy_notify_res { + struct nfs4_sequence_res cnr_seq_res; + + struct nfstime4 cnr_lease_time; + nfs4_stateid cnr_stateid; + struct nl4_server cnr_src; +}; + struct nfs42_seek_args { struct nfs4_sequence_args seq_args; From patchwork Mon Jul 8 19:24:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035725 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 0087417EF for ; Mon, 8 Jul 2019 19:24:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E57C528396 for ; Mon, 8 Jul 2019 19:24:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9EAC284D4; Mon, 8 Jul 2019 19:24:47 +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 5D2BF2847B for ; Mon, 8 Jul 2019 19:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391662AbfGHTYq (ORCPT ); Mon, 8 Jul 2019 15:24:46 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:41913 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391660AbfGHTYq (ORCPT ); Mon, 8 Jul 2019 15:24:46 -0400 Received: by mail-io1-f65.google.com with SMTP id j5so18498064ioj.8 for ; Mon, 08 Jul 2019 12:24:46 -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=qGIXOv5aXr0Zm8keKgGz5sHMQb8AM7DNIw/w19/udWc=; b=tXMVQ0lo5RZLsrbEiQ/mas7hoN5UQsEp7Z3HZ6m3b3Br6O5mNrxf98jMMWObUf0iKo rnwLUCrApwDOp10qG47ppGRBVBiwGU4K6wzSDwtyo4hipEGWfUu0S11+PYDHwzBgWRju eRUIQFcGhGyq7skZE+LzXpl7ekmW6SHcmK72cbNQ8lMIL3tk05cu0Wc/7CMVbLlqopBV 2KU8Red5qLK22rc2Ip/pzyam9NWQhM3Bc1r+Az9Me0V9wRzwKwsDABFPlTa7UNBRSWBe CkTdaZoGnpuKFqtBZUa5aOrz/pEmEukORwgw4g8cuRFrmL/YCUkSM5g65VYj7fhLm/Z3 IzoQ== 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=qGIXOv5aXr0Zm8keKgGz5sHMQb8AM7DNIw/w19/udWc=; b=uJzhpEpSHzQlWrznh58Kj+yXbdL7UpalNeCghQwUTt6rp5DY3VFfAVgHPb1ChLf13v MuZ4vtY0BBC65zkDYW5+r3er80ySuDpyKyVUTTZAyb5EZXxl4/DDkQzsl+IPMQELiCDn v0WmNMS6toMBTWCRbCUdBnzy8MAEdUaaz6X6GHcMIPL6sZW8G/0YhQBW+51+tt5lGxng 9U/KabihARrWQelk2vzP8jy2Q5CHn0iptOrtMEc23oo9Ik6xH9fa+M/u1diDF3G0p8Bw 4tm1kImCQGvRiflT21PMT29NIgdwFFf2VF5q+0a9G7mDbKH9Bvmpg8zCVo4ZINVbal+0 sdAg== X-Gm-Message-State: APjAAAVxRci0Rr/CTfq6TGXkqP1434gWH50kfQFbBq4KdHs9UEO46EaQ mMwZTTasTG+Rt4AVNqRjGxc= X-Google-Smtp-Source: APXvYqxP9Z5CW0kcXC3kHMU3Hyc9X7M30tX3OCPirtZC6cTtUL5IYXTUitqDjaPVbI/PpnVj7S/Ogw== X-Received: by 2002:a02:54c1:: with SMTP id t184mr24329488jaa.10.1562613885651; Mon, 08 Jul 2019 12:24:45 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.44 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:45 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 03/12] NFS: add ca_source_server<> to COPY Date: Mon, 8 Jul 2019 15:24:35 -0400 Message-Id: <20190708192444.12664-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia Support only one source server address: the same address that the client and source server use. Signed-off-by: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42.h | 3 ++- fs/nfs/nfs42proc.c | 26 +++++++++++++++++--------- fs/nfs/nfs42xdr.c | 12 ++++++++++-- fs/nfs/nfs4file.c | 7 ++++++- include/linux/nfs_xdr.h | 1 + 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h index 4995731a6714..02e3810cd889 100644 --- a/fs/nfs/nfs42.h +++ b/fs/nfs/nfs42.h @@ -15,7 +15,8 @@ /* nfs4.2proc.c */ #ifdef CONFIG_NFS_V4_2 int nfs42_proc_allocate(struct file *, loff_t, loff_t); -ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t); +ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t, + struct nl4_server *, nfs4_stateid *); int nfs42_proc_deallocate(struct file *, loff_t, loff_t); loff_t nfs42_proc_llseek(struct file *, loff_t, int); int nfs42_proc_layoutstats_generic(struct nfs_server *, diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 6317dd89cf43..e34ade844737 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -243,7 +243,9 @@ static ssize_t _nfs42_proc_copy(struct file *src, struct file *dst, struct nfs_lock_context *dst_lock, struct nfs42_copy_args *args, - struct nfs42_copy_res *res) + struct nfs42_copy_res *res, + struct nl4_server *nss, + nfs4_stateid *cnr_stateid) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY], @@ -257,11 +259,15 @@ static ssize_t _nfs42_proc_copy(struct file *src, size_t count = args->count; ssize_t status; - status = nfs4_set_rw_stateid(&args->src_stateid, src_lock->open_context, - src_lock, FMODE_READ); - if (status) - return status; - + if (nss) { + args->cp_src = nss; + nfs4_stateid_copy(&args->src_stateid, cnr_stateid); + } else { + status = nfs4_set_rw_stateid(&args->src_stateid, + src_lock->open_context, src_lock, FMODE_READ); + if (status) + return status; + } status = nfs_filemap_write_and_wait_range(file_inode(src)->i_mapping, pos_src, pos_src + (loff_t)count - 1); if (status) @@ -325,8 +331,9 @@ static ssize_t _nfs42_proc_copy(struct file *src, } ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, - struct file *dst, loff_t pos_dst, - size_t count) + struct file *dst, loff_t pos_dst, size_t count, + struct nl4_server *nss, + nfs4_stateid *cnr_stateid) { struct nfs_server *server = NFS_SERVER(file_inode(dst)); struct nfs_lock_context *src_lock; @@ -368,7 +375,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, inode_lock(file_inode(dst)); err = _nfs42_proc_copy(src, src_lock, dst, dst_lock, - &args, &res); + &args, &res, + nss, cnr_stateid); inode_unlock(file_inode(dst)); if (err >= 0) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index ccabc0cd93dd..c03f3246d6c5 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -21,7 +21,10 @@ #define encode_copy_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE) + \ XDR_QUADLEN(NFS4_STATEID_SIZE) + \ - 2 + 2 + 2 + 1 + 1 + 1) + 2 + 2 + 2 + 1 + 1 + 1 +\ + 1 + /* One cnr_source_server */\ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) #define decode_copy_maxsz (op_decode_hdr_maxsz + \ NFS42_WRITE_RES_SIZE + \ 1 /* cr_consecutive */ + \ @@ -216,7 +219,12 @@ static void encode_copy(struct xdr_stream *xdr, encode_uint32(xdr, 1); /* consecutive = true */ encode_uint32(xdr, args->sync); - encode_uint32(xdr, 0); /* src server list */ + if (args->cp_src == NULL) { /* intra-ssc */ + encode_uint32(xdr, 0); /* no src server list */ + return; + } + encode_uint32(xdr, 1); /* supporting 1 server */ + encode_nl4_server(xdr, args->cp_src); } static void encode_offload_cancel(struct xdr_stream *xdr, diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4e54432feb3b..b9825d02443e 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -134,6 +134,8 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, size_t count, unsigned int flags) { struct nfs42_copy_notify_res *cn_resp = NULL; + struct nl4_server *nss = NULL; + nfs4_stateid *cnrs = NULL; ssize_t ret; /* Only offload copy if superblock is the same */ @@ -154,8 +156,11 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret = -EOPNOTSUPP; goto out; } + nss = &cn_resp->cnr_src; + cnrs = &cn_resp->cnr_stateid; } - ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); + ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count, + nss, cnrs); out: kfree(cn_resp); return ret; diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 0a7af40026d7..008facac8a30 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1435,6 +1435,7 @@ struct nfs42_copy_args { u64 count; bool sync; + struct nl4_server *cp_src; }; struct nfs42_write_res { From patchwork Mon Jul 8 19:24:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035729 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 96F0317EF for ; Mon, 8 Jul 2019 19:24:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 870AE28396 for ; Mon, 8 Jul 2019 19:24:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B79D284D4; Mon, 8 Jul 2019 19:24:49 +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 E9AAE2847B for ; Mon, 8 Jul 2019 19:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391664AbfGHTYs (ORCPT ); Mon, 8 Jul 2019 15:24:48 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:34643 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391660AbfGHTYs (ORCPT ); Mon, 8 Jul 2019 15:24:48 -0400 Received: by mail-io1-f66.google.com with SMTP id k8so37945953iot.1 for ; Mon, 08 Jul 2019 12:24:47 -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=5cemtBtX1hls1+MLsuRSuTCDoBbFIh1Cf7gu0TW+wAA=; b=mRdUDy2YawJEIVBoBodO1HH3a/w0W9iXP/2m0aQr1BYn10FxofLNqD84Xhwu0PEInt CO4WrvzCH1pHmt7765znPUdcGnWD83zcgbQB0C4SOoFtuK6j+kvdGPR/bQFGrLKZrEe3 OUH7CnQkQOeRL+4X1dESTuE/MfoigLsLYKjqoJ7lA9qSjo70mebhuGAPDGbD2qvBDvR1 MK2Zc96U+jTgdujJAZ3mVWesAB4/rn8emQ5QSmOoM4kMfTboTmbk6ks+zWoCZebYIg2B pQa8/H9++eSApcNFLUYaW1Kv9EccFq3TA48ROUq6UmILokqVWeOS9i7wLCiNZf/7rtyD Mcvg== 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=5cemtBtX1hls1+MLsuRSuTCDoBbFIh1Cf7gu0TW+wAA=; b=mdWieFmOJi+o4o7iCGY6SaS77qSHT6aRmW7rR4XdELVBNURS+jeAJJzRvXJd6b1rrk i3cog13Oy38Fu//KhPTuImlDhQvpOW82ytan1AV0ZTZBxKfyIRLDcUaTdc/Zh+t1abyq S1nI0/Iywoa7Z7VKpQtNuXuwDr2jH79WbX/u2cAEWxlG7Mc4j8LCyzB9xO6tTGUkfkPX Ty8Cu1FD22GnFAbEsw/LZk/wggMeYPJB4uEGyWl6l7B06+BhzEPKpcTINdFn9Z4dYNTN KENG6HgIxtItAnwWaf2NGykjhiz4ITvPM1HK5H8Q89bYRlPcyEn3BdCNyig4vWh3i/kT 6D3w== X-Gm-Message-State: APjAAAXRzp5n2TVZUvMd825vcpexBgXkI6pDWr2zh6YxJ2NiH422Gfyi gLr8wpI6+KaZk2c1CTT6bDo= X-Google-Smtp-Source: APXvYqw4sHNwsSV2XAQy1FnEUyXufAIBZB+HhUa+ebel1r6sgYKsF5ZBW5d+dvutVw4tYD+luNkPFQ== X-Received: by 2002:a6b:da01:: with SMTP id x1mr20531336iob.216.1562613886585; Mon, 08 Jul 2019 12:24:46 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:46 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 04/12] NFS: inter ssc open Date: Mon, 8 Jul 2019 15:24:36 -0400 Message-Id: <20190708192444.12664-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia NFSv4.2 inter server to server copy requires the destination server to READ the data from the source server using the provided stateid and file handle. Given an NFSv4 stateid and filehandle from the COPY operaion, provide the destination server with an NFS client function to create a struct file suitable for the destiniation server to READ the data to be copied. Signed-off-by: Olga Kornievskaia Signed-off-by: Andy Adamson --- fs/nfs/nfs4_fs.h | 7 ++++ fs/nfs/nfs4file.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 5 +-- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index d75fea7ecf12..ff1cd600f07f 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -311,6 +311,13 @@ extern int nfs4_set_rw_stateid(nfs4_stateid *stateid, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, fmode_t fmode); +extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fattr *fattr, struct nfs4_label *label, + struct inode *inode); +extern int update_open_stateid(struct nfs4_state *state, + const nfs4_stateid *open_stateid, + const nfs4_stateid *deleg_stateid, + fmode_t fmode); #if defined(CONFIG_NFS_V4_1) extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index b9825d02443e..aab4d48764a7 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "delegation.h" #include "internal.h" #include "iostat.h" @@ -282,6 +283,99 @@ static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off, out: return ret < 0 ? ret : count; } + +static int read_name_gen = 1; +#define SSC_READ_NAME_BODY "ssc_read_%d" + +struct file * +nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh, + nfs4_stateid *stateid) +{ + struct nfs_fattr fattr; + struct file *filep, *res; + struct nfs_server *server; + struct inode *r_ino = NULL; + struct nfs_open_context *ctx; + struct nfs4_state_owner *sp; + char *read_name; + int len, status = 0; + + server = NFS_SERVER(ss_mnt->mnt_root->d_inode); + + nfs_fattr_init(&fattr); + + status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL); + if (status < 0) { + res = ERR_PTR(status); + goto out; + } + + res = ERR_PTR(-ENOMEM); + len = strlen(SSC_READ_NAME_BODY) + 16; + read_name = kzalloc(len, GFP_NOFS); + if (read_name == NULL) + goto out; + snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++); + + r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr, + NULL); + if (IS_ERR(r_ino)) { + res = ERR_CAST(r_ino); + goto out; + } + + filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ, + r_ino->i_fop); + if (IS_ERR(filep)) { + res = ERR_CAST(filep); + goto out; + } + filep->f_mode |= FMODE_READ; + + ctx = alloc_nfs_open_context(filep->f_path.dentry, filep->f_mode, + filep); + if (IS_ERR(ctx)) { + res = ERR_CAST(ctx); + goto out_filep; + } + + res = ERR_PTR(-EINVAL); + sp = nfs4_get_state_owner(server, ctx->cred, GFP_KERNEL); + if (sp == NULL) + goto out_ctx; + + ctx->state = nfs4_get_open_state(r_ino, sp); + if (ctx->state == NULL) + goto out_stateowner; + + set_bit(NFS_OPEN_STATE, &ctx->state->flags); + memcpy(&ctx->state->open_stateid.other, &stateid->other, + NFS4_STATEID_OTHER_SIZE); + update_open_stateid(ctx->state, stateid, NULL, filep->f_mode); + + nfs_file_set_open_context(filep, ctx); + put_nfs_open_context(ctx); + + file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping); + res = filep; +out: + return res; +out_stateowner: + nfs4_put_state_owner(sp); +out_ctx: + put_nfs_open_context(ctx); +out_filep: + fput(filep); + goto out; +} +EXPORT_SYMBOL_GPL(nfs42_ssc_open); +void nfs42_ssc_close(struct file *filep) +{ + struct nfs_open_context *ctx = nfs_file_open_context(filep); + + ctx->state->flags = 0; +} +EXPORT_SYMBOL_GPL(nfs42_ssc_close); #endif /* CONFIG_NFS_V4_2 */ const struct file_operations nfs4_file_operations = { diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 9bbd9bad5412..c898ce1bccc6 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -91,7 +91,6 @@ struct nfs4_opendata; static int _nfs4_recover_proc_open(struct nfs4_opendata *data); static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr); -static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode); static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode); static int nfs4_do_setattr(struct inode *inode, const struct cred *cred, struct nfs_fattr *fattr, struct iattr *sattr, @@ -1674,7 +1673,7 @@ static void nfs_state_clear_delegation(struct nfs4_state *state) write_sequnlock(&state->seqlock); } -static int update_open_stateid(struct nfs4_state *state, +int update_open_stateid(struct nfs4_state *state, const nfs4_stateid *open_stateid, const nfs4_stateid *delegation, fmode_t fmode) @@ -3966,7 +3965,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); } -static int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, +int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode) { From patchwork Mon Jul 8 19:24:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035727 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 2E5D5138D for ; Mon, 8 Jul 2019 19:24:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FE9C28396 for ; Mon, 8 Jul 2019 19:24:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1499328516; Mon, 8 Jul 2019 19:24:49 +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 A2E7728396 for ; Mon, 8 Jul 2019 19:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391663AbfGHTYs (ORCPT ); Mon, 8 Jul 2019 15:24:48 -0400 Received: from mail-io1-f47.google.com ([209.85.166.47]:39579 "EHLO mail-io1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbfGHTYs (ORCPT ); Mon, 8 Jul 2019 15:24:48 -0400 Received: by mail-io1-f47.google.com with SMTP id f4so22356105ioh.6 for ; Mon, 08 Jul 2019 12:24:47 -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=j4mW/8OmzRmXM+ufLvtFbCF367tp/PDFgRYcUVIHLSc=; b=BBPjV1Ltk+wYqzSmAIf2CIzbnW+22auh7F/cNllpSAuAzN1JbnQII72SA1M8RKsTYl HYGesKR+KyuJMMpBoEtcxq+oSJLeHDQpBi8UOyvq31lMemKvOoeIibDShIy4HaxkqUGe 6+OTBgDn00QfD37AoWWYwo7+r98Cw0pPV51ePIY1yRrwd4ae2/VPXvw/flACGgtqCWwb qhRGcY7jM9qZDJ7NvQ9t44ERJH4dzqVDpllKVAeRgrd6Qvc1dD8aRdekIHD1dXG5aF9m Pm68gZw52Z04Juh+Bpf4/iBWSy1o8KDg9nDP7ixtQrV6XneXb4TCrI1Jxky96bTVIhl3 hIpA== 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=j4mW/8OmzRmXM+ufLvtFbCF367tp/PDFgRYcUVIHLSc=; b=Llz5SAuF5dwgeB3ZHYatLKGr07I2IgcudWYgj9MmQg6melkQmqXO+ovvVr9t2ouSMv OIiStIPFqvTp/Mi6QdQQa9DuUWW9UXo5QSCVKE96TjrK+i0WoYmZfF2Puk4Tg/yc068J J6oWKbtjH91ORveISMGLW7y7NPjCngxiKerN7vTvSR8zA2oIkjxwrMbuzU96Ceyi1kuN htWUyOOizaGLz/5lDqv5dIKRJIQLgYwgJ02D88LhPMWHr4Wm93L4BzFjdOuWdCAcf3G1 Gj0ZFXo8/ZIG6hcSA0jH1AO3z9CnkrN97IctnUxNZ2YeNUevHTfYAQcICN9Z5fBNl3FI PjzA== X-Gm-Message-State: APjAAAU4rWMFxAIXQ/Z2wNmbwbWneyQIImKzZeu1mCaDtG0w+cjFCFAC Y3Kz1kaJhjOZdtJB1vcSRs8= X-Google-Smtp-Source: APXvYqyXmtUAKotR6GO99eeyXA3Imtkn/gDsB8A+slk6QJbUU+TwixU15/kldopGwG+LpfrXGu+rqA== X-Received: by 2002:a5d:9c46:: with SMTP id 6mr12841471iof.6.1562613887298; Mon, 08 Jul 2019 12:24:47 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:46 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 05/12] NFS: skip recovery of copy open on dest server Date: Mon, 8 Jul 2019 15:24:37 -0400 Message-Id: <20190708192444.12664-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia Mark the open created for the source file on the destination server. Then if this open is going thru a recovery, then fail the recovery as we don't need to be recoving a "fake" open. We need to fail the ongoing READs and vfs_copy_file_range(). Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4file.c | 1 + fs/nfs/nfs4state.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index ff1cd600f07f..d49fc19361d2 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -168,6 +168,7 @@ enum { NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */ #ifdef CONFIG_NFS_V4_2 NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/ + NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */ #endif /* CONFIG_NFS_V4_2 */ }; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index aab4d48764a7..5ef3c12bb54b 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -348,6 +348,7 @@ nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh, if (ctx->state == NULL) goto out_stateowner; + set_bit(NFS_SRV_SSC_COPY_STATE, &ctx->state->flags); set_bit(NFS_OPEN_STATE, &ctx->state->flags); memcpy(&ctx->state->open_stateid.other, &stateid->other, NFS4_STATEID_OTHER_SIZE); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index e2e3c4f04d3e..045af569835c 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1607,6 +1607,9 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs { struct nfs4_state *state; int status = 0; +#ifdef CONFIG_NFS_V4_2 + bool found_ssc_copy_state = false; +#endif /* CONFIG_NFS_V4_2 */ /* Note: we rely on the sp->so_states list being ordered * so that we always reclaim open(O_RDWR) and/or open(O_WRITE) @@ -1626,6 +1629,13 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs continue; if (state->state == 0) continue; +#ifdef CONFIG_NFS_V4_2 + if (test_bit(NFS_SRV_SSC_COPY_STATE, &state->flags)) { + nfs4_state_mark_recovery_failed(state, -EIO); + found_ssc_copy_state = true; + continue; + } +#endif /* CONFIG_NFS_V4_2 */ refcount_inc(&state->count); spin_unlock(&sp->so_lock); status = __nfs4_reclaim_open_state(sp, state, ops); @@ -1672,6 +1682,10 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs } raw_write_seqcount_end(&sp->so_reclaim_seqcount); spin_unlock(&sp->so_lock); +#ifdef CONFIG_NFS_V4_2 + if (found_ssc_copy_state) + return -EIO; +#endif /* CONFIG_NFS_V4_2 */ return 0; out_err: nfs4_put_open_state(state); From patchwork Mon Jul 8 19:24:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035731 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 3749B112C for ; Mon, 8 Jul 2019 19:24:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 271C328396 for ; Mon, 8 Jul 2019 19:24:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B813284D4; Mon, 8 Jul 2019 19:24:50 +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 C37F528396 for ; Mon, 8 Jul 2019 19:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391660AbfGHTYt (ORCPT ); Mon, 8 Jul 2019 15:24:49 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:43331 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbfGHTYt (ORCPT ); Mon, 8 Jul 2019 15:24:49 -0400 Received: by mail-io1-f66.google.com with SMTP id k20so37809755ios.10 for ; Mon, 08 Jul 2019 12:24:48 -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=NMgsPwcgWqY799nLZlYuCre0/XwCSngAA3yPJe7nzXA=; b=pZa+FrrhJrg7gebnCnTwMs8MW/J/u+rhUjmZjQ5sJ7mNRxCOjetNm8qaxwBkqsQoBc ZacHDmZkX2qxT3JKk1DU/uU9a0JHh+nBIUv4wy3udt0QvOLyBOFKtK9DJ19yCtAC7Ld4 wbielMxGqYc5Zxj+aGaGzZN6bcqUAYg1IaQDpxzTOInjkBCItP77CJlbU4er4VKNsBeo RJVVXBYycO4T87r9EnJqIqJtN67EzK4USYzUo+1TZEVUroxlFoKccqh9l5TmmOu/EgL7 T+BQ4eqY5THDoNud/7Ada8/qAEd2YQxaltW4E56cL2F7d/sIOr1o1LhL1EICkjTRm/ck IOVA== 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=NMgsPwcgWqY799nLZlYuCre0/XwCSngAA3yPJe7nzXA=; b=YZgrhU0A+96nPi6oqDujwd6cN6HlkBhTZ8gkxVDWtDpybwdD6xs3GPQlWsyBkc2/TF e/bg4JmEU/GgMrP/QbAUuFhpGFUJ1FTs17G/W8itsWeesAHgpR4Sf37ynTx21sawo6qZ XUqDWsFXbvLz3o6weCrhLtg9b3j2HOj8tlyq7w8WmQB95VuCBGZ92pj9/7vMitvBAvWm Jg7wrzgD0u0ZNCY+VAn3F9ap0AerDsAl4bGrwGXdWWe1YkBDFCWz6ql9Csd3ymUaFe80 Sw/s/IdBkeUifrO0ggqtmU3pZeBtb6lyUyc89tuqzTns3lLTTQAnND78n4Otr+v55HLT c4YQ== X-Gm-Message-State: APjAAAWMDau/A6LpWB8XiotSnytH8NXQmzSw3cITnQ3y15HNpaU9lcNE AefHJrSQVI6CG874r65BOPE= X-Google-Smtp-Source: APXvYqzKXvAeECRGfNGRrz/xQf5zEC69ybhPt0Spi4Ih4YKaHMDLHZMwf6n+SvSPHlj9eFIMaN2o+w== X-Received: by 2002:a05:6602:2256:: with SMTP id o22mr19862457ioo.95.1562613888216; Mon, 08 Jul 2019 12:24:48 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.47 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:47 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 06/12] NFS: for "inter" copy treat ESTALE as ENOTSUPP Date: Mon, 8 Jul 2019 15:24:38 -0400 Message-Id: <20190708192444.12664-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia If the client sends an "inter" copy to the destination server but it only supports "intra" copy, it can return ESTALE (since it doesn't know anything about the file handle from the other server and does not recognize the special case of "inter" copy). Translate this error as ENOTSUPP and also send OFFLOAD_CANCEL to the source server so that it can clean up state. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index e34ade844737..6ed5a16dc511 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -391,6 +391,11 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry = 1; continue; + } else if (err == -ESTALE && + !nfs42_files_from_same_server(src, dst)) { + nfs42_do_offload_cancel_async(src, &args.src_stateid); + err = -EOPNOTSUPP; + break; } err2 = nfs4_handle_exception(server, err, &src_exception); From patchwork Mon Jul 8 19:24:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035733 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 2C22E138D for ; Mon, 8 Jul 2019 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8FF28396 for ; Mon, 8 Jul 2019 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10FFD284D4; Mon, 8 Jul 2019 19:24:51 +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 871E628396 for ; Mon, 8 Jul 2019 19:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391666AbfGHTYu (ORCPT ); Mon, 8 Jul 2019 15:24:50 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:35228 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391658AbfGHTYt (ORCPT ); Mon, 8 Jul 2019 15:24:49 -0400 Received: by mail-io1-f65.google.com with SMTP id m24so28392231ioo.2 for ; Mon, 08 Jul 2019 12:24:49 -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=hf/20/zgdRrBxlarA02mT/b6DodVKxI+tbzEDBpNpDw=; b=jxFIO9ay0UFIutz8wc1fDf0y2S4XgJGgDH19BfvKTPbIcCWm/W+CoUJxK3oIIiYvSW HOnP0C8DbS8TmgX0Y9XwZSU7PymutoJMcanmFOJlz6w/PDw8rYsWuv41hK0sVDKb1CY9 kpVKviOjlqzZRMogtZfQJ3zcOwgnEKblRRhq0LmjLQWfnojm7KbPGQo4Tja4aiKTpIlQ YzjsxneWGGjhFCMF0z0D1PWtfmSGkmf5JKKKflNRjaNCmGl1rkIEBR4sGCToXiCp22DZ ed2M2oLUPpTjdnSJmaV7P3EWuF2l06HGeg/vZ91aofj+d4svxAvkq8Qb6/+ut8cl71Nu bpLQ== 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=hf/20/zgdRrBxlarA02mT/b6DodVKxI+tbzEDBpNpDw=; b=JDN7garOR0a6G8XcTVDrJEDhLnCZ5xYeROMJvmbx6Rv/Vx0wJILveyPjD8ZL7neJ2K qmaOlEpV+50eun1050XsbazLiHPCh7Hee+PBx/5Tl+P1VvsQ1WwEBCyKR4DcnGqKwQJK lZwjw8whcNcBPPNkvSAM5GQEiRORmMH5JPwpoifDE0gFtlsPXXK8u28ZPDvtHCpNecRX bJQbXr+MYFU0yZJHUPHk8iW0hFJoVxa0If8Bhzt4HSqhLMnkeVVzjLR/nS93EuNJtZ+n sFh2zWb6Bff0PrECGSVJ+0CTfJHlmy+W98/09/DY3ZsUMLVIAiA70RIV+YrlGFe1PFJ1 jzEQ== X-Gm-Message-State: APjAAAUh2zdAtzsgF03KX/412URjyXLK5x1da775i2zzSg2VYEAxEvCa SkEGu1URVYXMcQatH7mGHCU= X-Google-Smtp-Source: APXvYqy2DQB1YjnCfIzKNX6wLHSN0qozvcL0NxKXAzRydBwK9G8eeJBB4q0OfnnEnAjpsJ7pRw1sXg== X-Received: by 2002:a6b:5106:: with SMTP id f6mr19008107iob.15.1562613889108; Mon, 08 Jul 2019 12:24:49 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.48 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:48 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 07/12] NFS: COPY handle ERR_OFFLOAD_DENIED Date: Mon, 8 Jul 2019 15:24:39 -0400 Message-Id: <20190708192444.12664-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia If server sends ERR_OFFLOAD_DENIED error, the client must fall back on doing copy the normal way. Return ENOTSUPP to the vfs and fallback to regular copy. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 6ed5a16dc511..50538b975aba 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -391,7 +391,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry = 1; continue; - } else if (err == -ESTALE && + } else if ((err == -ESTALE || + err == -NFS4ERR_OFFLOAD_DENIED) && !nfs42_files_from_same_server(src, dst)) { nfs42_do_offload_cancel_async(src, &args.src_stateid); err = -EOPNOTSUPP; From patchwork Mon Jul 8 19:24:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035735 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 C072A17EF for ; Mon, 8 Jul 2019 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B14F128396 for ; Mon, 8 Jul 2019 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5749284D4; Mon, 8 Jul 2019 19:24:51 +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 534AF28396 for ; Mon, 8 Jul 2019 19:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391658AbfGHTYu (ORCPT ); Mon, 8 Jul 2019 15:24:50 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:44496 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391667AbfGHTYu (ORCPT ); Mon, 8 Jul 2019 15:24:50 -0400 Received: by mail-io1-f65.google.com with SMTP id s7so37836330iob.11 for ; Mon, 08 Jul 2019 12:24:50 -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=yo9sLYVGIpnI5eQhl4Hmyu40q9FnCAike73i03d2rRI=; b=rI9vZrH1Rv9A+8HtuhI7Ouvhd1DmxDu2dcPEDLNBJe8FSihO4AJJZlkQvZTu6Eb9o6 +Q79YG/EgQLpQXSXqN3RLDlpCi1GkowN78mFm9o3d1hYSxRWFWkPz76hsExr0rq+dyOn tX7d1fwZx7lAmkDSeK+xnSr/+wowB3pFpblIjQKcugScWaS0qrm6nllUoHwO7lnOt6I3 tN7SWLWEIiXCW/5zH1fmRuJ+MB6S5CNMubxQVZfK35N+HKmea6WhfAXO2qmNSGj/PPN2 5lpcL09PvLNx3h6npLsduVNf9mekGVZWxNoFp7WoI21g+9k6hntEcT41IiOVqY2x7Hjk tWwg== 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=yo9sLYVGIpnI5eQhl4Hmyu40q9FnCAike73i03d2rRI=; b=oDosbn7Qm7B4Ls+QX2zBCQCeduh/ayjABjzbzbZnDXNM/jk7ZK7vti69Ahcb/sa+ic sa7azx9tSfvz89PVYGngjuMZtVhZOJGF7VkZTG2r8CzMx6UYjLwpKRTQkJ0C63eTtC9Y 00RWZM+fHPXNBbyPIQkQTLEC/7uLC8bZdpuSuR6HVlAVYlHuiTxyV3jq3W2mQtmAmvl2 7IdpuS5scyCWdryIAe1r+Ol5SWdhSAhMLp7H36VXiApt093pw/gaIBCenNRh+0SqcrK/ 8Mu7Kq/K4A3tD8WMDhekpozST2qeSLuqt9kWpde/neAltqLyk6zbveqaTtAxJMnTiOoL LsfA== X-Gm-Message-State: APjAAAXJLucMB2Kok4yliFhEmoc9D7rJ0s24+eGrOAPN+70Sjn4r6xkw NmYPJiQiv0mC4FNbPCRMtPU= X-Google-Smtp-Source: APXvYqw4jRl+5ZMZL7srLmkj0L31Orryo7FxtLaKDCxzS5whOYHAU7AAiUfyxwLYO23fIsqUXp+E+A== X-Received: by 2002:a6b:3102:: with SMTP id j2mr1018846ioa.5.1562613889954; Mon, 08 Jul 2019 12:24:49 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.49 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:49 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 08/12] NFS: also send OFFLOAD_CANCEL to source server Date: Mon, 8 Jul 2019 15:24:40 -0400 Message-Id: <20190708192444.12664-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia In case of copy is cancelled, also send OFFLOAD_CANCEL to the source server. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 50538b975aba..5d833f5748e9 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -206,12 +206,14 @@ static int handle_async_copy(struct nfs42_copy_res *res, memcpy(&res->write_res.verifier, ©->verf, sizeof(copy->verf)); status = -copy->error; +out_free: kfree(copy); return status; out_cancel: nfs42_do_offload_cancel_async(dst, ©->stateid); - kfree(copy); - return status; + if (!nfs42_files_from_same_server(src, dst)) + nfs42_do_offload_cancel_async(src, src_stateid); + goto out_free; } static int process_copy_commit(struct file *dst, loff_t pos_dst, @@ -381,7 +383,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, if (err >= 0) break; - if (err == -ENOTSUPP) { + if (err == -ENOTSUPP && + nfs42_files_from_same_server(src, dst)) { err = -EOPNOTSUPP; break; } else if (err == -EAGAIN) { @@ -392,7 +395,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, dst_exception.retry = 1; continue; } else if ((err == -ESTALE || - err == -NFS4ERR_OFFLOAD_DENIED) && + err == -NFS4ERR_OFFLOAD_DENIED || + err == -ENOTSUPP) && !nfs42_files_from_same_server(src, dst)) { nfs42_do_offload_cancel_async(src, &args.src_stateid); err = -EOPNOTSUPP; From patchwork Mon Jul 8 19:24:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035737 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 854C9112C for ; Mon, 8 Jul 2019 19:24:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75F1028396 for ; Mon, 8 Jul 2019 19:24:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A406284D4; Mon, 8 Jul 2019 19:24:52 +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 1896328396 for ; Mon, 8 Jul 2019 19:24:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391668AbfGHTYv (ORCPT ); Mon, 8 Jul 2019 15:24:51 -0400 Received: from mail-io1-f54.google.com ([209.85.166.54]:37910 "EHLO mail-io1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391667AbfGHTYv (ORCPT ); Mon, 8 Jul 2019 15:24:51 -0400 Received: by mail-io1-f54.google.com with SMTP id j6so37879073ioa.5 for ; Mon, 08 Jul 2019 12:24:51 -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=J5715FQO+sJDvJbVkL450ZeVhGjy4w0w+RjJo9pkRRA=; b=W7yQ4hx3UCbZujqZdg46GHV4tnhJR42jphOAH/Sc2qO8BPeA0ZCTlerIW0cIgNIsF6 PmVVwfF/r44nRuDJgDV85hdahSdF4+LEARYugowbweB6G4oAyz25Q+GJJgF3QLqNmwaj elUjy5p0xOz+eJ6oOyF/FsAUXpehMDnVZ988uBefEhbh1QkYoK4YzhgvdvuZXC1ExYVC JQIdWptNurIO/I0HReyZyz97Dv/XCmPfX4GXQOzxtFBWBSj4nDmwNImf+BDiQn4bMkAV o05BeOPSILtFgGZhvSdaqWDLfvtGx0ePhoGGJh6eqqWyRLkamEnh/yqxPUWg64DJoB+X +swA== 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=J5715FQO+sJDvJbVkL450ZeVhGjy4w0w+RjJo9pkRRA=; b=Ojn0hBGXK8iVmVJvBMamILy0ieRBTOBLBi8SOUplFQE+e1sngQzApTPPHg1bAKojIw eAO/hPtWZ3+yaMv5KTkw9PupbMMICKpzPAgiySyt0CgQdNKxp0UZT4WN/R98mkHYTx8G +BR16sw5OBFU9sXwuhWR951cqF4ENmMPjLmdj+MF/L20cQx4c2o+RUd43n8WYUves9m1 R2pSVrR8X3s185XceKVv7HDHLO1uaUwWOMrtnuS1XNOIQoSNJq5jN5ycxEgalnUMjN8p 8GBHJjlvtUpCwwVoIXshIdv1ZavEEMgU9PMWRKoePuWZh2uM+UaYTZxtq97VdWKlwvNP fJ4Q== X-Gm-Message-State: APjAAAWuncAn7Lhta107gRPNcT1BksxkVjCugzZWmOTIUzX/XhmIJovN ZtM0R6yBkHhZnfmWkw/sdZ0M10JIKtw= X-Google-Smtp-Source: APXvYqzcZMd9OQ9s60s9LfKcYizO+oNYvJWtT6d4iUcke/N0EIuC3KbsjBenLM6dXDbbCJKON9pCdg== X-Received: by 2002:a6b:6310:: with SMTP id p16mr20928439iog.118.1562613890763; Mon, 08 Jul 2019 12:24:50 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.49 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:50 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 09/12] NFS handle NFS4ERR_PARTNER_NO_AUTH error Date: Mon, 8 Jul 2019 15:24:41 -0400 Message-Id: <20190708192444.12664-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia When a destination server sends a READ to the source server it can get a NFS4ERR_PARTNER_NO_AUTH, which means a copy needs to be restarted. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4proc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c898ce1bccc6..e31e1b683d62 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -458,6 +458,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server, case -NFS4ERR_ADMIN_REVOKED: case -NFS4ERR_EXPIRED: case -NFS4ERR_BAD_STATEID: + case -NFS4ERR_PARTNER_NO_AUTH: if (inode != NULL && stateid != NULL) { nfs_inode_find_state_and_recover(inode, stateid); From patchwork Mon Jul 8 19:24:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035743 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 89DF8112C for ; Mon, 8 Jul 2019 19:24:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785FB28396 for ; Mon, 8 Jul 2019 19:24:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D0AB284D4; Mon, 8 Jul 2019 19:24:55 +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 C0E4028396 for ; Mon, 8 Jul 2019 19:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391670AbfGHTYx (ORCPT ); Mon, 8 Jul 2019 15:24:53 -0400 Received: from mail-io1-f42.google.com ([209.85.166.42]:41037 "EHLO mail-io1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391667AbfGHTYx (ORCPT ); Mon, 8 Jul 2019 15:24:53 -0400 Received: by mail-io1-f42.google.com with SMTP id j5so18498714ioj.8 for ; Mon, 08 Jul 2019 12:24:52 -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=ZM8tDpymrPcQprwiAwHYfPLbTDi/J3kKbCfrEy6Yvqs=; b=p7vdBGmAI3tjcmZqophv3uoanAtAKZpLczg6pMhOgBXvqVjadky7acFF0FuGW0aZF9 cDWC7FCb3i7aEySTq0Jye4feIc/LRCb0x7yzvZTDN+iZywfLkLwxRdz0pSbljFPooPT1 Q11oduhkGmRKiwDwzjiPpdP496L3Q16DaRTQXczx5gyzGaLOMyCxxBA9Fb6gvE5jzcgu SA/NssYfETPXJFzOvMbRqkDW+vARB9nrueD8MdQh/uxWGW3cP3N2YEQbcbLVkcBQMT4w d776Fk9jAW9z/i3YJEYNnh3Fe2mVW7gd9s4Wk8XFLLBdTsnh1VujuaJ7jRpM8Yk4idoR f4MQ== 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=ZM8tDpymrPcQprwiAwHYfPLbTDi/J3kKbCfrEy6Yvqs=; b=VfkO86ZepkFtkpZvKpCE0wtjKQ2fhqmEjOC90va3sMhjXyw8V229rGkSnD+/8P1YT+ l2mh80zH7WBxwUsdkMFbDJt4J6NuQtieahBsfAcLCeGsGFSzGuqnLLVfHn+DP2QgVMbb XkaPFYdRPwLq2xQQkZgbfa6W2eF7eEW01hZg+f9rTmcwXIYe6zOrpM0Wis2YJCE7j+yQ YKqGWobWImrGkp/CMvhVVsEr0dztB4HRUNTwz5B2t1MZrzGpjaHbOoofueiltX0fF4xk qcJqV+XmzAQJrrIdxVnpzlEYJ0FxsuuQVcTFhEmJRPxHea3vModDSHBdk6yDK9Zlfrxy 5XgA== X-Gm-Message-State: APjAAAVuqLmiRS58IPeY0MZNgEJEBw0yDgYN/b6L91uvN8nAjRqLXInT Rn0z6LCEaGCkkcn25nZZQMI= X-Google-Smtp-Source: APXvYqx1hv/Y/FHh5IAjgxt7jNhmn+AkJHH3kAgNhfxOS49KCX2pr/k0RxpqXIXVr09b3NEEzpqiDg== X-Received: by 2002:a6b:e608:: with SMTP id g8mr1647396ioh.88.1562613891829; Mon, 08 Jul 2019 12:24:51 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:51 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 10/12] NFS: handle source server reboot Date: Mon, 8 Jul 2019 15:24:42 -0400 Message-Id: <20190708192444.12664-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia When the source server reboots after a server-to-server copy was issued, we need to retry the copy from COPY_NOTIFY. We need to detect that the source server rebooted and there is a copy waiting on a destination server and wake it up. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 68 +++++++++++++++++++++++++++++------------- fs/nfs/nfs4_fs.h | 1 + fs/nfs/nfs4file.c | 3 ++ fs/nfs/nfs4state.c | 26 ++++++++++++---- include/linux/nfs_fs.h | 4 ++- 5 files changed, 75 insertions(+), 27 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 5d833f5748e9..9c7feacb0358 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -153,22 +153,26 @@ int nfs42_proc_deallocate(struct file *filep, loff_t offset, loff_t len) } static int handle_async_copy(struct nfs42_copy_res *res, - struct nfs_server *server, + struct nfs_server *dst_server, + struct nfs_server *src_server, struct file *src, struct file *dst, - nfs4_stateid *src_stateid) + nfs4_stateid *src_stateid, + bool *restart) { struct nfs4_copy_state *copy, *tmp_copy; int status = NFS4_OK; bool found_pending = false; - struct nfs_open_context *ctx = nfs_file_open_context(dst); + struct nfs_open_context *dst_ctx = nfs_file_open_context(dst); + struct nfs_open_context *src_ctx = nfs_file_open_context(src); copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_NOFS); if (!copy) return -ENOMEM; - spin_lock(&server->nfs_client->cl_lock); - list_for_each_entry(tmp_copy, &server->nfs_client->pending_cb_stateids, + spin_lock(&dst_server->nfs_client->cl_lock); + list_for_each_entry(tmp_copy, + &dst_server->nfs_client->pending_cb_stateids, copies) { if (memcmp(&res->write_res.stateid, &tmp_copy->stateid, NFS4_STATEID_SIZE)) @@ -178,7 +182,7 @@ static int handle_async_copy(struct nfs42_copy_res *res, break; } if (found_pending) { - spin_unlock(&server->nfs_client->cl_lock); + spin_unlock(&dst_server->nfs_client->cl_lock); kfree(copy); copy = tmp_copy; goto out; @@ -186,19 +190,32 @@ static int handle_async_copy(struct nfs42_copy_res *res, memcpy(©->stateid, &res->write_res.stateid, NFS4_STATEID_SIZE); init_completion(©->completion); - copy->parent_state = ctx->state; + copy->parent_dst_state = dst_ctx->state; + copy->parent_src_state = src_ctx->state; + + list_add_tail(©->copies, &dst_server->ss_copies); + spin_unlock(&dst_server->nfs_client->cl_lock); - list_add_tail(©->copies, &server->ss_copies); - spin_unlock(&server->nfs_client->cl_lock); + if (dst_server != src_server) { + spin_lock(&src_server->nfs_client->cl_lock); + list_add_tail(©->src_copies, &src_server->ss_copies); + spin_unlock(&src_server->nfs_client->cl_lock); + } status = wait_for_completion_interruptible(©->completion); - spin_lock(&server->nfs_client->cl_lock); + spin_lock(&dst_server->nfs_client->cl_lock); list_del_init(©->copies); - spin_unlock(&server->nfs_client->cl_lock); + spin_unlock(&dst_server->nfs_client->cl_lock); + if (dst_server != src_server) { + spin_lock(&src_server->nfs_client->cl_lock); + list_del_init(©->src_copies); + spin_unlock(&src_server->nfs_client->cl_lock); + } if (status == -ERESTARTSYS) { goto out_cancel; - } else if (copy->flags) { + } else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { status = -EAGAIN; + *restart = true; goto out_cancel; } out: @@ -247,7 +264,8 @@ static ssize_t _nfs42_proc_copy(struct file *src, struct nfs42_copy_args *args, struct nfs42_copy_res *res, struct nl4_server *nss, - nfs4_stateid *cnr_stateid) + nfs4_stateid *cnr_stateid, + bool *restart) { struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY], @@ -255,7 +273,9 @@ static ssize_t _nfs42_proc_copy(struct file *src, .rpc_resp = res, }; struct inode *dst_inode = file_inode(dst); - struct nfs_server *server = NFS_SERVER(dst_inode); + struct inode *src_inode = file_inode(src); + struct nfs_server *dst_server = NFS_SERVER(dst_inode); + struct nfs_server *src_server = NFS_SERVER(src_inode); loff_t pos_src = args->src_pos; loff_t pos_dst = args->dst_pos; size_t count = args->count; @@ -291,13 +311,15 @@ static ssize_t _nfs42_proc_copy(struct file *src, if (!res->commit_res.verf) return -ENOMEM; } + set_bit(NFS_CLNT_SRC_SSC_COPY_STATE, + &src_lock->open_context->state->flags); set_bit(NFS_CLNT_DST_SSC_COPY_STATE, &dst_lock->open_context->state->flags); - status = nfs4_call_sync(server->client, server, &msg, + status = nfs4_call_sync(dst_server->client, dst_server, &msg, &args->seq_args, &res->seq_res, 0); if (status == -ENOTSUPP) - server->caps &= ~NFS_CAP_COPY; + dst_server->caps &= ~NFS_CAP_COPY; if (status) goto out; @@ -309,8 +331,8 @@ static ssize_t _nfs42_proc_copy(struct file *src, } if (!res->synchronous) { - status = handle_async_copy(res, server, src, dst, - &args->src_stateid); + status = handle_async_copy(res, dst_server, src_server, src, + dst, &args->src_stateid, restart); if (status) return status; } @@ -358,6 +380,7 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, .stateid = &args.dst_stateid, }; ssize_t err, err2; + bool restart = false; src_lock = nfs_get_lock_context(nfs_file_open_context(src)); if (IS_ERR(src_lock)) @@ -378,7 +401,7 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, err = _nfs42_proc_copy(src, src_lock, dst, dst_lock, &args, &res, - nss, cnr_stateid); + nss, cnr_stateid, &restart); inode_unlock(file_inode(dst)); if (err >= 0) @@ -388,8 +411,11 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, err = -EOPNOTSUPP; break; } else if (err == -EAGAIN) { - dst_exception.retry = 1; - continue; + if (!restart) { + dst_exception.retry = 1; + continue; + } + break; } else if (err == -NFS4ERR_OFFLOAD_NO_REQS && !args.sync) { args.sync = true; dst_exception.retry = 1; diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index d49fc19361d2..2cb5f507eefd 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -168,6 +168,7 @@ enum { NFS_STATE_CHANGE_WAIT, /* A state changing operation is outstanding */ #ifdef CONFIG_NFS_V4_2 NFS_CLNT_DST_SSC_COPY_STATE, /* dst server open state on client*/ + NFS_CLNT_SRC_SSC_COPY_STATE, /* src server open state on client*/ NFS_SRV_SSC_COPY_STATE, /* ssc state on the dst server */ #endif /* CONFIG_NFS_V4_2 */ }; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 5ef3c12bb54b..3bfa041424bc 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -146,6 +146,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, return -EOPNOTSUPP; if (file_inode(file_in) == file_inode(file_out)) return -EOPNOTSUPP; +retry: if (!nfs42_files_from_same_server(file_in, file_out)) { cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res), GFP_NOFS); @@ -164,6 +165,8 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, nss, cnrs); out: kfree(cn_resp); + if (ret == -EAGAIN) + goto retry; return ret; } diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 045af569835c..329e3ff872ab 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1555,16 +1555,32 @@ static void nfs42_complete_copies(struct nfs4_state_owner *sp, struct nfs4_state { struct nfs4_copy_state *copy; - if (!test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags)) + if (!test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) && + !test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags)) return; spin_lock(&sp->so_server->nfs_client->cl_lock); list_for_each_entry(copy, &sp->so_server->ss_copies, copies) { - if (!nfs4_stateid_match_other(&state->stateid, ©->parent_state->stateid)) - continue; + if ((test_bit(NFS_CLNT_DST_SSC_COPY_STATE, &state->flags) && + !nfs4_stateid_match_other(&state->stateid, + ©->parent_dst_state->stateid))) + continue; copy->flags = 1; - complete(©->completion); - break; + if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE, + &state->flags)) { + clear_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags); + complete(©->completion); + } + } + list_for_each_entry(copy, &sp->so_server->ss_copies, src_copies) { + if ((test_bit(NFS_CLNT_SRC_SSC_COPY_STATE, &state->flags) && + !nfs4_stateid_match_other(&state->stateid, + ©->parent_src_state->stateid))) + continue; + copy->flags = 1; + if (test_and_clear_bit(NFS_CLNT_DST_SSC_COPY_STATE, + &state->flags)) + complete(©->completion); } spin_unlock(&sp->so_server->nfs_client->cl_lock); } diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 0a11712a80e3..af584b1441ed 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -189,13 +189,15 @@ struct nfs_inode { struct nfs4_copy_state { struct list_head copies; + struct list_head src_copies; nfs4_stateid stateid; struct completion completion; uint64_t count; struct nfs_writeverf verf; int error; int flags; - struct nfs4_state *parent_state; + struct nfs4_state *parent_src_state; + struct nfs4_state *parent_dst_state; }; /* From patchwork Mon Jul 8 19:24:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035739 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 971AF112C for ; Mon, 8 Jul 2019 19:24:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87C862847B for ; Mon, 8 Jul 2019 19:24:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BD9A2852A; Mon, 8 Jul 2019 19:24:54 +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 EC2302847B for ; Mon, 8 Jul 2019 19:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391667AbfGHTYx (ORCPT ); Mon, 8 Jul 2019 15:24:53 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:43350 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391669AbfGHTYx (ORCPT ); Mon, 8 Jul 2019 15:24:53 -0400 Received: by mail-io1-f65.google.com with SMTP id k20so37810233ios.10 for ; Mon, 08 Jul 2019 12:24:52 -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=bIJpgprQPfxBsVxXDMaXUeK2hzuj27H2g/+Kc9t54wc=; b=XZMguoSsFIHqkPYSXlyyXWDGh6B9aMEiQzl6UIDyOigyqChh/Bup4JPT9SrI/N0xgI 1+8rfP7LZruFL1gw2/64i/ZoGAp1p1E/3fiBdGZNcjKCXK3kz61wYY2ztfMWIv4ZR2/K lXOJcKgUcgUFFsZVhAFcDgXarrnQE9EhvYaQY/NUtO0JsF2UuggCPw+yPoxvu3lHUam3 t94KwVpUPNdN0dDYmShEnB/vqRAxLVdmU0dQpQNgMROx/yEg66S1r/J4iw3N0DriNg2u Zjryliy+yjejbgwzEo4TRviqXELuYNlIwfkjPAakHbHofzw/ryl6xwp+Amf1x9EGkE0/ abDg== 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=bIJpgprQPfxBsVxXDMaXUeK2hzuj27H2g/+Kc9t54wc=; b=TD20X63BbVVgv/9BwNntK8RAjHZQiKBCROLiRf8jrUuL/i0SGUUWk8VCE87Ob8YWiH zaliOkRIcRzyekS3XYgQgZua6pgvBzFk7ga0XQLIXr00h6zFq80wZzuW6xKlv+mbIasP MU+K2qB4+ZLdhV0IpabuZj6fNtdV2VtftSDhe94amPcxXB+PefdStwhsZNyqmgNgeZiD F+AWx12nZZYIm+G5wYwboGWb36/resoa3sTRlX4Lda/fVuPRJYBEmnXVWyf5RkZoBY4f 9hqCWooK3Pme/TlxG4K271aufkvsIFqi8En6AlMxvABC7HU9RePF3O0wvtuL1frVHz7H wI7Q== X-Gm-Message-State: APjAAAV1dax7Def4SLSpxKvB9o+LycuOCjUhxwiK6YMWnGcVtBZC1/Ik mJ+6NjDc1UlJmZUH2U1+QiI= X-Google-Smtp-Source: APXvYqy00urWbHnHNUW06O55qmy9w7tJsuVNYDPhDX+JrxUPKIUi0SBixUlFq/FZCSs89bo41H1hsg== X-Received: by 2002:a6b:da01:: with SMTP id x1mr20531708iob.216.1562613892543; Mon, 08 Jul 2019 12:24:52 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:52 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 11/12] NFS based on file size issue sync copy or fallback to generic copy offload Date: Mon, 8 Jul 2019 15:24:43 -0400 Message-Id: <20190708192444.12664-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia For small file sizes, it make sense to issue a synchronous copy (and save an RPC callback operation). Also, for the inter copy offload, copy len must be larger than the cost of doing a mount between the destination and source server (14RPCs are sent during 4.x mount). Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42.h | 2 +- fs/nfs/nfs42proc.c | 4 ++-- fs/nfs/nfs4file.c | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h index 02e3810cd889..c891af949886 100644 --- a/fs/nfs/nfs42.h +++ b/fs/nfs/nfs42.h @@ -16,7 +16,7 @@ #ifdef CONFIG_NFS_V4_2 int nfs42_proc_allocate(struct file *, loff_t, loff_t); ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t, - struct nl4_server *, nfs4_stateid *); + struct nl4_server *, nfs4_stateid *, bool); int nfs42_proc_deallocate(struct file *, loff_t, loff_t); loff_t nfs42_proc_llseek(struct file *, loff_t, int); int nfs42_proc_layoutstats_generic(struct nfs_server *, diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 9c7feacb0358..aab6b7b6a24a 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -357,7 +357,7 @@ static ssize_t _nfs42_proc_copy(struct file *src, ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, struct file *dst, loff_t pos_dst, size_t count, struct nl4_server *nss, - nfs4_stateid *cnr_stateid) + nfs4_stateid *cnr_stateid, bool sync) { struct nfs_server *server = NFS_SERVER(file_inode(dst)); struct nfs_lock_context *src_lock; @@ -368,7 +368,7 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, .dst_fh = NFS_FH(file_inode(dst)), .dst_pos = pos_dst, .count = count, - .sync = false, + .sync = sync, }; struct nfs42_copy_res res; struct nfs4_exception src_exception = { diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 3bfa041424bc..2671619a44ff 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -138,6 +138,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, struct nl4_server *nss = NULL; nfs4_stateid *cnrs = NULL; ssize_t ret; + bool sync = false; /* Only offload copy if superblock is the same */ if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) @@ -146,8 +147,21 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, return -EOPNOTSUPP; if (file_inode(file_in) == file_inode(file_out)) return -EOPNOTSUPP; + /* if the copy size if smaller than 2 RPC payloads, make it + * synchronous + */ + if (count <= 2 * NFS_SERVER(file_inode(file_in))->rsize) + sync = true; retry: if (!nfs42_files_from_same_server(file_in, file_out)) { + /* for inter copy, if copy size if smaller than 12 RPC + * payloads, fallback to traditional copy. There are + * 14 RPCs during an NFSv4.x mount between source/dest + * servers. + */ + if (sync || + count <= 14 * NFS_SERVER(file_inode(file_in))->rsize) + return -EOPNOTSUPP; cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res), GFP_NOFS); if (unlikely(cn_resp == NULL)) @@ -162,7 +176,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, cnrs = &cn_resp->cnr_stateid; } ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count, - nss, cnrs); + nss, cnrs, sync); out: kfree(cn_resp); if (ret == -EAGAIN) From patchwork Mon Jul 8 19:24:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 11035741 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 F0F9017EF for ; Mon, 8 Jul 2019 19:24:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D952847B for ; Mon, 8 Jul 2019 19:24:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D65C7284D4; Mon, 8 Jul 2019 19:24:54 +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 8B901285A4 for ; Mon, 8 Jul 2019 19:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403907AbfGHTYy (ORCPT ); Mon, 8 Jul 2019 15:24:54 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:42563 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403906AbfGHTYx (ORCPT ); Mon, 8 Jul 2019 15:24:53 -0400 Received: by mail-io1-f68.google.com with SMTP id u19so37824473ior.9 for ; Mon, 08 Jul 2019 12:24:53 -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=4Rti/ogp9nh8jvdF3bDZU76EXFuU1Q2Jgt4w71ZMhJw=; b=TF8hZzb7l4PN1zDK2ABvVYAImyKXB0dHxT5BdxweJzNcXRnMo/1eqq99e3Sb7Xd2xg HMAEzz1Ox8hYLA4+H6YS1t9199PeCc5RugR/KbATxWqEj0rHrbupyjXmAAG2n8jHX5Ej xr/sZ4JMpOJuOkpwB/AUAIfK8uOFu/c68ObXNAnsKCys2UwqbRfy77AziMT0lcb7VH+H ERkA2e8xKjAUxKEoEs/I86Lq9KIXzv1gucNG2nK8qxmsCj3MYUDxAqlJxqGeEYj/xaaT oFsb4srMgmwPuCguifVrd6E0p0f/O9KtMkMC68jrbkpAilZkIxSI6Ghs9CNBjOFb+bLG yxpA== 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=4Rti/ogp9nh8jvdF3bDZU76EXFuU1Q2Jgt4w71ZMhJw=; b=ivhoR8S44b9JJNcAGnBq8taqEIRBtiV7wwZDLqIqfDqJAZ16rpaI+8ZcXEVM8vhnW+ 5H/vaAFY0vJ3IXaPuYz2VRwr20pV196q4W01tOjHdorsJ2aQwOcMBr5WT+Asjk2A7D9f MQzW8TEPUZdOQGUrDH77ocrKC+cRr/eu65hyLBUqzlZF6zBDcPK6OVkA5hGm6Pp/13Ii 6vxzh+GscykQ/OUUB3jkv/Y5++/u5QSEyho1/dD9dSiNhA5pHjUYILLGTOgZsex/RyKF ahW870KC1b+kk36NTgH3QoYWIsOiq+15aTDtjN5Ir+7vfoS5o6Vwn9ewTjznV+nHfFHm Yo8w== X-Gm-Message-State: APjAAAWfuU1xmX4jejxgbJtBJV8m8KmbxOhHLPjh8gsExQ1eph0UPNKI uFfxalCaChmTG/8QuP09sQqWdXBoIhU= X-Google-Smtp-Source: APXvYqy+OxXXLqLmRLTEDt9Rp1SeGPAq9nx01p4xhgp9Fc2GOxy6pPXQGH4OKoCty3Se2LOZa3BDpg== X-Received: by 2002:a5d:9c46:: with SMTP id 6mr12841891iof.6.1562613893405; Mon, 08 Jul 2019 12:24:53 -0700 (PDT) Received: from Olgas-MBP-201.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id n17sm17026554iog.63.2019.07.08.12.24.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 08 Jul 2019 12:24:52 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 12/12] NFS: replace cross device check in copy_file_range Date: Mon, 8 Jul 2019 15:24:44 -0400 Message-Id: <20190708192444.12664-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20190708192444.12664-1-olga.kornievskaia@gmail.com> References: <20190708192444.12664-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 From: Olga Kornievskaia Add a check to disallow cross file systems copy offload, both files are expected to be of NFS4.2+ type. Reviewed-by: Jeff Layton Reviewed-by: Matthew Wilcox Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 2671619a44ff..bbcc24d2d9e0 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -141,7 +141,7 @@ static ssize_t __nfs4_copy_file_range(struct file *file_in, loff_t pos_in, bool sync = false; /* Only offload copy if superblock is the same */ - if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + if (file_in->f_op != &nfs4_file_operations) return -EXDEV; if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) return -EOPNOTSUPP;