1. 22 Dec, 2023 5 commits
    • Christoph Hellwig's avatar
      xfs: turn the xfs_trans_mod_dquot_byino stub into an inline function · 825b49e4
      Christoph Hellwig authored
      Without this upcoming change can cause an unused variable warning,
      when adding a local variable for the fields field passed to it.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      825b49e4
    • Christoph Hellwig's avatar
      xfs: consider minlen sized extents in xfs_rtallocate_extent_block · 944df759
      Christoph Hellwig authored
      minlen is the lower bound on the extent length that the caller can
      accept, and maxlen is at this point the maximal available length.
      This means a minlen extent is perfectly fine to use, so do it.  This
      matches the equivalent logic in xfs_rtallocate_extent_exact that also
      accepts a minlen sized extent.
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      944df759
    • Wang Jinchao's avatar
      xfs/health: cleanup, remove duplicated including · b5785f61
      Wang Jinchao authored
      remove the second ones:
      \#include "xfs_trans_resv.h"
      \#include "xfs_mount.h"
      Signed-off-by: default avatarWang Jinchao <wangjinchao@xfusion.com>
      Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      b5785f61
    • Long Li's avatar
      xfs: fix perag leak when growfs fails · 78239218
      Long Li authored
      During growfs, if new ag in memory has been initialized, however
      sb_agcount has not been updated, if an error occurs at this time it
      will cause perag leaks as follows, these new AGs will not been freed
      during umount , because of these new AGs are not visible(that is
      included in mp->m_sb.sb_agcount).
      
      unreferenced object 0xffff88810be40200 (size 512):
        comm "xfs_growfs", pid 857, jiffies 4294909093
        hex dump (first 32 bytes):
          00 c0 c1 05 81 88 ff ff 04 00 00 00 00 00 00 00  ................
          01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace (crc 381741e2):
          [<ffffffff8191aef6>] __kmalloc+0x386/0x4f0
          [<ffffffff82553e65>] kmem_alloc+0xb5/0x2f0
          [<ffffffff8238dac5>] xfs_initialize_perag+0xc5/0x810
          [<ffffffff824f679c>] xfs_growfs_data+0x9bc/0xbc0
          [<ffffffff8250b90e>] xfs_file_ioctl+0x5fe/0x14d0
          [<ffffffff81aa5194>] __x64_sys_ioctl+0x144/0x1c0
          [<ffffffff83c3d81f>] do_syscall_64+0x3f/0xe0
          [<ffffffff83e00087>] entry_SYSCALL_64_after_hwframe+0x62/0x6a
      unreferenced object 0xffff88810be40800 (size 512):
        comm "xfs_growfs", pid 857, jiffies 4294909093
        hex dump (first 32 bytes):
          20 00 00 00 00 00 00 00 57 ef be dc 00 00 00 00   .......W.......
          10 08 e4 0b 81 88 ff ff 10 08 e4 0b 81 88 ff ff  ................
        backtrace (crc bde50e2d):
          [<ffffffff8191b43a>] __kmalloc_node+0x3da/0x540
          [<ffffffff81814489>] kvmalloc_node+0x99/0x160
          [<ffffffff8286acff>] bucket_table_alloc.isra.0+0x5f/0x400
          [<ffffffff8286bdc5>] rhashtable_init+0x405/0x760
          [<ffffffff8238dda3>] xfs_initialize_perag+0x3a3/0x810
          [<ffffffff824f679c>] xfs_growfs_data+0x9bc/0xbc0
          [<ffffffff8250b90e>] xfs_file_ioctl+0x5fe/0x14d0
          [<ffffffff81aa5194>] __x64_sys_ioctl+0x144/0x1c0
          [<ffffffff83c3d81f>] do_syscall_64+0x3f/0xe0
          [<ffffffff83e00087>] entry_SYSCALL_64_after_hwframe+0x62/0x6a
      
      Factor out xfs_free_unused_perag_range() from xfs_initialize_perag(),
      used for freeing unused perag within a specified range in error handling,
      included in the error path of the growfs failure.
      
      Fixes: 1c1c6ebc ("xfs: Replace per-ag array with a radix tree")
      Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
      Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      78239218
    • Long Li's avatar
      xfs: add lock protection when remove perag from radix tree · 07afd317
      Long Li authored
      Take mp->m_perag_lock for deletions from the perag radix tree in
      xfs_initialize_perag to prevent racing with tagging operations.
      Lookups are fine - they are RCU protected so already deal with the
      tree changing shape underneath the lookup - but tagging operations
      require the tree to be stable while the tags are propagated back up
      to the root.
      
      Right now there's nothing stopping radix tree tagging from operating
      while a growfs operation is progress and adding/removing new entries
      into the radix tree.
      
      Hence we can have traversals that require a stable tree occurring at
      the same time we are removing unused entries from the radix tree which
      causes the shape of the tree to change.
      
      Likely this hasn't caused a problem in the past because we are only
      doing append addition and removal so the active AG part of the tree
      is not changing shape, but that doesn't mean it is safe. Just making
      the radix tree modifications serialise against each other is obviously
      correct.
      Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      07afd317
  2. 16 Dec, 2023 6 commits
    • Chandan Babu R's avatar
      Merge tag 'repair-quota-6.8_2023-12-15' of... · 98bdbf60
      Chandan Babu R authored
      Merge tag 'repair-quota-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: online repair of quota and rt metadata files
      
      XFS stores quota records and free space bitmap information in files.
      Add the necessary infrastructure to enable repairing metadata inodes and
      their forks, and then make it so that we can repair the file metadata
      for the rtbitmap.  Repairing the bitmap contents (and the summary file)
      is left for subsequent patchsets.
      
      We also add the ability to repair file metadata the quota files.  As
      part of these repairs, we also reinitialize the ondisk dquot records as
      necessary to get the incore dquots working.  We can also correct
      obviously bad dquot record attributes, but we leave checking the
      resource usage counts for the next patchsets.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-quota-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: repair quotas
        xfs: improve dquot iteration for scrub
        xfs: check dquot resource timers
        xfs: check the ondisk space mapping behind a dquot
      98bdbf60
    • Chandan Babu R's avatar
      Merge tag 'repair-rtbitmap-6.8_2023-12-15' of... · 5bb4ad95
      Chandan Babu R authored
      Merge tag 'repair-rtbitmap-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: online repair of rt bitmap file
      
      Add in the necessary infrastructure to check the inode and data forks of
      metadata files, then apply that to the realtime bitmap file.  We won't
      be able to reconstruct the contents of the rtbitmap file until rmapbt is
      added for realtime volumes, but we can at least get the basics started.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-rtbitmap-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: online repair of realtime bitmaps
        xfs: create a new inode fork block unmap helper
        xfs: repair the inode core and forks of a metadata inode
        xfs: always check the rtbitmap and rtsummary files
        xfs: check rt summary file geometry more thoroughly
        xfs: check rt bitmap file geometry more thoroughly
      5bb4ad95
    • Chandan Babu R's avatar
      Merge tag 'repair-file-mappings-6.8_2023-12-15' of... · 98e63b91
      Chandan Babu R authored
      Merge tag 'repair-file-mappings-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: online repair of file fork mappings
      
      In this series, online repair gains the ability to rebuild data and attr
      fork mappings from the reverse mapping information.  It is at this point
      where we reintroduce the ability to reap file extents.
      
      Repair of CoW forks is a little different -- on disk, CoW staging
      extents are owned by the refcount btree and cannot be mapped back to
      individual files.  Hence we can only detect staging extents that don't
      quite look right (missing reverse mappings, shared staging extents) and
      replace them with fresh allocations.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-file-mappings-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: repair problems in CoW forks
        xfs: create a ranged query function for refcount btrees
        xfs: refactor repair forcing tests into a repair.c helper
        xfs: repair inode fork block mapping data structures
        xfs: reintroduce reaping of file metadata blocks to xrep_reap_extents
      98e63b91
    • Chandan Babu R's avatar
      Merge tag 'repair-inodes-6.8_2023-12-15' of... · 7b63ce86
      Chandan Babu R authored
      Merge tag 'repair-inodes-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: online repair of inodes and forks
      
      In this series, online repair gains the ability to repair inode records.
      To do this, we must repair the ondisk inode and fork information enough
      to pass the iget verifiers and hence make the inode igettable again.
      Once that's done, we can perform higher level repairs on the incore
      inode.  The fstests counterpart of this patchset implements stress
      testing of repair.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-inodes-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: skip the rmapbt search on an empty attr fork unless we know it was zapped
        xfs: abort directory parent scrub scans if we encounter a zapped directory
        xfs: zap broken inode forks
        xfs: repair inode records
        xfs: set inode sick state flags when we zap either ondisk fork
        xfs: dont cast to char * for XFS_DFORK_*PTR macros
        xfs: add missing nrext64 inode flag check to scrub
        xfs: try to attach dquots to files before repairing them
        xfs: disable online repair quota helpers when quota not enabled
      7b63ce86
    • Chandan Babu R's avatar
      Merge tag 'repair-ag-btrees-6.8_2023-12-15' of... · 6e1d7b89
      Chandan Babu R authored
      Merge tag 'repair-ag-btrees-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: online repair of AG btrees
      
      Now that we've spent a lot of time reworking common code in online fsck,
      we're ready to start rebuilding the AG space btrees.  This series
      implements repair functions for the free space, inode, and refcount
      btrees.  Rebuilding the reverse mapping btree is much more intense and
      is left for a subsequent patchset.  The fstests counterpart of this
      patchset implements stress testing of repair.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-ag-btrees-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: repair refcount btrees
        xfs: repair inode btrees
        xfs: repair free space btrees
        xfs: remove trivial bnobt/inobt scrub helpers
        xfs: roll the scrub transaction after completing a repair
        xfs: move the per-AG datatype bitmaps to separate files
        xfs: create separate structures and code for u32 bitmaps
      6e1d7b89
    • Chandan Babu R's avatar
      Merge tag 'repair-prep-for-bulk-loading-6.8_2023-12-15' of... · 5e60ca3f
      Chandan Babu R authored
      Merge tag 'repair-prep-for-bulk-loading-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.8-mergeB
      
      xfs: prepare repair for bulk loading
      
      Before we start merging the online repair functions, let's improve the
      bulk loading code a bit.  First, we need to fix a misinteraction between
      the AIL and the btree bulkloader wherein the delwri at the end of the
      bulk load fails to queue a buffer for writeback if it happens to be on
      the AIL list.
      
      Second, we introduce a defer ops barrier object so that the process of
      reaping blocks after a repair cannot queue more than two extents per EFI
      log item.  This increases our exposure to leaking blocks if the system
      goes down during a reap, but also should prevent transaction overflows,
      which result in the system going down.
      
      Third, we change the bulkloader itself to copy multiple records into a
      block if possible, and add some debugging knobs so that developers can
      control the slack factors, just like they can do for xfs_repair.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarChandan Babu R <chandanbabu@kernel.org>
      
      * tag 'repair-prep-for-bulk-loading-6.8_2023-12-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
        xfs: constrain dirty buffers while formatting a staged btree
        xfs: move btree bulkload record initialization to ->get_record implementations
        xfs: add debug knobs to control btree bulk load slack factors
        xfs: read leaf blocks when computing keys for bulkloading into node blocks
        xfs: set XBF_DONE on newly formatted btree block that are ready for writing
        xfs: force all buffers to be written during btree bulk load
      5e60ca3f
  3. 15 Dec, 2023 29 commits