Files
erofs-freebsd-out-tree/docs/pre11-batch-e.md
T
2026-08-18 09:20:44 +02:00

2.6 KiB

Pre11 Batch E: Mount Device Argument Cleanup

Scope

This batch consolidates caller-owned device.N argument cleanup in erofs_mount() and removes two impossible allocation checks. It does not change mount option semantics, GEOM ownership, device slot validation, mount error text, or any filesystem behavior.

Modified files:

  • src/super.c
  • docs/pre11-batch-e.md

Changes

After erofs_parse_device_options() succeeds, every exit from erofs_mount() now reaches one out_args label. Parse failure still returns directly because no caller-owned argument array has been transferred.

The operation order remains:

  1. erofs_parse_device_options()
  2. vfs_filteropt()
  3. vfs_getopt()
  4. erofs_open_device()
  5. erofs_update_iosize_max()
  6. erofs_mountfs()
  7. erofs_free_device_args()
  8. vfs_mountedfrom()
  9. erofs_statfs()

out_args only frees copied device arguments. It does not inspect or release primary. The existing erofs_mountfs() ownership transfer and all GEOM cleanup paths remain unchanged.

The checks for NULL immediately following allocation of packed_inode and metabox_en were removed. Both allocations retain M_WAITOK | M_ZERO, so a successful return cannot produce NULL. No other allocation checks or flags were changed.

Ownership Paths

Path Copied arguments Primary device Result
Parse failure No caller ownership Not opened Return parser error directly
Option filter failure Freed at out_args Not opened Return EINVAL
Invalid or missing from Freed at out_args Not opened Return EINVAL
Primary open failure Freed at out_args Open helper retains its existing cleanup contract Return open error
Mount setup failure Freed at out_args Ownership already transferred at erofs_mountfs() entry Return mount error
Success Freed at out_args Owned by the mounted filesystem Publish mounted-from and run statfs()

Static Verification

  • erofs_free_device_args() has one caller after the change.
  • erofs_mountfs() and erofs_sb_free() are unchanged.
  • The relative order of option filtering, option access, primary open, I/O sizing, mount setup, argument cleanup, mounted-from publication, and statfs is unchanged.
  • Existing errno values and mount error strings are unchanged.
  • Duplicate and missing external-device slot behavior is unchanged.
  • git diff --check passes.
  • The diff is restricted to the two declared Batch E files.

Validation Status

No build, QEMU smoke test, or feature test was run for this batch. Runtime validation is deferred to the final Pre11 build and targeted smoke test.