nfs-acl
Subsystems (4)
PATCH 11/11 nfs-acl
Client nfsacl support
Add support for the nfsacl protocol extension to nfs.
Andreas Gruenbacher <[email protected]>, SUSE Labs
fs/Kconfig +12 -0
@@ -1293,6 +1293,7 @@ config NFS_FS depends on INET select LOCKD select SUNRPC + select NFS_ACL_SUPPORT if NFS_ACL help If you are connected to some other (usually local) Unix computer (using SLIP, PLIP, PPP or Ethernet) and want to mount files residing
@@ -1335,6 +1336,17 @@ config NFS_V3 If unsure, say Y. +config NFS_ACL + bool "NFS_ACL protocol extension" + depends on NFS_V3 + select QSORT + help + Implement the NFS_ACL protocol extension for manipulating POSIX + Access Control Lists. The server must also implement the NFS_ACL + protocol extension; see the CONFIG_NFSD_ACL option. + + If unsure, say N. + config NFS_V4 bool "Provide NFSv4 client support (EXPERIMENTAL)" depends on NFS_FS && EXPERIMENTAL
fs/nfs/Makefile +1 -0
@@ -8,6 +8,7 @@ nfs-y := dir.o file.o inode.o nfs2xdr proc.o read.o symlink.o unlink.o write.o nfs-$(CONFIG_ROOT_NFS) += nfsroot.o mount_clnt.o nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o +nfs-$(CONFIG_NFS_ACL) += xattr.o nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ idmap.o nfs-$(CONFIG_NFS_DIRECTIO) += direct.o
fs/nfs/dir.c +4 -0
@@ -70,6 +70,10 @@ struct inode_operations nfs_dir_inode_op .permission = nfs_permission, .getattr = nfs_getattr, .setattr = nfs_setattr, + .listxattr = nfs_listxattr, + .getxattr = nfs_getxattr, + .setxattr = nfs_setxattr, + .removexattr = nfs_removexattr, };#ifdef CONFIG_NFS_V4
fs/nfs/file.c +4 -0
@@ -64,6 +64,10 @@ struct inode_operations nfs_file_inode_o .permission = nfs_permission, .getattr = nfs_getattr, .setattr = nfs_setattr, + .listxattr = nfs_listxattr, + .getxattr = nfs_getxattr, + .setxattr = nfs_setxattr, + .removexattr = nfs_removexattr, };/* Hack for future NFS swap support */
fs/nfs/inode.c +63 -3
127 lines not on this page · raw message
fs/nfs/nfs3proc.c +253 -1
276 lines not on this page · raw message
fs/nfs/nfs3xdr.c +138 -0
171 lines not on this page · raw message
fs/nfs/xattr.c +114 -0
114 lines not on this page · raw message
fs/nfsacl.c +7 -6
@@ -237,15 +237,16 @@ nfsacl_decode(struct xdr_buf *buf, unsig err =xdr_decode_array2 (buf, base +4 , &nfsacl_desc.desc);if (err)return err; -if (entries != nfsacl_desc.desc.array_len || -posix_acl_from_nfsacl (nfsacl_desc.acl) !=0 ) { -posix_acl_release (nfsacl_desc.acl); -return -EINVAL ; +if (pacl) { +if (entries != nfsacl_desc.desc.array_len || +posix_acl_from_nfsacl (nfsacl_desc.acl) !=0 ) { +posix_acl_release (nfsacl_desc.acl); +return -EINVAL ; + } + *pacl = nfsacl_desc.acl; }if (aclcnt) *aclcnt = entries; -if (pacl) - *pacl = nfsacl_desc.acl;return 8 + nfsacl_desc.desc.elem_size * nfsacl_desc.desc.array_len; }
include/linux/nfs_fs.h +16 -0
@@ -289,6 +289,22 @@ extern struct inode_operations nfs_file_extern struct file_operations nfs_file_operations;extern struct address_space_operations nfs_file_aops; +/* +* linux/fs/nfs/xattr.c +*/ +#ifdef CONFIG_NFS_ACL +extern ssize_t nfs_listxattr (struct dentry *,char *,size_t ); +extern ssize_t nfs_getxattr (struct dentry *,const char *,void *,size_t ); +extern int nfs_setxattr (struct dentry *,const char *, +const void *,size_t ,int ); +extern int nfs_removexattr (struct dentry *,const char *name); +#else +# define nfs_listxattr NULL +# define nfs_getxattr NULL +# define nfs_setxattr NULL +# define nfs_removexattr NULL +#endif +static __inline__struct rpc_cred *nfs_file_cred (struct file *file) {
include/linux/nfs_fs_sb.h +3 -0
@@ -9,6 +9,9 @@*/ struct nfs_server {struct rpc_clnt * client;/* RPC client handle */ +#ifdef CONFIG_NFS_ACL +struct rpc_clnt * acl_client;/* ACL RPC client handle */ +#endif /* CONFIG_NFS_ACL */ struct rpc_clnt * client_sys;/* 2nd handle for FSINFO */ struct nfs_rpc_ops * rpc_ops;/* NFS protocol vector */ struct backing_dev_info backing_dev_info;
include/linux/nfs_mount.h +3 -0
@@ -63,4 +63,7 @@ struct nfs_mount_data {#define NFS_MOUNT_SECFLAVOUR 0x2000/* 5 */ #define NFS_MOUNT_FLAGMASK 0xFFFF +/* Feature flag for the NFS_ACL protocol extension */ +#define NFSACL 0x10000 +#endif
include/linux/nfs_xdr.h +32 -0
@@ -2,6 +2,7 @@#define _LINUX_NFS_XDR_H#include <linux/sunrpc/xprt.h> +#include <linux/nfsacl.h> struct nfs4_fsid {__u64 major;
@@ -359,6 +360,20 @@ struct nfs_readdirargs {struct page ** pages; }; +struct nfs3_getaclargs { +struct nfs_fh * fh; +int mask; +struct page ** pages; +}; + +struct nfs3_setaclargs { +struct inode * inode; +int mask; +struct posix_acl * acl_access; +struct posix_acl * acl_default; +struct page ** pages; +}; +struct nfs_diropok {struct nfs_fh * fh;struct nfs_fattr * fattr;
@@ -480,6 +495,15 @@ struct nfs3_readdirres {int plus; }; +struct nfs3_getaclres { +struct nfs_fattr * fattr; +int mask; +unsigned int acl_access_count; +unsigned int acl_default_count; +struct posix_acl * acl_access; +struct posix_acl * acl_default; +}; +#ifdef CONFIG_NFS_V4 typedef u64 clientid4 ;
@@ -711,6 +735,11 @@ struct nfs_rpc_ops {void (*request_init)(struct nfs_page *,struct file *);int (*request_compatible)(struct nfs_page *,struct file *,struct page *);int (*lock)(struct file *,int ,struct file_lock *); +#ifdef CONFIG_NFS_ACL +struct posix_acl * (*getacl)(struct inode *,int ); +int (*setacl)(struct inode *,int ,struct posix_acl *); +int (*checkacls)(struct inode *inode); +#endif /* CONFIG_NFS_ACL */ };/*
@@ -732,4 +761,7 @@ extern struct rpc_version nfs_version4;extern struct rpc_program nfs_program;extern struct rpc_stat nfs_rpcstat; +extern struct rpc_version nfsacl_version3; +extern struct rpc_program nfsacl_program; +#endif
Quoted 4 lines · Andreas Gruenbacher
Client nfsacl support
Add support for the nfsacl protocol extension to nfs.
Why do we have to allocate an extra socket here? Can't we always assume that the NFSACL server will listen on port 2049 (the same as the NFS server)?
If so, we can simply clone the NFS rpc_client in order to share the socket/security flavours/...
BTW: why does the client side NFS_ACL select QSORT? Can't userland do all that for us?
Cheers,
Trond
Quoted 6 lines · Trond Myklebust
Quoted 4 lines · Andreas Gruenbacher
Client nfsacl support
Add support for the nfsacl protocol extension to nfs.
Quoted 6 lines
Why do we have to allocate an extra socket here? Can't we always assume that the NFSACL server will listen on port 2049 (the same as the NFS server)?
If so, we can simply clone the NFS
rpc_clientin order to share the socket/security flavours/...
We can share the same socket, but the code gets slightly messier. How about sharing the whole struct rpc_xprt (incremental patch)?
nfsacl-one-socket
-------------------------- 8< --------------------------
fs/nfs/inode.c +31 -31
@@ -370,32 +370,38 @@* Create an RPC client handle. */ static struct rpc_clnt * -__nfs_create_client (struct nfs_server *server, -const struct nfs_mount_data *data, -struct rpc_program *program) +nfs_create_client (struct nfs_server *server, +const struct nfs_mount_data *data, +struct rpc_program *program, +struct rpc_xprt *xprt) { -struct rpc_timeout timeparms; -struct rpc_xprt *xprt =NULL ;struct rpc_clnt *clnt =NULL ; -int tcp = (data->flags &NFS_MOUNT_TCP ); -/* Initialize timeout values */ - timeparms.to_initval = data->timeo *HZ /10 ; - timeparms.to_retries = data->retrans; - timeparms.to_maxval = tcp ?RPC_MAX_TCP_TIMEOUT :RPC_MAX_UDP_TIMEOUT ; - timeparms.to_exponential =1 ; +if (xprt) + xprt =xprt_get_handle (xprt); +else { +struct rpc_timeout timeparms; +int tcp = (data->flags &NFS_MOUNT_TCP ); + +/* Initialize timeout values */ + timeparms.to_initval = data->timeo *HZ /10 ; + timeparms.to_retries = data->retrans; + timeparms.to_maxval = tcp ?RPC_MAX_TCP_TIMEOUT : +RPC_MAX_UDP_TIMEOUT ; + timeparms.to_exponential =1 ; -if (!timeparms.to_initval) - timeparms.to_initval = (tcp ?600 :11 ) *HZ /10 ; -if (!timeparms.to_retries) - timeparms.to_retries =5 ; - -/* create transport and client */ - xprt =xprt_create_proto (tcp ?IPPROTO_TCP :IPPROTO_UDP , - &server->addr, &timeparms); -if (IS_ERR (xprt)) { -printk (KERN_WARNING "NFS: cannot create RPC transport.\n" ); -return (struct rpc_clnt *)xprt; +if (!timeparms.to_initval) + timeparms.to_initval = (tcp ?600 :11 ) *HZ /10 ; +if (!timeparms.to_retries) + timeparms.to_retries =5 ; + +/* create transport */ + xprt =xprt_create_proto (tcp ?IPPROTO_TCP :IPPROTO_UDP , + &server->addr, &timeparms); +if (IS_ERR (xprt)) { +printk (KERN_WARNING "NFS: cannot create RPC transport.\n" ); +return (struct rpc_clnt *)xprt; + } } clnt =rpc_create_client (xprt, server->hostname, program, server->rpc_ops->version, data->pseudoflavor);
@@ -416,12 +422,6 @@return clnt; } -static struct rpc_clnt * -nfs_create_client (struct nfs_server *server,const struct nfs_mount_data *data) -{ -return __nfs_create_client (server, data, &nfs_program); -} -/* * The way this works is that the mount process passes a structure * in the data argument which contains the server's IP address
@@ -482,13 +482,13 @@/* XXX maybe we want to add a server->pseudoflavor field */ /* Create RPC client handles */ - server->client =nfs_create_client (server, data); + server->client =nfs_create_client (server, data, &nfs_program,NULL );if (server->client ==NULL ) goto out_fail;#ifdef CONFIG_NFS_ACL if (server->flags &NFS_MOUNT_VER3 ) { - server->acl_client =__nfs_create_client (server, data, - &nfsacl_program); + server->acl_client =nfs_create_client (server, data, + &nfsacl_program, server->client->cl_xprt);if (server->acl_client ==NULL ) goto out_shutdown;/* Initially assume the nfsacl program is supported */
include/linux/sunrpc/xprt.h +2 -0
@@ -194,12 +194,14 @@void (*old_write_space)(struct sock *);wait_queue_head_t cong_wait; +int used; };#ifdef __KERNEL__struct rpc_xprt *xprt_create_proto (int proto,struct sockaddr_in *addr,struct rpc_timeout *toparms); +struct rpc_xprt *xprt_get_handle (struct rpc_xprt *);int xprt_destroy (struct rpc_xprt *);void xprt_shutdown (struct rpc_xprt *);void xprt_default_timeout (struct rpc_timeout *,int );
net/sunrpc/xprt.c +20 -6
@@ -1430,6 +1430,7 @@if ((xprt =kmalloc (sizeof (struct rpc_xprt ),GFP_KERNEL )) ==NULL )return ERR_PTR (-ENOMEM );memset (xprt,0 ,sizeof (*xprt));/* Nnnngh! */ + xprt->used =1 ; xprt->max_reqs = entries; slot_table_size = entries *sizeof (xprt->slot[0 ]); xprt->slot =kmalloc (slot_table_size,GFP_KERNEL );
@@ -1645,17 +1646,30 @@ }/* +* Get another reference to an RPC transport. +*/ +struct rpc_xprt * +xprt_get_handle (struct rpc_xprt *xprt) +{ + xprt->used++; +return xprt; +} + +/* * Destroy an RPC transport, killing off all requests. */ int xprt_destroy (struct rpc_xprt *xprt) { -dprintk ("RPC: destroying transport %p\n" , xprt); -xprt_shutdown (xprt); -xprt_disconnect (xprt); -xprt_close (xprt); -kfree (xprt->slot); -kfree (xprt); + xprt->used--; +if (!xprt->used) { +dprintk ("RPC: destroying transport %p\n" , xprt); +xprt_shutdown (xprt); +xprt_disconnect (xprt); +xprt_close (xprt); +kfree (xprt->slot); +kfree (xprt); + }return 0 ; }
-------------------------- 8< --------------------------
Quoted 2 lines
BTW: why does the client side
NFS_ACLselect QSORT? Can't userland do all that for us?
The server and client code both are using fs/nfsacl.c:nfsacl_decode() for converting from the xdr_buf to the internal representation. We could skip the qsort in the client case, but then the resulting struct posix_acl * would not work in all possible contexts anymore, and who knows where we will pass around acls in the future?
Thanks,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX AG
Quoted 2 lines · Andreas Gruenbacher
We can share the same socket, but the code gets slightly messier. How about sharing the whole struct
rpc_xprt(incremental patch)?
How about doing it as I suggested, using rpc_clone_client() instead?
You'll need to add
void rpc_change_program(struct rpc_client *clnt, struct rpc_program *program, int vers)
{
struct rpc_version *version;
BUG_ON(vers >= program->nrvers || !(version = program->version[vers]));
version = &program->version[vers];
clnt->cl_procinfo = version->procs;
clnt->cl_maxproc = version->nrprocs;
clnt->cl_protname = program->name;
clnt->cl_prog = program->number;
clnt->cl_vers = version->number;
clnt->cl_stats = program->stats
}...but that will allow you to do the whole process of creating the ACL RPC client in 2 lines:
struct rpc_client *aclclnt = rpc_clone_client(server->client); rpc_change_program(aclclnt, &nfsacl_program, 1);
...and hey presto, you have something that shares both the authentication cache and the socket with the NFS client.
Cheers,
Trond