1. 30 May, 2022 3 commits
  2. 27 May, 2022 13 commits
    • Darrick J. Wong's avatar
      xfs: move xfs_attr_use_log_assist usage out of libxfs · efc2efeb
      Darrick J. Wong authored
      The LARP patchset added an awkward coupling point between libxfs and
      what would be libxlog, if the XFS log were actually its own library.
      Move the code that sets up logged xattr updates out of libxfs and into
      xfs_xattr.c so that libxfs no longer has to know about xlog_* functions.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      efc2efeb
    • Darrick J. Wong's avatar
      xfs: move xfs_attr_use_log_assist out of xfs_log.c · d9c61ccb
      Darrick J. Wong authored
      The LARP patchset added an awkward coupling point between libxfs and
      what would be libxlog, if the XFS log were actually its own library.
      Move the code that enables logged xattr updates out of "lib"xlog and into
      xfs_xattr.c so that it no longer has to know about xlog_* functions.
      
      While we're at it, give xfs_xattr.c its own header file.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      d9c61ccb
    • Darrick J. Wong's avatar
      xfs: warn about LARP once per mount · 202865cc
      Darrick J. Wong authored
      Since LARP is an experimental debug-only feature, we should try to warn
      about it being in use once per mount, not once per reboot.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      202865cc
    • Darrick J. Wong's avatar
      xfs: implement per-mount warnings for scrub and shrink usage · df5660cf
      Darrick J. Wong authored
      Currently, we don't have a consistent story around logging when an
      EXPERIMENTAL feature gets turned on at runtime -- online fsck and shrink
      log a message once per day across all mounts, and the recently merged
      LARP mode only ever does it once per insmod cycle or reboot.
      
      Because EXPERIMENTAL tags are supposed to go away eventually, convert
      the existing daily warnings into state flags that travel with the mount,
      and warn once per mount.  Making this an opstate flag means that we'll
      be able to capture the experimental usage in the ftrace output too.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      df5660cf
    • Darrick J. Wong's avatar
      xfs: don't log every time we clear the log incompat flags · 37403796
      Darrick J. Wong authored
      There's no need to spam the logs every time we clear the log incompat
      flags -- if someone is periodically using one of these features, they'll
      be cleared every time the log tries to clean itself, which can get
      pretty chatty:
      
      $ dmesg | grep -i clear
      [ 5363.894711] XFS (sdd): Clearing log incompat feature flags.
      [ 5365.157516] XFS (sdd): Clearing log incompat feature flags.
      [ 5369.388543] XFS (sdd): Clearing log incompat feature flags.
      [ 5371.281246] XFS (sdd): Clearing log incompat feature flags.
      
      These aren't high value messages either -- nothing's gone wrong, and
      nobody's trying anything tricky.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      37403796
    • Darrick J. Wong's avatar
      xfs: convert buf_cancel_table allocation to kmalloc_array · 910bbdf2
      Darrick J. Wong authored
      While we're messing around with how recovery allocates and frees the
      buffer cancellation table, convert the allocation to use kmalloc_array
      instead of the old kmem_alloc APIs, and make it handle a null return,
      even though that's not likely.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      910bbdf2
    • Darrick J. Wong's avatar
      xfs: don't leak xfs_buf_cancel structures when recovery fails · 8db074bd
      Darrick J. Wong authored
      If log recovery fails, we free the memory used by the buffer
      cancellation buckets, but we don't actually traverse each bucket list to
      free the individual xfs_buf_cancel objects.  This leads to a memory
      leak, as reported by kmemleak in xfs/051:
      
      unreferenced object 0xffff888103629560 (size 32):
        comm "mount", pid 687045, jiffies 4296935916 (age 10.752s)
        hex dump (first 32 bytes):
          08 d3 0a 01 00 00 00 00 08 00 00 00 01 00 00 00  ................
          d0 f5 0b 92 81 88 ff ff 80 64 64 25 81 88 ff ff  .........dd%....
        backtrace:
          [<ffffffffa0317c83>] kmem_alloc+0x73/0x140 [xfs]
          [<ffffffffa03234a9>] xlog_recover_buf_commit_pass1+0x139/0x200 [xfs]
          [<ffffffffa032dc27>] xlog_recover_commit_trans+0x307/0x350 [xfs]
          [<ffffffffa032df15>] xlog_recovery_process_trans+0xa5/0xe0 [xfs]
          [<ffffffffa032e12d>] xlog_recover_process_data+0x8d/0x140 [xfs]
          [<ffffffffa032e49d>] xlog_do_recovery_pass+0x19d/0x740 [xfs]
          [<ffffffffa032f22d>] xlog_do_log_recovery+0x6d/0x150 [xfs]
          [<ffffffffa032f343>] xlog_do_recover+0x33/0x1d0 [xfs]
          [<ffffffffa032faba>] xlog_recover+0xda/0x190 [xfs]
          [<ffffffffa03194bc>] xfs_log_mount+0x14c/0x360 [xfs]
          [<ffffffffa030bfed>] xfs_mountfs+0x50d/0xa60 [xfs]
          [<ffffffffa03124b5>] xfs_fs_fill_super+0x6a5/0x950 [xfs]
          [<ffffffff812b92a5>] get_tree_bdev+0x175/0x280
          [<ffffffff812b7c3a>] vfs_get_tree+0x1a/0x80
          [<ffffffff812e366f>] path_mount+0x6ff/0xaa0
          [<ffffffff812e3b13>] __x64_sys_mount+0x103/0x140
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      8db074bd
    • Darrick J. Wong's avatar
      xfs: refactor buffer cancellation table allocation · 27232349
      Darrick J. Wong authored
      Move the code that allocates and frees the buffer cancellation tables
      used by log recovery into the file that actually uses the tables.  This
      is a precursor to some cleanups and a memory leak fix.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      27232349
    • Darrick J. Wong's avatar
      xfs: don't leak btree cursor when insrec fails after a split · a54f78de
      Darrick J. Wong authored
      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: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      a54f78de
    • Darrick J. Wong's avatar
      xfs: purge dquots after inode walk fails during quotacheck · 86d40f1e
      Darrick J. Wong authored
      xfs/434 and xfs/436 have been reporting occasional memory leaks of
      xfs_dquot objects.  These tests themselves were the messenger, not the
      culprit, since they unload the xfs module, which trips the slub
      debugging code while tearing down all the xfs slab caches:
      
      =============================================================================
      BUG xfs_dquot (Tainted: G        W        ): Objects remaining in xfs_dquot on __kmem_cache_shutdown()
      -----------------------------------------------------------------------------
      
      Slab 0xffffea000606de00 objects=30 used=5 fp=0xffff888181b78a78 flags=0x17ff80000010200(slab|head|node=0|zone=2|lastcpupid=0xfff)
      CPU: 0 PID: 3953166 Comm: modprobe Tainted: G        W         5.18.0-rc6-djwx #rc6 d5824be9e46a2393677bda868f9b154d917ca6a7
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20171121_152543-x86-ol7-builder-01.us.oracle.com-4.el7.1 04/01/2014
      
      Since we don't generally rmmod the xfs module between fstests, this
      means that xfs/434 is really just the canary in the coal mine --
      something leaked a dquot, but we don't know who.  After days of pounding
      on fstests with kmemleak enabled, I finally got it to spit this out:
      
      unreferenced object 0xffff8880465654c0 (size 536):
        comm "u10:4", pid 88, jiffies 4294935810 (age 29.512s)
        hex dump (first 32 bytes):
          60 4a 56 46 80 88 ff ff 58 ea e4 5c 80 88 ff ff  `JVF....X..\....
          00 e0 52 49 80 88 ff ff 01 00 01 00 00 00 00 00  ..RI............
        backtrace:
          [<ffffffffa0740f6c>] xfs_dquot_alloc+0x2c/0x530 [xfs]
          [<ffffffffa07443df>] xfs_qm_dqread+0x6f/0x330 [xfs]
          [<ffffffffa07462a2>] xfs_qm_dqget+0x132/0x4e0 [xfs]
          [<ffffffffa0756bb0>] xfs_qm_quotacheck_dqadjust+0xa0/0x3e0 [xfs]
          [<ffffffffa075724d>] xfs_qm_dqusage_adjust+0x35d/0x4f0 [xfs]
          [<ffffffffa06c9068>] xfs_iwalk_ag_recs+0x348/0x5d0 [xfs]
          [<ffffffffa06c95d3>] xfs_iwalk_run_callbacks+0x273/0x540 [xfs]
          [<ffffffffa06c9e8d>] xfs_iwalk_ag+0x5ed/0x890 [xfs]
          [<ffffffffa06ca22f>] xfs_iwalk_ag_work+0xff/0x170 [xfs]
          [<ffffffffa06d22c9>] xfs_pwork_work+0x79/0x130 [xfs]
          [<ffffffff81170bb2>] process_one_work+0x672/0x1040
          [<ffffffff81171b1b>] worker_thread+0x59b/0xec0
          [<ffffffff8118711e>] kthread+0x29e/0x340
          [<ffffffff810032bf>] ret_from_fork+0x1f/0x30
      
      Now we know that quotacheck is at fault, but even this report was
      canaryish -- it was triggered by xfs/494, which doesn't actually mount
      any filesystems.  (kmemleak can be a little slow to notice leaks, even
      with fstests repeatedly whacking it to look for them.)  Looking at the
      *previous* fstest, however, showed that the test run before xfs/494 was
      xfs/117.  The tipoff to the problem is in this excerpt from dmesg:
      
      XFS (sda4): Quotacheck needed: Please wait.
      XFS (sda4): Metadata corruption detected at xfs_dinode_verify.part.0+0xdb/0x7b0 [xfs], inode 0x119 dinode
      XFS (sda4): Unmount and run xfs_repair
      XFS (sda4): First 128 bytes of corrupted metadata buffer:
      00000000: 49 4e 81 a4 03 02 00 00 00 00 00 00 00 00 00 00  IN..............
      00000010: 00 00 00 01 00 00 00 00 00 90 57 54 54 1a 4c 68  ..........WTT.Lh
      00000020: 81 f9 7d e1 6d ee 16 00 34 bd 7d e1 6d ee 16 00  ..}.m...4.}.m...
      00000030: 34 bd 7d e1 6d ee 16 00 00 00 00 00 00 00 00 00  4.}.m...........
      00000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      00000050: 00 00 00 02 00 00 00 00 00 00 00 00 96 80 f3 ab  ................
      00000060: ff ff ff ff da 57 7b 11 00 00 00 00 00 00 00 03  .....W{.........
      00000070: 00 00 00 01 00 00 00 10 00 00 00 00 00 00 00 08  ................
      XFS (sda4): Quotacheck: Unsuccessful (Error -117): Disabling quotas.
      
      The dinode verifier decided that the inode was corrupt, which causes
      iget to return with EFSCORRUPTED.  Since this happened during
      quotacheck, it is obvious that the kernel aborted the inode walk on
      account of the corruption error and disabled quotas.  Unfortunately, we
      neglect to purge the dquot cache before doing that, which is how the
      dquots leaked.
      
      The problems started 10 years ago in commit b84a3a, when the dquot lists
      were converted to a radix tree, but the error handling behavior was not
      correctly preserved -- in that commit, if the bulkstat failed and
      usrquota was enabled, the bulkstat failure code would be overwritten by
      the result of flushing all the dquots to disk.  As long as that
      succeeds, we'd continue the quota mount as if everything were ok, but
      instead we're now operating with a corrupt inode and incorrect quota
      usage counts.  I didn't notice this bug in 2019 when I wrote commit
      ebd126a6, which changed quotacheck to skip the dqflush when the scan
      doesn't complete due to inode walk failures.
      
      Introduced-by: b84a3a96 ("xfs: remove the per-filesystem list of dquots")
      Fixes: ebd126a6 ("xfs: convert quotacheck to use the new iwalk functions")
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      86d40f1e
    • Dave Chinner's avatar
      xfs: assert in xfs_btree_del_cursor should take into account error · 56486f30
      Dave Chinner authored
      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: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      56486f30
    • Dave Chinner's avatar
      xfs: don't assert fail on perag references on teardown · 5b55cbc2
      Dave Chinner authored
      Not fatal, the assert is there to catch developer attention. I'm
      seeing this occasionally during recoveryloop testing after a
      shutdown, and I don't want this to stop an overnight recoveryloop
      run as it is currently doing.
      
      Convert the ASSERT to a XFS_IS_CORRUPT() check so it will dump a
      corruption report into the log and cause a test failure that way,
      but it won't stop the machine dead.
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      5b55cbc2
    • Dave Chinner's avatar
      xfs: avoid unnecessary runtime sibling pointer endian conversions · 5672225e
      Dave Chinner authored
      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: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      5672225e
  3. 22 May, 2022 14 commits
  4. 20 May, 2022 6 commits
  5. 12 May, 2022 4 commits
    • Dave Chinner's avatar
    • Dave Chinner's avatar
      xfs: can't use kmem_zalloc() for attribute buffers · 45ff8b47
      Dave Chinner authored
      Because heap allocation of 64kB buffers will fail:
      
      ....
       XFS: fs_mark(8414) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8417) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8409) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8428) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8430) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8437) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8433) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8406) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8412) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8432) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
       XFS: fs_mark(8424) possible memory allocation deadlock size 65768 in kmem_alloc (mode:0x2d40)
      ....
      
      I'd use kvmalloc() instead, but....
      
      - 48.19% xfs_attr_create_intent
        - 46.89% xfs_attri_init
           - kvmalloc_node
      	- 46.04% __kmalloc_node
      	   - kmalloc_large_node
      	      - 45.99% __alloc_pages
      		 - 39.39% __alloc_pages_slowpath.constprop.0
      		    - 38.89% __alloc_pages_direct_compact
      		       - 38.71% try_to_compact_pages
      			  - compact_zone_order
      			  - compact_zone
      			     - 21.09% isolate_migratepages_block
      				  10.31% PageHuge
      				  5.82% set_pfnblock_flags_mask
      				  0.86% get_pfnblock_flags_mask
      			     - 4.48% __reset_isolation_suitable
      				  4.44% __reset_isolation_pfn
      			     - 3.56% __pageblock_pfn_to_page
      				  1.33% pfn_to_online_page
      			       2.83% get_pfnblock_flags_mask
      			     - 0.87% migrate_pages
      				  0.86% compaction_alloc
      			       0.84% find_suitable_fallback
      		 - 6.60% get_page_from_freelist
      		      4.99% clear_page_erms
      		    - 1.19% _raw_spin_lock_irqsave
      		       - do_raw_spin_lock
      			    __pv_queued_spin_lock_slowpath
      	- 0.86% __vmalloc_node_range
      	     0.65% __alloc_pages_bulk
      
      .... this is just yet another reminder of how much kvmalloc() sucks.
      So lift xlog_cil_kvmalloc(), rename it to xlog_kvmalloc() and use
      that instead....
      
      We also clean up the attribute name and value lengths as they no
      longer need to be rounded out to sizes compatible with log vectors.
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      45ff8b47
    • Dave Chinner's avatar
      xfs: detect empty attr leaf blocks in xfs_attr3_leaf_verify · 51e6104f
      Dave Chinner authored
      xfs_repair flags these as a corruption error, so the verifier should
      catch software bugs that result in empty leaf blocks being written
      to disk, too.
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      51e6104f
    • Dave Chinner's avatar
      xfs: ATTR_REPLACE algorithm with LARP enabled needs rework · fdaf1bb3
      Dave Chinner authored
      We can't use the same algorithm for replacing an existing attribute
      when logging attributes. The existing algorithm is essentially:
      
      1. create new attr w/ INCOMPLETE
      2. atomically flip INCOMPLETE flags between old + new attribute
      3. remove old attr which is marked w/ INCOMPLETE
      
      This algorithm guarantees that we see either the old or new
      attribute, and if we fail after the atomic flag flip, we don't have
      to recover the removal of the old attr because we never see
      INCOMPLETE attributes in lookups.
      
      For logged attributes, however, this does not work. The logged
      attribute intents do not track the work that has been done as the
      transaction rolls, and hence the only recovery mechanism we have is
      "run the replace operation from scratch".
      
      This is further exacerbated by the attempt to avoid needing the
      INCOMPLETE flag to create an atomic swap. This means we can create
      a second active attribute of the same name before we remove the
      original. If we fail at any point after the create but before the
      removal has completed, we end up with duplicate attributes in
      the attr btree and recovery only tries to replace one of them.
      
      There are several other failure modes where we can leave partially
      allocated remote attributes that expose stale data, partially free
      remote attributes that enable UAF based stale data exposure, etc.
      
      TO fix this, we need a different algorithm for replace operations
      when LARP is enabled. Luckily, it's not that complex if we take the
      right first step. That is, the first thing we log is the attri
      intent with the new name/value pair and mark the old attr as
      INCOMPLETE in the same transaction.
      
      From there, we then remove the old attr and keep relogging the
      new name/value in the intent, such that we always know that we have
      to create the new attr in recovery. Once the old attr is removed,
      we then run a normal ATTR_CREATE operation relogging the intent as
      we go. If the new attr is local, then it gets created in a single
      atomic transaction that also logs the final intent done. If the new
      attr is remote, the we set INCOMPLETE on the new attr while we
      allocate and set the remote value, and then we clear the INCOMPLETE
      flag at in the last transaction taht logs the final intent done.
      
      If we fail at any point in this algorithm, log recovery will always
      see the same state on disk: the new name/value in the intent, and
      either an INCOMPLETE attr or no attr in the attr btree. If we find
      an INCOMPLETE attr, we run the full replace starting with removing
      the INCOMPLETE attr. If we don't find it, then we simply create the
      new attr.
      
      Notably, recovery of a failed create that has an INCOMPLETE flag set
      is now the same - we start with the lookup of the INCOMPLETE attr,
      and if that exists then we do the full replace recovery process,
      otherwise we just create the new attr.
      
      Hence changing the way we do the replace operation when LARP is
      enabled allows us to use the same log recovery algorithm for both
      the ATTR_CREATE and ATTR_REPLACE operations. This is also the same
      algorithm we use for runtime ATTR_REPLACE operations (except for the
      step setting up the initial conditions).
      
      The result is that:
      
      - ATTR_CREATE uses the same algorithm regardless of whether LARP is
        enabled or not
      - ATTR_REPLACE with larp=0 is identical to the old algorithm
      - ATTR_REPLACE with larp=1 runs an unmodified attr removal algorithm
        from the larp=0 code and then runs the unmodified ATTR_CREATE
        code.
      - log recovery when larp=1 runs the same ATTR_REPLACE algorithm as
        it uses at runtime.
      
      Because the state machine is now quite clean, changing the algorithm
      is really just a case of changing the initial state and how the
      states link together for the ATTR_REPLACE case. Hence it's not a
      huge amount of code for what is a fairly substantial rework
      of the attr logging and recovery algorithm....
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarAllison Henderson <allison.henderson@oracle.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
      fdaf1bb3