An error occurred fetching the project authors.
  1. 15 Apr, 2024 1 commit
  2. 15 Dec, 2023 4 commits
    • Darrick J. Wong's avatar
      xfs: repair inode records · 2d295fe6
      Darrick J. Wong authored
      If an inode is so badly damaged that it cannot be loaded into the cache,
      fix the ondisk metadata and try again.  If there /is/ a cached inode,
      fix any problems and apply any optimizations that can be solved incore.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      2d295fe6
    • Darrick J. Wong's avatar
      xfs: dont cast to char * for XFS_DFORK_*PTR macros · 6b5d9177
      Darrick J. Wong authored
      Code in the next patch will assign the return value of XFS_DFORK_*PTR
      macros to a struct pointer.  gcc complains about casting char* strings
      to struct pointers, so let's fix the macro's cast to void* to shut up
      the warnings.
      
      While we're at it, fix one of the scrub tests that uses PTR to use BOFF
      instead for a simpler integer comparison, since other linters whine
      about char* and void* comparisons.
      
      Can't satisfy all these dman bots.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      6b5d9177
    • Darrick J. Wong's avatar
      xfs: add missing nrext64 inode flag check to scrub · 576d30ec
      Darrick J. Wong authored
      Add this missing check that the superblock nrext64 flag is set if the
      inode flag is set.
      
      Fixes: 9b7d16e3 ("xfs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers")
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      576d30ec
    • Darrick J. Wong's avatar
      xfs: try to attach dquots to files before repairing them · 259ba1d3
      Darrick J. Wong authored
      Inode resource usage is tracked in the quota metadata.  Repairing a file
      might change the resources used by that file, which means that we need
      to attach dquots to the file that we're examining before accessing
      anything in the file protected by the ILOCK.
      
      However, there's a twist: a dquot cache miss requires the dquot to be
      read in from the quota file, during which we drop the ILOCK on the file
      being examined.  This means that we *must* try to attach the dquots
      before taking the ILOCK.
      
      Therefore, dquots must be attached to files in the scrub setup function.
      If doing so yields corruption errors (or unknown dquot errors), we
      instead clear the quotachecked status, which will cause a quotacheck on
      next mount.  A future series will make this trigger live quotacheck.
      
      While we're here, change the xrep_ino_dqattach function to use the
      unlocked dqattach functions so that we avoid cycling the ILOCK if the
      inode already has dquots attached.  This makes the naming and locking
      requirements consistent with the rest of the filesystem.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      259ba1d3
  3. 07 Dec, 2023 1 commit
  4. 17 Oct, 2023 1 commit
  5. 10 Aug, 2023 2 commits
  6. 12 Apr, 2023 8 commits
    • Darrick J. Wong's avatar
      xfs: don't take the MMAPLOCK when scrubbing file metadata · 1fc7a059
      Darrick J. Wong authored
      The MMAPLOCK stabilizes mappings in a file's pagecache.  Therefore, we
      do not need it to check directories, symlinks, extended attributes, or
      file-based metadata.  Reduce its usage to the one case that requires it,
      which is when we want to scrub the data fork of a regular file.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      1fc7a059
    • Darrick J. Wong's avatar
      xfs: retain the AGI when we can't iget an inode to scrub the core · 38bb1310
      Darrick J. Wong authored
      xchk_get_inode is not quite the right function to be calling from the
      inode scrubber setup function.  The common get_inode function either
      gets an inode and installs it in the scrub context, or it returns an
      error code explaining what happened.  This is acceptable for most file
      scrubbers because it is not in their scope to fix corruptions in the
      inode core and fork areas that cause iget to fail.
      
      Dealing with these problems is within the scope of the inode scrubber,
      however.  If iget fails with EFSCORRUPTED, we need to xchk_inode to flag
      that as corruption.  Since we can't get our hands on an incore inode, we
      need to hold the AGI to prevent inode allocation activity so that
      nothing changes in the inode metadata.
      
      Looking ahead to the inode core repair patches, we will also need to
      hold the AGI buffer into xrep_inode so that we can make modifications to
      the xfs_dinode structure without any other thread swooping in to
      allocate or free the inode.
      
      Adapt the xchk_get_inode into xchk_setup_inode since this is a one-off
      use case where the error codes we check for are a little different, and
      the return state is much different from the common function.
      
      xchk_setup_inode prepares to check or repair an inode record, so it must
      continue the scrub operation even if the inode/inobt verifiers cause
      xfs_iget to return EFSCORRUPTED.  This is done by attaching the locked
      AGI buffer to the scrub transaction and returning 0 to move on to the
      actual scrub.  (Later, the online inode repair code will also want the
      xfs_imap structure so that it can reset the ondisk xfs_dinode
      structure.)
      
      xchk_get_inode retrieves an inode on behalf of a scrubber that operates
      on an incore inode -- data/attr/cow forks, directories, xattrs,
      symlinks, parent pointers, etc.  If the inode/inobt verifiers fail and
      xfs_iget returns EFSCORRUPTED, we want to exit to userspace (because the
      caller should be fix the inode first) and drop everything we acquired
      along the way.
      
      A behavior common to both functions is that it's possible that xfs_scrub
      asked for a scrub-by-handle concurrent with the inode being freed or the
      passed-in inumber is invalid.  In this case, we call xfs_imap to see if
      the inobt index thinks the inode is allocated, and return ENOENT
      ("nothing to check here") to userspace if this is not the case.  The
      imap lookup is why both functions call xchk_iget_agi.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      38bb1310
    • Darrick J. Wong's avatar
      xfs: rename xchk_get_inode -> xchk_iget_for_scrubbing · 46e0dd89
      Darrick J. Wong authored
      Dave Chinner suggested renaming this function to make more obvious what
      it does.  The function returns an incore inode to callers that want to
      scrub a metadata structure that hangs off an inode.  If the iget fails
      with EINVAL, it will single-step the loading process to distinguish
      between actually free inodes or impossible inumbers (ENOENT);
      discrepancies between the inobt freemask and the free status in the
      inode record (EFSCORRUPTED).  Any other negative errno is returned
      unchanged.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      46e0dd89
    • Darrick J. Wong's avatar
      xfs: teach scrub to check for sole ownership of metadata objects · 69115f77
      Darrick J. Wong authored
      Strengthen online scrub's checking even further by enabling us to check
      that a range of blocks are owned solely by a given owner.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      69115f77
    • Darrick J. Wong's avatar
      xfs: ensure that all metadata and data blocks are not cow staging extents · 7ac14fa2
      Darrick J. Wong authored
      Make sure that all filesystem metadata blocks and file data blocks are
      not also marked as CoW staging extents.  The extra checking added here
      was inspired by an actual VM host filesystem corruption incident due to
      bugs in the CoW handling of 4.x kernels.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      7ac14fa2
    • Darrick J. Wong's avatar
      xfs: minimize overhead of drain wakeups by using jump labels · 466c525d
      Darrick J. Wong authored
      To reduce the runtime overhead even further when online fsck isn't
      running, use a static branch key to decide if we call wake_up on the
      drain.  For compilers that support jump labels, the call to wake_up is
      replaced by a nop sled when nobody is waiting for intents to drain.
      
      From my initial microbenchmarking, every transition of the static key
      between the on and off states takes about 22000ns to complete; this is
      paid entirely by the xfs_scrub process.  When the static key is off
      (which it should be when fsck isn't running), the nop sled adds an
      overhead of approximately 0.36ns to runtime code.  The post-atomic
      lockless waiter check adds about 0.03ns, which is basically free.
      
      For the few compilers that don't support jump labels, runtime code pays
      the cost of calling wake_up on an empty waitqueue, which was observed to
      be about 30ns.  However, most architectures that have sufficient memory
      and CPU capacity to run XFS also support jump labels, so this is not
      much of a worry.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      466c525d
    • Darrick J. Wong's avatar
      xfs: update copyright years for scrub/ files · ecc73f8a
      Darrick J. Wong authored
      Update the copyright years in the scrub/ source code files.  This isn't
      required, but it's helpful to remind myself just how long it's taken to
      develop this feature.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      ecc73f8a
    • Darrick J. Wong's avatar
      xfs: fix author and spdx headers on scrub/ files · 739a2fe0
      Darrick J. Wong authored
      Fix the spdx tags to match current practice, and update the author
      contact information.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
      739a2fe0
  7. 17 Nov, 2022 1 commit
  8. 11 Apr, 2022 2 commits
  9. 06 Jan, 2022 1 commit
  10. 20 Aug, 2021 1 commit
    • Darrick J. Wong's avatar
      xfs: fix perag structure refcounting error when scrub fails · 61e0d0cc
      Darrick J. Wong authored
      The kernel test robot found the following bug when running xfs/355 to
      scrub a bmap btree:
      
      XFS: Assertion failed: !sa->pag, file: fs/xfs/scrub/common.c, line: 412
      ------------[ cut here ]------------
      kernel BUG at fs/xfs/xfs_message.c:110!
      invalid opcode: 0000 [#1] SMP PTI
      CPU: 2 PID: 1415 Comm: xfs_scrub Not tainted 5.14.0-rc4-00021-g48c6615c #1
      Hardware name: Hewlett-Packard p6-1451cx/2ADA, BIOS 8.15 02/05/2013
      RIP: 0010:assfail+0x23/0x28 [xfs]
      RSP: 0018:ffffc9000aacb890 EFLAGS: 00010202
      RAX: 0000000000000000 RBX: ffffc9000aacbcc8 RCX: 0000000000000000
      RDX: 00000000ffffffc0 RSI: 000000000000000a RDI: ffffffffc09e7dcd
      RBP: ffffc9000aacbc80 R08: ffff8881fdf17d50 R09: 0000000000000000
      R10: 000000000000000a R11: f000000000000000 R12: 0000000000000000
      R13: ffff88820c7ed000 R14: 0000000000000001 R15: ffffc9000aacb980
      FS:  00007f185b955700(0000) GS:ffff8881fdf00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f7f6ef43000 CR3: 000000020de38002 CR4: 00000000001706e0
      Call Trace:
       xchk_ag_read_headers+0xda/0x100 [xfs]
       xchk_ag_init+0x15/0x40 [xfs]
       xchk_btree_check_block_owner+0x76/0x180 [xfs]
       xchk_btree_get_block+0xd0/0x140 [xfs]
       xchk_btree+0x32e/0x440 [xfs]
       xchk_bmap_btree+0xd4/0x140 [xfs]
       xchk_bmap+0x1eb/0x3c0 [xfs]
       xfs_scrub_metadata+0x227/0x4c0 [xfs]
       xfs_ioc_scrub_metadata+0x50/0xc0 [xfs]
       xfs_file_ioctl+0x90c/0xc40 [xfs]
       __x64_sys_ioctl+0x83/0xc0
       do_syscall_64+0x3b/0xc0
      
      The unusual handling of errors while initializing struct xchk_ag is the
      root cause here.  Since the beginning of xfs_scrub, the goal of
      xchk_ag_read_headers has been to read all three AG header buffers and
      attach them both to the xchk_ag structure and the scrub transaction.
      Corruption errors on any of the three headers doesn't necessarily
      trigger an immediate return to userspace, because xfs_scrub can also
      tell us to /fix/ the problem.
      
      In other words, it's possible for the xchk_ag init functions to return
      an error code and a partially filled out structure so that scrub can use
      however much information it managed to pull.  Before 5.15, it was
      sufficient to cancel (or commit) the scrub transaction on the way out of
      the scrub code to release the buffers.
      
      Ccommit 48c6615c added a reference to the perag structure to struct
      xchk_ag.  Since perag structures are not attached to transactions like
      buffers are, this adds the requirement that the perag ref be released
      explicitly.  The scrub teardown function xchk_teardown was amended to do
      this for the xchk_ag embedded in struct xfs_scrub.
      
      Unfortunately, I forgot that certain parts of the scrub code probe
      multiple AGs and therefore handle the initialization and cleanup on
      their own.  Specifically, the bmbt scrubber will initialize it long
      enough to cross-reference AG metadata for btree blocks and for the
      extent mappings in the bmbt.
      
      If one of the AG headers is corrupt, the init function returns with a
      live perag structure reference and some of the AG header buffers.  If an
      error occurs, the cross referencing will be noted as XCORRUPTion and
      skipped, but the main scrub process will move on to the next record.
      It is now necessary to release the perag reference before we try to
      analyze something from a different AG, or else we'll trip over the
      assertion noted above.
      
      Fixes: 48c6615c ("xfs: grab active perag ref when reading AG headers")
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
      61e0d0cc
  11. 19 Aug, 2021 2 commits
    • Dave Chinner's avatar
      xfs: convert xfs_sb_version_has checks to use mount features · ebd9027d
      Dave Chinner authored
      This is a conversion of the remaining xfs_sb_version_has..(sbp)
      checks to use xfs_has_..(mp) feature checks.
      
      This was largely done with a vim replacement macro that did:
      
      :0,$s/xfs_sb_version_has\(.*\)&\(.*\)->m_sb/xfs_has_\1\2/g<CR>
      
      A couple of other variants were also used, and the rest touched up
      by hand.
      
      $ size -t fs/xfs/built-in.a
      	   text    data     bss     dec     hex filename
      before	1127533  311352     484 1439369  15f689 (TOTALS)
      after	1125360  311352     484 1437196  15ee0c (TOTALS)
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      ebd9027d
    • Dave Chinner's avatar
      xfs: replace xfs_sb_version checks with feature flag checks · 38c26bfd
      Dave Chinner authored
      Convert the xfs_sb_version_hasfoo() to checks against
      mp->m_features. Checks of the superblock itself during disk
      operations (e.g. in the read/write verifiers and the to/from disk
      formatters) are not converted - they operate purely on the
      superblock state. Everything else should use the mount features.
      
      Large parts of this conversion were done with sed with commands like
      this:
      
      for f in `git grep -l xfs_sb_version_has fs/xfs/*.c`; do
      	sed -i -e 's/xfs_sb_version_has\(.*\)(&\(.*\)->m_sb)/xfs_has_\1(\2)/' $f
      done
      
      With manual cleanups for things like "xfs_has_extflgbit" and other
      little inconsistencies in naming.
      
      The result is ia lot less typing to check features and an XFS binary
      size reduced by a bit over 3kB:
      
      $ size -t fs/xfs/built-in.a
      	text	   data	    bss	    dec	    hex	filenam
      before	1130866  311352     484 1442702  16038e (TOTALS)
      after	1127727  311352     484 1439563  15f74b (TOTALS)
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      38c26bfd
  12. 09 Aug, 2021 1 commit
    • Darrick J. Wong's avatar
      xfs: grab active perag ref when reading AG headers · 48c6615c
      Darrick J. Wong authored
      This patch prepares scrub to deal with the possibility of tearing down
      entire AGs by changing the order of resource acquisition to match the
      rest of the XFS codebase.  In other words, scrub now grabs AG resources
      in order of: perag structure, then AGI/AGF/AGFL buffers, then btree
      cursors; and releases them in reverse order.
      
      This requires us to distinguish xchk_ag_init callers -- some are
      responding to a user request to check AG metadata, in which case we can
      return ENOENT to userspace; but other callers have an ondisk reference
      to an AG that they're trying to cross-reference.  In this second case,
      the lack of an AG means there's ondisk corruption, since ondisk metadata
      cannot point into nonexistent space.
      Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
      Reviewed-by: default avatarChandan Babu R <chandanrlinux@gmail.com>
      48c6615c
  13. 15 Jul, 2021 1 commit
  14. 09 Apr, 2021 1 commit
  15. 09 Dec, 2020 1 commit
  16. 04 Nov, 2020 1 commit
  17. 16 Sep, 2020 2 commits
  18. 29 Jun, 2019 1 commit
  19. 12 Dec, 2018 1 commit
  20. 29 Sep, 2018 1 commit
  21. 23 Jul, 2018 3 commits
  22. 06 Jun, 2018 1 commit
    • Dave Chinner's avatar
      xfs: convert to SPDX license tags · 0b61f8a4
      Dave Chinner authored
      Remove the verbose license text from XFS files and replace them
      with SPDX tags. This does not change the license of any of the code,
      merely refers to the common, up-to-date license files in LICENSES/
      
      This change was mostly scripted. fs/xfs/Makefile and
      fs/xfs/libxfs/xfs_fs.h were modified by hand, the rest were detected
      and modified by the following command:
      
      for f in `git grep -l "GNU General" fs/xfs/` ; do
      	echo $f
      	cat $f | awk -f hdr.awk > $f.new
      	mv -f $f.new $f
      done
      
      And the hdr.awk script that did the modification (including
      detecting the difference between GPL-2.0 and GPL-2.0+ licenses)
      is as follows:
      
      $ cat hdr.awk
      BEGIN {
      	hdr = 1.0
      	tag = "GPL-2.0"
      	str = ""
      }
      
      /^ \* This program is free software/ {
      	hdr = 2.0;
      	next
      }
      
      /any later version./ {
      	tag = "GPL-2.0+"
      	next
      }
      
      /^ \*\// {
      	if (hdr > 0.0) {
      		print "// SPDX-License-Identifier: " tag
      		print str
      		print $0
      		str=""
      		hdr = 0.0
      		next
      	}
      	print $0
      	next
      }
      
      /^ \* / {
      	if (hdr > 1.0)
      		next
      	if (hdr > 0.0) {
      		if (str != "")
      			str = str "\n"
      		str = str $0
      		next
      	}
      	print $0
      	next
      }
      
      /^ \*/ {
      	if (hdr > 0.0)
      		next
      	print $0
      	next
      }
      
      // {
      	if (hdr > 0.0) {
      		if (str != "")
      			str = str "\n"
      		str = str $0
      		next
      	}
      	print $0
      }
      
      END { }
      $
      Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
      Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
      0b61f8a4
  23. 30 May, 2018 1 commit
  24. 16 May, 2018 1 commit