xfs: online repair of extended attributes [v30.3 07/16]

This series employs atomic extent swapping to enable safe reconstruction
 of extended attribute data attached to a file.  Because xattrs do not
 have any redundant information to draw off of, we can at best salvage
 as much data as we can and build a new structure.
 
 Rebuilding an extended attribute structure consists of these three
 steps:
 
 First, we walk the existing attributes to salvage as many of them as we
 can, by adding them as new attributes attached to the repair tempfile.
 We need to add a new xfile-based data structure to hold blobs of
 arbitrary length to stage the xattr names and values.
 
 Second, we write the salvaged attributes to a temporary file, and use
 atomic extent swaps to exchange the entire attribute fork between the
 two files.
 
 Finally, we reap the old xattr blocks (which are now in the temporary
 file) as carefully as we can.
 
 This has been running on the djcloud for months with no problems.  Enjoy!
 
 Signed-off-by: Darrick J. Wong <djwong@kernel.org>
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQQ2qTKExjcn+O1o2YRKO3ySh0YRpgUCZh23UwAKCRBKO3ySh0YR
 pgtVAQDEjDtM1TqUn8neJtXqtOPC2FZdLFq6Z1uSzxGWSRi9TwD/fcwgpvIrdF7g
 LFrCRk9UUJZRxrK6kGb+RcEtSJwwNwc=
 =FVWN
 -----END PGP SIGNATURE-----

Merge tag 'repair-xattrs-6.10_2024-04-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux into xfs-6.10-mergeA

xfs: online repair of extended attributes

This series employs atomic extent swapping to enable safe reconstruction
of extended attribute data attached to a file.  Because xattrs do not
have any redundant information to draw off of, we can at best salvage
as much data as we can and build a new structure.

Rebuilding an extended attribute structure consists of these three
steps:

First, we walk the existing attributes to salvage as many of them as we
can, by adding them as new attributes attached to the repair tempfile.
We need to add a new xfile-based data structure to hold blobs of
arbitrary length to stage the xattr names and values.

Second, we write the salvaged attributes to a temporary file, and use
atomic extent swaps to exchange the entire attribute fork between the
two files.

Finally, we reap the old xattr blocks (which are now in the temporary
file) as carefully as we can.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>

* tag 'repair-xattrs-6.10_2024-04-15' of https://git.kernel.org/pub/scm/linux/kernel/git/djwong/xfs-linux:
  xfs: create an xattr iteration function for scrub
  xfs: flag empty xattr leaf blocks for optimization
  xfs: scrub should set preen if attr leaf has holes
  xfs: repair extended attributes
  xfs: use atomic extent swapping to fix user file fork data
  xfs: create a blob array data structure
  xfs: enable discarding of folios backing an xfile
This commit is contained in:
Chandan Babu R 2024-04-16 11:53:09 +05:30
commit 5f3e951186
30 changed files with 2284 additions and 83 deletions