]> git.baikalelectronics.ru Git - kernel.git/commit
dax: dax_layout_busy_page() should not unmap cow pages
authorVivek Goyal <vgoyal@redhat.com>
Fri, 2 Aug 2019 19:29:56 +0000 (15:29 -0400)
committerDan Williams <dan.j.williams@intel.com>
Mon, 5 Aug 2019 21:59:05 +0000 (14:59 -0700)
commit2f91ba360d70c1cb4b1151c2b1f8dda1a01916df
tree1d65601d8c5339c1103043fa5618a09ea00783bd
parent1b1e3f6d5a6ff25a6613c83a142ba0d73a10c16d
dax: dax_layout_busy_page() should not unmap cow pages

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: <stable@vger.kernel.org>
Fixes: 44d4e9f31e0c ("mm, fs, dax: handle layout changes to pinned dax mappings")
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Link: https://lore.kernel.org/r/20190802192956.GA3032@redhat.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
fs/dax.c