Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1082192ybl; Wed, 14 Aug 2019 10:24:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdk26zIBsJv9Wqx3wRqVLND6Iai4As3kBnH0Qn9s9htDdnCrNKvGLJhUIaOtSOs+WYZI8i X-Received: by 2002:a62:1688:: with SMTP id 130mr1024876pfw.187.1565803462541; Wed, 14 Aug 2019 10:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803462; cv=none; d=google.com; s=arc-20160816; b=VpL7A8xqPjjNtdqLQazUhWt6Xghwoc1PmWyzjIyfzZ5y7yyiXKQC5uvAP5arcIiskx UykH/ygvSwFzxzZrAjxMAQwxjO/pt4ghZYadyFOhEbiWl89BT0utSorohZMPfOaE9ViL 9c+bvKhiM5Sqwy+w2aEH8m2v4JFVp7vN+mDwmvAk2zScMkJPaZkH0Uo51cFf7KjJ+1j0 G0bu+N1eh6Mww3Acrazn5RsKthFh/Ztgnvx/PfI1iJffDP5fgZPyk2Ygwl1iAwPtRwXV RT/R96Y3+DzvYhzs47wmErN/nZ3gd8V39R+XfbSWz4ghvrIjWeSmvaZOqxnrFafZEPte s2gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=muE8JmgNgf9hbHS4LRfEVBucUHvShjYZjE0jvlTpPsw=; b=Vzz8dcLapEJmONXg2oo6yWiZfAp1NBlCuwYtyfJCoX45J0xyT+lDtOhhiSpEpv8/Lv ZN9PGZMcKWU1KpP0Df5fM/AqRdx18ZJ8maAo2WRVhHuGKHhxPlgViOfABoMTIRWXyEgH A15XMUndTBwiSLUJ3myL6fwuef1tGJIGbqvajxRmFyENmLEwb3jJ81wEmEmuz2E4x1qK 4fnMD69xW90QAal2g+WAe0J6w8NBhI96WbpdUJ4YBtiBqoE7FxO7JTNllwCuMNFeGgdO cuTd+tS8PjX9aqRAdoQkFM+GK1gqFLqLPUqTzFfK6oSeyi4GUL/cmuTdUY2Lw5RfnRRV kvqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vza96ptq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c18si116162pfj.4.2019.08.14.10.24.06; Wed, 14 Aug 2019 10:24:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vza96ptq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729153AbfHNRHc (ORCPT + 99 others); Wed, 14 Aug 2019 13:07:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:57032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729895AbfHNRHa (ORCPT ); Wed, 14 Aug 2019 13:07:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44D172084D; Wed, 14 Aug 2019 17:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802449; bh=NfrpQmMOf4J9fkuQWntFAF9LT56Nkw0hUJGQNe8kZ3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vza96ptqohbyN4Uk7PoFynvG8hMBiWKh+/dKWBmAisOajYbmLxHQIOg3LhJPBvcvf 9SA0Y9XTHn7g5vzgk+7Sl7sno+cSeHzOkWm1OikywYzIa+0dihiXxHmlllg+u+kDKS Ms3u9zpplM5ymJt4c5mmKmSPikoCwafU599/bMKI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vivek Goyal , Dan Williams Subject: [PATCH 5.2 131/144] dax: dax_layout_busy_page() should not unmap cow pages Date: Wed, 14 Aug 2019 19:01:27 +0200 Message-Id: <20190814165805.424900046@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vivek Goyal commit d75996dd022b6d83bd14af59b2775b1aa639e4b9 upstream. Vivek: "As of now dax_layout_busy_page() calls unmap_mapping_range() with last argument as 1, which says even unmap cow pages. I am wondering who needs to get rid of cow pages as well. I noticed one interesting side affect of this. I mount xfs with -o dax and mmaped a file with MAP_PRIVATE and wrote some data to a page which created cow page. Then I called fallocate() on that file to zero a page of file. fallocate() called dax_layout_busy_page() which unmapped cow pages as well and then I tried to read back the data I wrote and what I get is old data from persistent memory. I lost the data I had written. This read basically resulted in new fault and read back the data from persistent memory. This sounds wrong. Are there any users which need to unmap cow pages as well? If not, I am proposing changing it to not unmap cow pages. I noticed this while while writing virtio_fs code where when I tried to reclaim a memory range and that corrupted the executable and I was running from virtio-fs and program got segment violation." Dan: "In fact the unmap_mapping_range() in this path is only to synchronize against get_user_pages_fast() and force it to call back into the filesystem to re-establish the mapping. COW pages should be left untouched by dax_layout_busy_page()." Cc: Fixes: 5fac7408d828 ("mm, fs, dax: handle layout changes to pinned dax mappings") Signed-off-by: Vivek Goyal Link: https://lore.kernel.org/r/20190802192956.GA3032@redhat.com Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- fs/dax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/dax.c +++ b/fs/dax.c @@ -601,7 +601,7 @@ struct page *dax_layout_busy_page(struct * guaranteed to either see new references or prevent new * references from being established. */ - unmap_mapping_range(mapping, 0, 0, 1); + unmap_mapping_range(mapping, 0, 0, 0); xas_lock_irq(&xas); xas_for_each(&xas, entry, ULONG_MAX) {