From patchwork Tue Oct 16 03:20:48 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: 10643011 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 49DB43B73 for ; Tue, 16 Oct 2018 03:20:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3576428F69 for ; Tue, 16 Oct 2018 03:20:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2924429AF7; Tue, 16 Oct 2018 03:20: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 B5F9A28F69 for ; Tue, 16 Oct 2018 03:20:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 046FE6B028E; Mon, 15 Oct 2018 23:20:54 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F15BE6B0290; Mon, 15 Oct 2018 23:20:53 -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 DB6AE6B0291; Mon, 15 Oct 2018 23:20:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id 8E7496B028E for ; Mon, 15 Oct 2018 23:20:53 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id z8-v6so16073834pgp.20 for ; Mon, 15 Oct 2018 20:20:53 -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=XaJCcJb52edg+aC8VnKgwcIySPxyOilGPHSlrKf5LPY=; b=cE7tMTXUGd4Glq3TTjc1jd9/Ead8bsoln2zPBpI4A6aAOgmlvQJOxdVis4tY2sQiKi a5IVoXseRB3VXkddoCn/pvAGUGTMHK4nbCZfaypENw6bOgLlxMvszCYbxQaKcRhdvA6S aZNGIHycvIwJ+N+4bckorW8CcFh5+SIPgaPtKHVjJFy96pMnT6kepXtVJYa+NrsPseVW 0gLPoKqWbUCKdBGamfM+vzBSZo4iFnYnSjbQQ9qyV/rmsGABuD1SZ41yZahKB7Fp7N2z mLz1IAUFj5l1wdSIpetAQrkeHOT4/nTobdlnfklkm2TtkpD192OGfsS1qo7lQ+mof99l zKMw== X-Gm-Message-State: ABuFfohkmZ/urPZhUGSqC2D05xil76h+A0EhW/BwyglJ52dBWfuAeOZQ rpLbs1wsTL4ES2wRsu6qNbQLVbDyaGBpdVKQ3XSGCL1vpEO8ycimqgJpEimHIqEdS6s3uTXwjS6 qCOOXOZSmzAaBuVXgYJoDEBMrNibK/tDSPFxLZBLJeMPS9FkyJBcZwb+XFTvbrYzRkA== X-Received: by 2002:a17:902:2805:: with SMTP id e5-v6mr19777788plb.169.1539660053256; Mon, 15 Oct 2018 20:20:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV60E2fJp7KpW2Tyr1IvaCWnXXMPFSZTk3o5AgYnPcLS8xaTRVaP5oXew/X+iLJAbbpE2H6NO X-Received: by 2002:a17:902:2805:: with SMTP id e5-v6mr19777766plb.169.1539660052650; Mon, 15 Oct 2018 20:20:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539660052; cv=none; d=google.com; s=arc-20160816; b=bXBtd2erF3dpqwWJLzu0UNsU3Ang9kmIv49I86asCABdsclo6TF9gKOOtXnsU9PtZ+ z/I5mNSIa4VtRifcBdQ+++DAwjaGb9lLGRFfSVzUoqrKInt8xD7j105k35RweNwfVEVR UqndTR/l371lO3PayL65sN97iGiOTFiiKaN7OBQaE8W7litYINwTnuiigalOgT75UytE PEWXubCf6+GaZCQNkiccuehWxR4P6s4EqUbn5J2te8Ex+IzRLjMgwrvCDQowu7I3jCAz Vvv6FgFgjU16STQgZ4wVw4mvQS+pbqX2Se4yy/YzTyu7r2TuVBwCenPIsBM5EMkgLGEq do/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=XaJCcJb52edg+aC8VnKgwcIySPxyOilGPHSlrKf5LPY=; b=qrTYUbGKj/HCUAXIlPsgj2xGVzaYOWLAcocSVOiPr/NQnstHQp9CRBI+Dw2ITwC4xG w31q4YYnEzHCOMBP/2btTb9X5uwxmI6cp9qsQjljdVMTmLrpKrF/CV7Q33ctLSXjae4B SpLdIyS3JtaGDtIt3QZrDzuO0YW09ZDFrHSMM7JX2Dm6Y8qcVLX3+1VVSaTu9PKxoosP SownepimGumS4JSHoQoaGhplSDWVzEGYlGePuZCO9YDNXIf7ZvyMJdpiQz19iJrfr8wr WE5Xdv7QbX7RI/fGD4N/I+spLHfTmrg3m/9Mt8KcKlB08jqeJB46oCsokIDaiQGuAZon aDLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=M9aJJC01; 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 p4-v6si12152616plr.364.2018.10.15.20.20.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:20:52 -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=M9aJJC01; 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 w9G3Josa051805; Tue, 16 Oct 2018 03:20: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=XaJCcJb52edg+aC8VnKgwcIySPxyOilGPHSlrKf5LPY=; b=M9aJJC01Tp0zKMm3aGPrIymayT3/oGG8aOw26Q0M4e4DEK7vxr+C1dNV8a4IIDYGwIIi 73fE7Y5dtB9kyI9S1StHRq4Sjt9fxomsFtCT+0Ht6jO5HY4+DmCLmcASG5llF1uHcySb QBhvyQmOoB7X7DOwuQZHtEZQdpNs9hS9AgyiFiH2bPXpSGQswfy2L80wcwY4MaZTX0gx ZXcvbFa48F2OK+E88GXXZFNlvxv2qm0kDeGtLP6WwShpaMTkCQVJbAadXd34AA/W2Ysl S0YK4gwPZdTV5v7vHD22j3NAhnrdwWsP/QxerdGr+C414ZQRxelypj0KnkeycLv1ebD2 kQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384tx2ae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:51 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3KpjV030152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:51 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 w9G3KoTr012714; Tue, 16 Oct 2018 03:20:50 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:20:50 -0700 Subject: [PATCH 24/26] xfs: fix pagecache truncation prior to reflink From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Mon, 15 Oct 2018 20:20:48 -0700 Message-ID: <153966004854.3607.15187709452762502392.stgit@magnolia> In-Reply-To: <153965939489.1256.7400115244528045860.stgit@magnolia> References: <153965939489.1256.7400115244528045860.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9047 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=896 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160028 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Christoph Hellwig --- 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 9b1ea42c81d1..e8e86646bb4b 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1369,8 +1369,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); return 1; out_unlock: