From patchwork Sun Oct 21 16:16:42 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: 10651107 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 DA021174E for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7429287BE for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6EE7287C2; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-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 1F68C287BE for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDBB76B0271; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B8C686B0272; Sun, 21 Oct 2018 12:16:48 -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 A79976B0273; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 7AAD56B0271 for ; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id y131-v6so2464572yby.13 for ; Sun, 21 Oct 2018 09:16:48 -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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=p05rplTw1RmWl9wXn6H6ImKHJYZI9arQHTYY452k2etPmlm6BEtSYIgWAyCqgP5Xht Hws1ylzyNi65A6Quw3oHnA9lVuURiYoAruNr25YPyxkQH2iRTP6/ynrhTY2tK3dttCKw NAikcbCgt0K0LZDgGUtKOgWBaGQr5CorQmBIhTusuoubrD6hC13l1+l+8aHfLipoiNNg jmmWkXHtXu1h1R14KUKjmDSPKRuT7ldlv5pS8EhH0k1F66Pud5FXgKezwuksG7BseuNV EZLlCG6adIWCmApHk27tIJKWxuxWYaAVOAMZPMwW6bvk7f8UzQupjjxZyd0i6iKKjfYQ XfaA== X-Gm-Message-State: ABuFfojjN3tYkXrFDhk33RTNhriCrM9bQcTvUPoiw5aJKMy8evCKLhGI 3qs3djTwQTm2ZbTMneT8uwkCpR4Vcuqjs7Po6ugDakOe1AlxJPB1SXUSaIXoqTKqX/h24TarJ33 mnD0VpUfGrkHa4dg1qLRiLegZ/wcL5VHw8cbZVwGB4PlbFzaRzTxQimYSLm/7KyN8xg== X-Received: by 2002:a25:6c45:: with SMTP id h66-v6mr28702479ybc.112.1540138608238; Sun, 21 Oct 2018 09:16:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63GiYSdNemvyBusBnku54rkDdmI9136lvJGja+udPZoj0KkQZU6ZW0MmXsneTsIGD3/8OKH X-Received: by 2002:a25:6c45:: with SMTP id h66-v6mr28702442ybc.112.1540138607485; Sun, 21 Oct 2018 09:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138607; cv=none; d=google.com; s=arc-20160816; b=Z8PHw+p8mWET4OOhPEun6bagnkAMrQnRyOElSDPHH7xeLfRoqL9PO1ws+r5MOPq8CN 8gmlKMjn+9dMG2UAMNa3aCj6YF8fYCuMmsmTPmtb6MS7nXvXt/AO+QycPSfuH80TRqMe xPtWyX3A7WHwxxP5IOm65tzOZWtnzBcIhTMoX1EVbQo1FtSogc2zthw4ap1O47SDmlTR 334XeFN+jLfOH9YoP4hgTLayU7wVYRWbxDOqwwpWFfKk5yy+0WeyhGNXBw433iIMmE0C A5xYG1uY1sG1ZcSdgdHJS2V23x8abXesW51ebWNhu06bO1Bq/lNVMMDE3wDc2FCiR8qp PHFQ== 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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=lJUwfqPEEVFW2muIoK34+GLLPvnayfWOy7X3kniEQOsOhsbZzyZljgsmwZY7EGrnve DhozQ2XEoaLiwyhbsjg4RAu2b6TL+7tN9tu+A5IJ31LagET1GjTVSnUmKkGUktGvZfvF +QGb0ME4Xq7nPwLnn9UTXmrjhlmZRyKsjerH5wepH7l80NMVIqM9WSFtnwHRFIQ8rftO 0u75Ocr9lJURaOLxW4XtT9jsgszaSCpK3ywGIKKDy3Y9Vavsb8Dp+V/kHMLCpZV4w1SL qfPrWSC3Qxqbstb2XQRxsZgxwEsfv/BalLmwxwvZ5lO+q9z3YiGle4+99UOh+1RY7Ar3 W01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=m3ZIrCz+; 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 d81-v6si13619031ywc.464.2018.10.21.09.16.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:47 -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=m3ZIrCz+; 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 w9LGEt1E154508; Sun, 21 Oct 2018 16:16:45 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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=m3ZIrCz+sxUcG096jHpXpUkU6oa9kP4XZ7lc/0AZ7o4w2XckMRTX8su7m0CivjX0FTcu xXSYyXtK+rMEgnqRzWl922zJADwA6Xaqbko/ohWxIm1l7U9JNI2WI83UGYcBiwPUVLMo oNXSYV8+3Bu09ywflEF2iFk9tGZzvoVh5exL2sxYCPbJiJlsIb4P1fdVSCobXmlIB/Qa AIGmFxSr8vuidwkdUuJ6yyjjvGKW192SQn1H5BNbpKzlex1ywqmj/+Il3Vbe0HMf7b93 5yniV15Q0It6usMJSV1k0PQm6IVHJmmT0hnyfFiAicCbYCC+I43rSYjtvpyvCWzIdGVL iA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n7ustu1tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:45 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGGiTw005675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:44 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGGiPM019165; Sun, 21 Oct 2018 16:16:44 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:43 -0700 Subject: [PATCH 14/28] 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: Sun, 21 Oct 2018 09:16:42 -0700 Message-ID: <154013860216.29026.8102541414755320141.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 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=581 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 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 c72d8c3c065a..1c5e55d2a67d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1848,10 +1848,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);