summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/nfs/krpc.h4
-rw-r--r--sys/nfs/krpc_subr.c10
-rw-r--r--sys/nfs/nfs_boot.c43
-rw-r--r--sys/nfs/nfs_vfsops.c71
-rw-r--r--sys/nfs/nfsdiskless.h6
5 files changed, 79 insertions, 55 deletions
diff --git a/sys/nfs/krpc.h b/sys/nfs/krpc.h
index 423367426ef..5c3cfe68aec 100644
--- a/sys/nfs/krpc.h
+++ b/sys/nfs/krpc.h
@@ -1,11 +1,11 @@
-/* $OpenBSD: krpc.h,v 1.3 1996/04/17 04:50:21 mickey Exp $ */
+/* $OpenBSD: krpc.h,v 1.4 2001/11/14 23:37:33 mickey Exp $ */
/* $NetBSD: krpc.h,v 1.4 1995/12/19 23:07:11 cgd Exp $ */
#include <sys/cdefs.h>
int krpc_call __P((struct sockaddr_in *sin,
u_int prog, u_int vers, u_int func,
- struct mbuf **data, struct mbuf **from));
+ struct mbuf **data, struct mbuf **from, int retries));
int krpc_portmap __P((struct sockaddr_in *sin,
u_int prog, u_int vers, u_int16_t *portp));
diff --git a/sys/nfs/krpc_subr.c b/sys/nfs/krpc_subr.c
index d4961adc636..64e04506828 100644
--- a/sys/nfs/krpc_subr.c
+++ b/sys/nfs/krpc_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: krpc_subr.c,v 1.11 2001/06/27 05:45:00 nate Exp $ */
+/* $OpenBSD: krpc_subr.c,v 1.12 2001/11/14 23:37:33 mickey Exp $ */
/* $NetBSD: krpc_subr.c,v 1.12.4.1 1996/06/07 00:52:26 cgd Exp $ */
/*
@@ -164,7 +164,7 @@ krpc_portmap(sin, prog, vers, portp)
sin->sin_port = htons(PMAPPORT);
error = krpc_call(sin, PMAPPROG, PMAPVERS,
- PMAPPROC_GETPORT, &m, NULL);
+ PMAPPROC_GETPORT, &m, NULL, -1);
if (error)
return error;
@@ -186,11 +186,12 @@ krpc_portmap(sin, prog, vers, portp)
* the address from whence the response came is saved there.
*/
int
-krpc_call(sa, prog, vers, func, data, from_p)
+krpc_call(sa, prog, vers, func, data, from_p, retries)
struct sockaddr_in *sa;
u_int prog, vers, func;
struct mbuf **data; /* input/output */
struct mbuf **from_p; /* output */
+ int retries;
{
struct socket *so;
struct sockaddr_in *sin;
@@ -330,8 +331,7 @@ krpc_call(sa, prog, vers, func, data, from_p)
* but delay each re-send by an increasing amount.
* If the delay hits the maximum, start complaining.
*/
- timo = 0;
- for (;;) {
+ for (timo = 0; retries; retries--) {
/* Send RPC request (or re-send). */
m = m_copym(mhead, 0, M_COPYALL, M_WAIT);
if (m == NULL) {
diff --git a/sys/nfs/nfs_boot.c b/sys/nfs/nfs_boot.c
index 8ff20f81ee2..679aa744f82 100644
--- a/sys/nfs/nfs_boot.c
+++ b/sys/nfs/nfs_boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_boot.c,v 1.11 1999/01/03 10:07:19 deraadt Exp $ */
+/* $OpenBSD: nfs_boot.c,v 1.12 2001/11/14 23:37:33 mickey Exp $ */
/* $NetBSD: nfs_boot.c,v 1.26 1996/05/07 02:51:25 thorpej Exp $ */
/*
@@ -66,13 +66,14 @@ nfs_boot_init(nd, procp)
panic("nfs_boot_init: NFSCLIENT not enabled in kernel");
}
-void
+int
nfs_boot_getfh(bpsin, key, ndmntp)
struct sockaddr_in *bpsin;
char *key;
struct nfs_dlmount *ndmntp;
{
/* can not get here */
+ return (EOPNOTSUPP);
}
#else
@@ -101,7 +102,7 @@ nfs_boot_getfh(bpsin, key, ndmntp)
static int bp_whoami __P((struct sockaddr_in *bpsin,
struct in_addr *my_ip, struct in_addr *gw_ip));
static int bp_getfile __P((struct sockaddr_in *bpsin, char *key,
- struct sockaddr_in *mdsin, char *servname, char *path));
+ struct sockaddr_in *mdsin, char *servname, char *path, int retries));
/* mountd RPC */
static int md_mount __P((struct sockaddr_in *mdsin, char *path,
@@ -252,11 +253,12 @@ nfs_boot_init(nd, procp)
return (0);
}
-void
-nfs_boot_getfh(bpsin, key, ndmntp)
+int
+nfs_boot_getfh(bpsin, key, ndmntp, retries)
struct sockaddr_in *bpsin; /* bootparam server */
char *key; /* root or swap */
struct nfs_dlmount *ndmntp; /* output */
+ int retries;
{
char pathname[MAXPATHLEN];
char *sp, *dp, *endp;
@@ -269,23 +271,30 @@ nfs_boot_getfh(bpsin, key, ndmntp)
* Get server:pathname for "key" (root or swap)
* using RPC to bootparam/getfile
*/
- error = bp_getfile(bpsin, key, sin, ndmntp->ndm_host, pathname);
- if (error)
- panic("nfs_boot: bootparam get %s: %d", key, error);
+ error = bp_getfile(bpsin, key, sin, ndmntp->ndm_host, pathname,
+ retries);
+ if (error) {
+ printf("nfs_boot: bootparam get %s: %d\n", key, error);
+ return (error);
+ }
/*
* Get file handle for "key" (root or swap)
* using RPC to mountd/mount
*/
error = md_mount(sin, pathname, ndmntp->ndm_fh);
- if (error)
- panic("nfs_boot: mountd %s, error=%d", key, error);
+ if (error) {
+ printf("nfs_boot: mountd %s, error=%d\n", key, error);
+ return (error);
+ }
/* Set port number for NFS use. */
/* XXX: NFS port is always 2049, right? */
error = krpc_portmap(sin, NFS_PROG, NFS_VER2, &sin->sin_port);
- if (error)
- panic("nfs_boot: portmap NFS/v2, error=%d", error);
+ if (error) {
+ printf("nfs_boot: portmap NFS/v2, error=%d\n", error);
+ return (error);
+ }
/* Construct remote path (for getmntinfo(3)) */
dp = ndmntp->ndm_host;
@@ -296,6 +305,7 @@ nfs_boot_getfh(bpsin, key, ndmntp)
*dp++ = *sp++;
*dp = '\0';
+ return (0);
}
@@ -358,7 +368,7 @@ bp_whoami(bpsin, my_ip, gw_ip)
bpsin->sin_port = htons(PMAPPORT);
from = NULL;
error = krpc_call(bpsin, PMAPPROG, PMAPVERS,
- PMAPPROC_CALLIT, &m, &from);
+ PMAPPROC_CALLIT, &m, &from, -1);
if (error)
return error;
@@ -423,12 +433,13 @@ out:
* server pathname
*/
static int
-bp_getfile(bpsin, key, md_sin, serv_name, pathname)
+bp_getfile(bpsin, key, md_sin, serv_name, pathname, retries)
struct sockaddr_in *bpsin;
char *key;
struct sockaddr_in *md_sin;
char *serv_name;
char *pathname;
+ int retries;
{
struct mbuf *m;
struct sockaddr_in *sin;
@@ -451,7 +462,7 @@ bp_getfile(bpsin, key, md_sin, serv_name, pathname)
/* RPC: bootparam/getfile */
error = krpc_call(bpsin, BOOTPARAM_PROG, BOOTPARAM_VERS,
- BOOTPARAM_GETFILE, &m, NULL);
+ BOOTPARAM_GETFILE, &m, NULL, retries);
if (error)
return error;
@@ -526,7 +537,7 @@ md_mount(mdsin, path, fhp)
/* Do RPC to mountd. */
error = krpc_call(mdsin, RPCPROG_MNT, RPCMNT_VER1,
- RPCMNT_MOUNT, &m, NULL);
+ RPCMNT_MOUNT, &m, NULL, -1);
if (error)
return error; /* message already freed */
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index a6904781c9c..13420530fc3 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vfsops.c,v 1.37 2001/07/27 05:43:17 csapuntz Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.38 2001/11/14 23:37:33 mickey Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
@@ -286,7 +286,8 @@ nfs_mountroot()
/*
* Create the root mount point.
*/
- nfs_boot_getfh(&nd.nd_boot, "root", &nd.nd_root);
+ if (nfs_boot_getfh(&nd.nd_boot, "root", &nd.nd_root, -1))
+ panic("nfs_mountroot: root");
mp = nfs_mount_diskless(&nd.nd_root, "/", 0);
nfs_root(mp, &rootvp);
printf("root on %s\n", nd.nd_root.ndm_host);
@@ -341,38 +342,50 @@ nfs_mountroot()
* If swapping to an nfs node: (swdevt[0].sw_dev == NODEV)
* Create a fake mount point just for the swap vnode so that the
* swap file can be on a different server from the rootfs.
+ *
+ * Wait 5 retries, finally no swap is cool. -mickey
*/
- nfs_boot_getfh(&nd.nd_boot, "swap", &nd.nd_swap);
- mp = nfs_mount_diskless(&nd.nd_swap, "/swap", 0);
- nfs_root(mp, &vp);
- vfs_unbusy(mp, procp);
- printf("swap on %s\n", nd.nd_swap.ndm_host);
+ error = nfs_boot_getfh(&nd.nd_boot, "swap", &nd.nd_swap, 5);
+ if (!error) {
+ mp = nfs_mount_diskless(&nd.nd_swap, "/swap", 0);
+ nfs_root(mp, &vp);
+ vfs_unbusy(mp, procp);
- /*
- * Since the swap file is not the root dir of a file system,
- * hack it to a regular file.
- */
- vp->v_type = VREG;
- vp->v_flag = 0;
- /*
- * Next line is a hack to make swapmount() work on NFS swap files.
- * XXX-smurph
- */
- swdevt[0].sw_dev = NETDEV;
- /* end hack */
- swdevt[0].sw_vp = vp;
+ /*
+ * Since the swap file is not the root dir of a file system,
+ * hack it to a regular file.
+ */
+ vp->v_type = VREG;
+ vp->v_flag = 0;
- /*
- * Find out how large the swap file is.
- */
- error = VOP_GETATTR(vp, &attr, procp->p_ucred, procp);
- if (error)
- panic("nfs_mountroot: getattr for swap");
- n = (long) (attr.va_size >> DEV_BSHIFT);
+ /*
+ * Next line is a hack to make swapmount() work on NFS swap files.
+ * XXX-smurph
+ */
+ swdevt[0].sw_dev = NETDEV;
+ /* end hack */
+ swdevt[0].sw_vp = vp;
+
+ /*
+ * Find out how large the swap file is.
+ */
+ error = VOP_GETATTR(vp, &attr, procp->p_ucred, procp);
+ if (error)
+ printf("nfs_mountroot: getattr for swap\n");
+ n = (long) (attr.va_size >> DEV_BSHIFT);
+
+ printf("swap on %s\n", nd.nd_swap.ndm_host);
#ifdef DEBUG
- printf("swap size: 0x%lx (blocks)\n", n);
+ printf("swap size: 0x%lx (blocks)\n", n);
#endif
- swdevt[0].sw_nblks = n;
+ swdevt[0].sw_nblks = n;
+ return (0);
+ }
+
+ printf("WARNING: no swap\n");
+ swdevt[0].sw_dev = NODEV;
+ swdevt[0].sw_vp = NULL;
+ swdevt[0].sw_nblks = 0;
return (0);
}
diff --git a/sys/nfs/nfsdiskless.h b/sys/nfs/nfsdiskless.h
index 75872f9474c..563426e1ddd 100644
--- a/sys/nfs/nfsdiskless.h
+++ b/sys/nfs/nfsdiskless.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfsdiskless.h,v 1.5 1997/09/06 14:48:59 deraadt Exp $ */
+/* $OpenBSD: nfsdiskless.h,v 1.6 2001/11/14 23:37:33 mickey Exp $ */
/* $NetBSD: nfsdiskless.h,v 1.9 1996/02/18 11:54:00 fvdl Exp $ */
/*
@@ -65,7 +65,7 @@ struct nfs_diskless {
};
int nfs_boot_init __P((struct nfs_diskless *nd, struct proc *procp));
-void nfs_boot_getfh __P((struct sockaddr_in *bpsin, char *key,
- struct nfs_dlmount *ndmntp));
+int nfs_boot_getfh __P((struct sockaddr_in *bpsin, char *key,
+ struct nfs_dlmount *ndmntp, int retries));
#endif /* _NFS_DISKLESS_H_ */