Greetings. I'm curious whether the behavior I'm seeing is intended
when dealing with the situation of nested vnd files where the
lower/outer device is read-only (or whether I'm misunderstanding some
filesystem semantics). Full steps to reproduce are below (a little
verbose, I apologize) on 5.6-stable. The summary is:

Expected: Mount outer vnd as ro, mount inner vnd as ro.
Expected: Mount outer vnd as ro, attempt to mount inner vnd as rw, fails.
Unexpected: Mount outer vnd as ro, mount inner vnd as ro. Attempt to
remount inner vnd as rw, it succeeds despite outer vnd remaining ro.
Mounted inner vnd will accept changes, which appear to be retained in
the filesystem after unmounting everything and remounting.

-----

Create a 50 MB a.vnd...

# dd if=/dev/zero of=a.vnd bs=1m count=50
...
# vnconfig vnd0 a.vnd
# fdisk -i vnd0
...
# disklabel -Aw vnd0
# newfs /dev/rvnd0a
...
# mount /dev/vnd0a /tmp/a

Repeat the process for a 25 MB b.vnd inside the mounted a.vnd...

# cd /tmp/a
# dd if=/dev/zero of=b.vnd bs=1m count=25
...
# vnconfig vnd1 b.vnd
# fdisk -i vnd1
...
# disklabel -Aw vnd1
# newfs /dev/rvnd1a
...
# mount /dev/vnd1a /tmp/b

Looks good so far, both are mounted rw. Unconfigure and unmount each
vnd, outer first.

Mount both as ro...

# vnconfig vnd0 a.vnd
# mount -o ro /dev/vnd0a /tmp/a
# vnconfig vnd1 /tmp/a/b.vnd
# mount -o ro /dev/vnd1a /tmp/b
# mount|grep vnd
/dev/vnd0a on /tmp/a type ffs (local, read-only)
/dev/vnd1a on /tmp/b type ffs (local, read-only)

Start over, mount a.vnd as ro, attempt to mount b.vnd as rw...

# vnconfig vnd0 a.vnd
# mount -o ro /dev/vnd0a /tmp/a
# vnconfig vnd1 /tmp/a/b.vnd
# mount -o rw /dev/vnd1a /tmp/b
mount_ffs: /dev/vnd1a on /tmp/b: filesystem must be mounted read-only;
you may need to run fsck

Start over, mount both as ro, then switch /tmp/b to rw...

# vnconfig vnd0 a.vnd
# mount -o ro /dev/vnd0a /tmp/a
# vnconfig vnd1 /tmp/a/b.vnd
# mount -o ro /dev/vnd1a /tmp/b
# mount|grep vnd
/dev/vnd0a on /tmp/a type ffs (local, read-only)
/dev/vnd1a on /tmp/b type ffs (local, read-only)
# mount -oupdate,rw /tmp/b
# mount|grep vnd
/dev/vnd0a on /tmp/a type ffs (local, read-only)
/dev/vnd1a on /tmp/b type ffs (local)

Verify /tmp/a still ro, write to the newly-rw /tmp/b, and unmount...

# echo hi > /tmp/a/test
ksh: cannot create /tmp/a/test: Read-only file system
# echo hi > /tmp/b/test
# umount /tmp/b
# vnconfig -u vnd1
# umount /tmp/a
# vnconfig -u vnd0

Verify write succeeded...

# vnconfig vnd0 a.vnd
# mount -o ro /dev/vnd0a /tmp/a
# vnconfig vnd1 /tmp/a/b.vnd
# mount -o ro /dev/vnd1a /tmp/b
# cat /tmp/b/test
hi

I was surprised that a.) the /tmp/b mount allowed itself to be changed
to rw, and that b.) the /tmp/a mount accepted changes to its
filesystem despite being read-only.

Thanks.

Brian Conway

Reply via email to