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