Page MenuHomeFreeBSD

add a global file system mount option called "fsid" that overrides the file system's choice of fsid
AcceptedPublic

Authored by rmacklem on Nov 4 2018, 11:38 PM.

Details

Reviewers
avg
kib
jpaetzel
Summary

For some file system types such as ZFS, it is possible to copy/clone the file system so that the fileno for files
do not change, but the fsid for the file system does change.
Since the fsid is used in file handles (mostly used by the NFS server), this will result in a change in the file
handle for a file and ESTALE (stale file handle) errors if the cloned file system is used in a failover NFS server.

This patch adds a generic mount option "fsid=<N>" which replaces the fsid chosen by the file system with "<N>"
at mount time. The option can only be used during initial mounting and not during a "mount -u".

Test Plan

At this time, minimal testing using UFS shows that it seems to work when file handles are examined in
wireshark.
It needs to be tested for ZFS (which I think means changes to ZFS are required to make the option work,
since ZFS handles mount options internally).

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 20631

Event Timeline

rmacklem created this revision.Nov 4 2018, 11:38 PM
kib added a comment.Nov 4 2018, 11:58 PM

Please upload diffs with context, like svn diff -x -U99999999.

kern/vfs_subr.c
775

If you move the helper to vfs_mount.c, it can be declared static. Do you plan to allow its use outside vfs_mount.c ?

794

I think this should be done before dropping mntid_mtx, otherwise two parallel mounts might be allowed to set the same fsid,

rmacklem marked 2 inline comments as done.Nov 5 2018, 12:06 AM

Added two inline comments.

kern/vfs_subr.c
775

Yes, moving it to vfs_mount.c sounds like a good idea. It was in vfs_subr.c only
because I created it from one of the other functions there. Since the BSD-3-cluase
license applies to both source files, moving it shouldn't be a problem.

794

Not sure what you mean here?
mtx_unlock(&mntid_mtx);
is after this code block.

rmacklem marked an inline comment as done.Nov 5 2018, 1:45 AM

Added an inline comment.

kern/vfs_subr.c
775

I tried moving vfs_setfsid() to vfs_mount.c, but mntid_mtx is a static defined
in vfs_subr.c, so I think it is better to just leave it in vfs_subr.c.

kib accepted this revision.Nov 5 2018, 9:59 AM
This revision is now accepted and ready to land.Nov 5 2018, 9:59 AM

What's the plan for ZFS then? This looks to me like using fstab for ZFS, which is suboptimal, or bespoke FreeBSD ZFS code.

W.r.t. ZFS, I have no idea. It appears that it would need to be a temporary property, but I can't see how/where
those get added?

I won't commit this patch until the ZFS case is settled, since it is the main type of file system that needs this.