* preserve GFS2 inode metadata during rebuilds - #422
Merged
Merged
Conversation
Hawkynt
force-pushed
the
feat/gfs2-metadata-preservation
branch
from
September 30, 2026 12:02
4094512 to
de166df
Compare
Hawkynt
force-pushed
the
feat/gfs2-metadata-preservation
branch
2 times, most recently
from
September 30, 2026 16:09
f02ffaa to
6586955
Compare
Rebuild based edits retained only the image size and lock table, replacing file ownership, permissions, flags, timestamp precision, and UUID. Capture those dinode attributes and feed them back into buffered and streaming writer paths. The GFS2 inode layout follows the public Linux gfs2_ondisk.h definition; extended-attribute trees remain outside this change. Add a regression covering file metadata and UUID preservation across add.
…an have Symptom: the metadata-preserving rebuild copied di_flags verbatim. A source file flagged JDATA (data blocks behind a meta header, bsize - 24 bytes each) or EA_INDIRECT (an extended-attribute tree) was rewritten with plain data blocks and no attribute tree while still claiming both, and the writer accepted any flag word from a caller. Root cause: di_flags mixes access policy with layout, directory-only and transient bits (gfs2_ondisk.h), and the writer did not distinguish them. Fix: the writer accepts only DIRECTIO, IMMUTABLE, APPENDONLY, NOATIME and SYNC on a regular file and refuses the rest; the edit profile narrows a source file's flags to that set, skips directories, keeps the first entry of a repeated name instead of throwing, and zeroes out-of-range nanoseconds. Tests cover the default attributes, every policy flag, each refused layout flag, non-regular modes, the 999999999/1000000000 nanosecond boundary, Remove preservation, JDATA stripping on rebuild and the Uuid create option. A new external test has fsck.gfs2 accept the volume before and after a rebuild and gfs2_edit decode mode, uid, gid, the three timestamps and di_flags from the rebuilt dinode.
The support matrix and limitations now say which attributes a rebuild keeps and which it drops; the generated API sections were stale for the new Gfs2InodeMetadata type and writer overloads, which failed the package-README gate.
Hawkynt
force-pushed
the
feat/gfs2-metadata-preservation
branch
from
September 30, 2026 18:06
16801ef to
a2c407d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Gfs2Entry.The existing GFS2 implementation already provides image creation, nested directories, streaming reads/writes, defragmentation, and unused-space wiping. This change closes a metadata-loss path in rebuild operations. Extended-attribute trees and directory inode attributes are not preserved yet.
Validation
git diff --checkpassed.dotnet test Compression.Tests/Compression.Tests.csproj --filter FullyQualifiedName~Gfs2ModifyTests --no-restore; unable to run because the environment has nodotnetexecutable.gfs2_ondisk.hlayout. The change is original code based on that published structure; no GPL implementation code was copied.Review update
main.di_flagswas copied verbatim. A source file flagged JDATA (data blocks behind a meta header) or EA_INDIRECT (an extended-attribute tree) was rebuilt with plain data blocks and no attribute tree, yet still claimed both. The writer now accepts only the access-policy bits (DIRECTIO, IMMUTABLE, APPENDONLY, NOATIME, SYNC, pergfs2_ondisk.h) on a regular file and refuses the rest. The rebuild profile narrows a source file's flags to that set, skips directories, and does not throw on a repeated name.Uuidcreate option (valid, non-hex, 15 and 17 bytes).AttributedFile_SurvivesRebuild_AndGfs2EditDecodesItsDinode.fsck.gfs2 -naccepts the volume before and after a rebuild, andgfs2_editdecodes mode, uid, gid, atime/mtime/ctime anddi_flagsfrom the rebuilt dinode.gfs2_editdoes not print the*_nsecfields, so the internal tests cover those.Compression.Tests.Gfs2tests, WSL external gates included: 67 passed, 1 skipped.