Date: Mon, 25 Apr 2011 22:22:51 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r221032 - in head/sys: amd64/amd64 conf i386/i386 modules/nfscl modules/nfsclient nfs nfsclient Message-ID: <201104252222.p3PMMpJe094870@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rmacklem Date: Mon Apr 25 22:22:51 2011 New Revision: 221032 URL: http://svn.freebsd.org/changeset/base/221032 Log: Fix the experimental NFS client so that it does not bogusly set the f_flags field of "struct statfs". This had the interesting effect of making the NFSv4 mounts "disappear" after r221014, since NFSMNT_NFSV4 and MNT_IGNORE became the same bit. Move the files used for a diskless NFS root from sys/nfsclient to sys/nfs in preparation for them to be used by both NFS clients. Also, move the declaration of the three global data structures from sys/nfsclient/nfs_vfsops.c to sys/nfs/nfs_diskless.c so that they are defined when either client uses them. Reviewed by: jhb MFC after: 2 weeks Added: head/sys/nfs/bootp_subr.c - copied, changed from r221031, head/sys/nfsclient/bootp_subr.c head/sys/nfs/krpc.h - copied unchanged from r221031, head/sys/nfsclient/krpc.h head/sys/nfs/krpc_subr.c - copied, changed from r221031, head/sys/nfsclient/krpc_subr.c head/sys/nfs/nfs_diskless.c - copied, changed from r221031, head/sys/nfsclient/nfs_diskless.c head/sys/nfs/nfsdiskless.h - copied unchanged from r221031, head/sys/nfsclient/nfsdiskless.h Deleted: head/sys/nfsclient/bootp_subr.c head/sys/nfsclient/krpc.h head/sys/nfsclient/krpc_subr.c head/sys/nfsclient/nfs_diskless.c head/sys/nfsclient/nfsdiskless.h Modified: head/sys/amd64/amd64/genassym.c head/sys/conf/files head/sys/i386/i386/genassym.c head/sys/modules/nfscl/Makefile head/sys/modules/nfsclient/Makefile head/sys/nfsclient/nfs_vfsops.c Modified: head/sys/amd64/amd64/genassym.c ============================================================================== --- head/sys/amd64/amd64/genassym.c Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/amd64/amd64/genassym.c Mon Apr 25 22:22:51 2011 (r221032) @@ -65,7 +65,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #include <nfs/nfsproto.h> #include <nfsclient/nfs.h> -#include <nfsclient/nfsdiskless.h> +#include <nfs/nfsdiskless.h> #include <x86/apicreg.h> #include <machine/cpu.h> #include <machine/pcb.h> Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/conf/files Mon Apr 25 22:22:51 2011 (r221032) @@ -2822,12 +2822,12 @@ netsmb/smb_smb.c optional netsmb netsmb/smb_subr.c optional netsmb netsmb/smb_trantcp.c optional netsmb netsmb/smb_usr.c optional netsmb +nfs/bootp_subr.c optional bootp nfsclient | bootp nfscl +nfs/krpc_subr.c optional bootp nfsclient | bootp nfscl nfs/nfs_common.c optional nfsclient | nfsserver +nfs/nfs_diskless.c optional nfsclient nfs_root | nfscl nfs_root nfs/nfs_lock.c optional nfsclient | nfscl | nfslockd | nfsd -nfsclient/bootp_subr.c optional bootp nfsclient -nfsclient/krpc_subr.c optional bootp nfsclient nfsclient/nfs_bio.c optional nfsclient -nfsclient/nfs_diskless.c optional nfsclient nfs_root nfsclient/nfs_node.c optional nfsclient nfsclient/nfs_krpc.c optional nfsclient nfsclient/nfs_subs.c optional nfsclient Modified: head/sys/i386/i386/genassym.c ============================================================================== --- head/sys/i386/i386/genassym.c Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/i386/i386/genassym.c Mon Apr 25 22:22:51 2011 (r221032) @@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #include <nfs/nfsproto.h> #include <nfsclient/nfs.h> -#include <nfsclient/nfsdiskless.h> +#include <nfs/nfsdiskless.h> #ifdef DEV_APIC #include <x86/apicreg.h> #endif Modified: head/sys/modules/nfscl/Makefile ============================================================================== --- head/sys/modules/nfscl/Makefile Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/modules/nfscl/Makefile Mon Apr 25 22:22:51 2011 (r221032) @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../fs/nfsclient +.PATH: ${.CURDIR}/../../fs/nfsclient ${.CURDIR}/../../nfs KMOD= nfscl SRCS= vnode_if.h \ nfs_clrpcops.c \ @@ -22,4 +22,36 @@ SRCS= vnode_if.h \ opt_ufs.h \ opt_kgssapi.h +.if !defined(KERNBUILDDIR) +NFS_INET?= 1 # 0/1 - requires INET to be configured in kernel +NFS_INET6?= 1 # 0/1 - requires INET6 to be configured in kernel +NFS_ROOT?= 1 # 0/1 - requires NFS_ROOT to be configured in kernel + +.if ${NFS_INET} > 0 +opt_inet.h: + echo "#define INET 1" > ${.TARGET} +.endif + +.if ${NFS_INET6} > 0 +opt_inet6.h: + echo "#define INET6 1" > ${.TARGET} +.endif + +.if ${NFS_ROOT} > 0 +opt_nfsroot.h: + echo "#define NFS_ROOT 1" > ${.TARGET} +.endif +.else +OPT_NFS_ROOT!= cat ${KERNBUILDDIR}/opt_nfsroot.h +.if empty(OPT_NFS_ROOT) +NFS_ROOT= 0 +.else +NFS_ROOT= 1 +.endif +.endif + +.if ${NFS_ROOT} > 0 +SRCS+= nfs_diskless.c +.endif + .include <bsd.kmod.mk> Modified: head/sys/modules/nfsclient/Makefile ============================================================================== --- head/sys/modules/nfsclient/Makefile Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/modules/nfsclient/Makefile Mon Apr 25 22:22:51 2011 (r221032) @@ -1,6 +1,6 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../nfsclient ${.CURDIR}/../../rpc +.PATH: ${.CURDIR}/../../nfsclient ${.CURDIR}/../../nfs ${.CURDIR}/../../rpc KMOD= nfsclient SRCS= vnode_if.h \ Copied and modified: head/sys/nfs/bootp_subr.c (from r221031, head/sys/nfsclient/bootp_subr.c) ============================================================================== --- head/sys/nfsclient/bootp_subr.c Mon Apr 25 22:00:23 2011 (r221031, copy source) +++ head/sys/nfs/bootp_subr.c Mon Apr 25 22:22:51 2011 (r221032) @@ -69,8 +69,8 @@ __FBSDID("$FreeBSD$"); #include <nfs/nfsproto.h> #include <nfsclient/nfs.h> -#include <nfsclient/nfsdiskless.h> -#include <nfsclient/krpc.h> +#include <nfs/nfsdiskless.h> +#include <nfs/krpc.h> #include <nfs/xdr_subs.h> Copied: head/sys/nfs/krpc.h (from r221031, head/sys/nfsclient/krpc.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/nfs/krpc.h Mon Apr 25 22:22:51 2011 (r221032, copy of r221031, head/sys/nfsclient/krpc.h) @@ -0,0 +1,31 @@ +/* $NetBSD: krpc.h,v 1.4 1995/12/19 23:07:11 cgd Exp $ */ +/* $FreeBSD$ */ + +#include <sys/cdefs.h> + +struct mbuf; +struct thread; +struct sockaddr; +struct sockaddr_in; + +int krpc_call(struct sockaddr_in *_sin, + u_int prog, u_int vers, u_int func, + struct mbuf **data, struct sockaddr **from, struct thread *td); + +int krpc_portmap(struct sockaddr_in *_sin, + u_int prog, u_int vers, u_int16_t *portp, struct thread *td); + +struct mbuf *xdr_string_encode(char *str, int len); + +/* + * RPC definitions for the portmapper + */ +#define PMAPPORT 111 +#define PMAPPROG 100000 +#define PMAPVERS 2 +#define PMAPPROC_NULL 0 +#define PMAPPROC_SET 1 +#define PMAPPROC_UNSET 2 +#define PMAPPROC_GETPORT 3 +#define PMAPPROC_DUMP 4 +#define PMAPPROC_CALLIT 5 Copied and modified: head/sys/nfs/krpc_subr.c (from r221031, head/sys/nfsclient/krpc_subr.c) ============================================================================== --- head/sys/nfsclient/krpc_subr.c Mon Apr 25 22:00:23 2011 (r221031, copy source) +++ head/sys/nfs/krpc_subr.c Mon Apr 25 22:22:51 2011 (r221032) @@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$"); #include <rpc/types.h> #include <rpc/auth.h> #include <rpc/rpc_msg.h> -#include <nfsclient/krpc.h> +#include <nfs/krpc.h> #include <nfs/xdr_subs.h> /* Copied and modified: head/sys/nfs/nfs_diskless.c (from r221031, head/sys/nfsclient/nfs_diskless.c) ============================================================================== --- head/sys/nfsclient/nfs_diskless.c Mon Apr 25 22:00:23 2011 (r221031, copy source) +++ head/sys/nfs/nfs_diskless.c Mon Apr 25 22:22:51 2011 (r221032) @@ -55,13 +55,22 @@ __FBSDID("$FreeBSD$"); #include <netinet/in.h> #include <nfs/nfsproto.h> #include <nfsclient/nfs.h> -#include <nfsclient/nfsdiskless.h> +#include <nfs/nfsdiskless.h> static int inaddr_to_sockaddr(char *ev, struct sockaddr_in *sa); static int hwaddr_to_sockaddr(char *ev, struct sockaddr_dl *sa); static int decode_nfshandle(char *ev, u_char *fh, int maxfh); /* + * This structure must be filled in by a primary bootstrap or bootstrap + * server for a diskless/dataless machine. It is initialized below just + * to ensure that it is allocated to initialized data (.data not .bss). + */ +struct nfs_diskless nfs_diskless = { { { 0 } } }; +struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; +int nfs_diskless_valid = 0; + +/* * Validate/sanity check a rsize/wsize parameter. */ static int Copied: head/sys/nfs/nfsdiskless.h (from r221031, head/sys/nfsclient/nfsdiskless.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/nfs/nfsdiskless.h Mon Apr 25 22:22:51 2011 (r221032, copy of r221031, head/sys/nfsclient/nfsdiskless.h) @@ -0,0 +1,114 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Rick Macklem at The University of Guelph. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nfsdiskless.h 8.2 (Berkeley) 3/30/95 + * $FreeBSD$ + */ + +#ifndef _NFSCLIENT_NFSDISKLESS_H_ +#define _NFSCLIENT_NFSDISKLESS_H_ + +/* + * Structure that must be initialized for a diskless nfs client. + * This structure is used by nfs_mountroot() to set up the root vnode, + * and to do a partial ifconfig(8) and route(8) so that the critical net + * interface can communicate with the server. + * The primary bootstrap is expected to fill in the appropriate fields before + * starting the kernel. + * Currently only works for AF_INET protocols. + * NB: All fields are stored in net byte order to avoid hassles with + * client/server byte ordering differences. + */ + +/* + * I have defined a new structure that can handle an NFS Version 3 file handle + * but the kernel still expects the old Version 2 one to be provided. The + * changes required in nfs_vfsops.c for using the new are documented there in + * comments. (I felt that breaking network booting code by changing this + * structure would not be prudent at this time, since almost all servers are + * still Version 2 anyhow.) + */ +struct nfsv3_diskless { + struct ifaliasreq myif; /* Default interface */ + struct sockaddr_in mygateway; /* Default gateway */ + struct nfs_args root_args; /* Mount args for root fs */ + int root_fhsize; /* Size of root file handle */ + u_char root_fh[NFSX_V3FHMAX]; /* File handle of root dir */ + struct sockaddr_in root_saddr; /* Address of root server */ + char root_hostnam[MNAMELEN]; /* Host name for mount pt */ + long root_time; /* Timestamp of root fs */ + char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ +}; + +/* + * Old arguments to mount NFS + */ +struct onfs_args { + struct sockaddr *addr; /* file server address */ + int addrlen; /* length of address */ + int sotype; /* Socket type */ + int proto; /* and Protocol */ + u_char *fh; /* File handle to be mounted */ + int fhsize; /* Size, in bytes, of fh */ + int flags; /* flags */ + int wsize; /* write size in bytes */ + int rsize; /* read size in bytes */ + int readdirsize; /* readdir size in bytes */ + int timeo; /* initial timeout in .1 secs */ + int retrans; /* times to retry send */ + int maxgrouplist; /* Max. size of group list */ + int readahead; /* # of blocks to readahead */ + int leaseterm; /* Term (sec) of lease */ + int deadthresh; /* Retrans threshold */ + char *hostname; /* server's name */ +}; + +struct nfs_diskless { + struct ifaliasreq myif; /* Default interface */ + struct sockaddr_in mygateway; /* Default gateway */ + struct onfs_args root_args; /* Mount args for root fs */ + u_char root_fh[NFSX_V2FH]; /* File handle of root dir */ + struct sockaddr_in root_saddr; /* Address of root server */ + char root_hostnam[MNAMELEN]; /* Host name for mount pt */ + long root_time; /* Timestamp of root fs */ + char my_hostnam[MAXHOSTNAMELEN]; /* Client host name */ +}; + +#ifdef _KERNEL +extern struct nfsv3_diskless nfsv3_diskless; +extern struct nfs_diskless nfs_diskless; +extern int nfs_diskless_valid; +void bootpc_init(void); +void nfs_setup_diskless(void); +void nfs_parse_options(const char *, struct nfs_args *); +#endif + +#endif Modified: head/sys/nfsclient/nfs_vfsops.c ============================================================================== --- head/sys/nfsclient/nfs_vfsops.c Mon Apr 25 22:00:23 2011 (r221031) +++ head/sys/nfsclient/nfs_vfsops.c Mon Apr 25 22:22:51 2011 (r221032) @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD$"); #include <nfsclient/nfsmount.h> #include <nfs/xdr_subs.h> #include <nfsclient/nfsm_subs.h> -#include <nfsclient/nfsdiskless.h> +#include <nfs/nfsdiskless.h> FEATURE(nfsclient, "NFS client"); @@ -164,15 +164,6 @@ static struct nfs_rpcops nfs_rpcops = { nfs_commit, }; -/* - * This structure must be filled in by a primary bootstrap or bootstrap - * server for a diskless/dataless machine. It is initialized below just - * to ensure that it is allocated to initialized data (.data not .bss). - */ -struct nfs_diskless nfs_diskless = { { { 0 } } }; -struct nfsv3_diskless nfsv3_diskless = { { { 0 } } }; -int nfs_diskless_valid = 0; - SYSCTL_INT(_vfs_nfs, OID_AUTO, diskless_valid, CTLFLAG_RD, &nfs_diskless_valid, 0, "Has the diskless struct been filled correctly");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104252222.p3PMMpJe094870>