Resent: fixed '-p port' arg to rpc.nfsd plus more.
Subsystems (2)
PATCH 1/1 Resent: fixed '-p port' arg to rpc.nfsd plus more.
I found an issue with the kernel side of these patches that caused the server not to advertise any services if the server was restarted. The problem was nfsd_version array was getting NULL-ed out which meant server would not advertise any services if restarted. Here is the diff of the changes. The complete patches are attached.
fs/nfsd/nfssvc.c 2005-03-31 11:54:12.000000000 -0500 renamed from fs/nfsd/nfssvc.c 2005-03-18 08:39:53.000000000 -0500 +0 -0
@@ -77,10 +77,11 @@ #define NFSD_MINVERS 2 #define NFSD_NRVERS
(sizeof(nfsd_version)/sizeof(nfsd_version[0])) +static struct svc_version *nfsd_versions[NFSD_NRVERS];
struct svc_program nfsd_program = {
.pg_prog = NFS_PROGRAM, /* program
number */
.pg_nvers = NFSD_NRVERS, /* nr of
entries in nfsd_version */
- .pg_vers = nfsd_version, /* version table */
+ .pg_vers = nfsd_versions, /* version table */
.pg_name = "nfsd", /* program name */
.pg_class = "nfsd", /* authentication class */
.pg_stats = &nfsd_svcstats, /* version table */
At this point I believe I've address the two main issue that were brought up 1) The need for -V flag to specify a version 2) Changed the /proc/fs/nfsd/threads to /proc/fs/nfsd/config.
These patches do fix a pretty obvious bug plus makes the server much more configurable which I believe is a good thing so I do hope these patches will be (re)considered for inclusion the upstream kernel and nfs-utils....
steved.
support/include/nfs/nfs.h renamed from support/include/nfs/nfs.h.orig +8 -1
@@ -40,7 +40,14 @@ struct nfs_fh_old {#define NFSCTL_LOCKD 0x10000#define LOCKDCTL_SVC NFSCTL_LOCKD - +#define NFSCTL_VERSET (_cltbits, _v) ((_cltbits) |= (1 << ((_v) - 1))) +#define NFSCTL_VERUNSET (_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1))) +#define NFSCTL_UDPUNSET (_cltbits) ((_cltbits) &= ~(1 << (17 - 1))) +#define NFSCTL_TCPUNSET (_cltbits) ((_cltbits) &= ~(1 << (18 - 1))) + +#define NFSCTL_VERISSET (_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1))) +#define NFSCTL_UDPISSET (_cltbits) ((_cltbits) & (1 << (17 - 1))) +#define NFSCTL_TCPISSET (_cltbits) ((_cltbits) & (1 << (18 - 1)))/* SVC */ struct nfsctl_svc {
support/include/nfslib.h renamed from support/include/nfslib.h.orig +1 -1
@@ -118,7 +118,7 @@ int wildmat(char *text, char *pattern)* nfsd library functions. */ int nfsctl (int ,struct nfsctl_arg *,union nfsctl_res *); -int nfssvc (int port,int nrservs); +int nfssvc (int port,int nrservs,unsigned int ctlbits);int nfsaddclient (struct nfsctl_client *clp);int nfsdelclient (struct nfsctl_client *clp);int nfsexport (struct nfsctl_export *exp);
support/nfs/nfssvc.c renamed from support/nfs/nfssvc.c.orig +13 -8
@@ -14,27 +14,32 @@#include "nfslib.h" int -nfssvc (int port,int nrservs) +nfssvc (int port,int nrservs,unsigned ctlbits) {struct nfsctl_arg arg;int fd; - fd =open ("/proc/fs/nfsd/threads" ,O_WRONLY ); + fd =open ("/proc/fs/nfsd/config" ,O_WRONLY );if (fd <0 ) fd =open ("/proc/fs/nfs/threads" ,O_WRONLY );if (fd >=0 ) {/* 2.5+ kernel with nfsd filesystem mounted. * Just write the number in. -* Cannot handle port number yet, but does anyone care? */ -char buf[20 ]; +char buf[40 ];int n; -snprintf (buf,20 ,"%d\n" , nrservs); +snprintf (buf,40 ,"%d %d %d\n" , nrservs, port, ctlbits); n =write (fd, buf,strlen (buf));close (fd); -if (n !=strlen (buf)) -return -1 ; -else +if (n !=strlen (buf)) { +/* +* See if this an older kernel that does not +* have the ctlbits support +*/ +snprintf (buf,40 ,"%d\n" , nrservs); +if (n !=strlen (buf)) +return -1 ; + }else return 0 ; }
utils/mountd/mountd.c renamed from utils/mountd/mountd.c.orig +3 -0
@@ -255,6 +255,9 @@ mount_mnt_3_svc(struct svc_req *rqstp, d = sizeof(flavors)/sizeof(flavors[0]); ok->auth_flavors.auth_flavors_val = flavors; } +if (fh ==NULL || res->fhs_status) +xlog (D_CALL ,"MNT3(%s) failed: status %d\n" , res->fhs_status); +return 1 ; }
utils/nfsd/nfsd.c renamed from utils/nfsd/nfsd.c.orig +78 -6
123 lines not on this page · raw message
utils/nfsd/nfsd.man renamed from utils/nfsd/nfsd.man.orig +26 -2
@@ -6,7 +6,7 @@ .SH NAME rpc.nfsd \- NFS server process .SH SYNOPSIS -.BI "/usr/sbin/rpc.nfsd [-p " port "] " nproc +.BI "/usr/sbin/rpc.nfsd [" options "]" " "nproc .SH DESCRIPTION The .B rpc.nfsd
@@ -22,11 +22,35 @@ server provides an ancillary service nee by NFS clients. .SH OPTIONS .TP -.BI \-p " port" +.B \-p " or " \-\-port port specify a diferent port to listen on for NFS requests. By default, .B rpc.nfsd will listen on port 2049. .TP +.B \-N " or " \-\-no-nfs-version vers +This option can be used to request that +.B rpc.nfsd +do not offer certain versions of NFS. The current version of +.B rpc.nfsd +can support both NFS version 2,3 and the newer version 4. +.TP +.B \-T " or " \-\-no-tcp +Disable +.B rpc.nfsd +from accepting TCP connections from clients. +.TP +.B \-U " or " \-\-no-udp +Disable +.B rpc.nfsd +from accepting UDP connections from clients. +.TP +.B \-V " or " \-\-nfs-version +This option can be used to request that +.B rpc.nfsd +offer certain versions of NFS. The current version of +.B rpc.nfsd +can support NFS version 2,3 and the newer version 4. +.TP .I nproc specify the number of NFS server threads. By default, just one thread is started. However, for optimum performance several threads
fs/nfsd/nfs4state.c renamed from fs/nfsd/nfs4state.c.orig +2 -0
@@ -3250,6 +3250,8 @@ __nfs4_state_shutdown(void)void nfs4_state_shutdown (void ) { +if (!nfs4_init) +return ;nfs4_lock_state ();nfs4_release_reclaim ();__nfs4_state_shutdown ();
fs/nfsd/nfssvc.c renamed from fs/nfsd/nfssvc.c.orig +63 -33
136 lines not on this page · raw message
fs/nfsd/nfsctl.c renamed from fs/nfsd/nfsctl.c.orig +31 -9
@@ -49,7 +49,7 @@ enum { NFSD_Getfs, NFSD_List, NFSD_Fh, - NFSD_Threads, + NFSD_Config, NFSD_Leasetime, };
@@ -64,7 +64,7 @@ static ssize_t write_unexport(struct filstatic ssize_t write_getfd (struct file *file,char *buf,size_t size);static ssize_t write_getfs (struct file *file,char *buf,size_t size);static ssize_t write_filehandle (struct file *file,char *buf,size_t size); -static ssize_t write_threads (struct file *file,char *buf,size_t size); +static ssize_t write_config (struct file *file,char *buf,size_t size);static ssize_t write_leasetime (struct file *file,char *buf,size_t size);static ssize_t (*write_op[])(struct file *,char *,size_t ) = {
@@ -76,7 +76,7 @@ static ssize_t (*write_op[])(struct file [NFSD_Getfd] = write_getfd, [NFSD_Getfs] = write_getfs, [NFSD_Fh] = write_filehandle, - [NFSD_Threads] = write_threads, + [NFSD_Config] = write_config, [NFSD_Leasetime] = write_leasetime, };
@@ -133,7 +133,7 @@ static ssize_t write_svc(struct file *fiif (size <sizeof (*data))return -EINVAL ; data = (struct nfsctl_svc *) buf; -return nfsd_svc (data->svc_port, data->svc_nthreads); +return nfsd_svc (data->svc_port, data->svc_nthreads,0 ); }static ssize_t write_add (struct file *file,char *buf,size_t size)
@@ -304,13 +304,16 @@ static ssize_t write_filehandle(struct fextern int nfsd_nrthreads (void ); -static ssize_t write_threads (struct file *file,char *buf,size_t size) +static ssize_t write_config (struct file *file,char *buf,size_t size) {/* if size > 0, look for a number of threads and call nfsd_svc * then write out number of threads as reply */ char *mesg = buf;int rv; +unsigned int ctlbits =0 ; +unsigned int port =0 ; +if (size >0 ) {int newthreads; rv =get_int (&mesg, &newthreads);
@@ -318,11 +321,30 @@ static ssize_t write_threads(struct filereturn rv;if (newthreads <0 )return -EINVAL ; - rv =nfsd_svc (2049 , newthreads); + rv =get_int (&mesg, &port); +if (rv) { +/* +* its possible the rpc.nfsd does not +* have the ctlbits support, so just +* fill in with default values +*/ + port =2049 ; + ctlbits = ~0 ; +sprintf (buf,"%d\n" , newthreads); + }else { + rv =get_int (&mesg, &ctlbits); +if (rv) { + ctlbits = ~0 ; +sprintf (buf,"%d %d\n" ,nfsd_nrthreads (), port); + }else +sprintf (buf,"%d %d %d\n" ,nfsd_nrthreads (), port, ctlbits); + } + rv =nfsd_svc ((unsigned short )port, newthreads, ctlbits);if (rv)return rv; - } -sprintf (buf,"%d\n" ,nfsd_nrthreads ()); + }else +sprintf (buf,"%d\n" ,nfsd_nrthreads ()); +return strlen (buf); }
@@ -366,7 +388,7 @@ static int nfsd_fill_super(struct super_ [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, - [NFSD_Threads] = {"threads" , &transaction_ops,S_IWUSR |S_IRUSR }, + [NFSD_Config] = {"config" , &transaction_ops,S_IWUSR |S_IRUSR }, #ifdef CONFIG_NFSD_V4 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, #endif
include/linux/nfsd/syscall.h renamed from include/linux/nfsd/syscall.h.orig +8 -0
@@ -39,6 +39,14 @@#define NFSCTL_GETFD 7/* get an fh by path (used by mountd) */ #define NFSCTL_GETFS 8/* get an fh by path with max FH len */ +#define NFSCTL_VERUNSET (_cltbits, _v) ((_cltbits) &= ~(1 << ((_v) - 1))) +#define NFSCTL_UDPUNSET (_cltbits) ((_cltbits) &= ~(1 << (17 - 1))) +#define NFSCTL_TCPUNSET (_cltbits) ((_cltbits) &= ~(1 << (18 - 1))) + +#define NFSCTL_VERISSET (_cltbits, _v) ((_cltbits) & (1 << ((_v) - 1))) +#define NFSCTL_UDPISSET (_cltbits) ((_cltbits) & (1 << (17 - 1))) +#define NFSCTL_TCPISSET (_cltbits) ((_cltbits) & (1 << (18 - 1))) +/* SVC */ struct nfsctl_svc {unsigned short svc_port;
include/linux/nfsd/nfsd.h renamed from include/linux/nfsd/nfsd.h.orig +1 -1
@@ -63,7 +63,7 @@ extern struct svc_version nfsd_version2,/* * Function prototypes. */ -int nfsd_svc (unsigned short port,int nrservs); +int nfsd_svc (unsigned short port,int nrservs,unsigned int ctlbits);int nfsd_dispatch (struct svc_rqst *rqstp,u32 *statp);/* nfsd/vfs.c */