1. 17 12月, 2021 2 次提交
  2. 25 11月, 2021 1 次提交
  3. 22 11月, 2021 1 次提交
    • A
      iomap: Fix inline extent handling in iomap_readpage · d8af404f
      Andreas Gruenbacher 提交于
      Before commit 740499c7 ("iomap: fix the iomap_readpage_actor return
      value for inline data"), when hitting an IOMAP_INLINE extent,
      iomap_readpage_actor would report having read the entire page.  Since
      then, it only reports having read the inline data (iomap->length).
      
      This will force iomap_readpage into another iteration, and the
      filesystem will report an unaligned hole after the IOMAP_INLINE extent.
      But iomap_readpage_actor (now iomap_readpage_iter) isn't prepared to
      deal with unaligned extents, it will get things wrong on filesystems
      with a block size smaller than the page size, and we'll eventually run
      into the following warning in iomap_iter_advance:
      
        WARN_ON_ONCE(iter->processed > iomap_length(iter));
      
      Fix that by changing iomap_readpage_iter to return 0 when hitting an
      inline extent; this will cause iomap_iter to stop immediately.
      
      To fix readahead as well, change iomap_readahead_iter to pass on
      iomap_readpage_iter return values less than or equal to zero.
      
      Fixes: 740499c7 ("iomap: fix the iomap_readpage_actor return value for inline data")
      Cc: stable@vger.kernel.org # v5.15+
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      d8af404f
  4. 18 10月, 2021 1 次提交
    • A
      iov_iter: Turn iov_iter_fault_in_readable into fault_in_iov_iter_readable · a6294593
      Andreas Gruenbacher 提交于
      Turn iov_iter_fault_in_readable into a function that returns the number
      of bytes not faulted in, similar to copy_to_user, instead of returning a
      non-zero value when any of the requested pages couldn't be faulted in.
      This supports the existing users that require all pages to be faulted in
      as well as new users that are happy if any pages can be faulted in.
      
      Rename iov_iter_fault_in_readable to fault_in_iov_iter_readable to make
      sure this change doesn't silently break things.
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      a6294593
  5. 17 8月, 2021 13 次提交
  6. 06 8月, 2021 2 次提交
  7. 04 8月, 2021 5 次提交
  8. 16 7月, 2021 3 次提交
  9. 30 6月, 2021 1 次提交
  10. 10 6月, 2021 1 次提交
  11. 03 6月, 2021 1 次提交
  12. 15 5月, 2021 1 次提交
  13. 04 5月, 2021 1 次提交
  14. 09 4月, 2021 1 次提交
  15. 11 3月, 2021 1 次提交
  16. 27 2月, 2021 1 次提交
  17. 26 2月, 2021 1 次提交
  18. 03 12月, 2020 1 次提交
    • R
      mm: memcontrol: Use helpers to read page's memcg data · bcfe06bf
      Roman Gushchin 提交于
      Patch series "mm: allow mapping accounted kernel pages to userspace", v6.
      
      Currently a non-slab kernel page which has been charged to a memory cgroup
      can't be mapped to userspace.  The underlying reason is simple: PageKmemcg
      flag is defined as a page type (like buddy, offline, etc), so it takes a
      bit from a page->mapped counter.  Pages with a type set can't be mapped to
      userspace.
      
      But in general the kmemcg flag has nothing to do with mapping to
      userspace.  It only means that the page has been accounted by the page
      allocator, so it has to be properly uncharged on release.
      
      Some bpf maps are mapping the vmalloc-based memory to userspace, and their
      memory can't be accounted because of this implementation detail.
      
      This patchset removes this limitation by moving the PageKmemcg flag into
      one of the free bits of the page->mem_cgroup pointer.  Also it formalizes
      accesses to the page->mem_cgroup and page->obj_cgroups using new helpers,
      adds several checks and removes a couple of obsolete functions.  As the
      result the code became more robust with fewer open-coded bit tricks.
      
      This patch (of 4):
      
      Currently there are many open-coded reads of the page->mem_cgroup pointer,
      as well as a couple of read helpers, which are barely used.
      
      It creates an obstacle on a way to reuse some bits of the pointer for
      storing additional bits of information.  In fact, we already do this for
      slab pages, where the last bit indicates that a pointer has an attached
      vector of objcg pointers instead of a regular memcg pointer.
      
      This commits uses 2 existing helpers and introduces a new helper to
      converts all read sides to calls of these helpers:
        struct mem_cgroup *page_memcg(struct page *page);
        struct mem_cgroup *page_memcg_rcu(struct page *page);
        struct mem_cgroup *page_memcg_check(struct page *page);
      
      page_memcg_check() is intended to be used in cases when the page can be a
      slab page and have a memcg pointer pointing at objcg vector.  It does
      check the lowest bit, and if set, returns NULL.  page_memcg() contains a
      VM_BUG_ON_PAGE() check for the page not being a slab page.
      
      To make sure nobody uses a direct access, struct page's
      mem_cgroup/obj_cgroups is converted to unsigned long memcg_data.
      Signed-off-by: NRoman Gushchin <guro@fb.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: NShakeel Butt <shakeelb@google.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Link: https://lkml.kernel.org/r/20201027001657.3398190-1-guro@fb.com
      Link: https://lkml.kernel.org/r/20201027001657.3398190-2-guro@fb.com
      Link: https://lore.kernel.org/bpf/20201201215900.3569844-2-guro@fb.com
      bcfe06bf
  19. 05 11月, 2020 2 次提交
    • B
      iomap: clean up writeback state logic on writepage error · 50e7d6c7
      Brian Foster 提交于
      The iomap writepage error handling logic is a mash of old and
      slightly broken XFS writepage logic. When keepwrite writeback state
      tracking was introduced in XFS in commit 0d085a52 ("xfs: ensure
      WB_SYNC_ALL writeback handles partial pages correctly"), XFS had an
      additional cluster writeback context that scanned ahead of
      ->writepage() to process dirty pages over the current ->writepage()
      extent mapping. This context expected a dirty page and required
      retention of the TOWRITE tag on partial page processing so the
      higher level writeback context would revisit the page (in contrast
      to ->writepage(), which passes a page with the dirty bit already
      cleared).
      
      The cluster writeback mechanism was eventually removed and some of
      the error handling logic folded into the primary writeback path in
      commit 150d5be0 ("xfs: remove xfs_cancel_ioend"). This patch
      accidentally conflated the two contexts by using the keepwrite logic
      in ->writepage() without accounting for the fact that the page is
      not dirty. Further, the keepwrite logic has no practical effect on
      the core ->writepage() caller (write_cache_pages()) because it never
      revisits a page in the current function invocation.
      
      Technically, the page should be redirtied for the keepwrite logic to
      have any effect. Otherwise, write_cache_pages() may find the tagged
      page but will skip it since it is clean. Even if the page was
      redirtied, however, there is still no practical effect to keepwrite
      since write_cache_pages() does not wrap around within a single
      invocation of the function. Therefore, the dirty page would simply
      end up retagged on the next writeback sequence over the associated
      range.
      
      All that being said, none of this really matters because redirtying
      a partially processed page introduces a potential infinite redirty
      -> writeback failure loop that deviates from the current design
      principle of clearing the dirty state on writepage failure to avoid
      building up too much dirty, unreclaimable memory on the system.
      Therefore, drop the spurious keepwrite usage and dirty state
      clearing logic from iomap_writepage_map(), treat the partially
      processed page the same as a fully processed page, and let the
      imminent ioend failure clean up the writeback state.
      Signed-off-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      50e7d6c7
    • B
      iomap: support partial page discard on writeback block mapping failure · 763e4cdc
      Brian Foster 提交于
      iomap writeback mapping failure only calls into ->discard_page() if
      the current page has not been added to the ioend. Accordingly, the
      XFS callback assumes a full page discard and invalidation. This is
      problematic for sub-page block size filesystems where some portion
      of a page might have been mapped successfully before a failure to
      map a delalloc block occurs. ->discard_page() is not called in that
      error scenario and the bio is explicitly failed by iomap via the
      error return from ->prepare_ioend(). As a result, the filesystem
      leaks delalloc blocks and corrupts the filesystem block counters.
      
      Since XFS is the only user of ->discard_page(), tweak the semantics
      to invoke the callback unconditionally on mapping errors and provide
      the file offset that failed to map. Update xfs_discard_page() to
      discard the corresponding portion of the file and pass the range
      along to iomap_invalidatepage(). The latter already properly handles
      both full and sub-page scenarios by not changing any iomap or page
      state on sub-page invalidations.
      Signed-off-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      763e4cdc