From patchwork Sat Oct 13 00:05: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: 10639405 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 88E841869 for ; Sat, 13 Oct 2018 00:05:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 756942B78F for ; Sat, 13 Oct 2018 00:05:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 690D32B7A0; Sat, 13 Oct 2018 00:05: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 0CA702B78F for ; Sat, 13 Oct 2018 00:05:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19DF36B000A; Fri, 12 Oct 2018 20:05:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 176696B000C; Fri, 12 Oct 2018 20:05: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 062866B000D; Fri, 12 Oct 2018 20:05:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id CF9E96B000A for ; Fri, 12 Oct 2018 20:05:48 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id f20-v6so13786593qta.16 for ; Fri, 12 Oct 2018 17:05: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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=RP9CVJ03wD3A1hR7zPB9vs7rBshC6KZXBiOGMo0R8q0jfrt8eUqviG4rSKhih8hxWA Sg16VXWvE8FSUkgyk3GiIkLVfVyr0GFaEMS4mWQ8EJkQ41yi6TQ66QBEmyfVKKKtKeoq H6jbggSijm6FE69q+YP7KuLCcFrXnZsUvWJ+nRkSu7miLXv0gWCTlCLW+fSdFG6Onwbg XB/kV0zjuPwLe2FSDS9fjjxhzAIsM0yA4/+2sLqOd0WFqUoiiy7MOLbGWEIhuU8MggVK H+Qm8ieyg607L4PvcQ3rhjAShAgnFy5p2QRdRdhOryYPRgUASXNlLggUDZV7o1g9oS18 ojQw== X-Gm-Message-State: ABuFfoimSgDTTPnl19chwgOCLqGQ6ROvoKR0cIaXgInZDs3kPtBVRydP V8TezBvP1c77CvxugW/PnpUMaW8zI816etgB4Q7kVPt1kLaNBstIN6wqI6M6hhmT7zEDZgputss 1HzLpmRkRLCBBd75k50WFJKCyXZiTAiYRZpbvNgrk4qkshDD+uoNY+PjNu4uiomL6qw== X-Received: by 2002:ac8:3f56:: with SMTP id w22-v6mr7694076qtk.151.1539389148634; Fri, 12 Oct 2018 17:05:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV620/n626u7Wi/xq1E8lZAYw8p2+EHDxaYYxlqb9Go8ELV7XAfWUufB0PFN3a5rPMkXI/jtd X-Received: by 2002:ac8:3f56:: with SMTP id w22-v6mr7694054qtk.151.1539389148182; Fri, 12 Oct 2018 17:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389148; cv=none; d=google.com; s=arc-20160816; b=t0MjjRyo0TROXD7nEmpRjJShpuUHGa0U+FGqMYYMV1ht19xALpi3lH1AFHKHzENI4x v9uEvukcR9PQvyfIEOjvVo8Cjwh3hyAg3JX6yV8GGvN6y1scXJVDw7Ru7TcSVykzS+du +FrjV6EKMjzlOAaREVcj5DVXh2hgmhPv82P0CfOQT8FmqWtcHZRRRpYJesZs/Mf9CyL4 EfN7qki4ArsV5JyfwnTpIJlmXPUJMA1rkRGh98ahfU2/w63N6ETC+7uzD66ry2A4CDLM fnJL6ALJSWSQACqcBx82Zq4uROmkGS70A6bRd/8pNtSt6pRqSBSVnWfPoqeG1GyaTUaA m8+A== 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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=YcyQbnErCNsS+mFDKl+r+zYQehhe5hzPrJviOmkNV6s4nweiYrnR0ESOZBL9RBNXBd 9BctU1lkxtvGaMfzoVeB67G0g/AXzQq/+rt8yIuY8GL9X9Kp0kxC0zFZBR1hQwE0V5Tl 1xA+XTCVLHLBA8B8azeQGZXpVwRDT1q8Uo8SjrwNSrB2uF1k6xiBLjaqJ+1ryGcG2mdw /U6fIOKZD1Inlv0pqk+OQbe3szbAJ8/QSciMw/fCSQe77GAIU4vesnuU22DpX8q/o+gi p5UUv/FyA3GV+fP2QMwr08/Nm4qFgZeuM8ECGyOdancO9knRN1aQ1/SQd5hjGFX7WK5j VtIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oNwgpjID; 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 z36-v6si770182qtc.248.2018.10.12.17.05.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:05:48 -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=oNwgpjID; 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 w9D057BO163699; Sat, 13 Oct 2018 00:05: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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=oNwgpjIDNZVADHF5FGmmdkQvamecTKFIaqC7ydjFmufj+jzFl6rFFLISwtTT5t3U9+5U D7MM8isYqFusr3GLyZwmZ5szb86Dtw5SjUtwaHW6XEyNf1UBucufHwN/oE+ikbYrnFSG nlkg07QtKvrOmY2GCsGIhxfBO1/V7coUlLeXERJGusfETdfGTfniSvCkv534a3IA0Xt1 Ad0w0Us+OSSaR5q09HLtl+iwL/wR+dba9bYCgcnA8BzEzVNRh16Q/GT9sBNt4JVWj1JO 3KAFVEfACyq4N9g8fvZWYbONq/P/ksb65LROmKA7kBbCfV2Y9HO3HYGUo+Um2bAifwhc rQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:05:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9D05jCW000443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:05:45 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D05jc7017409; Sat, 13 Oct 2018 00:05:45 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:05:45 +0000 Subject: [PATCH 01/25] xfs: add a per-xfs trace_printk macro 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: Fri, 12 Oct 2018 17:05:36 -0700 Message-ID: <153938913665.8361.8967777059460905975.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=966 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 Add a "xfs_tprintk" macro so that developers can use trace_printk to print out arbitrary debugging information with the XFS device name attached to the trace output. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_error.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 246d3e989c6c..5caa8bdf6c38 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -76,6 +76,11 @@ extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag, unsigned int tag_value); extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); extern int xfs_errortag_clearall(struct xfs_mount *mp); + +/* trace printk version of xfs_err and friends */ +#define xfs_tprintk(mp, fmt, args...) \ + trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \ + MINOR((mp)->m_super->s_dev), ##args) #else #define xfs_errortag_init(mp) (0) #define xfs_errortag_del(mp) @@ -83,6 +88,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp); #define xfs_errortag_set(mp, tag, val) (ENOSYS) #define xfs_errortag_add(mp, tag) (ENOSYS) #define xfs_errortag_clearall(mp) (ENOSYS) +#define xfs_tprintk(mp, fmt, args...) do { } while (0) #endif /* DEBUG */ /* From patchwork Sat Oct 13 00:05:50 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: 10639417 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 6F6961508 for ; Sat, 13 Oct 2018 00:06:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D4CE2B78F for ; Sat, 13 Oct 2018 00:06:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51D462B7A0; Sat, 13 Oct 2018 00:06:03 +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 E4A8F2B78F for ; Sat, 13 Oct 2018 00:06:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 063936B000D; Fri, 12 Oct 2018 20:06:02 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 03B4A6B000E; Fri, 12 Oct 2018 20:06:01 -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 E928A6B0010; Fri, 12 Oct 2018 20:06:01 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id C04936B000D for ; Fri, 12 Oct 2018 20:06:01 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id n1-v6so13689975qtb.17 for ; Fri, 12 Oct 2018 17:06:01 -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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=Z1wCY047urKCLgeXvxA7JODnUF+7bmZzeWAE2FzowsKBHf6m3aFgWJL2yry5xHCxk3 LkluW35vg0V7dXtzoIWC1wL3DFF8RoFyuXqI69bZq7MaqWgp2emWdvYWIYE7hZyvcIBS R84aqbS7rxGo+3ecaxZXepzGXwUW9z5c/nWAtrvVtSfvSgmQRleAAYTseZsTeceA44Qi fRguQ3WIp4fJ7/P+3SRjtqTjVYwj/mBiXTUvbfx19UR8MVhVvTRdnvT0HEZmyhzMRRPf BVapozohwERX/nF897LFgyy/Vq6GaPLQFjW86Go/N28JXcrDcSeRxEPINnWkfadavb6i 4juQ== X-Gm-Message-State: ABuFfoivVqj7r2sItOlA0hBrGgwHopcfdlT3hb3EAUZTuG4hpFj4onsM /gLimjoSnpe7ZAq1hpy1s2jOeUS/ZpxTRsu+osRH/D1Hyy4btWqQbBxKOeelkNuUh+DyAY/ZRzV imAJDOwRmOnlp46OyLEFx2VpljlcndGtjiBpWhJRTohiqgOI7kB4VGUmFwWQ66+iJrg== X-Received: by 2002:ac8:29d3:: with SMTP id 19-v6mr7598098qtt.174.1539389161575; Fri, 12 Oct 2018 17:06:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV6198puzFkkm4QzUT4pnm1tlknLJF5+3SiC/9D86pbsibcrMyah+SJROkQddX5qchXgPt0LJ X-Received: by 2002:ac8:29d3:: with SMTP id 19-v6mr7598085qtt.174.1539389161127; Fri, 12 Oct 2018 17:06:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389161; cv=none; d=google.com; s=arc-20160816; b=Y7bDd/hJB0A0GegRvxmWe4MUjDPF4zsSz9yLss25MgLeH4d796cENN4QodJtEdv4G1 Bbop47wwJTqYic9kHB4ZLObA1mnHBWI4vwVogYJIkYZJ6PP0MMQAhT9eT5Rrvb2wnmWz plv89xlqddJ73D73TkHQgEDo0heeeQBTF/kVnTcNNMn8Yxal+2QpgkBNlCQcU1zh6WCB J3q9rhKHZA0z9RB5TVpEieHRpQTbsE+6zC/adLMGU52joVFlNf+RRI2C+4IP+bEzhGcb Hq2SJfrohro5aeHoXCy9a5CADcFeaKlD8k1iONiHVrh0WLBPUxLwtSoQDvzym9vyKXD/ m0pA== 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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=fZIgKOpT9Mp58pMwwTUxNeEVUuzt0U+pLxlFxz50xl1y70QJK4Dh+1Qh9/P+0sKBuY buLEDmGbneMqZndgyDDzNVUEJkG2y+gp6aw+47bZbJB4tEVShkBidIqGfV04Nik2SxU2 nAYLPmtxMBB8q1+0ZdTP7fRbnupaU2p6BhClDwJ/h1uYTqHmHCVMH46Qp1ZcRvEjyV6k 2q6x9BxQbZij5YMmGplIF4f8iCdiWlWU1sEToTyYvjSZ5GJfWAeUj/YXIysfCQs8HoxZ j9DWA5ChZ+B3DFKUYBXDZ8IdfEXP4EwIS4Somu7mVQo2VkxIVfacXIB5bAi7Y21G5+w1 1FZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="HK/nAUKz"; 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 p43si2467178qvj.72.2018.10.12.17.06.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:01 -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="HK/nAUKz"; 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 w9D03ufS143565; Sat, 13 Oct 2018 00:06:00 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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=HK/nAUKzSLROTDWa3mGInOfY/4F8xzPev5WsvyQknxjDrGdlyJoEPZLIgKRucM1a6ZYn tS2VbCwEehKsmB+/3n7HnrPbYnHbcPc/CzOwXoOOEh4DzX0fQ0XpGCp9cp6lp+j2Uomv LK1zkVHxDqoJkWU+Xa/l0eT6RXpmY059QNNhFwzruM+WnJLUueNC9GgjlkaYG2b9lkN2 weIROM3PpVvbZtRdviMRzfTiiz1g7GGOLz3vEOnPR7fhfiAAjqSIuSWLqmbY1CclBPNk h19lTurxwEs1rVZQDXShLIVtviw4P8toaoLiUgq+TS80vJyOzG5VrFaiiuu2jfbMpfSC CQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2mxmfudpud-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:00 +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 w9D05wH2001052 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:05:58 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D05wpc019165; Sat, 13 Oct 2018 00:05:58 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:05:58 +0000 Subject: [PATCH 02/25] vfs: vfs_clone_file_prep_inodes should return EINVAL for a clone from beyond EOF 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:05:50 -0700 Message-ID: <153938915033.8361.8568201027937509597.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=770 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 vfs_clone_file_prep_inodes cannot return 0 if it is asked to remap from a zero byte file because that's what btrfs does. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 8a2737f0d61d..260797b01851 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1740,10 +1740,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) return -EINVAL; - /* Are we going all the way to the end? */ isize = i_size_read(inode_in); - if (isize == 0) - return 0; /* Zero length dedupe exits immediately; reflink goes to EOF. */ if (*len == 0) { From patchwork Sat Oct 13 00:06:03 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: 10639429 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 5E67F1869 for ; Sat, 13 Oct 2018 00:06:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A5D42B79F for ; Sat, 13 Oct 2018 00:06:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E7B32B7A3; Sat, 13 Oct 2018 00:06:12 +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 6551D2B79F for ; Sat, 13 Oct 2018 00:06:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6CDCB6B0010; Fri, 12 Oct 2018 20:06:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A32B6B0266; Fri, 12 Oct 2018 20:06:10 -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 56BC36B0269; Fri, 12 Oct 2018 20:06:10 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 2C69D6B0010 for ; Fri, 12 Oct 2018 20:06:10 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id y23-v6so13683610qtc.7 for ; Fri, 12 Oct 2018 17:06:10 -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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=uIvbBm7dUk1mS8avt8qlnFLO5hYwT9iqvtHhlwhNxD1aTCOVXOtbXyeHALlf3rVdnO HRpK3UQ1VefKRxY8RyTgUz/wbYWRwpcwdTSxQXs0xnPQIJSEH/PvLmKWvyvwIitxDHF3 /aGJeH5snDjp7SAc9Rwo0viQbRw9//zYUqKlcEl0i4jYzdvsMC1VJQw0LCDKqQfYHbBc 3c0GQaycXXbyTN+lDKlgo7o8Dg7Bwt7caJoQHdNW1E78985UhDtroFE7PVunP/bTpoWp sQ4iTDm6qaPgJgHCzVK1svj1toVVukN4SUIMf1kZYSp0hvNCS4PyofN4NsTCFnoWhLMF EiAg== X-Gm-Message-State: ABuFfojAZPavqeG3zkHtPZgtxPUMHZbQRkw+2tkRf1G2hQ2CZsAP+FZ4 Ts/UVmnekh0puZ406qy6BeuLXS6OjrWw6oFf7YyOKOxbVqBoNnu7TdyfJv9bn1fHRyinj3cAsof dPA21u2TCUnJBk4krXxXCgz9ekcWLjjQghu6QckvxmcwfrPVFZaw0TjI3HYUrOfzzZA== X-Received: by 2002:a37:35c8:: with SMTP id c191-v6mr8031652qka.100.1539389169925; Fri, 12 Oct 2018 17:06:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV61x6uQtJQfYPXv7va9ZINCrn3Etf7HmdIFojt3O2QiiOFcfpwvR9WqlmI6GJOynElaazW88 X-Received: by 2002:a37:35c8:: with SMTP id c191-v6mr8031613qka.100.1539389169047; Fri, 12 Oct 2018 17:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389169; cv=none; d=google.com; s=arc-20160816; b=Un72W7zLTBM/D02nph+H+06C/q3lC0q6egcrsE7z8UihmAsjLOhbQqCT2jd7IpdtiZ cx3CfOefOJMabc6oQXJnRRY1iLsEN0G01/fti0fGgG7eTQHB2OUrMe/IjWIkXE3hmKcx kRK+Mm3zLve12rZLaOnwPbhCX4noW9+qxZoifBK/ArRWQy1PhT0gobO2PRWPEyJxXLhX oC+fhvfsAj4Kss3YBTPpa0B0u8Zwo+EuTUoL2pfGcLjPphXTmEafO5CqzIdGFVIWXOIV 2USInVNWsBtUU9H5i5iu6auK8/J5VkS91K2S2u3yzUTJ2VzTJ8EFn2i2UeX/9JYiTXAL hHzA== 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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=xZjwEuYR6YMQrCeiZxECI/B0Qf0aLJsGPCk4zJpTlxUIWmN5fUqRiOwzbhP07EAQDJ NfuOocICa7u/A1ZowOjbAppwTSdV6Tf5H/Egy8rCvgwXb2pJ1YneMoFyg2PvMB1LTpnV boEFMIDpb2dT9NyLXporNSj9uFk96sjve1ZNHl1yg9GMK/ZfVzMmBd/PStc0778Ku/gp u2o9pev6tuvxY3hxoHj/K4D2/hwGb6qEe/Z21db3Zgo+3F+kvEZWg1uJQBNjqUGLQF76 jyENYTKgvMXVzQu7anX181O6w4IT6BYdOsk6ISHQokTRKJg9CZtKwm6e3x/DqBaMZrj0 /tWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=DF9v2Nsw; 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 f60-v6si2340902qtd.93.2018.10.12.17.06.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:09 -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=DF9v2Nsw; 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 w9D042TG143609; Sat, 13 Oct 2018 00:06:07 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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=DF9v2Nswvy3iyf5vr38RMZSkx5ZJQfksNjmfi4vuZTTwwAWaYcqVDwFRJSkF1oBraPFp to35tL2cQfhK+ltivNPDW5a4Lp+kc9D7R3Hc9iZJhmz6aOtfpQJ5kYb1VmDneH7ahFr9 OuPumC9LII4iIsS1ZAmJYSST7+Sl/UdJXNLDsOzF3BWQ4B141I8CBZYJ7Zk7N8h20dT9 /ZbdAOmq5V0NNdFC38Bf7tG4pcTcoac88t4/gASzCmCpl2Cs2lZM7J3nBDPdkXaiigMb 1uBE2prs+j4x3s8f1TnZVOqnUYy1wdPkBneZYdlSrKvP+zeaSfVwCeQfCLny2gUNvE+4 VA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmfudpv8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:06 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9D066wh001331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:06 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D065dc018643; Sat, 13 Oct 2018 00:06:05 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:05 +0000 Subject: [PATCH 03/25] vfs: check file ranges before cloning files 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:06:03 -0700 Message-ID: <153938916339.8361.14543916522029520891.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=978 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 Move the file range checks from vfs_clone_file_prep into a separate generic_remap_checks function so that all the checks are collected in a central location. This forms the basis for adding more checks from generic_write_checks that will make cloning's input checking more consistent with write input checking. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Amir Goldstein --- fs/ocfs2/refcounttree.c | 2 + fs/read_write.c | 55 +++++++++---------------------------- fs/xfs/xfs_reflink.c | 2 + include/linux/fs.h | 9 ++++-- mm/filemap.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 47 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 7a5ee145c733..19e03936c5e1 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4850,7 +4850,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) goto out_unlock; - ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, + ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, &len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/fs/read_write.c b/fs/read_write.c index 260797b01851..d6e8e242a15f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1717,13 +1717,12 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ -int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, - struct inode *inode_out, loff_t pos_out, - u64 *len, bool is_dedupe) +int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *len, bool is_dedupe) { - loff_t bs = inode_out->i_sb->s_blocksize; - loff_t blen; - loff_t isize; + struct inode *inode_in = file_inode(file_in); + struct inode *inode_out = file_inode(file_out); bool same_inode = (inode_in == inode_out); int ret; @@ -1740,10 +1739,10 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) return -EINVAL; - isize = i_size_read(inode_in); - /* Zero length dedupe exits immediately; reflink goes to EOF. */ if (*len == 0) { + loff_t isize = i_size_read(inode_in); + if (is_dedupe || pos_in == isize) return 0; if (pos_in > isize) @@ -1751,36 +1750,11 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, *len = isize - pos_in; } - /* Ensure offsets don't wrap and the input is inside i_size */ - if (pos_in + *len < pos_in || pos_out + *len < pos_out || - pos_in + *len > isize) - return -EINVAL; - - /* Don't allow dedupe past EOF in the dest file */ - if (is_dedupe) { - loff_t disize; - - disize = i_size_read(inode_out); - if (pos_out >= disize || pos_out + *len > disize) - return -EINVAL; - } - - /* If we're linking to EOF, continue to the block boundary. */ - if (pos_in + *len == isize) - blen = ALIGN(isize, bs) - pos_in; - else - blen = *len; - - /* Only reflink if we're aligned to block boundaries */ - if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || - !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) - return -EINVAL; - - /* Don't allow overlapped reflink within the same file */ - if (same_inode) { - if (pos_out + blen > pos_in && pos_out < pos_in + blen) - return -EINVAL; - } + /* Check that we don't violate system file offset limits. */ + ret = generic_remap_checks(file_in, pos_in, file_out, pos_out, len, + is_dedupe); + if (ret) + return ret; /* Wait for the completion of any pending IOs on both files */ inode_dio_wait(inode_in); @@ -1813,7 +1787,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, return 1; } -EXPORT_SYMBOL(vfs_clone_file_prep_inodes); +EXPORT_SYMBOL(vfs_clone_file_prep); int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) @@ -1851,9 +1825,6 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - if (pos_in + len > i_size_read(inode_in)) - return -EINVAL; - ret = file_in->f_op->clone_file_range(file_in, pos_in, file_out, pos_out, len); if (!ret) { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 42ea7bab9144..281d5f53f2ec 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1326,7 +1326,7 @@ xfs_reflink_remap_prep( if (IS_DAX(inode_in) || IS_DAX(inode_out)) goto out_unlock; - ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, + ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/include/linux/fs.h b/include/linux/fs.h index 897eae8faee1..ba93a6e7dac4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1825,9 +1825,9 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *, unsigned long, loff_t *, rwf_t); extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); -extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, - struct inode *inode_out, loff_t pos_out, - u64 *len, bool is_dedupe); +extern int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *count, bool is_dedupe); 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, @@ -2967,6 +2967,9 @@ extern int sb_min_blocksize(struct super_block *, int); extern int generic_file_mmap(struct file *, struct vm_area_struct *); extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); +extern int generic_remap_checks(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + uint64_t *count, bool is_dedupe); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index 52517f28e6f4..47e6bfd45a91 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2974,6 +2974,75 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) } EXPORT_SYMBOL(generic_write_checks); +/* + * Performs necessary checks before doing a clone. + * + * Can adjust amount of bytes to clone. + * Returns appropriate error code that caller should return or + * zero in case the clone should be allowed. + */ +int generic_remap_checks(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + uint64_t *req_count, bool is_dedupe) +{ + struct inode *inode_in = file_in->f_mapping->host; + struct inode *inode_out = file_out->f_mapping->host; + uint64_t count = *req_count; + uint64_t bcount; + loff_t size_in, size_out; + loff_t bs = inode_out->i_sb->s_blocksize; + + /* The start of both ranges must be aligned to an fs block. */ + if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_out, bs)) + return -EINVAL; + + /* Ensure offsets don't wrap. */ + if (pos_in + count < pos_in || pos_out + count < pos_out) + return -EINVAL; + + size_in = i_size_read(inode_in); + size_out = i_size_read(inode_out); + + /* Dedupe requires both ranges to be within EOF. */ + if (is_dedupe && + (pos_in >= size_in || pos_in + count > size_in || + pos_out >= size_out || pos_out + count > size_out)) + return -EINVAL; + + /* Ensure the infile range is within the infile. */ + if (pos_in >= size_in) + return -EINVAL; + count = min(count, size_in - (uint64_t)pos_in); + + /* + * If the user wanted us to link to the infile's EOF, round up to the + * next block boundary for this check. + * + * Otherwise, make sure the count is also block-aligned, having + * already confirmed the starting offsets' block alignment. + */ + if (pos_in + count == size_in) { + bcount = ALIGN(size_in, bs) - pos_in; + } else { + if (!IS_ALIGNED(count, bs)) + return -EINVAL; + + bcount = count; + } + + /* Don't allow overlapped cloning within the same file. */ + if (inode_in == inode_out && + pos_out + bcount > pos_in && + pos_out < pos_in + bcount) + return -EINVAL; + + /* For now we don't support changing the length. */ + if (*req_count != count) + return -EINVAL; + + return 0; +} + int pagecache_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) From patchwork Sat Oct 13 00:06:10 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: 10639441 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 650BD1508 for ; Sat, 13 Oct 2018 00:06:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F5EB2B78F for ; Sat, 13 Oct 2018 00:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 434312B7A0; Sat, 13 Oct 2018 00:06:19 +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 A28722B78F for ; Sat, 13 Oct 2018 00:06:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 89FEC6B0269; Fri, 12 Oct 2018 20:06:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 87A5B6B026A; Fri, 12 Oct 2018 20:06:17 -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 769606B026B; Fri, 12 Oct 2018 20:06:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 488BE6B0269 for ; Fri, 12 Oct 2018 20:06:17 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id c33-v6so13943025qta.20 for ; Fri, 12 Oct 2018 17:06:17 -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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=mpzyTTozNnx6XdbDgRro02TF/4sauNzO55PD6ERAEi8fUO/xYkNmVGBPH8pFZYg0Ah hkpuRNhdFqtGMevafVi+1KthdQIuFbKP4iGEwNQWJdyoXGwYpcSOqLVJcY7trl4WLAke 5NHyNB1wekqDGMdZUp8q988A42dIySPK0PnKcZsEv0tgSerPg7gYU/CJprpI8MACz/mf hJOwkVr2Cj1txl9FvC6nigzQbVGgTC4bp2gyHHreAgkRDquEI2AvOJiQbe35O+rDMQot 7yvOcc21EUIYbGdjlq4oCHSq9PCVYBfjrgpGd0CxL0YmJjRlWDR9buEahNw/OKRRxjSS H6rQ== X-Gm-Message-State: ABuFfoi+jiFZvvsI327ta0LCcE0x09R5U+q46AqZeQjdE+PWTePOmHxT I9li1ZcZwKSXUsjNcHqVXbVzT8U5lWfaHtNCcASaiUBE5oBNkjkuAE/mQ/m4XkaZIFeWV8OZekh ixOGaRZ+Sgznah/fzhhyGpKrWQLgQKaP38aSqA+6UmhRUdeEwJJQdiKMrbR+eq4Bddg== X-Received: by 2002:a37:8e01:: with SMTP id q1-v6mr7793770qkd.59.1539389177046; Fri, 12 Oct 2018 17:06:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV60oXSCcKILXLCxKZN11b/OPLpk5HmYctuUMgx28qsToPtnkZ0Jcb+ejGtcJ3hV2FHzpB2Uy X-Received: by 2002:a37:8e01:: with SMTP id q1-v6mr7793724qkd.59.1539389176361; Fri, 12 Oct 2018 17:06:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389176; cv=none; d=google.com; s=arc-20160816; b=hd5xEEga+BfIoy05lcm2RMQIfvrPheVO0JvQ0l2OAikLyizqNat7Xkc65LDnhKAoM6 3kjTyrdkEMHCqhGTfaDGQ8eOmXfN0HWvbnwpD8fSxTP4xE3zNEZCVDUigl9hk/35fUi2 fH7mBAtWwA044HSPixkI9hpObwxLE4puNDUdSu+2L2L6tXzJ4h9sizND+ap4KpZ4BRi2 XxjIfuN44+SQPQaQeDEG4XgtY6zNFoJVYVVVY0D7KY4/TIO8eunwyGpqRusoAiNlj4Jw AQDnXVfoHqFNiZyjYrMS/YFs1+oHwk2WZ/vDfPDlUg5bxHQg3WUmfDOKZ68ygIpEYEAX ZlDg== 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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=KFQVl3HhadwQWBgwTKKLvfBys83e6eLL/JGok3rvCB0VDjE413FmINGK0ZVPWsUBVW H1NI5TNKex+5M7o9Vuid8yiIzaLt0NhvwAcOJYKRxrKQHVip24S/xLs8Tg2WDOYpw/Et oXVQTyqSdXEqCAFMrUg7z5OLP8Hz94fuA8kc7q016Sl+fXAs/FjvWug9xEwnKPRNRZbA /jBqBr/OxohdIbPvxV6a+M4j5Y7wx7JUYNsiSyLyxQrLUiXBKjv90quDLWBDoH/JgFzO 0iy+sliLLBViMQuDIqdHRacUbdAWN++LEmloaLqUk+JKbIItBBbD1WX4e2hpEAWXsj/E lxXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gWE8jXIv; 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 a76-v6si2271378qkh.119.2018.10.12.17.06.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:16 -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=gWE8jXIv; 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 w9D04Zvn163352; Sat, 13 Oct 2018 00:06:14 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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=gWE8jXIvAdOjeBZVQCZUSJI/S8SMRqk2c7x8duVDD7y9vfNbpF19Ua+yAK6cCw3z9fU0 U36bKSPNwYk2hvi8h0z9giy/eSbLQunuty/yd1abd+P60oo2pFrgEF1h8fXG2R/6tzgX QIKJV6ioG6bjS0phRmHGDeuEf3fnC7BeD8PhwyGGv79sKVJlvzEbXAUaliXz/5K9AwDN S4LSHboKN1WU7VMFUsbv9ysAgTJu2wVDtKOp4a1a6z5aM+AjKiCRA8aDyEX7lrG6Uhew 0zAc+llFs9CILxZYrzFMhgRydg/RfgM8E/YHZpxIrHMIZx6ThPAwlZeoZHld0O+kgy0u sw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:14 +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 w9D06DUB001541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:13 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06CXn029817; Sat, 13 Oct 2018 00:06:12 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:12 +0000 Subject: [PATCH 04/25] vfs: strengthen checking of file range inputs to generic_remap_checks 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:06:10 -0700 Message-ID: <153938917040.8361.8262720501664468642.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 File range remapping, if allowed to run past the destination file's EOF, is an optimization on a regular file write. Regular file writes that extend the file length are subject to various constraints which are not checked by range cloning. This is a correctness problem because we're never allowed to touch ranges that the page cache can't support (s_maxbytes); we're not supposed to deal with large offsets (MAX_NON_LFS) if O_LARGEFILE isn't set; and we must obey resource limits (RLIMIT_FSIZE). Therefore, add these checks to the new generic_remap_checks function so that we curtail unexpected behavior. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- mm/filemap.c | 91 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 47e6bfd45a91..08ad210fee49 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2915,6 +2915,49 @@ struct page *read_cache_page_gfp(struct address_space *mapping, } EXPORT_SYMBOL(read_cache_page_gfp); +static int generic_access_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + struct inode *inode = file->f_mapping->host; + + /* Don't exceed the LFS limits. */ + if (unlikely(pos + *count > MAX_NON_LFS && + !(file->f_flags & O_LARGEFILE))) { + if (pos >= MAX_NON_LFS) + return -EFBIG; + *count = min(*count, (loff_t)MAX_NON_LFS - pos); + } + + /* + * Don't operate on ranges the page cache doesn't support. + * + * If we have written data it becomes a short write. If we have + * exceeded without writing data we send a signal and return EFBIG. + * Linus frestrict idea will clean these up nicely.. + */ + if (unlikely(pos >= inode->i_sb->s_maxbytes)) + return -EFBIG; + + *count = min(*count, inode->i_sb->s_maxbytes - pos); + return 0; +} + +static int generic_write_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + unsigned long limit = rlimit(RLIMIT_FSIZE); + + if (limit != RLIM_INFINITY) { + if (pos >= limit) { + send_sig(SIGXFSZ, current, 0); + return -EFBIG; + } + *count = min(*count, (loff_t)limit - pos); + } + + return generic_access_check_limits(file, pos, count); +} + /* * Performs necessary checks before doing a write * @@ -2926,8 +2969,8 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - unsigned long limit = rlimit(RLIMIT_FSIZE); - loff_t pos; + loff_t count; + int ret; if (!iov_iter_count(from)) return 0; @@ -2936,40 +2979,15 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_flags & IOCB_APPEND) iocb->ki_pos = i_size_read(inode); - pos = iocb->ki_pos; - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) return -EINVAL; - if (limit != RLIM_INFINITY) { - if (iocb->ki_pos >= limit) { - send_sig(SIGXFSZ, current, 0); - return -EFBIG; - } - iov_iter_truncate(from, limit - (unsigned long)pos); - } + count = iov_iter_count(from); + ret = generic_write_check_limits(file, iocb->ki_pos, &count); + if (ret) + return ret; - /* - * LFS rule - */ - if (unlikely(pos + iov_iter_count(from) > MAX_NON_LFS && - !(file->f_flags & O_LARGEFILE))) { - if (pos >= MAX_NON_LFS) - return -EFBIG; - iov_iter_truncate(from, MAX_NON_LFS - (unsigned long)pos); - } - - /* - * Are we about to exceed the fs block limit ? - * - * If we have written data it becomes a short write. If we have - * exceeded without writing data we send a signal and return EFBIG. - * Linus frestrict idea will clean these up nicely.. - */ - if (unlikely(pos >= inode->i_sb->s_maxbytes)) - return -EFBIG; - - iov_iter_truncate(from, inode->i_sb->s_maxbytes - pos); + iov_iter_truncate(from, count); return iov_iter_count(from); } EXPORT_SYMBOL(generic_write_checks); @@ -2991,6 +3009,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, uint64_t bcount; loff_t size_in, size_out; loff_t bs = inode_out->i_sb->s_blocksize; + int ret; /* The start of both ranges must be aligned to an fs block. */ if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_out, bs)) @@ -3014,6 +3033,14 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, return -EINVAL; count = min(count, size_in - (uint64_t)pos_in); + ret = generic_access_check_limits(file_in, pos_in, &count); + if (ret) + return ret; + + ret = generic_write_check_limits(file_out, pos_out, &count); + if (ret) + return ret; + /* * If the user wanted us to link to the infile's EOF, round up to the * next block boundary for this check. From patchwork Sat Oct 13 00:06:17 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: 10639453 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 33B091508 for ; Sat, 13 Oct 2018 00:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2180C2B78F for ; Sat, 13 Oct 2018 00:06:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 154002B7A3; Sat, 13 Oct 2018 00:06:29 +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 8B8C92B78F for ; Sat, 13 Oct 2018 00:06:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8EF3A6B026B; Fri, 12 Oct 2018 20:06:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C6006B026C; Fri, 12 Oct 2018 20:06:27 -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 7DB3A6B026D; Fri, 12 Oct 2018 20:06:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 65E456B026B for ; Fri, 12 Oct 2018 20:06:27 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id q6-v6so13962098qtb.14 for ; Fri, 12 Oct 2018 17:06:27 -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=xkQw5bqFc5oVHdL+kJccEryf71PZClBt8QhI7IJ3dac=; b=AvNfl4XVKmMZK4t6qgSqj+CaHYeJ5Ryvvwqrms1afCBnGnu1sNvw7EuyTm232kTwWT nm9+tY+NwdtZGne60Dc+Je84KVfleSpGfm7vwvfmX1zVyorzZl6dSI51+BXTA+Evf7+5 M/BLFDNX1PnHU3MYU4Cnif9wmahKjlxkq88keyFY049pnR7PLoqTg5KkGb+uFlVMIHrv ofsDOLU23RpD/wyNDVgKR+u6rnzVNr1MzxjFaWpR+GojyjkOv7z63XRN2XgMgrtt7Hrx hVCMUwAwLJ6PBHzPHTI3FycH/gs2R5/wfiwWMEy+Ha2AlC/r91Z2g6WvLAeTCmmf6IZ4 bJYg== X-Gm-Message-State: ABuFfojVB1TG5Rs/ruhNr4L78yiTHEpTA2xn9/KkLE9DcIHotBVxiPFs 5RI2us5s/yQAPKun+vLDgkq3fkxanjrI7tp/ethulftBvMljaI8K4IMTu6mvDAt4i85lXwvTexj vJUJ0PdpEmeX99lThGL+YeUNURrVWhVllDfGqKZPdLH2ooCMR2gcQIwbhPinDW/2JOA== X-Received: by 2002:a37:8c42:: with SMTP id o63-v6mr7444481qkd.187.1539389187161; Fri, 12 Oct 2018 17:06:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Gw7ZKTCax2tzpBhyQRkCO7grH2g4XaUh4JkGzSlAbO9U6+tw82MAvxheKD2ZkAoQ4TvxQ X-Received: by 2002:a37:8c42:: with SMTP id o63-v6mr7444453qkd.187.1539389186520; Fri, 12 Oct 2018 17:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389186; cv=none; d=google.com; s=arc-20160816; b=uLhq+XF7iwTkn9XPzZ9VzvpQgy3R6Z7e0gMM2IZHtaK36qoRHdIuz2U4zHCljFgLU9 RK2vkx97QwhL9+O7dMiau3AOWY+yDTn5xfKRb547BQMzrz6sTHO0iTHogmf6FumOcKuP rLbJ63yhIEGXE5EfoxpNnXEy9GJp22C+VKAsdGaJVn1fopleikmxXNIDtR/6zIcKNO3f 0KeXn7HuzeegZW7/Xi1nn3okccM44qdWgBo/ME+5S8mwx8/c3cHEydP41+luKzF+jU0+ p6TDDN31rSIU3WJCAVZxmzKciKj7ujDqLYBfc9i4Q+wUKWulBU3bWfE1vc7jO6WeUvLe bDiA== 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=xkQw5bqFc5oVHdL+kJccEryf71PZClBt8QhI7IJ3dac=; b=bAx7vd2is3tr179dQYA+CxO0BDE1LjQoYyjbzD39hosC7TIbhWmqQVQJCoY8SugGLG XzMsJE3EQuAaRc/HyrkHvF20NWXYCCCwnxmEjtrn47mDcdzUGTm66msSkqNhel5J/SzQ b0m1cVs0sMP5MAP/Dn7/SXkkJiFDonq6RqGFnfCjtq9u5xCtUrubYqeA+kmGXRfDIpcT AUB98cuRkHTjRkc2KfBJnY5fda2JCwQkEeurDGOF5yTWFkYypjBQBKJwPnVwsANa1vjG xwwF24VxPImpkAzMzMs3UMSihuirqW6hq4SRlHqhXq07OhKXZ2NrqZeU+1hN19OmEM1G DXGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="sy49W/G+"; 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 e55-v6si2490465qvd.50.2018.10.12.17.06.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:26 -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="sy49W/G+"; 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 w9D03wHN143579; Sat, 13 Oct 2018 00:06:25 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=xkQw5bqFc5oVHdL+kJccEryf71PZClBt8QhI7IJ3dac=; b=sy49W/G+fFu1XZDyPsSt3TzaneGu0yxpOY6V/+gwG0ny1c60cxENmaAndGNeWQtlHw4E jGrDQa4luQZGOM497reD9HMJRakvuJmgmyUB3TcJ0LsWnJGSf1pRCdeQaOwufq5i2cD+ JroJJEljl+RsiTshmGtJBPxIOhnwOO7mnzi9F3r20eXJDxInQRLpdYLi2R0dZRSexP1+ VZoMm+Zok+iRnMyvH8vR2jv5FIrJoiidrHx0pDCQfEGNhCCEwko5feVxEwnVT8WiEiJo Zf92VDj7hL27ax2ztdY6YnJxJduSOG9ZvKGvg2FMo/04yNwtweTlJXYSzw/yevCOoqoR 1A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfudpw3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:25 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06JKH021744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:19 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D06Jgw017650; Sat, 13 Oct 2018 00:06:19 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:19 +0000 Subject: [PATCH 05/25] vfs: avoid problematic remapping requests into partial EOF block 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: Fri, 12 Oct 2018 17:06:17 -0700 Message-ID: <153938917765.8361.15966712047859994604.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=613 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 A deduplication data corruption is exposed in XFS and btrfs. It is caused by extending the block match range to include the partial EOF block, but then allowing unknown data beyond EOF to be considered a "match" to data in the destination file because the comparison is only made to the end of the source file. This corrupts the destination file when the source extent is shared with it. The VFS remapping prep functions only support whole block dedupe, but we still need to appear to support whole file dedupe correctly. Hence if the dedupe request includes the last block of the souce file, don't include it in the actual dedupe operation. If the rest of the range dedupes successfully, then reject the entire request. A subsequent patch will enable us to shorten dedupe requests correctly. When reflinking sub-file ranges, a data corruption can occur when the source file range includes a partial EOF block. This shares the unknown data beyond EOF into the second file at a position inside EOF, exposing stale data in the second file. If the reflink request includes the last block of the souce file, only proceed with the reflink operation if it lands at or past the destination file's current EOF. If it lands within the destination file EOF, reject the entire request with -EINVAL and make the caller go the hard way. A subsequent patch will enable us to shorten reflink requests correctly. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index d6e8e242a15f..067ff5698e0b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1723,6 +1723,7 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); + u64 blkmask = i_blocksize(inode_in) - 1; bool same_inode = (inode_in == inode_out); int ret; @@ -1785,6 +1786,22 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, return -EBADE; } + /* Are we doing a partial EOF block remapping of some kind? */ + if (*len & blkmask) { + /* + * If the dedupe data matches, chop off the partial EOF block + * from the source file so we don't try to dedupe the partial + * EOF block. + * + * If the user is attempting to remap a partial EOF block and + * it's inside the destination EOF then reject it. + */ + if (is_dedupe) + *len &= ~blkmask; + else if (pos_out + *len < i_size_read(inode_out)) + return -EINVAL; + } + return 1; } EXPORT_SYMBOL(vfs_clone_file_prep); From patchwork Sat Oct 13 00:06:24 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: 10639467 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 66F791508 for ; Sat, 13 Oct 2018 00:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5344D2B78F for ; Sat, 13 Oct 2018 00:06:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479A02B7A0; Sat, 13 Oct 2018 00:06:33 +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 D9F4D2B79F for ; Sat, 13 Oct 2018 00:06:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98D236B026D; Fri, 12 Oct 2018 20:06:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93A496B026E; Fri, 12 Oct 2018 20:06:31 -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 852356B026F; Fri, 12 Oct 2018 20:06:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 57E8C6B026D for ; Fri, 12 Oct 2018 20:06:31 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id f81-v6so13542046qkb.14 for ; Fri, 12 Oct 2018 17:06:31 -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=tBsOiKs5Tphii3LWAmGXkEUO5FMwTmp8KPFNnf+7h0M=; b=kqaojsOGyK4aWLI1iLBcmVYtULWNRpnQeVO5ehx8g8cJqNp5xKOENvbYWm3Ji7Gk+7 P3UyQnj/B7Ue0kklHU71v1cqE/LC1YRhKSfg+ASeZaFI1PaTxHEEsndlswm7fqrA2zlC emlCBhmYnqf1jGNx9GzEFZixQ+NE7Mm1S0sxk/8e4ihtu/1VM4Yj5uMIsfdtNWYo97jx rvlLL2oQsdDe4jfWifTOW4/hvV5EhkxgiArqSN+fIg4iEiggt4tqbJfKJGst/1BpkrwR BDncW66xqsv4cOPZG3WIKLTMDFbOdb7gY6hNa/dbvNAbnjjvVTaDm3+rZ68zKFGiBjn+ d6YQ== X-Gm-Message-State: ABuFfoiybc2d99qy75s2lYMnjG2mx3l9Z5phDqkiG8YJpk0n9nTWcbhE ABEB/XZWX1c55aHFUSuq8jvBnNl2f/YhR8MulaHeFEWX9q3tt9VQH/4xN1IsoU0mIfWOWgq0rxU NYtNVMKKMYBvRtz3qQOwmtK0VQgEuU+v95tdDFj/pfyrhobo2cDriKvnTwrX4MxnNbg== X-Received: by 2002:a37:3947:: with SMTP id g68-v6mr7247512qka.289.1539389191072; Fri, 12 Oct 2018 17:06:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV62hr0fZCZcdZGY5kOdRYUjvGyZS1QxnYl9KT15Zvlr92/KVwBJFGXFFtOoUlUwVu7MQfRLN X-Received: by 2002:a37:3947:: with SMTP id g68-v6mr7247493qka.289.1539389190660; Fri, 12 Oct 2018 17:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389190; cv=none; d=google.com; s=arc-20160816; b=i4h07jmn81tiQsMSIirPqMWcsPxOqvU7u9n3VJieFVikFDfUyQIwqv/L9TnLAzZAQY /704WpPvAbUyw+n6mguF/IaPR5R9F9jWEm0HF5H/ZZc19U6w0sNqctf7KSC1bMGX4E7y NkjdkM3dM9N9B0Hp9waRtTXo0poj6ogc8EIYQ8G8UQNlHSdELG8RhTYeR9YWmJQcFwna 68xPj4cR/75eFmzTwW+2Q/11M9NBsNwewpoWYUHUlcxR3ZOEBSXjKUty86RfWmT1y3H5 9D3CEgyWQGJRe5e8C7hn8KLuuvtDFPxhIRUF/NJwTfRDpKdBIccfxVA8W9Y6+rQCE82k AJWQ== 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=tBsOiKs5Tphii3LWAmGXkEUO5FMwTmp8KPFNnf+7h0M=; b=QuKI3R1cNiId19ZiQ06quefFOzi91Tpb47Mt84BKbTcotkQEZjrWKjrgqxKHQvz6FW cWmmDNPe7pKhCQ/jUPB9iTNKQKMEXbGl6i19ELAany8BMo05SfzlWxaAoo9aaoS/17jC pj6LoiTt6vCGD/B0WrLH7BqzaseinUKMCcfPmhweySDr6LeVtKm53D009ee9cuXIg5Jy ZogEq+Tv8A6kpCb/+/qawQw9FzkA/0ZXj3OqNT34WeXsm6KUIAUZ7XWJejDlOg6bGgjy jY6Ak+IvwAHFWZ5xhvyC8SgT4V+b1ae+enzBsP1fPsYNi7eTUSrHRvP2BYvk+9jeDbFH H6Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=4w6RlY2y; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id v12si2507490qve.43.2018.10.12.17.06.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=4w6RlY2y; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D04Hmc104817; Sat, 13 Oct 2018 00:06:28 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=tBsOiKs5Tphii3LWAmGXkEUO5FMwTmp8KPFNnf+7h0M=; b=4w6RlY2ySxTaUwhaglkZLfH+0LwgfU/00dt3FTLBTdt733YOye26GqEEUEB+1r06lFOi tnYR27ACqyp0dUtEn0wySOmQQDre6ce0zeRnt9w71RWbs1YCRQg/XA8n5u200+Z9ofBA sMvA/KreJmfecL8io0OHt95XAEzYYClreEcNzC1bXClJn91ItIlvS9ny9wK61dS8X1FB WsIEB/oabVrT8TGe3GMEnb6tvb1LE9MepPeF2lCTHF+uvmTpHng2NBAMjITT+D6YvGLy PWfsAAFWipvmlLRxKzSE11hE1uovw+LBfjDzPWWEIJlQ1c2BYEG1HfCd6NhNVJz2X3Db xA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprnfgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:28 +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 w9D06RBk017631 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:27 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06QL2030265; Sat, 13 Oct 2018 00:06:26 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:25 +0000 Subject: [PATCH 06/25] vfs: skip zero-length dedupe requests 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:06:24 -0700 Message-ID: <153938918436.8361.13374851564644374971.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=749 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 Don't bother calling the filesystem for a zero-length dedupe request; we can return zero and exit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Amir Goldstein --- fs/read_write.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 067ff5698e0b..2d84d18dc095 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1991,6 +1991,11 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, if (!dst_file->f_op->dedupe_file_range) goto out_drop_write; + if (len == 0) { + ret = 0; + goto out_drop_write; + } + ret = dst_file->f_op->dedupe_file_range(src_file, src_pos, dst_file, dst_pos, len); out_drop_write: From patchwork Sat Oct 13 00:06:31 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: 10639481 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 481DB1869 for ; Sat, 13 Oct 2018 00:06:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328A02B78F for ; Sat, 13 Oct 2018 00:06:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2688D2B7A3; Sat, 13 Oct 2018 00:06:40 +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 E37E52B78F for ; Sat, 13 Oct 2018 00:06:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 962F76B026F; Fri, 12 Oct 2018 20:06:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 93C056B0270; Fri, 12 Oct 2018 20:06:37 -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 7DCB96B0271; Fri, 12 Oct 2018 20:06:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by kanga.kvack.org (Postfix) with ESMTP id 4B3026B026F for ; Fri, 12 Oct 2018 20:06:37 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id f20-v6so13788272qta.16 for ; Fri, 12 Oct 2018 17:06:37 -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=yq/gHuRRPNJDeieeIi58yMdJYYsIoZEKO8MrefBpSDI=; b=R0+sNrUFzwXQWboEy2uQ9mb/fM2TLLOS9elxn63fZ/pbP//d8ySM/rz8PdP3YMIRrG wojrZ5A1Sxt//QBKiF4axWeEbxSvSVsVUG3zWxXJzENZ/iR6hPhmNEZ1qme8EogLSdyI pQKUVQlI+HxlEJYAMOGt+JbDNjc5C5+IQPLUVd3ggwCEcdGGk3AwXWT4BM92PVk9hGeN 4rnb/HBGb9ejEUCTvBHRVPs2DL3AfBfV3Xw8BU0AIXo0+sNNDpwszA7RzYLir/ks7bMe 1+q4SX7Osq16M60BVB/zt54A53GFzmUIrZFct1Fysj5Q15jxh81gxSeSN9G4upfV7XGS lP+g== X-Gm-Message-State: ABuFfoi+jYoeCGRQ4qkIEMuahIU1SLz7gzb0r6o9bSqv3WC22fbAi09r v1nipCogcsQ5LIOzlw3LLvs/IV/H3Yqjd5ZWMUiKBRRf3b4ybTJvODduQu3EZnO7sLqhOgpylGn XFiYp6vbk2pQL0a/ipa8FBGbVMPwhLSLWAnFaUPSDOy008p/4XsyuPFB3u0Gv3GOurQ== X-Received: by 2002:a37:48e:: with SMTP id 136-v6mr7420772qke.316.1539389197037; Fri, 12 Oct 2018 17:06:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV61d+9FKdaBpLwYVPoYjHXW41ldxSFUw3I7gkgSeaL12yFZaKYM6QbjzE0ZoJe5YkKjUCgyR X-Received: by 2002:a37:48e:: with SMTP id 136-v6mr7420712qke.316.1539389195879; Fri, 12 Oct 2018 17:06:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389195; cv=none; d=google.com; s=arc-20160816; b=eKO0EB4mNUPEG/TxghJkL8R780eTUQPU5W64WgH2gK1oE6DnVklt3heGZ/M+FhB41y lFe82oToZWpaW9a66FVTkYUzMCn2p1xh9XTd8sThif154xoo3mz8Oi2Y0byB/YoLSTat 67w5733itaobySS6tsA9JOVssz43nX8GKW1r3IPI+LieW+dUap6JIRPFZoGpBTQa3x93 ZRnUMvzAPM9dx4v3MYpx504/7M6Gsr1ydt7lK7yiaJGNxIuB84RJ2f0NqNFqOoKRTYaW g21CLKWeaV5AQ2exl/mVhowgFQCxkcs+d1wDqzDiiUDxBBICv3CCLaDbCl73Q5J1LeBz 43HA== 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=yq/gHuRRPNJDeieeIi58yMdJYYsIoZEKO8MrefBpSDI=; b=Xs1RNnGPwUVVak0GU8tMqgX69R+cQYRQO8mN5UmQtzTbhZDcWrCGD/Y7YLlrhe2uih jkELcMIPsUIjUVXpKqaC66G9EyXGTTO8QPOj7ata4Z138SwgnSaO7E5EFq2ymK2bKAWA FBw4TmNj3BfDcMCZZDcdeicDB0wQD9O3KR6Zo7aOi6wGDaOKyKUCX9gvZbdDNeUJWIEI QyfF8fhENd769QUmXzKL85OkKawPEljhgrNNFlrkUKXcJNRVJjdcHaS59ULCc5T7Mpdn 7oiBqB7H7PvMYatE+c8udkKRzsOe2MFFcF6GkxY1v2N/ywfCni1yVQ5L7FpNDRQ5OnzR ArGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Rh9OKooF; 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 55si867524qvl.84.2018.10.12.17.06.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:35 -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=Rh9OKooF; 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 w9D044al163224; Sat, 13 Oct 2018 00:06:33 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=yq/gHuRRPNJDeieeIi58yMdJYYsIoZEKO8MrefBpSDI=; b=Rh9OKooFFh6UM2aYvKtvelxWyIGYj4G/f0kmYuT+gM4338PM9omNy/cvWZ/zqCyOe4UV lcJNUUbSjHpcMytDSYkv53K4CsYsfTvkKM+WjMJ7BALVmDCElVH61Vilpmvmoz3ocIDn 6edeabEsWt3aX08qbo85TnQ6d9PnRgZ2lonJIiAsNOz7+UQej4+JuY41002P/4g2cFZ2 lp0j66KFzQuVHcYm1TxQE/BVuU4UuFuuiFrydeGIkDLdes978lfEeSIdWD63ddrVJF2I yYTF9fYvtA0N3XaFi5luV3jRkGORgOIYvTA2dVY6R4eovxEpeancUUkZQjjB1GvXsZdH Bg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:33 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06Xjh017788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:33 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D06Xhe017700; Sat, 13 Oct 2018 00:06:33 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:32 +0000 Subject: [PATCH 07/25] vfs: combine the clone and dedupe into a single remap_file_range 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:31 -0700 Message-ID: <153938919123.8361.13059492965161549195.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 Combine the clone_file_range and dedupe_file_range operations into a single remap_file_range file operation dispatch since they're fundamentally the same operation. The differences between the two can be made in the prep functions. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 12 ++++------ fs/btrfs/ctree.h | 8 ++----- fs/btrfs/file.c | 3 +- fs/btrfs/ioctl.c | 45 +++++++++++++++++++------------------ fs/cifs/cifsfs.c | 22 +++++++++++------- fs/nfs/nfs4file.c | 10 ++++++-- fs/ocfs2/file.c | 24 +++++++------------- fs/overlayfs/file.c | 30 ++++++++++++++----------- fs/read_write.c | 18 +++++++-------- fs/xfs/xfs_file.c | 23 ++++++------------- include/linux/fs.h | 27 +++++++++++++++++++--- 11 files changed, 116 insertions(+), 106 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index a6c6a8af48a2..2ec27203e4a6 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -883,8 +883,9 @@ struct file_operations { unsigned (*mmap_capabilities)(struct file *); #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); - int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); + int (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); }; @@ -960,11 +961,8 @@ otherwise noted. copy_file_range: called by the copy_file_range(2) system call. - clone_file_range: called by the ioctl(2) system call for FICLONERANGE and - FICLONE commands. - - dedupe_file_range: called by the ioctl(2) system call for FIDEDUPERANGE - command. + remap_file_range: called by the ioctl(2) system call for FICLONERANGE and + FICLONE and FIDEDUPERANGE commands to remap file ranges. fadvise: possibly called by the fadvise64() system call. diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2cddfe7806a4..124a05662fc2 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3218,9 +3218,6 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info, struct btrfs_ioctl_balance_args *bargs); -int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, - struct file *dst_file, loff_t dst_loff, - u64 olen); /* file.c */ int __init btrfs_auto_defrag_init(void); @@ -3250,8 +3247,9 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, struct extent_state **cached); int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); -int btrfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len); +int btrfs_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, u64 len, + unsigned int remap_flags); /* tree-defrag.c */ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 2be00e873e92..9a963f061393 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3269,8 +3269,7 @@ const struct file_operations btrfs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = btrfs_compat_ioctl, #endif - .clone_file_range = btrfs_clone_file_range, - .dedupe_file_range = btrfs_dedupe_file_range, + .remap_file_range = btrfs_remap_file_range, }; void __cold btrfs_auto_defrag_exit(void) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index d60b6caf09e8..bed5b8f9ec09 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3627,26 +3627,6 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, return ret; } -int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, - struct file *dst_file, loff_t dst_loff, - u64 olen) -{ - struct inode *src = file_inode(src_file); - struct inode *dst = file_inode(dst_file); - u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; - - if (WARN_ON_ONCE(bs < PAGE_SIZE)) { - /* - * Btrfs does not support blocksize < page_size. As a - * result, btrfs_cmp_data() won't correctly handle - * this situation without an update. - */ - return -EINVAL; - } - - return btrfs_extent_same(src, src_loff, olen, dst, dst_loff); -} - static int clone_finish_inode_update(struct btrfs_trans_handle *trans, struct inode *inode, u64 endoff, @@ -4348,9 +4328,30 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src, return ret; } -int btrfs_clone_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len) +int btrfs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, u64 len, + unsigned int remap_flags) { + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) + return -EINVAL; + + if (remap_flags & RFR_SAME_DATA) { + struct inode *src = file_inode(src_file); + struct inode *dst = file_inode(dst_file); + u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; + + if (WARN_ON_ONCE(bs < PAGE_SIZE)) { + /* + * Btrfs does not support blocksize < page_size. As a + * result, btrfs_cmp_data() won't correctly handle + * this situation without an update. + */ + return -EINVAL; + } + + return btrfs_extent_same(src, off, len, dst, destoff); + } + return btrfs_clone_files(dst_file, src_file, off, len, destoff); } diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7065426b3280..06b2587fcc77 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -975,8 +975,9 @@ const struct inode_operations cifs_symlink_inode_ops = { .listxattr = cifs_listxattr, }; -static int cifs_clone_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len) +static int cifs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, u64 len, + unsigned int remap_flags) { struct inode *src_inode = file_inode(src_file); struct inode *target_inode = file_inode(dst_file); @@ -986,6 +987,9 @@ static int cifs_clone_file_range(struct file *src_file, loff_t off, unsigned int xid; int rc; + if (!remap_check_flags(remap_flags, 0)) + return -EINVAL; + cifs_dbg(FYI, "clone range\n"); xid = get_xid(); @@ -1134,7 +1138,7 @@ const struct file_operations cifs_file_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1153,7 +1157,7 @@ const struct file_operations cifs_file_strict_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1172,7 +1176,7 @@ const struct file_operations cifs_file_direct_ops = { .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = cifs_llseek, .setlease = cifs_setlease, .fallocate = cifs_fallocate, @@ -1191,7 +1195,7 @@ const struct file_operations cifs_file_nobrl_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1209,7 +1213,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1227,7 +1231,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = cifs_llseek, .setlease = cifs_setlease, .fallocate = cifs_fallocate, @@ -1239,7 +1243,7 @@ const struct file_operations cifs_dir_ops = { .read = generic_read_dir, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = generic_file_llseek, .fsync = cifs_dir_fsync, }; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4288a6ecaf75..2452b1941f36 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -180,8 +180,9 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t return nfs42_proc_allocate(filep, offset, len); } -static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, - struct file *dst_file, loff_t dst_off, u64 count) +static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, + struct file *dst_file, loff_t dst_off, u64 count, + unsigned int remap_flags) { struct inode *dst_inode = file_inode(dst_file); struct nfs_server *server = NFS_SERVER(dst_inode); @@ -190,6 +191,9 @@ static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, bool same_inode = false; int ret; + if (!remap_check_flags(remap_flags, 0)) + return -EINVAL; + /* check alignment w.r.t. clone_blksize */ ret = -EINVAL; if (bs) { @@ -262,7 +266,7 @@ const struct file_operations nfs4_file_operations = { .copy_file_range = nfs4_copy_file_range, .llseek = nfs4_file_llseek, .fallocate = nfs42_fallocate, - .clone_file_range = nfs42_clone_file_range, + .remap_file_range = nfs42_remap_file_range, #else .llseek = nfs_file_llseek, #endif diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9fa35cb6f6e0..852cdfaadd89 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,24 +2527,18 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) return offset; } -static int ocfs2_file_clone_range(struct file *file_in, +static int ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len) + u64 len, + unsigned int remap_flags) { - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) + return -EINVAL; -static int ocfs2_file_dedupe_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len) -{ return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, true); + len, remap_flags & RFR_SAME_DATA); } const struct inode_operations ocfs2_file_iops = { @@ -2586,8 +2580,7 @@ const struct file_operations ocfs2_fops = { .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, - .clone_file_range = ocfs2_file_clone_range, - .dedupe_file_range = ocfs2_file_dedupe_range, + .remap_file_range = ocfs2_remap_file_range, }; const struct file_operations ocfs2_dops = { @@ -2633,8 +2626,7 @@ const struct file_operations ocfs2_fops_no_plocks = { .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, - .clone_file_range = ocfs2_file_clone_range, - .dedupe_file_range = ocfs2_file_dedupe_range, + .remap_file_range = ocfs2_remap_file_range, }; const struct file_operations ocfs2_dops_no_plocks = { diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 986313da0c88..455bf49bd07b 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -489,26 +489,31 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, OVL_COPY); } -static int ovl_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +static int ovl_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int remap_flags) { - return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - OVL_CLONE); -} + enum ovl_copyop op; + + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) + return -EINVAL; + + if (remap_flags & RFR_SAME_DATA) + op = OVL_DEDUPE; + else + op = OVL_CLONE; -static int ovl_dedupe_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) -{ /* * Don't copy up because of a dedupe request, this wouldn't make sense * most of the time (data would be duplicated instead of deduplicated). */ - if (!ovl_inode_upper(file_inode(file_in)) || - !ovl_inode_upper(file_inode(file_out))) + if (op == OVL_DEDUPE && + (!ovl_inode_upper(file_inode(file_in)) || + !ovl_inode_upper(file_inode(file_out)))) return -EPERM; return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - OVL_DEDUPE); + op); } const struct file_operations ovl_file_operations = { @@ -525,6 +530,5 @@ const struct file_operations ovl_file_operations = { .compat_ioctl = ovl_compat_ioctl, .copy_file_range = ovl_copy_file_range, - .clone_file_range = ovl_clone_file_range, - .dedupe_file_range = ovl_dedupe_file_range, + .remap_file_range = ovl_remap_file_range, }; diff --git a/fs/read_write.c b/fs/read_write.c index 2d84d18dc095..fd3fe05060a4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1588,9 +1588,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * Try cloning first, this is supported by more file systems, and * more efficient if both clone and copy are supported (e.g. NFS). */ - if (file_in->f_op->clone_file_range) { - ret = file_in->f_op->clone_file_range(file_in, pos_in, - file_out, pos_out, len); + if (file_in->f_op->remap_file_range) { + ret = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, len, 0); if (ret == 0) { ret = len; goto done; @@ -1831,7 +1831,7 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, (file_out->f_flags & O_APPEND)) return -EBADF; - if (!file_in->f_op->clone_file_range) + if (!file_in->f_op->remap_file_range) return -EOPNOTSUPP; ret = clone_verify_area(file_in, pos_in, len, false); @@ -1842,8 +1842,8 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - ret = file_in->f_op->clone_file_range(file_in, pos_in, - file_out, pos_out, len); + ret = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, len, 0); if (!ret) { fsnotify_access(file_in); fsnotify_modify(file_out); @@ -1988,7 +1988,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, goto out_drop_write; ret = -EINVAL; - if (!dst_file->f_op->dedupe_file_range) + if (!dst_file->f_op->remap_file_range) goto out_drop_write; if (len == 0) { @@ -1996,8 +1996,8 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, goto out_drop_write; } - ret = dst_file->f_op->dedupe_file_range(src_file, src_pos, - dst_file, dst_pos, len); + ret = dst_file->f_op->remap_file_range(src_file, src_pos, dst_file, + dst_pos, len, RFR_SAME_DATA); out_drop_write: mnt_drop_write_file(dst_file); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 61a5ad2600e8..7cce438f856a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -920,27 +920,19 @@ xfs_file_fallocate( } STATIC int -xfs_file_clone_range( +xfs_file_remap_range( struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len) + u64 len, + unsigned int remap_flags) { - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) + return -EINVAL; -STATIC int -xfs_file_dedupe_range( - struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len) -{ return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, true); + len, remap_flags & RFR_SAME_DATA); } STATIC int @@ -1175,8 +1167,7 @@ const struct file_operations xfs_file_operations = { .fsync = xfs_file_fsync, .get_unmapped_area = thp_get_unmapped_area, .fallocate = xfs_file_fallocate, - .clone_file_range = xfs_file_clone_range, - .dedupe_file_range = xfs_file_dedupe_range, + .remap_file_range = xfs_file_remap_range, }; const struct file_operations xfs_dir_file_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index ba93a6e7dac4..11fe36576d34 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1721,6 +1721,26 @@ struct block_device_operations; #define NOMMU_VMFLAGS \ (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) +/* + * These flags control the behavior of the remap_file_range function pointer. + * + * RFR_SAME_DATA: only remap if contents identical (i.e. deduplicate) + */ +#define RFR_SAME_DATA (1 << 0) + +#define RFR_VALID_FLAGS (RFR_SAME_DATA) + +/* + * Filesystem remapping implementations should call this helper on their + * remap flags to filter out flags that the implementation doesn't support. + * + * Returns true if the flags are ok, false otherwise. + */ +static inline bool remap_check_flags(unsigned int remap_flags, + unsigned int supported_flags) +{ + return (remap_flags & ~(supported_flags & RFR_VALID_FLAGS)) == 0; +} struct iov_iter; @@ -1759,10 +1779,9 @@ struct file_operations { #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, - u64); - int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, - u64); + int (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; From patchwork Sat Oct 13 00:06:38 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: 10639503 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 7945A1869 for ; Sat, 13 Oct 2018 00:06:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6612A2B79F for ; Sat, 13 Oct 2018 00:06:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 597432B78F; Sat, 13 Oct 2018 00:06: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 C56CB2B78F for ; Sat, 13 Oct 2018 00:06:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A26FF6B0271; Fri, 12 Oct 2018 20:06:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9FE8B6B0272; Fri, 12 Oct 2018 20:06: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 8ED996B0273; Fri, 12 Oct 2018 20:06:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id 643D36B0271 for ; Fri, 12 Oct 2018 20:06:49 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id d52-v6so13963791qta.9 for ; Fri, 12 Oct 2018 17:06:49 -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=RBiUtJQJTFjVx5Jsi2oXpat+Xjxoo1AZnkNlS024TVM=; b=MNjyXfsQAzNMXBPYBiZaH7V7gks1hO1ftgJKVH5cswSgSQ6cDsPfJWDNcjNnL+Z3v7 rWID7raX6T98df7J7stRIkxyE4zjEDA6mEuEhn4sTUGXYWQklWscOR05e9D2hO/Z9Pdg JfuF3Ss/YQcxHIuz6sDEGb8ryToI+KT+YRgY9iqOVuHEWG+sn8WXkDgIWUNtDEsnWgLL MPLT+QnXQ5ijw49wJuMAJ+PY4JTnrR7lcVgKuQ92QrBYqCCqhdhmJzlrZ9Mx01gg34X4 Jg5Bl8OPH4c5TpYyYWBQGBomaoRiUBFdjwcs46eE8MKQAr6VQC/hQHB/1xLNdzcQBWFP 1umg== X-Gm-Message-State: ABuFfohHDTEXGO1BVPVdBdN2cJrYNgT+qEctKBl7bH/OAfT20o7SmkBH IE513ZlairYehpKeDT4OghLDAego02Kf7PFXqPOrx030Plys10dz48VHfKkmYNMdbFKCTFHkcdg CzVePnJPdJg6+bdLw40dxyHPQ66YaiFntpRXPMduERtH1Nhsm/WzRQ/wpn+pmu+Ba4g== X-Received: by 2002:a37:ef08:: with SMTP id j8-v6mr8037361qkk.26.1539389209177; Fri, 12 Oct 2018 17:06:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uUibnfTboe5OszVvkGJqMl7GJA+iMILUkZ6qufVtixnLAUL+USniMoO2N9NBobL+r2KS1 X-Received: by 2002:a37:ef08:: with SMTP id j8-v6mr8037340qkk.26.1539389208597; Fri, 12 Oct 2018 17:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389208; cv=none; d=google.com; s=arc-20160816; b=K0E0zJSnYJ4Msmuw6jcX1Ro2d3Ueha57jmLDWWTw7Wm7/fII1hzy60lZdaTQlBu3OL S1xOMck/KsQW5miV06rTEpWzN/f3b7fkCOaB2Jv5/3xI5pGVVKFr2HP/OMMwSHNwURsJ f/ti/OGfoF1o1GPXvMPPeqxDKl5Y+yy1FyOVS6/lsGq7kVQu7ypNBoa1kMduC+Kn/oTq H6A2AB6czvbfu6nPoKoLQeoBTmVsn4tK8waOMKPmL94e3VzUImATL1w4Kt5zpXT+KAUb BEMe8GCgMWQAnuHbWZMopLwpFGov993PRXRuhHEtLQhSjSqNx0nQcUg5YfQcW+BUvMM4 +oTw== 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=RBiUtJQJTFjVx5Jsi2oXpat+Xjxoo1AZnkNlS024TVM=; b=Jb9aMNcAab/htiICgfp5JdLxuT2TCXu8NQhk70lhX+xRtevOVnL0ZOm6GzxoGPfoa4 ZPyv47sM61ScXD7+HD6ZE7WMc6uGfudIpwQIHfpisk9MynV2Odxmgf/lgIiubsRQHFkE sYzM+CYM/ek5f+2mPqYxG4riKyN9vNePTqjOjckWEvnsJbt0ksMd3edGEAcvLW1mo3ch Sre24oca7+1qo4WeZC6eyo0+SUbg78cGnlufMthOj925/vjUWZuFR4yywLAEe80K5EEZ BG5dcbdXqxhqBfJaNAZzDo0pVk/nLa2f3lzmV4KH4j6Jr1DI0uKMcgkTrxQsYYpDMYNO nyvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=d0KLJhFJ; 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 13si2452566qvo.211.2018.10.12.17.06.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:48 -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=d0KLJhFJ; 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 w9D0473N163230; Sat, 13 Oct 2018 00:06:46 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=RBiUtJQJTFjVx5Jsi2oXpat+Xjxoo1AZnkNlS024TVM=; b=d0KLJhFJqZ1bEFCZ28T0Hyc0NnV4V3cFyWAvt3zBczVgdO4xPl7Rc2K6QDduEw6y+4rn uGo+cAzrGlMDNbZc1mCySkK3JtpRld9Bddzn1dkqTS8tmDnwv6X60BFaH7QYIKG6WP1S bHe0UjEE6UhTfoxmd4nPHf1LwRxZVH4p6OHVaxQCZhVshyipGxOsFZSxqT7SYdWmb/Ay LgHQw5bzXI7QlcMaRnVfex+1zvUOOXy7r3v15+PqKxMI1ptU9VEOedoCMDY1jOWOr3E3 ry6t529e7MV4E4iMrEZs49k/u6ipKvW6MYvAiaXT/MLqqJDSd/b6zPqCsxTBIiZdm7mu Ew== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0qnme5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06: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 w9D06emt002301 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:40 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06eKl019410; Sat, 13 Oct 2018 00:06:40 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:39 +0000 Subject: [PATCH 08/25] vfs: rename vfs_clone_file_prep to be more descriptive 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:38 -0700 Message-ID: <153938919824.8361.6077145801942639742.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=781 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 The vfs_clone_file_prep is a generic function to be called by filesystem implementations only. Rename the prefix to generic_ and make it more clear that it applies to remap operations, not just clones. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ocfs2/refcounttree.c | 2 +- fs/read_write.c | 8 ++++---- fs/xfs/xfs_reflink.c | 2 +- include/linux/fs.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 19e03936c5e1..36c56dfbe485 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4850,7 +4850,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) goto out_unlock; - ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, + ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, &len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/fs/read_write.c b/fs/read_write.c index fd3fe05060a4..65285524e4c3 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1717,9 +1717,9 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ -int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 *len, bool is_dedupe) +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) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -1804,7 +1804,7 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, return 1; } -EXPORT_SYMBOL(vfs_clone_file_prep); +EXPORT_SYMBOL(generic_remap_file_range_prep); int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 281d5f53f2ec..a7757a128a78 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1326,7 +1326,7 @@ xfs_reflink_remap_prep( if (IS_DAX(inode_in) || IS_DAX(inode_out)) goto out_unlock; - ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, + ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/include/linux/fs.h b/include/linux/fs.h index 11fe36576d34..686905be04c0 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1844,9 +1844,9 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *, unsigned long, loff_t *, rwf_t); extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); -extern int vfs_clone_file_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_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *count, bool is_dedupe); 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, From patchwork Sat Oct 13 00:06:45 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: 10639511 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 4DBA51508 for ; Sat, 13 Oct 2018 00:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B9392B79F for ; Sat, 13 Oct 2018 00:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F3992B7FA; Sat, 13 Oct 2018 00:06: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 C00E72B79F for ; Sat, 13 Oct 2018 00:06:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C7A56B0273; Fri, 12 Oct 2018 20:06:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 178B96B0274; Fri, 12 Oct 2018 20:06: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 EE0DD6B0275; Fri, 12 Oct 2018 20:06:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id C52746B0273 for ; Fri, 12 Oct 2018 20:06:51 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id n188-v6so13344439qke.6 for ; Fri, 12 Oct 2018 17:06:51 -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=Kfx6b01y0nD5NBow+aLHaMRvX2Vt7rtxPOY+lM34dJ0=; b=XkmtR5Ee90FV5oRTwNh+MfWhHDJAM32JbKuSdO4Txmgbbldj91b32deRUtZCZpvi43 ikTnGljULo+Y9C7s3UOcMCBTuMSHJFT7b6l2Si85VY916R9m+N5wWapIk0PESBggq4Ym Z9lTNJaTlHwXGLCP65hR5xNJcMBItFVXYWUGqk9ICwtCo24uxeo5pIvBbhQzWijwiPTh oRfdNlRKNDYu0Xs3uSsEWPVt46fw/eFqKNI9MOp2lLorZlF3gHzA17NuUuKTIe6ko0UW WMOXdgC8c33VCbB+9baPf457N5yW8Gd6+BY3pw068Kzf/50DBH74IldNwNed2a3Pq8/E O35A== X-Gm-Message-State: ABuFfoiqcMQghyEl8VJGQd7TC6Nthb3xlVxFg5uZWz5NheOXYSMUCK9j qyo06P1zXw860t0fq5nbGSp7i6IoIZjPlufkuYoZ7/w9Vd4V2EW6vnH0BnaLRXl6EDE0qrjOn1l BhJtKy7Koep9ewn+WQrCpEEuNsRxh9Zi1XXm097lctxbFnmnLV87afK5gH+33gnZsqw== X-Received: by 2002:ac8:5257:: with SMTP id y23-v6mr7805515qtn.78.1539389211599; Fri, 12 Oct 2018 17:06:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV63EGwMuba52601YaX5lvzICVt+NJ0lQFCcBTK7z+SPzbjvHaZCmN2goqV25qJl0OmQfs1Pl X-Received: by 2002:ac8:5257:: with SMTP id y23-v6mr7805498qtn.78.1539389211125; Fri, 12 Oct 2018 17:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389211; cv=none; d=google.com; s=arc-20160816; b=un32IOBOm3Ux6OjymwBrz+2/TPC2JECCfreKINIhPUp+DYFKzXcH2RBScqru76c4zA JaoqlE5iTf+0qH/fZpaaV7S6K9C5c45fgOjNCsXFosEqnvwPj6TWT+Uq16kxR1g7Pucn Z5sJcAo4rQX0RAQ5qPVqoBuQEG1fyrs372DSD4K3aYa5t47mQZ6iLuhIKYREw1CiAPou bPr3er23RbLFHs2mtvXaNLViXnAI3HHmht8LUfmpm0VCSNKz+SnzqgoHrq/KTOuoVutn BcZ3F8tXifRE2yZ1h3GV0AQra88MLgs+gSPjQmYm/oWXZpTfojS5BTS6JFcmUlapbkGf 2XWw== 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=Kfx6b01y0nD5NBow+aLHaMRvX2Vt7rtxPOY+lM34dJ0=; b=UN0H6hLkRYJdah5voEsTr8BjqhUksamNrLATeD9usWRrmR6eLobPwkRly8qo3VEon7 90TaOiCDcFBBc8TV/h6d0c/uFnqoGXJPCbBeqj6nvV35v/i7/g7Vl9N9dErP6qWTPIwb vx23jOOB+Lom/2QEWj3vj4R37pDdIkz6bOrFQYRYoHHFA0OjKUWYN6PrUR5fj/mPPQrH IKul2fPGiLIxd6kGJpPP4FI+ztNPa6MSool3TVlX3DVu/9nYRHzue5XoUjpcNLuoGz4d v/QnSWJ47Dz6swRPZ2BcIsFzHaqVwrxV7ZyDj6XuXqQD1Ha1SgUPEY4ezHj5hnjxx7Zs 1dew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=GyqOWL0c; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id l15-v6si467239qkj.184.2018.10.12.17.06.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=GyqOWL0c; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D04QNx104849; Sat, 13 Oct 2018 00:06:48 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=Kfx6b01y0nD5NBow+aLHaMRvX2Vt7rtxPOY+lM34dJ0=; b=GyqOWL0cUdSzX/9zPjcH1a8PqRvhjb5Ux0q7TVuExawynupsH4bc7CSoWwrfcTfahe/5 K2L85IoiIY06b2hSYdm2H6s95lYZPSzrP0zhALOxFJmS+5wj6EUllj/9I+rb2A4KOFr/ Z3pT0qao0kidwTiAaxA2C4hEVvdMrbX1X4KS1CbkFf9Kc84qvIEI9IuCDve0uLio3bY7 rIM+X+gkz7/g/UlLXIMbcTPtsnDAAwfE/cF6k4pDL5lftkAxP47Bnp31m6l6M+yUkJr7 MpZz1fvDjqJuhmwse/wmy3/hobn5X1h48mE43b3gLZJOB99a5LxBfZQAcjDQUev0dGBl kw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprnfhb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:48 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06lF1018185 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:47 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D06kV9018800; Sat, 13 Oct 2018 00:06:47 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:46 +0000 Subject: [PATCH 09/25] vfs: rename clone_verify_area to remap_verify_area 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:45 -0700 Message-ID: <153938920501.8361.2713830760292171099.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=708 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 Since we use clone_verify_area for both clone and dedupe range checks, rename the function to make it clear that it's for both. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 65285524e4c3..ff6fcb3b99dd 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1686,7 +1686,7 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, return ret; } -static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) +static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) { struct inode *inode = file_inode(file); @@ -1834,11 +1834,11 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (!file_in->f_op->remap_file_range) return -EOPNOTSUPP; - ret = clone_verify_area(file_in, pos_in, len, false); + ret = remap_verify_area(file_in, pos_in, len, false); if (ret) return ret; - ret = clone_verify_area(file_out, pos_out, len, true); + ret = remap_verify_area(file_out, pos_out, len, true); if (ret) return ret; @@ -1971,7 +1971,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, if (ret) return ret; - ret = clone_verify_area(dst_file, dst_pos, len, true); + ret = remap_verify_area(dst_file, dst_pos, len, true); if (ret < 0) goto out_drop_write; @@ -2033,7 +2033,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) if (!S_ISREG(src->i_mode)) goto out; - ret = clone_verify_area(file, off, len, false); + ret = remap_verify_area(file, off, len, false); if (ret < 0) goto out; ret = 0; From patchwork Sat Oct 13 00:06: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: 10639531 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 52EB61508 for ; Sat, 13 Oct 2018 00:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FFC42B78F for ; Sat, 13 Oct 2018 00:06:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33CBB2B79F; Sat, 13 Oct 2018 00:06:59 +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 9F7EC2B7A0 for ; Sat, 13 Oct 2018 00:06:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 399616B0274; Fri, 12 Oct 2018 20:06:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 36DE66B0275; Fri, 12 Oct 2018 20:06:57 -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 25EF76B0276; Fri, 12 Oct 2018 20:06:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id ED8616B0274 for ; Fri, 12 Oct 2018 20:06:56 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id i64-v6so13794502qtb.21 for ; Fri, 12 Oct 2018 17:06:56 -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=X+hRMF8qOyPmwrn+aLfQoFcvGdBY/MR4c6X0bQBl/UQ=; b=Obru2MJzY6Y6IfUNoVSk/pB5x3DFF0I744+srxqscW+bmEgwAQ2/ACebOujoNVpoXK 88Xt0BsrwlyNGfXL/xybijkkMTHwf6Aeozew2LT+702nh0WpcaEvmcInMIE8IAQ8CuKP LUO9+hJ5TD7WiX9CvqGJdkVm+tKc3AB/lqzJJFCcXUpppu3Y+tt68PSR3eZxYBJ6/Aw/ 9JBzO+H7DcaemuoDKR8Tj5750M7n9uyazMif8zvtvUJN2oUY62vDg4iLUtVDbelIbROA iOGYcuyaa13lpZrQ+o0fDue7IQuhUDFravVVTzS8JVtTv0+WLQp/StdMLK2qjo5y36rA PmwQ== X-Gm-Message-State: ABuFfoiDBVamGrctnpUu2RqX172o2mU3Pxc7e7HpNgnaTtdPtSjp9gk4 e2Sum3dzjRpRpoIVG8MI5WPfjkG1/aY4uNcsS6J/7s77MjXkAUHGzoRLWBFEvF2lopmdtJ7Rx9j GIH2SjgCsun7lfocn5iR2RpbiR+4kgT3sMx2+3fbwq2yjVX8vbTU5iUA7cEKb5iREkg== X-Received: by 2002:a0c:92f3:: with SMTP id c48mr7921531qvc.39.1539389216733; Fri, 12 Oct 2018 17:06:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ujShNBb3omkZJT4c4upELRPfm5ukTdo3U0ddOW1SfjJiSQhUOseqOko3sV1jJr88bAZCf X-Received: by 2002:a0c:92f3:: with SMTP id c48mr7921506qvc.39.1539389216130; Fri, 12 Oct 2018 17:06:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389216; cv=none; d=google.com; s=arc-20160816; b=aUx5xPQ1CV2+/cJZU83Ezmzr2fAyoWSgDV0+sPT5VmrCAo3fNQQSw9KtKIeEeOq1LB Qbu7IPZFNxQ9CPF0cS8AANsEwKHFpOSXE9J7EUAuVQqEG2wLrjoOBdJfLRlQesmzaMxZ 1Ax47b1cf+zOcBC/qEO6G42aOoOd8SZzR1GfcLj3NPsMRGJzyM2OBB4jInxawxjox4Sn isEECi+VQWKFRZMIDWgW5rA014LMD2xQwBwm2ko8b/LHUqFfAU+F1glBjXVEyAMzeRAf QTtmSwNudPC1T7YZS0ks/ZBnV0lxJg9Mg/ZZOPCT3tbiv6qL0iyqUVK5KWNlSnoV509x YiCA== 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=X+hRMF8qOyPmwrn+aLfQoFcvGdBY/MR4c6X0bQBl/UQ=; b=XX53rzaC4a0Lt4ebQJyLT1u6ON2gyOkZXByLPzVHAIPdz/u7asws3FPkjixOzWF29f ejmcpODZW6NvPCJvDuR3bd+z4BntFDyPiH9xlGiD5S6KZEQy5efS2Sj8GBDtHyYbINJS Vn+P4PmkYx7zHrUV4OwZcLeUnp+y57ZVq+kBdq5IgjmBvltQeZxnQWEgGlLGKM7Fmjbl SmTcW+3WxLtvFjywdUUb4iM4PCGkY5uydME4LHbgXmXpa1F2M1Lu1+UoIlx+Gt7FbztG IZMztZTuiaEj7Ng/bhyQCZ/8hN+qvXEmgOGrdWAWpI5SwUQbqoODZ4lgNVYdz+wSwjEY kObw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oaf75sNI; 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 n79-v6si2385303qkl.244.2018.10.12.17.06.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:06:56 -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=oaf75sNI; 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 w9D058qB163717; Sat, 13 Oct 2018 00:06:54 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=X+hRMF8qOyPmwrn+aLfQoFcvGdBY/MR4c6X0bQBl/UQ=; b=oaf75sNI9fHdy3z1KCWd1yMoIIQOCfKi6l+fxwIosb+BBV/PVmeb9COz3atuJZSqTUvk gsDCA3RUWS+iSqwPIoZfURb82XUSyqrYJLiTOceAKpkzX/0W6RdfilwWfkA1pgNAUt7c FqZ7kNSkHNzVraOeuoUgQCS6MjSsSdFORjoJtO/T6jEq+CyJEZjs9m11n3158n658BEK lfZlu69J7TBiS+mkb3CjkFY13E6M1ztKyGlPIV3b84OOUY+QlNgt6XUA6/1DSzwcsm47 wcT+E5f1mS41cUGiBEm1IWwsgy/c3SXyQ4jnA2lJG8ys+JpidPOy2AWtC3uYRef5YzDW VA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:54 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D06rC3018311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:06:53 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D06rH5017876; Sat, 13 Oct 2018 00:06:53 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:06:53 +0000 Subject: [PATCH 10/25] vfs: create generic_remap_file_range_touch to update inode metadata 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:51 -0700 Message-ID: <153938921180.8361.13556945128095535605.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 Create a new VFS helper to handle inode metadata updates when remapping into a file. If the operation can possibly alter the file contents, we must update the ctime and mtime and remove security privileges, just like we do for regular file writes. Wire up ocfs2 to ensure consistent behavior. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ocfs2/refcounttree.c | 8 ++++++++ fs/read_write.c | 24 ++++++++++++++++++++++++ fs/xfs/xfs_reflink.c | 29 +++++++---------------------- include/linux/fs.h | 1 + 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 36c56dfbe485..ee1ed11379b3 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4855,6 +4855,14 @@ int ocfs2_reflink_remap_range(struct file *file_in, if (ret <= 0) goto out_unlock; + /* + * Update inode timestamps and remove security privileges before we + * take the ilock. + */ + ret = generic_remap_file_range_touch(file_out, is_dedupe); + if (ret) + goto out_unlock; + /* Lock out changes to the allocation maps and remap. */ down_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) diff --git a/fs/read_write.c b/fs/read_write.c index ff6fcb3b99dd..7b837d12f75d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1806,6 +1806,30 @@ 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 ret; + + /* If can't alter the file contents, we're done. */ + if (is_dedupe) + return 0; + + /* Update the timestamps, since we can alter file contents. */ + if (!(file->f_mode & FMODE_NOCMTIME)) { + ret = file_update_time(file); + if (ret) + return ret; + } + + /* + * Clear the security bits if the process is not being run by root. + * This keeps people from modifying setuid and setgid binaries. + */ + return file_remove_privs(file); +} +EXPORT_SYMBOL(generic_remap_file_range_touch); + int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index a7757a128a78..99f2ea4fcaba 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1371,28 +1371,13 @@ xfs_reflink_remap_prep( truncate_inode_pages_range(&inode_out->i_data, pos_out, PAGE_ALIGN(pos_out + *len) - 1); - /* If we're altering the file contents... */ - if (!is_dedupe) { - /* - * ...update the timestamps (which will grab the ilock again - * from xfs_fs_dirty_inode, so we have to call it before we - * take the ilock). - */ - if (!(file_out->f_mode & FMODE_NOCMTIME)) { - ret = file_update_time(file_out); - if (ret) - goto out_unlock; - } - - /* - * ...clear the security bits if the process is not being run - * by root. This keeps people from modifying setuid and setgid - * binaries. - */ - ret = file_remove_privs(file_out); - if (ret) - goto out_unlock; - } + /* + * Update inode timestamps and remove security privileges before we + * take the ilock. + */ + ret = generic_remap_file_range_touch(file_out, is_dedupe); + if (ret) + goto out_unlock; return 1; out_unlock: diff --git a/include/linux/fs.h b/include/linux/fs.h index 686905be04c0..91fd3c77763b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1847,6 +1847,7 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, 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); 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, 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, From patchwork Sat Oct 13 00:07:05 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: 10639559 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 E7F331869 for ; Sat, 13 Oct 2018 00:07:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D5DBF2B78F for ; Sat, 13 Oct 2018 00:07:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA3B42B79F; Sat, 13 Oct 2018 00:07:18 +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 8F2522B78F for ; Sat, 13 Oct 2018 00:07:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5935E6B0276; Fri, 12 Oct 2018 20:07:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 544B56B0277; Fri, 12 Oct 2018 20:07:16 -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 45A856B0278; Fri, 12 Oct 2018 20:07:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by kanga.kvack.org (Postfix) with ESMTP id 1BB6D6B0276 for ; Fri, 12 Oct 2018 20:07:16 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id j63-v6so3331118qte.13 for ; Fri, 12 Oct 2018 17:07:16 -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=liANWFsEK8bSCnqtpTXhPB44DP7Pns+fSB/icXEuWpA=; b=ehHjj0sDdYgPztV1NNQq2K5ze2E2s9kpHCzn07uDtDr9mX/7qK8qsdPhrpc2f9jSpw Ixf6+q3lDGg6FwXrU4Hrl5GhB756C5S5y/zvYF49eNtwUuSkeUQ2TqFx4m503RS1KAIJ GoFLA0c6JgsFqGpawgu8FwvghhpLY+tBOtN0bKqEavTIokECQlZuEwG2YrXQWBtVJMly naMW+jx7xeo7iDs1AgB9pCaHk3WvswgoHkEl3Pt1G89Wfe+R8oLlq/NT7ZBZcqGGWhGe V8IV0e71M5rnUwoQHLtM39nTmrbADsza1tLQxC3QXiAEX9ynqiZCtNqqQUZmdajmmcaX 33tQ== X-Gm-Message-State: ABuFfoh4elW5SCQdqMgPzRPDq1WifMYYFwpsbbjl8brhm/ytv/CS0gKt 5bKUsOxziLCJFowzft05s3UBoDGbTxw+9cwtnkWVrNvUvX5ODaOO1VboLA1etTmJQCybqebwB1N hTLZJ6mr58D5u36jua+sDRiRSJiL5DpE2hHrpRxyHy7nmMny/r8V5t8gVnTVRfxrEuw== X-Received: by 2002:ac8:3059:: with SMTP id g25-v6mr7959689qte.136.1539389235898; Fri, 12 Oct 2018 17:07:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV601dnCMsCGt9A1/JleWZMhFBNSqhk5Fd7FfeQ4rb+JenR1/3IE4Rgo5FLxXc8yulHCZhjfM X-Received: by 2002:ac8:3059:: with SMTP id g25-v6mr7959672qte.136.1539389235402; Fri, 12 Oct 2018 17:07:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389235; cv=none; d=google.com; s=arc-20160816; b=OEebYNf9kch9cAwyCUmEApgey2cq82u/mZ+WjU5IQcFYQ5j02HzhdOVIralN01AtRh bil9DNpfgSCKlwyl8Kt483WVYFm1cMsnpGFkWcQJGRt3s/H6qBCcjzFX8fvN9WFBNfCV B6ePTGl0hKBt0v95X8sIPby5Y8mJ2qjPoWaE//gSg38fcWnGdPNxX8Gk2ZglZ24MRHWB DWzTgw5ClsfgegH348z2xZEs/fm8F0KDnI6cPejArGFXv3t89ewHgVG3zjU1YzVK+q/m 1AZCUOAqB/tINJt8hfp99+hcVY3kzqjbqS5v+cN8L3AnWhfYY2WD4p4epvrxmkV589Ha q5mA== 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=liANWFsEK8bSCnqtpTXhPB44DP7Pns+fSB/icXEuWpA=; b=Cz0nJidb6WH81PF7nWruESqI3+hFQgQStWiZ/0Xms8XBgfequxroIjrnWWvDF/TbJP am98yvaekCxVhzaNkxRzM7LqCtXcFso0xNIQwtZQH7PvKfda9bSf/kXXTdLzviHYh2s3 ZhpT2TwDeCCOaTqGeMVSv4F+IjVUJbHv8jGtwA6o9zt+WCKiaC0dVQqhkzB2JAqC1KDt ni7CYnhGorcqF1R7fNV6pySRhfZIIe6oNA9xoa07xw0GxqfITDDjLH9AWgiqKF+Enizq CESeR5/a76KurSfEjdHv1qKbStRkgRqM95PHFyDXKgPXe2HjHpxaG4Dp5A8UTKUmclQP 9VOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=qOF9nR0m; 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 p17si2213527qvo.148.2018.10.12.17.07.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:15 -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=qOF9nR0m; 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 w9D03wHO143579; Sat, 13 Oct 2018 00:07:13 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=liANWFsEK8bSCnqtpTXhPB44DP7Pns+fSB/icXEuWpA=; b=qOF9nR0mgPn378Uexa1RHMsL8hPbDDAxY+OkAUJcG74u6Xz/AAE4YHu7X/xfCnzfHmm5 nXp6kksaAhOsPy0QA27UkuM55kD9gVu3BOfCuvSq53BYM6rVBFPS+JV22Ut4ZJwmF1oN 3zq1TpT6LYSgzF3xhBcomgR4wZtTml9LnXjzTgIzy27zurp5RRWUvhbB6jMrRsoRS4p8 QcgGUXkCy3Vlpa+t2it/1wQCp6vl41Ldl3+mI/Hk4hABYzF01k2NLK9kK+FD5zbcQT1d OvT78SK24HqGEN6Dx+bSsAdBasYst+2jUQebHqslvuZ7SzHCjKtKGVJhbFQryXaWTa3b yw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfudpxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:13 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D077V8018897 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:07 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D077lW018012; Sat, 13 Oct 2018 00:07:07 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:07 +0000 Subject: [PATCH 12/25] vfs: pass remap flags to generic_remap_checks 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:07:05 -0700 Message-ID: <153938922552.8361.18136407106022565712.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=479 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 Pass the same remap flags to generic_remap_checks for consistency. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 2 +- include/linux/fs.h | 2 +- mm/filemap.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 5d24e9854765..0c43997bd4a1 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1755,7 +1755,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, /* Check that we don't violate system file offset limits. */ ret = generic_remap_checks(file_in, pos_in, file_out, pos_out, len, - is_dedupe); + remap_flags); if (ret) return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index b67f108932a5..b59637b2f484 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2990,7 +2990,7 @@ extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); extern int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *count, bool is_dedupe); + uint64_t *count, unsigned int remap_flags); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index 08ad210fee49..c34a89a35d5a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3001,7 +3001,7 @@ EXPORT_SYMBOL(generic_write_checks); */ int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *req_count, bool is_dedupe) + uint64_t *req_count, unsigned int remap_flags) { struct inode *inode_in = file_in->f_mapping->host; struct inode *inode_out = file_out->f_mapping->host; @@ -3023,7 +3023,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, size_out = i_size_read(inode_out); /* Dedupe requires both ranges to be within EOF. */ - if (is_dedupe && + if ((remap_flags & RFR_SAME_DATA) && (pos_in >= size_in || pos_in + count > size_in || pos_out >= size_out || pos_out + count > size_out)) return -EINVAL; From patchwork Sat Oct 13 00:07:12 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: 10639573 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 46CCE1508 for ; Sat, 13 Oct 2018 00:07:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31D1F2B78F for ; Sat, 13 Oct 2018 00:07:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25EA62B79F; Sat, 13 Oct 2018 00:07:26 +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 C33A22B78F for ; Sat, 13 Oct 2018 00:07:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82A9F6B0278; Fri, 12 Oct 2018 20:07:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7DCAD6B0279; Fri, 12 Oct 2018 20:07:23 -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 6CC256B027A; Fri, 12 Oct 2018 20:07:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 3D4686B0278 for ; Fri, 12 Oct 2018 20:07:23 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id q48-v6so13677689qte.11 for ; Fri, 12 Oct 2018 17:07:23 -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=wCIHvwFJjQ2i2OQGMEnHd8C4mjaJSsvaMt8jQEaTyJ0=; b=he2ZbRKSogcy1QUX20oUjflPt94EmUAiLTG1UrJhD4BAlazcrQfVsU78ldkZEHcyuV ZPtE9+ie8xqyK1uVEyG8NKWJXdYI9FsufjzDFCZqhoHe6IIbZ5OGuuvxXfhqqpHUHi6x ayK7ieBYHuJY0ZbEA1HLytKQq3dmjQzMek8ji0fDiBz5eqfStJLW5zZHVKOXL4o7fCqc roIzlxizNFpy1SVju6aOnknKRPobXv2q8/36WUMvuWAQwUPwZ7EoGsKlQG+DoVNtFSwO jT6COOpNsZ9Z24HeBLCYx6ti2rPaekLhWlWjo5gcJ6nguYQatBV9uZigiL/KNNIh4nI1 Vxeg== X-Gm-Message-State: ABuFfogMMV4WMdbJ7Z/O8ilGwFY42IQhMBaNGhp/zzjhYBIucLmtQjP0 pyL2hagGtePC5940fz/mpbCEMk1x43pNcvUALibxa00hcMowyYXsL5CGd6gYTdFm2KGNga0lyyW 4vl+ixD7vK/cdSgnwyjStuhcEjzBukuX7WVrdbtsXQjV625Hm+x0Zmd88NdTL7G+grQ== X-Received: by 2002:a0c:953a:: with SMTP id l55mr8051090qvl.22.1539389242989; Fri, 12 Oct 2018 17:07:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV60wCkNRmYaUaBkQJkXY6Uvzh8NRL3jQb2U3I67YKv1RUl+LB0HIF4xUDzRgBZ3osvabVxCv X-Received: by 2002:a0c:953a:: with SMTP id l55mr8051033qvl.22.1539389241475; Fri, 12 Oct 2018 17:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389241; cv=none; d=google.com; s=arc-20160816; b=AfG9dj2kh7ygPLXOHB4RjT/GKdkr2zyNdOYJk9h5vIVOe8j8UUCCjF4kWIqlKOgdcM xL+AAnHotQV50FRgsatlii1MyejmoTX7UPzkv8jWeVgTguoqInDmsZ0HmAu7bKnXP2Lt AmSFk3jiBM7w6vpM9hXI9BH78fnP2Aqs6HVLcfIWNFeR+N9fI+KkpVI3pmc1Lu8aboQ1 TeF8yRRnllrKg79X8ac+XcQukVY1fSjY5v1fMbTc4DUd247oXn6qarp89G3FW5uoZ6Ad R8izRWajZcyz2zbnxyVf/edISoecP1QsjVrdLcV1x1EQyUvPwrES5GzyWf5wxjWMIvRd hiBw== 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=wCIHvwFJjQ2i2OQGMEnHd8C4mjaJSsvaMt8jQEaTyJ0=; b=h0SmU0bOQGyAIO7cw+hLBn8ZxBX0045dvcwVqywI1gq4fmgvev7WCY2mzXH0JYpKun 3F5sz2baW9tJQrgOgUi0LuEmalhFkc83m3dbIyoa0kTH10Li0PGzYzhZW7RKLAqOEKVz orxg/LwTZv/hE7Y6gZUlRDJ5VxSnOXB0RMbNUPQJVAj1IOcjF/bqVE/DMuDq7tUx96/6 xXcRZxCdJHIKNl/8VeVcoot7N9KlhCH2eJ+rCAVOhYhidrg5UnSuSAaiQtAFDNcU0TRZ AYvLAnoXK1Cquq2QInzBQh7lMySYZfDBHH0egKxz8XJ+f5U5e6YCTxTcMWFAeDts54JV d7mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=rtJvEovR; 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 o6si2348522qvn.65.2018.10.12.17.07.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:21 -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=rtJvEovR; 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 w9D03vSd162981; Sat, 13 Oct 2018 00:07:19 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=wCIHvwFJjQ2i2OQGMEnHd8C4mjaJSsvaMt8jQEaTyJ0=; b=rtJvEovR0uDDyqqbDUx+QDsltU4YrI0tIAb0FwZv65CsRiuJYrQZCcjc5HNbRAZXf160 YY0z5VMcbPqughOEvy/OgZhGRa5Q83sonHG/WzGtvDcFnYwZpYpvyT2Dzy/drggJQ/P6 E0m3uc7IpCZHP5tEAwG+9l9JtZkix8V/iXYjjomb/pNq1JZBJs8BFDdRTCSPvN0XVzeK nI+ccJctpX99gwpUaliHor4rS/EKsM0CIRmQIGieOP8NcSHGmaYDe6afbMjNHXGhBvMW B02njUxGPiUKSyymKV0ptCR40RPK05O6AwJZLcebIhWvMX5mWHoAz4RAmjDME9luTZWg 8Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:18 +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 w9D07ID2004313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:18 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07IoD019653; Sat, 13 Oct 2018 00:07:18 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:18 +0000 Subject: [PATCH 13/25] vfs: make remap_file_range functions take and return bytes completed 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:07:12 -0700 Message-ID: <153938923243.8361.6493326422286445833.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=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=939 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 Change the remap_file_range functions to take a number of bytes to operate upon and return the number of bytes they operated on. This is a requirement for allowing fs implementations to return short clone/dedupe results to the user, which will enable us to obey resource limits in a graceful manner. A subsequent patch will enable copy_file_range to signal to the ->clone_file_range implementation that it can handle a short length, which will be returned in the function's return value. For now the short return is not implemented anywhere so the behavior won't change -- either copy_file_range manages to clone the entire range or it tries an alternative. Neither clone ioctl can take advantage of this, alas. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 6 ++--- fs/btrfs/ctree.h | 6 ++--- fs/btrfs/ioctl.c | 13 ++++++---- fs/cifs/cifsfs.c | 6 ++--- fs/ioctl.c | 10 +++++++- fs/nfs/nfs4file.c | 6 ++--- fs/nfsd/vfs.c | 8 +++++- fs/ocfs2/file.c | 16 ++++++------- fs/ocfs2/refcounttree.c | 2 +- fs/ocfs2/refcounttree.h | 2 +- fs/overlayfs/copy_up.c | 6 ++--- fs/overlayfs/file.c | 12 +++++---- fs/read_write.c | 47 ++++++++++++++++++++----------------- fs/xfs/xfs_file.c | 9 +++++-- fs/xfs/xfs_reflink.c | 4 ++- fs/xfs/xfs_reflink.h | 2 +- include/linux/fs.h | 27 ++++++++++++--------- mm/filemap.c | 2 +- 18 files changed, 105 insertions(+), 79 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 2ec27203e4a6..393909585bd8 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -883,9 +883,9 @@ struct file_operations { unsigned (*mmap_capabilities)(struct file *); #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*remap_file_range)(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int remap_flags); + loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); }; diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 124a05662fc2..771a961d77ad 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3247,9 +3247,9 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, struct extent_state **cached); int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); -int btrfs_remap_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len, - unsigned int remap_flags); +loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags); /* tree-defrag.c */ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index bed5b8f9ec09..3e0aaca9e072 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4328,10 +4328,12 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src, return ret; } -int btrfs_remap_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len, +loff_t btrfs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, loff_t len, unsigned int remap_flags) { + int ret; + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) return -EINVAL; @@ -4349,10 +4351,11 @@ int btrfs_remap_file_range(struct file *src_file, loff_t off, return -EINVAL; } - return btrfs_extent_same(src, off, len, dst, destoff); + ret = btrfs_extent_same(src, off, len, dst, destoff); + } else { + ret = btrfs_clone_files(dst_file, src_file, off, len, destoff); } - - return btrfs_clone_files(dst_file, src_file, off, len, destoff); + return ret < 0 ? ret : len; } static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 06b2587fcc77..816a1b52767e 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -975,8 +975,8 @@ const struct inode_operations cifs_symlink_inode_ops = { .listxattr = cifs_listxattr, }; -static int cifs_remap_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len, +static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, loff_t len, unsigned int remap_flags) { struct inode *src_inode = file_inode(src_file); @@ -1029,7 +1029,7 @@ static int cifs_remap_file_range(struct file *src_file, loff_t off, unlock_two_nondirectories(src_inode, target_inode); out: free_xid(xid); - return rc; + return rc < 0 ? rc : len; } ssize_t cifs_file_copychunk_range(unsigned int xid, diff --git a/fs/ioctl.c b/fs/ioctl.c index 2005529af560..72537b68c272 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -223,6 +223,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, u64 off, u64 olen, u64 destoff) { struct fd src_file = fdget(srcfd); + loff_t cloned; int ret; if (!src_file.file) @@ -230,7 +231,14 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, ret = -EXDEV; if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; - ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen); + cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, + olen); + if (cloned < 0) + ret = cloned; + else if (olen && cloned != olen) + ret = -EINVAL; + else + ret = 0; fdput: fdput(src_file); return ret; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 2452b1941f36..eafa39162cfc 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -180,8 +180,8 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t return nfs42_proc_allocate(filep, offset, len); } -static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, - struct file *dst_file, loff_t dst_off, u64 count, +static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off, + struct file *dst_file, loff_t dst_off, loff_t count, unsigned int remap_flags) { struct inode *dst_inode = file_inode(dst_file); @@ -244,7 +244,7 @@ static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, inode_unlock(src_inode); } out: - return ret; + return ret < 0 ? ret : count; } #endif /* CONFIG_NFS_V4_2 */ diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index b53e76391e52..ac6cb6101cbe 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -541,8 +541,12 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, u64 dst_pos, u64 count) { - return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos, - count)); + loff_t cloned; + + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count); + if (count && cloned != count) + cloned = -EINVAL; + return nfserrno(cloned < 0 ? cloned : 0); } ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 53c8676a0daf..e6ffed70398e 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,18 +2527,18 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) return offset; } -static int ocfs2_remap_file_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len, - unsigned int remap_flags) +static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { + int ret; + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) return -EINVAL; - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); + ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, remap_flags); + return ret < 0 ? ret : len; } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 270a5b1919f6..a3df118bf3b9 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4824,7 +4824,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index d2c5f526edff..eb65c1d0843c 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -119,7 +119,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 1cc797a08a5b..8750b7235516 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -125,6 +125,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) struct file *new_file; loff_t old_pos = 0; loff_t new_pos = 0; + loff_t cloned; int error = 0; if (len == 0) @@ -141,11 +142,10 @@ 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 */ - error = do_clone_file_range(old_file, 0, new_file, 0, len); - if (!error) + cloned = do_clone_file_range(old_file, 0, new_file, 0, len); + if (cloned == len) goto out; /* Couldn't clone, so now we try to copy the data */ - error = 0; /* FIXME: copy up sparse files efficiently */ while (len) { diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 455bf49bd07b..177731b21bad 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -434,14 +434,14 @@ enum ovl_copyop { OVL_DEDUPE, }; -static ssize_t ovl_copyfile(struct file *file_in, loff_t pos_in, +static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, unsigned int flags, enum ovl_copyop op) + loff_t len, unsigned int flags, enum ovl_copyop op) { struct inode *inode_out = file_inode(file_out); struct fd real_in, real_out; const struct cred *old_cred; - ssize_t ret; + loff_t ret; ret = ovl_real_fdget(file_out, &real_out); if (ret) @@ -489,9 +489,9 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, OVL_COPY); } -static int ovl_remap_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int remap_flags) +static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { enum ovl_copyop op; diff --git a/fs/read_write.c b/fs/read_write.c index 0c43997bd4a1..29ec0a6bfa2f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1589,10 +1589,13 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * more efficient if both clone and copy are supported (e.g. NFS). */ if (file_in->f_op->remap_file_range) { - ret = file_in->f_op->remap_file_range(file_in, pos_in, - file_out, pos_out, len, 0); - if (ret == 0) { - ret = len; + loff_t cloned; + + cloned = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, + min_t(loff_t, MAX_RW_COUNT, len), 0); + if (cloned > 0) { + ret = cloned; goto done; } } @@ -1686,11 +1689,12 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, return ret; } -static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) +static int remap_verify_area(struct file *file, loff_t pos, loff_t len, + bool write) { struct inode *inode = file_inode(file); - if (unlikely(pos < 0)) + if (unlikely(pos < 0 || len < 0)) return -EINVAL; if (unlikely((loff_t) (pos + len) < 0)) @@ -1720,7 +1724,7 @@ static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, unsigned int remap_flags) + loff_t *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -1832,12 +1836,12 @@ int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) } EXPORT_SYMBOL(generic_remap_file_range_touch); -int do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +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 inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); - int ret; + loff_t ret; if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; @@ -1870,19 +1874,19 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, ret = file_in->f_op->remap_file_range(file_in, pos_in, file_out, pos_out, len, 0); - if (!ret) { - fsnotify_access(file_in); - fsnotify_modify(file_out); - } + if (ret < 0) + return ret; + fsnotify_access(file_in); + fsnotify_modify(file_out); return ret; } EXPORT_SYMBOL(do_clone_file_range); -int vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +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) { - int ret; + loff_t ret; file_start_write(file_out); ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); @@ -1988,10 +1992,11 @@ int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, } EXPORT_SYMBOL(vfs_dedupe_file_range_compare); -int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, - struct file *dst_file, loff_t dst_pos, u64 len) +loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, + struct file *dst_file, loff_t dst_pos, + loff_t len) { - s64 ret; + loff_t ret; ret = mnt_want_write_file(dst_file); if (ret) @@ -2040,7 +2045,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) int i; int ret; u16 count = same->dest_count; - int deduped; + loff_t deduped; if (!(file->f_mode & FMODE_READ)) return -EINVAL; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index dce01729e522..bc9e94bcb7a3 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -919,20 +919,23 @@ xfs_file_fallocate( return error; } -STATIC int +STATIC loff_t xfs_file_remap_range( struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags) { + int ret; + if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) return -EINVAL; - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, remap_flags); + return ret < 0 ? ret : len; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index ada3b80267c6..b24a2a1c4db1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1296,7 +1296,7 @@ xfs_reflink_remap_prep( loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, + loff_t *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); @@ -1396,7 +1396,7 @@ xfs_reflink_remap_range( loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 6f82d628bf17..c3c46c276fe1 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -28,7 +28,7 @@ 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, + struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, struct xfs_inode *ip, bool *has_shared); diff --git a/include/linux/fs.h b/include/linux/fs.h index b59637b2f484..035d8a88f633 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1779,9 +1779,9 @@ struct file_operations { #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*remap_file_range)(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int remap_flags); + loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; @@ -1846,21 +1846,24 @@ 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, unsigned int remap_flags); + loff_t *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, - struct file *file_out, loff_t pos_out, u64 len); +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); +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); 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); extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); -extern int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, - struct file *dst_file, loff_t dst_pos, - u64 len); +extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, + struct file *dst_file, loff_t dst_pos, + loff_t len); struct super_operations { @@ -2990,7 +2993,7 @@ extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); extern int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *count, unsigned int remap_flags); + loff_t *count, unsigned int remap_flags); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index c34a89a35d5a..369cfd164e90 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3001,7 +3001,7 @@ EXPORT_SYMBOL(generic_write_checks); */ int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *req_count, unsigned int remap_flags) + loff_t *req_count, unsigned int remap_flags) { struct inode *inode_in = file_in->f_mapping->host; struct inode *inode_out = file_out->f_mapping->host; From patchwork Sat Oct 13 00:07:23 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: 10639595 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 2C2CB1869 for ; Sat, 13 Oct 2018 00:07:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19C372B78F for ; Sat, 13 Oct 2018 00:07:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E3272B7A3; Sat, 13 Oct 2018 00:07:43 +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 6B9F82B78F for ; Sat, 13 Oct 2018 00:07:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0FB56B027B; Fri, 12 Oct 2018 20:07:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C96796B027C; Fri, 12 Oct 2018 20:07:38 -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 B5E1B6B027D; Fri, 12 Oct 2018 20:07:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 76F7D6B027C for ; Fri, 12 Oct 2018 20:07:38 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id i64-v6so13795640qtb.21 for ; Fri, 12 Oct 2018 17:07:38 -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=/N8lm4VWMXYX/YUGZqFSMHSFEsAdheTzWafxNONs5mI=; b=i2lOToKaZAxtzGZ762iV5ovdL38VH3tQSdrIxpyLD/ALt0zHxCcjGchQwaGH6x6UIk sVEDBDy8Lw9w8xTr4h/iapRhKD3MYjSj8pORRpTzSbnpvlNjiYCa2PHL3J7sp0FEqamv TiYFjsO5XgO83JDohDNAktwbOV5XqBzpZN2g7sdJyU0Dve7cX6AbiXbLc633Wy/wx4JC WLcmhw+dqQd3AD5aD+FIlPPVBFxtFogEEpnyfRmRumYum0XtIcmUtmaeiC6ek6ljPPti BB4aOqSFVjABFNGAxhHTCaFC7FywYRWC/zPx8fx7c19kdvB95FOjk42WUYNxSKTltJpV ejmA== X-Gm-Message-State: ABuFfohfnPdj8cq8io3R+qFToFy8qxPeknLc9ankqlvVP5D3oj4H4cj+ nUvAvJ4vUOzLtY4vI+8zF64f848vREXc2w+3OR1gsNmR/tfH0Vc99KQKnKYaoJ+pGKQDFaLekkr v+HJRIqtKCHlWo8raP8+wvio3PXmd3z5ckwi4E/CrgiyNCJwBcltiDjRfSzwLzmWKkg== X-Received: by 2002:a37:4855:: with SMTP id v82-v6mr7526246qka.10.1539389258243; Fri, 12 Oct 2018 17:07:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YlGOeSf4Q7iFjYNejJjYqTw+tOenkePZdPLw8+nLNrbVnBpV83obuTPqNjY/+YqKYLW7M X-Received: by 2002:a37:4855:: with SMTP id v82-v6mr7526224qka.10.1539389257664; Fri, 12 Oct 2018 17:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389257; cv=none; d=google.com; s=arc-20160816; b=qgw/fJxDEgpVKItuiYOu4eLyxz94kkEISmqmkPq7iCbUSnv3VwpITJO5+feeaytfls Iikq6KszJDGM06Uie7L2/uzGdrymDi3tQEogpJcsBMr26Vmq1rqj4XDeNLaSPQUCxcT/ 7nJ+3bOB7ZqyAJ6Be2cANATciirQx0sITMjo/icXaKieUhNlMlAaED9mM25s69btRjJs KItxmRzJ24gYESc0FwTk8Xt8CLq9JGVIz8lFrJJUcTypDX6wC4yCHLEoNKLZDDTQTfde LFQTGqhGqeBHZanp74lI76phqsgdxJERhtt2qmlvw3MsRNadZn6QQDoYznZsSiDLsti+ FcwA== 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=/N8lm4VWMXYX/YUGZqFSMHSFEsAdheTzWafxNONs5mI=; b=QVfhnr7mSKE1xZfHU1Pb7SAK3FvPqOFKVltMk1jWQCec112dD0eKGQH8JcUzskslMv ZvDf+84qVH/9wBgK5uZ3iv34qbgM4p1IO8KHt3QQ+xzpdkm4pbTaX+XCU278aH7vRI7U gE5BX7dfDvECYYfROHRrMrbvhJsKs4whGN97Vq43j3uRo2xKy5V1iF9TNDkAfbATbt15 svAG9jPnDfXOAqBY8fvGh9To6x2HX0sAXCvNzAeTcsl28yi3hpSSH56QMPE+OMPkgapj mf6wnTd63yjrDJZLvjybiv2J8Ep6jnJH/lkJY3rp2HZW0RWRKt8Fd185Pah7jy7tSU66 EnAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=U+qfEPnR; 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 s11-v6si1480915qti.348.2018.10.12.17.07.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:37 -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=U+qfEPnR; 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 w9D04whE144098; Sat, 13 Oct 2018 00:07:32 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=/N8lm4VWMXYX/YUGZqFSMHSFEsAdheTzWafxNONs5mI=; b=U+qfEPnRbsDjscZw3d5fkVq++vW7TxgwAM74kABNuVEqmJoHx6scT7Gnn+vh3wumWbep Fne85Xic2w7AoLP9z8hhI9fuiZguL/uoe/9ANC+HmQ2+kIexnTB0C0qQ01Aoxzpu8Ad9 lGtNIuS6Z351ZffHFIfk3QDb0xLjBEWo06nt3bql/NosjhFxJnTcF+jv4p+U96v3O6Ei 1u6vqAyuzAE14nobeGhJA16Yazp96cziQAaeLX24JKhmiCEUA/SKG65TbD/vn8Ia80Ns JuVEqZFHk0r+r/+HVqxRSz1Evren3A2n/C8xD3nzon/pWfBEgVDQvA0QRfdls9Hk8QnR yQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfudpyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:32 +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 w9D07QIK019491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:26 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07PS6031220; Sat, 13 Oct 2018 00:07:25 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:25 +0000 Subject: [PATCH 14/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, 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:07:23 -0700 Message-ID: <153938924351.8361.7769839930817710679.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=617 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 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 177731b21bad..e5cc17281d0b 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 29ec0a6bfa2f..30076ed38091 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1837,12 +1837,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)) @@ -1873,7 +1876,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; @@ -1884,12 +1887,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 035d8a88f633..4acda4809027 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1852,10 +1852,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); From patchwork Sat Oct 13 00:07:30 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: 10639589 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 921FD1508 for ; Sat, 13 Oct 2018 00:07:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F69F2B78F for ; Sat, 13 Oct 2018 00:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 733452B79F; Sat, 13 Oct 2018 00:07:40 +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 B84372B78F for ; Sat, 13 Oct 2018 00:07:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 93D6F6B027A; Fri, 12 Oct 2018 20:07:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8C5716B027D; Fri, 12 Oct 2018 20:07:38 -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 7E7226B027A; Fri, 12 Oct 2018 20:07:38 -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 532836B027A for ; Fri, 12 Oct 2018 20:07:38 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id p128-v6so13499617qke.13 for ; Fri, 12 Oct 2018 17:07:38 -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=TN7HH2GCIHxCaoeyZbzZgqgssWZARYD3D8oz4GWwF4g=; b=t2m5KYTLFv7IXZKAIGIk04mkTLtuSIDCs/dNzk2OOKd2KUQ4k1ph0jNGrcdOzv1o5W s+54LB0iFWx+uxSlk7y981teZyyBJszZT5YfC1mUAlY1ff2RNfyxuFEy6uTS/rAIADkJ Z085vc5501nWkkc2obCk/gfbWDEKyK8fTTaCkQ+kwRAGI6VXH0EgABzsMibAVT+Kns88 Nt2x93O2lQk5sx4x2EmufsxxEMWWK7Xf7NmULiqgIKJ7tGrzwTEpIke7DWAnJw5YVkhL 4PTvR3s1ob9IKkHO+BXhW6uQ7sJKZx/DdmoVyR8PYYSQQjZkcihJFfyBB6WmghOxj0Jy lI1Q== X-Gm-Message-State: ABuFfogLL5Exi/0I9f4eROpC3n4VHzmo5PnmHKEXrj5NURAZtOlxIfAx yQhW5cnFGEJHmAku7BbuLT4MWXvqfPe8XbBicVlskCWPj1OAgWxVFaQJIFV19fh7MhQIHtPXcVD Th/W08+OvMbefwcFSTVIVhR/7AVNO7tR9rodY5YfsSBi85XAGw1h36CY7gjP8yepEbw== X-Received: by 2002:ae9:e507:: with SMTP id w7-v6mr7857462qkf.246.1539389258119; Fri, 12 Oct 2018 17:07:38 -0700 (PDT) X-Google-Smtp-Source: ACcGV63I3nvMOjbDwAq4fqAi1lo8YEWzIeyWy+FToY8CwxXw8SUw41MBgdgATXJspQccQoT1vQXy X-Received: by 2002:ae9:e507:: with SMTP id w7-v6mr7857442qkf.246.1539389257559; Fri, 12 Oct 2018 17:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389257; cv=none; d=google.com; s=arc-20160816; b=Mpl090lxVcCQieiM8Hqd1S2WLlBUVOHWciceRdTPbFYRw58fMbOokB6fEIjEXxJQ4h /D1vTe7YlszQRFJ5CpNZk1SqCv5wOytWKd5zcRkmon2ZQZg2a7NoYKau7vbIQwkBpVHe Uh+IRP00dE9jWOSetXuiCgKqU+KQ580beM4Ar0MmA8X06vd1Lu4qEgFejVXLQpkCgz9O xD4++j2ifmgmnbPCIqBjp1G4EuNSpfJUiLrhj6lcwp/4L63hzgiN12zZOR0WKzdzZJq5 aim04xwfjW+wcqnJhXShhF0xO1mXhGmIWpuAChfwq1Crr0rWykxuFHrgEAkWoI0BPdga LlbQ== 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=TN7HH2GCIHxCaoeyZbzZgqgssWZARYD3D8oz4GWwF4g=; b=Gsvr3/KYRBt1I8HoMzTAcr9F3BWdxkxq/2/AyxS8o9SIEKkf/Jab/H2rGbL8zkJ+9l R1xKaEVCqIcXbIqonOITZXYtw0oZpDS9n7Wh/goLqXrzVN6AT/zuw/o/zSb47d43onhJ fQ/VroHb01zXaAugE0ptYaChfvAq8tod6kk6Ul0MBP3YsBzCFb7qi3PwjGZLMBAD2wGw ksvC/BzHb14je23axlPyoHpb3ATvn3/mlt10yQoiuM/7EcVc71Njy7Bh/wC3RCDbBVgt FFAlArOMXfUOqjyl4xJsWz0eLTavz89eKbMQK7x7XRDycudmeOMb79JkV3QQ8H4+6hgY LPjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=nKTtE7Zc; 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 l11-v6si105273qtr.173.2018.10.12.17.07.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:37 -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=nKTtE7Zc; 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 w9D052ox163671; Sat, 13 Oct 2018 00:07:34 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=TN7HH2GCIHxCaoeyZbzZgqgssWZARYD3D8oz4GWwF4g=; b=nKTtE7ZcI+TH2aJMzxu1S8qnaQVm1r2qKOlfvwI7ot2t1+kMqtZZCeW4oFn5lWuDFleS /ktU1IE2qJbhu/eolBTYuqmyiJRtY9rSJ8Z8uvbk36BlG+9FV/wDPUMx+UKG1h8sKIqy +u8hbZtoP/iNIB2lRIz/xzs+XpX96BR3zY/BaDEgtMNsTqK8P993Wk/efsAD4qACT/Zm cIinCllnk0VBdl5btli4IErsx41pRUvL/zenC6mnRjtzFjoEjQIoaW++oiCFVMkbQKJc Yr2ClLNzt2yoSW/GjqksmncIJkbzt4eiuNH7pbxs77DD47Ogq9EwdQ8x6rugTcR6ISQb DQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmg4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:34 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07W00004001 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:32 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D07Wap018219; Sat, 13 Oct 2018 00:07:32 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:32 +0000 Subject: [PATCH 15/25] vfs: plumb RFR_* remap flags through the vfs dedupe 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: Fri, 12 Oct 2018 17:07:30 -0700 Message-ID: <153938925037.8361.16126790489559826169.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=525 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 a remap_flags argument through the vfs_dedupe_file_range_one functions so that dedupe can take advantage of it. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/overlayfs/file.c | 3 ++- fs/read_write.c | 9 ++++++--- include/linux/fs.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index e5cc17281d0b..8f7a162768f2 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -467,7 +467,8 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, case OVL_DEDUPE: ret = vfs_dedupe_file_range_one(real_in.file, pos_in, - real_out.file, pos_out, len); + real_out.file, pos_out, len, + flags); break; } revert_creds(old_cred); diff --git a/fs/read_write.c b/fs/read_write.c index 30076ed38091..81e0f969da59 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1999,10 +1999,12 @@ EXPORT_SYMBOL(vfs_dedupe_file_range_compare); loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, - loff_t len) + loff_t len, unsigned int remap_flags) { loff_t ret; + WARN_ON_ONCE(remap_flags & ~(RFR_SAME_DATA)); + ret = mnt_want_write_file(dst_file); if (ret) return ret; @@ -2033,7 +2035,7 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, } ret = dst_file->f_op->remap_file_range(src_file, src_pos, dst_file, - dst_pos, len, RFR_SAME_DATA); + dst_pos, len, remap_flags | RFR_SAME_DATA); out_drop_write: mnt_drop_write_file(dst_file); @@ -2101,7 +2103,8 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) } deduped = vfs_dedupe_file_range_one(file, off, dst_file, - info->dest_offset, len); + info->dest_offset, len, + 0); if (deduped == -EBADE) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index 4acda4809027..d77b8d90d65e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1863,7 +1863,7 @@ extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, - loff_t len); + loff_t len, unsigned int remap_flags); struct super_operations { From patchwork Sat Oct 13 00:07:37 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: 10639613 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 BCA961869 for ; Sat, 13 Oct 2018 00:07:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7A542B78F for ; Sat, 13 Oct 2018 00:07:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C4792B7A3; Sat, 13 Oct 2018 00:07:46 +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 133F32B78F for ; Sat, 13 Oct 2018 00:07:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4CEB76B027F; Fri, 12 Oct 2018 20:07:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 47FAD6B0280; Fri, 12 Oct 2018 20:07:44 -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 397636B0281; Fri, 12 Oct 2018 20:07:44 -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 10ABF6B0280 for ; Fri, 12 Oct 2018 20:07:44 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id v198-v6so13353484qka.16 for ; Fri, 12 Oct 2018 17:07:44 -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=XyX+a0OwgmoCuUQlM5FRUIUGIs9diILaZiWpCujlIew=; b=I/biwuD5GSgCDCbdN/Q0b7ZHiAxS2iJ/kM/Rq4Csc9hWIvHM5zIppMoYeVtMwxhZzY /PrCbye8yi4MCX4iyiJwvn3nM9zRt1MBN9r61vSLzmfwyf9tN9loDLvAh23Dj6K+D7Pt 2aryHbhckWCLwLlL2xmeBBxV6b/yAUVI5jSJoU6B4rt0MMMQIxP4dSK0voE94EYElBWL sTeD1YkdCtmAwKKizoqzgLvFqkqUVfUbz8vED67KpQeUKsPToGRMbkxKuIXvdLAaJUwl BGXNOVRzffL5PcUW281QdX0hXlCvocr0d7OjJS+TDfk6vsCZp6rKy6cBmq80WbWh9na+ O7vA== X-Gm-Message-State: ABuFfoi9VtQR30V053MB1UV048TgSIGq6JeodQ4nLlR2rY2dl3uYDtUK pQykF+I48XcV++EtyFXfeK11vk+3h6xpZf+TWFU21StOHayudbcJfrsNT31OnP5bAt8Wg31fE11 ZaNmQzYnMvGkN/xIb+SRV1i64rMqyRGWRFIB57WgbJ/nsP2BM+2cBNUIYS4KH/Oj9ag== X-Received: by 2002:a37:4855:: with SMTP id v82-v6mr7526452qka.10.1539389263813; Fri, 12 Oct 2018 17:07:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV63tRWf9/7NT1daVDlMULMmgT3n0cYYormNoHCU/2LQEXuxujMKgmh5+OrGdPUu6CP2rUVd3 X-Received: by 2002:a37:4855:: with SMTP id v82-v6mr7526428qka.10.1539389263232; Fri, 12 Oct 2018 17:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389263; cv=none; d=google.com; s=arc-20160816; b=mDWZf737UpZxIJ/1Ov+d3qNRjvyNBkU8SlKQaD2H7FCMUUMu18SCrH2mjHkJJcJPy0 ceOCMBPOXMOkhIrYRlcxuW91u0n1byeCaS4WPerzM/eqEtskeDq0yaEgLatk/Z1/nkny jxFoIdXIlmMNyoG5qX8HPrAYZu3Tl4igyj5mDo6qZ4oJhaQ43oVGBSwKhYrCnDLzGJTR 7Ln6pgGKQVfsaiJIhwwak3NrOBK4xeDRS2P7ntGnq2eeSSeD+ISET680Gf+wEKAZxAdw iM7wB/qBQuUym0mchZH9sbX2FhPHnDmAJSWQEjSfpPX9xCyyenUywmazz7SSo44GSBpZ 81xQ== 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=XyX+a0OwgmoCuUQlM5FRUIUGIs9diILaZiWpCujlIew=; b=dYYb4LzgY3mt1Qf/XVUcwgVeJbx683wUmrhHvszPil/furBEd8vBxdtGBLWheVhcje ucTd6twSCc3FcJYu5UibVAZS+K6eDxaA7URciSxchfPjw8otkAMk3/5xq6Uk2c53ENU3 VCqXLYOhUPjxTxMySl69+Ed0uez0LupsLmNRXHb8eXxuIqrxJbnqgItLRd8husR8QWzk C4MZulOSKVuicC50F9IqAsqLJxfPjySy2G50o71ntMdIxfaOsNPLWFjLi6q439+Y6rmD dha6nFeskmFc/o3xmqQNePZZKmQZ02t4ve+PaSzaNjtJXQSl7X6ha8n9TxFILHMf+fM8 I6Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Rd75H4KU; 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 r141-v6si1939687qke.122.2018.10.12.17.07.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:43 -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=Rd75H4KU; 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 w9D04KRw143951; Sat, 13 Oct 2018 00:07:41 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=XyX+a0OwgmoCuUQlM5FRUIUGIs9diILaZiWpCujlIew=; b=Rd75H4KUtot55vJqqDqttjfoxizywdaBfCSQ3pbPE2n5xYGzt88Nt4sOiKC1M37g5tvl KwOXVbALvV6SHPvyjOzUJEvq0K/e7niDLzLkRL5s2ZjmfxfTyXYAYIVzdoesKRAy+03L 0NKr9eUxoNlb+06UOetcYnXX2Xui4aX5SN3t5EtwcRixx6cqWb5R6pISy37nlvt3v6+M zz2N/i6Xtw05Waa38g2C2MookBW4m6nDLpuRSjRuFhPF/sLqItZ7OyOIrj/m7xM3Rmo6 zfedQhPZZKPk0kvmw/mPCz5nEtDVxptnMjtHfBfIpKHvc2huP24mf/4VGYCHfYXp+j6h sQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfudpym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:41 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07dOu019930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:40 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D07dWM019143; Sat, 13 Oct 2018 00:07:39 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:39 +0000 Subject: [PATCH 16/25] vfs: make remapping to source file eof more explicit 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:07:37 -0700 Message-ID: <153938925737.8361.3995899966552253527.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=637 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 Create a RFR_TO_SRC_EOF flag to explicitly declare that the caller wants the remap implementation to remap to the end of the source file, once the files are locked. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ioctl.c | 3 ++- fs/nfsd/vfs.c | 4 +++- fs/read_write.c | 13 ++++++++----- include/linux/fs.h | 8 +++++++- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 505275ec5596..088cf240ca10 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -224,6 +224,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, { struct fd src_file = fdget(srcfd); loff_t cloned; + unsigned int remap_flags = olen == 0 ? RFR_TO_SRC_EOF : 0; int ret; if (!src_file.file) @@ -232,7 +233,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, 0); + olen, remap_flags); if (cloned < 0) ret = cloned; else if (olen && cloned != olen) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 726fc5b2b27a..0dc65047df1a 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -542,8 +542,10 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, u64 dst_pos, u64 count) { loff_t cloned; + unsigned int remap_flags = count == 0 ? RFR_TO_SRC_EOF : 0; - cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, + remap_flags); if (count && cloned != count) cloned = -EINVAL; return nfserrno(cloned < 0 ? cloned : 0); diff --git a/fs/read_write.c b/fs/read_write.c index 81e0f969da59..c02fc5144d15 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1746,15 +1746,18 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) return -EINVAL; - /* Zero length dedupe exits immediately; reflink goes to EOF. */ - if (*len == 0) { + /* + * If the caller asked to go all the way to the end of the source file, + * set *len now that we have the file locked. + */ + if (remap_flags & RFR_TO_SRC_EOF) { loff_t isize = i_size_read(inode_in); - if (is_dedupe || pos_in == isize) - return 0; if (pos_in > isize) return -EINVAL; *len = isize - pos_in; + if (*len == 0) + return 0; } /* Check that we don't violate system file offset limits. */ @@ -1844,7 +1847,7 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, struct inode *inode_out = file_inode(file_out); loff_t ret; - WARN_ON_ONCE(remap_flags); + WARN_ON_ONCE(remap_flags & ~(RFR_TO_SRC_EOF)); if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; diff --git a/include/linux/fs.h b/include/linux/fs.h index d77b8d90d65e..b9c314f9d5a4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1725,10 +1725,15 @@ struct block_device_operations; * These flags control the behavior of the remap_file_range function pointer. * * RFR_SAME_DATA: only remap if contents identical (i.e. deduplicate) + * RFR_TO_SRC_EOF: remap to the end of the source file */ #define RFR_SAME_DATA (1 << 0) +#define RFR_TO_SRC_EOF (1 << 1) -#define RFR_VALID_FLAGS (RFR_SAME_DATA) +#define RFR_VALID_FLAGS (RFR_SAME_DATA | RFR_TO_SRC_EOF) + +/* Implemented by the VFS, so these are advisory. */ +#define RFR_VFS_FLAGS (RFR_TO_SRC_EOF) /* * Filesystem remapping implementations should call this helper on their @@ -1739,6 +1744,7 @@ struct block_device_operations; static inline bool remap_check_flags(unsigned int remap_flags, unsigned int supported_flags) { + remap_flags &= ~RFR_VFS_FLAGS; return (remap_flags & ~(supported_flags & RFR_VALID_FLAGS)) == 0; } From patchwork Sat Oct 13 00:07:44 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: 10639627 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 1000F1508 for ; Sat, 13 Oct 2018 00:07:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF03E2B78F for ; Sat, 13 Oct 2018 00:07:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF5A92B7A3; Sat, 13 Oct 2018 00:07:52 +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 49B122B78F for ; Sat, 13 Oct 2018 00:07:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4A586B0283; Fri, 12 Oct 2018 20:07:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BD2AC6B0284; Fri, 12 Oct 2018 20:07:50 -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 AE8AC6B0285; Fri, 12 Oct 2018 20:07:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 6BA306B0283 for ; Fri, 12 Oct 2018 20:07:50 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id j9-v6so6769040plt.3 for ; Fri, 12 Oct 2018 17:07:50 -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=hGJg7Mw2eDLP+J7yKVhYwcUJLtxNrIR1f+LqpGNW/UQ=; b=HOtM7z8F98V9r3NjCgYnFg3dysgBNCC1HZxjkyH5UBeiEtMHB7cpRlTLY8YBX7BX9q nEGDT1IQoK+Bt0TLOBXgn2p+CDtjaZZCdYQORLKTnS0cV3VOOlly1eAGQ+gZunUwtoPb KZOMmEO4i/1ZV85luc2YZYtRkL15onToMHFY1+nfqh5ha2ZBUUat31cV3nIDc6yDNHVg EYCoGTiqgYVc8SsMDCG9JVvO4qnmze6C6AaqoxKKJGUlK7XNGSDAATSnJ5ktS/rUC4ym JcBhXkjQjsocM1yrwDkXHTmzsFDmxPY3sDmVU5lKEZWWtNEJsnm0up5jTyRjutNOziFO JqKQ== X-Gm-Message-State: ABuFfoi6s8iS3le3B5Aw+WDtVuOe6CaWsjf+D0wNvFmKYO02Y9jkL6Ez ytKDnoKpP1um41QW3QVJtXSgk6LKnPmDRvFAt3nn6sDXQXghjzjEgbF8oU/WKAHXTS1C8Yaw4P5 KW1blt+QGS7s5bFEtgzBsic2zzuYjmYpNQ5KKaSTb3/AMQgIDuo0kwCMtrG1mUHC5TA== X-Received: by 2002:a62:9015:: with SMTP id a21-v6mr8167568pfe.49.1539389270088; Fri, 12 Oct 2018 17:07:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV62J3glaEByPH1temHTi7C2eaj6+Jv6xHrjogONz4xvR/xeVL8QnGxx3j+tTFIqoljm9dUkB X-Received: by 2002:a62:9015:: with SMTP id a21-v6mr8167509pfe.49.1539389269223; Fri, 12 Oct 2018 17:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389269; cv=none; d=google.com; s=arc-20160816; b=axjoUgbpV3wF928LztEa/bK3u5DBS+aGLGt3Jai/5CNLdpM5ccsFqIW3Oduwd8Fvjm 58wHtLrWShHHQYLX+bqvxOjvARy6PdmLZaoMkERsszZ/AbnW4V2OaoJ8ArhUclrFNy0e y0GGjjNIeaTvxbVhTolpW1XdbT7RZWDaEKCwf5VKKmKgimRvOeOFK/Xxpw/BOzVG3G0l /3fYAxJprZ98mdTONnQNN7mgVlT5DZRRzZKpqJQMS12c37SdArk0AOUgeu5AzdNCFlRB fxdcsA5mYVFSFBKos1gGtzL0IUjZHxusx9lws2MXtrv/x/ai1H9qp/AKSrRAF75Whfel wm1Q== 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=hGJg7Mw2eDLP+J7yKVhYwcUJLtxNrIR1f+LqpGNW/UQ=; b=R/J0Cm30ky1GayYBdopUzmv+eqHI0IDCRyPdZVO0pIlRx3ZYsWnal5NDXyS19VDIAw cxOqyoAO8hjcXbEw5CVUDGYQta3Zkumr92WQkzP6roB9guz+RBobNm8h9YyZ1fvWWcfF Wf/gwBxjoQAV43Q4x1QJznnYx5Vs7Oi9PYFPaX4s4LIShzQ5y+l7O69FgMen4gwhWFQT bPPn5bShU3wlt6a0ApOFcQqE/qIWZ/CIUWIexWdoT4KG81FEGSczERg9bbu8Cjd8ouzi 5uauilO5CTceA/4FS1Jo8JouUWDBxg4EfAX967RwyYGCX37SW+qCpybF1z5okLSxsNIG ghoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=rr6AY7BY; 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 e4-v6si2868414pfa.274.2018.10.12.17.07.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:49 -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=rr6AY7BY; 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 w9D04VUQ143988; Sat, 13 Oct 2018 00:07: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=hGJg7Mw2eDLP+J7yKVhYwcUJLtxNrIR1f+LqpGNW/UQ=; b=rr6AY7BYYBkvd8M4lgeVvqXmQnU6Ue9WmevUeehAkOKabX6x2z4Pu6mwXnUfHtFOfJKw svD1AuPIj9oqyd7loGDib3ppsbw6fpX5oBpLNucYdwEuWV05Jgn7Wz7vHv+l5ZRK/tEx JahBEhoV6Df1qubV/VrQ2dKpARFNPBxTaj0PZQcDPLgU6pwNben8sUnpsIaLsma+Ab2u C0/6u7ANd+bc6/2uXuIzE5LBqfWf/eFTM22uOHHH/3xVqUpvXxdJwlrr42NYnsR+tqEw 6zeL9IiWsUrN2IBGSuMX3RuPpokHlAAWzj4bpyZophwr54HUcCcMCYjDu/ptesrHExtO 8Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfudpyv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07kQR025497 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:46 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D07kfm018360; Sat, 13 Oct 2018 00:07:46 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:45 +0000 Subject: [PATCH 17/25] vfs: enable remap callers that can handle short operations 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:07:44 -0700 Message-ID: <153938926421.8361.13101766265446494393.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 in a remap flag that enables the filesystem remap handler to shorten remapping requests for callers that can handle it. Now copy_file_range can report partial success (in case we run up against alignment problems, resource limits, etc.). We also enable CAN_SHORTEN for fideduperange to maintain existing userspace-visible behavior where xfs/btrfs shorten the dedupe range to avoid stale post-eof data exposure. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 22 +++++++++++++++------- include/linux/fs.h | 7 +++++-- mm/filemap.c | 16 ++++++++++++---- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index c02fc5144d15..86a8c2557d18 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1593,7 +1593,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, cloned = file_in->f_op->remap_file_range(file_in, pos_in, file_out, pos_out, - min_t(loff_t, MAX_RW_COUNT, len), 0); + min_t(loff_t, MAX_RW_COUNT, len), + RFR_CAN_SHORTEN); if (cloned > 0) { ret = cloned; goto done; @@ -1797,6 +1798,8 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, /* Are we doing a partial EOF block remapping of some kind? */ if (*len & blkmask) { + loff_t new_len = *len; + /* * If the dedupe data matches, chop off the partial EOF block * from the source file so we don't try to dedupe the partial @@ -1804,11 +1807,16 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, * * If the user is attempting to remap a partial EOF block and * it's inside the destination EOF then reject it. + * + * If possible, shorten the request instead of rejecting it. */ - if (is_dedupe) - *len &= ~blkmask; - else if (pos_out + *len < i_size_read(inode_out)) - return -EINVAL; + if (is_dedupe || pos_out + *len < i_size_read(inode_out)) + new_len &= ~blkmask; + + if (new_len != *len && !(remap_flags & RFR_CAN_SHORTEN)) + return is_dedupe ? -EBADE : -EINVAL; + + *len = new_len; } return 1; @@ -2006,7 +2014,7 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, { loff_t ret; - WARN_ON_ONCE(remap_flags & ~(RFR_SAME_DATA)); + WARN_ON_ONCE(remap_flags & ~(RFR_SAME_DATA | RFR_CAN_SHORTEN)); ret = mnt_want_write_file(dst_file); if (ret) @@ -2107,7 +2115,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) deduped = vfs_dedupe_file_range_one(file, off, dst_file, info->dest_offset, len, - 0); + RFR_CAN_SHORTEN); if (deduped == -EBADE) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index b9c314f9d5a4..57cb56bbc30a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1726,14 +1726,17 @@ struct block_device_operations; * * RFR_SAME_DATA: only remap if contents identical (i.e. deduplicate) * RFR_TO_SRC_EOF: remap to the end of the source file + * RFR_CAN_SHORTEN: caller can handle a shortened request */ #define RFR_SAME_DATA (1 << 0) #define RFR_TO_SRC_EOF (1 << 1) +#define RFR_CAN_SHORTEN (1 << 2) -#define RFR_VALID_FLAGS (RFR_SAME_DATA | RFR_TO_SRC_EOF) +#define RFR_VALID_FLAGS (RFR_SAME_DATA | RFR_TO_SRC_EOF | \ + RFR_CAN_SHORTEN) /* Implemented by the VFS, so these are advisory. */ -#define RFR_VFS_FLAGS (RFR_TO_SRC_EOF) +#define RFR_VFS_FLAGS (RFR_TO_SRC_EOF | RFR_CAN_SHORTEN) /* * Filesystem remapping implementations should call this helper on their diff --git a/mm/filemap.c b/mm/filemap.c index 369cfd164e90..bccbd3621238 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3051,8 +3051,12 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, if (pos_in + count == size_in) { bcount = ALIGN(size_in, bs) - pos_in; } else { - if (!IS_ALIGNED(count, bs)) - return -EINVAL; + if (!IS_ALIGNED(count, bs)) { + if (remap_flags & RFR_CAN_SHORTEN) + count = ALIGN_DOWN(count, bs); + else + return -EINVAL; + } bcount = count; } @@ -3063,10 +3067,14 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, pos_out < pos_in + bcount) return -EINVAL; - /* For now we don't support changing the length. */ - if (*req_count != count) + /* + * We shortened the request but the caller can't deal with that, so + * bounce the request back to userspace. + */ + if (*req_count != count && !(remap_flags & RFR_CAN_SHORTEN)) return -EINVAL; + *req_count = count; return 0; } From patchwork Sat Oct 13 00:07: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: 10639641 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 D51B91508 for ; Sat, 13 Oct 2018 00:07:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C20FC2B78F for ; Sat, 13 Oct 2018 00:07:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5BD92B7FA; Sat, 13 Oct 2018 00:07:59 +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 150782B78F for ; Sat, 13 Oct 2018 00:07:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A26506B0284; Fri, 12 Oct 2018 20:07:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9AEA76B0286; Fri, 12 Oct 2018 20:07:57 -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 8C72D6B0287; Fri, 12 Oct 2018 20:07:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 4A9456B0284 for ; Fri, 12 Oct 2018 20:07:57 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 11-v6so10506505pgd.1 for ; Fri, 12 Oct 2018 17:07:57 -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=tC47Y7Of1RhDxOgcQAduRR4B2Ct08GgJmbmOlMIirio=; b=i4RO4TKAeyKH69CFwNsU4q7AoGnLBmhac2j22uzFs6cqU+X4F824DxIlLji7xiAFCk MCCRhAF6S9kNF8aByzabRHz3gEK8ZS/lkTwidxGeOLivTB88KQlTXHXkYXIpNx8loet6 VHbgvK46bolWcYXJ6H1bImSKAe3Ta7xw3xRrGAaZGfHj8M+B2a2yrH4m/R/Dt3WcWT/4 UJQ5rx9Pxug03i+w0Uzsz1TbAXpw3gJfT7UG99on10X3jrejN/dfjcU0FAeXb1tkrA8s iTPm5JTAPwHfhzzOYG8zA6NAkrFmTx0mePSzt76Flf0g5xucZv0OBoT41xrtbUE0PXVV rkTQ== X-Gm-Message-State: ABuFfojnVINHznXUxW64Ou/IIv83TLL2eteY/aZoNl/9LlkwX4tZwdpQ XqGlHmZt+LsLsrduO164Uj3HgLJNO9toCicY7DfBEtLL8Tkth+Rz1arpQcyIdeBXMw/OVKC4qT1 ALyoAlQlZJ8FbKlkdTm9Zg6PFJJfQue+epChNQQYr61fFTz+7msTC7Ar5aWv/J6tlFw== X-Received: by 2002:a65:52c1:: with SMTP id z1-v6mr7316448pgp.65.1539389276960; Fri, 12 Oct 2018 17:07:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV6193FN1MVJ05hrzBugmXZLhljqrO40ZZS4h7eVYmnveS5Y6koZn0LL0yC88GWlJpxxKUgZC X-Received: by 2002:a65:52c1:: with SMTP id z1-v6mr7316404pgp.65.1539389276156; Fri, 12 Oct 2018 17:07:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389276; cv=none; d=google.com; s=arc-20160816; b=OfEi+Jhyga78qbpImp8Z3/fy35agY/MML4yrTlqjBskF9o9gKBDIYm7w4i5b+29NaP D4zTFiCL4I6Lqag9PGibVYJR2Qg2lwN9rKnSxLV3PQFRV8XlL7/gaucwprk2OGWEme2E yClGVNMl9s6rJxiWuo3V6VMDHotCQyZd8ydTC5TXRB22vAdvog495viPdI5ko9EEM1pK uJTjiIgeTABofpvSO2fR5wS1aI/v5gKRrJqXfqp+85aS9mhnYa2B0fQ3KS0090TfnMYj BLcvnbu/bzsFIZ21WZrhp3ZdtSreUBZtuGd2+sW89Bduei/R7pb6fsM62MK25ffkSmds kiYg== 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=tC47Y7Of1RhDxOgcQAduRR4B2Ct08GgJmbmOlMIirio=; b=fSDt9/cZsi5yOxA9NI57oYbXP67TlcYBvTWzYO4bBGbcTZeAZc1W+vWHhXFo5ghQtV QYcclvrplzsoBXVWrPzsI/1RaeTSxnePZ7VOnthY2ULv0TenszuHkDbOoDSFFBlanF0n 3lsx5Exob+0vmO+fp+dOecUnWt8yS3GhA2+8P2bieWLU/XSKZ99GiZ3iXmPTrv12+5Vw vXVIgGPuqWvjEeyb+9KJssknbMICPPKpo/D4GR5VjPGwSS/cX/seYnepy0zOlYxbgz+M KV/vtk+uj1luIrTI0rgYUG2xZ8a3PsMSso6SM0d4EeG2xyXUPhphg4786DfpoSdhUW/z uPXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Jqig3QDB; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id j15-v6si2734057pgg.433.2018.10.12.17.07.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:07:56 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Jqig3QDB; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D05F0r105290; Sat, 13 Oct 2018 00:07:54 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=tC47Y7Of1RhDxOgcQAduRR4B2Ct08GgJmbmOlMIirio=; b=Jqig3QDB6zOoCG+A6Y1STR7XzjNGeYtELin8dHfaFqbHYbG2jqWAEI4D1Z7bHRwUfw9M lcI1926hTXRDkAtJhlultBGguKhBonSjCpAtYHIe2mzYgej1TVtqD+ZNXP9HJxn8MvDZ vECNe9L3qk/duWcKv6+XLNKwKZg1L1+gUWr59lmC1u99zvK3e5pXyFD0CX90v2hF1RJf Zq1pWouSZgizfshH942Tt/7RSrsMG853BACAotHLKzlJsngfDrmcXTtC+RWfRkbYOtQq oIy6INwMRFtJQsXX3hZHwFvlcqggMUpKJ97sGzUpkU+L8e50U5eM/JF4gB1mprxYfIvB bg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnprnfkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:54 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D07rfM025719 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:07:53 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 w9D07qch031416; Sat, 13 Oct 2018 00:07:53 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:52 +0000 Subject: [PATCH 18/25] vfs: hide file range comparison function 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:07:51 -0700 Message-ID: <153938927103.8361.6327676425188043040.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=627 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 There are no callers of vfs_dedupe_file_range_compare, so we might as well make it a static helper and remove the export. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- fs/read_write.c | 191 ++++++++++++++++++++++++++-------------------------- include/linux/fs.h | 3 - 2 files changed, 95 insertions(+), 99 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 86a8c2557d18..ce3d5c4b1d34 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1714,6 +1714,101 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len, return security_file_permission(file, write ? MAY_WRITE : MAY_READ); } +/* + * Read a page's worth of file data into the page cache. Return the page + * locked. + */ +static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) +{ + struct address_space *mapping; + struct page *page; + pgoff_t n; + + n = offset >> PAGE_SHIFT; + mapping = inode->i_mapping; + page = read_mapping_page(mapping, n, NULL); + if (IS_ERR(page)) + return page; + if (!PageUptodate(page)) { + put_page(page); + return ERR_PTR(-EIO); + } + lock_page(page); + return page; +} + +/* + * Compare extents of two files to see if they are the same. + * Caller must have locked both inodes to prevent write races. + */ +static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, + struct inode *dest, loff_t destoff, + loff_t len, bool *is_same) +{ + loff_t src_poff; + loff_t dest_poff; + void *src_addr; + void *dest_addr; + struct page *src_page; + struct page *dest_page; + loff_t cmp_len; + bool same; + int error; + + error = -EINVAL; + same = true; + while (len) { + src_poff = srcoff & (PAGE_SIZE - 1); + dest_poff = destoff & (PAGE_SIZE - 1); + cmp_len = min(PAGE_SIZE - src_poff, + PAGE_SIZE - dest_poff); + cmp_len = min(cmp_len, len); + if (cmp_len <= 0) + goto out_error; + + src_page = vfs_dedupe_get_page(src, srcoff); + if (IS_ERR(src_page)) { + error = PTR_ERR(src_page); + goto out_error; + } + dest_page = vfs_dedupe_get_page(dest, destoff); + if (IS_ERR(dest_page)) { + error = PTR_ERR(dest_page); + unlock_page(src_page); + put_page(src_page); + goto out_error; + } + src_addr = kmap_atomic(src_page); + dest_addr = kmap_atomic(dest_page); + + flush_dcache_page(src_page); + flush_dcache_page(dest_page); + + if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) + same = false; + + kunmap_atomic(dest_addr); + kunmap_atomic(src_addr); + unlock_page(dest_page); + unlock_page(src_page); + put_page(dest_page); + put_page(src_page); + + if (!same) + break; + + srcoff += cmp_len; + destoff += cmp_len; + len -= cmp_len; + } + + *is_same = same; + return 0; + +out_error: + return error; +} + /* * Check that the two inodes are eligible for cloning, the ranges make * sense, and then flush all dirty data. Caller must ensure that the @@ -1912,102 +2007,6 @@ loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, } EXPORT_SYMBOL(vfs_clone_file_range); -/* - * Read a page's worth of file data into the page cache. Return the page - * locked. - */ -static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) -{ - struct address_space *mapping; - struct page *page; - pgoff_t n; - - n = offset >> PAGE_SHIFT; - mapping = inode->i_mapping; - page = read_mapping_page(mapping, n, NULL); - if (IS_ERR(page)) - return page; - if (!PageUptodate(page)) { - put_page(page); - return ERR_PTR(-EIO); - } - lock_page(page); - return page; -} - -/* - * Compare extents of two files to see if they are the same. - * Caller must have locked both inodes to prevent write races. - */ -int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, - struct inode *dest, loff_t destoff, - loff_t len, bool *is_same) -{ - loff_t src_poff; - loff_t dest_poff; - void *src_addr; - void *dest_addr; - struct page *src_page; - struct page *dest_page; - loff_t cmp_len; - bool same; - int error; - - error = -EINVAL; - same = true; - while (len) { - src_poff = srcoff & (PAGE_SIZE - 1); - dest_poff = destoff & (PAGE_SIZE - 1); - cmp_len = min(PAGE_SIZE - src_poff, - PAGE_SIZE - dest_poff); - cmp_len = min(cmp_len, len); - if (cmp_len <= 0) - goto out_error; - - src_page = vfs_dedupe_get_page(src, srcoff); - if (IS_ERR(src_page)) { - error = PTR_ERR(src_page); - goto out_error; - } - dest_page = vfs_dedupe_get_page(dest, destoff); - if (IS_ERR(dest_page)) { - error = PTR_ERR(dest_page); - unlock_page(src_page); - put_page(src_page); - goto out_error; - } - src_addr = kmap_atomic(src_page); - dest_addr = kmap_atomic(dest_page); - - flush_dcache_page(src_page); - flush_dcache_page(dest_page); - - if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) - same = false; - - kunmap_atomic(dest_addr); - kunmap_atomic(src_addr); - unlock_page(dest_page); - unlock_page(src_page); - put_page(dest_page); - put_page(src_page); - - if (!same) - break; - - srcoff += cmp_len; - destoff += cmp_len; - len -= cmp_len; - } - - *is_same = same; - return 0; - -out_error: - return error; -} -EXPORT_SYMBOL(vfs_dedupe_file_range_compare); - loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, loff_t len, unsigned int remap_flags) diff --git a/include/linux/fs.h b/include/linux/fs.h index 57cb56bbc30a..f0603ed007e9 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1865,9 +1865,6 @@ extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, 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, 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); extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, From patchwork Sat Oct 13 00:07:57 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: 10639657 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 22F261869 for ; Sat, 13 Oct 2018 00:08:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A4682B78F for ; Sat, 13 Oct 2018 00:08:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2B912B7FA; Sat, 13 Oct 2018 00:08:06 +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 5D0DF2B78F for ; Sat, 13 Oct 2018 00:08:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DCFA26B0286; Fri, 12 Oct 2018 20:08:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D7E7A6B0288; Fri, 12 Oct 2018 20:08:04 -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 C6E406B0289; Fri, 12 Oct 2018 20:08:04 -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 9CAB56B0286 for ; Fri, 12 Oct 2018 20:08:04 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id s24-v6so10582386plp.12 for ; Fri, 12 Oct 2018 17:08:04 -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=y5SA1q09PlxlYakQ5hgDwBmKYx7ptm+DDCmNZyuOEOQ=; b=cSlUkSEU3ilmaH1mzcRl9xH67r5VjmwwkITOiprdk32o4SGkEbQpvQGLEblVwXhPUj yDvychylLi7v9zjQ2A9MgH3hN4sqYGT0CSe0JJmExpPtFit2LoOZ65jYje6LtztsCVVZ vW+S+OXCS9Hb3yuippaNXmOrsg/Wz29ygIqEvVejl3c/aPAVfwl/aeQwTziScwmFaip5 OOOVVrqBiUyM/neUtowcIlcfwszhNPrimuQ+BaWhEyt7RnVx8Dv6EqPsgyfCBz2v2qEU f/OSGVncdmE/OD1gwUcfe685BucA3N+eVcPkE4k+eJNd8JuosAybCoiIDVX3Jv5yF0Io GlSQ== X-Gm-Message-State: ABuFfohvFusrAQwZ6OHCynk4pKyV5kOuXIR3wIrRyDzuUZZccYFFO51X 7J5vtxuNYWqQsaqjVBp/FoeLpJfPN93Nci3MRa3yM2xKVnfDhcSsFMrBewh8F6S78jDe3PeTMPe qJYH2o9VfgUhanrXy1JsEwsQ0lQsPgGiTSI1QDE+4BM2vvBQ5kZL/mREoqxTIygvSPg== X-Received: by 2002:a65:66c9:: with SMTP id c9-v6mr7412100pgw.55.1539389284297; Fri, 12 Oct 2018 17:08:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV60mZhqAfPNVdTUcOSuM8uY6VK/BJJ+aGALoAiEf1rILoRzSGUF80pfMqLBsqVjycbSilNyC X-Received: by 2002:a65:66c9:: with SMTP id c9-v6mr7412056pgw.55.1539389283475; Fri, 12 Oct 2018 17:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389283; cv=none; d=google.com; s=arc-20160816; b=xvTwX/Vas/tLuqwELF8Szk4UL26AmJDojf4/muwzl3NSiW/kbAliD1Lwf+duzyvBpB 1i0W/HANfcPsW2STbUjnqvd/945iMDGlYZwuJPjAFufQ3fMTwzdDdOWCZDkg9rvEOeXP oV4AJHtD1Gt4QwOAQ2PlS/xdJOq7Y97VnNL3IISEUKFmT1Gkv2Jh8rm87hV0hNeNRCwJ 19iRQdckeMzkuIwQGAB07T67aznV12s9vLF1vMT4U/dDAdG7ZlYinqm3M81hone4px+M UFy/FKJG97FBqLTZMb4C37+F5wh7wkPXE7uSkNrjVARDadfu4CbB5tr600vkfLgW00Bo yh6Q== 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=y5SA1q09PlxlYakQ5hgDwBmKYx7ptm+DDCmNZyuOEOQ=; b=JSTTGxIUFaaORr+D8YARrX8EaHBm3VzxeBJ4ktQ5g77U0G+vS8+2erv3v3RhPBMxfc hOd9lazYgBhoK3YRXJOkVHIGij3LC4C6wi2fsZ4+yqvwLWchQI5TiLnLpTf9Iehj9gLr kJnu7+0bm4doqqmr9gYRo0g3rhZfvrPfrTy8p7MqrgVuZymX79zf+yLWWjnjIUyzRXBQ 2jO1azBp2+zptI1/MrGRVM65xx6K6tWtequPvXCEyQDnYAZ0LilclGlhaXeSW575A+w+ c4dD/uqOz9sg1x+V2HbGAOnHQ6PGbopO222MFDrJN/QXC4cb546JBwG4/0yRXx/XEruv LUXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ic968xdb; 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 187-v6si3083783pfe.182.2018.10.12.17.08.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:03 -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=Ic968xdb; 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 w9D0428p143613; Sat, 13 Oct 2018 00:08:01 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=y5SA1q09PlxlYakQ5hgDwBmKYx7ptm+DDCmNZyuOEOQ=; b=Ic968xdb9NHeSzipxiKfpzW8wt6h1oOp/woIQkavl98yJvoC8zasjZFjRpoUC4ahoKMJ fBA+BEAT3N9mEwtvDbarHh3shXwCDtwPyTV3GNn1VDVzJvDFfKSIXzhmN5w8E9MDxdLG q/OvcjT9hDAnurMH6yWgTxt5t3Ha6C+wACMqRxPh0UTCCYY86nq80PXXJAuhGixLm81y WngZXQHd+sm7efNxSxtruYtUxtaCKvQndYvc2YLaYOTXFlcZSH1wXOLCnepdR3mstYdr sEqiYeQTV6xeu+7jQjDfu30tLNXsAn8EQO7v98UBDFUN6GL1n+hwLzgStPUEFk0V1Jcj aQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfudq07-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:01 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D080ZC020625 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D07xkx019300; Sat, 13 Oct 2018 00:07:59 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:07:59 +0000 Subject: [PATCH 19/25] vfs: implement opportunistic short dedupe 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:07:57 -0700 Message-ID: <153938927786.8361.10345203650384514542.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 For a given dedupe request, the bytes_deduped field in the control structure tells userspace if we managed to deduplicate some, but not all of, the requested regions starting from the file offsets supplied. However, due to sloppy coding, the current dedupe code returns FILE_DEDUPE_RANGE_DIFFERS if any part of the range is different. Fix this so that we can actually support partial request completion. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 48 ++++++++++++++++++++++++++++++++++++++---------- include/linux/fs.h | 7 +++++-- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index ce3d5c4b1d34..edd2e9ceb71b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1737,13 +1737,26 @@ static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) return page; } +static unsigned int vfs_dedupe_memcmp(const char *s1, const char *s2, + unsigned int len) +{ + const char *orig_s1; + + for (orig_s1 = s1; len > 0; s1++, s2++, len--) + if (*s1 != *s2) + break; + + return s1 - orig_s1; +} + /* * Compare extents of two files to see if they are the same. * Caller must have locked both inodes to prevent write races. */ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, - loff_t len, bool *is_same) + loff_t *req_len, + unsigned int remap_flags) { loff_t src_poff; loff_t dest_poff; @@ -1751,8 +1764,11 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, void *dest_addr; struct page *src_page; struct page *dest_page; - loff_t cmp_len; + loff_t len = *req_len; + loff_t same_len = 0; bool same; + unsigned int cmp_len; + unsigned int cmp_same; int error; error = -EINVAL; @@ -1762,7 +1778,7 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, dest_poff = destoff & (PAGE_SIZE - 1); cmp_len = min(PAGE_SIZE - src_poff, PAGE_SIZE - dest_poff); - cmp_len = min(cmp_len, len); + cmp_len = min_t(loff_t, cmp_len, len); if (cmp_len <= 0) goto out_error; @@ -1784,7 +1800,10 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, flush_dcache_page(src_page); flush_dcache_page(dest_page); - if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) + cmp_same = vfs_dedupe_memcmp(src_addr + src_poff, + dest_addr + dest_poff, cmp_len); + same_len += cmp_same; + if (cmp_same != cmp_len) same = false; kunmap_atomic(dest_addr); @@ -1802,7 +1821,17 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, len -= cmp_len; } - *is_same = same; + /* + * If less than the whole range matched, we have to back down to the + * nearest block boundary. + */ + if (*req_len != same_len) { + if (!(remap_flags & RFR_SHORT_DEDUPE)) + return -EBADE; + + *req_len = ALIGN_DOWN(same_len, dest->i_sb->s_blocksize); + } + return 0; out_error: @@ -1881,13 +1910,11 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, * Check that the extents are the same. */ if (is_dedupe) { - bool is_same = false; - ret = vfs_dedupe_file_range_compare(inode_in, pos_in, - inode_out, pos_out, *len, &is_same); + inode_out, pos_out, len, remap_flags); if (ret) return ret; - if (!is_same) + if (*len == 0) return -EBADE; } @@ -2013,7 +2040,8 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, { loff_t ret; - WARN_ON_ONCE(remap_flags & ~(RFR_SAME_DATA | RFR_CAN_SHORTEN)); + WARN_ON_ONCE(remap_flags & ~(RFR_SAME_DATA | RFR_CAN_SHORTEN | + RFR_SHORT_DEDUPE)); ret = mnt_want_write_file(dst_file); if (ret) diff --git a/include/linux/fs.h b/include/linux/fs.h index f0603ed007e9..18b6db85ab64 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1727,16 +1727,19 @@ struct block_device_operations; * RFR_SAME_DATA: only remap if contents identical (i.e. deduplicate) * RFR_TO_SRC_EOF: remap to the end of the source file * RFR_CAN_SHORTEN: caller can handle a shortened request + * RFR_SHORT_DEDUPE: deduplicate from byte 0 until the file data don't match */ #define RFR_SAME_DATA (1 << 0) #define RFR_TO_SRC_EOF (1 << 1) #define RFR_CAN_SHORTEN (1 << 2) +#define RFR_SHORT_DEDUPE (1 << 3) #define RFR_VALID_FLAGS (RFR_SAME_DATA | RFR_TO_SRC_EOF | \ - RFR_CAN_SHORTEN) + RFR_CAN_SHORTEN | RFR_SHORT_DEDUPE) /* Implemented by the VFS, so these are advisory. */ -#define RFR_VFS_FLAGS (RFR_TO_SRC_EOF | RFR_CAN_SHORTEN) +#define RFR_VFS_FLAGS (RFR_TO_SRC_EOF | RFR_CAN_SHORTEN | \ + RFR_SHORT_DEDUPE) /* * Filesystem remapping implementations should call this helper on their From patchwork Sat Oct 13 00:08:04 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: 10639669 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 4A5571869 for ; Sat, 13 Oct 2018 00:08:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3146A2860A for ; Sat, 13 Oct 2018 00:08:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20D702916C; Sat, 13 Oct 2018 00:08:12 +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 9E1B527FAC for ; Sat, 13 Oct 2018 00:08:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FDBE6B0288; Fri, 12 Oct 2018 20:08:10 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0AFA36B028A; Fri, 12 Oct 2018 20:08:10 -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 F08166B028B; Fri, 12 Oct 2018 20:08:09 -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 AFD506B028A for ; Fri, 12 Oct 2018 20:08:09 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id x2-v6so10434778pgr.8 for ; Fri, 12 Oct 2018 17:08:09 -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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=CxIvvJVOCNB/FgDA3oYz6gcDYDmG4t0jQSPErwTjmu7xrlQNWZfFcp5zcAULLoNekP sjP2cSxnmbvOXxTLTaSA5MoSDVAk9F5fFlJG7xlXAQ3ROXR9FjmXRULdRMSZ0yYirH1t naP5OYOpXhoNgjfWomv0r46x5PxQ+VV6yLGiH0DF7bIr0IEYS1Dx3ytQgRvYEpWunIgE ttURCRGKmIrKKSIASKlR03aFABjYVfPfxNRgpDwYXFxDl9edq7S+fh4Vh+AEX/evV8uJ JoW5a//mZhqrIRZ0W0fcRwGGEs388CPf4FpFhPtneZkL+gQdSvJ+WwOFYE/zWZmvfvlT 0Y8w== X-Gm-Message-State: ABuFfohIKKpHLWs7TSx1dtXZ5zkQ7aWSeVe1jPK4C0GU+EBu0V76X4VS pdQiXm1r10F4+zDsFkbw41Poh87+0rq7f6anUs1FUXvxQvpp9860ZUIJJsbEZ8hFnvu/LrtbcfW moJxr3OvCxyzvq16sjcMCVf57WpG72MCH7fWux1xacNJO/eiZ0ZG5ywS8s8NdXbyDTA== X-Received: by 2002:a63:e645:: with SMTP id p5-v6mr7120149pgj.218.1539389289401; Fri, 12 Oct 2018 17:08:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV63m+QU2klSCwfkyH3t3NvUINUGKsSsE4YsFHgrNz9eyDdzu5/7oTiUL4Vyk3mV2KPw6yY2I X-Received: by 2002:a63:e645:: with SMTP id p5-v6mr7120122pgj.218.1539389288838; Fri, 12 Oct 2018 17:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389288; cv=none; d=google.com; s=arc-20160816; b=dtW6fs4Nmxvi+wCqnD2S7CRQAzQWtsIQ6FP/YkBDI9i4E0Ei2rMq7AG3rInMMn8mGD c5WU1/u7DFFIlHSTAaiYBJaKNmjXOoWJuLhdnCLzvIWtN+bjvbuLhdUkYTA2ZaqZ8W6q L1dWO2fd6+dUxTcvQOzSEOBBZRDYL7GnKhpMoyPSkcYX4IIMzpVOGHehDxhZNHE+lWPO RPGmE0XpMn95KNqC9BRnYSHOrQ6YDMbdTfIuz2fQdri81i6NHKLmI7/HjnKh3eeBv5h4 q0Uh79N2F3eAerf2SU84q/jJZ8DiyBOK9VsD2/aqUziJIgHm99RAMeBL95sW5hY3X88l WriQ== 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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=R2JSZcNADWgD4NaDBVYfiiwoe3dNh8648vrukoGJ9M8i8Tljtrjchyb/9gUyOyUZmj c/qI7SwiEUqSkE5FHlz39pwDI/FBcBPIdDZZUmweAO6Z3DF/ZeeuS+FfVDS0RW3cgezL TDJbYs7dBMGM5ZisVPYeFrU+/XziP6GDI3rwMmn8hzc1MUvaNfjti9BWVepj29TpbA2T qsv/1U65GP73UbGJXtoB/+CnveeOkQZLU09SGMZk8FuHnxP3FrK/0a1dLCixr2l/7mrn s/n708CwR3a3nOyiVI/PQQosiTHcBX+reecobGXOPzBhA32DJ6/qKdrti05Mld4KrlRW 1FOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="V/VIXGDJ"; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id q85-v6si2969997pfq.32.2018.10.12.17.08.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="V/VIXGDJ"; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D04cFQ105128; Sat, 13 Oct 2018 00:08:08 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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=V/VIXGDJnBi/VoOavIDBKtXa5moipWtWRr0LdMCPHyEt1+dRJdoL+EN0u/bLaAJnpWha lplN+Cra/xDZ9AIihaEc9aHq8/KNTXT8rOCKndrLUz8g+k8wcIcQHYMj/j+KedycTfvy W5X1Mdn7aW5XLXAzc72oKUjQfl2I6yR8Z2FnEnZis6W2EGEnM0hmqZGYDyjDBJmsFghX 3yfMo828AaBzrxZwidiB6Vfhk+AEgb0VpMCqoTyxxwo4rFhBZngg+kKFWGXy3QXdJH90 YwDvlp6ERQBIVqjLJxqvk5ObnZdM4TqRptM8b+6br3pg8unRD2L57WXUnhbtjbPXIPs+ og== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprnfm1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:07 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D0876O020995 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:07 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D086dq018479; Sat, 13 Oct 2018 00:08:06 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:06 +0000 Subject: [PATCH 20/25] ocfs2: truncate page cache for clone destination file before remapping 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: Fri, 12 Oct 2018 17:08:04 -0700 Message-ID: <153938928467.8361.17081308150390428656.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=801 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 When cloning blocks into another file, truncate the page cache before we start remapping blocks so that concurrent reads wait for us to finish. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index a3df118bf3b9..851ba3ae7ce8 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4869,14 +4869,12 @@ int ocfs2_reflink_remap_range(struct file *file_in, down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, SINGLE_DEPTH_NESTING); - ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, - out_bh, pos_out, len); - /* Zap any page cache for the destination file's range. */ - if (!ret) - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); + truncate_inode_pages_range(&inode_out->i_data, pos_out, + PAGE_ALIGN(pos_out + len) - 1); + ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, + out_bh, pos_out, len); up_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) up_write(&OCFS2_I(inode_out)->ip_alloc_sem); From patchwork Sat Oct 13 00:08:11 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: 10639685 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 59FA35CAF for ; Sat, 13 Oct 2018 00:08:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47CA02B096 for ; Sat, 13 Oct 2018 00:08:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BF292B877; Sat, 13 Oct 2018 00:08:23 +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 C1E5B2B096 for ; Sat, 13 Oct 2018 00:08:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DBF46B028A; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78C586B028C; Fri, 12 Oct 2018 20:08:21 -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 67B946B028D; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 27C8C6B028A for ; Fri, 12 Oct 2018 20:08:21 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 25-v6so10070531pfs.5 for ; Fri, 12 Oct 2018 17:08:21 -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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=BAmjaVNwsxPVB5sUSfTAqrwEVWB2JGb7rkeHwzu4sgmnTkXNjhceJsePw4Mt9UClo3 JUnuNmYMXLixlBwQd88wbw3VNwud4Z7nHkQix5KmccoTep2ueFP70uPuvmmz+5ZPPRC0 8Qorjd5XZO1LepyT9XUPofANB7z9R+DTTdznW/zZNJpxtSds4rG4TrDRULbLcP5kSxO8 rU/RdOXvFugipyoP29pulMm6GXi4E2waQCa7Ozklscz0EZlqR9vs2+xkrEtGHYMydfwE iDpJtzwEeD/rXnJj6oBV/cxWYu8CJXIgWv+eQmWIJKrnVVEVh27XhJp/WdVlD/npJmdg cDHw== X-Gm-Message-State: ABuFfoidnfw7C5xO88BpUgoK6Uz/rpZO4RyVBcFzpxB99J/XRYYCFVyX zI0KIUbqcgD/6p/7Yj9azFeRiLcB2+OdIzHd0gmK1LI/FRy6OQMd257zRMj/kx1frzHqgLqUymD rqrsYxHCBtuoLxzLQenRiFyoJjVgotiJ1UFUjdJZJCRIwGRhLncQ0l7ZaR1D7IK42Kg== X-Received: by 2002:a62:18d3:: with SMTP id 202-v6mr7989720pfy.143.1539389300837; Fri, 12 Oct 2018 17:08:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61LySgiFjm5lLFL7kFDAv4nHqL1EwjQ+0PB7RHy/OPCmkVCc3xX1BhestGycKIeklIzqOgL X-Received: by 2002:a62:18d3:: with SMTP id 202-v6mr7989675pfy.143.1539389300193; Fri, 12 Oct 2018 17:08:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389300; cv=none; d=google.com; s=arc-20160816; b=gyKwM9RiL7SalJP5oU8N4J6DNFs6anQC9DBVIfGLCFdZjHHpH52FBPlAGQdYPVuHT9 3OZN+PQnxXneq/1A6op1k1el7knJITGJyT8Uxt9O2jgWvJ602st2KsN8FeV9Qm/3d6ZC X8/dxDZ36RMe8tGmjg/bZTHnDba6b6PofxvKwM73wt7ABJhk6rmaAOuot84lPlPCv7sD jtEBFMMF1OruiEQ0rLYrOCqiIWaq/jJxxrXv3d5DRD9UH1dlWtsIqBiJtVz3TmRs+akC 9NSSgkD6pGC8YRdafYcqtWRoOSttQsHCnSoHmZkzLgs3Iflr9QzzesX3lH5aBrUHB9Pq LIUw== 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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=HnIyD7ZfsFb5M5QVYuaukM/afDLaBfCBONV8B1fejvCBzGXr1b+buzdCd89gln5IFG o0GC9TAERvDdNJB4/3HMQgWNaQMYkKWY1wQaoWj5hfdXJBfMlFfxRDVlj0Fuo2kMhtfJ PBUErH7rDkHyVSbIGAVaLv2EXd7Fh5NYDbq6cP1kzU2mOEY7Z50/so6g/B0EPZ2Zt/EC 4IxfiWdji8xbwgBBwTY2LHDB14nPvIpYf1+O9AmyQ5NgVjGEHRhrQW+FgT5D5mhLX9P2 EJ/W3iqMeYPhFr+LYTEVhbPXdSBC0urqQXWepXkGNMaVz/TJqFoV1C2RFwAMj/Jcq7i+ Elyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kqHFE6Mt; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id w11-v6si2615205pfn.212.2018.10.12.17.08.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:20 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kqHFE6Mt; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D03uDA104670; Sat, 13 Oct 2018 00:08:19 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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=kqHFE6MtSWI5Oyu8aJl0GaLuQpX2m1466590GNN6ly7cpfUuVTv3SEo3+TLDM6Fg1mhx Ol6d9sjB6KOzK40YWMQmZFn8WuvXmhCus9cxkf1mmvdnT/aLhjN3fjA0jQHYCBQooo38 ybDmqi+zTphvGclYsgt1dhSVnQNNVPpaTQCTGF1UkeXM/cverhXQuGRgNXth/LJobmYb Al5aJ8vpGnmxQx+ewsgJL+w3OJDU1MQ+QggZC4VOYc6FSjvmq0IEOUjfThj2ClTSSFrw yElDlD8Rqhw5Ib9b4rwv1PV//qsKZDlQpgFVWJCLCm2TpYczeIzdmlvf1tr/sYJHp+IH PQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnprnfmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08DRU021198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:13 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08DFM020092; Sat, 13 Oct 2018 00:08:13 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:12 +0000 Subject: [PATCH 21/25] ocfs2: fix pagecache truncation prior to reflink 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: Fri, 12 Oct 2018 17:08:11 -0700 Message-ID: <153938929138.8361.13789018254018500647.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 Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up to page boundaries. We already wrote all the dirty data so the larger range should be fine. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 851ba3ae7ce8..b9e0418a1974 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4870,8 +4870,9 @@ int ocfs2_reflink_remap_range(struct file *file_in, SINGLE_DEPTH_NESTING); /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + len, PAGE_SIZE) - 1); ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, out_bh, pos_out, len); From patchwork Sat Oct 13 00:08:18 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: 10639691 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 F0FA05CAF for ; Sat, 13 Oct 2018 00:08:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD31B2B096 for ; Sat, 13 Oct 2018 00:08:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D09552B877; Sat, 13 Oct 2018 00:08:26 +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 316312B096 for ; Sat, 13 Oct 2018 00:08:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 606DD6B028C; Fri, 12 Oct 2018 20:08:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5B72C6B028E; Fri, 12 Oct 2018 20:08:24 -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 40AF76B028F; Fri, 12 Oct 2018 20:08:24 -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 F15FA6B028C for ; Fri, 12 Oct 2018 20:08:23 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id ba5-v6so6700397plb.17 for ; Fri, 12 Oct 2018 17:08:23 -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=hIKY9nQiwanIV2qW41QCGIkoUmtm4iR8ODVGIx3BUpQ=; b=K8kK1jX6I336bIiitwELmy6dtITWojrvxGqpG1A/R47X1ZZiQWFWL1cUPed/PHCfSw NrRjR16CzVSApV1c91ofM5UT8EEsMCGE+g7wTm3lDi3aXwrPQsktfaiwyvg4qJCZNJ8w 0DeOHirF9hs4jB/YT9ARVq4u30MKdKPKTxuEoPV2SEFybx3Ymb1OwM99fcTZKUh1+JBS gEEujqhig6p7yoRDevWMbdGZp95UTszY3XblLX7SjdmSwgBvgEc6mYPsW0VvkMOJir+0 gOn39uY72nsHUGTkg2fXxWmrjXEAjgfzxBX8LKnASUfnxQ7taADisMVLarXCdAMC01zS wVtQ== X-Gm-Message-State: ABuFfogH63QWWHGMXPoj0hMiyOtaZR/jP3P2wOxyeM2HdKZiLOQpogTB lhaUbVPbHJupYqioB+gD+nRMgXdWQLCTZ5OavPhIeptTnWygrPqcHum3jnzscAa2kiyV4yfWCac 0fTUnuRPrpCaDocGp5F0/TXTgVMPOVQjpGezlmcE+xOanhAi7kMn2bvL9/ofIO15/pA== X-Received: by 2002:a63:cc51:: with SMTP id q17-v6mr7302674pgi.291.1539389303644; Fri, 12 Oct 2018 17:08:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62u3tedx6unpRvtdF1bCa8mnN7seKFXv1egz3XNTUxmmrbUwB2Xf/tuY+FTAL7wj0OJF4BK X-Received: by 2002:a63:cc51:: with SMTP id q17-v6mr7302631pgi.291.1539389302758; Fri, 12 Oct 2018 17:08:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389302; cv=none; d=google.com; s=arc-20160816; b=dTljJeApMtVj28QjDIgQxWP4JkmkjLbHsejWo+/WQAaJ4eXvV9Axq0hK+efmgIGzYR eNg82y3HaP/RZyK7EpIiVRL5DqMlWG0dM1YUDC9owUxp9YVXXjfI3i6VblsARouYHSbE TRGA8W/kq9It8ZOCJXzsBzMT7U9dU1cbbEU7S50r2HAxPLNWl7LCsfCgl52WitH8GRBc DITZBLNFVFImQnKHxA62lR5TKdNjcRYf16TGN0bZskgtfx3bGiaHHnnOrfoWplvagTMk RiC/hsQK9n4GRfiMDleux7EAmtnmv5hmUrpz1UlDkuufNi2kvNY/0Iaz4t9vKNn6UMfd WRfg== 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=hIKY9nQiwanIV2qW41QCGIkoUmtm4iR8ODVGIx3BUpQ=; b=z/0kMBQ2PPPxVHE1Lz4XfANyc95htBJwQxjAcjYnpX1nP3oINQVtw609HcKD5j7Knm S3FD4HO/gQ6WPzhUaXnAegxSN1jdRAOq4h86e/5nJF92Cxfjt/BR07XWXdV8ol4RqHIE ttb2tl4YnLAveCDcxvjOKIjupvvPrakAekv+iW9cDyj+tE/gMyk7JJXrXZYUOLfigq97 juJvqo4zFsfg6euRDjrGztCLt5sSYwI50/uRrOL4t3NGDiSdUJXdfPjLR4cxiE4elc2f L2jfNPPExnEPZt/Bxk7zK2RRhYIwvyZuE5Xj962xU/cTjSplR0+QiH7DJvj9mmZWnGAc LNGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ceoQ1LPJ; 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 w134-v6si2918841pfd.55.2018.10.12.17.08.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:22 -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=ceoQ1LPJ; 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 w9D04BYe163285; Sat, 13 Oct 2018 00:08:21 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=hIKY9nQiwanIV2qW41QCGIkoUmtm4iR8ODVGIx3BUpQ=; b=ceoQ1LPJ/ELuYN8RPNeSJhGR5K+aHXwAUH9O+ILkxywvD/aett6Qy+U9mNQFOgekKpdI W/WBanLSyjYGmPGflshc8OvVxBQpQ9vaFTnDfQaeg25Um1YkIlmkb5X3NyhnSDCsI3MU dpLXz+ijILrKEE6kmzz3VZr6Q09suQGWc5PiO+1MfN7h0hOfGHk89RYB2cYV+opRyTZK DgGL4TtrxrCKsLiJaSBqcHGTuIjawb9H436lejtxPT4HWc572XKb9KPNI5EhwnuqFRH1 fX8HG6kvo8j59QIPNWekPPBESygWhDnTHF04Muk/AzXKueT0nOHBJ9OBKN+4dJbS5Bbs vA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmj4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:21 +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 w9D08KJM005499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:20 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08KtU020123; Sat, 13 Oct 2018 00:08:20 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:19 +0000 Subject: [PATCH 22/25] ocfs2: support partial clone range and dedupe range 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: Fri, 12 Oct 2018 17:08:18 -0700 Message-ID: <153938929813.8361.16702022670128567518.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 Change the ocfs2 remap code to allow for returning partial results. Signed-off-by: Darrick J. Wong --- fs/ocfs2/file.c | 7 +---- fs/ocfs2/refcounttree.c | 73 ++++++++++++++++++++++++++--------------------- fs/ocfs2/refcounttree.h | 12 ++++---- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index e6ffed70398e..061ae2c4bd4a 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2531,14 +2531,11 @@ static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags) { - int ret; - if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) return -EINVAL; - ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); - return ret < 0 ? ret : len; + return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, remap_flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index b9e0418a1974..4eacdd703874 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4507,14 +4507,14 @@ static int ocfs2_reflink_update_dest(struct inode *dest, } /* Remap the range pos_in:len in s_inode to pos_out:len in t_inode. */ -static int ocfs2_reflink_remap_extent(struct inode *s_inode, - struct buffer_head *s_bh, - loff_t pos_in, - struct inode *t_inode, - struct buffer_head *t_bh, - loff_t pos_out, - loff_t len, - struct ocfs2_cached_dealloc_ctxt *dealloc) +static loff_t ocfs2_reflink_remap_extent(struct inode *s_inode, + struct buffer_head *s_bh, + loff_t pos_in, + struct inode *t_inode, + struct buffer_head *t_bh, + loff_t pos_out, + loff_t len, + struct ocfs2_cached_dealloc_ctxt *dealloc) { struct ocfs2_extent_tree s_et; struct ocfs2_extent_tree t_et; @@ -4522,6 +4522,7 @@ static int ocfs2_reflink_remap_extent(struct inode *s_inode, struct buffer_head *ref_root_bh = NULL; struct ocfs2_refcount_tree *ref_tree; struct ocfs2_super *osb; + loff_t remapped = 0; loff_t pstart, plen; u32 p_cluster, num_clusters, slast, spos, tpos; unsigned int ext_flags; @@ -4605,30 +4606,32 @@ static int ocfs2_reflink_remap_extent(struct inode *s_inode, next_loop: spos += num_clusters; tpos += num_clusters; + remapped += ocfs2_clusters_to_bytes(t_inode->i_sb, + num_clusters); } -out: - return ret; + return remapped; out_unlock_refcount: ocfs2_unlock_refcount_tree(osb, ref_tree, 1); brelse(ref_root_bh); - return ret; +out: + return remapped > 0 ? remapped : ret; } /* Set up refcount tree and remap s_inode to t_inode. */ -static int ocfs2_reflink_remap_blocks(struct inode *s_inode, - struct buffer_head *s_bh, - loff_t pos_in, - struct inode *t_inode, - struct buffer_head *t_bh, - loff_t pos_out, - loff_t len) +static loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode, + struct buffer_head *s_bh, + loff_t pos_in, + struct inode *t_inode, + struct buffer_head *t_bh, + loff_t pos_out, + loff_t len) { struct ocfs2_cached_dealloc_ctxt dealloc; struct ocfs2_super *osb; struct ocfs2_dinode *dis; struct ocfs2_dinode *dit; - int ret; + loff_t ret; osb = OCFS2_SB(s_inode->i_sb); dis = (struct ocfs2_dinode *)s_bh->b_data; @@ -4700,7 +4703,7 @@ static int ocfs2_reflink_remap_blocks(struct inode *s_inode, /* Actually remap extents now. */ ret = ocfs2_reflink_remap_extent(s_inode, s_bh, pos_in, t_inode, t_bh, pos_out, len, &dealloc); - if (ret) { + if (ret < 0) { mlog_errno(ret); goto out; } @@ -4820,18 +4823,19 @@ static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, } /* Link a range of blocks from one file to another. */ -int ocfs2_reflink_remap_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - loff_t len, - unsigned int remap_flags) +loff_t ocfs2_reflink_remap_range(struct file *file_in, + loff_t pos_in, + 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); struct ocfs2_super *osb = OCFS2_SB(inode_in->i_sb); struct buffer_head *in_bh = NULL, *out_bh = NULL; bool same_inode = (inode_in == inode_out); + loff_t remapped = 0; ssize_t ret; if (!ocfs2_refcount_tree(osb)) @@ -4855,6 +4859,11 @@ int ocfs2_reflink_remap_range(struct file *file_in, if (ret <= 0) goto out_unlock; + if (len == 0) { + ret = 0; + goto out_unlock; + } + /* * Update inode timestamps and remove security privileges before we * take the ilock. @@ -4874,12 +4883,13 @@ int ocfs2_reflink_remap_range(struct file *file_in, round_down(pos_out, PAGE_SIZE), round_up(pos_out + len, PAGE_SIZE) - 1); - ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, - out_bh, pos_out, len); + remapped = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, + inode_out, out_bh, pos_out, len); up_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) up_write(&OCFS2_I(inode_out)->ip_alloc_sem); - if (ret) { + if (remapped < 0) { + ret = remapped; mlog_errno(ret); goto out_unlock; } @@ -4897,10 +4907,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, goto out_unlock; } - ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); - return 0; - out_unlock: ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); - return ret; + return remapped > 0 ? remapped : ret; } diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index eb65c1d0843c..9e64daba395d 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -115,11 +115,11 @@ int ocfs2_reflink_ioctl(struct inode *inode, const char __user *oldname, const char __user *newname, bool preserve); -int ocfs2_reflink_remap_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - loff_t len, - unsigned int remap_flags); +loff_t ocfs2_reflink_remap_range(struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + loff_t len, + unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ From patchwork Sat Oct 13 00:08:25 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: 10639713 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 10E441869 for ; Sat, 13 Oct 2018 00:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26A22B096 for ; Sat, 13 Oct 2018 00:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E697A2B82C; Sat, 13 Oct 2018 00:08:36 +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 86B052B096 for ; Sat, 13 Oct 2018 00:08:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 210DA6B028E; Fri, 12 Oct 2018 20:08:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C1676B0290; Fri, 12 Oct 2018 20:08:35 -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 08DD16B0291; Fri, 12 Oct 2018 20:08:35 -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 BEB0E6B028E for ; Fri, 12 Oct 2018 20:08:34 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id g72-v6so13616074pfk.9 for ; Fri, 12 Oct 2018 17:08:34 -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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=EVWYtuv/BBg6Bp7sBDxZqnJB0VfVFuKXWy6el9bSjejDr4hv0GPZIjbMlHzoJhlnWu yM6Dig8Ae/TFpWL5SwkI3JlyzwJYKK/ceCLVQF8sa08cxgObKw+sC9cgiIJmUkxzaJ9Y J80B5leqO8ZQ4kXxTuDD9Bkf8qLBUfOZLeOL09szS4MH/Sywfc+TM+7c/C0RpaSlu0S+ t1/Q3HDyLY39lHWGSJsRCbTpZdkMuNoiMRydMrqVL6rYT7w5FJ0G0BS2Ho0RPyO/iN2b osf8Iv0BrPNXUp8WVzTazdGuhCFx7PAp2bE6JwjS1VmFQigCcehsq2ml9eNt5Zlu90Ou bN7Q== X-Gm-Message-State: ABuFfohVGisaBc4xXz4r+x4wvLpwZ99H4Ceue1+9H3EdVBhSXqi/CTe1 z16LoMnRB/GY+rhaSv5rsSaSV4U0FHAHkL31CYs5eGDiG23dPwkjzWcHOrkvrEBI3U6hmLzpxiz lN2j/V0CLr7wmjU3jrumi30tPLfHXLyOz3YQHIyHSx3TlrAwAhMb3HyzyORColMSWlA== X-Received: by 2002:a63:9d01:: with SMTP id i1-v6mr6923968pgd.98.1539389314403; Fri, 12 Oct 2018 17:08:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JRt8xTEfKy2GLVqfr+9L6GIhBHdgkAu9YiAzvNutusxNmjoqf4PRZ4gmHy4lOiEg+1MCJ X-Received: by 2002:a63:9d01:: with SMTP id i1-v6mr6923943pgd.98.1539389313846; Fri, 12 Oct 2018 17:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389313; cv=none; d=google.com; s=arc-20160816; b=qKBd6KOMKt11Hxf0GHS05fCwd/5KY8iGI66BCinBuzeMZdH68QH3q5X9lCu6eFhvku DXL+Terbyk8M+zejUta1wVK7xC8UJJr83yQlpgIr6xLppUAIXPQHuST89dWCydiyWATf 8ERJRt7k8ujsoybZFrReTfr9h3FlXFHkqpb1UFISmulxjega1m9ov2Xry6feoLsPLqGH Tx3cunUaKDeDOSKqwMYIUktJ1r1MluzNHPNM/qJDoWGMTCEg4MxJNzp5Zts6fXpr1FD2 QFIm6jKeWo+lh86T/5ny1EmfBpmG+6AcEqyl0LGNbB19aNGsNOKrqy3s1w6cnmpqTJHj Ao5w== 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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=aPgw9AT7LMZGyFPCM7YRBPSgXLBOLJYZzb2RObPWlSCnKFIH5IHyb5k02hz3OwvrS4 QXAqtu7u1pvyntxuqgwFX9bBgd5CDa0qACPqc2rIXLt/AVk6w84z2t5M51DIvh/D2w3Z xw1TGX5B7cr/H9SmmpBYWtc8ZaSjDgHEEnR/721JhF7fSU5X0l3LUeaqsT4Nh7T21AMP bRBMJBK3RasBTBMNIAeMKX2tCmVCa8rZF9aoDctMYTbUEKfNJmvW6pfQ5wD1BE+LUgVv PqafBtdWBHTVvgxoAlZfUYRtrPvMuioifxSO7iusHmdXsKiRsv6mz2ftAXhWU+3SBnwV jm+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=i8lnEwm+; 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 b137-v6si3026869pga.80.2018.10.12.17.08.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:33 -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=i8lnEwm+; 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 w9D03wVN163194; Sat, 13 Oct 2018 00:08:33 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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=i8lnEwm+xjrR9xsODT2fvwWNOxhhnok62LalI7bBvl8Kd2KmY5ZV3Z/HqNEDEVQBoOxh FKbXdSwEZ1WbhRGK0Sjpn0YHFKaUeizJWl/WCTptbnSDwBP5lFEqqaXk9MGy+PA2Gd/y Ei+YlavIqcR2hbwWcVHejqzcpn7B8Hzj73m01mE8lYhsnHR+k+Kwqn8KjGlK6u+ZPEFQ hs5+5JE80woyyAhjnn9sDdHpBjq/JEZokO6oiMo7HaSQ1H8hkYBSOCxCNkI1aUkxN4+Z FZHL2q2FsDGRtJlvwDw6RIWNFqas0zZ7E/exIJalw9Cbxjue6pBBZHEUgLs5Evsk0XLq ZA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:32 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08Rbc021572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:27 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9D08RZM018636; Sat, 13 Oct 2018 00:08:27 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:26 +0000 Subject: [PATCH 23/25] xfs: fix pagecache truncation prior to reflink 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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:08:25 -0700 Message-ID: <153938930501.8361.16976146684396404822.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=925 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 Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up to page boundaries. We already wrote all the dirty data so the larger range shouldn't be a problem. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index b24a2a1c4db1..e1592e751cc2 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1370,8 +1370,9 @@ xfs_reflink_remap_prep( goto out_unlock; /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + *len) - 1); + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + *len, PAGE_SIZE) - 1); /* * Update inode timestamps and remove security privileges before we From patchwork Sat Oct 13 00:08:32 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: 10639723 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 D40951508 for ; Sat, 13 Oct 2018 00:08:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BBC192B7F4 for ; Sat, 13 Oct 2018 00:08:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B00B12B877; Sat, 13 Oct 2018 00:08:40 +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 28F3A2B7F4 for ; Sat, 13 Oct 2018 00:08:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08E056B0290; Fri, 12 Oct 2018 20:08:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 03E476B0292; Fri, 12 Oct 2018 20:08:37 -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 DF4DA6B0293; Fri, 12 Oct 2018 20:08:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id A12C36B0290 for ; Fri, 12 Oct 2018 20:08:37 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id r72-v6so9473875pfj.3 for ; Fri, 12 Oct 2018 17:08:37 -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=j1f7F7pQmBhjlVszrIyTzR7x7TmBVWaeEtlT+nNj2qg=; b=A4Sz6CDYJYWnv+gLo9zb+CFV7PA2ei4gGJRPM2u5Adc1N9S7W4ATPEr4/d1NPmLq3o T6Van7UqF3yW7h0lpTYg7I+4E1HWA7sePaBsndJ4GwF8J4ZV6y8Vm1OQ66QyXCuUejnu EAdzpdpsd5WA0cKuMpbahPPoObfBpIQC+eZcSiOAxkbNwJHXnogiKxJ2aiDr9QgUr84Z NfMmAOrlxNGU+W8PWJ+UU9FFS9AbgvGUgurr6PEV+OKSeTOmZIR+TZmxc8hxuzbvwKaz uqd8WaFKjhlfVXTHCc2I6fs865VXF4vJ9Vcp6N07awpaYEvP0sy/FIG2eVNDxFxBS8Hb x8yA== X-Gm-Message-State: ABuFfohgsPLcvHBnHBjqdzCYXswILqMsVoS7zeGe+xtQcBFTgbhCN2Q2 /DYImW7VyMagSnfyrGTBQLr0DcyiWjxbLN2YvgGyCdHR9YL/7TaIfXh9ZTJ43Qi7zebtJqEpZof 2e4SCqYkvRQyoJOFa/VPHXwrSByFt+CZeWZEdm/z9jFCa/QLB7S3JzG9Qpqsne2ef+A== X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr8396579pfu.134.1539389317336; Fri, 12 Oct 2018 17:08:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dSPw5EsIUJL7jVolfrl+HsfVLE5OMGy1Hi3rGLZotF6V8Da2cMurHgvHDl7lcHf3eAsA6 X-Received: by 2002:a62:2e02:: with SMTP id u2-v6mr8396499pfu.134.1539389315959; Fri, 12 Oct 2018 17:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389315; cv=none; d=google.com; s=arc-20160816; b=hrL1XBAwzNLngRL5nt0CD2h3w2h3kvmbyECDJGmPGmM4VLAgnsysdbxYEIryb5tYRL 2vRksamEgaj5jN98mMv2E2FOHO7cNLvT+RGaxzA5QvXUV9Vey0fEgyr5Q05iLSZDNbR2 dnSgxdC0UXFgb2FK5ZbBICQOSq2jKXvu0CfC3a7pgCK8DUVRYDdwd/1N8NGWc9xexkl1 zyJYYyQ6IsSCARSW+aNoBOKcJVVrOHccn5Mqp9dWXYwC6rqX/7Lc4X/ERNqkm7gON+R1 O6ep8gs5Lt9wCKz2Tg80Xt4hBQ5kMJjmnUtwX5XgRnoLqzSe3yusMf8JfJF9gijvDL9B yPJg== 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=j1f7F7pQmBhjlVszrIyTzR7x7TmBVWaeEtlT+nNj2qg=; b=J2ICqUhk93kfRg7Y7c8JHUnQr3iYD4R43wZpH5rBrRtN/ncd5RhVcHqd9xEicE1WDD vCWRkvlv2NWZy3CLfe56uSVVFX7yisCsuEuf/oJfX6KP5uRACFo8UCT+isBv/+H+a3Sx +DIOoxT9g5zgG0EhYKI8yd8ToMz8pPVgv2o/PaOazG/Pc75CKgsGN9+uogUt02zU1s6Y vJ+d4Y+KvwwM5CT4l3Bu/XhBxY5Ck/zIrXhdjNMZMIBQ0M27noRIGkosQBy31lwz3lQ6 lxnI8B116NbiY2nq1y6o4QaFuAS7qOkAGNLEuFtuGfQcFeKfj11Yx6oeVVskKdEk74CJ y7dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sTyoOz5D; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id d7-v6si2465858plo.418.2018.10.12.17.08.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sTyoOz5D; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9D03xtF104705; Sat, 13 Oct 2018 00:08:35 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=j1f7F7pQmBhjlVszrIyTzR7x7TmBVWaeEtlT+nNj2qg=; b=sTyoOz5DFRwE8hHpFLjJAntrQ/eP82020PpQF3A1xT0QhtpbxfK/IwemWapeHNbPqbdy w+MVAhh3wpTLfewOos41Q9+83VHaLYZCG31DaxtdczGPN4Y/YMNRLyUt0MOF1fCmdncq 5qO6QKeAXCyUcn1EROOqX1jMZfo6ljoKQDQ3W7ibgjgdjScKEku0Ns+WvDUWgQWme78J hJtToPlQ8RPOUsMR+dd8QKZ61bAPhsUqWtLuu1KCwfBusdMeW9tGD7idviFM45f+sE6C 6PG+J/VTGSv/31l3EV3lhLlQFzoV+Qcg5RPKXw719XP4Lqi9PQCgrG2n2ae4FMDDCQlT +A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnprnfnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:35 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08YjH027225 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:34 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08YdJ020284; Sat, 13 Oct 2018 00:08:34 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:33 +0000 Subject: [PATCH 24/25] xfs: support returning partial reflink results 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: Fri, 12 Oct 2018 17:08:32 -0700 Message-ID: <153938931226.8361.7365948775364411156.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=848 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 Back when the XFS reflink code only supported clone_file_range, we were only able to return zero or negative error codes to userspace. However, now that copy_file_range (which returns bytes copied) can use XFS' clone_file_range, we have the opportunity to return partial results. For example, if userspace sends a 1GB clone request and we run out of space halfway through, we at least can tell userspace that we completed 512M of that request like a regular write. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 5 +---- fs/xfs/xfs_reflink.c | 20 +++++++++++++++----- fs/xfs/xfs_reflink.h | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index bc9e94bcb7a3..b2b15b8dc4a1 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -928,14 +928,11 @@ xfs_file_remap_range( loff_t len, unsigned int remap_flags) { - int ret; - if (!remap_check_flags(remap_flags, RFR_SAME_DATA)) return -EINVAL; - ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, remap_flags); - return ret < 0 ? ret : len; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index e1592e751cc2..66a8ddb9c058 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1123,6 +1123,7 @@ xfs_reflink_remap_blocks( struct xfs_inode *dest, xfs_fileoff_t destoff, xfs_filblks_t len, + xfs_filblks_t *remapped_len, xfs_off_t new_isize) { struct xfs_bmbt_irec imap; @@ -1130,6 +1131,7 @@ xfs_reflink_remap_blocks( int error = 0; xfs_filblks_t range_len; + *remapped_len = 0; /* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */ while (len) { uint lock_mode; @@ -1168,6 +1170,7 @@ xfs_reflink_remap_blocks( srcoff += range_len; destoff += range_len; len -= range_len; + *remapped_len += range_len; } return 0; @@ -1391,7 +1394,7 @@ xfs_reflink_remap_prep( /* * Link a range of blocks from one file to another. */ -int +loff_t xfs_reflink_remap_range( struct file *file_in, loff_t pos_in, @@ -1406,9 +1409,10 @@ xfs_reflink_remap_range( struct xfs_inode *dest = XFS_I(inode_out); struct xfs_mount *mp = src->i_mount; xfs_fileoff_t sfsbno, dfsbno; - xfs_filblks_t fsblen; + xfs_filblks_t fsblen, remappedfsb = 0; + loff_t remapped_bytes = 0; xfs_extlen_t cowextsize; - ssize_t ret; + int ret; if (!xfs_sb_version_hasreflink(&mp->m_sb)) return -EOPNOTSUPP; @@ -1424,11 +1428,17 @@ xfs_reflink_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); + if (len == 0) { + ret = 0; + goto out_unlock; + } + dfsbno = XFS_B_TO_FSBT(mp, pos_out); sfsbno = XFS_B_TO_FSBT(mp, pos_in); fsblen = XFS_B_TO_FSB(mp, len); ret = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen, - pos_out + len); + &remappedfsb, pos_out + len); + remapped_bytes = min_t(int64_t, len, XFS_FSB_TO_B(mp, remappedfsb)); if (ret) goto out_unlock; @@ -1451,7 +1461,7 @@ xfs_reflink_remap_range( xfs_reflink_remap_unlock(file_in, file_out); if (ret) trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); - return ret; + return remapped_bytes > 0 ? remapped_bytes : ret; } /* diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index c3c46c276fe1..cbc26ff79a8f 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -27,7 +27,7 @@ extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset, 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, +extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, From patchwork Sat Oct 13 00:08:39 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: 10639735 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 74E181508 for ; Sat, 13 Oct 2018 00:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 635712B7F4 for ; Sat, 13 Oct 2018 00:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 578062B8A4; Sat, 13 Oct 2018 00:08:46 +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 E88C42B7F4 for ; Sat, 13 Oct 2018 00:08:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F322A6B0292; Fri, 12 Oct 2018 20:08:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F06746B0294; Fri, 12 Oct 2018 20:08:43 -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 D7F5E6B0295; Fri, 12 Oct 2018 20:08:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 9ACBF6B0292 for ; Fri, 12 Oct 2018 20:08:43 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id i189-v6so10531423pge.6 for ; Fri, 12 Oct 2018 17:08:43 -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=0eMENz0xNhmHfEQz6xYs7euXYnzzeWKWI3aBWCtEoDg=; b=g9F2tdEQLoZzbhAWt28yBLRwHJKUTYRjIDXBVgoksjh+nQ24q2W2xJiVwqCIZz9h6d iMmHcyzzTLYGrSMqDsLTlmI9nc63xW8Zm4sH2j4cFvhM2ZR2yFnchdvPsQEn6rnFZsvO j3706sZAfJiEntDCAEItg6gV7BpiqdW0FG8/Wbq220hU+9dTUU2xfzD1hDDE0TzWw7JO 2aM3S0Ps39Spr00NRADjg6wdyb88EMN36e2jcToXUVMks+s29mWp4JHg2UvkYs2zeffL h1l+x0zKEcguNo9LR7JhDe63Ic1y6KslBNSh+yVfMKCAGzUpVYSHt9bfInZSh6G5Ed2O JK1w== X-Gm-Message-State: ABuFfoj7Lo9xYFMyAt9LITFehvKVqEr/RXgEGukg+RBtbmVAUxEbD+Up dVDmWKbQFkdnMSpID7I0joNvH9qK/bgKfoVfNVTTkwB3alX6wtZlxHWUrFpGgljBuigBch+2x9d INGsQYsLD2XMA1qr+BC4at+04hou82/2oVvzEHfjWTLPS8yqUHvf9SYPFbXV+v1ep4Q== X-Received: by 2002:a63:ec4b:: with SMTP id r11-v6mr7316989pgj.295.1539389323313; Fri, 12 Oct 2018 17:08:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV62vGIgqs+v//KGKkgb5iqyTFQdjey0wknxGQswVM2xza3DtldtNZN341QLBTMlrZMsMcje8 X-Received: by 2002:a63:ec4b:: with SMTP id r11-v6mr7316964pgj.295.1539389322733; Fri, 12 Oct 2018 17:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389322; cv=none; d=google.com; s=arc-20160816; b=hEGDFge2nu1F3IrbVx9RIEeX6xw5wDec/lKHHjFx83edHgN0ABoOCYpUcodIsXpjmZ KLk4BDWDLrwIw0jdUQWBpeY3JuBnN/SceLUSzmGKVmdydLdlawOgKEbhNtGnK/D7DAy5 eq7yg0eVvrChfElNHrp6LtinSRusFvd90q85YUX/Pu4ik68E3DG4KWTaeofOU8y3bYkq k0DREwG6hfvM4BGLnsgSoZDpcXO8vFY8Y9aILjIcXwggVG6c7tJLK74OEvV9+d+MPXB8 fC2/y8oTW8EJ1kqoQGeg3+3MFcRTFiV0avs7hv2Jpc0vmm64JiCWm60EXsO61PjroZZL Zkbw== 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=0eMENz0xNhmHfEQz6xYs7euXYnzzeWKWI3aBWCtEoDg=; b=lo0SuFHsGE8yp2BW1gKbw5giWRHUdIDEGiRVMQI3/PmoKaF4M9kIQCbfsmHkPBXXGk fwB/ADAlHbs3pINaHAogwgLlCLQaEUdIkDUNV8ku7rJI+Ouh7dP4vkeajxqfaYPE+BOR s8y8k9gqvF5xgUfyXzAAh7yI0//5m1jUPzMcbz8DyVeftdhlT61WfC/BO2YgK8iW6ZEM nauaT9VzabiNJ11rp3uE0H84Vkd+5dTjtn2/i2qwSsDm8T2mdaJOg4VLVzoMwAN6C4ab kSGACbA0eMJtC9Z8+YkqBUaKESXvP/oE3inlB+3L0g7Mgja9deO9hIhkcn6MkvISF8B7 tqhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=QLAlO+oU; 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 r15-v6si2833051pgh.88.2018.10.12.17.08.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:42 -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=QLAlO+oU; 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 w9D03xw9143588; Sat, 13 Oct 2018 00:08:42 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=0eMENz0xNhmHfEQz6xYs7euXYnzzeWKWI3aBWCtEoDg=; b=QLAlO+oUAaMXeV7DCIZKiwC/Y8nT7kt+X2XFrc2aMWjchKzJMosE+wqRl6CyqyD8POb9 S5i9J6lbYBWP2GjfF7EAhBTJzmljWmK/QVyXKT2Sw25GhOq/yfIEk768cf+1PlxaO+Wt QwDyxx/BNzCcM01YJV0wNLyPpsQGu8S5b8ehSH09yQ1FG9mrnehdQ2td8Y1fz505f0s+ VRI44pPC4mc5C8mLKf7ILkaylwo4j7H0KKdPwQA6c9AMSCQ1++zoONmNlIkrFS6VpmD8 ak5wmxNU8t2G76GfKSNd4vdTz6y3ahgqkzwCDsmhU79v6UFNsvSnHXy8mdSL2F9a6Yp2 cw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfudq2g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:42 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08eBa027485 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:41 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9D08eqG020410; Sat, 13 Oct 2018 00:08:40 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:40 +0000 Subject: [PATCH 25/25] xfs: remove redundant remap partial EOF block checks 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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:08:39 -0700 Message-ID: <153938931898.8361.12558032149746338745.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 Now that we've moved the partial EOF block checks to the VFS helpers, we can remove the redundantn functionality from XFS. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 66a8ddb9c058..709735880efb 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1307,8 +1307,6 @@ xfs_reflink_remap_prep( 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; /* Lock both files against IO */ @@ -1336,24 +1334,6 @@ xfs_reflink_remap_prep( if (ret <= 0) goto out_unlock; - /* - * If the dedupe data matches, chop off the partial EOF block - * from the source file so we don't try to dedupe the partial - * EOF block. - */ - if (is_dedupe) { - *len &= ~blkmask; - } else if (*len & blkmask) { - /* - * The user is attempting to share a partial EOF block, - * if it's inside the destination EOF then reject it. - */ - if (pos_out + *len < i_size_read(inode_out)) { - ret = -EINVAL; - goto out_unlock; - } - } - /* Attach dquots to dest inode before changing block map */ ret = xfs_qm_dqattach(dest); if (ret)