From patchwork Tue Oct 16 03:19:40 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: 10642893 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 1225217D2 for ; Tue, 16 Oct 2018 03:19:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2C03299BC for ; Tue, 16 Oct 2018 03:19:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E619D29ABC; Tue, 16 Oct 2018 03:19:54 +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 998C6299BC for ; Tue, 16 Oct 2018 03:19:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9970F6B027D; Mon, 15 Oct 2018 23:19:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9464C6B027E; Mon, 15 Oct 2018 23:19:52 -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 836406B027F; Mon, 15 Oct 2018 23:19:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 4276C6B027D for ; Mon, 15 Oct 2018 23:19:52 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id q143-v6so15993481pgq.12 for ; Mon, 15 Oct 2018 20:19:52 -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=NXYVyyHmVmlKAp63WiEk80Yd1QK+kCWi9LT++yfOJrk=; b=KKWwXZFKtQ56uTq/uqjuxGO2Cqz42/wQwyomPH686bHRRymO8SfhFa8a+pu6JQEsvN NiA8A3dJVWbcbNfSHGQNvOA1jutZBO3QiXDacw571q/J8vCHnb6DDTinYqAkVkNniV5g bfsbgkAftj1T6sdyN/Ok5JAr2wrpzR/e3hBg9gSU48yHqUoj8LC7PhmnTLvkgIwR8vmU MF1kGQ/G/6rto0r4eyggtCSwTvscx6BklNNmrSO+zXdUCxW7gX8foeUfWVewpgQw0nRm HiXBvgnzMq0EhRi5AP2ZtI82qNzR7tKwREWVBPdMBOKoeDK8A79blDerWVdBo5xTcr43 Na3g== X-Gm-Message-State: ABuFfohaD+LJ5SA76zHGyJkXzdn8ToT9WDoRivYge8obfnmkK2NZpT0p 5/Smw7m5KXCb97XkaJkI2U/mEiyguYEGG+92lqdpnfzim0To/wCGNo8PUYSixZsvSAu5NjK1WI8 TQ11WrQYMXXfBiESzqcNciX7Gn97Qd/4KjuG77cIcxjrWyVGlvA043bQYT+yv7VPrcw== X-Received: by 2002:a63:fc23:: with SMTP id j35-v6mr17764776pgi.1.1539659991916; Mon, 15 Oct 2018 20:19:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV62kWOfh2Epra0y9lp+0cHPzeu3nRLnYdvzUkiLwRbDLCmOFFPbvlG26S1DQbnfT19o37bEe X-Received: by 2002:a63:fc23:: with SMTP id j35-v6mr17764747pgi.1.1539659991132; Mon, 15 Oct 2018 20:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539659991; cv=none; d=google.com; s=arc-20160816; b=m82KRHSu0EeQmTvMzc/uQvw+1GKyrVItSYwdQBz1ki08487x8dRWOSS8FG5pLFRl6f egzF2ma/EHDCI76SvYRYbJC9+nh8g9tTJBuqEVWcvOpQPgch2f4ia0bqmPaY95K49Be6 IWZQYx2ZekKZUSybJpveQzaDN7EbpJ3E27H48al4hDa83dmtg12OrBGoBxysHr4du/4a mJtV9URp9kNM+rEyTFJy98Z9Ax1ToIgSc0qNRNF8v942A4ZmCP3fza9MpslszSkf/asl xL/+RyObyKiIsVugdudNGRV3YkYukeHsYrhabQ1TGDv2XN+k65fF1e57oF7jzi/YaXoG 2eBw== 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=NXYVyyHmVmlKAp63WiEk80Yd1QK+kCWi9LT++yfOJrk=; b=zap1sy28vvjTh/wuqKkSxziJ/UqoFMSZ8md1l8dwe44gu0ehmu68NYycB0GJr5GV95 Sry5lsAX0F4xQ621vEEoIO0ZubDuAylH/S9VfN74YUwt0dIgDIJ6QgTIT6v8Acp/Y3/7 P1hflJuLOQ8awqAWRhQjY6gDObqRMtc49GTk8BTvsx8Ph7uzxgfmHnsP6GhIIQaEfXRU JOmHAAr6hu/+ltsvMXIiT2gsh+BktBZYL3eoQEEsUeDDO3M2QWzRp6eYDTO9s6JHOwSL hsrmeKOPwgCePvkJrYTXnxq1Iuj58dANocEUWYMJYMwdfFcC45yAeudgC8YbWnhu1nuO oeaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=w28UYpsZ; 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 x15-v6si12308410pln.425.2018.10.15.20.19.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:19:51 -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=w28UYpsZ; 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 w9G3Jk1p051787; Tue, 16 Oct 2018 03:19:49 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=NXYVyyHmVmlKAp63WiEk80Yd1QK+kCWi9LT++yfOJrk=; b=w28UYpsZn0QESdH6ooyHsPZ7SFyfEzPzSns19jRH38/Vee7C0yf6PuVnceIkXt/lejSE sFCuXREQc7f8VH6Scyue7ZbjOQlRLd4nrvOZOshg5xFzrNMgJXASe8SnorqNcl5bWmwr 2jL5WT8MSyJzm8ajHTvhDJFQZ7dtyxBKfSJ5fzVvx84/cWkhc4yEisGY+pvXrhgowCtu 1JEoEe0D9X56WLyCn4TMVgBZGS79kIVIEAFtkf6P51FW0KuZjGd/gDxfM1Pq38FpAGAQ D/ZY/8H605hj020q4u2aGX6Jjn+Dc3BJS99i9WWeZF6z78hu8od1tdmiNtJASyVA4a0C Zw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n384tx27s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:19:48 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3Jheg003413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:19:43 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3JgO5012319; Tue, 16 Oct 2018 03:19:42 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:19:42 -0700 Subject: [PATCH 15/26] 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: Mon, 15 Oct 2018 20:19:40 -0700 Message-ID: <153965998059.3607.7952535159459274693.stgit@magnolia> In-Reply-To: <153965939489.1256.7400115244528045860.stgit@magnolia> References: <153965939489.1256.7400115244528045860.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9047 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=584 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160028 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 906e78be5001..791b406e8264 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1857,12 +1857,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)) @@ -1893,7 +1896,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; @@ -1904,12 +1907,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 f1d082af34d0..bc353a5224a4 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);