From patchwork Thu Nov 1 16:45:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 991999 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nJnSADWt"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0C2NQwzB4Xs for ; Fri, 2 Nov 2018 03:45:31 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbeKBBtO (ORCPT ); Thu, 1 Nov 2018 21:49:14 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:41602 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbeKBBtN (ORCPT ); Thu, 1 Nov 2018 21:49:13 -0400 Received: by mail-oi1-f196.google.com with SMTP id y192-v6so1171741oie.8; Thu, 01 Nov 2018 09:45:28 -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=D3mPgmHbHiAVGsyI4bEkuzcTi5NVNKrpZPNiRWNG42w=; b=nJnSADWtHaea4xdoEqPiHKDdKo+UwFyowPrZA14q84oVjCZXeo/Kk4gqGp9ZWYUsQL GPuoU20WdlYpbms4x7+XP2KUDKu+pweyzTdldRXjCm0iRDiEurBhtpmbWbXud9gfx5+n X2s34I0Y1moM01PfNNR6a/PbP9Y6Iv6BZ1dZssLoNBSiXEBy7uItZnujMAq0FUEnuADj DVY6ezV9N8OWgWHGh3VHxFtM7vTijNQhvpoDO5Z/tj+eVRlA3E+dkTES8wtBerU9lkr+ hpwPwrBshQ+XeeA2BsXMZhJylSmUR/l3YLFsbnbJ1aFCyTaT/oIH4NsSNoExPUKGpsjQ A0Rw== 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=D3mPgmHbHiAVGsyI4bEkuzcTi5NVNKrpZPNiRWNG42w=; b=Cmf9CFfh6yh/sN5NouejtevK197q+7riYAgDw1JtMaMt7x37SUvo9x+cOqu75AkbLV FCCayf8AUMwkDIr7+QZFBPl0FefmqusHB1xCwPp9DL+O98PUKUGa7iYIf+jIwVrmWR/v gJ2zQFJQtdjfoiri8TI+YkjrgESah0B/hHhASgbpmS8gmwmxxD/F/w+E5vJdC6WTXZVL eoNYFHmjTcselrb8FftJtpxhMglm1rPhzaGYGYyirNcKwmsXKCyU+jccHSwks22HkBwM 7R/NdNHqIw6cJjGdXEaGVVZXpO8mFRsGLfnpVAhQuU9JhiE7wJQr/8buvKrMDsKmT4PX QyhQ== X-Gm-Message-State: AGRZ1gJrLh7Szq6UQCZh3Bs2kyYaVZ+jLiUufwoeEsFJFGKYO7B6aNNa LM38JjwDbeyjLjdJVGKGQL8= X-Google-Smtp-Source: AJdET5flcJQYypKlGae0AXgLWqygjhBxsndGUO1dcmJN3R8Zz+/hXNcB6LN9jQeJFuvWIAQj0pHubg== X-Received: by 2002:aca:ac90:: with SMTP id v138-v6mr1498862oie.70.1541090728444; Thu, 01 Nov 2018 09:45:28 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.27 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:27 -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 Subject: [PATCH v8 01/11] VFS: move cross device copy_file_range() check into filesystems Date: Thu, 1 Nov 2018 12:45:13 -0400 Message-Id: <20181101164523.41812-2-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia This patch makes it the responsibility of individual filesystems to allow or deny cross device copies. Both NFS and CIFS have operations for cross-server copies, and later patches will implement this feature. Note that as of this patch, the copy_file_range() function might be passed superblocks from different filesystem types. -EXDEV should be returned if cross device copies aren't supported. Reviewed-by: Amir Goldstein Reviewed-by: Matthew Wilcox Reviewed-by: Steve French Reviewed-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- Documentation/filesystems/porting | 7 +++++++ fs/cifs/cifsfs.c | 3 +++ fs/nfs/nfs4file.c | 3 +++ fs/overlayfs/file.c | 3 +++ fs/read_write.c | 13 ++++++++----- 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 7b7b845..897e1e7 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting @@ -622,3 +622,10 @@ in your dentry operations instead. alloc_file_clone(file, flags, ops) does not affect any caller's references. On success you get a new struct file sharing the mount/dentry with the original, on failure - ERR_PTR(). +-- +[mandatory] + ->copy_file_range() may now be passed files which belong to two + different superblocks of the same file system type or which belong + to two different filesystems types all together. As before, the + destination's copy_file_range() is the function which is called. + If it cannot copy ranges from the source, it should return -EXDEV. diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7065426..ca8fc87 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1114,6 +1114,9 @@ static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off, unsigned int xid = get_xid(); ssize_t rc; + if (file_inode(src_file)->i_sb != file_inode(dst_file)->i_sb) + return -EXDEV; + rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff, len, flags); free_xid(xid); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4288a6e..5a73c90 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -135,6 +135,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, { ssize_t ret; + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + return -EXDEV; + if (file_inode(file_in) == file_inode(file_out)) return -EINVAL; retry: diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index aeaefd2..0331e33 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -483,6 +483,9 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t len, unsigned int flags) { + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + return -EXDEV; + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags, OVL_COPY); } diff --git a/fs/read_write.c b/fs/read_write.c index 39b4a21..cfb1d10 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1575,10 +1575,6 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, (file_out->f_flags & O_APPEND)) return -EBADF; - /* this could be relaxed once a method supports cross-fs copies */ - if (inode_in->i_sb != inode_out->i_sb) - return -EXDEV; - if (len == 0) return 0; @@ -1588,7 +1584,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * Try cloning first, this is supported by more file systems, and * more efficient if both clone and copy are supported (e.g. NFS). */ - if (file_in->f_op->clone_file_range) { + if (inode_in->i_sb == inode_out->i_sb && + file_in->f_op->clone_file_range) { ret = file_in->f_op->clone_file_range(file_in, pos_in, file_out, pos_out, len); if (ret == 0) { @@ -1604,6 +1601,12 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, goto done; } + /* this could be relaxed once generic cross fs support is added */ + if (inode_in->i_sb != inode_out->i_sb) { + ret = -EXDEV; + goto done; + } + ret = do_splice_direct(file_in, &pos_in, file_out, &pos_out, len > MAX_RW_COUNT ? MAX_RW_COUNT : len, 0); From patchwork Thu Nov 1 16:45:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="u22ejWd2"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0D2mFDzB4Yg for ; Fri, 2 Nov 2018 03:45:32 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726329AbeKBBtP (ORCPT ); Thu, 1 Nov 2018 21:49:15 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46466 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbeKBBtP (ORCPT ); Thu, 1 Nov 2018 21:49:15 -0400 Received: by mail-ot1-f68.google.com with SMTP id q5so12884727otl.13; Thu, 01 Nov 2018 09:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Cqmt+GWWK9Zf9XynZ4EBj5J0CQZ2wW9XW6OcUaOzM2A=; b=u22ejWd2czfdVJMd7jlXKDxweqKqIWJhs6Y5oEI1d6GuOhQrYSS8GueptwnQxcH7Ap 1VqBIxMuhAxBPMj3VMDKyD4xg/blu3gdUPliG60X6bzt4RaHXKSqe1Q5wC4426Z6GDZ6 fuB2kaP26E1VE8u7OCyggXK+mqxe3kMZcO3XjCXye2PhiyBcNOdB2exhnOFOMIpwSJ5A 12h9YGakqXiB4NhvCA7def0Kvwf8BOcPivrHNp6k+fDr66tCAFfqyPhWos9Sq/Wzbwl8 naJZ+0i3WmbsiV4+CJp0uAxATRJIcYD8nuwlVTbsG+4jrT5KIwxiOXCeD3XXca57EXGd 3lcw== 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=Cqmt+GWWK9Zf9XynZ4EBj5J0CQZ2wW9XW6OcUaOzM2A=; b=uhsPJceUgI0EO7DMvX1EunYDgQ8jBsXIPpFVnmGeeQ3D+D7BpZh6anaBB72rA2wbjW yGDLXMBRx4NKc2i0WbQS2b0BEYvzHZ1hMtmHZYsYskQ5Ex8s2JXmOUkcWefidRfMRo+8 bla8avXufCZcixdeYgTecQgJ44P9nKJ7eJ/l3SrlC/OJ5vqz3QynGRzmdC5Z5vaf6rAe xe9E0+7WviFYmvUsyorHIKSmB0GC1mDzSX/YqJdUo2C1rcaPgkLEDpGsj+p354mde+mr t5BN0UIxeOmB95xE2mNYbfdAJ5kcVxtBTHTEu3OCsGHUmeGvm6vKa7LOBwN/iZ5RtKQ7 9PPA== X-Gm-Message-State: AGRZ1gIDZ9dfg9B1l1GMrzH/d6yHRNFqTm3r+fyYt9jl26DQ0bKzZl08 SOpLhkbDeDer5mqXWMkgUDc= X-Google-Smtp-Source: AJdET5cGypp/AfQBgxRJXWl68EMqmUg8aUfCbQ7vTYJpC83x6ycyoKUr39X+SKsBQbriJYvjk0Q9LA== X-Received: by 2002:a9d:7101:: with SMTP id n1mr4802680otj.236.1541090729888; Thu, 01 Nov 2018 09:45:29 -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 r62-v6sm1834301oig.14.2018.11.01.09.45.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:29 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH v8 02/11] NFS: validity check for source offset in copy_file_range Date: Thu, 1 Nov 2018 12:45:14 -0400 Message-Id: <20181101164523.41812-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia copy_file_range() man page mandates that EINVAL is returned if the specified range is beyond the end of the file but currently does not enforce it. NFS RFC 7832 states that "if the source offset or the source offset plus count is greater than the size of the source file, the operation MUST fail with NFS4ERR_INVAL." From the NFS community discussion from earlier on https://www.spinics.net/lists/linux-nfs/msg62627.html in was thought that offset plus count should instead be a short read. In this patch only proposing to enforce the offset check: Input source offset can not be beyond the end of the file. Future work in VFS might perform the arguments checks and we can remove this check. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 5a73c90..7838bdf 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -135,6 +135,9 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, { ssize_t ret; + if (pos_in >= i_size_read(file_inode(file_in))) + return -EINVAL; + if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) return -EXDEV; From patchwork Thu Nov 1 16:45:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="K2780E84"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0G2klRzB4Y1 for ; Fri, 2 Nov 2018 03:45:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbeKBBtR (ORCPT ); Thu, 1 Nov 2018 21:49:17 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:37200 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeKBBtQ (ORCPT ); Thu, 1 Nov 2018 21:49:16 -0400 Received: by mail-oi1-f194.google.com with SMTP id w66-v6so12838270oiw.4; Thu, 01 Nov 2018 09:45:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CNj2pCMxPlcH1fEKnenx/QqOVUgHVEB5Ekmf2YUbfVA=; b=K2780E84GyIin7wKGPVIzmorV99lwPhcc6X8CR40li/69a/Vj32gDdrqtWq4IIn/AK aXoGKTM8M7jQaS2oDqWEWMg2Ok33P0pYBOdTPad4Bkxy3ADJDnhWqNi3LIQ7JGNeBnr4 npfWXatpDUCKUmk+IbyOAkRak9Gl+p9aOSM0MnbtnkwjfrBBmMkm+0rpk95/MwGlJy6M 85CB7nTxGdSMKSfSNp5IknTgQ0KEmT23GbA65uBwGY5NSFnnbbqW+GYaFS7P7QmvPzWx ntFR+L4b48NvKQxUkepdJ/rgcw13j72KoBz8bgLd1GIbW47fvoryicX6jUcn/sh9pGGh AyZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CNj2pCMxPlcH1fEKnenx/QqOVUgHVEB5Ekmf2YUbfVA=; b=JYme/3SvTsls23r7MfNoWEP8uK54Om1Okes31UQGdaoM2tzxum7C/mcpXglUVJC52t q39pk5nLFRLjKf6sMnJAmjFMdzj8M+qhkZS1LX6KoI/rN486eJ+ctCbCmSNNCQA8HJOO 3nM9j9oZ6kHNwaUMGkGodyD74/Bo7rqILucENje7j8C5bL3edIsuJ1AP9jy5Vs1Ll0Zm ntGyHm5KpD0uT50RHOLQjzhcjKzVONA+L+8s4i2LdmSmyGz9jiw/fxcGt77Ca64XlnGG AN+oPISfaYtlgrzoqarG53y7qz6082xP2DEbbsl2pslohb4U8ssXEW0DONF24HrxgkD6 5xmw== X-Gm-Message-State: AGRZ1gJKSBlUsXJMePpbFlcw3cQdkt8sD3medNcuvVKg+0AzijrNQ10x yM+9HgQ7+uEv5qswF5+tGHOP4D9d X-Google-Smtp-Source: AJdET5f4ej7T0B3ZL73gYGzXleAQdv/CYNREp3bZ35qvy6eE6Pz1si1TRMvC92lB6d0zpXSLSc3PKg== X-Received: by 2002:a54:4188:: with SMTP id 8-v6mr5055357oiy.105.1541090731257; Thu, 01 Nov 2018 09:45:31 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.29 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:30 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH v8 03/11] NFS NFSD: defining nl4_servers structure needed by both Date: Thu, 1 Nov 2018 12:45:15 -0400 Message-Id: <20181101164523.41812-4-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia These structures are needed by COPY_NOTIFY on the client and needed by the nfsd as well Reviewed-by: Jeff Layton Signed-off-by: Olga Kornievskaia --- include/linux/nfs4.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 1b06f0b..4803507 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -16,6 +16,7 @@ #include #include #include +#include enum nfs4_acl_whotype { NFS4_ACL_WHO_NAMED = 0, @@ -672,4 +673,27 @@ struct nfs4_op_map { } u; }; +struct nfs42_netaddr { + char netid[RPCBIND_MAXNETIDLEN]; + char addr[RPCBIND_MAXUADDRLEN + 1]; + u32 netid_len; + u32 addr_len; +}; + +enum netloc_type4 { + NL4_NAME = 1, + NL4_URL = 2, + NL4_NETADDR = 3, +}; + +struct nl4_server { + enum netloc_type4 nl4_type; + union { + struct { /* NL4_NAME, NL4_URL */ + int nl4_str_sz; + char nl4_str[NFS4_OPAQUE_LIMIT + 1]; + }; + struct nfs42_netaddr nl4_addr; /* NL4_NETADDR */ + } u; +}; #endif From patchwork Thu Nov 1 16:45:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aN8YvgYf"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0H41W4zB4Yg for ; Fri, 2 Nov 2018 03:45:35 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726472AbeKBBtS (ORCPT ); Thu, 1 Nov 2018 21:49:18 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:35449 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbeKBBtS (ORCPT ); Thu, 1 Nov 2018 21:49:18 -0400 Received: by mail-oi1-f196.google.com with SMTP id v198-v6so14364779oif.2; Thu, 01 Nov 2018 09:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TmTBN4uYR/OzOuharXdrm7jaDJ4PtOKEa6zKLayvjVw=; b=aN8YvgYfLizGBr6AGXH8ZS1cW6CZigAoeiHHByatiJrEh76jxG3/OsDL9BVR3ufJ2q sBEXssLpN7eD0lT8EweJPCrjEmqU8qT0jgrQTvHOCujfTa3UCx2Rve9BNEA2okCwOwDf gXx9KCyVy5Ebn1jdWKsS7P1hI64t71U47plojbfY41sPvJQqkPy5Y1CHmvlctfiPmj+k EgxVN955Dqyk8a9vOXIXZKUwwosaUQsU+L9So2rhcLxMwD+jmM+6nceNFsRc+oR1m3sN MAg4FDfQqHNBnNJlMLtT1uD8D25OQTgReTCViMeIet77rb6DKtPXI0AMRdPlrax3cd0w GqGA== 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=TmTBN4uYR/OzOuharXdrm7jaDJ4PtOKEa6zKLayvjVw=; b=BWZY8ZB5RgzP2niXwVbnGhpJ6koqKcZt1s1esMj6eDAIwOzB7Lj8i2aR6BONV2ov5l lbxqbQCFGX9DB5mm2t7K+24XWyqCNsG5uu8fmnD0tMk2aU19s3CxUrNG7WQwz9CdQoMR dV36r+1XIOO/Om6hIqWWMVYZnie+mRY3cRKtb9jK5THfz7Qcbiif24SSNzoaxhhPOru9 2hrTp1dtV/2vY9YGYlV4/sk1PpHMrhoU85kN2MVQpoJZs8L6uId9AXpa/SfNmI8pVAU4 JWDc75bU+eYW6RGJwFuNeKW+3T95PNpAREygj7TpLi+LjmMSx8jOJarqgJNcTA/LChRE mEyQ== X-Gm-Message-State: AGRZ1gKdioeMtlk4rCbuKkeET+BSJnXno5AMFIX979P/wVE+/2N4/X9/ b+vEBNezzeLDv4Mc5NERzBnrYQq6 X-Google-Smtp-Source: AJdET5d6nJvOeReyOfYr9oDAX/9q8P0mkZR45ApAYFgMeozGHwr8qDINjX/PG2o4hCGUP5Re7i79jg== X-Received: by 2002:aca:5cc6:: with SMTP id q189-v6mr4965968oib.121.1541090732637; Thu, 01 Nov 2018 09:45:32 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.31 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:31 -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 Subject: [PATCH v8 04/11] NFS: add COPY_NOTIFY operation Date: Thu, 1 Nov 2018 12:45:16 -0400 Message-Id: <20181101164523.41812-5-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia Try using the delegation stateid, then the open stateid. Only NL4_NETATTR, No support for NL4_NAME and NL4_URL. Allow only one source server address to be returned for now. To distinguish between same server copy offload ("intra") and a copy between different server ("inter"), do a check of server owner identity and also make sure server is capable of doing a copy offload. Reviewed-by: Jeff Layton Signed-off-by: Andy Adamson Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42.h | 12 +++ fs/nfs/nfs42proc.c | 91 +++++++++++++++++++++++ fs/nfs/nfs42xdr.c | 181 ++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4_fs.h | 2 + fs/nfs/nfs4client.c | 2 +- fs/nfs/nfs4file.c | 17 +++++ 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, 324 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42.h b/fs/nfs/nfs42.h index 19ec38f8..bbe49a3 100644 --- a/fs/nfs/nfs42.h +++ b/fs/nfs/nfs42.h @@ -13,6 +13,7 @@ #define PNFS_LAYOUTSTATS_MAXDEV (4) /* nfs4.2proc.c */ +#ifdef CONFIG_NFS_V4_2 int nfs42_proc_allocate(struct file *, loff_t, loff_t); ssize_t nfs42_proc_copy(struct file *, loff_t, struct file *, loff_t, size_t); int nfs42_proc_deallocate(struct file *, loff_t, loff_t); @@ -20,5 +21,16 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *, struct nfs42_layoutstat_data *); int nfs42_proc_clone(struct file *, struct file *, loff_t, loff_t, loff_t); +int nfs42_proc_copy_notify(struct file *, struct file *, + struct nfs42_copy_notify_res *); +static inline bool nfs42_files_from_same_server(struct file *in, + struct file *out) +{ + struct nfs_client *c_in = (NFS_SERVER(file_inode(in)))->nfs_client; + struct nfs_client *c_out = (NFS_SERVER(file_inode(out)))->nfs_client; + return nfs4_check_serverowner_major_id(c_in->cl_serverowner, + c_out->cl_serverowner); +} +#endif /* CONFIG_NFS_V4_2 */ #endif /* __LINUX_FS_NFS_NFS4_2_H */ diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index ac5b784..b1c57a4 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -3,6 +3,7 @@ * Copyright (c) 2014 Anna Schumaker */ #include +#include #include #include #include @@ -15,10 +16,30 @@ #include "pnfs.h" #include "nfs4session.h" #include "internal.h" +#include "delegation.h" #define NFSDBG_FACILITY NFSDBG_PROC static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *std); +static void nfs42_set_netaddr(struct file *filep, struct nfs42_netaddr *naddr) +{ + struct nfs_client *clp = (NFS_SERVER(file_inode(filep)))->nfs_client; + unsigned short port = 2049; + + rcu_read_lock(); + naddr->netid_len = scnprintf(naddr->netid, + sizeof(naddr->netid), "%s", + rpc_peeraddr2str(clp->cl_rpcclient, + RPC_DISPLAY_NETID)); + naddr->addr_len = scnprintf(naddr->addr, + sizeof(naddr->addr), + "%s.%u.%u", + rpc_peeraddr2str(clp->cl_rpcclient, + RPC_DISPLAY_ADDR), + port >> 8, port & 255); + rcu_read_unlock(); +} + static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep, struct nfs_lock_context *lock, loff_t offset, loff_t len) { @@ -461,6 +482,76 @@ static int nfs42_do_offload_cancel_async(struct file *dst, return status; } +int _nfs42_proc_copy_notify(struct file *src, struct file *dst, + struct nfs42_copy_notify_args *args, + struct nfs42_copy_notify_res *res) +{ + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); + struct rpc_message msg = { + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY_NOTIFY], + .rpc_argp = args, + .rpc_resp = res, + }; + int status; + struct nfs_open_context *ctx; + struct nfs_lock_context *l_ctx; + + ctx = get_nfs_open_context(nfs_file_open_context(src)); + l_ctx = nfs_get_lock_context(ctx); + if (IS_ERR(l_ctx)) + return PTR_ERR(l_ctx); + + status = nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx, + FMODE_READ); + nfs_put_lock_context(l_ctx); + if (status) + return status; + + status = nfs4_call_sync(src_server->client, src_server, &msg, + &args->cna_seq_args, &res->cnr_seq_res, 0); + if (status == -ENOTSUPP) + src_server->caps &= ~NFS_CAP_COPY_NOTIFY; + + put_nfs_open_context(nfs_file_open_context(src)); + return status; +} + +int nfs42_proc_copy_notify(struct file *src, struct file *dst, + struct nfs42_copy_notify_res *res) +{ + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); + struct nfs42_copy_notify_args *args; + struct nfs4_exception exception = { + .inode = file_inode(src), + }; + int status; + + if (!(src_server->caps & NFS_CAP_COPY_NOTIFY)) + return -EOPNOTSUPP; + + args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_NOFS); + if (args == NULL) + return -ENOMEM; + + args->cna_src_fh = NFS_FH(file_inode(src)), + args->cna_dst.nl4_type = NL4_NETADDR; + nfs42_set_netaddr(dst, &args->cna_dst.u.nl4_addr); + exception.stateid = &args->cna_src_stateid; + + do { + status = _nfs42_proc_copy_notify(src, dst, args, res); + if (status == -ENOTSUPP) { + status = -EOPNOTSUPP; + goto out; + } + status = nfs4_handle_exception(src_server, status, &exception); + } while (exception.retry); + +out: + kfree(args); + return status; +} + static loff_t _nfs42_proc_llseek(struct file *filep, struct nfs_lock_context *lock, loff_t offset, int whence) { diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 69f72ed..e6e7cbf 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -29,6 +29,16 @@ #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \ XDR_QUADLEN(NFS4_STATEID_SIZE)) #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz) +#define encode_copy_notify_maxsz (op_encode_hdr_maxsz + \ + XDR_QUADLEN(NFS4_STATEID_SIZE) + \ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) +#define decode_copy_notify_maxsz (op_decode_hdr_maxsz + \ + 3 + /* cnr_lease_time */\ + XDR_QUADLEN(NFS4_STATEID_SIZE) + \ + 1 + /* Support 1 cnr_source_server */\ + 1 + /* nl4_type */ \ + 1 + XDR_QUADLEN(NFS4_OPAQUE_LIMIT)) #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \ encode_fallocate_maxsz) #define decode_deallocate_maxsz (op_decode_hdr_maxsz) @@ -84,6 +94,12 @@ #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ decode_offload_cancel_maxsz) +#define NFS4_enc_copy_notify_sz (compound_encode_hdr_maxsz + \ + encode_putfh_maxsz + \ + encode_copy_notify_maxsz) +#define NFS4_dec_copy_notify_sz (compound_decode_hdr_maxsz + \ + decode_putfh_maxsz + \ + decode_copy_notify_maxsz) #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_deallocate_maxsz + \ @@ -137,6 +153,25 @@ static void encode_allocate(struct xdr_stream *xdr, encode_fallocate(xdr, args); } +static void encode_nl4_server(struct xdr_stream *xdr, const struct nl4_server *ns) +{ + encode_uint32(xdr, ns->nl4_type); + switch (ns->nl4_type) { + case NL4_NAME: + case NL4_URL: + encode_string(xdr, ns->u.nl4_str_sz, ns->u.nl4_str); + break; + case NL4_NETADDR: + encode_string(xdr, ns->u.nl4_addr.netid_len, + ns->u.nl4_addr.netid); + encode_string(xdr, ns->u.nl4_addr.addr_len, + ns->u.nl4_addr.addr); + break; + default: + WARN_ON_ONCE(1); + } +} + static void encode_copy(struct xdr_stream *xdr, const struct nfs42_copy_args *args, struct compound_hdr *hdr) @@ -162,6 +197,15 @@ static void encode_offload_cancel(struct xdr_stream *xdr, encode_nfs4_stateid(xdr, &args->osa_stateid); } +static void encode_copy_notify(struct xdr_stream *xdr, + const struct nfs42_copy_notify_args *args, + struct compound_hdr *hdr) +{ + encode_op_hdr(xdr, OP_COPY_NOTIFY, decode_copy_notify_maxsz, hdr); + encode_nfs4_stateid(xdr, &args->cna_src_stateid); + encode_nl4_server(xdr, &args->cna_dst); +} + static void encode_deallocate(struct xdr_stream *xdr, const struct nfs42_falloc_args *args, struct compound_hdr *hdr) @@ -298,6 +342,25 @@ static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req, } /* + * Encode COPY_NOTIFY request + */ +static void nfs4_xdr_enc_copy_notify(struct rpc_rqst *req, + struct xdr_stream *xdr, + const void *data) +{ + const struct nfs42_copy_notify_args *args = data; + struct compound_hdr hdr = { + .minorversion = nfs4_xdr_minorversion(&args->cna_seq_args), + }; + + encode_compound_hdr(xdr, req, &hdr); + encode_sequence(xdr, &args->cna_seq_args, &hdr); + encode_putfh(xdr, args->cna_src_fh, &hdr); + encode_copy_notify(xdr, args, &hdr); + encode_nops(&hdr); +} + +/* * Encode DEALLOCATE request */ static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req, @@ -416,6 +479,58 @@ static int decode_write_response(struct xdr_stream *xdr, return -EIO; } +static int decode_nl4_server(struct xdr_stream *xdr, struct nl4_server *ns) +{ + struct nfs42_netaddr *naddr; + uint32_t dummy; + char *dummy_str; + __be32 *p; + int status; + + /* nl_type */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + return -EIO; + ns->nl4_type = be32_to_cpup(p); + switch (ns->nl4_type) { + case NL4_NAME: + case NL4_URL: + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > NFS4_OPAQUE_LIMIT)) + return -EIO; + memcpy(&ns->u.nl4_str, dummy_str, dummy); + ns->u.nl4_str_sz = dummy; + break; + case NL4_NETADDR: + naddr = &ns->u.nl4_addr; + + /* netid string */ + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > RPCBIND_MAXNETIDLEN)) + return -EIO; + naddr->netid_len = dummy; + memcpy(naddr->netid, dummy_str, naddr->netid_len); + + /* uaddr string */ + status = decode_opaque_inline(xdr, &dummy, &dummy_str); + if (unlikely(status)) + return status; + if (unlikely(dummy > RPCBIND_MAXUADDRLEN)) + return -EIO; + naddr->addr_len = dummy; + memcpy(naddr->addr, dummy_str, naddr->addr_len); + break; + default: + WARN_ON_ONCE(1); + return -EIO; + } + return 0; +} + static int decode_copy_requirements(struct xdr_stream *xdr, struct nfs42_copy_res *res) { __be32 *p; @@ -458,6 +573,46 @@ static int decode_offload_cancel(struct xdr_stream *xdr, return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL); } +static int decode_copy_notify(struct xdr_stream *xdr, + struct nfs42_copy_notify_res *res) +{ + __be32 *p; + int status, count; + + status = decode_op_hdr(xdr, OP_COPY_NOTIFY); + if (status) + return status; + /* cnr_lease_time */ + p = xdr_inline_decode(xdr, 12); + if (unlikely(!p)) + goto out_overflow; + p = xdr_decode_hyper(p, &res->cnr_lease_time.seconds); + res->cnr_lease_time.nseconds = be32_to_cpup(p); + + status = decode_opaque_fixed(xdr, &res->cnr_stateid, NFS4_STATEID_SIZE); + if (unlikely(status)) + goto out_overflow; + + /* number of source addresses */ + p = xdr_inline_decode(xdr, 4); + if (unlikely(!p)) + goto out_overflow; + + count = be32_to_cpup(p); + if (count > 1) + pr_warn("NFS: %s: nsvr %d > Supported. Use first servers\n", + __func__, count); + + status = decode_nl4_server(xdr, &res->cnr_src); + if (unlikely(status)) + goto out_overflow; + return 0; + +out_overflow: + print_overflow_msg(__func__, xdr); + return -EIO; +} + static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_DEALLOCATE); @@ -585,6 +740,32 @@ static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp, } /* + * Decode COPY_NOTIFY response + */ +static int nfs4_xdr_dec_copy_notify(struct rpc_rqst *rqstp, + struct xdr_stream *xdr, + void *data) +{ + struct nfs42_copy_notify_res *res = data; + struct compound_hdr hdr; + int status; + + status = decode_compound_hdr(xdr, &hdr); + if (status) + goto out; + status = decode_sequence(xdr, &res->cnr_seq_res, rqstp); + if (status) + goto out; + status = decode_putfh(xdr); + if (status) + goto out; + status = decode_copy_notify(xdr, res); + +out: + return status; +} + +/* * Decode DEALLOCATE request */ static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp, diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 8d59c96..7d17b31 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -460,6 +460,8 @@ int nfs41_discover_server_trunking(struct nfs_client *clp, struct nfs_client **, struct rpc_cred *); extern void nfs4_schedule_session_recovery(struct nfs4_session *, int); extern void nfs41_notify_server(struct nfs_client *); +bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, + struct nfs41_server_owner *o2); #else static inline void nfs4_schedule_session_recovery(struct nfs4_session *session, int err) { diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 8f53455..ac00eb8 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -625,7 +625,7 @@ int nfs40_walk_client_list(struct nfs_client *new, /* * Returns true if the server major ids match */ -static bool +bool nfs4_check_serverowner_major_id(struct nfs41_server_owner *o1, struct nfs41_server_owner *o2) { diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 7838bdf..42ce562 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -133,6 +133,7 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, size_t count, unsigned int flags) { + struct nfs42_copy_notify_res *cn_resp = NULL; ssize_t ret; if (pos_in >= i_size_read(file_inode(file_in))) @@ -143,8 +144,24 @@ 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; + + if (!nfs_server_capable(file_inode(file_out), NFS_CAP_COPY)) + return -EOPNOTSUPP; retry: + if (!nfs42_files_from_same_server(file_in, file_out)) { + cn_resp = kzalloc(sizeof(struct nfs42_copy_notify_res), + GFP_NOFS); + if (unlikely(cn_resp == NULL)) + return -ENOMEM; + + ret = nfs42_proc_copy_notify(file_in, file_out, cn_resp); + if (ret) + goto out; + } + ret = nfs42_proc_copy(file_in, pos_in, file_out, pos_out, count); +out: + kfree(cn_resp); if (ret == -EAGAIN) goto retry; return ret; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index db84b4a..fec6e6b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9692,6 +9692,7 @@ static bool nfs4_match_stateid(const nfs4_stateid *s1, | NFS_CAP_ALLOCATE | NFS_CAP_COPY | NFS_CAP_OFFLOAD_CANCEL + | NFS_CAP_COPY_NOTIFY | NFS_CAP_DEALLOCATE | NFS_CAP_SEEK | NFS_CAP_LAYOUTSTATS diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index b7bde12..2163900 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -7790,6 +7790,7 @@ int nfs4_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry, PROC42(CLONE, enc_clone, dec_clone), PROC42(COPY, enc_copy, dec_copy), PROC42(OFFLOAD_CANCEL, enc_offload_cancel, dec_offload_cancel), + PROC42(COPY_NOTIFY, enc_copy_notify, dec_copy_notify), PROC(LOOKUPP, enc_lookupp, dec_lookupp), }; diff --git a/include/linux/nfs4.h b/include/linux/nfs4.h index 4803507..9e49a6c 100644 --- a/include/linux/nfs4.h +++ b/include/linux/nfs4.h @@ -537,6 +537,7 @@ enum { NFSPROC4_CLNT_CLONE, NFSPROC4_CLNT_COPY, NFSPROC4_CLNT_OFFLOAD_CANCEL, + NFSPROC4_CLNT_COPY_NOTIFY, NFSPROC4_CLNT_LOOKUPP, }; diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index 0fc0b91..e5d89ff 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -261,5 +261,6 @@ struct nfs_server { #define NFS_CAP_CLONE (1U << 23) #define NFS_CAP_COPY (1U << 24) #define NFS_CAP_OFFLOAD_CANCEL (1U << 25) +#define NFS_CAP_COPY_NOTIFY (1U << 26) #endif diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 0e01625..dfc59bc 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1428,6 +1428,22 @@ struct nfs42_offload_status_res { int osr_status; }; +struct nfs42_copy_notify_args { + struct nfs4_sequence_args cna_seq_args; + + struct nfs_fh *cna_src_fh; + nfs4_stateid cna_src_stateid; + struct nl4_server cna_dst; +}; + +struct nfs42_copy_notify_res { + struct nfs4_sequence_res cnr_seq_res; + + struct nfstime4 cnr_lease_time; + nfs4_stateid cnr_stateid; + struct nl4_server cnr_src; +}; + struct nfs42_seek_args { struct nfs4_sequence_args seq_args; From patchwork Thu Nov 1 16:45:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N8eHZt5a"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0K0KVjzB4Yk for ; Fri, 2 Nov 2018 03:45:37 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbeKBBtU (ORCPT ); Thu, 1 Nov 2018 21:49:20 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:43107 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeKBBtT (ORCPT ); Thu, 1 Nov 2018 21:49:19 -0400 Received: by mail-oi1-f194.google.com with SMTP id j202-v6so16710418oih.10; Thu, 01 Nov 2018 09:45:34 -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=lG51Qo4JNhN7C9mQgeI5pvogPKAmVec6WVzS70dRjiw=; b=N8eHZt5asZIKc6kWrDyHzt4DEmwZXAbxGcpYxqcBFGA1oHy03HhrEXO01Qyb2wDjJh 0o4Pnl3Jowchwd/y80doKaTJ5r+38DHFSDp224jUl4Jq2jwO/ZAF/e4nAYCk39PJwZjL AsGsGz5LP7uNthrCwlbMHOvzM/DpVm0HOjrPee1dIGp/FJWWVGLjkGP1Gq1cwYdN5Aqe oT6ludhFVq+HdhnUUD7x59+QrT088uIL2sSmbSi6d/VS06eDKxt4zZJUqd8zjMXNGI92 +gCgOCyWnyW1r2Rm+pwyxkH4AI/c9Dfzq+O4f0CYdLdIKcqjq2YvOpiszLCgWmLKYM2q IP3Q== 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=lG51Qo4JNhN7C9mQgeI5pvogPKAmVec6WVzS70dRjiw=; b=L0fAsWQg3ZqMtSeR6kHaKd2Y3JUMQjEFH2QykL0dWG8zSDK9gC0VKMzE1Tk4kz02FV +LqHDexp2Ggjk9V+5T+bLQKxE59GZc3KN8/TEiCVYlkvDMzwaawBhKUjT3xYiwrXCGZf 79wzhflK+gQGFFYAhQg3vpAef7AFeNM3rvwLj64xg0ZnFHUvBBq4JAxRotz8ivDzYLLQ IHe5DX+T7vO976/Y5G7OcxWL/GUUcgxJI4ZBprOuAYOt8MourCDU84Zzap/lyoSlpw/c X/dM45egObTkOQEBWpKSIjx5YaHuN3A7z6AGBi4ziwc6njmEA2CX8kRGb4/qM0soYl5t l90g== X-Gm-Message-State: AGRZ1gLX435Gho49aqJw6L126NZh9N3qT/RMWbPx51zHcPD2TD2tl3cq U8eG5rj25wRBRezR4UDlKuY= X-Google-Smtp-Source: AJdET5fkcaTIY0FuBRWmYOwiEDLBB+oOJmCivvyOjARXYugx18vJRRsPI8lUJFz08yxIkrNOPILXYw== X-Received: by 2002:aca:5158:: with SMTP id f85-v6mr4968709oib.72.1541090734138; Thu, 01 Nov 2018 09:45:34 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.32 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:33 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH v8 05/11] NFS: add ca_source_server<> to COPY Date: Thu, 1 Nov 2018 12:45:17 -0400 Message-Id: <20181101164523.41812-6-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 42ce562..18f5421 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -134,6 +134,8 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, size_t count, unsigned int flags) { struct nfs42_copy_notify_res *cn_resp = NULL; + struct nl4_server *nss = NULL; + nfs4_stateid *cnrs = NULL; ssize_t ret; if (pos_in >= i_size_read(file_inode(file_in))) @@ -157,9 +159,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 Thu Nov 1 16:45:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992004 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="HJvlXEJL"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0N52NyzB4Yg for ; Fri, 2 Nov 2018 03:45:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726564AbeKBBtV (ORCPT ); Thu, 1 Nov 2018 21:49:21 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:33320 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726464AbeKBBtU (ORCPT ); Thu, 1 Nov 2018 21:49:20 -0400 Received: by mail-ot1-f66.google.com with SMTP id q1so8883022otk.0; Thu, 01 Nov 2018 09:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DqnHnZrMSvA0or48b6pnWzyYDz4iWYc8+TMTuA2+K94=; b=HJvlXEJL0wyQxADnmUn/wBOr9CopicZ9Ch5qLBQ2vRPpVF/awGnSxu2Qd/TyVsZrjo il29p6hpDvz5TNUXiM0kSqQanHvdsAwS4+/+zcodJvNwSW9qBTwI71nHJGarLy8BuXEF /2zF+kotyS2OdOGoREeV5u8jRtSxDu2U6EGU5RZKd2ztPEqxzJebVnFrM4bMPfIWwhXk E8sgdHS/ZLEGL3HH/6JlMDZFr16qQZmPuS8XegBYmx182LcfhviCssYdTP8WzIcRhnVS 9lHsl6KOmv7uZjQo29trioBRWt3egNUo6da6u27dWHJlCSoskylXvDhP/133k5M7F2D1 6ofA== 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=JQ+qjF1GhUCz/sZXJtf2iHfoyzE5Qw8jtnezPlCPLoqDlQsFK8/QxUp6BRF9A+VrHX +5UqDFNrOld0nEZ/+fFMrlk7O5dSOIXd4iMEvoHkdf08qmiRHrARXDT5HyzKrI+YcThz Nkdhes72Z/JuZdd4hhTsaz9vUhvkx2mV0qvKXsr+HGlMc2eApUHF9m6v1cr5asapVMzO kat5T/WYRlKH7ag2gCtJ6o6fEIxtrGOrgfqsswmY/UqE1///VL1BEfAP8s2uBNtDyL3/ a1iKv0v4SzRWAaVF4cp5dcp+VmHK4sQR58T5nUajEhj4T3HvBa8gHz0cSBKdD0o9wIY8 PohQ== X-Gm-Message-State: AGRZ1gLFuddlSEIUmEIAm6crqG0ZGSNmlWe5BNK5gycS9t/Uii2nsIsj xWMLMFgXH6hSRd+7jcVZpZg= X-Google-Smtp-Source: AJdET5fAdMIM6pYUuJeLVzFZh5ySPXFV5LA0jIl/y8KgP2ZmIQFqzzzYYuy08Oh4KpPHTR3GHrYJXQ== X-Received: by 2002:a9d:6511:: with SMTP id i17mr5272361otl.358.1541090735659; Thu, 01 Nov 2018 09:45:35 -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 r62-v6sm1834301oig.14.2018.11.01.09.45.34 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:34 -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 Subject: [PATCH v8 06/11] NFS: also send OFFLOAD_CANCEL to source server Date: Thu, 1 Nov 2018 12:45:18 -0400 Message-Id: <20181101164523.41812-7-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 Thu Nov 1 16:45:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992005 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ntXARJkq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0Q1SHqzB4Y1 for ; Fri, 2 Nov 2018 03:45:42 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbeKBBtX (ORCPT ); Thu, 1 Nov 2018 21:49:23 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:39622 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbeKBBtW (ORCPT ); Thu, 1 Nov 2018 21:49:22 -0400 Received: by mail-oi1-f194.google.com with SMTP id e3-v6so17144554oiy.6; Thu, 01 Nov 2018 09:45:37 -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=JEMEIDCmJwKjFzu3KxfJmPhagUzEAs3md5Oe8AEnHgY=; b=ntXARJkqjKIe0AMXi2ZgneWDFoslpLavVnHUgH2eu4AA6fvGt+yWxvZO5vyIaMCpG3 opY8KMqsBfP4q9CXyhksoibKFO7ewGyZn/DeJuxrAlnSilAcLJwlH8QyEhqDWTOTMyxW HiZeDM0xuR2iPbnhQZN9qMbkoEvrDjAlP2mBu5HfVcwzYm5/2zo9z20nDDweIpha7k2Q j4OvDkdN1bRvUe91ewiHpXNs89xno6bVaFZkCwAIaJMQ6e51Ua3+lZshPFMzWyWrJwOd OpAzhvFMkOr6srBjDOH1EDCPzoIjTvH3+CnKEOaq0JFUhF5MCBg0iUZvxBRRwPKTYJuM qebQ== 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=JEMEIDCmJwKjFzu3KxfJmPhagUzEAs3md5Oe8AEnHgY=; b=LtwKJTk+F3ccUPHRP9+7UJcfdydkGu/I6igzv5oZEvKJ07+RmGrvRLfOOz9COMxGOc gbDNcwmIsEgqtzmyaIBt685QJhDHss/2rBX7blIVGLX3XDubo2+d4hb4EYI0SRnc2Pki MmnkZ7KbM44TD1euJ8pLYMZ7aQXJp8LryfOqqVYC/XuIYv/fYhDqR7quVTy7j24mO0Ll uYLGdYGskQXEGCIinqNzAZwkjTJslDtDk1yQIQlmzEueaED9Wt71kbKoGwyugGKxESyy GW1r5ga8EEIOMW9c7AXWwmAv2KZwSHt/GKxlFztYN/3XZCZN6SdrSY6Lj36ToYWWlj2P D25g== X-Gm-Message-State: AGRZ1gLJ4OYsvxXY2IiUJVNVD1dfWwiLRp1Aor/COYAxNcHCA+x38vcw GSLo1TTmLF1JdhKCQ0shbLQ= X-Google-Smtp-Source: AJdET5coY53WAVesl3qf3WiEQH+VK5fQDHhYcIqxz3NN18lwjLdoNQX9kKoPdkpIVJ6G5KoM27Sprw== X-Received: by 2002:aca:f50b:: with SMTP id t11-v6mr5005218oih.57.1541090736936; Thu, 01 Nov 2018 09:45:36 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.35 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:36 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH v8 07/11] NFS: inter ssc open Date: Thu, 1 Nov 2018 12:45:19 -0400 Message-Id: <20181101164523.41812-8-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia NFSv4.2 inter server to server copy requires the destination server to READ the data from the source server using the provided stateid and file handle. Given an NFSv4 stateid and filehandle from the COPY operaion, provide the destination server with an NFS client function to create a struct file suitable for the destiniation server to READ the data to be copied. Signed-off-by: Olga Kornievskaia Signed-off-by: Andy Adamson --- fs/nfs/nfs4_fs.h | 7 +++++ fs/nfs/nfs4file.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/nfs4proc.c | 5 ++- 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 7d17b31..9c566a4 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -307,6 +307,13 @@ extern int nfs4_set_rw_stateid(nfs4_stateid *stateid, const struct nfs_open_context *ctx, const struct nfs_lock_context *l_ctx, fmode_t fmode); +extern int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, + struct nfs_fattr *fattr, struct nfs4_label *label, + struct inode *inode); +extern int update_open_stateid(struct nfs4_state *state, + const nfs4_stateid *open_stateid, + const nfs4_stateid *deleg_stateid, + fmode_t fmode); #if defined(CONFIG_NFS_V4_1) extern int nfs41_sequence_done(struct rpc_task *, struct nfs4_sequence_res *); diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 18f5421..df468a2 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" @@ -270,6 +271,99 @@ static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, out: return ret; } + +static int read_name_gen = 1; +#define SSC_READ_NAME_BODY "ssc_read_%d" + +struct file * +nfs42_ssc_open(struct vfsmount *ss_mnt, struct nfs_fh *src_fh, + nfs4_stateid *stateid) +{ + struct nfs_fattr fattr; + struct file *filep, *res; + struct nfs_server *server; + struct inode *r_ino = NULL; + struct nfs_open_context *ctx; + struct nfs4_state_owner *sp; + char *read_name; + int len, status = 0; + + server = NFS_SERVER(ss_mnt->mnt_root->d_inode); + + nfs_fattr_init(&fattr); + + status = nfs4_proc_getattr(server, src_fh, &fattr, NULL, NULL); + if (status < 0) { + res = ERR_PTR(status); + goto out; + } + + res = ERR_PTR(-ENOMEM); + len = strlen(SSC_READ_NAME_BODY) + 16; + read_name = kzalloc(len, GFP_NOFS); + if (read_name == NULL) + goto out; + snprintf(read_name, len, SSC_READ_NAME_BODY, read_name_gen++); + + r_ino = nfs_fhget(ss_mnt->mnt_root->d_inode->i_sb, src_fh, &fattr, + NULL); + if (IS_ERR(r_ino)) { + res = ERR_CAST(r_ino); + goto out; + } + + filep = alloc_file_pseudo(r_ino, ss_mnt, read_name, FMODE_READ, + r_ino->i_fop); + if (IS_ERR(filep)) { + res = ERR_CAST(filep); + goto out; + } + filep->f_mode |= FMODE_READ; + + ctx = alloc_nfs_open_context(filep->f_path.dentry, filep->f_mode, + filep); + if (IS_ERR(ctx)) { + res = ERR_CAST(ctx); + goto out_filep; + } + + res = ERR_PTR(-EINVAL); + sp = nfs4_get_state_owner(server, ctx->cred, GFP_KERNEL); + if (sp == NULL) + goto out_ctx; + + ctx->state = nfs4_get_open_state(r_ino, sp); + if (ctx->state == NULL) + goto out_stateowner; + + set_bit(NFS_OPEN_STATE, &ctx->state->flags); + memcpy(&ctx->state->open_stateid.other, &stateid->other, + NFS4_STATEID_OTHER_SIZE); + update_open_stateid(ctx->state, stateid, NULL, filep->f_mode); + + nfs_file_set_open_context(filep, ctx); + put_nfs_open_context(ctx); + + file_ra_state_init(&filep->f_ra, filep->f_mapping->host->i_mapping); + res = filep; +out: + return res; +out_stateowner: + nfs4_put_state_owner(sp); +out_ctx: + put_nfs_open_context(ctx); +out_filep: + fput(filep); + goto out; +} +EXPORT_SYMBOL_GPL(nfs42_ssc_open); +void nfs42_ssc_close(struct file *filep) +{ + struct nfs_open_context *ctx = nfs_file_open_context(filep); + + ctx->state->flags = 0; +} +EXPORT_SYMBOL_GPL(nfs42_ssc_close); #endif /* CONFIG_NFS_V4_2 */ const struct file_operations nfs4_file_operations = { diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index fec6e6b..e5178b2f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -91,7 +91,6 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data); static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr); -static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode); static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode); static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred, struct nfs_fattr *fattr, struct iattr *sattr, @@ -1653,7 +1652,7 @@ static void nfs_state_clear_delegation(struct nfs4_state *state) write_sequnlock(&state->seqlock); } -static int update_open_stateid(struct nfs4_state *state, +int update_open_stateid(struct nfs4_state *state, const nfs4_stateid *open_stateid, const nfs4_stateid *delegation, fmode_t fmode) @@ -3936,7 +3935,7 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0); } -static int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, +int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode) { From patchwork Thu Nov 1 16:45:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992009 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WBbuc9jA"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0T6F2vzB4Yj for ; Fri, 2 Nov 2018 03:45:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726712AbeKBBt3 (ORCPT ); Thu, 1 Nov 2018 21:49:29 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:46479 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbeKBBtX (ORCPT ); Thu, 1 Nov 2018 21:49:23 -0400 Received: by mail-ot1-f65.google.com with SMTP id q5so12885153otl.13; Thu, 01 Nov 2018 09:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Ld/1Zld8R8avZQSZVI4eRsvqLOCfV8kYBvr9LN+UEk=; b=WBbuc9jAU3zoI9kkwxv83TsMqaucABDyHmqySUvUN0dpMGJw/FN5EycieSMHxL3rkR Ml032JCGhLsjK3KhYNTaZxH5ZbIWf/zhPB0i7Wz9V6Epfj8l54ueYgg8gkDbkE92rcoj CdWffRqkygejcKUYXN+y/JYLDflkmLF2JDuGeMLbE3h7uuBX3Sn2FICGWWwGv84mQvQV UZItT5iT81X7JicZJVYWgsX1T4p9P74GCiZAJ4/UKtr9WG9lVpDfjg81h6dz8mcCBZF+ Bm8csGEKhxgToddnYnm+8vy3wtOY4fvAnTVzzAXQahwq4W6p+6bxT7Jx/h7bqyh9LmsL xAUA== 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=0Ld/1Zld8R8avZQSZVI4eRsvqLOCfV8kYBvr9LN+UEk=; b=uLl0IzCtZvk01EjdROqefIO3SW9iOgODd6Y0XuqYKAWvkbKd0N9X7cq+rT+i5Wqhcn Nv9QWjH/DqZwFm4mJXmTk8rs7aDtpqQqU3ihnEjtZGCmvnpdzbP1XFuWGUKKBsM14OR7 CxOW8XKLZNOh2NDUW/os7uaBiZfTvC9XMu2SkVX3OhBgejS1Lrxsl8HZmFCqAqRZULHE 5BrqqNS4i6XGllNnDQPkoLx5kXKcfomgeFRsqF0fsZg72Y9dxEC+FoT47WyJYTgSEbgX QGf4iLjpwhzE3L7vtdQiuAQxk87B/xfHo7b15NP/f3eaN3lgzqGtrJfI8DOUFi4iTb3j IgBQ== X-Gm-Message-State: AGRZ1gKqRMxPtuUYpw/GY7SIniiGy3pJOgM72kXvCoYJo1k8T33mIzIJ w5brSHRsz6+0Pfl4z8JEdYyDZVc7 X-Google-Smtp-Source: AJdET5eczrCIL6ile6u1lPdq/OP7hdZbDjlORERi4VS35oN6Qo37XIDMZuP99yDtWIPNmKoGY5CI6g== X-Received: by 2002:a9d:30c2:: with SMTP id r2mr5173899otg.53.1541090738435; Thu, 01 Nov 2018 09:45:38 -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 r62-v6sm1834301oig.14.2018.11.01.09.45.36 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:37 -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 Subject: [PATCH v8 08/11] NFS: skip recovery of copy open on dest server Date: Thu, 1 Nov 2018 12:45:20 -0400 Message-Id: <20181101164523.41812-9-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org 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 df468a2..12c34b3 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -336,6 +336,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 Thu Nov 1 16:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992006 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="WgjdqWRZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0R1by5zB4Yg for ; Fri, 2 Nov 2018 03:45:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726693AbeKBBtZ (ORCPT ); Thu, 1 Nov 2018 21:49:25 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:39716 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726580AbeKBBtY (ORCPT ); Thu, 1 Nov 2018 21:49:24 -0400 Received: by mail-ot1-f68.google.com with SMTP id g27so5448469oth.6; Thu, 01 Nov 2018 09:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7UYm6KwHepkUcFRejYDPg8EOERI1MmALOURzx0oOqU8=; b=WgjdqWRZSBCk+y5XNGR0Oxbe9YV13LTKQ1xpaqzswAD4/Y3/ffLJHwVDUjjngUKOGy e1Rdno1U9cCxOqgcTjMQ4qOS68CblAF0t4zqMk+a3n801BKXGq5iI94o5EeyLJ0co3JZ nPC44N5V0hDoDrs5K1Io1F+oBCPfmvqiTrEdOfCHwHr40qKcFGPDeLts5y3UDTGc8DiV WLF5K9itYHe/LcdhtjYRUSuSG8Hoda9e41Die3jrcbXvfvCzJ3SZS9Il7DLhs4HuqK6n HGIs5/IKrzbw1zqRRu3SJpvu8o0MkRqalTztr5V8ReQTrFiv1N95Yq3iGCuqiQgO8IGI +ixA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7UYm6KwHepkUcFRejYDPg8EOERI1MmALOURzx0oOqU8=; b=RD/zMhdITBznT48KXJrEhHW0zJuM0b2StVzJxUuvd6x15NMN2Z0uM3A3vpI37ZNhzf tiEjWDv1kWqbZpyZURTHgsgfNxdSQRUP7v6MOa7uK/5X9ZQKt5MxzXH7AFHDqSZtsgbb aKcd610HjY8/CRCoftuwZQJ4zs96DIJfDYWaY8O2G0sLwE2E555QwKTdXyFb2Bx6V368 YgLBdWx/b2kzKHe+AVxYYOLY5dE1nQBuoWlkWY3oJwyRiE4mfJRrUWz7NYjtPLB5QA3r 2btw2u5T5uXd9lS4u61Da6nviiA2MR2TrGhIRZRPFtV6lyCQjDjZUAr7GUxlAeLFqto0 9UcA== X-Gm-Message-State: AGRZ1gKKn1BhQnOPfebVy7B3OOHtVddQXwV4C3+pF9bFvpCoNUFFzfWM 1j1xc8oTyexB9qvVq6n09Nc= X-Google-Smtp-Source: AJdET5eI5m7Br4MHgBECKZMotd5GHotg+IJd2r7J3teZ1Qshkz8UYwxDnva7SXXf+QcpHEK1F4u2Vw== X-Received: by 2002:a9d:17e9:: with SMTP id j96mr5323937otj.34.1541090739670; Thu, 01 Nov 2018 09:45:39 -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 r62-v6sm1834301oig.14.2018.11.01.09.45.38 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:39 -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 Subject: [PATCH v8 09/11] NFS: for "inter" copy treat ESTALE as ENOTSUPP Date: Thu, 1 Nov 2018 12:45:21 -0400 Message-Id: <20181101164523.41812-10-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia If the client sends an "inter" copy to the destination server but it only supports "intra" copy, it can return ESTALE (since it doesn't know anything about the file handle from the other server and does not recognize the special case of "inter" copy). Translate this error as ENOTSUPP and also send OFFLOAD_CANCEL to the source server so that it can clean up state. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 98fe00b..00809b3 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -395,6 +395,11 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry = 1; continue; + } else if (err == -ESTALE && + !nfs42_files_from_same_server(src, dst)) { + nfs42_do_offload_cancel_async(src, &args.src_stateid); + err = -EOPNOTSUPP; + break; } err2 = nfs4_handle_exception(server, err, &src_exception); From patchwork Thu Nov 1 16:45:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992007 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="syGNnlih"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0R753xzB4Y1 for ; Fri, 2 Nov 2018 03:45:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbeKBBt0 (ORCPT ); Thu, 1 Nov 2018 21:49:26 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:46389 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbeKBBtZ (ORCPT ); Thu, 1 Nov 2018 21:49:25 -0400 Received: by mail-oi1-f196.google.com with SMTP id k64-v6so17122310oia.13; Thu, 01 Nov 2018 09:45:41 -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=syGNnlihDkFdEtO/6CTLrG9vXXYlNGx2N4uhly/4Ghj/EHrih9UXpFOqLQLWcqjp4D dbdfQzqfC/1j2nAwtek4muoyBVGJ7uNt5cQiHYY/d/5CSVxMqgISR7pgE3PIl9red4j3 IWCMVwpecTHZMymAfvJoDCab3P8xSSczuUcX5vxkoLuFZj9fVQCa36PZr3Wvd3LAFaDL KtkFOxDIoJ55K5BezOGh2wUWwpgJezROWkXQDvcbARFMh2wy8lLCLXgdMvorkWjv0sST OD/yts9RZxeSNBav/aJBrc8USdABG1PVmoCOPeNpSAiK4gbH0RhKUok22ZQXmeVBRDr8 hznw== 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=FZu1b5hT0n9NzOwmlUhtOSaecY9kFtoCOFkbx4gz7CfTKS9CUc4ZUZuRsEyYn7Rr2R /aEGP6W9s+9JsfHXtEU3oYFoJFrW9ed1Nv++f1yJOAL4zMbfBQ88ZsspSkfAVbsnvVGm Y13Pbu7cYxr0m1Z63gqwf2yGz8oHk8ugzYXG0Afdp0uv/FpAM8TVl3XYT4XPhKxnnzAr 6rCMRqrvRBWz+DxOmEq+noWvVQsPWR1c8CEaztZcJgOHKd6I8VGSjABaA4rx4BW0Zm+V g6f6e3D83U2HWVGPpe598VgqvroasJh+EAVxHv0N686iBGeSf9hbZtzma++0qP0swCQG qCTQ== X-Gm-Message-State: AGRZ1gKN/cPbQamwhOEFTPZj6AOhwjVDAoVvACHnKyWzSh0HYHcZ7r1t V/Llnk8ClzIFfMRxCxyJywI= X-Google-Smtp-Source: AJdET5fT7X56DvGCN8sqGPN5x6DPIu0vcuwt9W1iQSSq4/4UYd+sfH6adVV8Hx4AdQVWA35Y1fqzAA== X-Received: by 2002:aca:f084:: with SMTP id o126-v6mr4919459oih.21.1541090740939; Thu, 01 Nov 2018 09:45:40 -0700 (PDT) Received: from Olgas-MBP-195.attlocal.net (172-10-226-31.lightspeed.livnmi.sbcglobal.net. [172.10.226.31]) by smtp.gmail.com with ESMTPSA id r62-v6sm1834301oig.14.2018.11.01.09.45.39 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45:40 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, viro@zeniv.linux.org.uk, smfrench@gmail.com, miklos@szeredi.hu Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: [PATCH v8 10/11] NFS: COPY handle ERR_OFFLOAD_DENIED Date: Thu, 1 Nov 2018 12:45:22 -0400 Message-Id: <20181101164523.41812-11-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia If server sends ERR_OFFLOAD_DENIED error, the client must fall back on doing copy the normal way. Return ENOTSUPP to the vfs and fallback to regular copy. Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs42proc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 00809b3..c7c2ffa 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -395,7 +395,8 @@ ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, args.sync = true; dst_exception.retry = 1; continue; - } else if (err == -ESTALE && + } else if ((err == -ESTALE || + err == -NFS4ERR_OFFLOAD_DENIED) && !nfs42_files_from_same_server(src, dst)) { nfs42_do_offload_cancel_async(src, &args.src_stateid); err = -EOPNOTSUPP; From patchwork Thu Nov 1 16:45:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 992008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="sBQvl11x"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42mB0T0tHhzB4Y1 for ; Fri, 2 Nov 2018 03:45:45 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbeKBBt1 (ORCPT ); Thu, 1 Nov 2018 21:49:27 -0400 Received: from mail-ot1-f50.google.com ([209.85.210.50]:39692 "EHLO mail-ot1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbeKBBt1 (ORCPT ); Thu, 1 Nov 2018 21:49:27 -0400 Received: by mail-ot1-f50.google.com with SMTP id g27so5448597oth.6; Thu, 01 Nov 2018 09:45: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=T6NY1ZqMpMDP9hCYA0jR0CNHkfUq1OpC1PqHK6+EhwM=; b=sBQvl11x2RC5w7LBcUNJk90xfTMf1k7yGrdy3P0JmP18U2D/yaQ0KHasvyGQcf9yiL 2Kq3b4iICSrZpy9PEeMWhaouEeNPI8yi9e2ESlD353FVNIESOoghLq9YPv2DNt8LK9U1 nRljgslRZvsiJgSl9aAwf7X8jTIUfuKpLnu0HPKWFn560F9yix15ncXgUEktT4ittvL+ 8Rt5dOkcH4+Z9n+wLxxcj79jE8Dsf7ypr2a7VdiaUhAf6CENLNG/biS/w/LwYFv6oeCq lo0rYVXVhxTxP8cd7wEWV3+zcfYoqy+HeOD07Yo6JaqYiRIhGtsFJUJlPC3QSssT2+xK iJRQ== 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=T6NY1ZqMpMDP9hCYA0jR0CNHkfUq1OpC1PqHK6+EhwM=; b=QWPiV/GFZ7g9a6w7jR0xDV4HaBuwtSW0KiZckPb5bAmpv1YsPn9kfGrpyTLYuUDagZ Sholbzt5vJrUmjXSVyd/1E3mVYhS3ciB75g5YAX8O2uhVwvHIm8A38DZswvYNgddwib4 2drVE2uJ3Tt8Cx4txso0LBvngJlSjg8OJ+SyIpMHDgyfsZHsssBAJtaKQLHAZMzGX8hO 54IGwdKnE4HKkVkkyzlRcuGwqgjuAHLp/FkT3/fyhLOv/2uZST6SPTieShLDRTGkqpDQ gj7AfDawxM+dXFVVkZ6D3eTqRcLpiXCnEEH6+EJwmqaCALtknOXXQ+yWdRciEumwBI7P hx3A== X-Gm-Message-State: AGRZ1gITYrPVq4UmnKOIW/kgDdyKDClypZFz/m1BiL1HwfduWeewGapD 54A/l8VLIfPL2A788i+udw8= X-Google-Smtp-Source: AJdET5dQZYvGZNcXkqTaqJ58n/YCjNZoCXdcGbh5eR6DHNBoXy3wl06r/EN/mWBXceIkcVPkTa0OiA== X-Received: by 2002:a9d:2c46:: with SMTP id f64mr1685949otb.192.1541090742283; Thu, 01 Nov 2018 09:45:42 -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 r62-v6sm1834301oig.14.2018.11.01.09.45.40 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Nov 2018 09:45: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 Subject: [PATCH v8 11/11] NFS: replace cross device check in copy_file_range Date: Thu, 1 Nov 2018 12:45:23 -0400 Message-Id: <20181101164523.41812-12-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20181101164523.41812-1-olga.kornievskaia@gmail.com> References: <20181101164523.41812-1-olga.kornievskaia@gmail.com> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org From: Olga Kornievskaia Add a check to disallow cross file systems copy offload, both files are expected to be of NFS4.2+ type. Reviewed-by: Jeff Layton Reviewed-by: Matthew Wilcox Signed-off-by: Olga Kornievskaia --- fs/nfs/nfs4file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 12c34b3..ceab66a 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -142,7 +142,7 @@ static ssize_t nfs4_copy_file_range(struct file *file_in, loff_t pos_in, if (pos_in >= i_size_read(file_inode(file_in))) return -EINVAL; - if (file_inode(file_in)->i_sb != file_inode(file_out)->i_sb) + if (file_in->f_op != &nfs4_file_operations) return -EXDEV; if (file_inode(file_in) == file_inode(file_out))