Skip to content
Snippets Groups Projects
  1. Dec 18, 2021
  2. Dec 04, 2021
  3. Aug 17, 2021
  4. Jul 08, 2021
  5. Jun 29, 2021
    • Jan Kara's avatar
      dax: fix ENOMEM handling in grab_mapping_entry() · 1a14e377
      Jan Kara authored
      grab_mapping_entry() has a bug in handling of ENOMEM condition.  Suppose
      we have a PMD entry at index i which we are downgrading to a PTE entry.
      grab_mapping_entry() will set pmd_downgrade to true, lock the entry, clear
      the entry in xarray, and decrement mapping->nrpages.  The it will call:
      
      	entry = dax_make_entry(pfn_to_pfn_t(0), flags);
      	dax_lock_entry(xas, entry);
      
      which inserts new PTE entry into xarray.  However this may fail allocating
      the new node.  We handle this by:
      
      	if (xas_nomem(xas, mapping_gfp_mask(mapping) & ~__GFP_HIGHMEM))
      		goto retry;
      
      however pmd_downgrade stays set to true even though 'entry' returned from
      get_unlocked_entry() will be NULL now.  And we will go again through the
      downgrade branch.  This is mostly harmless except that mapping->nrpages is
      decremented again and we temporarily have an invalid entry stored in
      xarray.  Fix the problem by setting pmd_downgrade to false each time we
      lookup the entry we work with so that it matches the entry we found.
      
      Link: https://lkml.kernel.org/r/20210622160015.18004-1-jack@suse.cz
      
      
      Fixes: b15cd800 ("dax: Convert page fault handlers to XArray")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1a14e377
  6. May 07, 2021
  7. May 05, 2021
  8. Feb 09, 2021
    • Paolo Bonzini's avatar
      mm: provide a saner PTE walking API for modules · 9fd6dad1
      Paolo Bonzini authored
      
      Currently, the follow_pfn function is exported for modules but
      follow_pte is not.  However, follow_pfn is very easy to misuse,
      because it does not provide protections (so most of its callers
      assume the page is writable!) and because it returns after having
      already unlocked the page table lock.
      
      Provide instead a simplified version of follow_pte that does
      not have the pmdpp and range arguments.  The older version
      survives as follow_invalidate_pte() for use by fs/dax.c.
      
      Reviewed-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9fd6dad1
  9. Dec 16, 2020
  10. Sep 21, 2020
  11. Sep 10, 2020
    • Vivek Goyal's avatar
      dax: Create a range version of dax_layout_busy_page() · 6bbdd563
      Vivek Goyal authored
      
      virtiofs device has a range of memory which is mapped into file inodes
      using dax. This memory is mapped in qemu on host and maps different
      sections of real file on host. Size of this memory is limited
      (determined by administrator) and depending on filesystem size, we will
      soon reach a situation where all the memory is in use and we need to
      reclaim some.
      
      As part of reclaim process, we will need to make sure that there are
      no active references to pages (taken by get_user_pages()) on the memory
      range we are trying to reclaim. I am planning to use
      dax_layout_busy_page() for this. But in current form this is per inode
      and scans through all the pages of the inode.
      
      We want to reclaim only a portion of memory (say 2MB page). So we want
      to make sure that only that 2MB range of pages do not have any
      references  (and don't want to unmap all the pages of inode).
      
      Hence, create a range version of this function named
      dax_layout_busy_page_range() which can be used to pass a range which
      needs to be unmapped.
      
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: linux-nvdimm@lists.01.org
      Cc: Jan Kara <jack@suse.cz>
      Cc: Vishal L Verma <vishal.l.verma@intel.com>
      Cc: "Weiny, Ira" <ira.weiny@intel.com>
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      6bbdd563
  12. Aug 23, 2020
  13. Jul 31, 2020
  14. Jul 28, 2020
  15. Apr 03, 2020
  16. Feb 06, 2020
  17. Jan 03, 2020
  18. Oct 23, 2019
  19. Oct 21, 2019
  20. Aug 05, 2019
    • Vivek Goyal's avatar
      dax: dax_layout_busy_page() should not unmap cow pages · d75996dd
      Vivek Goyal authored
      
      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: 5fac7408 ("mm, fs, dax: handle layout changes to pinned dax mappings")
      Signed-off-by: default avatarVivek Goyal <vgoyal@redhat.com>
      Link: https://lore.kernel.org/r/20190802192956.GA3032@redhat.com
      
      
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      d75996dd
  21. Jul 29, 2019
  22. Jul 17, 2019
  23. Jun 17, 2019
  24. Jun 07, 2019
    • Jan Kara's avatar
      dax: Fix xarray entry association for mixed mappings · 1571c029
      Jan Kara authored
      
      When inserting entry into xarray, we store mapping and index in
      corresponding struct pages for memory error handling. When it happened
      that one process was mapping file at PMD granularity while another
      process at PTE granularity, we could wrongly deassociate PMD range and
      then reassociate PTE range leaving the rest of struct pages in PMD range
      without mapping information which could later cause missed notifications
      about memory errors. Fix the problem by calling the association /
      deassociation code if and only if we are really going to update the
      xarray (deassociating and associating zero or empty entries is just
      no-op so there's no reason to complicate the code with trying to avoid
      the calls for these cases).
      
      Cc: <stable@vger.kernel.org>
      Fixes: d2c997c0 ("fs, dax: use page->mapping to warn if truncate...")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      1571c029
Loading