Skip to content

Commit

Permalink
Suuport volumes with the 0x80 incompatible feature
Browse files Browse the repository at this point in the history
The official newfs_apfs now sets a 0x80 incompatible feature in all
volumes by default. The feature is undocumented as far as I know, but
after some testing it would seem that its effect is to set a flag in
preallocated extents. I can't imagine why such a feature would be
incompatible instead of read-only compatible, so there is a chance that
I'm missing something important, but for now enable support and let's
see if anything breaks.

By the way, no real changes are needed here because we don't preallocate
extents ourselves, and we put existing preallocated extents through the
same CoW as all the others. The only problem remaining is that writes
after the end of a file will not flip the "preallocation" flags that may
be set in previous blocks, but neither the official fsck nor the driver
seem to care about this. I just don't get what this flag is for, which
is a little scary of course.

Signed-off-by: Ernesto A. Fernández <[email protected]>
  • Loading branch information
eafer committed May 4, 2024
1 parent 6e7371a commit 02cb8bb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1299,10 +1299,6 @@ static int apfs_check_vol_features(struct super_block *sb)
apfs_warn(sb, "PFK is not supported");
return -EINVAL;
}
if (features & APFS_INCOMPAT_EXTENT_PREALLOC_FLAG) {
apfs_warn(sb, "extent prealloc flag is not supported");
return -EINVAL;
}
if (features & APFS_INCOMPAT_SECONDARY_FSROOT) {
apfs_warn(sb, "secondary fsroot is not supported");
return -EINVAL;
Expand All @@ -1314,6 +1310,16 @@ static int apfs_check_vol_features(struct super_block *sb)
}
apfs_info(sb, "volume is sealed");
}
/*
* As far as I can see, all this feature seems to do is define a new
* flag (which I call APFS_FILE_EXTENT_PREALLOCATED) for extents that
* are fully after the end of their file. I don't get why this change
* is incompatible instead of read-only compatible, so I fear I might
* be missing something. I will never be certain though, so for now
* allow the mount and hope for the best.
*/
if (features & APFS_INCOMPAT_EXTENT_PREALLOC_FLAG)
apfs_warn(sb, "extent prealloc flag is set");

features = le64_to_cpu(vsb_raw->apfs_fs_flags);
/* Some encrypted volumes are readable anyway */
Expand Down

0 comments on commit 02cb8bb

Please sign in to comment.