From patchwork Sat Oct 13 00:08:25 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: 10639713 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 10E441869 for ; Sat, 13 Oct 2018 00:08:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F26A22B096 for ; Sat, 13 Oct 2018 00:08:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E697A2B82C; Sat, 13 Oct 2018 00:08:36 +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 86B052B096 for ; Sat, 13 Oct 2018 00:08:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 210DA6B028E; Fri, 12 Oct 2018 20:08:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C1676B0290; Fri, 12 Oct 2018 20:08: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 08DD16B0291; Fri, 12 Oct 2018 20:08:35 -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 BEB0E6B028E for ; Fri, 12 Oct 2018 20:08:34 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id g72-v6so13616074pfk.9 for ; Fri, 12 Oct 2018 17:08:34 -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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=EVWYtuv/BBg6Bp7sBDxZqnJB0VfVFuKXWy6el9bSjejDr4hv0GPZIjbMlHzoJhlnWu yM6Dig8Ae/TFpWL5SwkI3JlyzwJYKK/ceCLVQF8sa08cxgObKw+sC9cgiIJmUkxzaJ9Y J80B5leqO8ZQ4kXxTuDD9Bkf8qLBUfOZLeOL09szS4MH/Sywfc+TM+7c/C0RpaSlu0S+ t1/Q3HDyLY39lHWGSJsRCbTpZdkMuNoiMRydMrqVL6rYT7w5FJ0G0BS2Ho0RPyO/iN2b osf8Iv0BrPNXUp8WVzTazdGuhCFx7PAp2bE6JwjS1VmFQigCcehsq2ml9eNt5Zlu90Ou bN7Q== X-Gm-Message-State: ABuFfohVGisaBc4xXz4r+x4wvLpwZ99H4Ceue1+9H3EdVBhSXqi/CTe1 z16LoMnRB/GY+rhaSv5rsSaSV4U0FHAHkL31CYs5eGDiG23dPwkjzWcHOrkvrEBI3U6hmLzpxiz lN2j/V0CLr7wmjU3jrumi30tPLfHXLyOz3YQHIyHSx3TlrAwAhMb3HyzyORColMSWlA== X-Received: by 2002:a63:9d01:: with SMTP id i1-v6mr6923968pgd.98.1539389314403; Fri, 12 Oct 2018 17:08:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JRt8xTEfKy2GLVqfr+9L6GIhBHdgkAu9YiAzvNutusxNmjoqf4PRZ4gmHy4lOiEg+1MCJ X-Received: by 2002:a63:9d01:: with SMTP id i1-v6mr6923943pgd.98.1539389313846; Fri, 12 Oct 2018 17:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539389313; cv=none; d=google.com; s=arc-20160816; b=qKBd6KOMKt11Hxf0GHS05fCwd/5KY8iGI66BCinBuzeMZdH68QH3q5X9lCu6eFhvku DXL+Terbyk8M+zejUta1wVK7xC8UJJr83yQlpgIr6xLppUAIXPQHuST89dWCydiyWATf 8ERJRt7k8ujsoybZFrReTfr9h3FlXFHkqpb1UFISmulxjega1m9ov2Xry6feoLsPLqGH Tx3cunUaKDeDOSKqwMYIUktJ1r1MluzNHPNM/qJDoWGMTCEg4MxJNzp5Zts6fXpr1FD2 QFIm6jKeWo+lh86T/5ny1EmfBpmG+6AcEqyl0LGNbB19aNGsNOKrqy3s1w6cnmpqTJHj Ao5w== 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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=aPgw9AT7LMZGyFPCM7YRBPSgXLBOLJYZzb2RObPWlSCnKFIH5IHyb5k02hz3OwvrS4 QXAqtu7u1pvyntxuqgwFX9bBgd5CDa0qACPqc2rIXLt/AVk6w84z2t5M51DIvh/D2w3Z xw1TGX5B7cr/H9SmmpBYWtc8ZaSjDgHEEnR/721JhF7fSU5X0l3LUeaqsT4Nh7T21AMP bRBMJBK3RasBTBMNIAeMKX2tCmVCa8rZF9aoDctMYTbUEKfNJmvW6pfQ5wD1BE+LUgVv PqafBtdWBHTVvgxoAlZfUYRtrPvMuioifxSO7iusHmdXsKiRsv6mz2ftAXhWU+3SBnwV jm+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=i8lnEwm+; 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 b137-v6si3026869pga.80.2018.10.12.17.08.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:08:33 -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=i8lnEwm+; 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 w9D03wVN163194; Sat, 13 Oct 2018 00:08:33 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=fqlIdqP1FV33bP9F33aDWskwE65KeeJpDzWYgBwmSbE=; b=i8lnEwm+xjrR9xsODT2fvwWNOxhhnok62LalI7bBvl8Kd2KmY5ZV3Z/HqNEDEVQBoOxh FKbXdSwEZ1WbhRGK0Sjpn0YHFKaUeizJWl/WCTptbnSDwBP5lFEqqaXk9MGy+PA2Gd/y Ei+YlavIqcR2hbwWcVHejqzcpn7B8Hzj73m01mE8lYhsnHR+k+Kwqn8KjGlK6u+ZPEFQ hs5+5JE80woyyAhjnn9sDdHpBjq/JEZokO6oiMo7HaSQ1H8hkYBSOCxCNkI1aUkxN4+Z FZHL2q2FsDGRtJlvwDw6RIWNFqas0zZ7E/exIJalw9Cbxjue6pBBZHEUgLs5Evsk0XLq ZA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0qnmjj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:32 +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 w9D08Rbc021572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 13 Oct 2018 00:08:27 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 w9D08RZM018636; Sat, 13 Oct 2018 00:08:27 GMT Received: from localhost (/10.159.251.254) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 13 Oct 2018 00:08:26 +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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Fri, 12 Oct 2018 17:08:25 -0700 Message-ID: <153938930501.8361.16976146684396404822.stgit@magnolia> In-Reply-To: <153938912912.8361.13446310416406388958.stgit@magnolia> References: <153938912912.8361.13446310416406388958.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9044 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=925 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810130000 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 --- 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