From patchwork Sun Oct 21 16:17: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: 10651171 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 9841713A9 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F80287C0 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AA7B287C6; Sun, 21 Oct 2018 16:17:30 +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 1F4A2287C0 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 019386B026B; Sun, 21 Oct 2018 12:17:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F0B786B0280; Sun, 21 Oct 2018 12:17:28 -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 DFAAD6B0282; Sun, 21 Oct 2018 12:17:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by kanga.kvack.org (Postfix) with ESMTP id B34006B026B for ; Sun, 21 Oct 2018 12:17:28 -0400 (EDT) Received: by mail-yb1-f199.google.com with SMTP id t15-v6so23324583ybl.20 for ; Sun, 21 Oct 2018 09:17: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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=AR4Nja+OltyQOCo75E00RidsdeyoeWH+oP/HeEUungw/CwGvH4dzQuNYCSBYASdlq4 h3lghUwGLOzajPh7Xh78E/xVZmeBcqeqanDdYHigD3pfuKxAfQ5jqzLIdvZb4r2y35ER O9/F3+UB3ZoyTs/aWhKun4dnK2/lL9CgpKvpjVzgFHP4o/N9CqObRC2vXrDGC8XVzEql YcM6jkOi39j19ZqmEn+YbHBBpnZ8tlBG4MFeXG9SHaBGh0sfTbaDfFPHX0O5CJ64MNqx cBXJPtbP4rDUM9Gr3IS4+zRbVTibb1L1ETEvR0p/1mvAPt8llXUtCLQlIi1WOi46JJK8 aMPw== X-Gm-Message-State: ABuFfoj1KoDwY137JVRIklRwJPniFIfPXOlcrOJiNik8n6Wh9kBz2IJg SSpgdGt1ycnEPKQCKRpwkA/Ces0BqpZ1H3I9E3wxs30ubJrqCQNGg8gRmI5ztB4vT8orNfqyyXu i6FuNtskrNkKIipgNeoBTl5SyHSamvdArAK2GXubNL6dNz4KzpRoroNRxVSVDHE8qvg== X-Received: by 2002:a81:8496:: with SMTP id u144-v6mr7316881ywf.266.1540138648472; Sun, 21 Oct 2018 09:17:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WHtL4XW1LibIp48ri8uiuxxp/5rT8zTLgAiKexQEdt6xGtOa5U2zLEXwXA8I1kxd5j0ao X-Received: by 2002:a81:8496:: with SMTP id u144-v6mr7316845ywf.266.1540138647842; Sun, 21 Oct 2018 09:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138647; cv=none; d=google.com; s=arc-20160816; b=ZydKfQE55yDMkbM7cWX2oEtvRnAfozEUw0PUleSSIZ4c5R9y3xxFHdxRW7OnruyYvK AXbbTOrIlqjKMC3NDsbmYCjkWEG+AuScMZ3RAoCd3DRL2G3TRHJghMZTqJOlTVuMBMcG tytzy3sMr/OkPPhsOwpxP7KU8YgX9d7fbuABBpLhzQ3OgpUlYm/PuCu9WSNUOp68S6bb DZtZ9lmx+dISHWP0wsguQbrJoOlLLNLnmjLX0noMyunPPBaIq4mxMIEQ7I30vgMK2zDL gT5/FkfLoU86iMpJuPQWL+E2LXHTqEwFc29NPHJvfNzr9gyP0cHtjzqPy2rNWFyZuwCi cihA== 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=iWH0TjRj3Q0KSxr0Y83Rf6L98YoIDmIYIdov8I6ylTNb52oJav9RB3c99a4exfqoey /OBPNBt9mQSwxhHet+1wdbJQOTZH/he7kWo91LtBGTdHhJxKjfWXwaZOe8Aus3U6n4j+ A6xYxKdbFl0z0uK3/02VVgL8XCQ8g+qtKmYJ+3yZpl8fRmHanbolFKENREIf+81ZoYk0 sFt15sQK3r31ehML6tTf081oncVfDVuK77/fT0qE9Bvh4v+wTXtOcLSKEDeO9CBWA6R4 oxUUU9g9FnhmS2wWk7VmBzkseVxH42+cUUly2Ct6hIoIQbnRqCJwTigNWF6F3FvmMDlq fgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=y+bPOH5J; 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 g4-v6si13621803ybk.217.2018.10.21.09.17.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:27 -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=y+bPOH5J; 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 w9LGEAp8154117; Sun, 21 Oct 2018 16:17:26 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=y+bPOH5Jlh5LNEGhbJmYsOyxQDiK7M67f/w0weuAQdVJ0kvnOMIZTP2oEq3dnAVPXfRm +FEgR/y79TeF0ffGvpNCc+MCWpryKgx/PRBoIZgkp+uaUHSUhhG6mc4bUxP0e8qjcafZ gPBJBewGd3fDmHyIgCwD0ij+DI7me5/JMZrV1pyZuNjc3e1JJsDtPy0xedsE/1jYRBYQ 42kX0aHiSLDsHGUoHAQvwcoBn+JiwVraxzdzFZ2YpCP9weRgkj1IitZ9OGDoQSEt2IuT JaH/hZ1BSs6A65Kl3tTXAPykG2psbERykRnxR0eSAmurWIfaVgoGRXJZTS95m7/1g+m7 YQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n7ustu1uw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:26 +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 w9LGHPaO010274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:25 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 w9LGHOAK019421; Sun, 21 Oct 2018 16:17:25 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:24 -0700 Subject: [PATCH 20/28] 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: Sun, 21 Oct 2018 09:17:23 -0700 Message-ID: <154013864305.29026.1507854884363595736.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 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-1810210151 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 2a5c96bc9677..7c709229e108 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4862,8 +4862,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);