From patchwork Wed Oct 17 22:45:51 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: 10646351 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 835B8157A for ; Wed, 17 Oct 2018 22:46:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 737F1288C7 for ; Wed, 17 Oct 2018 22:46:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67E2D288E4; Wed, 17 Oct 2018 22:46:07 +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 C7C20288C7 for ; Wed, 17 Oct 2018 22:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB7856B0270; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B68206B0282; Wed, 17 Oct 2018 18:46:05 -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 A0B086B0283; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 5AB4E6B0270 for ; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id 25-v6so24797028pfs.5 for ; Wed, 17 Oct 2018 15:46:05 -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=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=ST8F0gkxsfMz8S+31STQbYkdyQE9aKdVmrDH04Sxt4Dg4PUnC7WztV1ADKxYO+tJUH 01XtwiZCx4h+InU7vyjUnL0pmFov/s+PSMKAzOEERcnhbWAxIaAZ9qzd/0vfuGmNH0iB 9UYPvF96zjBrau3Kh0IbmJtGcIeBQ6JNmAeLfn6pnEB2QrOmzv3PstQ4aYPvyC1m2j/W 7kjlwFl7SwD5efRi4YVtgc0cXlATa0aRDlfT8ZrPa5w0/b2r+6XCBz/z9PoWfXOwOGOl NK0d+ZgGDkfAtcS/5Y5YSsnz+8pQrBViOpKRAu2k0/nBqByn94w8EBGtRkuVMdFIO5AD Iv1g== X-Gm-Message-State: ABuFfohWUC7QyS2/6KYGKGWQ5d/qg3VAFAw4ksnrKUJ7DCrhIbkpNH7l IvtvRs70bAUW9wtPG6l+XiJ/pFY4Iz6Ry8NfUpvBrQieEdJt1clXaVOaZo9n0xHZ74Mj2Kv/cRX +XUydASHUkn78SteaRPpCeYpOiBaCvD8SZ80bZ1lydAsdXh/ikMrhr2johuPMwhfvAQ== X-Received: by 2002:a62:5f05:: with SMTP id t5-v6mr28177380pfb.223.1539816365029; Wed, 17 Oct 2018 15:46:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV611cOldJKRitLYrC8lcb06zrhAhymGMIDB8I75LB+w6Mw5NlgT2/gPBa0uxRq/0m6gWVMjE X-Received: by 2002:a62:5f05:: with SMTP id t5-v6mr28177354pfb.223.1539816364287; Wed, 17 Oct 2018 15:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816364; cv=none; d=google.com; s=arc-20160816; b=DsoEBkMvLKNkVEOlbq0R6pVrwBeuk8E02J9Ihl6w40x78hcxEc2Fn3DJRBrrZJXtM2 aPj3im9QfiykktRfaES80ekpZFEa4vAZyxQpb7O/I9yZtWhJphAmZsNb691DtePkzoqb dI7H3UKGOwzpxSZGf1gqyziLJIRnBkXag/g4QQFclseEsPzeCrAmZm0ph/qenOv6UXFU whbsixZi0dDKj2uvWPpuRUC1lDHvqthMFEMlVkLNGtLJjCzQzXpyuVehb8JtNSV8y2VO a146/7vXVyPl75XJ35l9MHeXoNBuNpq+OYdzb2wtrSc2Gs+1M4r2Ni65UzuKppVzPuVc PPmg== 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=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=OEfs7K3/imy0V/XUDCu/rekr7RPvkgoZFKrHxg9aECmuGxUZPCjNKCDEcv6Rmog1LH v+c0FQZEDsmL/7zuSfZ9KP4mmbgw8E4DDAkVKaKGD5QiYoG0eiZIxpSgGEmNlN2QRcdu d3Wpxn1r5nSaxVyjeS/Jep6VGao5lWVxydlwBL6LqUSyaCDzZEFmnoaA+GrLsmh4qFJM prRUfeXVA9j/3QNepxZcAfzpLUmsDGqxCQ52+X0eHwWtL9bdMcbazkx8xF3BFWiIMLg1 WWQLMH0+jmM/Z4JDtOKmsHfEN4jW8JapGtGv1FPPhV9Y4BnN8vEJW4sXUEw5OwVINTrG GYMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ocZImKv6; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id n2-v6si18557000plk.255.2018.10.17.15.46.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:04 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ocZImKv6; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 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 (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9HMiHst040218; Wed, 17 Oct 2018 22:46:02 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=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=ocZImKv6lvQwf9jgRR5gDmIISLQPGwDuEhHo4lS5IGyaOunMp7PrB7lGq633vVpcyfQ7 rsmj0XnZyq+h3ezGPdjMKk/xV4wIcixvVnLPVsv0YdKigmc+wdukK8/mr5Cuy0qG/Rh8 nNRLI3g2QqdZVspKJc22bbE69RGHpicP1sB06GINSXu4+QA4ct0tCiV+x2iCC3GBUr08 PEc90hw2nXboUkaYlB0ZzDVxQXkhUwvZRocNSoNUhSNUeDsQM+rMGA/AZp/JnLqvVu06 lYZ/Fnuwgc/6OnHdkydlbuNGL2Xt9iL9RB4IamM6cmZaNUw/FtVlzsdN4ao+S8CnSfDS IQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua01r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:02 +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 w9HMk1vK004688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:01 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMk0dB031457; Wed, 17 Oct 2018 22:46:00 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:00 -0700 Subject: [PATCH 14/29] vfs: plumb 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, 17 Oct 2018 15:45:51 -0700 Message-ID: <153981635183.5568.14122129836747881883.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=582 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 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 6c3fec6168e9..0393815c8971 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 356641afa487..0d1ac1b9bc22 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,12 +1848,15 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(generic_remap_file_range_prep); 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)) @@ -1884,7 +1887,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; @@ -1895,12 +1898,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 80485efad457..bc78ad7e21b2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1843,10 +1843,10 @@ extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, 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);