From patchwork Mon Aug 14 12:44:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 801183 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=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical-com.20150623.gappssmtp.com header.i=@canonical-com.20150623.gappssmtp.com header.b="Ltj3adZl"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3xWFgP0BcFz9t33; Mon, 14 Aug 2017 22:44:49 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1dhEjd-0006hL-Tt; Mon, 14 Aug 2017 12:44:45 +0000 Received: from mail-it0-f41.google.com ([209.85.214.41]) by huckleberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1dhEjW-0006gM-V3 for kernel-team@lists.ubuntu.com; Mon, 14 Aug 2017 12:44:39 +0000 Received: by mail-it0-f41.google.com with SMTP id 76so17735914ith.0 for ; Mon, 14 Aug 2017 05:44:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=trpV5rIgeaSs89aaswaYWkhHzYO8+5WoJm0o1rJk2Tk=; b=Ltj3adZlbkAfP/6m/GScOkBCEqXDlqLJyEZP06QxRxf+eAiBG+Jh09yu/CxJ07tn4D 29uufS/XJ1C05F6RWLxCPXifDtDwn3hz2qFClZkgPdbiCibvNmFOYUttSdk5+XRfyP+3 8JkU+cZHSa5kDBgjvrom3clOC7lOegWgq35mwTVMbVnfei6+p5qtZGe44P5vzr1JwsPu SZfHGMgRSiRxwXo91aSbIKh4yv2w18wfIMJeNFqdGTQ8az7DqI7p8rOYPoeLoHD4zrRa 4LGlcXrYoo4RMcWPL/hR7oIruGi8a0VJqKe3hTj+RIvOkuD3oJZS2KPPmnfNHBEo6/cj epqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=trpV5rIgeaSs89aaswaYWkhHzYO8+5WoJm0o1rJk2Tk=; b=rkl9+DWMgm9HMvEaHtZgwlEERUwgxtDB67uHUxT8eKy/X81MG1HegD/2RSx6Dyq55o XCGzlG1zzK1YyaO6U6sPFKihzxjhCEJBjTZQgac5Z4kW7MovyqN4qFlIiWi2lLn3Veas bxiKw+rdlUothq7Jmz/JjkJMXuYTekiNSbVMhGkntFWJB8j/UGEVwzCGwL3lvprYNj3z SuWjNNhrBYMIeYIiGzfofcRaA+kCxacriEHiAK0REgfROVM0Ij23JCgw7AFdGZVdIxfV 0qIYOv8T1s91mF9rKXDpd08hskBTnEOUtgb0ouz3x4nB9Ne40U4vU8KAq4/1ij0cEBfY wEFw== X-Gm-Message-State: AHYfb5hpbjMRGGaKjBswmN/BFVaGRohb/iGoydsv47CjiBP3g5vP9oHG Opy5srhRA/O4iYIoiI4= X-Received: by 10.36.213.131 with SMTP id a125mr6104097itg.74.1502714677458; Mon, 14 Aug 2017 05:44:37 -0700 (PDT) Received: from localhost ([2605:a601:aa7:8920:c495:d3d7:37af:e135]) by smtp.gmail.com with ESMTPSA id a83sm3513879ioj.36.2017.08.14.05.44.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 Aug 2017 05:44:36 -0700 (PDT) From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH zesty 1/2] aufs: for v4.5, use vfs_clone_file_range() in copy-up Date: Mon, 14 Aug 2017 07:44:31 -0500 Message-Id: <20170814124432.19537-2-seth.forshee@canonical.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170814124432.19537-1-seth.forshee@canonical.com> References: <20170814124432.19537-1-seth.forshee@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: "J. R. Okajima" BugLink: http://bugs.launchpad.net/bugs/1709749 In mainline, ioctl(FICLONE) is introduced by the commit 04b38d6 2015-12-07 vfs: pull btrfs clone API to vfs layer so are vfs_clone_file_ranage() and f_op->clone_file_ranage(). Compared to copy_file_range(2), cloning doesn't return with the partial success. Using this method in aufs copy-up, the speed will be improved. But unfortunately this method is supported by nfs4.2, btrfs and cifs only (currently). Additionally, linux nfs server 4.2 implementation simply calls vfs_clone_file_ranage(), which means if the backend fs doesn't support this operation, it returns EOPNOTSUPP. So the benefit is rather limited, but it must be a good thing. Signed-off-by: J. R. Okajima (backported from commit b4d3dcc92a13d53952fe6e9a640201ef87475302 https://github.com/sfjro/aufs4-standalone.git) [saf: Resolved conflicts based primarily on resolution found in fd18affa818115edad7e1b7472f26ac4d73e73a1] Signed-off-by: Seth Forshee --- fs/aufs/cpup.c | 25 ++++++++++++++++++++++--- fs/aufs/vfsub.h | 16 ++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/fs/aufs/cpup.c b/fs/aufs/cpup.c index 7112866b30ba..48e4d8511553 100644 --- a/fs/aufs/cpup.c +++ b/fs/aufs/cpup.c @@ -393,7 +393,7 @@ static int au_cp_regular(struct au_cp_generic *cpg) .label = &&out_src } }; - struct super_block *sb; + struct super_block *sb, *h_src_sb; struct inode *h_src_inode; struct task_struct *tsk = current; @@ -411,9 +411,28 @@ static int au_cp_regular(struct au_cp_generic *cpg) /* try stopping to update while we copyup */ h_src_inode = d_inode(file[SRC].dentry); - if (!au_test_nfs(h_src_inode->i_sb)) + h_src_sb = h_src_inode->i_sb; + if (!au_test_nfs(h_src_sb)) IMustLock(h_src_inode); - err = au_copy_file(file[DST].file, file[SRC].file, cpg->len); + + if (h_src_sb != file_inode(file[DST].file)->i_sb + || !file[DST].file->f_op->clone_file_range) + err = au_copy_file(file[DST].file, file[SRC].file, cpg->len); + else { + if (!au_test_nfs(h_src_sb)) { + inode_unlock(h_src_inode); + err = vfsub_clone_file_range(file[SRC].file, + file[DST].file, cpg->len); + inode_lock(h_src_inode); + } else + err = vfsub_clone_file_range(file[SRC].file, + file[DST].file, cpg->len); + if (unlikely(err == -EOPNOTSUPP && au_test_nfs(h_src_sb))) + /* the backend fs on NFS may not support cloning */ + err = au_copy_file(file[DST].file, file[SRC].file, + cpg->len); + AuTraceErr(err); + } /* i wonder if we had O_NO_DELAY_FPUT flag */ if (tsk->flags & PF_KTHREAD) diff --git a/fs/aufs/vfsub.h b/fs/aufs/vfsub.h index 8fae3d491ddf..71d2bc47d5c9 100644 --- a/fs/aufs/vfsub.h +++ b/fs/aufs/vfsub.h @@ -266,6 +266,22 @@ int vfsub_trunc(struct path *h_path, loff_t length, unsigned int attr, struct file *h_file); int vfsub_fsync(struct file *file, struct path *path, int datasync); +/* + * re-use branch fs's ioctl(FICLONE) while aufs itself doesn't support such + * ioctl. + */ +static inline int vfsub_clone_file_range(struct file *src, struct file *dst, + u64 len) +{ + int err; + + lockdep_off(); + err = vfs_clone_file_range(src, 0, dst, 0, len); + lockdep_on(); + + return err; +} + /* ---------------------------------------------------------------------- */ static inline loff_t vfsub_llseek(struct file *file, loff_t offset, int origin)