1. 27 5月, 2022 3 次提交
    • D
      xfs: don't leak btree cursor when insrec fails after a split · a54f78de
      Darrick J. Wong 提交于
      The recent patch to improve btree cycle checking caused a regression
      when I rebased the in-memory btree branch atop the 5.19 for-next branch,
      because in-memory short-pointer btrees do not have AG numbers.  This
      produced the following complaint from kmemleak:
      
      unreferenced object 0xffff88803d47dde8 (size 264):
        comm "xfs_io", pid 4889, jiffies 4294906764 (age 24.072s)
        hex dump (first 32 bytes):
          90 4d 0b 0f 80 88 ff ff 00 a0 bd 05 80 88 ff ff  .M..............
          e0 44 3a a0 ff ff ff ff 00 df 08 06 80 88 ff ff  .D:.............
        backtrace:
          [<ffffffffa0388059>] xfbtree_dup_cursor+0x49/0xc0 [xfs]
          [<ffffffffa029887b>] xfs_btree_dup_cursor+0x3b/0x200 [xfs]
          [<ffffffffa029af5d>] __xfs_btree_split+0x6ad/0x820 [xfs]
          [<ffffffffa029b130>] xfs_btree_split+0x60/0x110 [xfs]
          [<ffffffffa029f6da>] xfs_btree_make_block_unfull+0x19a/0x1f0 [xfs]
          [<ffffffffa029fada>] xfs_btree_insrec+0x3aa/0x810 [xfs]
          [<ffffffffa029fff3>] xfs_btree_insert+0xb3/0x240 [xfs]
          [<ffffffffa02cb729>] xfs_rmap_insert+0x99/0x200 [xfs]
          [<ffffffffa02cf142>] xfs_rmap_map_shared+0x192/0x5f0 [xfs]
          [<ffffffffa02cf60b>] xfs_rmap_map_raw+0x6b/0x90 [xfs]
          [<ffffffffa0384a85>] xrep_rmap_stash+0xd5/0x1d0 [xfs]
          [<ffffffffa0384dc0>] xrep_rmap_visit_bmbt+0xa0/0xf0 [xfs]
          [<ffffffffa0384fb6>] xrep_rmap_scan_iext+0x56/0xa0 [xfs]
          [<ffffffffa03850d8>] xrep_rmap_scan_ifork+0xd8/0x160 [xfs]
          [<ffffffffa0385195>] xrep_rmap_scan_inode+0x35/0x80 [xfs]
          [<ffffffffa03852ee>] xrep_rmap_find_rmaps+0x10e/0x270 [xfs]
      
      I noticed that xfs_btree_insrec has a bunch of debug code that return
      out of the function immediately, without freeing the "new" btree cursor
      that can be returned when _make_block_unfull calls xfs_btree_split.  Fix
      the error return in this function to free the btree cursor.
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      a54f78de
    • D
      xfs: assert in xfs_btree_del_cursor should take into account error · 56486f30
      Dave Chinner 提交于
      xfs/538 on a 1kB block filesystem failed with this assert:
      
      XFS: Assertion failed: cur->bc_btnum != XFS_BTNUM_BMAP || cur->bc_ino.allocated == 0 || xfs_is_shutdown(cur->bc_mp), file: fs/xfs/libxfs/xfs_btree.c, line: 448
      
      The problem was that an allocation failed unexpectedly in
      xfs_bmbt_alloc_block() after roughly 150,000 minlen allocation error
      injections, resulting in an EFSCORRUPTED error being returned to
      xfs_bmapi_write(). The error occurred on extent-to-btree format
      conversion allocating the new root block:
      
       RIP: 0010:xfs_bmbt_alloc_block+0x177/0x210
       Call Trace:
        <TASK>
        xfs_btree_new_iroot+0xdf/0x520
        xfs_btree_make_block_unfull+0x10d/0x1c0
        xfs_btree_insrec+0x364/0x790
        xfs_btree_insert+0xaa/0x210
        xfs_bmap_add_extent_hole_real+0x1fe/0x9a0
        xfs_bmapi_allocate+0x34c/0x420
        xfs_bmapi_write+0x53c/0x9c0
        xfs_alloc_file_space+0xee/0x320
        xfs_file_fallocate+0x36b/0x450
        vfs_fallocate+0x148/0x340
        __x64_sys_fallocate+0x3c/0x70
        do_syscall_64+0x35/0x80
        entry_SYSCALL_64_after_hwframe+0x44/0xa
      
      Why the allocation failed at this point is unknown, but is likely
      that we ran the transaction out of reserved space and filesystem out
      of space with bmbt blocks because of all the minlen allocations
      being done causing worst case fragmentation of a large allocation.
      
      Regardless of the cause, we've then called xfs_bmapi_finish() which
      calls xfs_btree_del_cursor(cur, error) to tear down the cursor.
      
      So we have a failed operation, error != 0, cur->bc_ino.allocated > 0
      and the filesystem is still up. The assert fails to take into
      account that allocation can fail with an error and the transaction
      teardown will shut the filesystem down if necessary. i.e. the
      assert needs to check "|| error != 0" as well, because at this point
      shutdown is pending because the current transaction is dirty....
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      56486f30
    • D
      xfs: avoid unnecessary runtime sibling pointer endian conversions · 5672225e
      Dave Chinner 提交于
      Commit dc04db2a has caused a small aim7 regression, showing a
      small increase in CPU usage in __xfs_btree_check_sblock() as a
      result of the extra checking.
      
      This is likely due to the endian conversion of the sibling poitners
      being unconditional instead of relying on the compiler to endian
      convert the NULL pointer at compile time and avoiding the runtime
      conversion for this common case.
      
      Rework the checks so that endian conversion of the sibling pointers
      is only done if they are not null as the original code did.
      
      .... and these need to be "inline" because the compiler completely
      fails to inline them automatically like it should be doing.
      
      $ size fs/xfs/libxfs/xfs_btree.o*
         text	   data	    bss	    dec	    hex	filename
        51874	    240	      0	  52114	   cb92 fs/xfs/libxfs/xfs_btree.o.orig
        51562	    240	      0	  51802	   ca5a fs/xfs/libxfs/xfs_btree.o.inline
      
      Just when you think the tools have advanced sufficiently we don't
      have to care about stuff like this anymore, along comes a reminder
      that *our tools still suck*.
      
      Fixes: dc04db2a ("xfs: detect self referencing btree sibling pointers")
      Reported-by: Nkernel test robot <oliver.sang@intel.com>
      Signed-off-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDave Chinner <david@fromorbit.com>
      5672225e
  2. 04 5月, 2022 1 次提交
  3. 21 4月, 2022 1 次提交
  4. 23 3月, 2022 1 次提交
  5. 12 11月, 2021 1 次提交
  6. 20 10月, 2021 5 次提交
  7. 15 10月, 2021 2 次提交
  8. 20 8月, 2021 5 次提交
  9. 19 8月, 2021 3 次提交
  10. 02 6月, 2021 3 次提交
  11. 26 2月, 2021 1 次提交
  12. 12 2月, 2021 1 次提交
    • B
      xfs: consider shutdown in bmapbt cursor delete assert · 1cd738b1
      Brian Foster 提交于
      The assert in xfs_btree_del_cursor() checks that the bmapbt block
      allocation field has been handled correctly before the cursor is
      freed. This field is used for accurate calculation of indirect block
      reservation requirements (for delayed allocations), for example.
      generic/019 reproduces a scenario where this assert fails because
      the filesystem has shutdown while in the middle of a bmbt record
      insertion. This occurs after a bmbt block has been allocated via the
      cursor but before the higher level bmap function (i.e.
      xfs_bmap_add_extent_hole_real()) completes and resets the field.
      
      Update the assert to accommodate the transient state if the
      filesystem has shutdown. While here, clean up the indentation and
      comments in the function.
      Signed-off-by: NBrian Foster <bfoster@redhat.com>
      Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
      1cd738b1
  13. 17 12月, 2020 1 次提交
  14. 13 12月, 2020 1 次提交
  15. 18 3月, 2020 3 次提交
    • D
      xfs: support bulk loading of staged btrees · 60e3d707
      Darrick J. Wong 提交于
      Add a new btree function that enables us to bulk load a btree cursor.
      This will be used by the upcoming online repair patches to generate new
      btrees.  This avoids the programmatic inefficiency of calling
      xfs_btree_insert in a loop (which generates a lot of log traffic) in
      favor of stamping out new btree blocks with ordered buffers, and then
      committing both the new root and scheduling the removal of the old btree
      blocks in a single transaction commit.
      
      The design of this new generic code is based off the btree rebuilding
      code in xfs_repair's phase 5 code, with the explicit goal of enabling us
      to share that code between scrub and repair.  It has the additional
      feature of being able to control btree block loading factors.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NBrian Foster <bfoster@redhat.com>
      60e3d707
    • D
      xfs: introduce fake roots for inode-rooted btrees · 349e1c03
      Darrick J. Wong 提交于
      Create an in-core fake root for inode-rooted btree types so that callers
      can generate a whole new btree using the upcoming btree bulk load
      function without making the new tree accessible from the rest of the
      filesystem.  It is up to the individual btree type to provide a function
      to create a staged cursor (presumably with the appropriate callouts to
      update the fakeroot) and then commit the staged root back into the
      filesystem.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NBrian Foster <bfoster@redhat.com>
      349e1c03
    • D
      xfs: introduce fake roots for ag-rooted btrees · e06536a6
      Darrick J. Wong 提交于
      Create an in-core fake root for AG-rooted btree types so that callers
      can generate a whole new btree using the upcoming btree bulk load
      function without making the new tree accessible from the rest of the
      filesystem.  It is up to the individual btree type to provide a function
      to create a staged cursor (presumably with the appropriate callouts to
      update the fakeroot) and then commit the staged root back into the
      filesystem.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NBrian Foster <bfoster@redhat.com>
      e06536a6
  16. 14 3月, 2020 3 次提交
  17. 12 3月, 2020 1 次提交
  18. 27 1月, 2020 2 次提交
  19. 08 1月, 2020 1 次提交
  20. 19 11月, 2019 1 次提交