From patchwork Sat Oct 13 00:06:58 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: 10639545 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 4287D1869 for ; Sat, 13 Oct 2018 00:07:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F21F2B78F for ; Sat, 13 Oct 2018 00:07:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2348B2B79F; Sat, 13 Oct 2018 00:07:11 +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 6234D2B78F for ; Sat, 13 Oct 2018 00:07:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 397D56B0275; Fri, 12 Oct 2018 20:07:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 349B06B0276; Fri, 12 Oct 2018 20:07:09 -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 2109E6B0277; Fri, 12 Oct 2018 20:07:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by kanga.kvack.org (Postfix) with ESMTP id EEE116B0275 for ; Fri, 12 Oct 2018 20:07:08 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id v198-v6so13352577qka.16 for ; Fri, 12 Oct 2018 17:07:08 -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=LYjJXc/Xz2cQPU4uS6RQK8uH5X4STYpNRAht3hCzCyg=; b=TO1vy+4VYauPxXUw2tBvk9hpc+Ea+wCK3lFfzK/s1yIQfhZLT1peltOesUytxOhhnr tt+SKDmJBYVPG63XnBHz6LeX2gh4SmaJsabNpaIiwGMTECY/KQZiBdaGD0KxwtK7iUBo Uo3UrZOdwJowTImo8fvXnz7s8jLSUtNjqMCBSKMHDKF2ZMUmldUeQ4KrfAbq6uxWmfM1 M81RRh/P0ubdxkApPN1d7MRtSaSYZRTbajJxVhIa8pwqEH633U6Ba7W3SXohwUB/tyvW p6JjENR5vAIcsg/zjtAJ4rCTM7or7v44aMpvdmMEh4BAXuMbC4qwwigfjQ4veT8yPaoy EoYA== X-Gm-Message-State: ABuFfojRQ9ZZ9WMIF/qy8XN+vPSDM0GCgD4L58cf1toe3jpytjBLdwb3 mRqFUHIEf0mA1+1+FKs6Q940MFoQTb0ox7QYeeQuaDCMiDgrPvVlpvhjfDuF6SQj9c6fNSPhMmU TbTdyfOC5BqNZrvefL0XOeucQd0ro8uLK7DFM3dUcfsZ/KBdusuj625D73hB5IIR19A== X-Received: by 2002:aed:2722:: with SMTP id n31-v6mr7852559qtd.304.1539389228710; Fri, 12 Oct 2018 17:07:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV617raBc5udqfSh9uwBwo2vBVW5Khb2Mt9nQy1uwybP/ue8/u+ltrSinpoEeySZkQsWRLSoR X-Received: by 2002:aed:2722:: with SMTP id n31-v6mr7852526qtd.304.1539389227845; Fri, 12 Oct 2018 17:07:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389227; cv=none; d=google.com; s=arc-20160816; b=W4Rzss1NtDBuxaKXMhf/3y1HZD8IPjG5zZgz8trWRco/r0BVB+BR7txGDYCHuMWLKQ Dd5venq16iv7TTkVbaUOVmGarnRxYOm22b3PdyvxidDYCQOPCMxwLo0u6/ZYeeyjTj/6 a6dDbZ8Uwxj2eB0DgyLKKv6lGSSyWRl68NMojwN08WUa+8gY4UkMTPYUdnggX2+6lQ28 xuAkrbRXhmEvIwBXpw3qWuG5Djq3pJ3zz5piNlCvdQcWvIqPVrX7g9Ew0LJIM7pGosV9 Q6bvSL1sYWfTzlqqXIehznw7Hel3pVblWh2w73BFSONNCKd8YChf5aF2ebM3sVYZlBig tzcg== 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=LYjJXc/Xz2cQPU4uS6RQK8uH5X4STYpNRAht3hCzCyg=; b=VlqgwLhNzSIyFO1+HZATLfPSzvlnURR7xcvKRYLFF74FSUuoszxbYu5cnxE082KFOu PcE8Wob4KLq78p+bf2nrRRYaShi7+t1yoc9w3KT3ABIZHNbHIGU80IZcvwZ50pQSnEQP ee4TFu5+yCqrEw4Yn4K+uYpBeM5Y8CBCuBgeg08B6DmUP8UuwDG0R5Gqcljig5ePUNBi k8XEmleWvWyl6ZsXTb6Yu2crzNzJqVb6Q3xBBIZdvu5yHV91/t4hDNuNBIf5HAGxluot I1HE2qcs+yJCljuoSTmvLPqmjopY/juUzSTY6/Iqn+4DiUO3UfZ50r1kXGasNn9ruC6D Y2yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gt4rhDPi; 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 u6-v6si1389909qvm.139.2018.10.12.17.07.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:07 -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=gt4rhDPi; 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 w9D04b58163357; Sat, 13 Oct 2018 00:07:06 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=LYjJXc/Xz2cQPU4uS6RQK8uH5X4STYpNRAht3hCzCyg=; b=gt4rhDPiV6Zv6EkHwsalthzAuLcjRve84KmHXigLiCGSCA7mBx9jdfnnBn3kXEFlC11/ 7R2h+SZHHfrsjpFJxxTVqSPbLYUC+CGlDQ8buEKGeQremeM0Dih21aQa2OfL+stQwAQ+ 3cyi0ddumtapC7+gvcZViKcBEPPNKe/15ByJPNcUd7wsQNl5IOQNuN50x3JcEerD+TjI rKhnNLEug4a3ZcuX1iqPWlDWCrQHk3KDbSq0oRCB1rOk+fe97D8st/IbgpT2ELFmoFt4 nKLbIlc2KuSkbsck4UAyMIwZ1Q2O7t+9on7+dps6+ulBfPrdo0s43lVUEoORqKdZRCHU 2Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmf0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:06 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9D070Rl003509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:00 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D070tY019573; Sat, 13 Oct 2018 00:07:00 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:00 +0000 Subject: [PATCH 11/25] vfs: pass remap flags to generic_remap_file_range_prep 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: Fri, 12 Oct 2018 17:06:58 -0700 Message-ID: <153938921860.8361.1983470639945895613.stgit@magnolia> In-Reply-To: <153938912912.8361.13446310416406388958.stgit@magnolia> References: <153938912912.8361.13446310416406388958.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9044 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810130000 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 the remap flags through the filesystem from the vfs function dispatcher all the way to the prep function to prepare for behavior changes in subsequent patches. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ocfs2/file.c | 2 +- fs/ocfs2/refcounttree.c | 6 +++--- fs/ocfs2/refcounttree.h | 2 +- fs/read_write.c | 10 ++++++---- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_reflink.c | 16 +++++++++------- fs/xfs/xfs_reflink.h | 3 ++- include/linux/fs.h | 5 +++-- 8 files changed, 26 insertions(+), 20 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 852cdfaadd89..53c8676a0daf 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2538,7 +2538,7 @@ static int ocfs2_remap_file_range(struct file *file_in, return -EINVAL; return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags & RFR_SAME_DATA); + len, remap_flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index ee1ed11379b3..270a5b1919f6 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4825,7 +4825,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -4851,7 +4851,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, goto out_unlock; ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, - &len, is_dedupe); + &len, remap_flags); if (ret <= 0) goto out_unlock; @@ -4859,7 +4859,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, * Update inode timestamps and remove security privileges before we * take the ilock. */ - ret = generic_remap_file_range_touch(file_out, is_dedupe); + ret = generic_remap_file_range_touch(file_out, remap_flags); if (ret) goto out_unlock; diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index 4af55bf4b35b..d2c5f526edff 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -120,6 +120,6 @@ int ocfs2_reflink_remap_range(struct file *file_in, struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe); + unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ diff --git a/fs/read_write.c b/fs/read_write.c index 7b837d12f75d..5d24e9854765 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1712,18 +1712,20 @@ static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) /* * Check that the two inodes are eligible for cloning, the ranges make * sense, and then flush all dirty data. Caller must ensure that the - * inodes have been locked against any other modifications. + * inodes have been locked against any other modifications. This function + * takes RFR_* flags in remap_flags. * * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, bool is_dedupe) + u64 *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); u64 blkmask = i_blocksize(inode_in) - 1; + bool is_dedupe = (remap_flags & RFR_SAME_DATA); bool same_inode = (inode_in == inode_out); int ret; @@ -1807,12 +1809,12 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(generic_remap_file_range_prep); /* Update inode timestamps and remove security privileges when remapping. */ -int generic_remap_file_range_touch(struct file *file, bool is_dedupe) +int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) { int ret; /* If can't alter the file contents, we're done. */ - if (is_dedupe) + if (remap_flags & RFR_SAME_DATA) return 0; /* Update the timestamps, since we can alter file contents. */ diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 7cce438f856a..dce01729e522 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -932,7 +932,7 @@ xfs_file_remap_range( return -EINVAL; return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags & RFR_SAME_DATA); + len, remap_flags); } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 99f2ea4fcaba..ada3b80267c6 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -921,10 +921,11 @@ xfs_reflink_update_dest( struct xfs_inode *dest, xfs_off_t newlen, xfs_extlen_t cowextsize, - bool is_dedupe) + unsigned int remap_flags) { struct xfs_mount *mp = dest->i_mount; struct xfs_trans *tp; + bool is_dedupe = (remap_flags & RFR_SAME_DATA); int error; if (is_dedupe && newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) @@ -1296,13 +1297,14 @@ xfs_reflink_remap_prep( struct file *file_out, loff_t pos_out, u64 *len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct xfs_inode *src = XFS_I(inode_in); struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); bool same_inode = (inode_in == inode_out); + bool is_dedupe = (remap_flags & RFR_SAME_DATA); u64 blkmask = i_blocksize(inode_in) - 1; ssize_t ret; @@ -1327,7 +1329,7 @@ xfs_reflink_remap_prep( goto out_unlock; ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, - len, is_dedupe); + len, remap_flags); if (ret <= 0) goto out_unlock; @@ -1375,7 +1377,7 @@ xfs_reflink_remap_prep( * Update inode timestamps and remove security privileges before we * take the ilock. */ - ret = generic_remap_file_range_touch(file_out, is_dedupe); + ret = generic_remap_file_range_touch(file_out, remap_flags); if (ret) goto out_unlock; @@ -1395,7 +1397,7 @@ xfs_reflink_remap_range( struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct xfs_inode *src = XFS_I(inode_in); @@ -1415,7 +1417,7 @@ xfs_reflink_remap_range( /* Prepare and then clone file data. */ ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, - &len, is_dedupe); + &len, remap_flags); if (ret <= 0) return ret; @@ -1442,7 +1444,7 @@ xfs_reflink_remap_range( cowextsize = src->i_d.di_cowextsize; ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize, - is_dedupe); + remap_flags); out_unlock: xfs_reflink_remap_unlock(file_in, file_out); diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index c585ad9552b2..6f82d628bf17 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -28,7 +28,8 @@ extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); extern int xfs_reflink_recover_cow(struct xfs_mount *mp); extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len, bool is_dedupe); + struct file *file_out, loff_t pos_out, u64 len, + unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, struct xfs_inode *ip, bool *has_shared); extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, diff --git a/include/linux/fs.h b/include/linux/fs.h index 91fd3c77763b..b67f108932a5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1846,8 +1846,9 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *count, bool is_dedupe); -extern int generic_remap_file_range_touch(struct file *file, bool is_dedupe); + u64 *count, unsigned int remap_flags); +extern int generic_remap_file_range_touch(struct file *file, + unsigned int remap_flags); extern int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in,