From patchwork Thu Oct 11 04:12: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: 10635705 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 5DE0D933 for ; Thu, 11 Oct 2018 04:12:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41B842A63B for ; Thu, 11 Oct 2018 04:12:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 321CA2A63D; Thu, 11 Oct 2018 04:12:35 +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 C86B42A61E for ; Thu, 11 Oct 2018 04:12:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF7766B026D; Thu, 11 Oct 2018 00:12:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EA7016B026E; Thu, 11 Oct 2018 00:12:33 -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 D6F346B026F; Thu, 11 Oct 2018 00:12:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 96AB26B026D for ; Thu, 11 Oct 2018 00:12:33 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id p89-v6so6684641pfj.12 for ; Wed, 10 Oct 2018 21:12:33 -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=ZadgFER+Ti0t3eVadlM5lMUfqb6Yf1z3Jkv4eD79Mn/BJSHB/JlVVE6mZ5dYeTd6j2 IsanOjaW86MjyC3WE0ER+onNCQB1KCm3Sa2Y0vfq0PcRRgEfnnTBeTby56LNoWoIXRDy gdZx03X2JuPLk+eL5VfhHBDJ4za22Z3oR3Qf+qVTsUYxLIyIYicKsKo2q8HVMqxU26mh N8rr8HTYIpUJxVMAyxvygSO2t3CxoiKAxqpq6Ujr/AKbtWFySsU1M5AJrGJbypSupKbG ASmD7DTiJq0k7EzoGQyguIqyLFjxu8l0W88z9iwzifePBdO5/LuoBU1vWIlOvCxsKESo Mwmw== X-Gm-Message-State: ABuFfojEJIPqqlQKjnGXNnoiq4UFzLelWIPDh7nDV9vw3ymfO5e7dgKX DyBwAh4Bcj4MX8vlAiMOVfY3GUfMHvbZcGqvXw5OEGZ8h6qgbBAHKdMKerwxzpIPur0uV3H0BjX qu/iy601RYy+UXWdgZL5RAhYGStqF+Pb6zt1gTM3W843gNhBkbzO6DcC7cYcGGY1DAQ== X-Received: by 2002:a62:7788:: with SMTP id s130-v6mr37456759pfc.189.1539231153302; Wed, 10 Oct 2018 21:12:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV62bGpXBObEy6rhrqdZGWftZjos2thQEBK1oqks12AM1gv+4WmPj+M5qRlYYeIoaQJO/udxm X-Received: by 2002:a62:7788:: with SMTP id s130-v6mr37456725pfc.189.1539231152621; Wed, 10 Oct 2018 21:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231152; cv=none; d=google.com; s=arc-20160816; b=RTmS8PKwgWUlTT/GYv5JACr4167c0reQDpOXWmFIwFHHcfRyjQKbns0yLRDTUqSJft yE/bFRq8Tv/fIaGu1lSuxct7t2W+9oZj/K+rlKTr6JJ//G93Kxl29Ma+Uxbq6W8NJ5Wx VSLF5Uv/kdFJOXfOvroZ06lwN+dg2rsQm/degqoi6tuk6z8WJfCp+URC4tc6vFmsCym0 x3xCzuvqITbyIcwDh2klywnYniqMgecfgfQI0muR5E7gZb8TxMzur4boS4PAKbvMhoCY e0aMCJxWBrFqpKGT8PXo1N4mZyQ/U2W6TyWogAlRXO62NwMVo2D6Bxq8UScKjSirQ4Sc LXwA== 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=HSrAbh9rD2IEGsrhQg3qptpm1xC0G746AsHwGu3asY6ra9qzTqHfQ1D1Lr7A0bs0ak 7RiKi8SPsKHSIeoH4CU4KsxPstQDHP2GfIa7f/APSXk9YMcJz9Bknn61xz+yLx6zuooa dXK2WRL+mHc/HdNdJ+qs6DNxAX8+yYVG8cLkRO93CvZ+IsB4R2QphHv4Oih3H0nE0hs5 7RtKUtpucLutT2VslEcazYTbZTdq2JN15Uvk0COTc8m0XiDCwbN0yZmgIZHVOgCdWxv/ YzKLw49OWZuk1HUsk4mdwU29JcOQKqECalpp3OInD0nL3caHNBVcmUZG4RR4t2QjI4Io uR+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gGVBr+xu; 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 d13-v6si27466958pfo.108.2018.10.10.21.12.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:12:32 -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=gGVBr+xu; 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 w9B496bi191359; Thu, 11 Oct 2018 04:12: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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=gGVBr+xuueHi48YgdV6/3br4ddfeOXNKO8kq7ROcMqMl1L6Jc71ruQAzdq5jlWhYuKO1 uRHGo0YxLVvT6vUbcJGAqqo4Zzp5zyyJfRVKs8696MKrKyZmj9R7io26NhW105Kb7/q5 BisUhnwBZh7C86kt2zJXBgJuvD2PtmsNOY6qBaIWiah/7DN8hyHkQoCPNX0JozKTL5xD +ybkKKxQZl52eCddUtVBw7HHL5F2zTIDIv9Z2ZJAfhpKJI1v9iIkj84bEJ39QS0eLpPC LpmA3xM6UgzZER+I0TPki2412rZ0Fz0u7o4Uec/7uvMVlCT5eK0OvCDc/NSP6dJqCrLY QA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mxnpr98u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4CP18010556 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:25 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4CPXa007856; Thu, 11 Oct 2018 04:12:25 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:12:25 +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: Wed, 10 Oct 2018 21:12:23 -0700 Message-ID: <153923114361.5546.11838344265359068530.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 Thu Oct 11 04:12: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: 10635723 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 4564869B6 for ; Thu, 11 Oct 2018 04:12:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DCC82A612 for ; Thu, 11 Oct 2018 04:12:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 121372A651; Thu, 11 Oct 2018 04:12:45 +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=unavailable 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 B1D9E2A612 for ; Thu, 11 Oct 2018 04:12:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 978F56B026F; Thu, 11 Oct 2018 00:12:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9296A6B0270; Thu, 11 Oct 2018 00:12:40 -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 7CB076B0271; Thu, 11 Oct 2018 00:12:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 3E2D06B026F for ; Thu, 11 Oct 2018 00:12:40 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id r67-v6so6725572pfd.21 for ; Wed, 10 Oct 2018 21:12:40 -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=6YeYac0pIbKXg9gOOS19st5IEZX9NQyrMy4NIgyH78Q=; b=DYl8I8mKXHjjHBGeEp0csZcOzVjxDoapxQIAvsHsEdDzvXEcl9Uuq6rleBh8c9M9ZY iOrooMhh3RxV9npEXnYxBmzybejufOM3zv129ctXdLNErSjxyuHbtucV/cB3ZaamT0nS iwGWtRw3TgQaozp3lLJZPPuQQ/N8sUDQ078pZeOeMHqTNIV2v+xNmfNZYw/V1G5tQ1FD 3K3ujNu5YUtRUVIsxq1Bt05nG40o4tl2SEuhwqfPCkscpvnju2As1tt2WpcaYKrClrGf dhGeHrukwW/bqd259GmpHZ672MIdul/qf/RmgYxfM8Kt0drrjBEIV3ww1yI0TCTko3V+ xCWw== X-Gm-Message-State: ABuFfoivX/6S/mifN2QL3Wdp8p7sjN4j9ze21+UMonUoi1gZBVIw481i TJglPW8ot5Ipsgp7gAueBM8h02yIXAZg7AtyCdFYrBb0d2ltO24XrWsQlw0o+IkwMvcQtlXpnRi tR/1lMgwvrI3/gBhizf5W/96X282ZGJWUjxWaXzp6FCKUcBp3Vk8GyTKVno4UvDKfpQ== X-Received: by 2002:a17:902:7c11:: with SMTP id x17-v6mr1960635pll.1.1539231159937; Wed, 10 Oct 2018 21:12:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV633y30usTeGukYGHhCOO5UcJJANOnRRfHzBGVfH+fUilZjTGD9J354LHHWGqEMFK9QKtLMq X-Received: by 2002:a17:902:7c11:: with SMTP id x17-v6mr1960616pll.1.1539231159313; Wed, 10 Oct 2018 21:12:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231159; cv=none; d=google.com; s=arc-20160816; b=bwQoLHwwT49Lm/CSAO2BHOmIw9NHKPVwXYhSI+9LOEBN1Pd3SMqGyABy2y01/YhIB0 llSrvjcUk78gv85TjxzfLzR9JYQ1k0L2Sjp1bilmQx9mLIjA8Ou8E0ir2RNVcPGma2Sz R2MB2otUdayX8SgJ+93yKlRdD17IpniiG1/JZXCayVJe7pR4UQMeOfvoEcEW92YG12AT lhsuLPXmKz67tMdW/rbtws2vw8LWHnZKTubrxRtonafBNgZibtMweQWpR4oYcZGqYMOA K2/V1yx+RB5cB/wYHvk79FYo9g0gaZm/dTVTIUpxqKQ33YnSCfyoB/gTNwBGiO4mI4jN PbNA== 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=6YeYac0pIbKXg9gOOS19st5IEZX9NQyrMy4NIgyH78Q=; b=M41PAiJfBst5XE1Jk/C/XtoONvCjm5vUEitNslT0xlWUYQ54v1aFdqPYL69hqwhQjA nsKC6RScchc4Aim7fZpKtC1FEMfkDj3Y7fDNKfXtQ3EAMQNqTsvB1NbpEFcgQIapxIxi Sr1mv28ajsdTdF9e/hwm0oP74Y/InP93StaV9D+MehXBb9BGeLdP7HAgHbXZsV8K+eJG K45bNWq9eI03AuZ9JbJuhg5x9/cqUlOYPBuPQ9PA0xz+bh+d8Ec7Ms3StJpgWKaf1wFG KaGiMuDuxXK+v6G7wlxkfI4HX2mJmBD1vAxEO10g9TnVMVce9CW+Oyj2vZz47gjSTNjF vThA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="vO/4IHrn"; 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 d38-v6si26938748pla.422.2018.10.10.21.12.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:12:39 -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="vO/4IHrn"; 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 w9B49FHM033615; Thu, 11 Oct 2018 04:12:38 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=6YeYac0pIbKXg9gOOS19st5IEZX9NQyrMy4NIgyH78Q=; b=vO/4IHrnOoofZJCBptwjZ9Qo55D++9a/1ctvSo2CafhS7XIjC899jD00pPhwkk7Cn73N MrsqqL1ga40tQ4061uTd7P2Kv85I5dg3xmV+PMlkM55i0t6xqFRj+ljBTfq2hv9PI/fk /uhDShjNh7dpoTvVLvKw+d2HrFm3AB/HCsmP47t07ObRH4w7H16u1B7cfPSkQBNPs5hy Wqnp16Qxz8eRJp8xC4m+m7sroiwl6CoMiJxVfP0zlY2v/aev7JZ7CzBNPjUhbNDfSo7R ZKq7aAeHkPuUxpdgicCto0AmcBqfL5PnoTlHAyPXLFm5bcYghxA+IBAfTcLhJ37GoPvk Eg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfu1fuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:38 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4CZsB016580 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:35 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4CYrn029468; Thu, 11 Oct 2018 04:12:34 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:12:34 +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, ocfs2-devel@oss.oracle.com Date: Wed, 10 Oct 2018 21:12:30 -0700 Message-ID: <153923115041.5546.14464512857556875980.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=739 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110039 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 Thu Oct 11 04:12: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: 10635729 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 BB0C314DB for ; Thu, 11 Oct 2018 04:12:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E5E52A612 for ; Thu, 11 Oct 2018 04:12:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 915292A620; Thu, 11 Oct 2018 04:12: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 B5F822A612 for ; Thu, 11 Oct 2018 04:12:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C39BD6B0271; Thu, 11 Oct 2018 00:12:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BE71A6B0272; Thu, 11 Oct 2018 00:12: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 A89D66B0273; Thu, 11 Oct 2018 00:12:52 -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 67E0F6B0271 for ; Thu, 11 Oct 2018 00:12:52 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id v138-v6so5128025pgb.7 for ; Wed, 10 Oct 2018 21:12:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=ZrwUJGpl1HAEVpq1b2P3ZCvkT50bs3Go5cWZHsZUl3PZtIxR9RANJ48MRGD+2ZnWoz kn3UgQKREscYLedHMUO3E9I1zg4YZzlf5spv5NnBFnXHrpDmFeIgGVgNhbsmX88XzvAj fr3V6pZwiA2tsXiPb2tUlXFkYDu/HV50Asw46yTbQ3N6b9NKn1UDypa5EZ64M1dn59lK FQnOX9UZ2zAKcaRM4mIb6MAEF4eq3EWDFfji4poE/14VLEP8di5uPfLoIXkGq2kibFfV mXq+IMu/r/2EhuidZoRU5Y4RLUEJuI4uD+pcBGG6WK6nTJJpWvAb9/RY6s+SEGfS3GNq FxNw== X-Gm-Message-State: ABuFfoj+gQSctRFSVAPiyeuxZXCR9b4J7H746vVSePo9TQmF00vQRaxK KU5ijsDm+yw7DzU80xeMrH1Z3D/BSZe49BmsBM/s6j7xi7jrNw8/SCqOwaT6iRalMStb3k8ZWUV OdBT287JH30oc2b31XNmNvNsy0lYsXW6Sq4/oLgFU1V081U9llhUYA+9fC+VgPr3A2w== X-Received: by 2002:a17:902:b943:: with SMTP id h3-v6mr851290pls.5.1539231172078; Wed, 10 Oct 2018 21:12:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV63ZoclxliXIIl3YsT3oriRpkJcC6XVSiSSvJO56T7jCLfezYNyor1csYJPisZPm1YGMlOTb X-Received: by 2002:a17:902:b943:: with SMTP id h3-v6mr851245pls.5.1539231171083; Wed, 10 Oct 2018 21:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231171; cv=none; d=google.com; s=arc-20160816; b=Txs+tG1DnkxPZInhZW/IpBQ2ATjF7PPxUgHb+zlcPXjPaQydJjij6p1q5LqocLfRzZ lOarMUMILvfDUsvCRCnrsJcT0DQCYNPA51/ECM1sxejgMIv8Mjqbw7RY7pwRz8ceASK0 EeBwgudgi2+/3YnC/8rxQ/NmSWiV/h6OBhYDrg/sSwnNP4OW8JR3rEeJ43aupWnlC6U+ YzBPYg4vIfNavTPOWP1PMbOcgevFiPD4UsREfs9uvXY2Uy68A2/V1oFCssv7p3EwNSwf 7fOKQ6QQVR5lL0AkoarS21qS2IrSVp0fO9857GFSFCEAUBg2VZZmMY1iKPkVMX+lJmCR C2Hg== 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=lcv/dnGwmOfApq4VwLE+LkMCySzVH6BCh5nm4NTEb47BmZcAciO3nCmVMhtoWqqUf+ qigk+KgLJ8EK/tByl+Ka0OOyYAkM63+IHVjlp3HoKnzACpm7IXzBZ/FghR/08aODGbiM I0M9X20SyK85WLVJQK0hOnJC6+siO13kQHAaD4TVn7ku2xtCwPpdtQsL5vOxo4t6wFbR u5Wm1Kgkxj8cZAfZIwCtiIwRO4RwaNFRlK5x44DrD+rhHnDK36MJpecAwz0sHwPcS2+I nOzdhv3MWFD2nmZSu6UzBcqumn82R82XwgJg8VZdqA4quXFVMuR8M5RWzT036fIAssoY vXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=NafQ9PuA; 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 n73-v6si27980377pfh.96.2018.10.10.21.12.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:12: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=NafQ9PuA; 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 w9B495oR191331; Thu, 11 Oct 2018 04:12:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=NafQ9PuAw0a2J5i8XyTqAexFTXkFzks+I4Qo6VpzMdJwn8Ay9eHrFe7kVqUGxXf1ipMZ TRuXz5l/D2bz5E7c2w+PiyQ1FTGcVuW/sL9pGfOVzwe1zVZcsG+oa/ne4v1IbjF+yQQu jPUf2eKvoyNs55gZ3wjqHInrp9pvRAD54o6LKXmi8p7XjCK4wBjzWFbl6sxO3UUPydv5 v0OiSczIjDzTGDhUxr4q6cKX5sru7R46LTw9Swk077TfXBUGkY2p1VqV6jQtql0WEAH3 wJ3ArVEkhs6xgIdxzqBcNC6BPcmMZE1FJCIY/votcMpOx5WMqmxjelKLw6v5wxRe9+Q2 +g== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mxnpr98ux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:49 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4CgGY011604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:43 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4CfxR029499; Thu, 11 Oct 2018 04:12:42 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:12:41 +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: Wed, 10 Oct 2018 21:12:39 -0700 Message-ID: <153923115968.5546.9927577186377570573.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=979 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110039 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 Thu Oct 11 04:12:46 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: 10635731 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 3AA8C14DB for ; Thu, 11 Oct 2018 04:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F3F2A61E for ; Thu, 11 Oct 2018 04:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12AD72A620; Thu, 11 Oct 2018 04:12:57 +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 72ED72A612 for ; Thu, 11 Oct 2018 04:12:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4BE26B0273; Thu, 11 Oct 2018 00:12:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CFB3F6B0274; Thu, 11 Oct 2018 00:12:54 -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 BC4A26B0275; Thu, 11 Oct 2018 00:12:54 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 7E3346B0273 for ; Thu, 11 Oct 2018 00:12:54 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id b27-v6so6726016pfm.15 for ; Wed, 10 Oct 2018 21:12:54 -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=nhsxHTydnstM/Zgyp2IpKwX1aLggX3h2aFWrrLXDSjg=; b=kgv0duuxkc54mziO1dIM/EV3lknXJ1Lh4u+8We41VJ5iNeHK8BnBC2gChvqKSbSpAv SfngFQgrccIUMYg3BjyZkfEoVmuvSp5XYv0JioX/aqH0iZoPkJXkvBfninDn5lBZEkZl +Z7ceGCNb4lKgy6UJHe1qWsen5XdybjWedRCYRscbyjoChj01Un6vLmDxyDgOZ21wv2B E1ZLpcQqD3Y/h4pLrF9jpHH8x3XAp8NLv1fUHsXY+s6ASYU65U8rgmU7czF8HbtiGETN Np5/m3zjMmAjlCYYtVw/BdtNdNa7b8hDogWXXcirUaWF4ETWVESKMFh416VsGq1ncwI6 aSEw== X-Gm-Message-State: ABuFfog0tEsujX7/Nr8PIg3pgAd5Egm05uP2fWs1nHNw2gkZma8FVVxD HnY+TPHZdO14fus+TXYwHV3sAQT/Uztfbv7owN+nol+K3/w9Wot8dTx0vbEvQ28S/o3DXLb8jXe h0JkYyV4Y8/+aznVZAk1HK4oslwbtW7ERnBUHhtVwOX2b/g8s/HgKo/HRPOOI7AvqZA== X-Received: by 2002:a63:5c1f:: with SMTP id q31-v6mr3895725pgb.452.1539231174151; Wed, 10 Oct 2018 21:12:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63cG0ihCAvqcnebWf3o/XlU1E3uXiFjJbvt9xywUFlwI2OMHvgtrvRx7a6W5Fx4ucF0U7++ X-Received: by 2002:a63:5c1f:: with SMTP id q31-v6mr3895694pgb.452.1539231173393; Wed, 10 Oct 2018 21:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231173; cv=none; d=google.com; s=arc-20160816; b=hjbrYOiYaLZeKNi68SWVkB5NLcD7WFcws9xaAYb14xUT+uvNTe2Zxgz4zR9Rsc8M5m jGMOl6e8lBkVwFRHhNuYiREtysCYbcay23fhd9xcDRYaZzs7fqdxh8LE1DS81EfyCW5w RxGxfZxQAblEqDRmYcMOEv5GHydP774j2vtP0WpL7csuMdESzfaqCMrfDkNUvYWvFjug oyhWCOab7W7otfq98aUfoYdn/N5YwSmjdmVM9TYcZlXEXov4fXzennG+jehdZsHAWvLk cT+EtdZMp6SucdI4/D0UCXvk8t1AwbGRr148lHQujWhO/ViD4dKU5B5SkIu/Yy/MYlaK Pmyg== 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=nhsxHTydnstM/Zgyp2IpKwX1aLggX3h2aFWrrLXDSjg=; b=JubZU5TBpyEDnhtkfGptQpUL/4KOQocm7Vwq5Nww43iJKMLlrIygAivhuaXkOHu3Fx 0kXAtdSEZJHdf/KMxbPrUqQpOktOfOjb5zRQt/zQHFfrCsx/Uhwc+A96qfwropdRtPXu TjDf8O6LMUat7WuawEauyhxQ5I9mKo+xXF9mzroMEZeOd9hnOxcUxQ2DpX4XUhqFMTYG wjabvfWbA8PSJ5d6jT2P3su810odIopOd+N7AsVhHwT+ktkTqEbQI2+RMVbIhWgGfRpJ Gu6IF5H85TxU7677616xz9zzMBViW0c0uJezbYIUAkRBEJbLxV3F8YIiEeGRuP2+6HDu U/Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gnxjtVH+; 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 s20-v6si22901849pgj.546.2018.10.10.21.12.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:12:53 -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=gnxjtVH+; 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 w9B49mTa033975; Thu, 11 Oct 2018 04:12:51 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=nhsxHTydnstM/Zgyp2IpKwX1aLggX3h2aFWrrLXDSjg=; b=gnxjtVH+EIZMQweB6epVic+WSH3nycHLyHGy/8UF2joBDSaA7rWdKh4oWfozJ1TXNNeJ F9W4pNYIEycVCJ0YgdekQEiEwqyujeJaxmQh9QdFytf2xR8WWooSpGwWZq1QY6DMNJ5L iQtJOu9R0+huO4g4N8q2v5dm3UB4zy2AcZTzOEzpn7ErlK/yfrA0jqDkDmT3vQaJ+VMn L8jdpfq6/An/Xq1u4qQeh13AfXpho39rrGnt9c5vbXOz5iXgiyD3R+9bKzR1/FKqHBm6 gPbuo2OLnGFKmEz71vSa0EaftNH85FB+3TN8N371na8ChEWwBpOblMe7p6lOUPE2spNy YA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmfu1fvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:51 +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 w9B4Cn5l001212 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:12:49 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4Cn9P008068; Thu, 11 Oct 2018 04:12:49 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:12:48 +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, ocfs2-devel@oss.oracle.com Date: Wed, 10 Oct 2018 21:12:46 -0700 Message-ID: <153923116686.5546.8711942394464060950.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 Thu Oct 11 04:12:54 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: 10635753 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 D0BB8933 for ; Thu, 11 Oct 2018 04:13:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6BA821BED for ; Thu, 11 Oct 2018 04:13:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 975A720CCF; Thu, 11 Oct 2018 04:13: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 1535320CCF for ; Thu, 11 Oct 2018 04:13:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 226286B0275; Thu, 11 Oct 2018 00:13:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1D5366B0276; Thu, 11 Oct 2018 00:13:11 -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 09DBF6B0277; Thu, 11 Oct 2018 00:13:11 -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 D6CA06B0275 for ; Thu, 11 Oct 2018 00:13:10 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id y201-v6so7152950qka.1 for ; Wed, 10 Oct 2018 21:13: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=rYNys5t3mXrXHQI06sCGnidadi3Ilenga8cPevys5pA=; b=CvFVYqzJvf+MEoxDxlDj3xwBeQpgHJ98h/v94/dK5fqR+adUzYlHQODxuPoFYsn2hf H55MaO+CBrfDLOndw3nPDgeAiNuWzSXggYFXV0Zl4W6TyrtUP0E0jOqGhggFIRR0AZdV OcCLXXwhFbI3hRwvdEQ0391Wfah5oV9+QY5ldYJgIVSYQtgoycwozVEmg2LnxppCa5xP UYIIa/9cB7VAd3h9/txODbpO4cIgQqV9q4LARTpt6gk9FACiO9e81qN/JGuOCDePNgp8 ReHJGK60hdAnUNUf1HpR6CO9IP1AA6sAmCYO35uvdCxba4l0xURsLH2F7YEKr2ASNKcx UOOA== X-Gm-Message-State: ABuFfoh3o+3ORQ63B6GBlxBWKds/SiaXyFWT7icyi9UgYVPXNrI6Ikj0 lo+/nzxAoQBm1pSRLHZEop3Cq82OYt0QSV8uNRrAjzzJof5KkZ0CwucaU1byXWqESfCRPb7mHIl dgEytyJtNNyTV7OGVMAuyn9BT8LhwsIjjYlGapGVfKCl6G16eVQvJT1VhvVNnrJ6PMQ== X-Received: by 2002:ac8:1c1a:: with SMTP id a26-v6mr30099402qtk.16.1539231190603; Wed, 10 Oct 2018 21:13:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV60G8dSR5AFT2/E48LuBv7Xh2y2PuveE7hGQw+eW2bEed3P15biTd0JRnsi1Zz5pnxC66UF0 X-Received: by 2002:ac8:1c1a:: with SMTP id a26-v6mr30099383qtk.16.1539231190004; Wed, 10 Oct 2018 21:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231189; cv=none; d=google.com; s=arc-20160816; b=0R65Lk86XmRdM+X5aRU9hjDkFvlWcmPeyvR3GWh0CrCxsyitfxtvGHH1tH1alLAheI 57ENCPx5hnbio64Zh2Fo4GnX+tih56omy4WPxZLnRDOJrCYJx+X+TZv35DhnBBAxYtwB 9jAOl6Y1mIPwiHk1U+/Gv43h5w3elrikx4tYbSjRjQtfN8yCDm0XO192QFOg0RQKXH2m 6G2e/EbIYcJeBExtcNlsc6j5JtUz9l9Tox1sSiHZQM+Q/kpbM4/abV/XHCcD1r5HbdIG PIQ6CQFxF+Glh/mGlIPcvaOjyP5VxHYtiOrX27PBxrzTczTkmjBUDTBRzCcRKpjw3e9a bjxw== 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=rYNys5t3mXrXHQI06sCGnidadi3Ilenga8cPevys5pA=; b=07HhLsiHaCL3LlsfAgDrdVojGLXA3V0+2M+NcXf50Svwy6VcYB+dSwQxHi7LbtFcYP Eu7LpW9zYXZtlhhStiS0ufVJSbbS2NxbVjZ8/DoMS5Ij6KJH2/TRM/c79Zb1yLskZZDe jc2mjqZWTBv3rIhscpmhRTseGqyygpSptOUxkKb8cwsoorGm8ml13Yz8MITGgWUTFJg7 A7FImKX4XSX2hhigGeg3t+qyylf8l9GGrvJrKW2HyPopqQoTEnooM5aF9ZN07iXGbojF 1n4KChwaa8MbsnCmiBTSY6m0TXFpjBbwjP9TaffnWxp92btlVjstFR8LSyycNl1YBJza iPPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=SEHdlmBH; 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 l9-v6si571189qtq.254.2018.10.10.21.13.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:09 -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=SEHdlmBH; 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 w9B496X1052689; Thu, 11 Oct 2018 04:13:09 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=rYNys5t3mXrXHQI06sCGnidadi3Ilenga8cPevys5pA=; b=SEHdlmBHl1PEWtBx1kYYvDGijkTeRKt9mbK37pkwKSlP+xzGA8BzBE9l4HgH8pubHTCG 3pXIVN3BGCuKto224oA4Qn7ERYh8BkALgWgbicwGwWlvGjw5lvRU7+0F4nvI9thzFSOf JVqSFtVuTgk+V/MQZKKqBncyCdybDsM8v1A2ijWRF+IrfraawhY3Sf9KsQULQ+tlK+pu wB8nr1eYYVV88+rBysG5TcdoeLzofefES9SVeYE3Im/yPvTfx/95sJ8bK0DFUcNRpbzN hOHuvbQCDVkknI0XktzKEZKNPlq9H9oZARJwaJ6ZNfdVXat/LSX2gc0MNhq6BqNixwoG nQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q9dub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:08 +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 w9B4D2jD001922 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:02 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 w9B4D1cT011595; Thu, 11 Oct 2018 04:13:01 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:01 +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: Wed, 10 Oct 2018 21:12:54 -0700 Message-ID: <153923117420.5546.13317703807467393934.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=625 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110039 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 by fstests generic/505 on XFS. 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 --- fs/read_write.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index d6e8e242a15f..8498991e2f33 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,27 @@ 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, 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. + * + * We don't support shortening requests, so we can only reject + * them. + */ + if (is_dedupe) + ret = -EBADE; + else if (pos_out + *len < i_size_read(inode_out)) + ret = -EINVAL; + + if (ret) + return ret; + } + return 1; } EXPORT_SYMBOL(vfs_clone_file_prep); From patchwork Thu Oct 11 04:13:06 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: 10635755 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 5E2A1933 for ; Thu, 11 Oct 2018 04:13:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43FC825223 for ; Thu, 11 Oct 2018 04:13:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3882C2787C; Thu, 11 Oct 2018 04:13:15 +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 BC68621BED for ; Thu, 11 Oct 2018 04:13:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEAB66B0276; Thu, 11 Oct 2018 00:13:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D6FB06B0277; Thu, 11 Oct 2018 00:13:12 -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 C37EC6B0278; Thu, 11 Oct 2018 00:13:12 -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 861B06B0276 for ; Thu, 11 Oct 2018 00:13:12 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id e24-v6so5145699pga.16 for ; Wed, 10 Oct 2018 21:13:12 -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=mbCJTCJlHtGyJxCxGNwQiD9bwchYhi3Y610tPi4XMVI=; b=eE2didAlYtcjfny0yYOq8g/y61134418V/Pn8BpTzlVDd4Lt47GbHAM6OMIEFp23Zv pCyFu1aqDO1MVGW3SQUYJGNqoplup8jU3/94JxQuQLNi/EU4cmLbMKjgXzyWjSUwR53/ Bvvz6iyYiBhK/XicGeMhc49c5FtWatTPTnAggRM5FNC6tEcL0+UajjRSezTumWnc5S4l RpEmibfa85fSa+m6GzMRweVE9MdP9mlOq0KaCJ8g7U3RM3GJCXBNjmD42SGiN5uF5bOM V6cImk8KtXSd2QYqHfJF0ZeeOBAh5lcIt0Cf7U6aelTdj0No9hXA6+8A1WwJ/7j6FIN2 Kd/w== X-Gm-Message-State: ABuFfoi33/7jB5ND3m/dtj6R0XWCnP/XyZtUY4Dw4t1fDk44OdfzairA fGxsYZufa2ERtpyITmvuKvmpj0O7Weg6AuyQ64Ee4tDecJAxORyvsePx/9bUsYI/l1DIRydcfiY SgtM2aKj9S7QnGAL0sM0EsMad1UJcYDmrjM+YCJP8NKu6CvViOKjiTiSjVFKni1UVow== X-Received: by 2002:a62:4c3:: with SMTP id 186-v6mr37009539pfe.156.1539231192219; Wed, 10 Oct 2018 21:13:12 -0700 (PDT) X-Google-Smtp-Source: ACcGV61UNnJzASfJ0JyYyV5M7vomEl749FgREMyFbSVo5pqIWnx+4EMj+CEp9YXDQO+SACr+fzd0 X-Received: by 2002:a62:4c3:: with SMTP id 186-v6mr37009513pfe.156.1539231191574; Wed, 10 Oct 2018 21:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231191; cv=none; d=google.com; s=arc-20160816; b=OP9QoqkU8MOrBBGU+/FMX4oRBKGacc/AGP+Titlmc3Ir+MvA+C21vp2eLNKLKGsmGQ oYJiRcnvoYCJZge37n6Jmjb/BeqkDOcJYmiszLzFoKr0Pg38kFkU2ux9gRTOeRD345IY nBFcwYSSedqurFJFagBe8IaBCw9Becf3uZeIYxWJh/prop+K36Pg+fJw5xOup+fUZC/I 5eOYoJGdAE0qCatBHPVssAfQxkIGZR4YAPwqp3VxphFxYLmnXR6cBnL6xViT1NBpke01 Kp8nF8QlXDNt29DlVOQaj95qaWtCjpZjaFgfsp9yStqvuCpDf41ANlPBeG2yPBZOziAC eUbA== 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=mbCJTCJlHtGyJxCxGNwQiD9bwchYhi3Y610tPi4XMVI=; b=rwuaORlMtr1rdvQY006Vk6buX5/qEnMb3ek0jvz9pZJ+6tOiBjJvrm5o+UPZfgM7uN VvqE6xj5JRghMm5YMtoGz7H6yAQX8QC+asNnktGGhyHCKKtYENwArZNZH64IdmOrqiQ9 biDWSo146ycFF9moxh31lqsgY/VYAnSUGrQ7Hu2Xx5TQB/IVTw5v3Noj4xYFkS3W9V0p 2f8ImiFClMfhdRv9xblIFISmZlLWC/uakI2jD5+bfJnIYT7rzIQT5p9v9CfSkKqQkGYY USdsxtQDfwjOyWFqP5cQUiyLWIxQTRZW7fvCTumNDUT2g+OyGLL1se1lAVYExUHdYaJq g66w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=teHEeHb8; 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 v12-v6si25691604pgn.547.2018.10.10.21.13.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:11 -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=teHEeHb8; 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 w9B49RmX191602; Thu, 11 Oct 2018 04:13:10 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=mbCJTCJlHtGyJxCxGNwQiD9bwchYhi3Y610tPi4XMVI=; b=teHEeHb8WJZPjuJ6X2yubSe9uTmR4HvMEk6QUTYBGBaIduMcO1/S1m4PfIrcV4RKk/Al +Ah53OS0lKm8b783yXgN7xgkioM9SXJ9ad2FhEk2YW1KxqmJ9ECJE9/FOzZhFVm+zqwD IfTXJHbHvTu9QqmlGOO/0Akf0BYwgqSQG2QxcDtqPIHy+/iyWZuDAVo3nmgzNo5Kpog2 L2Xn7U3DDrvA9fitcOuz5YLUAeDyZ9a9eB8l0Z77qtTCInwYqX3dmaLx7dzrI/uG0fuS 9Nl9Su80Dst4DTeDhARjo9y1JPxObpD3RvBsNnDDPcIX9B3noqayiPk+GKXsK7642B9f LQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnpr98w9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:09 +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 w9B4D8ER018613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:09 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4D8Nu011619; Thu, 11 Oct 2018 04:13:08 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:08 +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: Wed, 10 Oct 2018 21:13:06 -0700 Message-ID: <153923118667.5546.2251008065628647198.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 8498991e2f33..48d83231968f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1996,6 +1996,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 Thu Oct 11 04:13:13 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: 10635779 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 083BA933 for ; Thu, 11 Oct 2018 04:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFD8221BED for ; Thu, 11 Oct 2018 04:13:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3F312846C; Thu, 11 Oct 2018 04:13:25 +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 997A421BED for ; Thu, 11 Oct 2018 04:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 707906B0279; Thu, 11 Oct 2018 00:13:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9086B027A; Thu, 11 Oct 2018 00:13: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 55AC06B027B; Thu, 11 Oct 2018 00:13:23 -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 09BC86B0279 for ; Thu, 11 Oct 2018 00:13:23 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id i189-v6so5168424pge.6 for ; Wed, 10 Oct 2018 21:13: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=SWe3KO2gGNo4yvtVsI6Se9I/mOyzQ8ruopQWUVCVvUU=; b=uBpmyDWQQHyxFcfHNspcTBiteMl3aS7a4WQ8BAeKm00TMYKDXooAd+oREVlZz09ZPJ /B+D8Y52TvG1wgo8GDaLguFxiJ4loffyB1BXiKZEMWapCv/2VGqDW2kYMgY/1+LSx48R FGsJd5dX0juPdO3IIgUTOmEmQ8aqRlxBnPuXvcFFCKcEHmpafZZ2BZInY8+OK1BWvpjX pnob5GvHOPDjCejKEYm7dq6kJvPfPRX15vFgFuSOsuA4gOFGZdQBe+nCOAQxwrH6iqHk 73DtwH+SIrXxwJFZRXjWPviDb9CUk4sjpYRYtCIrlJj9HymD2y5tZHJiwY2QMA0dMJt+ 5DBg== X-Gm-Message-State: ABuFfogEnL1RnAUcx9IFSTPNfP8kLrmgzWhdvKvFvsz6etrSjUQPdhSs MP6KkCBHF+HrYKwwQIXhTlFvuF39MGFXCR2Ga6BeZP91W12MTvFhqAH8wb20lrHPEn8KN5BzZ88 2h+P0iaB+93I63Y3Z39+uzDUi0lwNeLlA0g/BiyPWJ6Rr/YY7bNT/oDfGyRil2YRqfQ== X-Received: by 2002:a17:902:7e41:: with SMTP id a1-v6mr1134574pln.149.1539231202674; Wed, 10 Oct 2018 21:13:22 -0700 (PDT) X-Google-Smtp-Source: ACcGV61SpS7BKB62r8UAZLzXQrEK0ZTQDvkIDzqIEn2BUoL1VqTPCNAHjaJKML9Prq9R0aB7KTRf X-Received: by 2002:a17:902:7e41:: with SMTP id a1-v6mr1134491pln.149.1539231200828; Wed, 10 Oct 2018 21:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231200; cv=none; d=google.com; s=arc-20160816; b=NV9AfeTISpDbBL1u9jihRmVHjOJ9RxGtxGv9QNL3IQDqHkBZeU+gytIFAuua0qwb04 +8JaHhju51Kurg2Xxh5d0A75Y6UgAfjJhsS9w23QZGqyZthc4QW2OMES/rKtm/XxWUmn qiCxbrWqi0OepwXTAMby0eeJ2zriTFMV0cKp2cmEIo0USd5hRGhl2bzYsZwrmbxmINGA YMD2JAc81AC4MJmzS4sbtG9TYJ43c5eDaukfk4sJvnw3sghb3YoWDh/4zVZ1+5AIj3pD iExgnDkLMd2orvMAecfgpNeRwZFEnqcjEMcIQgx1mMyvnMzaiJ2+6KeG9+0pzYP6BvkD RW7Q== 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=SWe3KO2gGNo4yvtVsI6Se9I/mOyzQ8ruopQWUVCVvUU=; b=H0OL4Fvl7RgMtgFUQoiRVu+MiGzHmYbRV1bHgk5fZ5pm4NX9SpphbiXsbu3ZQCTQaL lypSAEMNOjed/kRJeIALinTL5y1XqUA7dRnmtYc/YevStEdWmqDdoo2K7g9zSdajtsA3 NYAer1mNThQeNUNbLVKNKfGJOCmnLdwi7EsvfQbOG1mXM2xkSnC5MC2TU6rKIkIepOIt ZHkbd6Q05Du+0LnI2ofCpSXQzBxbR49vk9gE1nASnNTbmFBiQJ9qot6TIRyHPMjehXc9 aYzkON63vnNfTDeGlKC495/nakaVQAvLhJnBncGgjDaw5vQGmlOe2QwQcd5YsO6tXVbh FYZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=09Y6chCD; 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 f65-v6si27995830pff.276.2018.10.10.21.13.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13: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=09Y6chCD; 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 w9B49B6v191427; Thu, 11 Oct 2018 04:13: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=SWe3KO2gGNo4yvtVsI6Se9I/mOyzQ8ruopQWUVCVvUU=; b=09Y6chCDovXGfExSjlsYFdMYtpQT/xHuZ86USx7PmMJ7sbCdvtVho+rAbn7Xv9mSREcD 6CL7a0cwr5fx9q+JGWFyMg6T235wuXIzRPlAK+4GFPfnZdGtLxU8WvGeV/2ixbwTeBzU gbxLUE7kFfzH89vbYtskqqCNdDnJWaY0fTSIwRnRB3ctNfH48OHJMEBACQve3RtnobV+ /lB4hb9ByxUC39cXO8Kxad7hfBcpleSCv+0YOsu/qfwNGJ3X/dc7ixHNxRFx8JDxPPhI 8VTMJH/zn4ylgTSZfibYtEKXATp8aHSyny2SLDoDvEhlKH1S18J0RaTNOqdjz+LWuauk zg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mxnpr98x7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:18 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4DHiL014442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:18 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4DGvW029749; Thu, 11 Oct 2018 04:13:16 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:15 +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: Wed, 10 Oct 2018 21:13:13 -0700 Message-ID: <153923119362.5546.6366409105372497321.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 48d83231968f..4d6855671bf3 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; @@ -1836,7 +1836,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); @@ -1847,8 +1847,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); @@ -1993,7 +1993,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) { @@ -2001,8 +2001,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 Thu Oct 11 04:13:21 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: 10635791 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 A3F5214DB for ; Thu, 11 Oct 2018 04:13:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88F8521BED for ; Thu, 11 Oct 2018 04:13:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A2EA25223; Thu, 11 Oct 2018 04:13:31 +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 5167D21BED for ; Thu, 11 Oct 2018 04:13:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3ACF66B027A; Thu, 11 Oct 2018 00:13:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 35BEE6B027B; Thu, 11 Oct 2018 00:13:29 -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 2264F6B027C; Thu, 11 Oct 2018 00:13:29 -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 ED1AD6B027A for ; Thu, 11 Oct 2018 00:13:28 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id f81-v6so7167523qkb.14 for ; Wed, 10 Oct 2018 21:13:28 -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=FPeyuRN3Xjx63rLkII3YE0NweIY+TcOwDUsAkW8yb78=; b=oGy7I1oeCME4KgcfmPDZlP55BD7UD1vKwd/XSYdcTrFS1uCAv35YgqA6SYXqm2Ct+Q 5KhGmoZwcL2AHOCQ8N9ryEkL/KslIjCOv9DeuGYmd7bFhi/etKiy1UHmOWWYoRFPWENO PkIosJU/VXDKy8P9cqL+ArqkqUSQVRztzoHLITUUlx87Vtv69JtY3rqUKj6C9PIjJQ82 zoSyhSAOtebsFS4pbvg9Jn4OCGFyn8ADlf1zB6UGeuxXzuGnavM2g4DXLeRt9hRLscx+ EIv5+6Gb+uVt5WOjojHZUogQ8DW0sgYUfYEHirgqLP0cgrsaUfCrNc+M+vY4JczyOZOC 1I7g== X-Gm-Message-State: ABuFfogqMBjj8qXx7JVTpVt81M+U7r839T1mUVhSpF565yf1bm95Civ5 fhR8dtwXHjcvQ72zmfcjSvkqmKoPgiulGcXhqvlkcHI/0TlpuvPa8VqMtJ1O6U9WgBlEMQXAq03 qd6OG9ePw0VA8u4mZbrcTDJDN8YdgCXeuxB8YEy0a+edF1biOpSC8ZxUrZK9F7RvxQw== X-Received: by 2002:ac8:3829:: with SMTP id q38-v6mr28804157qtb.91.1539231208746; Wed, 10 Oct 2018 21:13:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV61SiCO1YUZn8tC//t2dNGlGXFhahySsBM+TyTHFA3q7FA22xQB0kOSuMbaOqdAPQbZwKCkJ X-Received: by 2002:ac8:3829:: with SMTP id q38-v6mr28804141qtb.91.1539231208142; Wed, 10 Oct 2018 21:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231208; cv=none; d=google.com; s=arc-20160816; b=MWDvu44Ddt0e/L6cATs52dyMQNdlCn2LDrE0GLn0wRbYpp72G1fmA/IRwvpUJIz5lm 4OQHSTOBijrRHoOSLXlJyh6DZpa2Q2uM/eruNYkZF8Yh0wzVvrJq4apeJF64CT2GdmeI 0PHC/FN8GS42VDl8gIIaSJTL3rGYlYmOjqXgG3J73/h1ZlvWVEsmtijGmW+kjVGPqZcC z+asKtrRirMdnYV5vlgDBBdmzv8M9rpibqGBFoudJE91f6KmmrjsVlzIv4ksq5m7QzDM U0vFmfBEmu8h1ilMlSxn8nt2l65Mm72chv6nhcgdQxf1zZEsxHylUbkhZrm5F3yrF1Cq rXBQ== 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=FPeyuRN3Xjx63rLkII3YE0NweIY+TcOwDUsAkW8yb78=; b=VGipzcRosuZ2qryu9clnOR0Yi7hU0Jj/rI2I2RGM5ohycRdevO4eY2W9/2tn5X6TVm z0ds3Z8vc9ippsOS1WLEAtUIUg5GDhv4Wa4fGjHMMw9+TLHF5Rx5h7c8Ana7OhcogV9D cIJR40oSgrpVPZBfNxXfJW/+AtpXAw9Td7Gx9IyihWdC5pDoy8di+s9iSqOCp94xrL07 4cao1XGAVvtQLeMcK12D6sHUXT3YKjhcEDshIktomU0qKHpuhrqrpGFZ0UVwa7/VidtT hBFkwSC3ZJSUgREz13M4bLxI9iBwWENMNUojg9bvp2U40unHJgJQuOqcmWGyqUBsnCxR EB0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="vHt/OMIm"; 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 39-v6si4346073qky.25.2018.10.10.21.13.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:28 -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="vHt/OMIm"; 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 w9B4971Z052718; Thu, 11 Oct 2018 04:13: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=FPeyuRN3Xjx63rLkII3YE0NweIY+TcOwDUsAkW8yb78=; b=vHt/OMImYZNFqmc1YloKKq39j03qykjhaz+ANO3Scb1JXvu1NqtJ0axxLs4HpEnSU1aM 8dW6kWKPz8Ph1xjKoTKOSdLluhhfZeYchTm70UH7R8lJEQPrIxEy2becj5963c/YVHWK sAjhWUs3ul3LUZbulmsI/UkixErrWgXEDNDxevRATFy7YrtP4bzgKqaCcYrbYHtQnAsY zm+MCPWVlVqunY9OiJUQzq8qSTHxA1voVe8IqN81FlyUXUHi1/YfYMavsXRW+E5DIhzB f/fIUqH58zlKJqah8gWCHaHN7JUyuvhxyy/1kKXf6KF8HRVU85ORB6t+TA0bZ/0t6Kls Tg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mxn0q9dvs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13: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 w9B4DNnR019610 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:24 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4DN2F008757; Thu, 11 Oct 2018 04:13:23 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:23 +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: Wed, 10 Oct 2018 21:13:21 -0700 Message-ID: <153923120146.5546.12819462933063012193.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 4d6855671bf3..ebf62ffca57b 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); @@ -1809,7 +1809,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 Thu Oct 11 04:13:28 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: 10635813 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 85D8017E1 for ; Thu, 11 Oct 2018 04:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C65125223 for ; Thu, 11 Oct 2018 04:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6021D28405; Thu, 11 Oct 2018 04:13:37 +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 E298C21E5A for ; Thu, 11 Oct 2018 04:13:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C37C96B027B; Thu, 11 Oct 2018 00:13:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BE7696B027E; Thu, 11 Oct 2018 00:13: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 B0FCE6B027B; Thu, 11 Oct 2018 00:13:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 72AB56B027B for ; Thu, 11 Oct 2018 00:13:35 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id t8-v6so5381181plo.4 for ; Wed, 10 Oct 2018 21:13:35 -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=OTo0aS/v5GOSjQQZScdxEFPK/rxcY8PE4Z0I9lovRvs=; b=BeBAPNk6uxDYeKa5fjawHsguCbHvXDoM9A0OjvEKlQzZb9R4mdqORRyppHZiLXC02L 9H58qfkBqn+I33hcBodDzx5QspSmCdmFbhi/vrwsoXx5uV7F05a+tZe4OHCdTMku2w84 UY4xl2oD/7BVFIELK/YZcj8SKTrha4Zlao3ItAmvuiae641olQtBYnoeKGLt7IHT10H/ WcrxlWf6BHh4sGfPKWY9NpUaceuWeuHWFvNvx6sm8B6dGOjpULLSfoZSBvYai4g/upPa 7+Hj/PmNK0ha5/mGKNtpqio2zQod2zzKztbfr/fMhTXbIgDK7NTrkpU76rRbvY5Tejb1 YAbw== X-Gm-Message-State: ABuFfojXMu298KF1UxlxOTnf9DvdmhSKaBlCxuk+JJkNuAkvS1lygagJ qhZI7LqYfQ2Mp/VBsmztnFPj6sqLGL5kRhSZKP6l+4U9e1KUg0+nkx08vvABVT9vFyXGiQEcDIj yEjGDh5BJwlN3B0Im4qa/GCaRFbm/FioKOeTZK5dPlzpZ2bjgz8/d0uncIHyVGyf19w== X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr32425075pgk.427.1539231215145; Wed, 10 Oct 2018 21:13:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60vFR+yk+bCfaYUz6ym2IzcYBJ+s6GKqAcsIgEgcgT/PqBUI1qlLUK0uSwavcQHL1KupVxN X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr32425052pgk.427.1539231214522; Wed, 10 Oct 2018 21:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231214; cv=none; d=google.com; s=arc-20160816; b=aICV0sF7Yeq99DnzG5wMK+XYyPrnMOBRRR4hckg5l7P6CyTnrFCe9cRK+o9SRA8iBD lw0cGdsk/olpfajQO9J2SPoPQM9bVnox2iK38aOjL/Z2kJBihoc3L16Y72cDUbCicP4h Tju3QHlg8uO25THYRzhAIdA2MsgyTUvdYUf9fAOd5tCeNF1hDGxVMRT8htZVpIkihCD0 oJt7XW313dvEhpuxIkFVqm14gWnnEtIm785u2HC+kfvwdwV0U7lKT2rEDB56qFZs3ZvB CewleZzwyqKtFloBeUuX7GxJxoj8z4UYBhM2o3cKeIn9KSinZDLldEPafPuWhiQ3SiWU 1HpA== 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=OTo0aS/v5GOSjQQZScdxEFPK/rxcY8PE4Z0I9lovRvs=; b=SdqY9eHfy7PV0d13hai9SbHmPVoMklOdP/SVEpDCcs725h+5UIL2VQuQVzEVYkqtXl N4/gfR83xId0F4CRAc4sQJMZoZC5IRAhElH2A5+ZZhJY4LOqTaA3MTLPTkDFOKIRzEqU YYFwBAR1cjQ2bYhXWEth1uMWBH4/jjeeZgcz0V3VebgIjD+cqaIgHU5EAzkA+U7Zw/lU OzHd92J7PXJ8n23IKzKLCTbkMsimMuxwYTKU0FjtyMTzS6fbAKt1OTHl7kanVGjTC99g JkCJ8+QtQsXcN3gcpcxNd/LoK/bUSLmFZsHVBLovw0OeWIKbLWxg+1iW2rHaO/v3SFsD phRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=OBHMaLR+; 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 d92-v6si27766915pld.75.2018.10.10.21.13.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:34 -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=OBHMaLR+; 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 w9B49JP8033639; Thu, 11 Oct 2018 04:13: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=OTo0aS/v5GOSjQQZScdxEFPK/rxcY8PE4Z0I9lovRvs=; b=OBHMaLR+njKd1GUsiB8lOuWmN2IixYZ+o+RPJmSARkPiZyuiF5BkrwwmjNztti5AGawJ wSMbFoPjYUfwVHwksUefeBfE/VK22WJyKddxYr8tGtTzqTlGRfldchkMBbj0cs1cZ3UT JpZMk2fLVE7m6aXpjnWpoF9+6u9cygr8PEq5NXsdOEunP1NTGKMIUWgppvFFiTacXcN/ Qyzm+O9vhNdR6Pvw00nul+jVI7K9XpWjCEWfg9ak190Tt9ce9tDPv8ux5q6hlhdfzjWm Hafq8h5ce7P6H1F2Ibpk+ApansVx7tvvApoToOQv5+RfDtaKFLhUNIhIrtlYueYzZfmE Aw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfu1fyc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13: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 w9B4DUih015672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:31 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4DU2E010717; Thu, 11 Oct 2018 04:13:30 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:29 +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: Wed, 10 Oct 2018 21:13:28 -0700 Message-ID: <153923120833.5546.17948742293210510133.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 ebf62ffca57b..60cdfb576d81 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); @@ -1839,11 +1839,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; @@ -1976,7 +1976,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; @@ -2038,7 +2038,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 Thu Oct 11 04:13:35 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: 10635831 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 D24AB14DB for ; Thu, 11 Oct 2018 04:13:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B62792856E for ; Thu, 11 Oct 2018 04:13:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A992F2A63B; Thu, 11 Oct 2018 04:13:44 +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 1E3DA2856E for ; Thu, 11 Oct 2018 04:13:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0502C6B027C; Thu, 11 Oct 2018 00:13:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 027556B027D; Thu, 11 Oct 2018 00:13:42 -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 E811C6B027E; Thu, 11 Oct 2018 00:13:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id AB2F46B027C for ; Thu, 11 Oct 2018 00:13:42 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id n81-v6so6709655pfi.20 for ; Wed, 10 Oct 2018 21:13:42 -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=/3l7N/X857KPTkSp1muxCsYvuhsKcEoEr7NE87oRJI0=; b=lrikFAROxV84f2xwZsflT3McAQQnm05fKYHbtbgEx5pT5q+7sJnrFX8iNhaOtHNH8y G5qrl8fTQ/gITNe3Z/mKZHO3aGGChUSN/E/cGZac/VhrnENT5Pouq9n9V5gL/DYpRadt ZW8uilqx0+wi8OgfXLioirur394R8Y80XgxG2UXWFVI6LCRUDfYgUj5p7PZvwiAwd9HU krCODfDOhfMC4oVFw60Co1jr/G2A9PiRDSUECIuEMm2FHuGg8n61+PtfQnAXQjGDiVAQ WdArZoTxz8jp+cOIRIcL2PbzyuFvFY3ipLtQPnnqNSjVvB1BC4htxtdPZGTKZ79jhj38 n4SQ== X-Gm-Message-State: ABuFfoibdTWjDin7TogjF/3ctPMhOR0l9cZ9DrdluFsz/O9DR/6W5B4P zrQkbQ2Cr1qFaA9ZvtYyatVW8BlkiNOAKbmi9vq/pnru71GdNUoU9hlGmUD0eqXPG8+bUw6PSTf xpMmUmRh3gps7LFly4PkaxkXUdR6wYjAP6C4rrgqXrc6+WWW9FA3nZf4xIjP/gZTGOg== X-Received: by 2002:a17:902:8bc3:: with SMTP id r3-v6mr35485173plo.218.1539231222357; Wed, 10 Oct 2018 21:13:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV63eARtPjZt9Mm/5YDAxcz64VuIRwhrEA/DX757hRiHV9aAF4V1xSUydu9hjbN91TS947mBq X-Received: by 2002:a17:902:8bc3:: with SMTP id r3-v6mr35485144plo.218.1539231221590; Wed, 10 Oct 2018 21:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231221; cv=none; d=google.com; s=arc-20160816; b=BwWf/2QabvBjGQ5HBd4UN0ExSD/vHGpB/a8/WxSlMyBSN3KY410Ki9TV00qLGsuoQO SVPz1OQVD8uBuXKTecbjQwu6J/wUOHVe32kvW7oBYissHkF1EsBkyVlcCAVybFHvEKXW cZiT4pUT8+QEntVsb9+eukKiGNCzcEjlmi0AIGMzEOkteYn3RdwYc/edvLtm+d2IqRJB vr0OZFRX2IBfcUS4MDIm35dNQzcAI2AeC+BgqDQNWavagV/LrhGTF64kW0qoYOSZzddd zPmsv/zMfYRpknZncZHnk/Pk54JHAGAT885sHFx0xenj6YgE7hP2HG+B//5LUBcZgWWC p6KQ== 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=/3l7N/X857KPTkSp1muxCsYvuhsKcEoEr7NE87oRJI0=; b=Q829SuYbqabvUlioa3S+Z0ovw2xQ2nNRdbA2rFtR96FO3wiXXY/myHkXRZpcqFq/EJ 6iinvodjQyasT1EUJkm+RuvZKMDUtuw4Z+HicSmmtz1TBrIujvYRsJ4Di0Ji68/A3YFT vPwaMzuFnlox/SeWzNAfEnRfWk+isqOKEvXz0kmCwYciQ/loTFs67tOzk+0HH7SAbFq8 0cvTfLwRZ6rmfUAQ7zr5ZvSmVrgte3JTaslaZOHsUjb3GCPjQTf2o7p8GPQG8uBEW/nf tYBL8R3hSOXWQv9/dz8aLyNr33T1p/B+iXAqxOooRhUkzPx0zPVcMWrKAIwhSOMR6jhf riAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=BSqSq+tr; 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 a94-v6si28662526pla.123.2018.10.10.21.13.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:41 -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=BSqSq+tr; 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 w9B49E23191454; Thu, 11 Oct 2018 04:13:39 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=/3l7N/X857KPTkSp1muxCsYvuhsKcEoEr7NE87oRJI0=; b=BSqSq+trbEleQirbu1tgM1FSk0fFdALrWymV5yUCvcDC8onpQEavsKsxUvbOqT3ky3aV Mm/zXYWW/BSOSXOMS7n1uJiEVhoD6tKE9/Xq6yweq/RzNytIEb0mjj1xNgalnGGZibuu xG9eRGAPdm8OY+ZPaAOdxsZpNQIhega+aohUa6c1PXi9/YeopMPaWPXca5WXOpymdX0c 4AyJFtBnUK6trvNj0KFTZe5ckm5qqrIe27Qy6xaOfvOfS672dpH4Y18bgIOIcl2Y1ZXo X1VB6UBlTzs8FCtUSLpMUxpQdIytUBB1O29GMuqAC7sV5lxuGu+bnG6+YMON3mRyJ6wB 8g== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnpr98yn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:39 +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 w9B4DbV5020339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:37 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 w9B4DboT011825; Thu, 11 Oct 2018 04:13:37 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:36 +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: Wed, 10 Oct 2018 21:13:35 -0700 Message-ID: <153923121518.5546.15603284343898988670.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 60cdfb576d81..b233fe019fae 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1811,6 +1811,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 Thu Oct 11 04:13:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10635843 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 45BA314DB for ; Thu, 11 Oct 2018 04:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ABF42856E for ; Thu, 11 Oct 2018 04:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DE232A63B; Thu, 11 Oct 2018 04:13: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 57EB32856E for ; Thu, 11 Oct 2018 04:13:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29BA56B027D; Thu, 11 Oct 2018 00:13:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 272296B027E; Thu, 11 Oct 2018 00:13: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 161716B027F; Thu, 11 Oct 2018 00:13:50 -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 CBDB56B027D for ; Thu, 11 Oct 2018 00:13:49 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 14-v6so6668471pfk.22 for ; Wed, 10 Oct 2018 21:13: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=4MA+USrltiYPL+iYPkMX4cBpFsmgn+VO5WqH26LIDYk=; b=pWoURdyXZy24BBqgyUbMuygSd2eUxwRNM6ZXmKuXQhaUhqdqwpCm5LK1DVpPPrdS/7 H3n0n3MxzfgQtsZS/y9D9rbFdZ1JesQTvUjNgBDB5pWPf82YP6MgzOEJTe+OwAWXlSSs OykHi3Jxqq2ftaQUWtErod3hB9Bxm1Ew+EzcflSOC3h7PR9w9xM3S4nB7aLI4wLrWMDC LynYfIPQ0FQ7WJIg59CFGSPf4c6ro8fKtrc4DAkcUuGUmNXO3czJObhJ5BFihgHxXm8Z rPEsx0C5+IJyhrQslYIcKfIgkjsFB5KpNzq1scQBDX3aiIEn0sEC4u39Q6T+CdmHBb7s 3wBg== X-Gm-Message-State: ABuFfoh9pADtRxso3RPIHyC+m5fsR2yidNuyCWLDPcZAUeDPtEovUSfP 0rQw2YSaJ6anX+0W5R/kWSk93QNwpz8yXdC9m6WnKlFBQve4mthsQdnYbXsptu9fUBXdM3CjW+0 5+hwauFS+sdfsQYclkEIfInkZUQxWj/XtJpXvHl1AXyPXX17bI9PvkD3vn5sWdtD7nw== X-Received: by 2002:a17:902:ab8a:: with SMTP id f10-v6mr36072933plr.203.1539231229493; Wed, 10 Oct 2018 21:13:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV605bFMla0DqnZFUfwHPZ0F/Jr7DhW3akdk1ZlUIIaNzuOb82h0AFkPl4nwQZp+nNjnfr0Kg X-Received: by 2002:a17:902:ab8a:: with SMTP id f10-v6mr36072886plr.203.1539231228515; Wed, 10 Oct 2018 21:13:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231228; cv=none; d=google.com; s=arc-20160816; b=C7z/6aBo7g3D8ZVr7b9c4ADNjpcd4jQ32G3i1a+C1NjHho9uapYsoSN8XOnpqyT5NW LFYtILqbLwIks/tY7H6W4NkwaDNEjEcwrtzKcRJWvWO8ZTEbR/UoaeqsmJr2/RNBBfiO xBvVe522UcBw8ygK7+HOoBrLFxDpcBnxcvyrIay3r3+xQkBDzDD/L55AvWk7DJ8pNaU2 TI0XZAMtHRpN93ZmMnZ8jfGLelBpx91xX0QMpf8VOIfd4De3XVH7k/Oq+KGTYwerxKZQ 14kiV1DD4mTcCORg75u6bN5/ifV+9e72V+ehhCsF8C/hkZ2TV+jC8YNTXAZNCLx51Xpi RT2w== 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=4MA+USrltiYPL+iYPkMX4cBpFsmgn+VO5WqH26LIDYk=; b=p4vd0eQ8zz9RqpjsCzCYBruvkfj3wiE0l2FStndaVpQwJXbQmYILwseAbLFPIik4cA /E7aPFaGQqsy5SjEoL+/ve1b/KL73yfqAwkKI6cjS01z9Yh8TjxymiSONuPUTZx9cp0z VkV7CBs2gGY1t2Re1pqFVggH6ucxp4EzHlTKozWD7bZdxhWeLzSvZ1C3wAe94E6elI0P Gs2SFlvuEvMnPpnofiEOjxQsVJuCoZXnWU+1tqzGvgFmPnXDFjewR/YjMXRsI3RkBW5n i6wdiXLBoOOSVpiVVE4tZWJEC1u1U/y9OTMI3/sPfGviNsYP6t77lapkfK3TCF5O6drX i5jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=l6xcPMe9; 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 y6-v6si21784008pge.215.2018.10.10.21.13.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:13:48 -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=l6xcPMe9; 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 w9B49AGR033341; Thu, 11 Oct 2018 04:13: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=4MA+USrltiYPL+iYPkMX4cBpFsmgn+VO5WqH26LIDYk=; b=l6xcPMe956dfiBvJcb8PoPi4MTTtSBDCvVkJL0wuwuL1dBK+0Z5WSwAjLxlY8hy2YIBQ tliiGHxH4yAcfuLYY2AbXFW1hUNRN1FRMDkqiZcE/WofjCSiQvfCh7uZQwPFW/9rryXu bdg4sgNL5Xe5HOapuLZ4QxRopUuHKzXx/Tg/1zhjrduURJOLVUedfQ7CE+edgi5VaXkd BrporvyfQ8o79BJedtY4mYfPapZjroCSF6dxqoXFfT0h1tkNG/u3SMcdjNTIQrrILoxr Huy6HuYxgxfPWP0+0zjJtA8oqO0+BJ/AXoD2JlJRc8gkDxH1XK9HGiShqFdI1jrXljWy Ag== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmfu1g0j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:46 +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 w9B4DiOQ004250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:44 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 w9B4Di6H009111; Thu, 11 Oct 2018 04:13:44 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:43 +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: Wed, 10 Oct 2018 21:13:42 -0700 Message-ID: <153923122206.5546.290608555442155698.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110039 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 b233fe019fae..bd5f8d724b13 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; @@ -1812,12 +1814,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 Thu Oct 11 04:13:49 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: 10635859 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 99CD4933 for ; Thu, 11 Oct 2018 04:14:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F5DB2856E for ; Thu, 11 Oct 2018 04:14:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73C542A63B; Thu, 11 Oct 2018 04:14: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 F31022856E for ; Thu, 11 Oct 2018 04:14:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0ABA6B027F; Thu, 11 Oct 2018 00:14:01 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DBA806B0280; Thu, 11 Oct 2018 00:14: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 CD0326B0281; Thu, 11 Oct 2018 00:14:01 -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 8F1BF6B027F for ; Thu, 11 Oct 2018 00:14:01 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id i76-v6so6746683pfk.14 for ; Wed, 10 Oct 2018 21:14: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=H7fqbZNarcHp8AoXaNeFCNJudr51tNtSEzebsw1VAEs=; b=YKoq2wQ+AYWgux1/Iw30RNMeUlt99ORBW3UA3lK6dXwe98b3G/IYoebzGHZtxkyUWQ KNf4oWG/qIyLZ4DOfBbKDZhnlUSsRQyP9l86W/sPSQKIAvOHa/gtRVTBBDknjI+H2Ott nXnNugcP7iUB4Y1cVjcFIjKMzhkfc6fWnQccn6shtncbAJTmMSKeYPLyAHKOJVPI9mq+ Efb29JTErr2z3Rf+Y9akzl9C4g4dzCh5FiibNn0LnM1KokUEd0PsjUdLmlRrgnHAKvWp KmFHZx4TqBFmTr4IHVNqtqqPc1iYrXk2lPoVumTHICWqtDr3tsdETBnMRwNZrRbyaQ3l Anng== X-Gm-Message-State: ABuFfojyx3wACkUk93KvmFAbh4kcmZNiSJ0g180FQh53socLJqAqctEu UPMRLPt6NXokEnYSkH8uiIrlUgV/krTuDdobBbOeI1v2XKKzKWLoj/LOS65HenxTjVqIvN0xpnx J1TquJHc5nEiFfoMpPIPwd8dsl0gJVeICTOC/tQMmNfCnHZV+KNSCtSCBDfkMX0ZD1A== X-Received: by 2002:a17:902:48:: with SMTP id 66-v6mr24930442pla.7.1539231241272; Wed, 10 Oct 2018 21:14:01 -0700 (PDT) X-Google-Smtp-Source: ACcGV63wXmRvA5Y5XpDkzsEi2BHCnaDclJFMD4fkLU2fQRX7GSvVgdgzlyq8L4yPPr+Qt2GnlbtZ X-Received: by 2002:a17:902:48:: with SMTP id 66-v6mr24930405pla.7.1539231240605; Wed, 10 Oct 2018 21:14:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231240; cv=none; d=google.com; s=arc-20160816; b=NemVJDTV72ubhS1L4RpauR+/7WTQMqSGbPrflaJRbELva7MbAyjxVPPBDHMRCuCzCx 5GctvuF4nQuhIGenb1X4a5Nb+RgY0Xvo+jmPzOHNKg8hV6uHqpu0D4t6cwIAgPIuxOis 2AmYKUxbgiEcSJv3fvsRuapiIBHF+hvvmOIEslx/MkD+uSSx6xR/lpKHELrZwHIkjqsf hIfuhyrBQAmkDndOqt7k3KDgirndtYDaPIjIdEIHGO/Crec1/KJbIgbJ9NQoetaY9P7B I7C3NJu3VTJ1TwiaM69jk9Ml0WQAjT3pKAZo0oTsZib1OElxJnUNHVP4rY8IU7i1s/Sf ys+g== 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=H7fqbZNarcHp8AoXaNeFCNJudr51tNtSEzebsw1VAEs=; b=gDCjkJwjQ51P2ggToR1taUILAaHx77Z3/xaITtYivIHYNSiH4wARNYBl66evYa4o38 yuno8N7IgktizSs5YKzwWMQCcAjCzDI94B0pLjJfeF/M+/3Y1mJgLOl3dN/s+R/yOfIx oaUnVKbOMIH3p+JVqHXtE79pMaCex4o7cMmyCOyE4vDoia0lWdB4udaX+KZ2lb8c5TAo kKy/5pz+n1hzYBG7zI0AlbeBcXjYGBPx2rR3NktDhfHJnaQ/+oqN8hPrB8ucc8fa0rym j1F9ZvBviaty5t6CdCJcFlGZx63YoDd6V0lQD6ByIWUt3za1HY2L3S9vl85o7Y4LnaV3 katw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=NjMca7MO; 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 d35-v6si28036824pla.116.2018.10.10.21.14.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:00 -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=NjMca7MO; 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 w9B4DwOn039315; Thu, 11 Oct 2018 04:13:58 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=H7fqbZNarcHp8AoXaNeFCNJudr51tNtSEzebsw1VAEs=; b=NjMca7MOVtqMyMDzvskzRDBYLmny1Gt9FmHLWKTZF+Yj+QDldXDEGAaGWcFg1CawLNBO 7G8Bt+QkJ9MvCJJZlNax8o9Zj7ehagZNOXtfUIh9cAmzVCuoRCva2lxYsoI3BH7RlYdt 7JSEeIlM0cE+4JnI70cwV+uYMD4NgrsSzj/PrZf/Riz82KNFt1EI9KZKSSfmSdC/OYfg W2KF8O2aDW9m9KKmRRU9T4+siGJmvlz4U7xXd/1b4CgwuU6hYCTPLTUufLyd/Rs8QILC ecMR1xQTZiAQzWVE/p2ZQ1US3AI5yZwFQTFnn7BhzkdZTVzM+0aCOFYNejwPIu0/DlOL xw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfu1g19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:58 +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 w9B4Dqtu016810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:13:52 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 w9B4Dqew012000; Thu, 11 Oct 2018 04:13:52 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:52 +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: Wed, 10 Oct 2018 21:13:49 -0700 Message-ID: <153923122899.5546.15614724337094695251.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 bd5f8d724b13..5de5d102ef4d 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 Thu Oct 11 04:13: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: 10635871 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 C0FB614DB for ; Thu, 11 Oct 2018 04:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A47F02856E for ; Thu, 11 Oct 2018 04:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982582A63B; Thu, 11 Oct 2018 04:14:09 +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 3029C2856E for ; Thu, 11 Oct 2018 04:14:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A8A456B0281; Thu, 11 Oct 2018 00:14:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A39296B0282; Thu, 11 Oct 2018 00:14:06 -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 929306B0283; Thu, 11 Oct 2018 00:14:06 -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 6166A6B0281 for ; Thu, 11 Oct 2018 00:14:06 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id i14-v6so7509238qtf.13 for ; Wed, 10 Oct 2018 21:14:06 -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=STTLsn7pukckq4Im6++gk0BvRB6owo8z7FNNDahnJsw=; b=RZsdirHc+AreDw8gNrERx/5Tb49tkGvs7QHonQScjwKngWM+iIgmwef6ufzHKYYvPI 5SbfU6Rlhp9dUhGU22W2UKO9Z/sRenpbJVXla+HvTB2Jmk9GXOlLakoCixSg2GfeS5oV wGX+POks9QNrBlBxPnGYZlKlBCabpk2BwBrrzsdTPnxIw0/WTjWlXA1kX9n+LzOg4Zc8 0kDiGPGKBfMhkCo1w5X0N/wWW0KBHSltVBxzIv4EsdKIpCu/oA4+g1xrlKobRfOMmGoc zPIIVt4nYXhH5mJl1kqbfQqgH6PzA5+ZLuLrlHi04ShN//z5I06LiQNmWaZ4+TMNtyVS gLIQ== X-Gm-Message-State: ABuFfoifSyikOTH7zGUZcATR8p5BqDYHLXIQUqgg1xtx7SDT2Ir0YWHu ujwNckwPsecnVj/9uncfXYJDV0ylZs29wqOgoG0dKkm7QZzKUFs1woh3VeGvZKvoLDPhnBfL9vP 6BfewgXuswDsOvNmvHlrCSsT8M/hiCrge4FZVYckyEiwrqhqP9DwMVouT4rUHnjrXgg== X-Received: by 2002:ae9:ef11:: with SMTP id d17-v6mr29567754qkg.80.1539231246101; Wed, 10 Oct 2018 21:14:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV61J6/oxkV+fYcfO7y4WZQqj//zfQAE/C512EkLuBNZgjq9j+0hOG2Wz+gzC81KUz0YoDqz4 X-Received: by 2002:ae9:ef11:: with SMTP id d17-v6mr29567706qkg.80.1539231244710; Wed, 10 Oct 2018 21:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231244; cv=none; d=google.com; s=arc-20160816; b=KhkQiMSNxr3VFNvhz3Iw4etk002dQJPZLN0oCNbzP5JW7bq/yds30jeWAFMy2uwe2w WigTNRZXMpLiWoEMW0y3a5ftWo+xrJhsoaYVJ/WSs4/h2VX4NipBngNKEcg9ItX5Sy1X j9a7KUMMl1etYKKiRG6HEp30nsp+ze7qj7PWXcSnru4ybUEwSrEQnA0vy4/vGB5zxOai 3O4dM7KFbRswUKk3XHB7JGJB81rMFQsjxHCGPccu9hjDDQJaTUM7OsIZ9P35/XKATpZB zEi+8JhwDC4hbqXvZU6W8amBPd46orxU9MxkY3s9bGGt9HnkWzQBLkMkhzM0KIwDDtKU M5pg== 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=STTLsn7pukckq4Im6++gk0BvRB6owo8z7FNNDahnJsw=; b=MH7tB5hv/2FsMx6y0npU+r1oZyNf2CJ+r6+ZMcSMp9k56olhwJjx7jF9EXwEUJJ8Ty 4VA5SuX099GjQxcLFBl8adKL9g1s7ETsOig05SKKKXCIymrSIYTyziwyuQNorNUuV7lD YBADNQZNOMjX98RtE4VbaGUgaxUuOt4ZnFsB1wuDMJoew0GIuRVMqLDUeYbTNRqdg49l wr/gWKR631oUDAVE0mLuSLr4f9/ZJEPMcY56lQ4S0WhxAaYGLZLDuJEVGq6pz3ben1Qo inkknDMFfJoM6nmk538MiF4JaqpzBSuWdO0yczK4fGjopNf8JC2qPzofPUBfK+5RZ5+M m1MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=KHXQKkrN; 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 w58-v6si7962845qth.63.2018.10.10.21.14.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:04 -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=KHXQKkrN; 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 w9B4E2C5058606; Thu, 11 Oct 2018 04:14:02 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=STTLsn7pukckq4Im6++gk0BvRB6owo8z7FNNDahnJsw=; b=KHXQKkrNle6m2TyD1cR6qiI+Cuyek8Pu/BM/Ju5btY5nDjwNiCNp7Ur8jkMx52nGax62 21eqqJudKODEq+POWqwfFA6RxyJkilmy2Gt3bwhlc5xcsXEO4t3FIfgL/z8QfQa5Kx07 tIpvKXKxhurJdyHbjAamfIjzPItvi9y1UOKeCvELIVmU3ow6PylsAk9LXEmbjLfx2u10 5zRRZ1KmkD/VTPqFZ8H97AqYHs75caruTXEqJmQjtppEVakVWmPJk6vfm+MU/dvBGrZj hYRiXL5dJGPZw6aBVBXS/C8kgKGU1VNdFD102wZPO4SQoPvGycSYc6JUKHll+DwCY4JN zQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mxn0q9dy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:01 +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 w9B4E0nJ021812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:00 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4DxCj009358; Thu, 11 Oct 2018 04:14:00 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:13:59 +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: Wed, 10 Oct 2018 21:13:57 -0700 Message-ID: <153923123724.5546.1792508853693528650.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 5de5d102ef4d..461acd5fcc4a 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); @@ -1837,12 +1841,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; @@ -1875,19 +1879,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); @@ -1993,10 +1997,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) @@ -2045,7 +2050,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 Thu Oct 11 04:14: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: 10635885 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 84C1F17E1 for ; Thu, 11 Oct 2018 04:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ADE32A61E for ; Thu, 11 Oct 2018 04:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F6EF2A63D; Thu, 11 Oct 2018 04:14:14 +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 B72822A61E for ; Thu, 11 Oct 2018 04:14:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C2956B0283; Thu, 11 Oct 2018 00:14:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 298786B0284; Thu, 11 Oct 2018 00:14:12 -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 187E16B0285; Thu, 11 Oct 2018 00:14:12 -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 E3C7A6B0283 for ; Thu, 11 Oct 2018 00:14:11 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id x7-v6so7466783qtb.6 for ; Wed, 10 Oct 2018 21:14:11 -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=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=gmwHKmAacHsmC1/Cs6ojxU7uP6Ptna1Yzgpqqu9YqLzjwdNjIIS45lKYXI7oMgJNmg Jlw320kprR/txZ8ws4IPajaAkcORYXdjp6yYg055mLx4WzJDCvpHw6z8iUer+8vbbBEN XA9ROQl6zh7pVwe2SyIkItiqBkEywMge/lPp2cqXVcXO/Rd6d96m9ZbylYysacIQS3j7 cSEp697hPFv8AFZE9zWr4ODrW8srix9yv3iHE1Ne5EfQjcjia0159ab+ZAPuAGMRBaUi Z4dgM/3dlKnyYDfEnivLlKZG8B+CJEYOgs0TFDihIQ9iKsDUcRb1w7YS/JQQt/ImXYje ZU9g== X-Gm-Message-State: ABuFfojQsDeNHH05USnl+vkiAP3b62SpxeiS8zaSnzR9umWm9wqIL7pX UFq7MjvfTSNR2kklGQ51PAckrit7b6bpfbdQlEjYHAMbGULF7begA6jtaXQWsgtbKiFP/CAUPPP N2O+2ofsViDn2KBg9U7YEQl9bsFJgLq1yBFQ/YQvNYFrgrRrsY+1v4HwNcjC4tBzguQ== X-Received: by 2002:aed:2684:: with SMTP id q4-v6mr15459264qtd.293.1539231251696; Wed, 10 Oct 2018 21:14:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YkWdUbt8ZlzEAdBRgIvOwjBEGGAmauLqKj0tfaGY51JjG8PbrSnlKxtWNOdBTPEftUT4h X-Received: by 2002:aed:2684:: with SMTP id q4-v6mr15459246qtd.293.1539231251020; Wed, 10 Oct 2018 21:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231250; cv=none; d=google.com; s=arc-20160816; b=uKHwVe9GJ3x/5+TEp0vwO4vK1CU5Ggzt+kUcDddTUtwVvXAKQH698lL2R/O7K+Mu5l RamCer3oZK/1kdIjt3f4pYs24oMGWxsAjABCSqCjlCZq4qPlBBlFlDFUw/c1I5I5/dZ8 OX7rFHQ07N9cZWbVX1ChE+S2q8kiFs1QcqLGDRVIm3E3POg/fBM+WwxYOZq57BuxUkG9 dUaAmQ4BFPTeEyUS8na+NH7ETMm32XA6JvW3yld4ZhwohYy4wdASUcEulOAZL4+DKYVy osnX+E109VY24j/Y45LK09l+XQQj7W0rZRZJ2AB0KPLnYBEKdChcGCJhN0FlGQ3xqnok RRTA== 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=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=ExRvrreKcAUOuMPD+Gu0iA+ag1Ion6Qhkjpq8UPbvcOLt8OGZcQtSGsQUKCQq6bGDB NNstaTGtE4BZUmaRnlFpL28KOqJIFtG5CmfhRQdNi0nxF/lNS63e0HMWKXx2J0q8ldZY NyuX18gw2vLYReOCMhMFmDahlGpfnckGnLCPdEOQyEXdqoJtgL5vZC+S12bQ3q142GJb IrYxD/Zc4D4E+dRxiQkKL8jzgSpi4Bwx+0+xr8fbZYmP5JwqbqIPWnQ7iRUUifCyUPHm 87p5+Wbf/HO/uJyXLJ7KVB0zlRuR4+BCXVbwShKwQ/zk5nvGex9j9vycA6SdgTQpdIwH i16A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=i+Q1M5T6; 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 r32si7257585qvr.26.2018.10.10.21.14.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:10 -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=i+Q1M5T6; 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 w9B4DtIa058434; Thu, 11 Oct 2018 04:14: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=6zkqFIHE464xGeFIjlnSQ0eGfTVJtdWHbkt73gVdvYU=; b=i+Q1M5T6Mn5ZmCTgcOBaOBeVnm9AgNGfQLns5tfzLLLX9w/rks8wTraMv07Pqh8TZHCv i9eF4FG2sG9iboD4b2chmN8CV+MSeXTpGzJsJDd/8ZuPkw5P7amaaX3pHJYxLbyv1kD8 uLDDH1CL/yCqvlFNLGh+SC7BUXjm/bcxvbZLc/ebvg8MIdmZV6foP7ar6uq2UxhwDSEf 3p5sISkV6r1zjOUExu8sZ/YwmH1wfMys8W//qdy/p2sRIdnGqZcK6axM8B1egEOtCD55 L/4X7aFzY8eCD66hSwujgiXvMfn2GUu2RdLJy0lO0gkvIFVZxgpPkyPKLzmn9wuK3by/ Og== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0q9dyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:08 +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 w9B4E7aj017979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:07 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4E62u010901; Thu, 11 Oct 2018 04:14:06 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:06 +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: Wed, 10 Oct 2018 21:14:05 -0700 Message-ID: <153923124495.5546.2993415758308396845.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 461acd5fcc4a..b3f8b4a2bdfc 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1842,12 +1842,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)) @@ -1878,7 +1881,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; @@ -1889,12 +1892,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 Thu Oct 11 04:14: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: 10635899 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 EFB8A933 for ; Thu, 11 Oct 2018 04:14:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6BFE2856E for ; Thu, 11 Oct 2018 04:14:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2502A651; Thu, 11 Oct 2018 04:14:21 +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 5462A2856E for ; Thu, 11 Oct 2018 04:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2255D6B0286; Thu, 11 Oct 2018 00:14:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1FB856B0287; Thu, 11 Oct 2018 00:14:20 -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 0ED4F6B0288; Thu, 11 Oct 2018 00:14:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id C11C76B0286 for ; Thu, 11 Oct 2018 00:14:19 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id f17-v6so5388508plr.1 for ; Wed, 10 Oct 2018 21:14:19 -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=OdIc8YLsa80Ux9kQHDzThidqDdLKImkUmlD2xgowl3w=; b=QpK10zRmHmfpW5i6iW1b3BvTown22zP2QRf7VNvK3Ud0WSUTWsrW8ctWj63L18fMJo YVwEN4QBtQVFEhocBjU1t0/q5cWjUBhpqCrTNlq4Nt5RenBFEvPKqmZB+1UcBWc+qCa1 IWAXZvy/5wNerqkE7tnX0hHBXvozUO80l/gOKcc5ECQZaD0Gc0jdV/KGTk70ZrjUCI1G Tpfi8u61ytSwj3xyY9jyRVw1oqGna9EGzYghlY7gou1zA+KTraqXS/AXxJ+4e7efVia8 uXIZZn61ZpwumY39YexuKE2UdL67AlXco5RALqMSw3JGyOyVqFsQuk1GZJcaaTB+JH0E UomA== X-Gm-Message-State: ABuFfog4grHceNFMUaL2RYoZaPkgs3o+EeuSjh/pvv4MzJ1qaLt4dBHv QCGf4JHT/fHilWzYwA/NCt6krATbawxjNWGIwItguPWW+LenieiKJnZtIwDkQkN2Rx3tLtgsLUm Un+trIP9l5qpVEZSBPjkfM8psDBo93tVAHX6+bNtAo5Vy4ZvDA4UCgsj3hgs9Ct2K9Q== X-Received: by 2002:a62:12c9:: with SMTP id 70-v6mr37777061pfs.140.1539231259475; Wed, 10 Oct 2018 21:14:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV63dwnyzNTqIqkbpRYGBe6iDTwshVB6+tSA7DUZyNR7VTTKIqJAeu3PGEQwRaDCrJHwvLhIc X-Received: by 2002:a62:12c9:: with SMTP id 70-v6mr37777034pfs.140.1539231258700; Wed, 10 Oct 2018 21:14:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231258; cv=none; d=google.com; s=arc-20160816; b=n90w4qfG5fUZr0gdrGotyFqdLCtVjLvY28GexeDCIhgCVm4HHHdqQ1WLbBvIh5toVs 6kC6WJSkbotfrClZRVu180Z08Wh/xBzbdGFfIoNi3gbYtTzun5kQUtOuaqX2HSPEqSgr BB52jsAcdANqtNBmCkcnqQ9zuUZIXP9w0PoRta8A1mSLSc7xWC6MhpgdPR581f4ZpzN9 AaUuSEJ13kTTxwX/dpxHt7ZCZliZUhrbYMQq2C0WAM0Nshrapaz0gVrIJnqvXJIStmr7 3bclu8TV31sVbPK9E0m8gNAhVYEhoOAOOZKhivUIrKAm8WO5KGjQ/M+KyWZO1cTgCFbX thLA== 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=OdIc8YLsa80Ux9kQHDzThidqDdLKImkUmlD2xgowl3w=; b=rLLxJfoV6J9WjKr7iG9gPsN79zPbBQd/XpN6uappHzql5cEtn+qSE0e6qVz464fJSW 1PGWaUVTSMT9fRBT6Gq/LaWRH/1CCpDQ6bMfGv7JfDeS0x7shlN4R6WB3My8ZCqR4Ylb h28Owswm7Pde7akg3dxQ5Ytt61+bXRKMIDNHU9cQzObc3SePOa4LwzvAKYYi2l8dTDuK xDAPm8CbY0Ln2ZlVR6r3jYj+MtKyx4o0twrnJ0+4LzroLmaU9Avo2qcxDavviDIdIw7N PMq/OhYMHTMXiiKMkyFPTYuVOoMG1Gmmpe8gP4tiOGRVvTTeBPeJzelteYMR7ViszNau 26wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="Aifj+4/I"; 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 q76-v6si26422338pfa.91.2018.10.10.21.14.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:18 -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="Aifj+4/I"; 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 w9B4E2VE002940; Thu, 11 Oct 2018 04:14:16 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=OdIc8YLsa80Ux9kQHDzThidqDdLKImkUmlD2xgowl3w=; b=Aifj+4/IfYPh0+MHesC1MXbBCLW1Bn2Ygjyn1PR9oG7TYXIBvcu0t4roXhXGQ4JkODUF FEh4eQSCLLjkuGI3L/VucmP2L9Y/Pw/wC1f1LrCwryCJcvK7fLQ09a/8spT7rg/cG0ip z36LqU5LTuZxfNzhHedCjSoHg7iFIENwmfyaRjEE90cwaqxdM4iPWHNPzJSVjBb61I1e 9OpjkfzNeYTdFEx75TAJN2AOGCYPRvJS6MdqdiP13gTtAE0+vONKYoZWsW58P+qWIk65 uHB+sM0AehRY84lh0l5mf/zHW3ErGPIJvJFNADX43N4ANvOJKOHAwcqCL80RjXj9wOJW Nw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnpr9922-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:16 +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 w9B4EFI0018439 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:15 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4EEAm030112; Thu, 11 Oct 2018 04:14:14 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:13 +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: Wed, 10 Oct 2018 21:14:11 -0700 Message-ID: <153923125177.5546.7735584725952507239.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=524 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 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 b3f8b4a2bdfc..a360274b0cdc 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -2004,10 +2004,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; @@ -2038,7 +2040,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); @@ -2106,7 +2108,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 Thu Oct 11 04:14:19 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: 10635913 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 31C9B933 for ; Thu, 11 Oct 2018 04:14:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 173132856E for ; Thu, 11 Oct 2018 04:14:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B1AF2A63B; Thu, 11 Oct 2018 04:14:28 +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 73C7C2856E for ; Thu, 11 Oct 2018 04:14:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D96A96B0288; Thu, 11 Oct 2018 00:14:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D7B7B6B0289; Thu, 11 Oct 2018 00:14:25 -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 C5DDE6B028A; Thu, 11 Oct 2018 00:14:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id 881D66B0288 for ; Thu, 11 Oct 2018 00:14:25 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id f4-v6so6747223pff.2 for ; Wed, 10 Oct 2018 21:14:25 -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=Pd8cr54zNEs+WF7tjnnato3jT3tm205KBd6EXZJEY5k=; b=WgMKGo9Ou03FChW8yGz1sEVwYOnB0X0jDjaJozNS8s2xaV/y3DFdCEn/Aza+Fee0XQ lbxQ42fOF7j18sj+z4jlcBP3i8uh3zkbK0G5xufUK2OXOiDipRP6Fl1lOXwajfOsBC+p KMu3DTkGqwrrPpgjm9WpVV7oYY44GNvo/SE5pcV+rWsUlpuc7JbUxB+2wZIkI2jWAC0H /OEmCv53DGAn0SmMlFzOkceIyujWsEMdq19IbtDs4CQqlhkKLKgw45Z2RrRuTpj0fStl zQflJdYYk5MBPd4+U21+7Y24g/Pd69GpnLMKsBvcMTQFytD7BTQMGFY1O6+7wWZbkG7C Ze4g== X-Gm-Message-State: ABuFfoj1GrZ4lUP+yyZBeJcO8w6MKr14GtdFFpoZu6JxoKOGNIw9lo8G UH66m0H5h7rHNYLX7ZfIky9LKCznumGsV6QvOGYmxdl2xrtEwfNyRgFFKPENJod62WWFyxmL1EL f2nCQY+sAuq4qi1A3F0AwWBTJtIgBBZIjn9LIk0/edDA9IzMXylHySJcLRfE3rG9flw== X-Received: by 2002:a63:2323:: with SMTP id j35-v6mr32477385pgj.337.1539231265228; Wed, 10 Oct 2018 21:14:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV61cbAYj/X5kFDdK6ZViF5gwh4E4shLpYSPxquabGjzZVhvRtHdHGYhVmuBqfEmpMZNP/llw X-Received: by 2002:a63:2323:: with SMTP id j35-v6mr32477353pgj.337.1539231264459; Wed, 10 Oct 2018 21:14:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231264; cv=none; d=google.com; s=arc-20160816; b=ROwHGY3NM52Lz3MFGEnjuMzreMhJEKCFX8g/f68oSdE4kAbNbUERJBxpbBHUdnOlFx jBaeED9EOIQZ3PPbC1+MQVx82z84hUbuYXsRCW2lQ3SYEShVQm0oWMtj8/jyawxcZzdS YZu7jlzotn1RFSuH4BNsEn2G9ip+Rg3AoisuhxRfiA8is5U9lV6OX80jT2n6mlRpA+Pw /8AmCMCMt0epM8p3nAn50MRh5+KfRAJOVi3I7cUwFJH9eHfT1qbM62qqunKFOEIz49qg D1B062sMFZSYyfP/niKAiOh56R99p3/pmGUh4iR1V9YOMith1xAZSczCajWylPOf2HS8 YdPQ== 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=Pd8cr54zNEs+WF7tjnnato3jT3tm205KBd6EXZJEY5k=; b=a7rXUFB032DC7gyEMQ2h1EuKq9BgP60VFMW7P8kal/qX/aYVxqeilfLLZSP251LcUl olvSD+vneZZ4D4nLh6Om1DzeOJ72sVrmpJ9aBOVm65BMuk8/0f6Y2AwJXwaQkMCHEPdl TlxsgSdqeZt+MMIE/V/Riokt3omYeT6yW+SrATLD+rr20rvt02j82u28FqM9J+1MPzuM wYBBYWHDP66X77jSATqu7Ak9Q+C0cHMEOwGZvPg90EgXebPFDLmxG5D6FGgf1yHQp9Kx 2BunckehKtp49HEMUxX0XGRuABeT+oyR/IswjK2qrrhyhpX+l9Q4Uli/X9f7mxEBrvXJ WRIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=O8yDALxk; 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 u12-v6si27737269pfd.66.2018.10.10.21.14.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:24 -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=O8yDALxk; 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 w9B4E0X7058531; Thu, 11 Oct 2018 04:14: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=Pd8cr54zNEs+WF7tjnnato3jT3tm205KBd6EXZJEY5k=; b=O8yDALxkaTyT+1594tU7Ji50GpimTVudbldgfwOB0ziIewCzlWr5IBKeeWp6oVkRRp7q 0NOkLV1t011Whf+l1Jn9WsynC3EQkjVt/5EGA8Y+2zPLdgslH0ur4VK5Wwg1Cr3jJ1aR xAiPdBjaX/yRrqKi+bgvf+mWiJXM1zd7RRRP4kTpsEXywf/ntYWTg87U0X6EFZBHIOrI GujyMMIiWMkjSaOBqf/4kTOjZGZ9HBJzh4CQ0Cp3n3FaPDIEFna05bfV8EFk7x4Uancc 2FSqBz4x9lxtj3A+uO70KhT9DFpAbkgWw4/PehsZ43SiZ2yeOkXcyZKtHofQvc4lPIyv ag== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0q9e0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:21 +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 w9B4ELv8018731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:21 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4ELCT012159; Thu, 11 Oct 2018 04:14:21 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:20 +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: Wed, 10 Oct 2018 21:14:19 -0700 Message-ID: <153923125910.5546.5091507666171734847.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 a360274b0cdc..6ec908f9a69b 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. */ @@ -1849,7 +1852,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 Thu Oct 11 04:14:26 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: 10635931 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 3470614DB for ; Thu, 11 Oct 2018 04:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 182F42787C for ; Thu, 11 Oct 2018 04:14:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C97F2A61E; Thu, 11 Oct 2018 04:14: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 78D152787C for ; Thu, 11 Oct 2018 04:14:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 707166B028C; Thu, 11 Oct 2018 00:14:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6B6886B028D; Thu, 11 Oct 2018 00:14: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 5CD896B028E; Thu, 11 Oct 2018 00:14:44 -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 1EA5C6B028C for ; Thu, 11 Oct 2018 00:14:44 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id z12-v6so6710116pfl.17 for ; Wed, 10 Oct 2018 21:14: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=9Oy/QAfur+gc2YE69PqaCVfOP0qAmnW7K6awiLQrXfA=; b=SJ/6f0K8050w0eOjXwhdFJCRFqgpeLe6CBIcKsZadIWTntBqDhIgs38fnSwV7vX0sM z+Q5/lBPwRMHyLSpbYJKsGOyzqmZEwHa4JcK4/dig181l6ZFDv6OVZMNeNeLjj0Zg24S ZIMgad5CgCkQsDp6gj8h4yEVBkuxvLYEWy6worg21mo8iE9iFoB0ss0W9fHdxiWIh++D b4mTalgKWSZdjGiV8d61pfkFqVQoCWLgmE85aYlfTZxjwVK4rmCuooIHmEoth7LyW6Nd lZDrOkz6wNHKz3t+pl+Lj+ogc6PHtBd2P/cUDEQto36yVYnJRZ/m9IoFUs1qzl58ThBr Xd2g== X-Gm-Message-State: ABuFfohmRDGw8RW+0V2TirWKJZ4UUY4zi49elfVRzS5OrtZA++GGobAx ft0/BPAXkrNs5AKOsOlmIzSG7kDdtdlZ2x2XLLzkYbZy3SdiAPvMsuIDZ9+ptGARI2r2Xz3/5gE Av+4rIyxsyEYec5Y8jKoXSK+mrB0yh7AjCx3QbVKLHKD6mXoHmE7oK0mYupkYOhOPRw== X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr32034936pgf.186.1539231283794; Wed, 10 Oct 2018 21:14:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV611zHyLbT8gdkwEFAJu7C9AYrOXICLdNRdAUDBVE2ukcNtozSAerQvx9uZJJurhXcyuaqG0 X-Received: by 2002:a63:a119:: with SMTP id b25-v6mr32034919pgf.186.1539231283053; Wed, 10 Oct 2018 21:14:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231283; cv=none; d=google.com; s=arc-20160816; b=M+LyDBVyZBiXGfyhmsq05dhRvZiw4yL3scSZLSQwp0sCOJlkyGU+XFL4Wbj/EF5K+H +jgDvluaOGWH2wSK71FKITr7hpBUUfeznjUKDnQVNRwGg2fv6JmWM752JhXRs612KzQA VVFyvC6p29OMEHwubqiSGQ32/OVGuqj5LCKH4Q0A1wsi/gXALw4fkz2XkBBlTEDPMSfO mN8cAZ6AvFph8vfFy92MKYLxB/l44Jc3QlKWiTJhe9/EnQzfyKdtDm4w7r2ezICiKt2Z UWPB4IimS0qGSNsSMLr0troucWaiu/RKCZPXBitLFfTe9dAbkgaR8H5mt1eDuZiyWatj lMtw== 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=9Oy/QAfur+gc2YE69PqaCVfOP0qAmnW7K6awiLQrXfA=; b=dPxonadO9Ouqr4PNMlHDAIjxGaFDEizm81uPmw3HhrliOYyyIFGIyNEQETodHOZq9o wpNspHQzokZYVquYxhevFEl1Ifl6Dz/7soDTdD1+Z3rM1geukevIiMv5rFZqrYV7HXoD 4NJ60Z9d5vWjOvzWegNuqKYySKwRlAfMoHGZ39INWBuDcY2kgavQ/MRi0TwTAId1lXQ6 Ilo8r0WTonnz4UqBepfBuD3Qao/fhG7sI1FyNq5k19o3wzrl2iY4E+uhvxAvILXB5sPO fT74goD90O0Zwuq0EFLnHHaXVw9+6DohaMi1HED+cb2gs1DXchM2oUnfYQy+M/Rj0TK3 CKSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=tY1B9peQ; 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 h1-v6si23212124pgs.493.2018.10.10.21.14.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14: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=tY1B9peQ; 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 w9B4EMt7039889; Thu, 11 Oct 2018 04:14:40 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=9Oy/QAfur+gc2YE69PqaCVfOP0qAmnW7K6awiLQrXfA=; b=tY1B9peQVMRogGaH1hofNx9pVnXzlmoAlr1e2PjJNUFT233d0dx649aDxbwo518aDv45 xpKRckn1VOw02g+SjcyB8TRgr8roiTglMglJXVUieXPGZ9lN+nKIvpFDRiT+bKbRFLTy zytVpYdiAuu6toXlN59H0STXxO78Yu0KNf6phYAiAq3zB0BZuOfTsIRFa2j90E92Pdvr 9THTd97zSxzGlRRJrClDFHZUT9y1d4cWGzY7guhmS0r/7d7ukEwFdh12e7JyGNpWF2C2 oxFOW0BmTIBRQxCtejDNQJsGIcgVSa/OygGpPedEOK8tK9Ueu+xL7g6HLykaEfqtFFBx ZQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmfu1g48-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:40 +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 w9B4EXXj007016 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:33 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4EXoG012323; Thu, 11 Oct 2018 04:14:33 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:33 +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: Wed, 10 Oct 2018 21:14:26 -0700 Message-ID: <153923126628.5546.3484461137192547927.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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.). Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 15 +++++++++------ include/linux/fs.h | 7 +++++-- mm/filemap.c | 16 ++++++++++++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 6ec908f9a69b..3713893b7e38 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; @@ -1804,16 +1805,18 @@ 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. * - * We don't support shortening requests, so we can only reject - * them. + * If possible, shorten the request instead of rejecting it. */ if (is_dedupe) ret = -EBADE; else if (pos_out + *len < i_size_read(inode_out)) ret = -EINVAL; - if (ret) - return ret; + if (ret) { + if (!(remap_flags & RFR_CAN_SHORTEN)) + return ret; + *len &= ~blkmask; + } } return 1; @@ -2112,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 Thu Oct 11 04:14: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: 10635939 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 15DD7933 for ; Thu, 11 Oct 2018 04:14:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBFEE2787C for ; Thu, 11 Oct 2018 04:14:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA8692A63D; Thu, 11 Oct 2018 04:14:48 +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 27DDB2787C for ; Thu, 11 Oct 2018 04:14:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBE136B028D; Thu, 11 Oct 2018 00:14:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D95A86B028F; Thu, 11 Oct 2018 00:14:45 -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 C37436B0290; Thu, 11 Oct 2018 00:14:45 -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 92C806B028D for ; Thu, 11 Oct 2018 00:14:45 -0400 (EDT) Received: by mail-qt1-f197.google.com with SMTP id c33-v6so7507144qta.20 for ; Wed, 10 Oct 2018 21:14:45 -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=CGsruWwZ9+5W3dIHGIHDPROMqGkFLi0bB5XpuLCATew=; b=JXw5Na2/5o+561aHwoQCLgPCVnisekxwIVusqbfjkjUhyApBvSGmb7Th7cZxFB2vVs vKjj/MNt/IXWXDPAxJOqh1ienUO3Mtn/RL8+hMbnu0Nun3MP3fjCesW1+2/jRmfszjsH xzz+7+TxFn5v8eSqk0W4c8br7IbxTt0gzQYC8OxWgesLPK/P76qbVL/TnzEdPgXe2HKs R2l8yMn2b7NOHDQEr92v+s8+aQF1+tB9IDu4fIHiuhTOrL8nRz2zjKDfi4wysPFeTOkh Clt+psbRTfbyl5a0U108irKjIyTyIhHOa/C4tXjVpcoUMCzxu42kJ/0kSL6zkWd2yOAZ sBiA== X-Gm-Message-State: ABuFfohe6JKMgRqZqoKbxf2bwmCQq+2/Ov2d/Cjj5X55daz2HTeYm4qf KucK+z5+9CjgHuu3q2UHPzxPeM+KydiCeNggWzdZ2wuFWQylyNY1UF73dITD3+O1jkvCArWKR0w Qt76uPdwfLnkeu82KmH9tNunY/dwJNY2x9q87LJoCcXMKVlvINf0F7dJr4fyAD3pZHw== X-Received: by 2002:ac8:2d9d:: with SMTP id p29-v6mr30516396qta.238.1539231285368; Wed, 10 Oct 2018 21:14:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV63hEf4RHHlAEl7THIFpWrgsP320JTcK+pTv+LfIs0mwvGC6QixROEwmTBi2otLdg3LMZn8Y X-Received: by 2002:ac8:2d9d:: with SMTP id p29-v6mr30516373qta.238.1539231284720; Wed, 10 Oct 2018 21:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231284; cv=none; d=google.com; s=arc-20160816; b=DbhIycXHYSJf3kITS0ZPpHADMdbAxNgcgAWLvT/14BRQWkfWXePEL3Hr1k3HeXijqj V0gpAQBFkiqrj2r8/4SY7p3zNVqTUnNTNgpIht2W9dsXvPVW+9UfYYTosCul8wtnB/ql EPPcPOc8GEeZx+fK4EyIAfJdIAy1CT7yBJy55aoHhAtPqjc8RjyLtBPc7GND8Xp9b0W+ mYLoyTmwud1+dy9rCao3D9LUpp0y1Lzn5RW33UlWEZC0HEuSTzB9qyEXHlgC76xKk3WW ap2kM+6Wac06sf/81mPLKYvxYab1kPCy0lEzIDR8ee0p52IKmF7+/QS2dlYX/5PeiSJs gGIg== 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=CGsruWwZ9+5W3dIHGIHDPROMqGkFLi0bB5XpuLCATew=; b=Li6kPj+2De5HplM1OBI+jmsNIaJds6OCIdkfwEfw4hyqyU1yPEteHNRU0IBgdUmLUR mFkUydpZVKRiWDzKwj1nZLfQmiv6zbRFKNlh6NpOuYg5TcNyt7lAlLhkwE7I9pfbuzet OQ1c5T/wSmbeydex3UpQogbpDs4tNnpJoW3whn7m4rTjuUcyrHVNKKhKPAZpcNmrIn/o w9aoqMBpLC4auW7ErgYB+3hUx7w0YxXYDfG9furyA2/jl/OoyZ25ghtBeig6tI34jcQn UsAZu+Ed+CpKecYNmD5uCgy0I/k5wz9xINs+JxKl8ln7FFEVo0eZRktUewCLhrjQh/OD H1fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ecbc6Tcb; 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 b16-v6si9455188qkg.77.2018.10.10.21.14.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:44 -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=ecbc6Tcb; 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 w9B4DspG039247; Thu, 11 Oct 2018 04:14: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=CGsruWwZ9+5W3dIHGIHDPROMqGkFLi0bB5XpuLCATew=; b=ecbc6Tcb7OPd+hWU3biSHU9mkSLvXPg74eN4LedTOBjCOpHSv6lbejqBn+xGQo2TtszC MZRw0wpLnrqy9M1wZzEpdYSxfqxaVso7ni+77nUdyI0el0cHOUOaULFQmJbA1BefQPbg OqKR6PM1eQbRaOqjKAj0N0mo4iY7EVHWZawrwYoieGOq5YwyUPVfTXiQySI9N+aERS0D TkfhKG0Zra/aXEzXFj87q9kaGpPNzDq/gOdqOZJHICH4kInFs9Te2LwC4z/+8iNfyFiV 3oYddk8m/72IeQlww7jilfSYbxDYs1TQ4sjWZwTUPPzDWcxM5410+DL8hgjEy4KEoZDB ig== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfu1g4a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:41 +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 w9B4EepS024243 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:40 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4Eeqr009582; Thu, 11 Oct 2018 04:14:40 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:40 +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: Wed, 10 Oct 2018 21:14:38 -0700 Message-ID: <153923127846.5546.7509528220834177005.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=626 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 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 --- 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 3713893b7e38..c88a443d9eb2 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 Thu Oct 11 04:14: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: 10635957 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 01E9A14DB for ; Thu, 11 Oct 2018 04:15:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D94452856E for ; Thu, 11 Oct 2018 04:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC79B2A61E; Thu, 11 Oct 2018 04:14: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 A12572787C for ; Thu, 11 Oct 2018 04:14:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DA746B028F; Thu, 11 Oct 2018 00:14:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 88B8F6B0291; Thu, 11 Oct 2018 00:14: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 77AFB6B0292; Thu, 11 Oct 2018 00:14:57 -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 518746B028F for ; Thu, 11 Oct 2018 00:14:57 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id l6-v6so7390713qtc.12 for ; Wed, 10 Oct 2018 21:14: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=6z2yUjh+q93KiATMr1nC1rDHarlM3lLqQ0gvNkngREw=; b=j32S3iJcRU82LUZNbaMT/YVN0Sa0v7BNxZWZZU7PMjQ9hZ6JzkWBnUwkkkx7HIecHb f2bbBoh2V7kXodFf2MKw0Ci9QugLCzU9KZLAVbQv/Apewv/PLvYMgXhGN3p5jrd/A72O QxlUbKdmbGcgl9nrhkrBxX8dDeaXuyIXvpcTzHygSjpcJO0pyR/POQOGdJm658LiglGv F7o2WuAuU2mhRZG5e4Bgk4fI1TyNtESuz7Zi9YAfzwG2isIxQMA3+2qTCvru3M8R4Gtg 6GGvakyn/n1AQVPPrFwRVZKVYprwo5hHFsNOHFfJU/ohzm5k7l4a4M6GtecEgP0rukAk cVmw== X-Gm-Message-State: ABuFfohag6XRkuiT6gDsMd/CgGUPD3I9//+Wu7uHMuY+q9K053wdEK2P 9MGHjIZw1ljPRjhWKQ5G4ohwVMF+XGPCL4he5parW85VZ7HEBWp/P6gbfFGs4Yl28XOBfRFNB3y VRlauJiehwQPk0dz3ilQm+ltxlc4JXC0kuJE/g1zBs9uXdx+62xtZiUWWn0ZcmaQogw== X-Received: by 2002:a37:4a96:: with SMTP id x144-v6mr29624493qka.112.1539231297061; Wed, 10 Oct 2018 21:14:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63jK4OsNVQfss9jKjb65hEisKbMzWKPB3iaeEAR1emAkZfaGZU6hZq6Kr8zKRdJ517UgVOi X-Received: by 2002:a37:4a96:: with SMTP id x144-v6mr29624460qka.112.1539231296330; Wed, 10 Oct 2018 21:14:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231296; cv=none; d=google.com; s=arc-20160816; b=vjjDy7x48QRpMx0etrEmbqr42jtuwSgyJK1OIDdW6pKFIReQ6a+ElJFa3KEU4wUnJ+ Pjm5do62R3OjHVqr6Llufd6GEG6DUwNn3o045KlWwD3w0rKyx2pFShzDcb/UN1x3XP4e /NYsJxdebKlZDehQTgV0X+nTkQNsLb8rmj40Eq5v/ticMGq+NHkcs0NVMzr9Ha4tuORT +yLcc386YVVuCm9sJgXDCJOIm/sukXrVpk5IqckUUHYru5C5wS1PpHOfLQ/2jhmnBFDt TrWCdOKviA2u7BMMUOqZwMJipvhs56jeKWBF1IdCzm0gYeFXiVpEyjO5hxu1zMuGps+V 8pCQ== 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=6z2yUjh+q93KiATMr1nC1rDHarlM3lLqQ0gvNkngREw=; b=r9uxYKVF/ATNclwAFjl681tY2NPmZasH38wbo7GDWtipE78J+2+nzndcBuOF1acI+x 19rKncU/1ex9fIVyuz4qSYnZlFGjH8iLWuCTYJ48X1DMcAKE/QYZyscXIqO48ecujFEl 3eSbmfzb6hAqa3yQeMyK4iV0vRBTrOpRVJQuh4AJxwKxtihcF9gBY53rd+nHjqSZYzPz aSW6IWzpaE7+eQ6JEzJx7j2XLyQ6kA/SKIr3WJlKnvEZulkOMB/mhcAGFD+JUB2KlCUZ eLRhXO/gehG+a8XEK2CWkbqh759lW8XDNt9cVS97iUIhU/3ObJ/dv6WbhtTE/l3nqB5d RlAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=DSN55RLa; 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 t31-v6si6476780qtd.113.2018.10.10.21.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:56 -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=DSN55RLa; 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 w9B4EbPT040075; Thu, 11 Oct 2018 04:14:53 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=6z2yUjh+q93KiATMr1nC1rDHarlM3lLqQ0gvNkngREw=; b=DSN55RLarYQzdGroznkeUhqhRr4VMMStZ9qOiqpyUhkeqXYT1G6XrKzRGcYMDOUrhUuq ZyzQD3aUoeLVk2OsgVMpjh0ONTn9gUqrpHTcKZvYO8i7WIQgN98bT5bFurz3/7RvZ1n4 sVWGQOdXmoHEz++G5oeZ03vhMLaBxmCEaOxPIMMRWTWwHzNDNUau8jw29gIlzth3goDt pXnVKgQykN2NyHeVuAoKwvI88yf8Fc9wBwWnkqe4vFnBM2/mgu1o3qEiWeqh4gR1CJCE KpM1s81WEdPwSIqwVWQR3g6yiUIKlFyskQ5Ku5xgFZOJzQ0qNgCxinItIjEUTh036HRA Xw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmfu1g56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:53 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4El7w024822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:47 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4ElOM030326; Thu, 11 Oct 2018 04:14:47 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:46 +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: Wed, 10 Oct 2018 21:14:45 -0700 Message-ID: <153923128529.5546.6430455638279784448.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 c88a443d9eb2..de055cb9c5ae 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)); + 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 Thu Oct 11 04:14:52 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: 10635965 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 C7DCB14DB for ; Thu, 11 Oct 2018 04:15:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABF492787C for ; Thu, 11 Oct 2018 04:15:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DAFC2A651; Thu, 11 Oct 2018 04:15:01 +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 38B662787C for ; Thu, 11 Oct 2018 04:15:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 38D6A6B0291; Thu, 11 Oct 2018 00:14:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2C4A56B0293; Thu, 11 Oct 2018 00:14:58 -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 0E8F86B0294; Thu, 11 Oct 2018 00:14:58 -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 D6F176B0291 for ; Thu, 11 Oct 2018 00:14:57 -0400 (EDT) Received: by mail-qt1-f200.google.com with SMTP id q6-v6so7525792qtb.14 for ; Wed, 10 Oct 2018 21:14: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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=JYo5XfUoSdmrO4aplsd0OfBFlzyg2Va/WN/KxQZR3zyxvYtbR957Moe6l1pdSAkTne +/V3q1uEU47TAudWGr1rNL8U1sofZiocqzb9vU5wLOw2QkmRIQRWqyLA8zDZp+Yt9bYF EL4lIxuFNs/IOBG/Fymit8vudMYux3Xfi6X0T21hfcBLCNWEHnEkb2WP7AZvbsGWK5Me z4UZLQR7wpqL+FBa5Hwz6wGUbhpjepRJH2DP8oDw7VUDG1ziz9hYAN8zbUbUkvKt5bk0 mdLAENjpQnl834y9eu6AO9e+Q7h25FbdOK3RHFsOCsNyS2simZTo/WNj8B7FLi/rQv1P QoWQ== X-Gm-Message-State: ABuFfohyZlehvVTBZeUbOfQP7FhBSF7Kzs/WgpLeZXp80AeJXfvMajCw EAFQd7La3MUtRGO5UeFp8Yfrm1OpwKishtZZU3le78EUDQADSvYo4iKabEWNxcyhM4ScSZ1DDJM XE2EQXZafinJGDiB9ieR818ca9E0doH+TZcHPoZMRtBaDuOJJBtY+4Xh3RNc54ENnqA== X-Received: by 2002:a37:6d41:: with SMTP id i62-v6mr29755889qkc.237.1539231297602; Wed, 10 Oct 2018 21:14:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV60op91TqlhtTFMr2Ao7yA4uku+TE4bZdk0qAbxXmWsiqyYFgfuzkdVLBk6HsAnRl36y9sK/ X-Received: by 2002:a37:6d41:: with SMTP id i62-v6mr29755868qkc.237.1539231297140; Wed, 10 Oct 2018 21:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231297; cv=none; d=google.com; s=arc-20160816; b=09CRSc6c8gb6LsWOfrQdsi6IGF0c25/Py1HeGVIKKNaNLHBUvXnRggacicJHuWDhg6 lIikX43fWugnIu/bpFx0BLdSu+5yUYl6QP7WEesLI3OO5EmOrNyOT9Y2br87neT+BTKK VZOOBxdngmV3MlYfZYJ1+lck+2aavWhHEvMa8Ces2hlGP142n+Jz95BxYBJnYDjvcKp0 8fiST78viNOxGZskXnIbw81oPgWwkIqLlreAIwwVY1dQ4V1jQdESC6qSib/98wdp9wnL F2sKM7vBUCFf65wTNqNjsW1kpXfTme5qL2qvlQjT3okanBxFk1sgwoYUc3ag3EA2IMhu jukw== 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=Ih2utQdq3mfN0pf1xIXoq0DQ0gpSwYxcRF5ekitN6zappa49+Bb3cvrx7055A5F6tz GYy5brDNogrOI8TYmohJDoKtfdlt2C1uMVezbpxUkjw+2B7npknrSpQKn/QdZah1oWY6 +/Jq3mvxNRgBwllRXtieeVRVlZPty/OiUFPBn9G9ykLHXE8cdeVNm/JmWusDDE42gCiF 4J/Jrc/gB4b97jmB+slSGsM00+n4ROPGtMiV527Z80aoMEn4g+sZncHuw6hhvS9C3VBc 7pprRQjBzx+sbbeMtn6vvo+UmcfE9vqSOLDH/8gMsY3lWiw5nnHRXWRAGlD1SshNvzYI T/DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=xGaN7Sot; 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 v2-v6si4722246qth.252.2018.10.10.21.14.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:14:57 -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=xGaN7Sot; 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 w9B4DtIa058441; Thu, 11 Oct 2018 04:14:56 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=xGaN7Sot9eJSZUxta0zU0Bt60mUrF03IKbyv2HZJwdYA7pKV14F89yvoC4tavXoDMgPA odiZSHJ3IBy64p+JAuSqLitC0xWewGehvj5ai3rkrfgtegXoXXaUZviPAn1+73vK132N QAmFcU1Yqoh4XHJo3mp+bz7L9oL7tswxdm1eHCy3M34fAP8QYfm0yfuh4YObUvHhfqKz q5CwuOdGlTm7PIwEr9ElYoigY8lEMGV1dY3snvwXYUuzWoXAGOlT1jCQ5FL6tf+1fFvZ 8qxyzM+owOYcf2xYCPolmEW+HcnFbPqkaFG4PUCQ6voTjPB9C8hhh4/q1Ol55wN4hfjJ gg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q9e2t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:56 +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 w9B4EsWi008174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:14:54 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4Es1k009726; Thu, 11 Oct 2018 04:14:54 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:14:53 +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: Wed, 10 Oct 2018 21:14:52 -0700 Message-ID: <153923129210.5546.9940179804812552182.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=800 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 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 Thu Oct 11 04:14:59 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: 10635983 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 EBE3E933 for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1C362787C for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C581E2A63B; Thu, 11 Oct 2018 04:15:05 +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 69C082787C for ; Thu, 11 Oct 2018 04:15:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D963B6B0293; Thu, 11 Oct 2018 00:15:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D45FE6B0295; Thu, 11 Oct 2018 00:15:03 -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 C36A86B0296; Thu, 11 Oct 2018 00:15:03 -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 944536B0293 for ; Thu, 11 Oct 2018 00:15:03 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id q6-v6so7525946qtb.14 for ; Wed, 10 Oct 2018 21:15:03 -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=kCwHYwLtWx2SpGoO6XacmN4mhC8pBcTxjpb71QrymNTablRzDOsZnHNwtW0cbcyYN1 MuqFvDcq8TtY4PKENZiEmEYmSfriV9WCDw8BWnuFhZPBM0on7gI/N3Ubd5Qs5FAQ4lyv k6OgM7KusDnZvcfZaScE4zLaRC47+aa2w5f+bKPenkoZbxxE1lt4ygUoQCYN2wT0K8Vk RVK0V+XTqqGRk33xgYA4bvc9hK09d/9F0vtxYJpcnEBLXZx7gTBFKXwhI93N+76MxDC0 c/jYaa/Elsn9jIBgZ8PD8Th5+ZlizUEBvAtpuaXsxJISXjJBtzd3lkszOmdGjqrmDLxu bRUw== X-Gm-Message-State: ABuFfoiFr6T1UPneizyvYeJ5kCJNFq1MWPsL5Zu9spgYoTuCz0IXsH1o wrgMRkOuyjX3NzyAmmBz2ihMBxHa9Lo5rSkmKwRJNUveJ45COMFI1IOXHKpqCCJqni5dv6ZnklP SSGth8YGOCRXxLN+2RsxyfHs/G3VhXfkPYV41L3BoIP51Z5IPTftVmnh8Bolq/UPBAA== X-Received: by 2002:ac8:5548:: with SMTP id o8-v6mr16186217qtr.283.1539231303321; Wed, 10 Oct 2018 21:15:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV60TAPgF/02e/uw3EpCxLxc71O4aD7BIshyBMYpDd5rnNlTtEm80lJAsLfubXkyJE4W27AgG X-Received: by 2002:ac8:5548:: with SMTP id o8-v6mr16186190qtr.283.1539231302865; Wed, 10 Oct 2018 21:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231302; cv=none; d=google.com; s=arc-20160816; b=oCAX5LjOyRajOWJiCe75g8W5upwQ9NMVoLNNr7gKszagyDP4t2z0ybtNdZV8a4fkBl w8frE0n1cH+njdO5+oTN6BHna0E2vSjk+L/Zx4FMOCek49Wn1xUW0MEPhmwzuQkKBkzG TYLylX6vEYL0dLbbgx58ZocKUDi+ZXpBU0E4q7fiWNbVdGUkxh4AkxU/bW5fS/yydKq1 4/pa1nrgxIOd+4vIYzCMseM6RoM3ieZbSIc+J1aCCvngcKoE6f2pVxRcWDo9U1lnGh0T fkQEVm9wM+wNTUfS6YYz1tS1C+fr/7rgTXOzPZB5GZ7vEI2cXBSDYMtiVYjge1+tyxAn ctzQ== 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=KGQyHXZQ2Bq1GusU5HhTK2FgMsX6u5U+B98F9Es63W8BlvO7ufYLPGWXTwScJNEvtj 2RfUXURdtp+VSbNOWz7XDOgu5HT7+5LLy8p+F/gzcEfHZ5yXMJY8iaIyw+LaywTi3ow6 xU41PLFuky7aZtmQIXB30+VPhAdi8BRw2UAxHn6gsg0gxwQVA/aZkNRiZO5Ivd8+73Ei XkGje2oViJpJ5atv3XWh5hO19UembQKiTxiP7mxn5vjvl3qHM1M9/LVhgos0cfWUL/pD iuXkln2CEl00s08iaEJv+REABa7F2u7znCf8Box1MtSqYu5Z71mq9ySNJm4DbHaqsJi0 guxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oqCDDeqg; 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 h1-v6si5143925qkj.159.2018.10.10.21.15.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15:02 -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=oqCDDeqg; 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 w9B4Dte0058453; Thu, 11 Oct 2018 04:15: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=pleIHv/sRduv8+OkUOJBlq1ti8nIBaJ9AMLqPSF5HiA=; b=oqCDDeqgvBTu19DRen40L0j00QC3X+PzEg08HfGvtV4MrpnTqSGjecGy7V2qOe0ImjeM zhdZ/sBWzQccLz7eII7FrEWxTRRpTYzd1ZeVxR4DbFm5K6nQDGVw/ef5K5Xi+UC0xKgb BtrXlqrwtvuL+XdJ2DOXMSJyNXx/4fuJR5ouBOE40E9fpW+QzPtRPJY39FvM4vyU9m9d 7uEiy6A8AM3m5lX/P5Os7A6MrQ5NrvshFRgRvGbnTY7+b20RUriDEDsvhQSYF7xdnN3U WxTg4dGwtg38VogxgsA0pnBEtd1cIcod03VjIgUlrXogqgymW0+4Ptt3CjBSjsQ1cye+ AA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0q9e3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4F1He020909 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:01 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9B4F0K1009814; Thu, 11 Oct 2018 04:15:00 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:00 +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: Wed, 10 Oct 2018 21:14:59 -0700 Message-ID: <153923129911.5546.12641183057086407273.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 Thu Oct 11 04:15: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: 10635997 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 46EFE933 for ; Thu, 11 Oct 2018 04:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BFCF2787C for ; Thu, 11 Oct 2018 04:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 202792A63B; Thu, 11 Oct 2018 04:15: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 75B942787C for ; Thu, 11 Oct 2018 04:15:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 558D66B0295; Thu, 11 Oct 2018 00:15:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 507B26B0297; Thu, 11 Oct 2018 00:15: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 3A9A46B0298; Thu, 11 Oct 2018 00:15:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id 0F9F56B0295 for ; Thu, 11 Oct 2018 00:15:16 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id p73-v6so7158984qkp.2 for ; Wed, 10 Oct 2018 21:15: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=hIKY9nQiwanIV2qW41QCGIkoUmtm4iR8ODVGIx3BUpQ=; b=RGQ+/QLLIcVJ+SlP6ctNg2MpRurX7rd7oacI1n5jhVhpMUwkoIpXw53Qol95SRbWnl RfAwvKjbb0S1thAOn5ssZyhjNDcRl/3TzyK68SRs4GP7kxaERwiC7j25JGTqgxdk6urT IytEizRZjVLcU+vMMJPjCpB5SSgcE3KiIhO6e04A30U/a2reFbJ69RsczLDLhKawXAU0 A22BS0x9vmQWq4uohE+KWZxisZ/1oa7/F/NZ72izPm++M81j4PzELNc7DAByqOHsbxa0 aVJcfqqbyS4d570sKh2v78+n0KAaffAwTcm4ugwfr040sOotRV+VJmpGGkvoQd5MkHX0 xfGg== X-Gm-Message-State: ABuFfoj/x+YWBegFQ7KfSmIB/rrQTYpeNfh36FZx+2DLXz1Bc6I8uwNc jmTgEEhgPJmInSpZuwtjInsXq7t/H5UH3yx/T/ABV7aIs+fc/iJJY6p5OQwgN3yaXnATwoizW6/ WFyw1LX6kuufyxKuQMd1yIoid+XGW4R3iH6fsdfNxYhYHJVIosxXJ2j5QEzcX7KUNKw== X-Received: by 2002:a37:2307:: with SMTP id j7-v6mr29442556qkj.146.1539231315779; Wed, 10 Oct 2018 21:15:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV6058xLsCuV3cDrVLYkxiJY/G0C0z2kGtfY4NfhyxRaqEv4iIZVUHpbnmh8yddDNsvwVknwo X-Received: by 2002:a37:2307:: with SMTP id j7-v6mr29442504qkj.146.1539231314881; Wed, 10 Oct 2018 21:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231314; cv=none; d=google.com; s=arc-20160816; b=BBrbruNbErUFGg1mjmbg60ACxnwr1dzsAgI7YKuLslhDqOaZxmbSk2emAyhhsJdOtV 8wGjdCyh1X/u2wiPRWsvySau5y3dvXFFZvJBPbUJo1460JtK0r4M5eCSHswsyvqEO/wN La4oWZzlWYpkBNkAoLKpEPyBj382m5wLYOHfmqcSiWRUmmyFpOhB8/30Art5R+EQ95mG p2S15ltRTQ34G1hYIeQTryH11Er0ZTnN7wReuFJZ5SDqc2pr77YLhzlgLKAIytNuDJEK 9llifjiCLDOCc9f7/8aRw5IpA8CGVtNtHvyMXJhwLAn1PLoaJq3oG5nZy6J9A3hc0DZs qSvw== 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=mVqlXELGqbnTSP1dHkFLMEO8J8tr7+NxkuiUlatyMqHQeDbjCdkT7JhbAgubqTSVNa ZEhpWjVE5WBuZ+y9Qd4ISJBBGxRzKnu1190fQXrGHGaVsjdDyrLD6q926VNrFGTUIz2d PHKBuWuPEciFCgHLe1bNauRYBsWnJ8up+HWEUtyxIImebbtlpBoP+ReNNFiYRMvt6YEL s5zqPKBNSPUmKXMBu0MWYMIoB2Qg+qQbUuHY3cMWyaPNYauFtqp/XBx1nxmTXqWKKg4D d23vKJlpWwTzsPQwN2/WAxa0enWaiMR4fjSrN95Iw26d4BQgCjCbxwfSABXcVeSmo3Vv U1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=BEAJbF3L; 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 q7-v6si4297723qvl.23.2018.10.10.21.15.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15:14 -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=BEAJbF3L; 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 w9B4E72C058661; Thu, 11 Oct 2018 04:15: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=hIKY9nQiwanIV2qW41QCGIkoUmtm4iR8ODVGIx3BUpQ=; b=BEAJbF3LZF7G0qIWbqPrxfD/H9eU+P3dXaeGcA5c9nK0Z5D8MpkV6puoQN1Q38E9arf9 jzQ7JKe74wGs1S26ww6a/n5zP3zQXfGwaDPxzTtP2Wsim4JWaH5J6DR36oKkxQU4OK+9 1wpMPwuEWyfcA689NqeHcicVZ/FzQjC3OBLN9wevOmNy5s83x8ZmQX0XqDfbGtxFjw1g 8TYj555rrbYe6uzNObMB4RcNsVJSIugyEx/NtADHJ99tmfSpB/YUPmJGPCfW8or6H2qx 4U8rxKPp4jqix9TRjM64fWvxSp/5LqB8HezHiIi/MeFMotNn6njE7FeI+kWkKaREL5mf Gg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0q9e4y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4F88c021599 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:08 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 w9B4F7tg030517; Thu, 11 Oct 2018 04:15:07 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:07 +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: Wed, 10 Oct 2018 21:15:05 -0700 Message-ID: <153923130590.5546.14411534641774672905.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 Thu Oct 11 04:15: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: 10635999 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 A6AE114DB for ; Thu, 11 Oct 2018 04:15:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C6BF2787C for ; Thu, 11 Oct 2018 04:15:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FC4E2A63B; Thu, 11 Oct 2018 04:15:20 +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 22C412787C for ; Thu, 11 Oct 2018 04:15:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA7406B0297; Thu, 11 Oct 2018 00:15:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E7F2E6B0299; Thu, 11 Oct 2018 00:15: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 CADD16B029A; Thu, 11 Oct 2018 00:15:17 -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 9B1216B0297 for ; Thu, 11 Oct 2018 00:15:17 -0400 (EDT) Received: by mail-qk1-f198.google.com with SMTP id d200-v6so6968941qkc.22 for ; Wed, 10 Oct 2018 21:15: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=sLm37K838DbrX4foFOXuwPIkr6fqDHiTbK9qF0yrdDY=; b=VNkDf3D7wIQbEkXn8N15X3gp7SB0QLduKpr0yyKSkRRJQ6hsHlW4T4kuuXM+eBRYe9 /zLgUXboL4LJ16caVP0KLsAM1wgoC2gxw3w3hqmzJfkKxC5ncrUd+DZp9+Ir3BummkGa VJGV8DDRU2VasZSHQZPoGSsaiciU6uTp997k+xEimdxtjkgL/QT3hKKXhCEY9vk/FMtn 94PkMXR7gKQkzGg0sD92zrGmDrIefLh9T/YtQoRWcilFJLT/9XESHsDnOEVTMxpi/DHg b06Ny70Y1x+SVYjxwUdnI1sOpZzdH0qsSRp9p5YdPUWoM1CIESsZjv4tkkisGhzvBo9k Qojg== X-Gm-Message-State: ABuFfojOAdZY5NguyGiFQLCnY78XMpfUxRkSdsNqAeMWFHDs0Vu/kAm3 uwXgoJ46de/kgc3v5jf3uOzeReq1GtpsVz3g2TF6NcnV5fDMgmfs/Kfef2p0xbQqjkMQDlHc+xt ThjcdHKA5buWcLTAWAOZrH967P2oyjlwkL/Kgc0YJNT5jrTd1U+66YD3I4Pv9qTDK4w== X-Received: by 2002:a0c:9925:: with SMTP id h34-v6mr4262192qvd.81.1539231317401; Wed, 10 Oct 2018 21:15:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV62aNMJEFXV0MqUvh8lLZfqqslUUmrMnt+mviahlyAG48nbHqLopQ3fvLm+stHIiOg5GR1Jx X-Received: by 2002:a0c:9925:: with SMTP id h34-v6mr4262167qvd.81.1539231316882; Wed, 10 Oct 2018 21:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231316; cv=none; d=google.com; s=arc-20160816; b=Z/A3k9r8dUyrKNQXFhgh+4Ki5WRrfuzv2IpS0apAkf5/T6rUI8+Tp41LnIIW5mkL7u 99WV853bwJ8zDiGQv5hkv4R2xyiLsTXYofJv9lG15T1azo9Bw8iP7nOljdilu2euBFGG ucTWQeGGEVghUHxHs9vwx9dLR8LxqYFcz+b/itG/6z2iaYMQcPThGCj3mNCOMnkx6nSX Z9rM7d8mfnMwPXxqPwIg09o2htjaCj41t7loEqQ577qoVIrxYc8wa/VbvJC3MZSxDHWi Ftq/4DA4TlufNyHWtOfKbeTtpddyEzZKBh0cA/rooXXabbhcNkGwtgfbK2J8hoy9DB71 DCGA== 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=sLm37K838DbrX4foFOXuwPIkr6fqDHiTbK9qF0yrdDY=; b=EJx0AHwPJZ+I91mMZWy0leftv5XfB08in+k82xerK7oy+cEtaApnoRBQClnozEmS9+ 77bEg4njRoCt0+5UKwlnEoHrXR7B5Zq01sc0UpMQXiecG/x89pptt8Yf3USGPjhLfGlj HlQjg/QJ9mqzzsN8R4/8JfqQB9QJqnpc36ScBvYjpXT8E5mVl6PuhJVh+pSn9XP47VZt BSUm7lj5QiN3wjj7JAPhZc/bddRSh5ap6ijgbqdeoSStcyaC6YjVgluOtwPjMXQPrG/h xXGR+vbamKrvlMQWtgy8tJ1gELrQWH8+5/JMryJRkku8ZM8mLX1rpOfdn6ngze6MHwde dUww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=S0YPvBIE; 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 q15-v6si3749480qte.344.2018.10.10.21.15.16 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15:16 -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=S0YPvBIE; 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 w9B4DsK2039252; Thu, 11 Oct 2018 04:15:15 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=sLm37K838DbrX4foFOXuwPIkr6fqDHiTbK9qF0yrdDY=; b=S0YPvBIEyLp+mNjZNdos2llGM8Dcc5zWE/mXWtbp5UuCIDeUos5IjB93sIarATZxC6gm fwkXl6utrh1wmG0csh9K82bqsx45tFgA0QqTDMFVjGYonMPnO8hQhTmrSczz8GpBuz0i waLP6wKZceSif2Ed8Q64o8QNWVPqY8EbTCDf6je2lNe4I9qTbkcFPyptpFQZWZoAWPpO 34ZVuRWkrln84tgXQRuZGx2l7uLM0o7MW50xROxLRTBc0vaaOj1MsHb0iovDuNNN+G/b CygSKIUp41wZRfaXvtmFcy0fNzXBob9bx5ClOJQAhChA42HKqa5L6QNf0IiUS/gnbLWr KQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmfu1g7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:15 +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 w9B4FERT009621 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:14 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4FEcd012638; Thu, 11 Oct 2018 04:15:14 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:14 +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, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Wed, 10 Oct 2018 21:15:12 -0700 Message-ID: <153923131273.5546.6811645962559576222.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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=869 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810110040 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 Thu Oct 11 04:15:19 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: 10636029 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 BE3FB933 for ; Thu, 11 Oct 2018 04:15:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A35632787C for ; Thu, 11 Oct 2018 04:15:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 976B82A61E; Thu, 11 Oct 2018 04:15:32 +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 0E67A2A63B for ; Thu, 11 Oct 2018 04:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A0396B0299; Thu, 11 Oct 2018 00:15:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 04DB86B029B; Thu, 11 Oct 2018 00:15:30 -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 DE5236B029C; Thu, 11 Oct 2018 00:15:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by kanga.kvack.org (Postfix) with ESMTP id A9ADF6B0299 for ; Thu, 11 Oct 2018 00:15:30 -0400 (EDT) Received: by mail-qk1-f200.google.com with SMTP id d200-v6so6969350qkc.22 for ; Wed, 10 Oct 2018 21:15:30 -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=8E8puuvfkew1Gv1w0ptnyI/ykA53ICgvrrj5w/bTXjY=; b=PbdHpeeTXrCpIMj+CozYGVWjqVr+XkRFZh0wvp1ZldQhoUdyF5Bp0C2EDrId1ollFJ C/a13p14izZzSvx6O8SOK2tUC7IsFQAyMJBpZUfNKTkl2rsUktFinavRylFzl30m/brq xPs5I7N21y2ILIVswlR+zxS9v3wZM4gd3IR/copj7YehstBkbFaS3oRJ0jw8x+zMEj99 T24Ms8R8a+gjUArFQpK9VrToIGcoSE2aMsOni5afRzdS9jb4OFyKQJWc6xXmw2WDuv8y 6hK4BxLk8LJlzzberemlKC3Tdh0dsNIPh9BGVUpCY9gHTyxoyoD/CJ3hJHcfCaEo8aoj ywNg== X-Gm-Message-State: ABuFfoikL8JL99crXxvtofquH0DqnEGBaxyZVOLzEqueji7fDVoY+FRV 1pPH1rHpoTIVTtd2xpYhTgkCxcciIKa2cJKf0n/jJBcCrtAmT+S8UdHd5usLSDwYcHSCmEwGS3H uFE7CpGIHHc367aotUFjoivSC1xWMlxkas61Z1TCdZ5sNpuVGiP7LN0Ib1l9ePsN9ZQ== X-Received: by 2002:aed:3f08:: with SMTP id p8-v6mr29936633qtf.185.1539231330477; Wed, 10 Oct 2018 21:15:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV60r8GFWIeAY57wLHA2QHhFTmJmTshc6a5Bsf0lHsZHw1vqCq8naI75qTpY10/EPaVHriA8s X-Received: by 2002:aed:3f08:: with SMTP id p8-v6mr29936594qtf.185.1539231329877; Wed, 10 Oct 2018 21:15:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231329; cv=none; d=google.com; s=arc-20160816; b=F46NL5y94BC5tIhYU497tsB5HTNwVzM9BcoZd2+ZqpCsqx2k61QkUwAJ+NNsggC/hr 9maQ9QUX4fZQNh30DEk1SyrE5EceEcbSpuMXzVk7xb+geItuLict+0VmALXvkv3YC8JH fXM2/b0nbppPmnbpMMUErJMNDKqL0DYjGUFHmM5y+U48bNxYVc1KwY3VsqbwzDp1wDQY pPxhZCxrMc2nT4MH01NiWN+eWCnppYo7gjR/tME/VVqllI8CeMi4Yoa3t3SWY5kGmIga cWNaVeS4Jg6KAOZnK9TB9xzuUjLCjkUF2bPodtjhUJ9hAXMdNHuSdUQG0Dv1TnY8f957 J1DA== 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=8E8puuvfkew1Gv1w0ptnyI/ykA53ICgvrrj5w/bTXjY=; b=u0X1ojuBd+AE9YS+mGfPXGfF0RgAKc+x1TULDIhlgxvUEQpHTBp5D7gTmwaPbGgS00 waSVcGd9RGO8WWPRw3P3zakZd/feIkVNGFOVbLaNHizzdy82zXMoJxqK8qlXFaUjoMP7 EZHZvrsq1b63NJElIT4OfALWMBVutPijVWPhblWZOgr6tznP3NbMz7qv1HtjpDIE7wJj 9mh4nYcO5ft35G4JKJrD33FSCw1/uYXILxvXzf3ZIGNq7rcha/K7AXgFqgfUwpGMyEuT LiT+b8587f3i554i3MFgDqS8wvr61NPSD/bfY8Hpazv8C10oo4cE58rAspVXXkad4ZXw nGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=KbyvslqU; 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 w198-v6si12864052qkb.168.2018.10.10.21.15.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15:29 -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=KbyvslqU; 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 w9B4E1DO039425; Thu, 11 Oct 2018 04:15: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=8E8puuvfkew1Gv1w0ptnyI/ykA53ICgvrrj5w/bTXjY=; b=KbyvslqUqTtRk/Zf8mKvhGTL1xO3UwGmNlzmvzJnnPhtgy0I0s3/v1Fzf8kfxvTWGa7A Fx0q33hy3x98ufYU+cUIOoILdBN4SNqcHug2EEGz+N/kpzdU/9HaYYLObKPJXg1hLjLT Fy19D2S5wtCnHiNwtT9t3w/KA/w/SFz7PYY0MXWUA8Pr+HoKQU5xrmrlCRKaRid0LBpN GEIEeRgyhUzwntaeX2gGssynu74xKGP84xFcC2OzdPmbhsWg8EYVrXFBsVoxbA5XEbjb BdxCA8t+0cXlU64bg3cQf6ev+B18wzszcG24fkVkue2AUsuiOnLIH0YzIUxNbEENkEBP WA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmfu1g7v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15: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 w9B4FMCV022731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:22 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9B4FLdT011619; Thu, 11 Oct 2018 04:15:21 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:21 +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: Wed, 10 Oct 2018 21:15:19 -0700 Message-ID: <153923131946.5546.5209673711907751253.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 | 19 ++++++++++++++----- fs/xfs/xfs_reflink.h | 2 +- 3 files changed, 16 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..12a1fe92454e 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, 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 = 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 += 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,9 @@ 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, remapped = 0; xfs_extlen_t cowextsize; - ssize_t ret; + int ret; if (!xfs_sb_version_hasreflink(&mp->m_sb)) return -EOPNOTSUPP; @@ -1424,11 +1427,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); + &remapped, pos_out + len); + remapped = min_t(int64_t, len, XFS_FSB_TO_B(mp, remapped)); if (ret) goto out_unlock; @@ -1451,7 +1460,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 > 0 ? remapped : 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 Thu Oct 11 04:15:26 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: 10636033 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 57F6416B1 for ; Thu, 11 Oct 2018 04:15:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC702A61E for ; Thu, 11 Oct 2018 04:15:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 321BE2A651; Thu, 11 Oct 2018 04:15:35 +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 BE6512A61E for ; Thu, 11 Oct 2018 04:15:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6BA686B029B; Thu, 11 Oct 2018 00:15:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 641606B029C; Thu, 11 Oct 2018 00:15: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 4E2A36B029E; Thu, 11 Oct 2018 00:15:31 -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 1AE346B029C for ; Thu, 11 Oct 2018 00:15:31 -0400 (EDT) Received: by mail-qt1-f198.google.com with SMTP id k21-v6so7361759qtj.23 for ; Wed, 10 Oct 2018 21:15: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=GtHOAv/QF0y7KDuBC7HZvhRe0zfnNWbV0kEOmXhecBY=; b=VLzUsGDJrk0+oBrxJNZDvK2oWgJgZ4xgbcP8HLUc+m63VV3B482ykYeqrSY21o35lV c2WJELv8MnaQJWR1EtQWasvlVVjhM8J+S0rzA/2d7zDpUrb5kX5VnFiq4C8qxVfY74Qd JyapHQJeD2k//Ecuh7StqgJe7FjLA6sFZmudvH4Zeg68r4Q1RHINakoGeUpRxcrNOuW+ kS307u1sW8NGIuUr3EeFrSVspuHeCOfHHLGSBa44j+AGCnwUwz3P2PZqV6D1Ksk5ipPS nW2+FaEprgVoXjtI02c/vdTKIoDMpb4ka+NdnN1CMrU8qpg1cnjd4DhNwczhufJ+M5IB fX3w== X-Gm-Message-State: ABuFfoiCwGzHCco560NzNDYL9WSj0Kb7qMoJuL8F8zgSmYKaP+jqL+5T Ic7QI+RxbKF+z/bw0oOOPuApH2QYTAAplF4kLOOo9hv36Ql04V+gCk4MVi4c5MbjfszrLUwfROD ufQUPLkCPggca9cEKoSXYfLaoBdB/vK8L06UugyGGTwYs7rCYwXSjhhZWnTONh0WL5w== X-Received: by 2002:a0c:b04b:: with SMTP id l11-v6mr29834244qvc.139.1539231330893; Wed, 10 Oct 2018 21:15:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sUNMEldl3gfzgD4jiFovFtw7RZGZizwxjws5BxbGnqPmzISwILwvllaAAUDzgWIU2nShp X-Received: by 2002:a0c:b04b:: with SMTP id l11-v6mr29834226qvc.139.1539231330476; Wed, 10 Oct 2018 21:15:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539231330; cv=none; d=google.com; s=arc-20160816; b=wt/OgrOVATJI32RJ649UY+MByL+/WOvbtko1jkP/Q1er5wtEVfJEGzcwdhz7wMCToB X3zhIkIFdZc8DXIOFIMMZFs9c4/Rm8VOPCtUw+1GOjK0qBJjSIw3cU0JeFWCPYsiD95O +k7d3fHtpeE4frBj+Cj3j9g+k26Eln1NQznd9/7FoDt+zbptCvVgmPsK9Zs8PyESpykg r31MfsZnVKWyV60MGhZTNSn0S6QE6wPaiFqJux5YNLzBJ4VkEFhNp5ps+VQvdLYuXywx eCEOgxtQK83rupqhFyGqYxU5fKbbPPRRnqDeZMf1pzOxS7iFHkxCjC4AscE6RzPLqwOb KXiw== 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=GtHOAv/QF0y7KDuBC7HZvhRe0zfnNWbV0kEOmXhecBY=; b=oC3FQAFZfsfCLuGUseLV9qM5KVYnjd2M1+I9pbqcg65Q5gsTmYfLNlYW2C4c5G06Tg dLfoOX/jWTQzlbyC5K4+XRCBn0QHV3w6GvePfbYlVV2gVLgAVJX5ikn61fDO32WQ73kD DhlgYeG5xSIZxAPjqfxGtqQ4V8g/XnLf9YpwphtoOemo3g3JYsSCGrJev8kZ29/Hj35L FHSXxzCXqSlCn/XwkhXsWulcJ6rLd8XcZQp658rmLp+3xyYEJFvPVcDXeBeAOCeKJF/N 8rZYKH+8iVzCIy2xeqhw3v7IBWM8JzchVwbXpeQmLqhfebfmA3jE4ls67SYgF7ea2uRl m8AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=jiaPMQek; 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 t29-v6si2029355qvc.47.2018.10.10.21.15.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Oct 2018 21:15: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=jiaPMQek; 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 w9B4DsHP002714; Thu, 11 Oct 2018 04:15:29 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=GtHOAv/QF0y7KDuBC7HZvhRe0zfnNWbV0kEOmXhecBY=; b=jiaPMQekkirLHjdnXajmGlZYaH6AI90VeT9yzBHvNtkNFPFeOMCGxenmXX8If2+YeXQX QrOaiy1nnibe1CJ9gHV/8yR/ibiw2qh4XqgJtD9k5H2qu+pD8jvp+dpmsAV2B1FRWlZt 5CLbIyDNqL+lhms66iPnQ29ghqBQJtqR9URBwyVgSjGHKeTUCjRDZouV3Za/mNOX2vom 7tzCyt1CqRTl8OrrJaocWA7rGoZGR2Uk4xMgVcJ5Yf64Yfsc5Zw4wmkhVlh7e0KQEQ5J pcNS4WJtPiT863q3yPY5PseJfOvUocfrdP+3CBejMb/wtQm9vY9U6L3WQgnrfFuGzut/ nA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnpr996g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:29 +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 w9B4FSHv023078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Oct 2018 04:15:28 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 w9B4FS0j010121; Thu, 11 Oct 2018 04:15:28 GMT Received: from localhost (/10.159.132.249) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 11 Oct 2018 04:15:27 +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, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Wed, 10 Oct 2018 21:15:26 -0700 Message-ID: <153923132645.5546.97372209609060021.stgit@magnolia> In-Reply-To: <153923113649.5546.9840926895953408273.stgit@magnolia> References: <153923113649.5546.9840926895953408273.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9042 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-1810110040 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 12a1fe92454e..4450443f1148 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)