sys/vfs/hammer: Fix incomplete mountctl(2) vop behavior
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 17 Sep 2015 10:31:56 +0000 (19:31 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 24 Sep 2015 14:09:53 +0000 (23:09 +0900)
commit87b8f936e9f58031ae638e720361f548bcb9e121
tree07d2bc4645440ebf203e59e3eb7e78187b725328
parente2a9b402fba6588052ea681c52888d7ba253c97a
sys/vfs/hammer: Fix incomplete mountctl(2) vop behavior

mount(8) is unable to print nomirror mount option while other
two (nohistory, master=) are properly printed. This is because
hammer's mountctl and mount flags aren't implemented the way
vfs expects them to be. mount(8) generates option strings by
mountctl(2).

===== missing nomirror string
  # mount_hammer -o nohistory -o master=5 -o nomirror /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # mount | grep /HAMMER
  TEST on /HAMMER (hammer, local, nohistory, master)

===== using this commit
  # mount_hammer -o nohistory -o master=5 -o nomirror /dev/da1:/dev/da2:/dev/da3 /HAMMER
  # mount | grep /HAMMER
  TEST on /HAMMER (hammer, local, nohistory, master, nomirror)

This commit adds HMNT_NOMIRROR using a reserved HMNT_RESERVED
and assigns HMNT_NOMIRROR to nomirror. This is necessary since
two options (master=, nomirror) using the same HMNT_MASTERID
is the root cause of above behavior.

This change would affect userspace in theory, however the only
userspace that would actually use these mount option flags is
mount command itself (for inbox userspace programs at least).
It's more important that hammer properly handles mount(8).

This commit also adds a missing nomirror mountctl element in
hammer_vop_mountctl() using HMNT_NOMIRROR so mountctl becomes
aware of nomirror option.

The reason nomirror needs to use HMNT_NOMIRROR instead of
HMNT_MASTERID is because vfs_flagstostr() assumes each option
has an unique flag (see vfs_flagstostr() where it does the
following).
  flags &= ~optp->o_opt;

This could have been fixed by changing above vfs code, but
fixing hammer code is probably the right approach. Also note
that master= and nomirror options aren't alias of each other.
These two are similar but they do have different purpose, which
should make sense to have independent flags, and that's what
vfs expects.
sbin/mount_hammer/mount_hammer.c
sys/vfs/hammer/hammer_mount.h
sys/vfs/hammer/hammer_vfsops.c
sys/vfs/hammer/hammer_vnops.c