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)
Jan 7 2024, 11:54 AM
Unknown Object (File)
Jan 2 2024, 7:13 PM
Unknown Object (File)
Dec 20 2023, 4:21 AM
Unknown Object (File)
Oct 2 2023, 2:11 PM
Unknown Object (File)
Aug 16 2023, 6:59 AM
Unknown Object (File)
Aug 15 2023, 11:57 AM
Unknown Object (File)
Aug 11 2023, 7:32 PM
Unknown Object (File)
Aug 5 2023, 3:59 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.