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.
Tags
None
Referenced Files
Unknown Object (File)
Oct 16 2024, 6:55 PM
Unknown Object (File)
Oct 5 2024, 1:39 AM
Unknown Object (File)
Oct 4 2024, 8:48 AM
Unknown Object (File)
Oct 3 2024, 8:18 AM
Unknown Object (File)
Oct 2 2024, 12:06 PM
Unknown Object (File)
Sep 28 2024, 1:29 AM
Unknown Object (File)
Sep 26 2024, 10:45 PM
Unknown Object (File)
Sep 15 2024, 5:25 PM
Subscribers

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 - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 20631

Event Timeline

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,

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.

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.

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.