[Bug 281456] makefs zfs is tricky to get right with multiple partitions, matching freebsd install default

From: <bugzilla-noreply_at_freebsd.org>
Date: Thu, 12 Sep 2024 18:08:51 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281456

--- Comment #3 from Pat Maddox <pat@patmaddox.com> ---
> The release scripts use the following invocation

Ah good to know about that, thanks. Next time I will grep the code base to see
where the tools might be being used. The tests were very helpful though.

> Would it be useful to include that as an example in the makefs man page?

I think so. Even a simplified example would be helpful, along the lines of the
layout that I showed above. And maybe a script in examples/. I share Ed's take
that either one would get out of sync with the installer. I think on the lower
end of effort, a simplified example in man page is fine, plus a note to find
the complete & current invocation in the release script.

A smaller note: the man page says "fs-options is a comma-separated list of
options." I didn't realize I could pass -o multiple times, so was doing stuff
like -o
poolname=zroot,rootpath=/,fs=zroot/foo\;mountpoint=/foo\;canmount=on,fs=zroot/bar\;mountpoint=/foo\;canmount=on.
Perhaps it's convention that comma-separated can be split into multiple args, I
don't know - but multiple -o was more natural and easier to read, which I got
from the tests.

> What ordering constraints were causing problems?

After another look, I don't think it was an order issue. Rather it looks like
the expectations around datasets mounted at /.

The scenarios I came up with are:

1. Defining a dataset with mountpoint=/, while not defining the root dataset. I
think this is an implicit example of 1a.
1a. Defining the root dataset with mountpoint=/ and another dataset with it.
2. Defining root dataset to have mountpoint!=rootpath, and no dataset with
mountpoint=rootpath

An interesting variation of 1a is that it's possible to define two datasets
with same mountpoint, even if both canmount. So it seems limited to / or
rootpath.

---

Example 1: Additional dataset with mountpoint=/, root dataset undefined

makefs -t zfs -s 64m -o poolname=zroot -o rootpath=/ -o
fs=zroot/ROOT\;mountpoint=none -o fs=zroot/ROOT/default\;mountpoint=/ test.img
foo
ZFS support is currently considered experimental. Do not use it for anything
critical.
Assertion failed: (cur->inode->param == NULL), function fs_layout_one, file
/home/patmaddox/wip/.trees/infra-pdt-rewrite/infra/pdt/freebsd-src.git/b/stable/14/usr.sbin/makefs/zfs/fs.c,
line 886.
Abort trap (core dumped)

---

Example 1a: Additional dataset with mountpoint=/, root dataset explicit
mountpoint=/ (succeeds if canmount=off)


makefs -t zfs -s 64m -o poolname=zroot -o rootpath=/ -o fs=zroot\;mountpoint=/
-o fs=zroot/ROOT\;mountpoint=none -o fs=zroot/ROOT/default\;mountpoint=/
test.img foo
ZFS support is currently considered experimental. Do not use it for anything
critical.
Assertion failed: (cur->inode->param == NULL), function fs_layout_one, file
/home/patmaddox/wip/.trees/infra-pdt-rewrite/infra/pdt/freebsd-src.git/b/stable/14/usr.sbin/makefs/zfs/fs.c,
line 886.
Abort trap (core dumped)

makefs -t zfs -s 64m -o poolname=zroot -o rootpath=/ -o
fs=zroot\;mountpoint=/\;canmount=off -o fs=zroot/ROOT\;mountpoint=none -o
fs=zroot/ROOT/default\;mountpoint=/ test.img foo
ZFS support is currently considered experimental. Do not use it for anything
critical.

--- example 2: solo root dataset with mountpoint!=rootpath

makefs -t zfs -s 64m -o rootpath=/ -o poolname=zroot -o
fs=zroot\;mountpoint=/zroot main.zfs foo
ZFS support is currently considered experimental. Do not use it for anything
critical.
Segmentation fault (core dumped)

---

bonus: two datasets with same mountpoint succeeds

makefs -t zfs -s 64m -o poolname=zroot -o rootpath=/ -o
fs=zroot/foo\;mountpoint=/foo -o fs=zroot/bar\;mountpoint=/foo test.img foo
makefs -t zfs -s 64m -o poolname=zroot -o rootpath=/ -o
fs=zroot/foo\;mountpoint=/foo -o fs=zroot/bar\;mountpoint=/foo test.img foo
ZFS support is currently considered experimental. Do not use it for anything
critical.

-- 
You are receiving this mail because:
You are the assignee for the bug.