From patchwork Tue Oct 16 03:20: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: 10642977 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 0E08B17D2 for ; Tue, 16 Oct 2018 03:20:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEFE128E72 for ; Tue, 16 Oct 2018 03:20:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3138298AF; Tue, 16 Oct 2018 03:20:34 +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 7CF0A28E72 for ; Tue, 16 Oct 2018 03:20:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A09A6B0289; Mon, 15 Oct 2018 23:20:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 526666B028A; Mon, 15 Oct 2018 23:20: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 3F0D76B028B; Mon, 15 Oct 2018 23:20:33 -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 F19EE6B0289 for ; Mon, 15 Oct 2018 23:20:32 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id s15-v6so16233832pgv.9 for ; Mon, 15 Oct 2018 20:20:32 -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=AfMW/JOlYgjnzptq/KyS+dCaYDVpQ0opYb+eiw86DMegVgBXlDZDWK7W8iXTdWVjTb 26QhMMjQKJHIIX4160W7CVrYMeea44tzZNmslh5CFgkpTQkhbHLwVmzAtKbZc+PId9cE aW7imhD7pHIjlNk+tUS2Fj1HK2LDjmDV9rQjuLKMH4q50rIoVAs6IyRCqel2yru6M872 irsfSC0i0s0tihk0dJ64JxF6hSdbSnXTgpwJmpO1DxQgk/pDeMRzvnOCLOpCMsVZgKn4 E7infl7nMtTEp1gx/VpZD0OhyIP8VmYxfSTMzPyxMjMi8j/fbc+oYJRoIaZVhJV8TPFV tJNw== X-Gm-Message-State: ABuFfoit0xHSfZPnPFsnuGftzLjMf92lgPTbbSwHwMxvGAMMMvsmXF6V mkKVAIun8bkYcmyzDQRCuJrX+IMuCx+HnZXrqIvUTWxLKo9HjHVN+dXeQhS3d6fpmfG2IRFlE6T Pm2r5M9VAydQTak5qM+IT1e/rMYC8RSlM3bBIDu4xam6fXsDMqeZcUeZNrCSLt+JASA== X-Received: by 2002:a62:ce83:: with SMTP id y125-v6mr20346172pfg.201.1539660032665; Mon, 15 Oct 2018 20:20:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV63WMqPgL4gOSL2nH3MQlzgtlpCPOzm/WFhSK5/Y+Rlk9FCyfV4f7aCu/c9F1bhUO1UUSNDv X-Received: by 2002:a62:ce83:: with SMTP id y125-v6mr20346134pfg.201.1539660031990; Mon, 15 Oct 2018 20:20:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539660031; cv=none; d=google.com; s=arc-20160816; b=OMAlwZ7H/wue2JY3YWJEWI31o/Tmv+afvilRR7ow4G3GajtEXwMVgz3w0PP4xZ2nWV wMcCg4Q5xMZcL9n0C/4DBWpCnqL4u7nZeWCrKy3Dc0gwNLxBVlwwLXvaQSzZyUjAy101 zGQf7rzI/MiRPKRwODZIDDZDmHKqNmCIXlCNWBpQegrxIl6t5ww+FE/TmZ8AbbJx3d28 y5n8wM8QjFa6s5O/sm7l6tGwwAF3nHZKV1HutKzzWfj5IZ6xjNWUpriABh8jkbr84dbU GOiaM6ew8pj+Gy2Pxq/Lzp98LS1SPcLHEjfRbZKyl8y9fxSlMS0PqB9PFwp89AAne0FB Fj1g== 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=V3mNMpeGkSBZJBg0R0mQKT7X4amfp3Zb2LECitpngOaeFGKQtpWlUIDcZI6qRfRtMH MbkracM8zJ3Wwa4Pfarr6qXnyoeuuua2as/CN/NbzGEkI7wL2n1e53rLejibQr4eFsyW RgW5wrfC1T7LcnLcgyttRdqtCvv8cEPosChRGflRiJxCpnAd+2qHnXM6XtmKe2Ab1M+s 7/tGSFduQEX5scqG9V0QEEy0TclKnyYSo6tB0ZRgHpnsmrWZbdtfBFN9l464FpCN8fxK A4laMEuGwZGKgozc+CVFHcckElBbZltaxpzQmCFsIeJurj5rfhnSQGc4lgB3UFuJFT8v sGPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=iBSICVn4; 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 u12-v6si12241318pls.150.2018.10.15.20.20.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:20:31 -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=iBSICVn4; 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 w9G3JosY051805; Tue, 16 Oct 2018 03:20:31 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=iBSICVn4f9CkaRFFiOxk2xB6Y4NFF+6yJTm0g85Ac8gHYjxhbKJs7hWy8xzvr7mKImeN V8N/wYDDl1S13EN4709ZB0nQAF8wsAYGdoekttm+crepR3b6VUelYUjwEkVk+2M2dmkE /NrZoJh7gZznmDo77tU5l+ACD1JK6isq55m/9n1bZIL2yfrzyllpmvz+a9kSwvHjAprS xnCZpHestWVzu6VTXPrnQ9Vx/Gvt87rXQCnZvXJKNng5vnVDpq5Xb0r7b4lKU3p1w4ou LKNboZS0vnvnnvsb33r/PNcDLrVmTu+Vm4nYEN+hh1Qw9oIzM0Z+g3ghIe5EwM1584l8 Cw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384tx29t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:31 +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 w9G3KUJf029604 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:30 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3KTFY012664; Tue, 16 Oct 2018 03:20:30 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:20:29 -0700 Subject: [PATCH 21/26] 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: Mon, 15 Oct 2018 20:20:28 -0700 Message-ID: <153966002809.3607.17959416355714610983.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=999 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 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);