From patchwork Wed Oct 10 00:13:36 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: 10633603 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 5A32B16B1 for ; Wed, 10 Oct 2018 00:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48889284C9 for ; Wed, 10 Oct 2018 00:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C30928F95; Wed, 10 Oct 2018 00:13:51 +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 9CC7D284C9 for ; Wed, 10 Oct 2018 00:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69D7F6B027F; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 623E66B0280; Tue, 9 Oct 2018 20:13:49 -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 4C5F26B0281; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 047696B027F for ; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id t1-v6so2629531plz.17 for ; Tue, 09 Oct 2018 17:13: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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=P/YQlM0zBKzZCKNmo/NUmCxM2Wsz0+Zw5Mwl06F/+a3zbi90rcXfogb9d2zcYeKHtT K5q8mZ9ru3Y2VOnBxaguLFhQlzght2FWqLyryYm8N0xxpMJXd9RIyCRgEqQUvI4tL3F3 JT31CyT6J+MSWMxMc9p9peQXUb6em9QNU7mSORxSjazQAl+dIgpoYyrMpNNdRrUcrYZ2 73Z48HCY45l4kcD6bVn1qOhNmJcmZcLJZAlqnmgm9R3D5ZxcSmf5BG7bA8q+Pm3GM4wQ NKVdhld0YOAK06ycDoPNNlTE1KkJFy1pGThnqT8tTeQKArjYPFtzDgJrIpr/fEfLBX5a kFJA== X-Gm-Message-State: ABuFfoiQQ9701HEFb4jtbpYV8zOACGVReIQ1Z+mUtOMviDrwOPQHjpaO p5sPIyP4EwsVusxVl4HBnFvTWVQ+hOf0lrSi4iizU6YfPmEMeTrG1mC2VPQdjjO+zLFv4QCIJJw D1vL/sdHzF1AqxB3CXifLyUBMLkmQfN0/vDX7n8GnvNn3XE79K8ZLZueQ8BbTNNbonA== X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr27471442pfg.10.1539130428670; Tue, 09 Oct 2018 17:13:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63yHekv+Ob7Itkmw/3beISFRfm7kNDNKly/HuDpoSg/mHWhAqYUaXLVladSO1AAhNuw/ZZC X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr27471390pfg.10.1539130427769; Tue, 09 Oct 2018 17:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130427; cv=none; d=google.com; s=arc-20160816; b=afFuQ8LTdoMgRvH2vFUHF+P/krBTgeKmM8WiVgAkvd9x1qu34/1W/WYJw+cz5Lq6NG IfkhGfJmGK/lve7caIly52WmIBIMYLEDnA58ht4bWThCraYlIS4BKQQ0q4G65RCFhHki 63xoVpTij+FuDcIUIzxTufw1P4iDN63uzrRC4gkaGbYrKuL7FPEn/XBs4hhjikm8MZld bDK4kRe7yjTH9gZsgyR5KX9xqcuNyGJu/sR9fkW7nErGSQ7gH64Xs5f2r1HxxL03rJYy ccOR2cZY6tyXWhSqAUogICYN/n0ornBMjJD1/V/6irIIG6EqecsvQ8s4QUzLcbLcGbxQ 1SLw== 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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=ha87f7bd4/aSu2F1pP6MHCBCJrmGxWegZDl1SHcH3quhyk3YWCsxXo7JzhPnCYS/jW 2sSnC847GGtZXiQSygiV6lzN84FqJoz3IG+oLHn67IT+P9CpX6KN01LCOXz1BdsrsnDm OwD6wKl29+rXbWQeAl3z3m4/G2c837/IgQOuZbIZfrHlQ+HaHf1xiCuhVEMMH+SAk2LG F+161T5JzRIpGShVO64OXz3sAcM0VPyUJbIz+IENKmVmBZY4QEGDr61kdJsF2MU6+l8R 1XjoqBFPWPSgaZy433DgH0Sg5qUY2F0PoQ5HGaL5xzyxoBMSYYPAiRho++RpX1BpxgzC vWFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ltB5n4q8; 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 u5-v6si21512620pgm.268.2018.10.09.17.13.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13: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=ltB5n4q8; 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 w9A0DltO123163; Wed, 10 Oct 2018 00:13:47 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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=ltB5n4q8FqZUZZ9tFTMAhvHyRhJqxH+//6ARrNXx1zeV084XjrkvqI7+YncAaVrJ7C8Y f2QK/6wu6OnkWlnWQR8AMn4EoBPzRtiDjVCZhSeDkM2VdDUBw/i54BypCWI8w7HUa1ml yI4eiMCpYR1DCRmhFzH5IgnB0R3D+Bc59APrhLaC9CLQSUQMXn8G32OLsoXuKt8qegaw ESbcIdPF4yOSJ/YqmwI9xuK1KBmyKJCK3jiHKVgc1oRg3NgSCo0DDQz0/IIFFLzSKkn1 5AtKvaG3Vt1WWT99f7PzynaUZ/WznBAqwUT6vJd22UaaGDpc2oH7xCEC5yS3/RzQiEFD Ug== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmftrvq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:46 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DjdZ004368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:46 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Djq4005684; Wed, 10 Oct 2018 00:13:45 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:45 +0000 Subject: [PATCH 15/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, 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: Tue, 09 Oct 2018 17:13:36 -0700 Message-ID: <153913041692.32295.9928643841686525236.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=539 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 --- fs/ioctl.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/file.c | 4 ++-- fs/read_write.c | 13 +++++++++---- include/linux/fs.h | 4 ++-- 6 files changed, 16 insertions(+), 11 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 c2b53509e7f1..bf60a3386c11 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 c8c890c22898..8b22035af4d7 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: @@ -509,7 +509,7 @@ 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, + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags, op); } diff --git a/fs/read_write.c b/fs/read_write.c index f43b0620afd4..cf81d1f68b69 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1821,12 +1821,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)) @@ -1857,7 +1860,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; @@ -1868,12 +1871,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 1ee09152ecd5..21f947b20f37 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1838,10 +1838,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);