ACLs over NFS: Necessary changes in the core NFS code
Subsystems (3)
Hello,
I have implemented Sun's NFS ACL protocol, which is an extension to NFSv3 that allows to manipulate POSIX ACLs over NFS mounts. Before that can be integrated a few changes to the NFS/RPC layer are needed:
* The NFS ACL protocol binds to the same port as the NFS protocol. The kernel NFS doesn't yet support multiple RPC programs on the same port.
* The RPC client does not properly report missing program/procedure information to its caller.
* Particularly for the NFS ACL protocol, the -ENOTSUPP and -ENOPNOTSUPP errors are not converted into NFS errors.
The attached patch implements these missing bits.
I am not certain about how to best handle the clnt->cl_xprt transport
endpoints: The patch uses a reference count in struct rpc_xprt to keep track of how many clients are using a certain endpoint. This is the least intrusive change; it may make more sense to handle this explicitly in the RPC clients. What do you think?
(The attached patch is against 2.5.62; this and a 2.4.21pre4 patch can be found at <http://www.suse.de/~agruen/acl/nfs/>.)
Cheers,
Andreas.
fs/lockd/svc.c +1 -0
@@ -380,6 +380,7 @@#define NLM_NRVERS (sizeof(nlmsvc_version)/sizeof(nlmsvc_version[0]))struct svc_program nlmsvc_program = { + .pg_next =NULL ,/* last program */ .pg_prog =NLM_PROGRAM ,/* program number */ .pg_nvers =NLM_NRVERS ,/* number of entries in nlmsvc_version */ .pg_vers = nlmsvc_version,/* version table */
fs/nfsd/nfsproc.c +2 -0
@@ -592,6 +592,8 @@#endif { nfserr_stale, -ESTALE }, { nfserr_dropit, -ENOMEM }, + { nfserr_notsupp, -ENOTSUP }, + { nfserr_notsupp, -ENOTSUPP }, { -1, -EIO } };int i;
fs/nfsd/nfssvc.c +2 -1
@@ -335,10 +335,11 @@#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0]))struct svc_program nfsd_program = { + .pg_next =NULL ,/* last program */ .pg_prog =NFS_PROGRAM ,/* program number */ .pg_nvers =NFSD_NRVERS ,/* nr of entries in nfsd_version */ .pg_vers = nfsd_version,/* version table */ .pg_name ="nfsd" ,/* program name */ .pg_class ="nfsd" ,/* authentication class */ - .pg_stats = &nfsd_svcstats,/* version table */ + .pg_stats = &nfsd_svcstats,/* rpc statistics */ };
include/linux/sunrpc/svc.h +2 -1
@@ -225,9 +225,10 @@ };/* -* RPC program +* List of RPC programs on the same transport endpoint */ struct svc_program { +struct svc_program * pg_next;/* other programs */ u32 pg_prog;/* program number */ unsigned int pg_lovers;/* lowest version */ unsigned int pg_hivers;/* lowest version */
include/linux/sunrpc/xprt.h +2 -0
@@ -148,6 +148,8 @@ nocong : 1, /* no congestion control */ resvport : 1, /* use a reserved port */ stream : 1; /* TCP */ +unsigned int clients;/* Number of clients using +this transport */ /* * State of TCP reply receive stuff
net/sunrpc/clnt.c +11 -1
@@ -117,6 +117,8 @@memset (clnt,0 ,sizeof (*clnt));atomic_set (&clnt->cl_users,0 ); + xprt->clients++; + clnt->cl_xprt = xprt; clnt->cl_procinfo = version->procs; clnt->cl_maxproc = version->nrprocs;
@@ -209,7 +211,7 @@ clnt->cl_auth =NULL ; }rpc_rmdir (clnt->cl_pathname); -if (clnt->cl_xprt) { +if (clnt->cl_xprt && !(--clnt->cl_xprt->clients)) {xprt_destroy (clnt->cl_xprt); clnt->cl_xprt =NULL ; }
@@ -939,6 +941,14 @@return p;case RPC_GARBAGE_ARGS :break ;/* retry */ +case RPC_PROG_UNAVAIL : +dprintk (KERN_WARNING "RPC: unknown program\n" ); +rpc_exit (task, -ENOSYS ); +return NULL ; +case RPC_PROC_UNAVAIL : +dprintk (KERN_WARNING "RPC: unknown procedure\n" ); +rpc_exit (task, -ENOSYS ); +return NULL ;default :printk (KERN_WARNING "call_verify: server accept status: %x\n" , n);/* Also retry */
net/sunrpc/svc.c +5 -4
@@ -319,8 +319,10 @@ goto dropit; } - progp = serv->sv_program; -if (prog != progp->pg_prog) +for (progp = serv->sv_program; progp; progp = progp->pg_next) +if (prog == progp->pg_prog) +break ; +if (progp ==NULL ) goto err_bad_prog; if (vers >= progp->pg_nvers ||
@@ -433,8 +435,7 @@ err_bad_prog:#ifdef RPC_PARANOIA -if (prog !=100227 || progp->pg_prog !=100003 ) -printk ("svc: unknown program %d (me %d)\n" , prog, progp->pg_prog); +printk ("svc: unknown program %d\n" , prog);/* else it is just a Solaris client seeing if ACLs are supported */ #endif serv->sv_stats->rpcbadfmt++;