From patchwork Tue Oct 30 20:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661513 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 63FE813BF for ; Tue, 30 Oct 2018 20:56:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 53A392AA38 for ; Tue, 30 Oct 2018 20:56:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 482352AA42; Tue, 30 Oct 2018 20:56:29 +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 B975E2AA38 for ; Tue, 30 Oct 2018 20:56:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726723AbeJaFvb (ORCPT ); Wed, 31 Oct 2018 01:51:31 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:40549 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726005AbeJaFvb (ORCPT ); Wed, 31 Oct 2018 01:51:31 -0400 Received: by mail-qt1-f195.google.com with SMTP id k12so9401463qtf.7; Tue, 30 Oct 2018 13:56:26 -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=xf4FnrHcgBJlod1T6CFfI+ZNKQfM2kBPZpTDX2oetmI=; b=PBO8fsG5ppvF19ITVtAjmqfP/q74WCFeYGtor7xr8Q0ViVIB7A8QhDz3QUstkg/lhP Z2ipS5B3z1vy18CUqnkCc+SqSy82/LtIYi23ESWrusN8BND3xR/xm99n83wgh54DxhIS xNwzAUyY+8jwxWzJX77we38hdYZ93eqTz+4AzAOmJQWJ8FlcOy3YppQPPSyXtNzu2S6G kZ+dNoxPi1cAPRaX0twRYqUatyz/5eZgSKRlmOrU5vHtpRlh9B1hJpQqzHiS1V07wwTe nYB5ySIFA6uW6w5Wp8R/ZCsgvhnvQa925EzNuPG4i2zJgUpaHfWs51se7BXuelxvWqQT UNIA== 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=xf4FnrHcgBJlod1T6CFfI+ZNKQfM2kBPZpTDX2oetmI=; b=tvuMe6QCDj4MHa6DJl/ktzf4Kb2/Rc4+q/MSdH0/OpCuV6ernp3Ubb988khOomFvUp WoegtPM4biEfbJyr5vQ3BTs3au4OKmsz6g6v6eLS4sbyBHKd2R2SJFE1Ayhi0LGB5FLp t864rsv2LKgBZ5mhvMw0uWoI+xGQMLHoDmNfxocMmGXn6HJtDmgDx587P3AUxzWJXoFw ElpK6b/DsZkCJZTNcEGFM9F1hjFYLsgZunpcGL9eiXVTTK91tTUfWHyWM5wkXaqgKnjh K+ZWFCOvfUwxg47i1iTetf9nR1J5TuRcbhK8sz0ii87DTiQ0vZIqMbyZDBxdU/fVl4US bTIA== X-Gm-Message-State: AGRZ1gJ74ej8Vuaj5QuIlPPRfitabDSnVVcbUNJLtogeQY2Lg+vasSX3 deCmMvt25RD6eSDYYTX0F2k= X-Google-Smtp-Source: AJdET5e2MoRylB5NHdI+TG8Xl8qj7D74y7kmvJtjt5s4l3Z4abb5sdUAgiUP1fNTaFvICyMckYmZoA== X-Received: by 2002:ac8:8ea:: with SMTP id y39-v6mr291841qth.3.1540932985853; Tue, 30 Oct 2018 13:56:25 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.24 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:25 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 01/11] VFS: move cross device copy_file_range() check into filesystems Date: Tue, 30 Oct 2018 16:56:03 -0400 Message-Id: <20181030205614.40754-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 This patch makes it the responsibility of individual filesystems to allow or deny cross device copies. Both NFS and CIFS have operations for cross-server copies, and later patches will implement this feature. Note that as of this patch, the copy_file_range() function might be passed superblocks from different filesystem types. -EXDEV should be returned if cross device copies aren't supported. Reviewed-by: Amir Goldstein Reviewed-by: Matthew Wilcox Reviewed-by: Steve French Reviewed-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- Documentation/filesystems/porting | 7 +++++++ fs/cifs/cifsfs.c | 3 +++ fs/nfs/nfs4file.c | 3 +++ fs/overlayfs/file.c | 3 +++ fs/read_write.c | 12 +++++++----- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 7b7b845..897e1e7 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting @@ -622,3 +622,10 @@ in your dentry operations instead. alloc_file_clone(file, flags, ops) does not affect any caller's references. On success you get a new struct file sharing the mount/dentry with the original, on failure - ERR_PTR(). +-- +[mandatory] + ->copy_file_range() may now be passed files which belong to two + different superblocks of the same file system type or which belong + to two different filesystems types all together. As before, the + destination's copy_file_range() is the function which is called. + If it cannot copy ranges from the source, it should return -EXDEV. diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7065426..ca8fc87 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1114,6 +1114,9 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, unsigned int xid = get_xid(); ssize_t rc; + if (file_inode(src_file)->i_sb != file_inode(dst_file)->i_sb) + return -EXDEV; + rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff, len, flags); free_xid(xid); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4288a6e..5a73c90 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -135,6 +135,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, { ssize_t ret; + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + return -EXDEV; + if (file_inode(file_in) == file_inode(file_out)) return -EINVAL; retry: diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index aeaefd2..0331e33 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -483,6 +483,9 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t len, unsigned int flags) { + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + return -EXDEV; + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags, OVL_COPY); } diff --git a/fs/read_write.c b/fs/read_write.c index 39b4a21..c5bed2e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1575,10 +1575,6 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, (file_out->f_flags & O_APPEND)) return -EBADF; - /* this could be relaxed once a method supports cross-fs copies */ - if (inode_in->i_sb != inode_out->i_sb) - return -EXDEV; - if (len == 0) return 0; @@ -1588,7 +1584,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * Try cloning first, this is supported by more file systems, and * more efficient if both clone and copy are supported (e.g. NFS). */ - if (file_in->f_op->clone_file_range) { + if (inode_in->i_sb == inode_out->i_sb && + file_in->f_op->clone_file_range) { ret = file_in->f_op->clone_file_range(file_in, pos_in, file_out, pos_out, len); if (ret == 0) { @@ -1604,6 +1601,11 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, goto done; } + if (inode_in->i_sb != inode_out->i_sb) { + ret = -EXDEV; + goto done; + } + ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); From patchwork Tue Oct 30 20:56:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661521 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 827CE13BF for ; Tue, 30 Oct 2018 20:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75D932AA3B for ; Tue, 30 Oct 2018 20:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69ECA2AA46; Tue, 30 Oct 2018 20:56:31 +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=unavailable 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 29CF22AA3B for ; Tue, 30 Oct 2018 20:56:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726005AbeJaFvd (ORCPT ); Wed, 31 Oct 2018 01:51:33 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:34487 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbeJaFvd (ORCPT ); Wed, 31 Oct 2018 01:51:33 -0400 Received: by mail-qt1-f196.google.com with SMTP id z2-v6so15313320qts.1; Tue, 30 Oct 2018 13:56:29 -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=nArMGW/INjteRrujdLkp69gM/ZmeUcX82tVQQvtlFnc=; b=RHckd8ROwPWhc3lU4r24zhA1uDj0gmlh5Obpm62kyhO4kFKW6Lcoy6NE1w7fAtlDQS ABnF6VRhn2uQf3ptAYdKdl7HQeum7wa9UAqKRIRoYL/8gH9SUM116UnMxbfpgSivlmna GaXQWGulUMQ+Z/lUVJ8gzhYgrmZM6tScl+UYfMQD/W7q4t05gu5RiM7KYJQ/QPrCX4Ek 2pqVcrs9huckeky1AEVnKpTd5MgXPQji5i16RsT1pdQr0e+0rOcEy5Uu7cIKdc0iHxTz y2g7kQUDYIX39NqeVfvdeg96vIO6ddfMYTSJU/ZUztLJAzO0oOYxYsuYLlm5HFzCs6ky eYcg== 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=nArMGW/INjteRrujdLkp69gM/ZmeUcX82tVQQvtlFnc=; b=QodRhYsWd2QEShAZEXJiTSb/nLs/25eoPfMCPZPVwaAAXw3oZFB9/1QC6OyrSyHLRn qu7IF5eQHRvfLUi/AxCNRyj0FZ4Yp6iRY+cyBZdY13TACRnyiSwkPhUlwwllbE4JJ9Ti TKRNIKn3tzUhtZ0AUfcdHGwHaDochRWeeAF110HUCH9Y8bbpOn+XheCNbTj+AY4OYdA6 S+OC7FPlQBL6PGilgflkDTfocHexZoPOPWHvNRpMyES/z4Sgzs/0m2EnNCi7iB9hkWO8 mZ3snJtkslBO2Kmnh+Fs9UpXaVKLr5RwBcmov4fwZEdIGXPH+PtIGnNjsYEeFb488EGI JOug== X-Gm-Message-State: AGRZ1gLHf4Uf12rA32HUXmHEAqxrZFFc56jSEB+KMMzWGPxqYIg78ADx g5aqx5UwEnVHrp35mlUAx7g= X-Google-Smtp-Source: AJdET5d+i+5we0gVFReH2wFo28seYFUStCjY2KpG7SbefgK5gtzxEF3SeTaetrLufvt5UM5WLzJ6Sg== X-Received: by 2002:a0c:bd15:: with SMTP id m21mr285050qvg.77.1540932988721; Tue, 30 Oct 2018 13:56:28 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.27 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:28 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 02/11] NFS: validity check for source offset in copy_file_range Date: Tue, 30 Oct 2018 16:56:05 -0400 Message-Id: <20181030205614.40754-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 Input source offset can not be beyond the end of the file. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 5a73c90..7838bdf 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -135,6 +135,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, { ssize_t ret; + if (pos_in >= i_size_read(file_inode(file_in))) + return -EINVAL; + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) return -EXDEV; From patchwork Tue Oct 30 20:56:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661525 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 EF6C013BF for ; Tue, 30 Oct 2018 20:56:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6642AA38 for ; Tue, 30 Oct 2018 20:56:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3A4A2AA40; Tue, 30 Oct 2018 20:56:32 +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 866642AA38 for ; Tue, 30 Oct 2018 20:56:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727948AbeJaFvf (ORCPT ); Wed, 31 Oct 2018 01:51:35 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:36225 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbeJaFve (ORCPT ); Wed, 31 Oct 2018 01:51:34 -0400 Received: by mail-qt1-f193.google.com with SMTP id u34-v6so15268944qth.3; Tue, 30 Oct 2018 13:56:30 -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=CNj2pCMxPlcH1fEKnenx/QqOVUgHVEB5Ekmf2YUbfVA=; b=CmCpHZMvqcUFlYHrILN6glreEixyEE7rsqwWQ5a8L6bO78z2rDWTBcWozw0jZ27Yvq n87OWfKMDMTK0mmJS9sN/2mZWsvnJ4AW1qTvntoQurumS/dBvClcKDgXLcgSaqPI/on/ /RXFJRC/bXb774rTKO10tg90+928AKm8z9gLQbcA43NNupH2HK67AcClsiZDSQWmBmyU Z8xvnRgBVAqZ0AuJuTkwd1hm6qSSpFpRtVmWUcCKRUag5vTG/c1VuiV01yr0AvliI3LF RSb4SGQJ3yWhDIwjSvc8k086Wdt1Cc5r+SOt+o4gzDSVzQzW68pHRF56E8THdZJxXscC JvqA== 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=CNj2pCMxPlcH1fEKnenx/QqOVUgHVEB5Ekmf2YUbfVA=; b=qCO6rKmvyL8V7wb02APQqI1ccSDVullr288MmZzmP8I7hq3O7O56CGJDwHhjT+HW3R LXN2KqXHCgguurhpOzh9wm7Gu1tsXNA59zKOLZOR691AZLbEDVk4D0rIHXmhhawWX5AR +x/ljBSpzKHe74Gh/AaWcgCl9KOw/WpbZFBOm2oAhgeK5ie1Y4yvbOr2ZYtghPk3AC8L Pz9YaqI5sDZWA/wRB0tN6gi9wG2vUCxPtfEHf/O40ea4r7SjHUECjt/rA2SLNIAxfXy2 f+ctzbF/k0nRuw1vm7SMKGjRLl9t61FpZpChyXe9ZyocsOjzzFm/P4tFFTGpn7hY4XjD i4DQ== X-Gm-Message-State: AGRZ1gLFWXwIkpAHsRiRuF5Iuqk7pM1uxNSKrGvQiQuVc6vX1xJkZzaV dxf5ZETGjf3tuasxOeBYFKg= X-Google-Smtp-Source: AJdET5ed6J8HiEDUtwbkDInscw7rrrNlKv1jDOXSjWxHlmqH4GWRSo+0RYbBCmf1nBOrrwOdAfVgmg== X-Received: by 2002:ac8:2249:: with SMTP id p9-v6mr311107qtp.200.1540932990060; Tue, 30 Oct 2018 13:56:30 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:29 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 03/11] NFS NFSD: defining nl4_servers structure needed by both Date: Tue, 30 Oct 2018 16:56:06 -0400 Message-Id: <20181030205614.40754-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 1b06f0b..4803507 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, @@ -672,4 +673,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 Tue Oct 30 20:56:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661583 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 C3F131734 for ; Tue, 30 Oct 2018 20:56:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F322879C for ; Tue, 30 Oct 2018 20:56:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7E602AA3B; Tue, 30 Oct 2018 20:56:56 +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=unavailable 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 AFEAE2879C for ; Tue, 30 Oct 2018 20:56:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727954AbeJaFvg (ORCPT ); Wed, 31 Oct 2018 01:51:36 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:34496 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726420AbeJaFvg (ORCPT ); Wed, 31 Oct 2018 01:51:36 -0400 Received: by mail-qt1-f196.google.com with SMTP id z2-v6so15313495qts.1; Tue, 30 Oct 2018 13:56:31 -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=sxpwy6K01WTZfX4+OAfEXIBBPNNAjwngI4oqBhF7nFk=; b=LK08gVV+dEcg3Oj3OMrd27Ct4wdlXwne76bP2KQjK0tkcTz5C1ZLlC4UglpeiIY1EV dJFEN7XuLl9ygBsYVq7woJxBhSSd+svSn9Z5podKqDBdYYvvtJlVPeHyI9rQdGtMhn4y LcRiwma6i5DkcicgiAWVcm1FSaGCgyB16BsBdwN3KhtYaqxaoiMCn3KMuhy6Ge1LlO5w hiLo9DwUi7HVGjLfPvHqDrm9rxKv0+BfIHXicmAKy6BKD/e/2y9T6bV0SUlhpt4PAAPT g70OngEzZzZH0V4NUthjGy6nl//UbjAY+U6k5+tvM9LbwrSPRZSvBATjMyri+lHloTe7 qvkQ== 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=sxpwy6K01WTZfX4+OAfEXIBBPNNAjwngI4oqBhF7nFk=; b=C4dN3rcl6pLd+SOcDMc15nB93effrWzwXAbYas3iQRej/vZeq05CBKHgw5qGqmgTrR sgm3T5EpVHlHz8mK3mOkFzdyi4UWixG4qyhHSbuLryMrQSmuZuw/gDmMT7Rkqths1CH/ fC0tG0hKJVY7VYomzvjvkdMlYmaPbV439nwtYqVq8hK7EmC6g0l3bUXVTB/F+3WD62KH g+T900eFe5lLjNmNU6Hhg/IyyBZrJRJ9xQvsYmWFAFEAjwf/jF1KWw2Eo91qByQ4EUAQ 7KjrBfblaJe7OjoExmVUxpjDq2khOQHhXBcSlq6doW3A11nxvXMyyDY9IDvII2DgPzkP ZzSg== X-Gm-Message-State: AGRZ1gJLXIhBUA8f0cM2SXsl7NxbaWKEos3HfrAssail2xOMuidjeS+t pa/6Zq++MNNJIc0G2QIUNtA= X-Google-Smtp-Source: AJdET5fFIuUKhGiyRS5s+kNAz67mB1iwwscwgdDm7SH61/0z8DBOBnN6Qz3+WxJJjCTHQRbMrzBv2Q== X-Received: by 2002:ac8:1909:: with SMTP id t9mr257439qtj.327.1540932991347; Tue, 30 Oct 2018 13:56:31 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.30 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:30 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 04/11] NFS: add COPY_NOTIFY operation Date: Tue, 30 Oct 2018 16:56:07 -0400 Message-Id: <20181030205614.40754-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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. Reviewed-by: Jeff Layton Signed-off-by: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42.h | 12 +++ fs/nfs/nfs42proc.c | 91 +++++++++++++++++++++++ fs/nfs/nfs42xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4_fs.h | 2 + fs/nfs/nfs4client.c | 2 +- fs/nfs/nfs4file.c | 14 ++++ 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, 321 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h index 19ec38f8..bbe49a3 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); @@ -20,5 +21,16 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *, struct nfs42_layoutstat_data *); int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t); +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 ac5b784..b1c57a4 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) { @@ -461,6 +482,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 69f72ed..e6e7cbf 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) @@ -84,6 +94,12 @@ #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_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_putfh_maxsz + \ encode_deallocate_maxsz + \ @@ -137,6 +153,25 @@ 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) @@ -162,6 +197,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) @@ -298,6 +342,25 @@ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req, } /* + * 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 */ static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req, @@ -416,6 +479,58 @@ static int decode_write_response(struct xdr_stream *xdr, return -EIO; } +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; @@ -458,6 +573,46 @@ 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)) + goto out_overflow; + 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)) + goto out_overflow; + + /* number of source addresses */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + goto out_overflow; + + 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)) + goto out_overflow; + return 0; + +out_overflow: + print_overflow_msg(__func__, xdr); + return -EIO; +} + static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_DEALLOCATE); @@ -585,6 +740,32 @@ static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp, } /* + * 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 */ static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp, diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 8d59c96..7d17b31 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -460,6 +460,8 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, struct nfs_client **, struct rpc_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 8f53455..ac00eb8 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -625,7 +625,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 7838bdf..beda4b3 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -133,6 +133,7 @@ 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; if (pos_in >= i_size_read(file_inode(file_in))) @@ -144,7 +145,20 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, if (file_inode(file_in) == file_inode(file_out)) return -EINVAL; retry: + 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) + goto out; + } + ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); +out: + kfree(cn_resp); if (ret == -EAGAIN) goto retry; return ret; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index db84b4a..fec6e6b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9692,6 +9692,7 @@ static bool nfs4_match_stateid(const nfs4_stateid *s1, | 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 b7bde12..2163900 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7790,6 +7790,7 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, 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), }; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 4803507..9e49a6c 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, }; diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 0fc0b91..e5d89ff 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -261,5 +261,6 @@ struct nfs_server { #define NFS_CAP_CLONE (1U << 23) #define NFS_CAP_COPY (1U << 24) #define NFS_CAP_OFFLOAD_CANCEL (1U << 25) +#define NFS_CAP_COPY_NOTIFY (1U << 26) #endif diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 0e01625..dfc59bc 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1428,6 +1428,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 Tue Oct 30 20:56:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661577 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 3300113BF for ; Tue, 30 Oct 2018 20:56:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 255872879C for ; Tue, 30 Oct 2018 20:56:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195F02AA38; Tue, 30 Oct 2018 20:56: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=unavailable 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 ECDCC2AA3B for ; Tue, 30 Oct 2018 20:56:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727978AbeJaFvi (ORCPT ); Wed, 31 Oct 2018 01:51:38 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:42380 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727953AbeJaFvh (ORCPT ); Wed, 31 Oct 2018 01:51:37 -0400 Received: by mail-qk1-f195.google.com with SMTP id u68so4244739qkg.9; Tue, 30 Oct 2018 13:56:33 -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=L/lyESnrT7eI5UkekwLVWgapYd9jVCBDfyygHzXaoSk=; b=bHfCf83vEqDe1kJa8LqKvoyMt77m//NSuIdFss3B/hVV2F/aJsyizET8JOhhHDZzdr wE8qQExtYa3PmmGjDzGF576ffnm/se+/8Q65WNiox7hFA3nmCizisq+lbquuy3k7RWPC usEeA8rQHt+AES8aALGn5+ABeF37HYVxM4pLLCDvDHhf+NAmp3ERNirAcd7eO+xkEGWA +m7ZndrFRy1YcHP13QWJhEUwxmJU0PO4CngICx3tnFtpAdZiOuju+NScos4utD86FEsY c3kEjUJJ3mfjht2Ui2fyCtb4DfL8BB4/x2lHoIKuV+p3TaIF0R7studF4m5kN+4cRpxq 3VIw== 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=L/lyESnrT7eI5UkekwLVWgapYd9jVCBDfyygHzXaoSk=; b=pKV6vDD+gjh5EJsb/SzPkanVU5PS4o8FAEOMM3i0aAe75igvwW/dgoWl8chSxZwLqa rxLdIWUMLoLDnj6YCpVLjTTOGMuwWPW2IiMKgNZ7T26EwEl0ae3gTcXAo0Lpj6L9Zuxw X5HDF4DGCa7jn4z0N5vDDg9nqSJ5H9N66BTFzWuC0AJw1WFL5UOh9Q0HdxhjAMTE30Dl uyJ0mnelz3vQjhDxvhXtYuydAxhXcdwfv0BoV4E8x9iM8UuG/lUlbyScpz6w1XNDRzkh s5TMCyEMCCqZZZ0TNZty5PIKKgWkNs+u+emW8JgZAtK6SBH0M25CLuE7+tn/fJfm24h2 tN1g== X-Gm-Message-State: AGRZ1gL9MGpA30U2/W4+I/ebtAnA1qmLGZj/PfJBzNbY9BQxjRcIwb0s iMQzkL9uTSShCD5lkY8HMAU= X-Google-Smtp-Source: AJdET5cj7eG8xATQov0LQJTFULOqNXGRs7LhBuLh1bAH1fVzWRW11OvCFV+fb7Q6QNS3/g6LHClnfQ== X-Received: by 2002:a37:4f92:: with SMTP id d140-v6mr263258qkb.17.1540932992822; Tue, 30 Oct 2018 13:56:32 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.31 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:32 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 05/11] NFS: add ca_source_server<> to COPY Date: Tue, 30 Oct 2018 16:56:08 -0400 Message-Id: <20181030205614.40754-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 bbe49a3..28dcee5 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 b1c57a4..bb9e799 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -242,7 +242,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], @@ -256,11 +258,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) @@ -324,8 +330,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; @@ -370,7 +377,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 e6e7cbf..c96c3f8 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 */ + \ @@ -186,7 +189,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 beda4b3..e5c1a68 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; if (pos_in >= i_size_read(file_inode(file_in))) @@ -154,9 +156,12 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, ret = nfs42_proc_copy_notify(file_in, file_out, cn_resp); if (ret) 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); if (ret == -EAGAIN) diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index dfc59bc..3a40b17 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1400,6 +1400,7 @@ struct nfs42_copy_args { u64 count; bool sync; + struct nl4_server *cp_src; }; struct nfs42_write_res { From patchwork Tue Oct 30 20:56:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661571 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 B834813BF for ; Tue, 30 Oct 2018 20:56:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAAB22AA3B for ; Tue, 30 Oct 2018 20:56:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9EA2D2AA40; Tue, 30 Oct 2018 20:56: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=unavailable 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 4D9642AA47 for ; Tue, 30 Oct 2018 20:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728018AbeJaFvk (ORCPT ); Wed, 31 Oct 2018 01:51:40 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:42027 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727984AbeJaFvj (ORCPT ); Wed, 31 Oct 2018 01:51:39 -0400 Received: by mail-qt1-f196.google.com with SMTP id z20-v6so15256981qti.9; Tue, 30 Oct 2018 13:56:35 -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=DqnHnZrMSvA0or48b6pnWzyYDz4iWYc8+TMTuA2+K94=; b=pitGpPthvATx7Y+Z/PDpsfEse4t5ETFcqXXMzejc/21sepODoe9FwVxELC45RV9uzX Dzuke16lPijmo9ASIjOU9KTe8YoFiwt358Rom5IOmj9tw6F4tR1xnkoqbzco/6Y4rc7B EEPxSe10Gqc9e9gxnCxMEbvrKia+U7d4i3r59jCZbaqJeFYTpPNqa1WHtN/QprMTuMyO N3AInCTFmZM55nE04Fb0DHq5JfEE/YEJCVJb1eosckbRBylvaBE2xxCkMvYGEvgiGuX2 fP1+d0JE35js7ORLDLApWXeFIa4o5XVhRlUhrSNapKPjUJf9qxJWj/w05F+WhAZI7Ti9 cGRA== 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=DqnHnZrMSvA0or48b6pnWzyYDz4iWYc8+TMTuA2+K94=; b=Z62SOWEGrHvRY8L12d8qdmnhNz5K1+fM/jrM1OxE5//rggINh5Mc2Ax44YnTvsudTa GNY9TN3XnbkzLjz3I4bTKYoXnj/KOYUL5qSaXe0uK85/dk+m6pERbwFyBZ0oCRqe4O8m +gf5bhMrWLjkhiJMNMQCkF63uKZbYWQ0q86XQrAq4pvVBoc80aBQdZMnKyfDBvs5eeGu 06kvWlyOxNx9NVcVucD+M2yhJ8eqnX654VYnjhAr05CCxbZNmWFe4tfcdbmN1J3WWs2V dFY1DfCGJyL3+31OMGHSOWfvL8HxoySkzddw4bj6eRUvxsTgJEOg2LiblMQ0CxCgt+3Y w1KQ== X-Gm-Message-State: AGRZ1gJfifbVKITFnA0ZeO00r67dCKrU6gRNK/Nk2QkAe6KNnc30o3kK H/bZg3MF8yv4+sumGbPNPvQ= X-Google-Smtp-Source: AJdET5cw4bUgLaX5mP9GhRZljgm4D7CH97WDY78dRn0Hjmie9aSSzA+HAvt1ILETBBv27lIhM9cSIQ== X-Received: by 2002:aed:35c5:: with SMTP id d5mr303046qte.212.1540932994677; Tue, 30 Oct 2018 13:56:34 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.32 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 06/11] NFS: also send OFFLOAD_CANCEL to source server Date: Tue, 30 Oct 2018 16:56:09 -0400 Message-Id: <20181030205614.40754-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index bb9e799..98fe00b 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -205,12 +205,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, From patchwork Tue Oct 30 20:56:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661563 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 2134F1734 for ; Tue, 30 Oct 2018 20:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F28F2AA38 for ; Tue, 30 Oct 2018 20:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0338A2AA46; Tue, 30 Oct 2018 20:56:48 +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 6A1252AA38 for ; Tue, 30 Oct 2018 20:56:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbeJaFvn (ORCPT ); Wed, 31 Oct 2018 01:51:43 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:35040 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727949AbeJaFvl (ORCPT ); Wed, 31 Oct 2018 01:51:41 -0400 Received: by mail-qt1-f194.google.com with SMTP id a10-v6so15269529qtp.2; Tue, 30 Oct 2018 13:56:36 -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=qWc4e/0MmfBIIgJWWnXm9U9/kkhvubDK4oN4lTXjqm4=; b=DmznW5TiNpzq4S9YlLeNFHdoB4KfxVYPpkY+GyuVuxeS/xompbL53UEAPV5yKVea+i lmkkvny0LvrR+tN6UIDhfaO/HpM0/TxibG8B0fV6Yblg4NuHfHcQXv98cM/+AcIBHnSa fLdE497JXgyT3tcsBl1yPuYyS/DUHQWo++2cFEEJB+BLVKiMNUbZOT9Vk20MODaRqsv3 dxd/zx15iEF4J8pBl/N8WWVqcw4nLytDfVVTes2u7W8fqmP63R7W7I9ctc1QaR9lIi6+ t/+KDumdfLFDQaXbBDS+m15oaHUFH6VXIbZQLpiWsZebaW7g/aGhuUEo5CWd6cabOFK2 6ONw== 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=qWc4e/0MmfBIIgJWWnXm9U9/kkhvubDK4oN4lTXjqm4=; b=tdEkcpaPg/Z+IdQ0jR4en51FxnMc9e9n5R8ncKMIvTrJMTjbjUn3hbXK/VclTgM0Zt rRftr2rbqW7LG8YAs3BR6K/HhemQ+O7dx8jc2URFcAMgNh7Vtxzum/t07cBfJasuc23F dPnBPTQ6UPCtpZXjmpThcYTnLTaoH3AsKAeB1itebB9kbKstfW0BAP4BZK39gy3vRKov PRLdHCJPDUU78D58mShT0Y5/ouhVyaak99HpFdQf07ehWUEqIdgJOPW6Bj0EaMvkz2Y/ ln6IymuJGpL/bR5O/1Qm+06N+Br9sXbsN++MvGFa3uwttddGbAIWnHoRGpWB8jriJ0mv 9bow== X-Gm-Message-State: AGRZ1gIJEMV9k3Jm+PcChDnA4izFmaIgTiYjmXEnT1EXt/MThLT9De99 gP2rv+qAF0ZqJo/Y8nNZpKg= X-Google-Smtp-Source: AJdET5cErtK8rt93BnO1Tvufx+KAxdNN3T6KX5fM1ru2KP+4WNIc1l1zlmTLi95uNFfnXlSQupQhlQ== X-Received: by 2002:ac8:764e:: with SMTP id i14-v6mr269963qtr.373.1540932996156; Tue, 30 Oct 2018 13:56:36 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:35 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 07/11] NFS: inter ssc open Date: Tue, 30 Oct 2018 16:56:10 -0400 Message-Id: <20181030205614.40754-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 7d17b31..9c566a4 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -307,6 +307,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 e5c1a68..0b1dcf9 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" @@ -267,6 +268,99 @@ static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, out: return ret; } + +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 fec6e6b..e5178b2f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -91,7 +91,6 @@ 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, struct rpc_cred *cred, struct nfs_fattr *fattr, struct iattr *sattr, @@ -1653,7 +1652,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) @@ -3936,7 +3935,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 Tue Oct 30 20:56:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661543 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 E86C81734 for ; Tue, 30 Oct 2018 20:56:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA39F2AA38 for ; Tue, 30 Oct 2018 20:56:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE4352AA40; Tue, 30 Oct 2018 20:56:41 +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=unavailable 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 791F22AA3B for ; Tue, 30 Oct 2018 20:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728043AbeJaFvn (ORCPT ); Wed, 31 Oct 2018 01:51:43 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:38037 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbeJaFvm (ORCPT ); Wed, 31 Oct 2018 01:51:42 -0400 Received: by mail-qk1-f194.google.com with SMTP id p3-v6so8212892qkb.5; Tue, 30 Oct 2018 13:56:38 -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=4PksShieLrh4Cf0smwQQ0hWXC8t13fGxowZ1fcGZ/Dw=; b=NUZ/hVL0rdhHoPrCqxoePsrXZ47FbpMwrTIO9a6khMsFtE9Y07hcbr3IaHJqeUppOh M6HA6e4l8ZLw27LhmCwSzE5mhjh7XJQCVStxATiWiONhxHbx/pDZguoxtQx9RVqhgyMh ppear2qDXeemm9Nz3GYyHCJoKfmPp+GDs/Jl50OLsKGPCuHlh9b7SPg/AV1S4KeL2nrQ 6iAgeyPyfVeb1yLZ1oLcKsSJ5wsPbh5hO5k+hF/++Rj6KTKCQntgaPH2BP9cy0XO7C2U KHG6EaYJ0bzVn0aHtB+QD4BWO2/5Yb7egZT5vZtNMqabZ0E4vcf5UmQMnKDCcrKrWTLu wvRg== 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=4PksShieLrh4Cf0smwQQ0hWXC8t13fGxowZ1fcGZ/Dw=; b=HlQVTlzQArbSoGDZJS6j1mHz/gN1M2IoHjQm1BNrqWYuO5hAoNsqxIvNB/DDr3G9dZ 6PExqfNx3K0G9CKaeyBsEY3ZDjqGIcum64A2d855LNh0Obc67DFfet5ldMyLs5DFg4pl M2Cza9wGl7P2bROjADs929ZFcWgBhCNRuEJl/7ToTYy/H3YoD9qCI/lx9O6YdNDQStDw eyl98a3dFuspFYoXozRC56vBkaGJMN1g3JSkZljsZ0BkIlCMDQrwaGpr4AXoyUapf5+C HjePwnahDdNtJ+ZIHcfaQkXzNwgAnF+gpVeSdEaKtR0AhYAz171RaZ92MmSSIMzoHw1a Cy4w== X-Gm-Message-State: AGRZ1gLQ66ii+ACTvVk9Cd0XTM7h12Udq5P3mxTut0Mdp7Q7B4cn1V7E SpytHKnBVAEtOeQfgtqnr3o= X-Google-Smtp-Source: AJdET5dzh3xpbNKXR2zXHiqQJu1S4R+dOUzTBPLEvoIr2gLYsUCgDDo868BLmKwGtj5RMrOEADV7fQ== X-Received: by 2002:ae9:ee02:: with SMTP id i2-v6mr313391qkg.0.1540932997892; Tue, 30 Oct 2018 13:56:37 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.36 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:36 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 08/11] NFS: skip recovery of copy open on dest server Date: Tue, 30 Oct 2018 16:56:11 -0400 Message-Id: <20181030205614.40754-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 9c566a4..482754d 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -165,6 +165,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 0b1dcf9..989f174 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -333,6 +333,7 @@ struct file * 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 62ae0fd..b0b82c6 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1606,6 +1606,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) @@ -1625,6 +1628,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); @@ -1671,6 +1681,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 Tue Oct 30 20:56:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661551 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 F1D913E9D for ; Tue, 30 Oct 2018 20:56:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E41692AA38 for ; Tue, 30 Oct 2018 20:56:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D51B02AA3B; Tue, 30 Oct 2018 20:56:43 +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=unavailable 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 8F51D2AA42 for ; Tue, 30 Oct 2018 20:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728055AbeJaFvp (ORCPT ); Wed, 31 Oct 2018 01:51:45 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38906 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbeJaFvo (ORCPT ); Wed, 31 Oct 2018 01:51:44 -0400 Received: by mail-qt1-f193.google.com with SMTP id v1-v6so11048474qtq.5; Tue, 30 Oct 2018 13:56:40 -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=7UYm6KwHepkUcFRejYDPg8EOERI1MmALOURzx0oOqU8=; b=EYIPGGYUB15cBohrLbQ1H7xRmewHyk12yScSrEhUOIEB8Bdo+5Pt0fSdXUuzIG/6mK yzNkLHK0/1uWcemMFOaYiKvajSvk9IqbbgaqIF9/2xJR3kNZ0ZRmGtWCCG088vq8QBIR eEddIB861PuM6RXm+YJGzv7Gxaol7VNg71077QOUK6KTl/msgFJKjJCimXq/CFHyJ9/W n+/v1R63wBV6Lnk8xR7ViM4kqFC8J49W7vaOm90QkHbbTHuUEMCyj1EQPrLOkN9XeYLP DuMsA2p9O7UdafxPCDNa2SJTq/k+cdTxRLZ9oIYBpFH6CzUbHdWNlGcv8ZujG2GvqGIB aDRw== 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=7UYm6KwHepkUcFRejYDPg8EOERI1MmALOURzx0oOqU8=; b=uZzrrF9ep4rqhZfHCL0ac1+733bk1pCPsKIE5Uka0d78RR31ULeT7TilnPogjyMHMI XO8/4JuYwK1cKuWRGE/hXir0Y7lcUtYv+7P6ybC6J2kKLoOY4812G0lgZ+6vcWGuzSxj Ty9E5g3QNLQl1w4nQ259hivX5LSyuzZy88EDUvrRP59g9lt3iK7zLx/XVZBVKkgx3YHo UUBTt+Rt1QF8YgFooruJljEPNYRsoC0JEbC5Vb0Kw8RBJ+OwWwJHfUy0bVCaNRv83SBh odVJdW3X0gFNbBKWs52r8/lWiNU0GAX0tY/DtxTGiYedpuCCvbaMIUO2V9rNJACF4YgP Xheg== X-Gm-Message-State: AGRZ1gLZ9alUP2v35IUKWuVbqap1GT/kIuav/JKMjcPa2DOpbB8AUzNe YoaVeX2Dae662eumeYg44Mw= X-Google-Smtp-Source: AJdET5cfONjqbSf9Ih1IMfHw0q6IIX43hA16mJ8T1YoolkobyMYHt0c8r44y1h9Xpf07qoxukXbwtQ== X-Received: by 2002:ac8:2249:: with SMTP id p9-v6mr311543qtp.200.1540933000179; Tue, 30 Oct 2018 13:56:40 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.37 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:38 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 09/11] NFS: for "inter" copy treat ESTALE as ENOTSUPP Date: Tue, 30 Oct 2018 16:56:12 -0400 Message-Id: <20181030205614.40754-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 98fe00b..00809b3 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -395,6 +395,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 Tue Oct 30 20:56:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661557 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 49D061734 for ; Tue, 30 Oct 2018 20:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BED12AA38 for ; Tue, 30 Oct 2018 20:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30AE72AA40; Tue, 30 Oct 2018 20:56:46 +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=unavailable 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 E37DF2AA38 for ; Tue, 30 Oct 2018 20:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728062AbeJaFvr (ORCPT ); Wed, 31 Oct 2018 01:51:47 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38909 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728030AbeJaFvq (ORCPT ); Wed, 31 Oct 2018 01:51:46 -0400 Received: by mail-qt1-f193.google.com with SMTP id v1-v6so11048548qtq.5; Tue, 30 Oct 2018 13:56:42 -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=fwlJnXfUGTRII/SW0YspOWGhfPFdbZ3Rgyeu7Z/VErM=; b=sg813fnQDp2bgDq3gMAKZcrx2LKZK9Cp3CWMsNvsmdm1TnF43cMdz9UbACpFJhlMUR bppLKiHFvf1KIEzGfQ0/kSYtTyrRnsWm70eyLDB7oFQAtYbkLhBwHf1bMGgOFLRnr/va 9rsDvzk8w3fcC0a7PTFpqyRijVDbh82idvwRstoYcMLtO7sR0m3ZQnp3zOLIe4KOXqLq t9RNpGamPexJbNYO4cKRfT93se+iC9yjNqTYHDyNrHx9aRuQDOJvLVXAV9cO/+8auaXK m8PFrcs5jYucc40jdu0SZD2nasvLkLhgxYIrGe5D+lCZ2Cr/r3v21vzio200dz4SW/sT SK6Q== 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=fwlJnXfUGTRII/SW0YspOWGhfPFdbZ3Rgyeu7Z/VErM=; b=so+iXWmdeKuiDqmvXu9DjZFsYfZ4JsLmf9seLHHrZafz4tAflhi8SyKQmC2zbmhw6E 7g2SIwp7cBvouGvy/wSG3Feo3BmvXZF53J+YxLpUZGLd9PXh/WFmwH2AaPYNyDkgFhHX wbypQrIVpMdIb35QoUa7wiKFuxCcJu5wkvMSX3xbedHddMcPJ+WY5EQd/ufu4lpTde+S eyNcvnXXGfHaZns7122M4EJp7GpVVtde4fr+UJ5wAZAtGfWsZGBXIankpAVUdk9rPxUw /XT9SPq53F1ddBJhChKnatF+aiiCCBbw6VZNoVudgcTSguWlbiwHXfQEUNNUPRabFe70 pvLQ== X-Gm-Message-State: AGRZ1gLS6M6CXbO956lgPyCpvBPiA8woeAREXbiiMngAfZZyAe1j9mJn qGNJNY7ksM7Sa5c4xGec8P8= X-Google-Smtp-Source: AJdET5cmgPKIBg2zJnUbOQ9AbMFO6Z2Mxn7nwwo7XX+lbgPZIXtCKSvc3MC+6wSvXiC/9QXMGJHG/A== X-Received: by 2002:aed:39a9:: with SMTP id m38-v6mr311222qte.222.1540933001598; Tue, 30 Oct 2018 13:56:41 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.40 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:40 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 10/11] NFS: COPY handle ERR_OFFLOAD_DENIED Date: Tue, 30 Oct 2018 16:56:13 -0400 Message-Id: <20181030205614.40754-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 00809b3..c7c2ffa 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -395,7 +395,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 Tue Oct 30 20:56:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10661565 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 B9A4113BF for ; Tue, 30 Oct 2018 20:56:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8D882AA40 for ; Tue, 30 Oct 2018 20:56:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98A982AA42; Tue, 30 Oct 2018 20:56:48 +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=unavailable 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 AB0272AA3B for ; Tue, 30 Oct 2018 20:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728030AbeJaFvt (ORCPT ); Wed, 31 Oct 2018 01:51:49 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]:36704 "EHLO mail-qt1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728071AbeJaFvs (ORCPT ); Wed, 31 Oct 2018 01:51:48 -0400 Received: by mail-qt1-f182.google.com with SMTP id u34-v6so15269715qth.3; Tue, 30 Oct 2018 13:56: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=vBxFiCMdm9zwB+fNOLFFTK+4s/3BLVSMs2/+B1oAwOg=; b=cgkKa0Q3i+KlnjGiuVy79GFf4RjqUdspiwev4l0bkgi6ZpXbPJWsA1DJcDZzqI82vG 8SvOqklJqWfblfQUq5DhGJAnyuS+VOCvR8oiohe62DGrbVivuQBgnDaAM2eSwdiSOfnC liKDGrhI/MCnS8CqPvz34BwYapnVM2+F4UIPImBJFTFjBNWrudpHH+lGuEb0pYFh+5oP WNyn8DaiquGNJKLj/f/E25Z9BaPloZ1WsqnDNxahzQI/exZiz2QXjHlqa+46aeUemRfN JH/z9Os1wUttFNsdjrPnKVxxjxozXrSl6uRowQWoAcFtuItz6lnlEZR8pqXF2IWJJbkD cvRQ== 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=vBxFiCMdm9zwB+fNOLFFTK+4s/3BLVSMs2/+B1oAwOg=; b=UsTPQczXENjRoKnc4hi1KevTA4MVX+LV3tFmiOoX1Mlz08GtCoRTozIK4/O/M5y7H2 6nyZAxf+Ogprkn7R7AuefuObLHhkI8UeaOAcBSk2xL6ni2/4cQz82ulNlGY4tlYPgJRx YWKm0x2WDzvX1j3WFGDR0Hd2cWJ1HOHxrNs0PS5bXVwpJ+c9YhOfFJ9z0XR+WTspKCjQ l8EcCHomgA95tD4fT7xRanCML8uw3W+PQ+nPMnjfffUoyvyuMsOS45Jh6EH3qL7FySDm iH+0rwsfFjzoQy0Ros14b/yR1LTJNIJAMP5BehICwM6B4mHIAFQE0655ILMpfotBOvi0 08EQ== X-Gm-Message-State: AGRZ1gKVkKDHDhhsSBeJFVjXDMdKQJVjADmq7/Pz7bktQu5mP2pEGl6d 4OO+om/95MJmWNI/YS2RdDIVCTF7 X-Google-Smtp-Source: AJdET5fUpkjHaVVPXUjqzIjTXdnOE/xbHvR4j7xM0d6R8B1xsYh/OgWGwBdkC3ygiedanWCDR4yv/w== X-Received: by 2002:a0c:ec92:: with SMTP id u18mr298903qvo.168.1540933003937; Tue, 30 Oct 2018 13:56:43 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id i11-v6sm23478157qtc.96.2018.10.30.13.56.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 30 Oct 2018 13:56:43 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-man@vger.kernel.org Subject: [PATCH v7 11/11] NFS: replace cross device check in copy_file_range Date: Tue, 30 Oct 2018 16:56:14 -0400 Message-Id: <20181030205614.40754-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181030205614.40754-1-olga.kornievskaia@gmail.com> References: <20181030205614.40754-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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 989f174..69e2705 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -142,7 +142,10 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, if (pos_in >= i_size_read(file_inode(file_in))) return -EINVAL; - 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(file_inode(file_in)))->nfs_client->cl_minorversion < 2) return -EXDEV; if (file_inode(file_in) == file_inode(file_out))