Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Jun 2022 15:41:47 +0000
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        John-Mark Gurney <jmg@funkthat.com>, "freebsd-net@FreeBSD.org" <freebsd-net@FreeBSD.org>
Subject:   Re: make NFSv3 default now on diskless
Message-ID:  <YQBPR0101MB974284972E180F3FC7B0D434DDDE9@YQBPR0101MB9742.CANPRD01.PROD.OUTLOOK.COM>
In-Reply-To: <YQBPR0101MB97426750C2E6717B06983AC7DDDE9@YQBPR0101MB9742.CANPRD01.PROD.OUTLOOK.COM>
References:  <20220602032456.GY88842@funkthat.com> <YQBPR0101MB97426750C2E6717B06983AC7DDDE9@YQBPR0101MB9742.CANPRD01.PROD.OUTLOOK.COM>

next in thread | previous in thread | raw e-mail | index | archive | help
Rick Macklem <rmacklem@uoguelph.ca> wrote:=0A=
> John-Mark Gurney <jmg@funkthat.com> wrote:=0A=
> > I just booted FreeBSD-current diskless, using NFS root, and I ended=0A=
> > up having issues because by default, NFS root is only v2.=0A=
> >=0A=
> > One of things that happened was disk space available was listed as=0A=
> > -138G, or -144830429K.  I assume this is because the server is reportin=
g=0A=
> > TBs instead.=0A=
> Yes. NFSv2 uses 32bit sizes.=0A=
> =0A=
> > If I mount via mount_nfs, the sizes are normal/correct because it mount=
s=0A=
> > v3.=0A=
> I believe most specify "nfsv3" in the "/" mount line of /etc/fstab on the=
=0A=
> remote root fs. Then, when the system does a "mount -u" to make it=0A=
> read/write it gets toggled to NFSv3.=0A=
> =0A=
> > The other issue that I ran into is that NFSv2 can't access >4GB files=
=0A=
> > (or create them).=0A=
> As above, NFSv2 uses 32bit sizes.=0A=
>=0A=
> > Anyone object to adding BOOTP_NFSV3 to GENERIC?=0A=
> Well, that option only works when used with BOOTP_NFSROOT.=0A=
> The GENERIC configs for amd64, arm64,... use the other way.=0A=
> (Just to make it confusing, there are two different ways an NFS root=0A=
>  fs is set up.)=0A=
> See below.=0A=
>=0A=
> >  Or maybe making it a=0A=
> > tunable that defaults to set, because it seems a bit crazy to default=
=0A=
> > to v2 these days.=0A=
> I don't think changing the default to NFSv3 will be a problem.=0A=
> The reason it was NFSv2 was that,=0A=
> for some non-FreeBSD NFS servers, the NFSv3 file handle is different=0A=
> than the NFSv2 one.=0A=
>=0A=
> I added NFSv3 support to stand/libsa/nfs.c about 15years ago, so every=0A=
> system should be running the newer NFS code in the loader and be able=0A=
> to do NFSv3 booting.=0A=
> =0A=
> > This option was added in 432aad0e in 1997 so that the nfs_diskless=0A=
> > structure didn't need to be filled out.  Does anything even=0A=
> > populate/fill it out anymore?  I saw code in i386/i386/locore.s that=0A=
> > does this, but it doesn't appear anywhere else.=0A=
> Yes. For "options NFS_ROOT" (the other way), the loader uses=0A=
> "stand/libsa/nfs.c" to acquire the remote file system's root file handle=
=0A=
> and fills it in. (See nfs_setup_diskless() in sys/nfs/nfs_diskless.c.)=0A=
> Looking at it, it appears to enable NFSv3 so long as it finds=0A=
> "boot.nfsroot.nfshandlelen" set.=0A=
Just to give you a little more on how these two methods work=0A=
(from my vague recollection..):=0A=
options NFS_ROOT=0A=
- Something (usually PXEBOOT) loaded the loader.=0A=
- The loader filled in some environment variables using the code in=0A=
   stand/libsa/nfs.c.=0A=
   boot.nfsroot.nfshandle - The root fs file handle=0A=
   boot.nfsroot.nfshandlelen - The length of above (if not set, use NFSv2)=
=0A=
   - plus some others to set up the network interface=0A=
- The kernel uses these environment variables to fill in nfs_diskless or=0A=
  nfsv3_diskless. This is done by the function called nfs_setup_diskless(),=
=0A=
  found in sys/nfs/nfs_diskless.c.=0A=
=0A=
options BOOTP_NFSROOT=0A=
- Kernel gets loaded somehow.=0A=
- Kernel uses code in sys/nfs/bootp_subr.c to get the information=0A=
  needed (such as the root fs file handle) via BOOTP/DHCP.=0A=
  For this one, it will use NFSv2 unless "options BOOTP_NFSV3" was=0A=
  specified along with "options BOOTP_NFSROOT" in the kernel config.=0A=
=0A=
If you are using the "NFS_ROOT" approach, I am surprised that you=0A=
get NFSv2, since the code in stand/libsa/nfs.c appears to do NFSv3 now=0A=
and sets "boot.nfsroot.nfshandlelen", unless I am mis-reading it?=0A=
- Maybe you can pop out into the loader and look at the environment=0A=
  variables with "show"?=0A=
=0A=
rick=0A=
=0A=
> There also appears to possibly be a way via mount options, but I can't=0A=
> see where it's documented to set them.=0A=
I think you just specify "nfsv3" as a mount option in the root fs=0A=
line in /etc/fstab on the root fs on the NFS server.=0A=
=0A=
I don't think changing the default to NFSv3 will be a problem.=0A=
The hassle is testing the various cases, to make sure nothing=0A=
breaks. I have no diskless setup to do testing and I don't even know=0A=
when installs/upgrades actually replace the loader?=0A=
=0A=
rick=0A=
=0A=
--=0A=
  John-Mark Gurney                              Voice: +1 415 225 5579=0A=
=0A=
     "All that I will do, has been done, All that I have, has not."=0A=
=0A=
=0A=
=0A=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YQBPR0101MB974284972E180F3FC7B0D434DDDE9>