From patchwork Sun Oct 21 16:17:43 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: 10651221 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 2B4AE14E2 for ; Sun, 21 Oct 2018 16:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19E44287C0 for ; Sun, 21 Oct 2018 16:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DAD0287C6; Sun, 21 Oct 2018 16:17:55 +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 8BF00287C9 for ; Sun, 21 Oct 2018 16:17:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87F4C6B0285; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 82F046B0287; Sun, 21 Oct 2018 12:17: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 6F7816B0288; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 34DDE6B0285 for ; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id y131-v6so2465946yby.13 for ; Sun, 21 Oct 2018 09:17: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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=Yc/49dRK1U+1ahZw09x2PMDoVrH5/pIvs9ss8OFBbqOqxR4Wmw4En/s/6DMqwFwP7F wAB/hI7B7ixdpS3dD5FWKf6mgIG+X8pwoLNN8b41U49UxYTJooJhwIA3IsNibADKrCEL 7xRvS9Kn4su3Wro73b6ecZhwDeii3m4e4TltlIRMlPRWb0c9tmlRqUEwjCFlmsIojjCC PdjGl1i9eRUp6mTN8bqUXFyvE9QlsBHvD01ptip2uFumAb6z5T/Tkz/I8Xgj9oMOvBlJ s+sCS3VF14X8Z8esEY3gHgT76+d5nf4h5bM/M6BHikg77TOGGQIOX5m3xnf6Ji3H4GO7 SKVQ== X-Gm-Message-State: ABuFfogpj99bsLBoC2WT22UqeWl76uDK/mdBQ9fPRutYVB4lFDyphSWX sI0tk6ERn5p4He6DtwOq4oF2XPWyWjPUxoxie8+5bVZubdWK1pOXE2Bnhl5Ywj2uZsl9vSuoPCY fdXqb6NdJu9eZ0Bou9rl8jveU0qIlGPWIEXGGOyC4es3rNvZ4iCFwizNP/taCbUOuYQ== X-Received: by 2002:a25:820d:: with SMTP id q13-v6mr15209808ybk.171.1540138672982; Sun, 21 Oct 2018 09:17:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV63aZFCQcqRL/ECpnmK0XC/4s/HZ2wD9fcgoZre1i/JnTDkei5MQRII0U4gT/uErN7UISQ1V X-Received: by 2002:a25:820d:: with SMTP id q13-v6mr15209783ybk.171.1540138672443; Sun, 21 Oct 2018 09:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138672; cv=none; d=google.com; s=arc-20160816; b=oCWz/hHUr6en4LHNeLVFmKg8z39riym4mGVGB3hWIqzHsPECJgmx8jatwdCAmaibFP YYRKbR66I2ca73gEd15Sm49T7ZkTBR7iR8FkgsavnONlx0+Xyl7NfYhoXUYdCcM8UKdv wrvp5RgETo95EmY5uefat58/SCbAeNDrCXblGDjxx96z92lFKnKVAKut93v+F7AKne1P V3PlCUnt7lboNJRiATi99yNwZK26VzhZ1gILhLqTTtk/aasXbFwg9CXG+v0B/7gRWXr+ HqJEKrKgmaVO46qZhJHmNIEgbZ3e/jY0QoVPg29cQryYJxMFYK+R+4VdAcfZ2TFCldW1 da5Q== 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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=zVXwPsvz107hgWZBBrzt/gTJCOx7EamfxzCTEsNImVGN14RKDGlWXyH1nQeh7Iq/Au 3jINqFIJiLWjaP4tsNeyuOLP9gspoMAifogIaeewqhgDsWexGdRQC7zjjdc8IWG5qER8 QBYudCKlZYj4qGk7WtMfBaxT/a7KIJww7I3mYG0mIDtJtOBdDWuNcFLKf2ZkIEvI+ZYt LyH+Bm7COW6WjMuqQGG8kYrLcDv4WB+zeZvVHFvdXfWZ2d/3JS0xW1TyNVHhdQuJuoc6 F9zW9zAIEy5QEfeUiYdhiYIZrlO+Xk8xAut5X3PKV8LMcoiSmU70X8HsG27HSnN/kjPg AK/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=24DUBrAG; 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 w189-v6si10960755ybg.176.2018.10.21.09.17.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17: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=24DUBrAG; 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 w9LGE2Nq154085; Sun, 21 Oct 2018 16:17: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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=24DUBrAGkrS2J7UxUA0/AFMP2niht/l+UPTNWVEE060bjG0GnWg2p395m+ArKTBUx7y8 8Pf3F/xyVSSzU2K8Rs3RJpTOWwy6IixapcY4hhlmyvjqel0igTNgBDVwKp+ZUt0yvJ8i Bbe5zJXWBRnIIPVOE3yW0zP6AdK7hqDVDb5GNSkFmAcJ5Hxu4lonIwT+3e19/K+RnO9l zNykhLIuplLOLFXg/FjypYE1/l+DuckhLJl0kowR2EvKqP3tt7swvyXKJPGgvNXdKcsi MxjkHcDic0D1podKczKFJNoUbEBagCkE1VgGJGj+v5eGx+VggQ+TQuRS1OiwnXxdNHUl 5A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n7ustu1v9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:51 +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 w9LGHjFo027541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:45 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHjwD024877; Sun, 21 Oct 2018 16:17:45 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:45 -0700 Subject: [PATCH 23/28] 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:17:43 -0700 Message-ID: <154013866350.29026.11722237862126200267.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=952 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 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: