Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1079431ybl; Wed, 14 Aug 2019 10:21:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqytEnnVI+yUIKb29TQGxnejQaiN/yP3ggYbJUStzMWB7HiXawUvMkFlqvdPxOgC7c2mSPbp X-Received: by 2002:a65:60d3:: with SMTP id r19mr225294pgv.91.1565803295104; Wed, 14 Aug 2019 10:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803295; cv=none; d=google.com; s=arc-20160816; b=CUDPbVe4b/WbZ95u1qq9l5U3CPAG78OYIVW/GSlvW9cvKdAv7OnaqAq0qpPlYqFsk7 F1ZvVNKJzP91X9U8+aO+Nxcx2M04SQ4Agp1tb5f9pox1l0F8eWcBctUDrFxCrtfX6jZT n0+0s0Z1ac77GRgdfwdl3MJnKfogbqvDos+nRNZmRTm6PpiLhjXkKG/te8Sa0aiqEvEs anLHMooDeJfaJt7sNJVDD4fDjNUF2yughS7etxnXWiBun5KodjCBe2VbxjbeY5yQarfy 9a2syNRWlZGvSmUhriWcd0nOy2HFXPkCK2bMxw9QpxVjImjv0uySVntJC0E3Dgh2BUhR duhA== 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=N3wVqJmo5xysRXCkD+u6P/WC/5cYWT9jcFAz6luyLM0=; b=PhOS5hGspEfxLsbVzCJ6byst7J7qufouvhr8VoxmBwj+bbfsG0B3ptUewK4qxicN6Y WN22gy5HCkBRbFbsTRpkvl+GRUldvoC+DDo6ihlELtvSksDkTGkUrAshS2RmwZ9dDY5p V/nMqzmoo9Z9++l7I3y021jPMP92Njeyg4nuaD2RA7nbZQCbZg3mzOdSaF8sR9n98cIU /V+CLL8xF6cGODWyYAXUv16vam4FbsDQF0Oy7dbBAqeF0AiI88OMjPi/XXHm3XWtnZxG Q/hu4bI2NU3eWKqWMs6TN2ow1yTSxH6LYpWIOl0T1kQUXCtPqdad9dWElN78SHZ5gGzB Ismg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KIWopYPS; 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 e23si159279pgv.528.2019.08.14.10.21.19; Wed, 14 Aug 2019 10:21:35 -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=KIWopYPS; 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 S1728934AbfHNRT3 (ORCPT + 99 others); Wed, 14 Aug 2019 13:19:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:35056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730612AbfHNRLi (ORCPT ); Wed, 14 Aug 2019 13:11:38 -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 295342063F; Wed, 14 Aug 2019 17:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802697; bh=Tqo8loJ+Ma9PbRKchpp4wA38Hs/iv/SgwBFUkNqQR6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KIWopYPSfcArqNm3Km027yGnXuzSc9buz/9sLIRohM2IwCZVptM8mDIiLEI+hzAvw byEA2fR0cTGKcA/KCesWmSQ1FzjF633BIVLfzE9FUjgB09zHyfHIEpi+ix+xtRQf0D HcqCPh+4Raw+8tuNb8D5zzTUdoAk9+jieWOiDg7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vivek Goyal , Dan Williams Subject: [PATCH 4.19 82/91] dax: dax_layout_busy_page() should not unmap cow pages Date: Wed, 14 Aug 2019 19:01:45 +0200 Message-Id: <20190814165753.521134006@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 @@ -659,7 +659,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); while (index < end && pagevec_lookup_entries(&pvec, mapping, index, min(end - index, (pgoff_t)PAGEVEC_SIZE),