From patchwork Thu Oct 11 04:14:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10635885 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 84C1F17E1 for ; Thu, 11 Oct 2018 04:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ADE32A61E for ; Thu, 11 Oct 2018 04:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F6EF2A63D; Thu, 11 Oct 2018 04:14:14 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B72822A61E for ; Thu, 11 Oct 2018 04:14:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C2956B0283; Thu, 11 Oct 2018 00:14:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 298786B0284; Thu, 11 Oct 2018 00:14:12 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 187E16B0285; Thu, 11 Oct 2018 00:14:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id E3C7A6B0283 for ; Thu, 11 Oct 2018 00:14:11 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id x7-v6so7466783qtb.6 for ; Wed, 10 Oct 2018 21:14:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=gmwHKmAacHsmC1/Cs6ojxU7uP6Ptna1Yzgpqqu9YqLzjwdNjIIS45lKYXI7oMgJNmg Jlw320kprR/txZ8ws4IPajaAkcORYXdjp6yYg055mLx4WzJDCvpHw6z8iUer+8vbbBEN XA9ROQl6zh7pVwe2SyIkItiqBkEywMge/lPp2cqXVcXO/Rd6d96m9ZbylYysacIQS3j7 cSEp697hPFv8AFZE9zWr4ODrW8srix9yv3iHE1Ne5EfQjcjia0159ab+ZAPuAGMRBaUi Z4dgM/3dlKnyYDfEnivLlKZG8B+CJEYOgs0TFDihIQ9iKsDUcRb1w7YS/JQQt/ImXYje ZU9g== X-Gm-Message-State: ABuFfojQsDeNHH05USnl+vkiAP3b62SpxeiS8zaSnzR9umWm9wqIL7pX UFq7MjvfTSNR2kklGQ51PAckrit7b6bpfbdQlEjYHAMbGULF7begA6jtaXQWsgtbKiFP/CAUPPP N2O+2ofsViDn2KBg9U7YEQl9bsFJgLq1yBFQ/YQvNYFrgrRrsY+1v4HwNcjC4tBzguQ== X-Received: by 2002:aed:2684:: with SMTP id q4-v6mr15459264qtd.293.1539231251696; Wed, 10 Oct 2018 21:14:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YkWdUbt8ZlzEAdBRgIvOwjBEGGAmauLqKj0tfaGY51JjG8PbrSnlKxtWNOdBTPEftUT4h X-Received: by 2002:aed:2684:: with SMTP id q4-v6mr15459246qtd.293.1539231251020; Wed, 10 Oct 2018 21:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231250; cv=none; d=google.com; s=arc-20160816; b=uKHwVe9GJ3x/5+TEp0vwO4vK1CU5Ggzt+kUcDddTUtwVvXAKQH698lL2R/O7K+Mu5l RamCer3oZK/1kdIjt3f4pYs24oMGWxsAjABCSqCjlCZq4qPlBBlFlDFUw/c1I5I5/dZ8 OX7rFHQ07N9cZWbVX1ChE+S2q8kiFs1QcqLGDRVIm3E3POg/fBM+WwxYOZq57BuxUkG9 dUaAmQ4BFPTeEyUS8na+NH7ETMm32XA6JvW3yld4ZhwohYy4wdASUcEulOAZL4+DKYVy osnX+E109VY24j/Y45LK09l+XQQj7W0rZRZJ2AB0KPLnYBEKdChcGCJhN0FlGQ3xqnok RRTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=ExRvrreKcAUOuMPD+Gu0iA+ag1Ion6Qhkjpq8UPbvcOLt8OGZcQtSGsQUKCQq6bGDB NNstaTGtE4BZUmaRnlFpL28KOqJIFtG5CmfhRQdNi0nxF/lNS63e0HMWKXx2J0q8ldZY NyuX18gw2vLYReOCMhMFmDahlGpfnckGnLCPdEOQyEXdqoJtgL5vZC+S12bQ3q142GJb IrYxD/Zc4D4E+dRxiQkKL8jzgSpi4Bwx+0+xr8fbZYmP5JwqbqIPWnQ7iRUUifCyUPHm 87p5+Wbf/HO/uJyXLJ7KVB0zlRuR4+BCXVbwShKwQ/zk5nvGex9j9vycA6SdgTQpdIwH i16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=i+Q1M5T6; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id r32si7257585qvr.26.2018.10.10.21.14.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=i+Q1M5T6; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9B4DtIa058434; Thu, 11 Oct 2018 04:14:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=i+Q1M5T6Mn5ZmCTgcOBaOBeVnm9AgNGfQLns5tfzLLLX9w/rks8wTraMv07Pqh8TZHCv i9eF4FG2sG9iboD4b2chmN8CV+MSeXTpGzJsJDd/8ZuPkw5P7amaaX3pHJYxLbyv1kD8 uLDDH1CL/yCqvlFNLGh+SC7BUXjm/bcxvbZLc/ebvg8MIdmZV6foP7ar6uq2UxhwDSEf 3p5sISkV6r1zjOUExu8sZ/YwmH1wfMys8W//qdy/p2sRIdnGqZcK6axM8B1egEOtCD55 L/4X7aFzY8eCD66hSwujgiXvMfn2GUu2RdLJy0lO0gkvIFVZxgpPkyPKLzmn9wuK3by/ Og== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0q9dyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:08 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4E7aj017979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:07 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4E62u010901; Thu, 11 Oct 2018 04:14:06 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:06 +0000 Subject: [PATCH 14/25] vfs: plumb RFR_* remap flags through the vfs clone functions From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Wed, 10 Oct 2018 21:14:05 -0700 Message-ID: <153923124495.5546.2993415758308396845.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=617 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Plumb a remap_flags argument through the {do,vfs}_clone_file_range functions so that clone can take advantage of it. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ioctl.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/file.c | 6 +++--- fs/read_write.c | 13 +++++++++---- include/linux/fs.h | 4 ++-- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 72537b68c272..505275ec5596 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -232,7 +232,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, - olen); + olen, 0); if (cloned < 0) ret = cloned; else if (olen && cloned != olen) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index ac6cb6101cbe..726fc5b2b27a 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -543,7 +543,7 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, { loff_t cloned; - cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count); + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); if (count && cloned != count) cloned = -EINVAL; return nfserrno(cloned < 0 ? cloned : 0); diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 8750b7235516..5f82fece64a0 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -142,7 +142,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) } /* Try to use clone_file_range to clone up within the same fs */ - cloned = do_clone_file_range(old_file, 0, new_file, 0, len); + cloned = do_clone_file_range(old_file, 0, new_file, 0, len, 0); if (cloned == len) goto out; /* Couldn't clone, so now we try to copy the data */ diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 177731b21bad..e5cc17281d0b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -462,7 +462,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, case OVL_CLONE: ret = vfs_clone_file_range(real_in.file, pos_in, - real_out.file, pos_out, len); + real_out.file, pos_out, len, flags); break; case OVL_DEDUPE: @@ -512,8 +512,8 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, !ovl_inode_upper(file_inode(file_out)))) return -EPERM; - return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - op); + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, + remap_flags, op); } const struct file_operations ovl_file_operations = { diff --git a/fs/read_write.c b/fs/read_write.c index 461acd5fcc4a..b3f8b4a2bdfc 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1842,12 +1842,15 @@ int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) EXPORT_SYMBOL(generic_remap_file_range_touch); loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, loff_t len) + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); loff_t ret; + WARN_ON_ONCE(remap_flags); + if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) @@ -1878,7 +1881,7 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, return ret; ret = file_in->f_op->remap_file_range(file_in, pos_in, - file_out, pos_out, len, 0); + file_out, pos_out, len, remap_flags); if (ret < 0) return ret; @@ -1889,12 +1892,14 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(do_clone_file_range); loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, loff_t len) + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { loff_t ret; file_start_write(file_out); - ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); + ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len, + remap_flags); file_end_write(file_out); return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 035d8a88f633..4acda4809027 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1852,10 +1852,10 @@ extern int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags); extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - loff_t len); + loff_t len, unsigned int remap_flags); extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - loff_t len); + loff_t len, unsigned int remap_flags); extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same);