From patchwork Wed Oct 24 19:58:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654929 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 A4A8B13A9 for ; Wed, 24 Oct 2018 19:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 938092AFD5 for ; Wed, 24 Oct 2018 19:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 87C592AFE6; Wed, 24 Oct 2018 19:58: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 B9D632AFE3 for ; Wed, 24 Oct 2018 19:58:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727230AbeJYE2J (ORCPT ); Thu, 25 Oct 2018 00:28:09 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:37674 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2I (ORCPT ); Thu, 25 Oct 2018 00:28:08 -0400 Received: by mail-qt1-f196.google.com with SMTP id d14-v6so7108031qto.4; Wed, 24 Oct 2018 12:58: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=dlFL4npXT0g1RppdgdYI/CystWwtpVfsVcBHdAcJOKA=; b=UfClAvfD/Z/UQ27zoXkMd0a+JVVxVwpSCS3DYNx99Z3z31ieNt38rx/PFl6IO0VD5z 10sXnoM7l38C13ZIBcypmMoFFDozSwVub7y2rvCBYxs98pVWbf7uyA3PXTkevhVTtrwJ efhXiCLBFrnw6R8sdmQjA1MXkpLu37SWMQPYgVGjCV+4jNa+kM9Hi+14O+l3mp2TJGQR oekdDBfJhAdYxeaPHxnxNHgV7XC081FA0cqnJ8iGrBBezzQeivVcCruYCNCptYelYGnS lmpUbDs0j4CvveDnhvaP6oil7uuoMsj1AdB/umQ/JM/Ywez1KVSsaiovcHwVIJK5EeIW 5reQ== 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=dlFL4npXT0g1RppdgdYI/CystWwtpVfsVcBHdAcJOKA=; b=nHRUbn/nDEQCwh/n8iY/lYIIkEiyrtdtw+gmROxf9v8ThmYad3B4Ii34Yl3iRBIfTR BRVXKYdWGO104z8/qQD8HpoOZgoMLe7Y9SaEH69NyGi/vDuGUwcBxkgo3LK3yRRAwiJ2 MAOdhkDyaRehRg+cuyjkdQhHaYr369K7A8pMiz54E5UkZyOUMb9lKH2OMfe18J4+3IJc hMF2Joc8wmj8EquZdCGHvTWH4np+DDE2g26OhZZkuRDS49nzlCZgb//wS1GJBLfBqhFj 0bglobUdjgV4v8ULZKCb3N8Ca4Mn4o5pfuz7fn7Xx8L8JkiY+B75imUGOt2+plPfGL38 lQaA== X-Gm-Message-State: AGRZ1gK22QcXjdqD9/oCcnUelySKqc+R8phdY8IcIq4aR9AKoSU80NL8 HY4TTvTJZNVpnRsCp9nvvUg= X-Google-Smtp-Source: AJdET5dnc7L3vszQz8CSbJWRBJw6F09QZz3ZTHPuXHl09N/H8drGK6gbNvwS88jbf53sIhanhZLp8A== X-Received: by 2002:a0c:b211:: with SMTP id x17mr3758304qvd.153.1540411121739; Wed, 24 Oct 2018 12:58: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 d124-v6sm3872380qkf.85.2018.10.24.12.58.40 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:41 -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 v2 01/13] VFS permit cross device vfs_copy_file_range Date: Wed, 24 Oct 2018 15:58:24 -0400 Message-Id: <20181024195837.35532-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia This patch removes the check for source and destination files to come from the same superblock. This feature was of interest to NFS as well as CIFS communities. Specifically, this feature is needed to allow for NFSv4.2 copy offload to be done between different NFSv4.2 servers. SMBv3 copy offload between different servers would be able to use this as well. Removal of the check implies that passed in source and destination files can come from different superblocks of the same file system type or different. It is upto each individual copy_file_range() file system implementation to decide what type of copy it is capable of doing and return -EXDEV in cases support is lacking. There are 3 known implementator of copy_file_range() f_op: NFS, CIFS, OverlayFS. NFS and CIFS are interested to support cross-device copy offload but do not support cross file system types copy offload. Following patches will add appropriate checks in each of the drivers. If the copy_file_range() errors with EXDEV, the code would fallback on doing do_splice_direct() copying which in itself is beneficial. Adding wording to the vfs.txt and porting documentation about the new support for cross-device copy offload. Signed-off-by: Olga Kornievskaia --- Documentation/filesystems/porting | 7 +++++++ Documentation/filesystems/vfs.txt | 6 +++++- fs/read_write.c | 9 +++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 7b7b845..ebb4954 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/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index a6c6a8a..34c0e8c 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -1,5 +1,6 @@ Overview of the Linux Virtual File System +- [fs] nfs: Don't let readdirplus revalidate an inode that was marked as stale (Benjamin Coddington) [1429514 1416532] Original author: Richard Gooch @@ -958,7 +959,10 @@ otherwise noted. fallocate: called by the VFS to preallocate blocks or punch a hole. - copy_file_range: called by the copy_file_range(2) system call. + copy_file_range: called by copy_file_range(2) system call. This method + works on two file descriptors that might reside on + different superblocks which might belong to file systems + of different types. clone_file_range: called by the ioctl(2) system call for FICLONERANGE and FICLONE commands. diff --git a/fs/read_write.c b/fs/read_write.c index 39b4a21..fb4ffca 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) { @@ -1600,7 +1597,7 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (file_out->f_op->copy_file_range) { ret = file_out->f_op->copy_file_range(file_in, pos_in, file_out, pos_out, len, flags); - if (ret != -EOPNOTSUPP) + if (ret != -EOPNOTSUPP && ret != -EXDEV) goto done; } From patchwork Wed Oct 24 19:58:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654939 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 F320D13A9 for ; Wed, 24 Oct 2018 19:58:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E34E82AFD5 for ; Wed, 24 Oct 2018 19:58:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7A982AFE6; Wed, 24 Oct 2018 19:58: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 8F12C2AFD5 for ; Wed, 24 Oct 2018 19:58:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727369AbeJYE2M (ORCPT ); Thu, 25 Oct 2018 00:28:12 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44736 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2L (ORCPT ); Thu, 25 Oct 2018 00:28:11 -0400 Received: by mail-qt1-f195.google.com with SMTP id o17-v6so1409283qtq.11; Wed, 24 Oct 2018 12:58: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=D3Oki5BmKEd8nnsyx5CzmdHvMrAIdEpQvYy6/1wa7ko=; b=jb0CWUnpA+Q1EPxxDQdk98QHV1OqqAEJQScocoKZMks9O2+VTMGD56MZS3Hv78yGqm ZheLtgj6XnlcjevVWnxydz+nBY8GSOMQw5zcQDseBBJ3Vc9JURMty2KlfIko8XEREVkZ zHzCxzDxvHW9UHkamJenSAEoc2X/2hBBp+BHXJCfkLJt5ka4gK7C/p1eeHcDOGGeRiSV POfU0BKMhbSeVk4BJYPs5r8bHPGyTcNSihG5GNaMibhzT2OsccpjcvDvnXhASekV73Fm x16buNRIWLNjL8jViPycQXsxF1crLDlGeMdeF56VxxtcszyB112LCRe+Mk/ayvww0d4y x4iw== 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=D3Oki5BmKEd8nnsyx5CzmdHvMrAIdEpQvYy6/1wa7ko=; b=HuadWFsYurlChmGyJICT9EJC5NqFkFQ4tTfzuO3pkI2Nc5LrSyAIir0ZtEWd20iYH9 GIKRn5fYmT38skNXhgRGU2Lu0Qlc7Bkxao1AdnAkVTVFhw5BJvwScXJNZdIhFkOxXoHz i+I7EFAQ2FTtti7oGzNzczsK7mTDOkgJGrOdf2kbv9fFC2rUAnPRKcU2qMsvvCOM4op+ rMhjHIKM2IEdbIRrQavYrtNCc6xllcC4F39L3+KWbILoebKXaQVwDRxYXW146Mkauob/ KgX+zAYQkuQ+8fd+pQzgUWDiKlBzN49HA/OzUfxeRTXXG9jOuUN1M6Djj7NFL1P4x3tH s8AA== X-Gm-Message-State: AGRZ1gJ6gpAT2bVgLpS9XyP95HVeCf5AZz7AnR+DhWGRLS0ij2RMAeYb jhCSJcZhRP2I6quRHTuVgeU= X-Google-Smtp-Source: AJdET5eAH7+PcHTv/btAPvMM9L283QOjCm3exyEBenGY7N7+Lv6PP6xR6lN4ZArSM7wKPIVXbla5vw== X-Received: by 2002:aed:33a7:: with SMTP id v36-v6mr3326728qtd.267.1540411124255; Wed, 24 Oct 2018 12:58:44 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.43 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58: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 v2 02/13] CIFS: add cross-device check for copy_file_range Date: Wed, 24 Oct 2018 15:58:26 -0400 Message-Id: <20181024195837.35532-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia VFS copy_file_range was relaxed to allow for cross-device copy. Add a check for now, to disallow cross-device copy offload until appropriate support is added. Signed-off-by: Olga Kornievskaia --- fs/cifs/cifsfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7065426..1f41e74 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1114,6 +1114,8 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, unsigned int xid = get_xid(); ssize_t rc; + if (src_file->f_inode->i_sb != dst_file->f_inode->i_sb) + return -EXDEV; rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff, len, flags); free_xid(xid); From patchwork Wed Oct 24 19:58:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654945 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 E01F914E2 for ; Wed, 24 Oct 2018 19:58:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8C82AFE3 for ; Wed, 24 Oct 2018 19:58:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C332B2AFD5; Wed, 24 Oct 2018 19:58: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 781482AFD5 for ; Wed, 24 Oct 2018 19:58:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727401AbeJYE2N (ORCPT ); Thu, 25 Oct 2018 00:28:13 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43892 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeJYE2M (ORCPT ); Thu, 25 Oct 2018 00:28:12 -0400 Received: by mail-qt1-f195.google.com with SMTP id q41-v6so7084597qtq.10; Wed, 24 Oct 2018 12:58: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=hvO97r38odejQD2UfpD/KDSrWr7Es3ZRdoL6dlpHDTY=; b=aFxrcAIXBS51Bj+q9TQcW8dj9mo2rrJjRWQXewjiRr0pJF7s6j4jkxEuQCAk0OQhOc ER+6gI3kjTmw+XdK8pFgp3OGgaFNOi6X8dMX2469hpONwENS0X12Ig5o9oDORTj1hhiX XReEwM58MpncFcWKGw5XBO5zRuY13I6kL+/0CnjsUvYIZ/Cl5754hoi9gF/bxvl7XAfH rd08KTg/PrVOxHR6zGEX9ZVlUjY+oddzNgh5lJSgfs4ztPwuq78pC6kOVodpH+lZ/r5A m2gEx9mBokMLbRJBiv9rM+H78h7ibikf/jM9VCPu8A3XhScjHC7ZzrQgGFEV4BS/akOf Ieyw== 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=hvO97r38odejQD2UfpD/KDSrWr7Es3ZRdoL6dlpHDTY=; b=ptk/+sSYhrL6eSy1F55IgnMRhe35qjIuGi/y34iL07wG6R5bs3Vj/fQG5PeO0YEyoT LGxp8K/xTXzHyMXN58cyduFwv7U9OPaVU3NIeYaQ7oK3T1/8b+H2QdonQVhABGWdXnYH zUFuAzvU3kdFQcYxUYx+Nut4Nzbg5Y6nmkp5CM/2Ii57h04UyjhHmOErQZVr0czmw5/n xGLyAxAfKdyGOAmqrq6sXR8TIgKW8MxH9d6nrImyzbBT9ioXlkDDNCwVm6kKeKrkpXiI Y0pXx6iE/D0v6OmNQg7iPIQ5Ijc9wr6sdOkoF66M5Ro3n8Oe78wNbn/2LMCnXF8khl4B leRg== X-Gm-Message-State: AGRZ1gJilqqrP6qKUftYNRFhtAu6FLj9kZvDSmPEDyOjqLeHz3TMgWVF jUJgaCESVPqBwxYELrqegbc= X-Google-Smtp-Source: AJdET5dbTi5HYhRU2qJEDRaB8vr13zxgOKCgdIoY0lf9m5ntYBC41ytTdxtn6jR97Xeb7hyIifvHYA== X-Received: by 2002:ac8:33ad:: with SMTP id c42-v6mr3849722qtb.190.1540411125567; Wed, 24 Oct 2018 12:58:45 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.44 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:45 -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 v2 03/13] OverlayFS: add cross-device check for copy_file_range Date: Wed, 24 Oct 2018 15:58:27 -0400 Message-Id: <20181024195837.35532-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia VFS copy_file_range was relaxed to allow for cross-device copy. Add a check for now, to disallow cross-device copy offload until appropriate support is added. Signed-off-by: Olga Kornievskaia ` Reviewed-by: Amir Goldstein --- fs/overlayfs/file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index aeaefd2..5282853 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_in->f_inode->i_sb != file_out->f_inode->i_sb) + return -EXDEV; + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags, OVL_COPY); } From patchwork Wed Oct 24 19:58:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654951 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 E0A4117F3 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1EF428481 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C2C2B224; Wed, 24 Oct 2018 19:58: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=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 85EA628481 for ; Wed, 24 Oct 2018 19:58:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727427AbeJYE2O (ORCPT ); Thu, 25 Oct 2018 00:28:14 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40158 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2N (ORCPT ); Thu, 25 Oct 2018 00:28:13 -0400 Received: by mail-qt1-f194.google.com with SMTP id z9-v6so7097058qto.7; Wed, 24 Oct 2018 12:58: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=XkCvx+hgMC4KAXjFXC+q8/hinOBCjkRD+CDTi9Non44=; b=djl1mQAjmlY2jlzKOytCKVVWxSJxcGhGfV4H2GqrFEwONHv+InSHZ1v+KXaGR9/LXg HzB+qwGw12Boms0fEK3JvVh6grEz3jHMdv79QDAtajPUed/u8lgJtmscGYEk8YFjUdE1 H7dJhNqkxjmOYnr6k1IuozT/M603RMQtGD/DlGlSOCAgsHlH3jIf7ujmA4TS6+5WykHz 4+ooUq5IN2F9Jqns77z+HrkNCRaedNS4twn0Ft++J68K+opMY5Ou+uwyWJ4jwVYItBT5 AS/HobcT5enAVxRB0FqiYKkUktL9mKaC6rBVyD2JdSkT3pSAbb1aHSEFLOaELDXXW7Ic dj+Q== 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=XkCvx+hgMC4KAXjFXC+q8/hinOBCjkRD+CDTi9Non44=; b=hjXGXkMcaRvFkguUtWQZ+pf/SmbPLcE2r5usmVfPhQ6/o/hzACq7rAo1gVYZnd5QWr 1BOtbZj/MzMkvvFzutDJvcEJROoGExLsH00nIf9FjuEQsB49i6cjz3GV7bbB+jvxPAot MVZhB+s5lHi3kFed9KMr8/ylab6Ldeggp0rj0XwcJuCGeD5yCC+xKAWPJdcRrtGV/b0M XFvpDpdNCS7uIlBdHjBqOWzMMkG/UL3IHKqQET8OmnISTvQmGnv1SgQHrvQSYCYaDqqz bZrna1M7ecDzVmYiMTnq3CooKrUhXjs52ef9uIzJBuzsZaW/xhoRTZcQxqy+2LOpTd4H i3gg== X-Gm-Message-State: AGRZ1gID0F8e1MW86azQrCvfNmF3s5/Mm8UeCm32JvLfKj5Zy+d20M6G lCIruZa6LW45VH5ablwo+7M= X-Google-Smtp-Source: AJdET5faYI4cJ7ltYOUvpgsxdMUq0VcmiMg4BBZeW5mYa62wsXj0QXikBr0ShL5gH5kbBD0wC6jYIg== X-Received: by 2002:aed:2a0b:: with SMTP id c11-v6mr3824826qtd.147.1540411126914; Wed, 24 Oct 2018 12:58:46 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.45 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:46 -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 v2 04/13] NFS: add cross file system check for copy_file_range Date: Wed, 24 Oct 2018 15:58:28 -0400 Message-Id: <20181024195837.35532-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia VFS copy_file_range was relaxed to allow for cross-device copy. Add a check to disallow cross file systems copy offload, both files are expected to be of NFS type. 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 4288a6e..7137e7b 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_in->f_inode->i_sb->s_type != file_out->f_inode->i_sb->s_type) + return -EXDEV; + if (file_inode(file_in) == file_inode(file_out)) return -EINVAL; retry: From patchwork Wed Oct 24 19:58:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654955 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 7755913A9 for ; Wed, 24 Oct 2018 19:58:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68FA228481 for ; Wed, 24 Oct 2018 19:58:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5CB3D2B224; Wed, 24 Oct 2018 19:58: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=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 1B9AB28481 for ; Wed, 24 Oct 2018 19:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727441AbeJYE2P (ORCPT ); Thu, 25 Oct 2018 00:28:15 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:37685 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726221AbeJYE2P (ORCPT ); Thu, 25 Oct 2018 00:28:15 -0400 Received: by mail-qt1-f194.google.com with SMTP id d14-v6so7108416qto.4; Wed, 24 Oct 2018 12:58: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=+0fsrlOq/dSjaEtkyCmz/HyRHi0zkd/mUP3yrg/KeN8=; b=EULgr7097K2Ned1BR7S+KHDiMM+5pTQXBi+/v10X8ADiQzLQl/hB68Nh11aCmZH1+z 9TMxogvhuGvmH1QtWRTAAGDMjGqV8SwD21HpH8gBJD9ojphTdHCJYvgCSJK6ZDedbrTl hBh5DTRVxp9k7LuJQvplERe2NZbWCp7EvhvxLNexVtw2WHqZaxRtVp2/vg5w+tnZ1U55 s0MSjWZ329QH1iUPKqs9gOmOOeNtXHA7ZNuFX8tIOnMMETzgwaMnvaU8jV/iT5EiSkEM N8xEzOSMjcxgZauWmm6FjRagSHNMyyQisVoYEuPLUhCMVr0AFdRdeG5fDdMzOZtxOce4 D1MQ== 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=+0fsrlOq/dSjaEtkyCmz/HyRHi0zkd/mUP3yrg/KeN8=; b=o4UngGN+KiDHd2dqR/h5T9Sw9qK293q5R12SCXML914mSODoBsrtHL1GOOTuJkmhee vf0/DnLwyqG7o+K/n0McW+rjSwEJJqFPAN06cBnLUFA0X1t1sEYBi4qy/XbOBsFcyy1d Q6mm32ADZpGdrLkVN7jiBu9mVFEUdoUbhEaKFwZnkHzCkFuAOJCUZfHjr8Z8eL05Xny9 2Pz9rG0gum5te4Z2phX9nBgQZ+M9SiuSaSKUdvMEcfVCXb70OYdouLR4noJZaeTWp1vd hCRYl8OtEi3E+JcLGrYPhV+NOTfJJboh7o4xfGlt0pBMc0J+NDxiEZWRCCDyVzOjOEgC +i6w== X-Gm-Message-State: AGRZ1gIeDB1oP9HWBI2BqkhMDRcBGM+gOO88apGvLHhsXA4UmpmQzKyR vN+3ixFJM/Pfv5Yuio1Jlq/sUT9v X-Google-Smtp-Source: AJdET5foZ7hC57QxWf9Wc6rH2HTULwU9uUkA9F0tcrzg6Xcsf/l6e2MUB6hAs4jrF9fqe4ExAC+7ag== X-Received: by 2002:ac8:550e:: with SMTP id j14-v6mr3936452qtq.139.1540411128393; Wed, 24 Oct 2018 12:58:48 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:47 -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 v2 05/13] VFS: Don't copy beyond the end of the file Date: Wed, 24 Oct 2018 15:58:29 -0400 Message-Id: <20181024195837.35532-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Olga Kornievskaia Enforce the check that source offset can't be beyond the end of the file. Signed-off-by: Anna Schumaker --- fs/read_write.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index fb4ffca..7bdbf39 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1570,6 +1570,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, if (unlikely(ret)) return ret; + if (pos_in >= i_size_read(inode_in)) + return -EINVAL; + if (!(file_in->f_mode & FMODE_READ) || !(file_out->f_mode & FMODE_WRITE) || (file_out->f_flags & O_APPEND)) From patchwork Wed Oct 24 19:58:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654959 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 1624617F3 for ; Wed, 24 Oct 2018 19:58:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0791728481 for ; Wed, 24 Oct 2018 19:58:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFAAC2B227; Wed, 24 Oct 2018 19:58:53 +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 520D22B226 for ; Wed, 24 Oct 2018 19:58:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbeJYE2R (ORCPT ); Thu, 25 Oct 2018 00:28:17 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:37688 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2Q (ORCPT ); Thu, 25 Oct 2018 00:28:16 -0400 Received: by mail-qt1-f193.google.com with SMTP id d14-v6so7108521qto.4; Wed, 24 Oct 2018 12:58: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=MFrexHXO7yQY1QRrDlhjfVTvrBtGmp73ZTx4Rn7FdtQ=; b=Fn9SkUq0x+PAp1QclbMdemsP1+0K/6QnUnZnKMhGUilFAAXpM29jt2bLnBJ4bXyRc1 u1NeI6UqYKrdfTtNF3H2WIHFTCjMiT2hFl+10d36vyOgmc7I1dgjEdd0jlUyIzre3ekR SDt1oFJwSGzfBXKrbFOzT8nBw+8RfyLSs8T/+J7gegPOiP0o0wPVnE0N0owNlwrp+z3o RTi+roXvJ/3Wml/ugCGQ7gAkAZWSySc3F9SqbkgJTfk5H5Zzb1f6uqsQh5F6AGuHUYpx 1ORd2bYciFxEkuSCllHPt+Nk44QWmBbEUJLYNH/uYKRgLhOwYDR4/W5a/tF2F6CGV3pP QNQA== 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=MFrexHXO7yQY1QRrDlhjfVTvrBtGmp73ZTx4Rn7FdtQ=; b=s/zj45CUA+H3vqkGwRa2zct2lGT/A3RqioEQPYuh8l2+yh1+8xsrxPd+Tw9byYH98C 6eBodFybe4kZTuGjXYWNbpGbznBJ73gf91R/Uz3FyVbn3mxBT5EvVyZfqljT95qW/Bf9 /wbpC0gQsO8Ehr7AGnSmqtueYPmw+CSHqPPWWroXecQ9Dp23jWG//32ecY5zhBQR3bUU dJ01uK3vjN5lUcWuFNRrKJIvbGaR5TU0tZj33j3l8uprviCgaqv6XAlr3MLI95t8hbyw WjGC9q15bCaIVNfTPKhdRuZc5nx+zWocdVQksfYgh7dfjOYJ333XufgTEGkjjbVhyzSH i9bA== X-Gm-Message-State: AGRZ1gLAXd3dyluxYQissCsc7pzbsQYd1R0G9xA9tCPP1W/mqtYHtp+b 1MUuaGF3wcoAx24K8G5ZUkw= X-Google-Smtp-Source: AJdET5c297/vyC6W+kCDq2UDOmGTVxadwWAag8mMO+kaIgTEmdONgKRFkzJh4tAp5iu6Njjn5QKhYg== X-Received: by 2002:ac8:13c6:: with SMTP id i6-v6mr3922194qtj.357.1540411129666; Wed, 24 Oct 2018 12:58:49 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.48 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:49 -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 v2 06/13] NFS NFSD defining nl4_servers structure needed by both Date: Wed, 24 Oct 2018 15:58:30 -0400 Message-Id: <20181024195837.35532-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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 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..4d76f87 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 Wed Oct 24 19:58:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10655005 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 668A114E2 for ; Wed, 24 Oct 2018 19:59:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 581622B224 for ; Wed, 24 Oct 2018 19:59:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CB442B227; Wed, 24 Oct 2018 19:59:17 +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 54DEF2B224 for ; Wed, 24 Oct 2018 19:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727460AbeJYE2T (ORCPT ); Thu, 25 Oct 2018 00:28:19 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:38076 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbeJYE2S (ORCPT ); Thu, 25 Oct 2018 00:28:18 -0400 Received: by mail-qt1-f193.google.com with SMTP id r22-v6so7103549qtm.5; Wed, 24 Oct 2018 12:58: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=EHkL+bngW2QXlxaoJo7hTX1WJfYAeYiMlEdVWo5UXRU=; b=GAUg1EHBZz0Ud35nm79K6C4HALHxZR9n45DxY4o8ssXwUyksRUrkW4yyD0BP0G20Tp difJ+ud0gSUMm5vRXRwPyn43CgK3xUVPCbdQSZPLUWf7fmR31ELxS5aFJRvT3wmjtcn7 aEmTIOzZTLGFhmyIvIT1Cyq04LMaPfVPf43K77abOfTat0XcZDP612NW7WY74nUcT1o6 Q19DXgZbWg4ylfXvhQKGyT1D4ItOqEYnxZd6H9Eh7w8ojGxqsmGQUodobueYBFvG+mi/ jcqQrWpr7uRQsMS+W27kGLFiYit29X6oj17tInNTouInZr/s7m1SmhhV5uVIax8+v/k0 /4OQ== 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=EHkL+bngW2QXlxaoJo7hTX1WJfYAeYiMlEdVWo5UXRU=; b=mtmmRq42pw5ZOJgsGhxxpVC54yvGM0eCq7Tz4NOft8qz9vpRusAMsD6LlPhJQOSryA r6yRPtNL+gwAj2wkCTqjrmZsb3JAwoRkiLwrQZSpQ4xhBxvgyOgG79umUjGrOXu9Yio3 TIhCGgpNxRcTpNMflbeT8BvONEDwGLx8oEmLHMeI7sjWjbQGC97Xl1Qp3OL4GEMlMwJM dxPxSFhbNPSh5PPnJORNg4E91phKmJSkV9KrynKvrbczJj8RUrZqkwiMRFRxQkgiJtgQ cgOTOuPn6CQ6VCAbCPoahJzxGI2HZYhLzPzx+6YjrrVmN6iu4Or3Zf4WcnZ6ISCWl7Ft MPxA== X-Gm-Message-State: AGRZ1gJMBvUdcoZ5ZVYAoOog09lxrJsMOI6ns29HaGvlJjV9j1e6rVW+ QnPMtr8gXTusM0rR838gcjM= X-Google-Smtp-Source: AJdET5fYQQWJj4C3r1WadQuXZ4jo2kyiTEoTZA/gl70tl53N0GnBgpy3x5wurII2pEqI9z23nR2RvQ== X-Received: by 2002:aed:3a69:: with SMTP id n96-v6mr3949474qte.344.1540411131132; Wed, 24 Oct 2018 12:58:51 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.49 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:50 -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 v2 07/13] NFS add COPY_NOTIFY operation Date: Wed, 24 Oct 2018 15:58:31 -0400 Message-Id: <20181024195837.35532-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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. 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 7137e7b..ae51e38 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 (file_in->f_inode->i_sb->s_type != file_out->f_inode->i_sb->s_type) @@ -141,7 +142,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 4d76f87..d80b25e 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 Wed Oct 24 19:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654967 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 3772213A9 for ; Wed, 24 Oct 2018 19:58:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 272BE2B221 for ; Wed, 24 Oct 2018 19:58:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B9D92B226; Wed, 24 Oct 2018 19:58: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=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 9794D2B221 for ; Wed, 24 Oct 2018 19:58:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727475AbeJYE2U (ORCPT ); Thu, 25 Oct 2018 00:28:20 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:42518 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2T (ORCPT ); Thu, 25 Oct 2018 00:28:19 -0400 Received: by mail-qt1-f193.google.com with SMTP id j46-v6so7087940qtc.9; Wed, 24 Oct 2018 12:58: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=fgmvujVOMXhhxMK3seNt3VrkFNf88H5CT6EtF8fNZVA=; b=l8deqLfQf57q4s22d2O6ba+DlF9pEgTjZJQn2O/3lDg5zVORHvEagmirSF3g67X7EF TiArikfNiFe+To3J1n93oBGwwm8q0rOP9FoxC30cJR1AM2OTLr6Zj08xTv5Kt/YxmwRq 4xYhwxtaGYi9WG6hAdy6JXX3i8QC5XIQJ/cgjURetdDBX4+XMgvYwxF/XoKrYpPAx9Nz RSOVkkDFjX3Fuu4wM7DuoqjIpBUcUqiEv1BZWOEVjlAgEaujyMCv1k/4NAtRBQ8d4+kM v/NVFlIAPh/uyEnwGemdePXghfMs+C74wBd1LtiZdhWRLkBW6qGhNyUFm18OQJdyFHj2 9Ybg== 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=fgmvujVOMXhhxMK3seNt3VrkFNf88H5CT6EtF8fNZVA=; b=ZnyNOPrXDVsic/PBfLC9d5yXKz4kYmnApLawwf3mlTFzpQbyL4d+IBNFnku8MCw8ph rQeR5hbJqWSlWJ6FXD0qhw0MpDBI/Clnu78o/PBW7FMRxvhLAa52mJEBd8dOTlPoT7CM up3uOJMCicv5er1JGh2lH45yuzp0Q2CjeubMUkE9dOjvZAjt/aTP6XRznnuH+RIwTvrl 9y0y3oP+pSOkh24OgSoGu+CddE9E7p5SeX+kOxVELNi7Ln7uZVVKrxLNSh0t+DrOSkk/ zj7bYRKXPjCvzCBqfbrf9DKkgdbx2W7fp1AFTjctEV+xEdMGQHdXvgOBxLuJDlT0IPox y4zQ== X-Gm-Message-State: AGRZ1gJQ8Dl+haFf3hSxP0gYAGskv/5TkyuXt6QhL8Ade3mmIYIjkbkc 3Htg9wdjY4ZxrEMJY/oTF4o= X-Google-Smtp-Source: AJdET5e/t1G5CSRmcjt5wClv2DYPZEvzfI2rWcfw6RHaoJcg1sXgKij3i2drgodRInaQOzbpmL+r9w== X-Received: by 2002:ac8:6b8c:: with SMTP id z12-v6mr3821292qts.328.1540411132566; Wed, 24 Oct 2018 12:58:52 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.51 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:51 -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 v2 08/13] NFS add ca_source_server<> to COPY Date: Wed, 24 Oct 2018 15:58:32 -0400 Message-Id: <20181024195837.35532-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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 ae51e38..703b56f 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 (file_in->f_inode->i_sb->s_type != file_out->f_inode->i_sb->s_type) @@ -151,9 +153,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 Wed Oct 24 19:58:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10655003 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 961DA14E2 for ; Wed, 24 Oct 2018 19:59:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 868432B221 for ; Wed, 24 Oct 2018 19:59:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AC452B227; Wed, 24 Oct 2018 19:59:16 +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 336742B221 for ; Wed, 24 Oct 2018 19:59:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727478AbeJYE2W (ORCPT ); Thu, 25 Oct 2018 00:28:22 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:33525 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727456AbeJYE2U (ORCPT ); Thu, 25 Oct 2018 00:28:20 -0400 Received: by mail-qt1-f194.google.com with SMTP id p24-v6so1171028qtq.0; Wed, 24 Oct 2018 12:58:54 -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=Orrg4+IUS70/He9/HvyiGLpqKLwtqiRg87WVasQElYQxC+5MivRe1/v6oHV48X9rY5 Ry95VOLwXVCKmKwmVSMvz1t1aqVC+kK7XcUc40uHsekLGUMZ28PW5qSk+JcwizwKeewB 7YKomlImk2Hpi36BFTTB7rEw/A/nUdxxXuCKwEJAone2wFdagqYgxYUtGuOLmxu78WH7 H7uGQuRznQ9cEcADNeQoA+65zhmm5QbZi2oCDEVzauqwzwi2dCP/7s3zvPGm+60cjROa 5wVSi5vkwy8bLpt4x7w0kVAmXM7pB8GBPye47dkJt+JfDp+80fRVHBpCodups4hj+aBT SdNg== 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=hVbb2lByNiHbYw5VtuP7hH0jXAJEu04vxz2Zagoj/ziD9zyuUgjIqMSWlAkvsDmPdu VglZj+ffL4D6HjUkS5n4SCh/Bi38oanO4ZeYhDOGxapUxc/oqvYkIVvgatlr3rBmOL1r FxCaD1DVYE2CMPIrWaZMnLdj6cfzq0LpGf2FQb4r7pshIsIxqNyJD07x8RbgGKtkoIZj VePQTjaTyFF99LaOFaLBVnkCJM817o6/w3s8e9w+taKOyMVgW2/Nd+ok7INPCoGJkfKP dx5bkH+NUkxoBAheaJJFd0fLRnhKkk2tseiGE9ChHC7FG8fcHN2Bv8A/64LHiIzf3oxP Rxnw== X-Gm-Message-State: AGRZ1gLugwC7Gf1rqJZV+RiEbUrJL65POZxfkfERF+d8Wir9Dfst6MMi j1uUEnTkSAFfJ8/MGj2pGS8= X-Google-Smtp-Source: AJdET5cWwxoYfGXCvAm0girlk0mnHAzk6UXKSJl28Oqgablw+G0cx/Fh4hQ7wmLx5gnlD7BaPUL1FA== X-Received: by 2002:a0c:f651:: with SMTP id s17mr3910667qvm.46.1540411133978; Wed, 24 Oct 2018 12:58:53 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.52 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:53 -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 v2 09/13] NFS also send OFFLOAD_CANCEL to source server Date: Wed, 24 Oct 2018 15:58:33 -0400 Message-Id: <20181024195837.35532-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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 Wed Oct 24 19:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10655001 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 503A613A9 for ; Wed, 24 Oct 2018 19:59:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41AA928481 for ; Wed, 24 Oct 2018 19:59:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 358492B224; Wed, 24 Oct 2018 19:59:05 +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 B21B92B221 for ; Wed, 24 Oct 2018 19:59:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727504AbeJYE2X (ORCPT ); Thu, 25 Oct 2018 00:28:23 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:36812 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbeJYE2W (ORCPT ); Thu, 25 Oct 2018 00:28:22 -0400 Received: by mail-qt1-f195.google.com with SMTP id u34-v6so7106719qth.3; Wed, 24 Oct 2018 12:58:55 -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=YyjZM/WJkdcr4SaYbwYLN8f4HIYIQO/LHrCGPYHk06g=; b=H/3gRlueh4FvoQqik9mz5l9FDnximsr8EDrGhO1lYjNZVKonNsLLLXUCB2krrxxQe6 WTtVFoh+TPaHy+QynyvDGXFCM15uNl/qQPMG85LnZPm5g6+V3Pq0lbI1A/NcVaYndsAF qrDv59+CVvxyWztBUVxbbpk15OWD8vw12kXvgaajmp+GYJUWwTDIMrIwIPFDvsNrYeTT x0ryPnnbHuRJarXxSZdvSmVWu7NY25o4RRX7QjUhvVRLy8/EeX9X5CSs3UnS9b6oH6XF zt4a+JSYORvG7WHZplr+tkCaxtcqRNJORbEtK3FGzTHFpeDV4hQHfam98UQP6cOodiss WG4A== 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=YyjZM/WJkdcr4SaYbwYLN8f4HIYIQO/LHrCGPYHk06g=; b=j1bS1VskuoGuimBCPUejwwVLl0T5HlviOsZHxtQ9EdrI0TuBhLtWHj3H6rhDr0n2Uw 3hEyM5mdSnojaU9NndpFhO+yOtP8apkAWLuP6NnFB955of6QijQYK7OmWcGof82n8RPa XxoS4VUs75ce0pF95JATsnJQ0Pmikk1ikO3y8zY9f7Dd7iiX8/gtyGf/xS42Cqdyzssl E57eB5FYebcqBlNFCUm3HbK/nBpO57JaptkGT+L/Lkx6ARf5jvXYOE4ak9Z96f7V50ZN dz+UWsFrtjDrOS6DO5rTTRbovEnNxE/8AX58d1Xejqfa0FV0D8DJbh3jcOwgoVpKqQGa 4EHQ== X-Gm-Message-State: AGRZ1gLVknLTbwTozMt63pxmDM7arrQQzZOK8vKkTpxK2S+DXisrWCQ5 ve7g+zTbKd5UdHksRzrhd+NH1WJ7 X-Google-Smtp-Source: AJdET5fjh0wT777ZD66n+tnwSHcl/LVx/yugh0d2Yrk9YNiZSGcNzsVfJFFUhLCp61lSBHcfrCXvcg== X-Received: by 2002:a0c:c346:: with SMTP id j6mr3886039qvi.48.1540411135387; Wed, 24 Oct 2018 12:58:55 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.54 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:54 -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 v2 10/13] NFS inter ssc open Date: Wed, 24 Oct 2018 15:58:34 -0400 Message-Id: <20181024195837.35532-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4_fs.h | 7 ++++ fs/nfs/nfs4file.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 5 ++- 3 files changed, 106 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 703b56f..300880f 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" @@ -264,6 +265,102 @@ 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: + dprintk("<-- %s error %ld filep %p r_ino %p\n", + __func__, IS_ERR(res) ? PTR_ERR(res) : 0, res, r_ino); + + 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 Wed Oct 24 19:58:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654983 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 62A9117F3 for ; Wed, 24 Oct 2018 19:59:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51C382B221 for ; Wed, 24 Oct 2018 19:59:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 462B32B224; Wed, 24 Oct 2018 19:59:00 +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 DBC232B221 for ; Wed, 24 Oct 2018 19:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727508AbeJYE2Y (ORCPT ); Thu, 25 Oct 2018 00:28:24 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:40190 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbeJYE2X (ORCPT ); Thu, 25 Oct 2018 00:28:23 -0400 Received: by mail-qt1-f194.google.com with SMTP id z9-v6so7097732qto.7; Wed, 24 Oct 2018 12:58:57 -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=Phkx7dtRxIh0Q2t3XHkNvjFUnOOqS0aUwmfPKMDFh7E=; b=jfufODN7HFoGMI0Ah4Xn1flPfv/4ZYEr0lOjAjNX1zay6Iv76v5zPewzoJAi+sjzLs JR5ih4U07Z9mN1gVQCnpNAiXzxMxGwMcQDHk+DIA5i/dX3LEjPHfoh2KJffglGDumvlo YGNbteW/BxGmCQxiW4L68g7GHuljM16oF/LzqVOGlYQBuKAoj16Gfwms6Y/emV7WmO0I wZt430mmXY17n/WmYDVXDviIDPVtwKCuOqgo+yPPIGRjbiWHuU1dJd31SM9Uef0E1xuI BBi9dlE9xBPyNjidCiLz/DaFPbXVOwcaZcxl+gZwB/OuULpKFtQnKzk4QM4h6AH9dr+W pMHA== 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=Phkx7dtRxIh0Q2t3XHkNvjFUnOOqS0aUwmfPKMDFh7E=; b=R0sfwhNAapvhVzjt/58RQvu0Svcv0nNJUFDgYMCiO63GIRwIVITMALCuDBqg9kNH94 64kQDQFGT/dCB6GFCIpRr+K/BJilMlWvDuvNIO5bf7iT3G0vg2ne/4/lYcr4V1Z4CLKn ivG6JqKxZZZ6LMuJkgLPtKQCYBoZwLs40X4gFPRFGVieyAY00DhZySOs80zZSIqXhbMH L51bu+C0hnwvAoOMgzjZfSVB+0+Wh62L4vsRqxMIK2gfLRbihnV4EUjbL+w4WRLsxCAV JuHeUt6qly/wtFv/UmI3yydpgNuS+/NyTptLRx9XuMCyN39WR/z/5VLGUve0hfeQ8BTL D3Zg== X-Gm-Message-State: AGRZ1gJsji1b35gnnDfGj5r3R3VPCPVkBa4a3PVNJ95EN++Rgy1xshKt Qbj9q2Q2WdBxCjB+VGrdbgc= X-Google-Smtp-Source: AJdET5cnvKbPVW+OjcXOjpsVLrqpPidLX7FfKRWfsX1xWp1QiLB8JkCgZoDUgGLY33LY7YZ7xvlU1A== X-Received: by 2002:ad4:408c:: with SMTP id l12mr3730114qvp.231.1540411136982; Wed, 24 Oct 2018 12:58:56 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.55 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:56 -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 v2 11/13] NFS skip recovery of copy open on dest server Date: Wed, 24 Oct 2018 15:58:35 -0400 Message-Id: <20181024195837.35532-13-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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 300880f..480b384 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -330,6 +330,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 Wed Oct 24 19:58:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654989 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 A30D113A9 for ; Wed, 24 Oct 2018 19:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9203128481 for ; Wed, 24 Oct 2018 19:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 860E72B224; Wed, 24 Oct 2018 19:59:01 +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 439CD2B221 for ; Wed, 24 Oct 2018 19:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727533AbeJYE2Z (ORCPT ); Thu, 25 Oct 2018 00:28:25 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:41734 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbeJYE2Z (ORCPT ); Thu, 25 Oct 2018 00:28:25 -0400 Received: by mail-qt1-f195.google.com with SMTP id l41-v6so7089227qtl.8; Wed, 24 Oct 2018 12:58:58 -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=K7MFHrnWE4fWFYme7dBc6bdrP0/8P/CPMn5um30ZDY4=; b=GmgxpqlTCSH4sxnhjDmk1b3zz7z6tY7NM4ZTpwBEqBX9xRywdGfWsgiWTJFBzSQUq+ 1Gkxmc9MR8Bigwn1+6gjuqChU54aqehj114aEkSSLt88NYRKX5dsEGMrxTp7/zBd/JiX B9Zb/EmjQo3pg1aRR028rpVpFNlAkJP7PrDCqjfCnZUcnNELtgLE3m6rWOCOuZrYFUpK zPwha3L7HO9J9OnevBCuHByj2EZLWYXsKlDS8IIiwQpbKcpglzUNIw7i+FpQiuNqHpca sqNSZKyJjnf4FvG2034Plv+NLZIYhmbDmp1qPd0JmN0LFmYxaXYMq0T91JjRhHpKyQJh VOWg== 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=K7MFHrnWE4fWFYme7dBc6bdrP0/8P/CPMn5um30ZDY4=; b=rkz3s3k9gFaBBaP6K7Ni7SR4rQAvYBiMozfuPGiA1BLUEKLuh+9/BN0Dnmz7EfNX55 3oao+e967ZDBVWMVD7fqdTQeGLjtfhrBmrs+758RnSLxEcodIVllXv77qttkUXKY6qjv sTb959Vv+N00inYndYW1bwfMPilGupMTCZui+KbQWo72/Y3uxxGWTod5WzVPTvOXIxxl n/H8vjvGo66GDEoYThmbrnZZsQNLYbDGRQsiUN4gcjQWBBF9WRowT/OBnnm45FAOJUM9 jAFc5c5VQAcgqwjvf8n8XrLCsaB5T1Z4H4s6gGQFQDX3oiSB+Ia5r1aPG81M+IoUDEsx UbGg== X-Gm-Message-State: AGRZ1gKzHk5pmgjX+caHRsld4gMQiT7YgaAyNbsljo3ub8VXQXIFr2mE IuoJarRHzwTr5qXZ3d9c3ak= X-Google-Smtp-Source: AJdET5epiUQnbmNbY7amS4LFXFehvCJgpEOl75o8b04n8rMWdi3/d9IqFeDtf7eUeZE51OJqiOLQQw== X-Received: by 2002:ac8:38bd:: with SMTP id f58-v6mr3675217qtc.337.1540411138393; Wed, 24 Oct 2018 12:58:58 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.57 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:57 -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 v2 12/13] NFS for "inter" copy treat ESTALE as ENOTSUPP Date: Wed, 24 Oct 2018 15:58:36 -0400 Message-Id: <20181024195837.35532-14-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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 teh 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 Wed Oct 24 19:58:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 10654991 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 4F9CA13A9 for ; Wed, 24 Oct 2018 19:59:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E85828481 for ; Wed, 24 Oct 2018 19:59:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32DA72B224; Wed, 24 Oct 2018 19:59:02 +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 DA58E28481 for ; Wed, 24 Oct 2018 19:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727542AbeJYE21 (ORCPT ); Thu, 25 Oct 2018 00:28:27 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:33191 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbeJYE20 (ORCPT ); Thu, 25 Oct 2018 00:28:26 -0400 Received: by mail-qk1-f195.google.com with SMTP id o89so4245104qko.0; Wed, 24 Oct 2018 12:59:00 -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=dFOerZNwKxzWjYWepyVme3Fh9Q3k55q5/TxJq/G9IV0dpPWWmMo45lS6MkgkyggYyh ol63X1kCOUowfnx2WPGuu8VIvkKZfZeQOGl9LgXvTIyLerV3h3cAufKFMQrmz+zwb6QV s3ArQBrzmPK30QRYN/XdABVj0XQxn0Uk6mGWCJUj1O+7Dz4D36TTKf4Xi4lGTJJHHkLe GbGlvev0QSyYut7kR1o9/c4MzEobfLEev1T5YV8ty6C81+UMSPGqRytwl4ORlRDpX7Sn 9W9sM8LfmrfQCqiTWXXGZChl1oUs4pOX2wi5TwOmrT/BnkaUvNbK5fCnQinTJnnbOOkr x1qA== 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=rM9cczdSD7oo6JR4uUFyYK7Cy2OwQtFQT6O8YETL+gHhZZfMKE7y2R2cSuJlhF14Y8 vpibYnejg+h9WsEyWpo7f1b3YOnVkdxYzspjbKclaQYfGBC4BHkrP2gGNY2lJcJLK208 rQ9kgqnJUzlzhr+9RAaiunGkFdUg0bhLomVHoVzAK9/TIl+YuKauTHOuKLsfAS2ag5eu 2A1jvgD8uJ2GJHf/Xt1zcPEv2B04xHV3430C5qnY6ZqkJLPtC2Lw+uXlbtUjgXV/WIlX mrUWKFNLLhn6wVRp7Fli8/1w4mVWyImye3hoAe7qtH4r652a4hRQAA60deUTn6Xev/5C fdWg== X-Gm-Message-State: AGRZ1gK41R5djaFN1CbzqfC78MMrj//YKRm+Org/sZVWsgOyqYLpiKth A6mOouIFzCSg9RH/+HjgTNcim1lZ X-Google-Smtp-Source: AJdET5f3q2pM5N014v9sq0oZkZuTaJ+CoqOz3wvAeKsFUHXj4ne0G6PTwZbyoqi8jNHw/gy46folyQ== X-Received: by 2002:a37:ae06:: with SMTP id x6-v6mr3756794qke.238.1540411139695; Wed, 24 Oct 2018 12:58:59 -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 d124-v6sm3872380qkf.85.2018.10.24.12.58.58 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 24 Oct 2018 12:58:59 -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 v2 13/13] NFS COPY handle ERR_OFFLOAD_DENIED Date: Wed, 24 Oct 2018 15:58:37 -0400 Message-Id: <20181024195837.35532-15-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181024195837.35532-1-olga.kornievskaia@gmail.com> References: <20181024195837.35532-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@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;