NFSACL protocol extension for NFSv3
Subsystems (6)
v2 cover NFSACL protocol extension for NFSv3
This is the proper nfsacl patchset against 2.6.11-rc5. Again, these are the open issues:
- Not sure what do do about the Solaris compatibility hack. It's ugly no matter how we hide it, so I'll probably keep it the way it is now,
- Matt's heapsort is defective, so I'm not using it, yet.
Regards,
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 1/16 acl kconfig cleanup
Original patch from Matt Mackall <[email protected]>.
fs/Kconfig +6 -2
@@ -29,6 +29,7 @@ config EXT2_FS_XATTR config EXT2_FS_POSIX_ACL bool "Ext2 POSIX Access Control Lists" depends on EXT2_FS_XATTR + select FS_POSIX_ACL help Posix Access Control Lists (ACLs) support permissions for users and groups beyond the owner/group/world scheme.
@@ -97,6 +98,7 @@ config EXT3_FS_XATTR config EXT3_FS_POSIX_ACL bool "Ext3 POSIX Access Control Lists" depends on EXT3_FS_XATTR + select FS_POSIX_ACL help Posix Access Control Lists (ACLs) support permissions for users and groups beyond the owner/group/world scheme.
@@ -224,6 +226,7 @@ config REISERFS_FS_XATTR config REISERFS_FS_POSIX_ACL bool "ReiserFS POSIX Access Control Lists" depends on REISERFS_FS_XATTR + select FS_POSIX_ACL help Posix Access Control Lists (ACLs) support permissions for users and groups beyond the owner/group/world scheme.
@@ -257,6 +260,7 @@ config JFS_FS config JFS_POSIX_ACL bool "JFS POSIX Access Control Lists" depends on JFS_FS + select FS_POSIX_ACL help Posix Access Control Lists (ACLs) support permissions for users and groups beyond the owner/group/world scheme.
@@ -289,8 +293,7 @@ config FS_POSIX_ACL # Never use this symbol for ifdefs. # bool - depends on EXT2_FS_POSIX_ACL || EXT3_FS_POSIX_ACL || JFS_POSIX_ACL || REISERFS_FS_POSIX_ACL || NFSD_V4 - default y + default n config XFS_FS tristate "XFS filesystem support"
@@ -1531,6 +1534,7 @@ config NFSD_V4 bool "Provide NFSv4 server support (EXPERIMENTAL)" depends on NFSD_V3 && EXPERIMENTAL select NFSD_TCP + select FS_POSIX_ACL help If you would like to include the NFSv4 server as well as the NFSv2 and NFSv3 servers, say Y here. This feature is experimental, and
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [nfsacl v2 01/16] acl kconfig cleanup
Quoted 2 lines · Andre Tomt
The
Kconfigcleanup from Matt breaks compilation for me, on 2.6.11 kernel.org release.
It's based on a patch by Matt, but all bugs are mine ;) The attached patch went out privately before; I should have posted it here as well. This should fix the problem.
Thanks for testing!
Regards,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX GMBH
lib/Makefile +2 -1
@@ -5,7 +5,8 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ kobject.o kref.o idr.o div64.o parser.o int_sqrt.o \ - bitmap.o extable.o kobject_uevent.o prio_tree.o sort.o + bitmap.o extable.o kobject_uevent.o prio_tree.o +obj-y := sort.o ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG
fs/Kconfig +2 -2
@@ -1405,6 +1405,7 @@ select LOCKD select SUNRPC select EXPORTFS + select NFS_ACL_SUPPORT if NFSD_ACL help If you want your Linux box to act as an NFS *server*, so that other computers on your local network which support NFS can access certain
@@ -1438,7 +1439,6 @@ config NFSD_ACL bool "NFS_ACL protocol extension" depends on NFSD_V3 - select NFS_ACL_SUPPORT help Implement the NFS_ACL protocol extension for manipulating POSIX Access Control Lists on exported file systems. The clients must
@@ -1446,7 +1446,7 @@ CONFIG_NFS_ACL option. If unsure, say N. config NFS_ACL_SUPPORT - bool + tristate select FS_POSIX_ACL config NFSD_V4
fs/Kconfig +1 -1
@@ -1320,6 +1320,7 @@ 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
@@ -1415,7 +1416,6 @@ select LOCKD select SUNRPC select EXPORTFS - select NFS_ACL_SUPPORT if NFS_ACL help If you want your Linux box to act as an NFS *server*, so that other computers on your local network which support NFS can access certain
fs/nfs/nfs3proc.c +1 -1
@@ -1053,7 +1053,6 @@ .dentry_ops = &nfs_dentry_operations, .file_inode_ops = &nfs3_file_inode_operations, .dir_inode_ops = &nfs3_dir_inode_operations, - .special_inode_ops = &nfs3_special_inode_operations, .getroot = nfs3_proc_get_root, .getattr = nfs3_proc_getattr, .setattr = nfs3_proc_setattr,
@@ -1085,6 +1084,7 @@ .file_release = nfs_release, .lock = nfs3_proc_lock, #ifdef CONFIG_NFS_ACL + .special_inode_ops = &nfs3_special_inode_operations, .getacl = nfs3_proc_getacl, .setacl = nfs3_proc_setacl, .setacls = nfs3_proc_setacls,
PATCH v2 2/16 Qsort
In reply to Andreas GruenbacherAdd a quicksort from glibc as a kernel library function, and switch xfs over to using it. The implementations are equivalent. The nfsacl protocol also requires a sort function, so it makes more sense in the common code.
The plan is to replace this by Matt Machall's heap sort implementation after it has been fixed.
include/linux/kernel.h +2 -0
@@ -93,6 +93,8 @@ extern int sscanf(const char *, const ch __attribute__ ((format (scanf,2,3)));extern int vsscanf (const char *,const char *,va_list ); +extern void qsort (void *,size_t ,size_t ,int (*)(const void *,const void *)); +extern int get_option (char **str,int *pint);extern char *get_options (const char *str,int nints,int *ints);extern unsigned long long memparse (char *ptr,char **retptr);
lib/Kconfig +3 -0
@@ -30,6 +30,9 @@ config LIBCRC32C require M here. See Castagnoli93. Module will be libcrc32c. +config QSORT + bool "Quick Sort" + # # compression support is select'ed if needed #
lib/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_CRC_CCITT) += crc-ccitt.o obj-$(CONFIG_CRC32) += crc32.o obj-$(CONFIG_LIBCRC32C) += libcrc32c.o obj-$(CONFIG_GENERIC_IOMAP) += iomap.o +obj-$(CONFIG_QSORT) += qsort.o obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/ obj-$(CONFIG_ZLIB_DEFLATE) += zlib_deflate/
lib/qsort.c new file +249 -0
249 lines not on this page · raw message
fs/xfs/support/qsort.c deleted +0 -155
155 lines not on this page · raw message
fs/xfs/Makefile +0 -1
@@ -143,7 +143,6 @@ xfs-y += $(addprefix linux-2.6/, \ xfs-y += $(addprefix support/, \ debug.o \ move.o \ - qsort.o \ uuid.o) xfs-$(CONFIG_XFS_TRACE) += support/ktrace.o
fs/xfs/support/qsort.h deleted +0 -41
41 lines not on this page · raw message
fs/xfs/linux-2.6/xfs_linux.h +0 -1
@@ -64,7 +64,6 @@#include <sema.h> #include <time.h> -#include <support/qsort.h> #include <support/ktrace.h> #include <support/debug.h> #include <support/move.h>
fs/xfs/Kconfig +1 -0
@@ -3,6 +3,7 @@ menu "XFS support" config XFS_FS tristate "XFS filesystem support" select EXPORTFS if NFSD!=n + select QSORT help XFS is a high performance journaling filesystem which originated on the SGI IRIX platform. It is completely multi-threaded, can
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
Re: [nfsacl v2 02/16] Qsort
Quoted 7 lines · Andreas Gruenbacher
Add a quicksort from glibc as a kernel library function, and switch xfs over to using it. The implementations are equivalent. The nfsacl protocol also requires a sort function, so it makes more sense in the common code.
The plan is to replace this by Matt Machall's heap sort implementation after it has been fixed.
My fault; I overlooked the existing fixes in Andrew's tree. So this patch replaces qsort. I have rolled all the fixes into one patch.
A new "[10/16] Infrastructure and server side of nfsacl" patch will follow.
Regards,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX PRODUCTS GMBH
From: Matt Mackall <[email protected]>
Subject: heapsort
[Fixes added by [email protected].]
This patch adds a generic array sorting library routine. This is meant to replace qsort, which has two problem areas for kernel use.
The first issue is quadratic worst-case performance. While quicksort worst-case datasets are rarely encountered in normal scenarios, it is in fact quite easy to construct worst cases for almost all quicksort algorithms given source or access to an element comparison callback. This could allow attackers to cause sorts that would otherwise take less than a millisecond to take seconds and sorts that should take less than a second to take weeks or months. Fixing this problem requires randomizing pivot selection with a secure random number generator, which is rather expensive.
The second is that quicksort's recursion tracking requires either nontrivial amounts of stack space or dynamic memory allocation and out of memory error handling.
By comparison, heapsort has both O(n log n) average and worst-case performance and practically no extra storage requirements. This version runs within 70-90% of the average performance of optimized quicksort so it should be an acceptable replacement wherever quicksort would be used in the kernel.
Note that this function has an extra parameter for passing in an optimized swapping function. This is worth 10% or more over the typical byte-by-byte exchange functions.
Benchmarks:
qsort: glibc variant 1189 bytes (+ 256/1024 stack) qsort_3f: my simplified variant 459 bytes (+ 256/1024 stack) heapsort: the version below 346 bytes shellsort: an optimized shellsort 196 bytes
P4 1.8GHz Opteron 1.4GHz (32-bit)
size algorithm cycles relative cycles relative
100:
qsort: 38682 100.00% 27631 100.00%
qsort_3f: 36277 106.63% 22406 123.32%
heapsort: 43574 88.77% 30301 91.19%
shellsort: 39087 98.97% 25139 109.91%
200:
qsort: 86468 100.00% 61148 100.00%
qsort_3f: 78918 109.57% 48959 124.90%
heapsort: 98040 88.20% 68235 89.61%
shellsort: 95688 90.36% 62279 98.18%
400:
qsort: 187720 100.00% 131313 100.00%
qsort_3f: 174905 107.33% 107954 121.64%
heapsort: 223896 83.84% 154241 85.13%
shellsort: 223037 84.17% 148990 88.14%
800:
qsort: 407060 100.00% 287460 100.00%
qsort_3f: 385106 105.70% 239131 120.21%
heapsort: 484662 83.99% 340099 84.52%
shellsort: 537110 75.79% 354755 81.03%
1600:
qsort: 879596 100.00% 621331 100.00%
qsort_3f: 861568 102.09% 522013 119.03%
heapsort: 1079750 81.46% 746677 83.21%
shellsort: 1234243 71.27% 820782 75.70%
3200:
qsort: 1903902 100.00% 1342126 100.00%
qsort_3f: 1908816 99.74% 1131496 118.62%
heapsort: 2515493 75.69% 1630333 82.32%
shellsort: 2985339 63.78% 1964794 68.31%
6400:
qsort: 4046370 100.00% 2909215 100.00%
qsort_3f: 4164468 97.16% 2468393 117.86%
heapsort: 5150659 78.56% 3533585 82.33%
shellsort: 6650225 60.85% 4429849 65.67%
12800:
qsort: 8729730 100.00% 6185097 100.00%
qsort_3f: 8776885 99.46% 5288826 116.95%
heapsort: 11064224 78.90% 7603061 81.35%
shellsort: 15487905 56.36% 10305163 60.02%
25600:
qsort: 18357770 100.00% 13172205 100.00%
qsort_3f: 18687842 98.23% 11337115 116.19%
heapsort: 24121241 76.11% 16612122 79.29%
shellsort: 35552814 51.64% 24106987 54.64%
51200:
qsort: 38658883 100.00% 28008505 100.00%
qsort_3f: 39498463 97.87% 24339675 115.07%
heapsort: 50553552 76.47% 37013828 75.67%
shellsort: 82602416 46.80% 56201889 49.84%
102400:
qsort: 81197794 100.00% 58918933 100.00%
qsort_3f: 84257930 96.37% 51986219 113.34%
heapsort: 110540577 73.46% 81419675 72.36%
shellsort: 191303132 42.44% 129786472 45.40%include/linux/sort.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _LINUX_SORT_H +#define _LINUX_SORT_H + +#include <linux/types.h> + +void sort (void *base,size_t num,size_t size, +int (*cmp)(const void *,const void *), +void (*swap)(void *,void *,int )); + +#endif
lib/Makefile +1 -1
@@ -5,7 +5,7 @@ lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \ bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \ kobject.o kref.o idr.o div64.o parser.o int_sqrt.o \ - bitmap.o extable.o kobject_uevent.o prio_tree.o + bitmap.o extable.o kobject_uevent.o prio_tree.o sort.o ifeq ($(CONFIG_DEBUG_KOBJECT),y) CFLAGS_kobject.o += -DDEBUG
lib/sort.c new file +119 -0
119 lines not on this page · raw message
PATCH v2 3/16 Return -ENOSYS for RPC programs that are unavailable
In reply to Andreas GruenbacherThe issuer of an RPC call should be able to tell the difference between an I/O error and program unavailable / program version unavailable / procedure unavailable. Return -ENOSYS for unavailable RPCs instead of -EIO.
Only issue a program unavailable warning for program numbers other than the one for nfsacl: Clients with nfsacl support are quite common already; no need to clutter the syslog.
net/sunrpc/clnt.c +9 -6
@@ -1041,23 +1041,26 @@ call_verify(struct rpc_task *task)case RPC_SUCCESS :return p;case RPC_PROG_UNAVAIL : -printk (KERN_WARNING "RPC: call_verify: program %u is unsupported by server %s\n" , - (unsigned int )task->tk_client->cl_prog, - task->tk_client->cl_server); - goto out_eio; +dprintk (KERN_WARNING "RPC: call_verify: program %u is unsupported by server %s\n" , + (unsigned int )task->tk_client->cl_prog, + task->tk_client->cl_server); + error = -ENOSYS ; + goto out_err;case RPC_PROG_MISMATCH :printk (KERN_WARNING "RPC: call_verify: program %u, version %u unsupported by server %s\n" , (unsigned int )task->tk_client->cl_prog, (unsigned int )task->tk_client->cl_vers, task->tk_client->cl_server); - goto out_eio; + error = -ENOSYS ; + goto out_err;case RPC_PROC_UNAVAIL :printk (KERN_WARNING "RPC: call_verify: proc %p unsupported by program %u, version %u on server %s\n" , task->tk_msg.rpc_proc, task->tk_client->cl_prog, task->tk_client->cl_vers, task->tk_client->cl_server); - goto out_eio; + error = -EOPNOTSUPP ; + goto out_err;case RPC_GARBAGE_ARGS :dprintk ("RPC: %4d %s: server saw garbage\n" , task->tk_pid, __FUNCTION__);break ;/* retry */
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 4/16 Add missing -EOPNOTSUPP => NFS3ERR_NOTSUPP mapping in nfsd
In reply to Andreas GruenbacherAdd the missing NFS3ERR_NOTSUPP error code (defined in NFSv3) to the system-to-protocol-error table in nfsd. The nfsacl extension uses this error code.
fs/nfsd/nfsproc.c +1 -0
@@ -590,6 +590,7 @@ nfserrno (int errno) { nfserr_dropit, -EAGAIN }, { nfserr_dropit, -ENOMEM }, { nfserr_badname, -ESRCH }, + { nfserr_notsupp, -EOPNOTSUPP }, { -1, -EIO } };int i;
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 5/16 Allow multiple programs to listen on the same port
In reply to Andreas GruenbacherThe NFS and NFSACL programs run on the same RPC transport. This patch adds support for this by converting svc_program into a chained list of programs (server-side).
include/linux/sunrpc/svc.h +2 -1
@@ -240,9 +240,10 @@ struct svc_deferred_req { };/* -* RPC program +* List of RPC programs on the same transport endpoint */ struct svc_program { +struct svc_program * pg_next;/* other programs (same xprt) */ u32 pg_prog;/* program number */ unsigned int pg_lovers;/* lowest version */ unsigned int pg_hivers;/* lowest version */
net/sunrpc/svc.c +18 -17
@@ -35,20 +35,24 @@ svc_create(struct svc_program *prog, unsif (!(serv = (struct svc_serv *)kmalloc (sizeof (*serv),GFP_KERNEL )))return NULL ;memset (serv,0 ,sizeof (*serv)); + serv->sv_name = prog->pg_name; serv->sv_program = prog; serv->sv_nrthreads =1 ; serv->sv_stats = prog->pg_stats; serv->sv_bufsz = bufsize? bufsize :4096 ; - prog->pg_lovers = prog->pg_nvers-1 ; xdrsize =0 ; -for (vers=0 ; vers<prog->pg_nvers ; vers++) -if (prog->pg_vers[vers]) { - prog->pg_hivers = vers; -if (prog->pg_lovers > vers) - prog->pg_lovers = vers; -if (prog->pg_vers[vers]->vs_xdrsize > xdrsize) - xdrsize = prog->pg_vers[vers]->vs_xdrsize; - } +while (prog) { + prog->pg_lovers = prog->pg_nvers-1 ; +for (vers=0 ; vers<prog->pg_nvers ; vers++) +if (prog->pg_vers[vers]) { + prog->pg_hivers = vers; +if (prog->pg_lovers > vers) + prog->pg_lovers = vers; +if (prog->pg_vers[vers]->vs_xdrsize > xdrsize) + xdrsize = prog->pg_vers[vers]->vs_xdrsize; + } + prog = prog->pg_next; + } serv->sv_xdrsize = xdrsize;INIT_LIST_HEAD (&serv->sv_threads);INIT_LIST_HEAD (&serv->sv_sockets);
@@ -56,8 +60,6 @@ svc_create(struct svc_program *prog, unsINIT_LIST_HEAD (&serv->sv_permsocks);spin_lock_init (&serv->sv_lock); - serv->sv_name = prog->pg_name; -/* Remove any stale portmap registrations */ svc_register (serv,0 ,0 );
@@ -332,7 +334,10 @@ svc_process(struct svc_serv *serv, struc goto sendit; } -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 ||
@@ -444,11 +449,7 @@ err_bad_auth: goto sendit; 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); -/* else it is just a Solaris client seeing if ACLs are supported */ -#endif +dprintk ("svc: unknown program %d\n" , prog); serv->sv_stats->rpcbadfmt++;svc_putu32 (resv, rpc_prog_unavail); goto sendit;
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 6/16 Allow multiple programs to share the same transport
In reply to Andreas GruenbacherAllow a clone of an RPC client (created with rpc_clone_client()) to change to another program. This allows the NFS and NFSACL programs to share the same transport.
include/linux/sunrpc/clnt.h +3 -0
@@ -22,6 +22,7 @@* This defines an RPC port mapping */ struct rpc_portmap { +struct rpc_portmap *pm_parent;__u32 pm_prog;__u32 pm_vers;__u32 pm_prot;
@@ -116,6 +117,8 @@ struct rpc_clnt *rpc_clone_client(structint rpc_shutdown_client (struct rpc_clnt *);int rpc_destroy_client (struct rpc_clnt *);void rpc_release_client (struct rpc_clnt *); +void rpc_change_program (struct rpc_clnt *,struct rpc_program *, +int );void rpc_getport (struct rpc_task *,struct rpc_clnt *);int rpc_register (u32 ,u32 ,int ,unsigned short ,int *);
net/sunrpc/clnt.c +23 -0
@@ -139,6 +139,7 @@ rpc_create_client(struct rpc_xprt *xprt, clnt->cl_maxproc = version->nrprocs; clnt->cl_protname = program->name; clnt->cl_pmap = &clnt->cl_pmap_default; + clnt->cl_pmap->pm_parent = clnt->cl_pmap; clnt->cl_port = xprt->addr.sin_port; clnt->cl_prog = program->number; clnt->cl_vers = version->number;
@@ -207,6 +208,9 @@ rpc_clone_client(struct rpc_clnt *clnt)rpc_init_rtt (&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);if (new->cl_auth)atomic_inc (&new->cl_auth->au_count); + new->cl_pmap = &new->cl_pmap_default; + new->cl_pmap->pm_parent = clnt->cl_pmap->pm_parent; +rpc_init_wait_queue (&new->cl_pmap_default.pm_bindwait,"bindwait" );return new; out_no_clnt:printk (KERN_INFO "RPC: out of memory in %s\n" , __FUNCTION__);
@@ -296,6 +300,25 @@ rpc_release_client(struct rpc_clnt *clnt }/* +* Change the program of a (usually cloned) client +*/ +void +rpc_change_program (struct rpc_clnt *clnt,struct rpc_program *program, +int vers) +{ +struct rpc_version *version; + +BUG_ON (vers >= program->nrvers || !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; +} + +/* * Default callback for async RPC calls */ static void
net/sunrpc/pmap_clnt.c +2 -2
@@ -41,7 +41,7 @@ static spinlock_t pmap_lock = SPIN_LOCKvoid rpc_getport (struct rpc_task *task,struct rpc_clnt *clnt) { -struct rpc_portmap *map = clnt->cl_pmap; +struct rpc_portmap *map = clnt->cl_pmap->pm_parent;struct sockaddr_in *sap = &clnt->cl_xprt->addr;struct rpc_message msg = { .rpc_proc = &pmap_procedures[PMAP_GETPORT ],
@@ -132,7 +132,7 @@ static void pmap_getport_done(struct rpc_task *task) {struct rpc_clnt *clnt = task->tk_client; -struct rpc_portmap *map = clnt->cl_pmap; +struct rpc_portmap *map = clnt->cl_pmap->pm_parent;dprintk ("RPC: %4d pmap_getport_done(status %d, port %d)\n" , task->tk_pid, task->tk_status, clnt->cl_port);
net/sunrpc/sunrpc_syms.c +1 -0
@@ -42,6 +42,7 @@ EXPORT_SYMBOL(rpc_release_task);/* RPC client functions */ EXPORT_SYMBOL (rpc_create_client);EXPORT_SYMBOL (rpc_clone_client); +EXPORT_SYMBOL (rpc_change_program);EXPORT_SYMBOL (rpc_destroy_client);EXPORT_SYMBOL (rpc_shutdown_client);EXPORT_SYMBOL (rpc_release_client);
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 7/16 Lazy RPC receive buffer allocation
In reply to Andreas GruenbacherAllow to allocate pages in the receive buffer lazily. Used for the GETACL RPC, which has a big maximum reply size, but a small average reply size.
include/linux/sunrpc/xdr.h +1 -1
@@ -160,7 +160,7 @@ typedef struct {typedef size_t (*skb_read_actor_t )(skb_reader_t *desc,void *to,size_t len); -extern void xdr_partial_copy_from_skb (struct xdr_buf *,unsigned int , +extern int xdr_partial_copy_from_skb (struct xdr_buf *,unsigned int ,skb_reader_t *,skb_read_actor_t );struct socket ;
net/sunrpc/xdr.c +12 -3
@@ -176,7 +176,7 @@ xdr_inline_pages(struct xdr_buf *xdr, un xdr->buflen += len; } -void +int xdr_partial_copy_from_skb (struct xdr_buf *xdr,unsigned int base,skb_reader_t *desc,skb_read_actor_t copy_actor)
@@ -190,7 +190,7 @@ xdr_partial_copy_from_skb(struct xdr_buf len -= base; ret =copy_actor (desc, (char *)xdr->head[0 ].iov_base + base, len);if (ret != len || !desc->count) -return ; +return 0 ; base =0 ; }else base -= len;
@@ -210,6 +210,13 @@ xdr_partial_copy_from_skb(struct xdr_buf do { char *kaddr; + /* ACL likes to be lazy in allocating pages - ACLs + * are small by default but can get huge. */ + if (unlikely(*ppage == NULL)) { + if (!(*ppage = alloc_page(GFP_ATOMIC))) + return -ENOMEM; + } + len = PAGE_CACHE_SIZE; kaddr = kmap_atomic(*ppage, KM_SKB_SUNRPC_DATA); if (base) {
@@ -226,13 +233,15 @@ xdr_partial_copy_from_skb(struct xdr_bufflush_dcache_page (*ppage);kunmap_atomic (kaddr,KM_SKB_SUNRPC_DATA );if (ret != len || !desc->count) -return ; +return 0 ; ppage++; }while ((pglen -= len) !=0 ); copy_tail: len = xdr->tail[0 ].iov_len;if (base < len)copy_actor (desc, (char *)xdr->tail[0 ].iov_base + base, len - base); + +return 0 ; }
net/sunrpc/xprt.c +22 -4
@@ -725,7 +725,8 @@ csum_partial_copy_to_xdr(struct xdr_buf goto no_checksum; desc.csum =csum_partial (skb->data, desc.offset, skb->csum); -xdr_partial_copy_from_skb (xdr,0 , &desc, skb_read_and_csum_bits); +if (xdr_partial_copy_from_skb (xdr,0 , &desc, skb_read_and_csum_bits) <0 ) +return -1 ;if (desc.offset != skb->len) {unsigned int csum2; csum2 =skb_checksum (skb, desc.offset, skb->len - desc.offset,0 );
@@ -737,7 +738,8 @@ csum_partial_copy_to_xdr(struct xdr_bufreturn -1 ;return 0 ; no_checksum: -xdr_partial_copy_from_skb (xdr,0 , &desc, skb_read_bits); +if (xdr_partial_copy_from_skb (xdr,0 , &desc, skb_read_bits) <0 ) +return -1 ;if (desc.count)return -1 ;return 0 ;
@@ -907,6 +909,7 @@ tcp_read_request(struct rpc_xprt *xprt,struct rpc_rqst *req;struct xdr_buf *rcvbuf;size_t len; +int r;/* Find and lock the request corresponding to this xid */ spin_lock (&xprt->sock_lock);
@@ -927,16 +930,30 @@ tcp_read_request(struct rpc_xprt *xprt, len = xprt->tcp_reclen - xprt->tcp_offset;memcpy (&my_desc, desc,sizeof (my_desc)); my_desc.count = len; -xdr_partial_copy_from_skb (rcvbuf, xprt->tcp_copied, + r =xdr_partial_copy_from_skb (rcvbuf, xprt->tcp_copied, &my_desc, tcp_copy_data); desc->count -= len; desc->offset += len; }else -xdr_partial_copy_from_skb (rcvbuf, xprt->tcp_copied, + r =xdr_partial_copy_from_skb (rcvbuf, xprt->tcp_copied, desc, tcp_copy_data); xprt->tcp_copied += len; xprt->tcp_offset += len; +if (r <0 ) { +/* Error when copying to the receive buffer, +* usually because we weren't able to allocate +* additional buffer pages. All we can do now +* is turn off XPRT_COPY_DATA, so the request +* will not receive any additional updates, +* and time out. +* Any remaining data from this record will +* be discarded. +*/ + xprt->tcp_flags &= ~XPRT_COPY_DATA ; + goto out; + } +if (xprt->tcp_copied == req->rq_private_buf.buflen) xprt->tcp_flags &= ~XPRT_COPY_DATA ;else if (xprt->tcp_offset == xprt->tcp_reclen) {
@@ -949,6 +966,7 @@ tcp_read_request(struct rpc_xprt *xprt, req->rq_task->tk_pid);xprt_complete_rqst (xprt, req, xprt->tcp_copied); } +out:spin_unlock (&xprt->sock_lock);tcp_check_recm (xprt); }
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 8/16 Encode and decode arbitrary XDR arrays
In reply to Andreas GruenbacherAdd xdr_encode_array2 and xdr_decode_array2 functions for encoding end decoding arrays with arbitrary entries, such as acl entries. The goal here is to do this without allocating a contiguous temporary buffer.
include/linux/sunrpc/xdr.h +18 -1
@@ -146,7 +146,8 @@ extern void xdr_shift_buf(struct xdr_bufextern void xdr_buf_from_iov (struct kvec *,struct xdr_buf *);extern int xdr_buf_subsegment (struct xdr_buf *,struct xdr_buf *,int ,int );extern int xdr_buf_read_netobj (struct xdr_buf *,struct xdr_netobj *,int ); -extern int read_bytes_from_xdr_buf (struct xdr_buf *buf,int base,void *obj,int len); +extern int read_bytes_from_xdr_buf (struct xdr_buf *,int ,void *,int ); +extern int write_bytes_to_xdr_buf (struct xdr_buf *,int ,void *,int );/* * Helper structure for copying from an sk_buff.
@@ -168,6 +169,22 @@ struct sockaddr;extern int xdr_sendpages (struct socket *,struct sockaddr *,int ,struct xdr_buf *,unsigned int ,int ); +extern int xdr_encode_word (struct xdr_buf *,int ,u32 ); +extern int xdr_decode_word (struct xdr_buf *,int ,u32 *); + +struct xdr_array2_desc ; +typedef int (*xdr_xcode_elem_t )(struct xdr_array2_desc *desc,void *elem); +struct xdr_array2_desc { +unsigned int elem_size; +unsigned int array_len; +xdr_xcode_elem_t xcode; +}; + +extern int xdr_decode_array2 (struct xdr_buf *buf,unsigned int base, +struct xdr_array2_desc *desc); +extern int xdr_encode_array2 (struct xdr_buf *buf,unsigned int base, +struct xdr_array2_desc *desc); +/* * Provide some simple tools for XDR buffer overflow-checking etc. */
net/sunrpc/sunrpc_syms.c +4 -0
@@ -129,6 +129,10 @@ EXPORT_SYMBOL(xdr_encode_netobj);EXPORT_SYMBOL (xdr_encode_pages);EXPORT_SYMBOL (xdr_inline_pages);EXPORT_SYMBOL (xdr_shift_buf); +EXPORT_SYMBOL (xdr_encode_word); +EXPORT_SYMBOL (xdr_decode_word); +EXPORT_SYMBOL (xdr_encode_array2); +EXPORT_SYMBOL (xdr_decode_array2);EXPORT_SYMBOL (xdr_buf_from_iov);EXPORT_SYMBOL (xdr_buf_subsegment);EXPORT_SYMBOL (xdr_buf_read_netobj);
net/sunrpc/xdr.c +253 -3
277 lines not on this page · raw message
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 9/16 Add noacl nfs mount option
In reply to Andreas GruenbacherWith the noacl mount option, nfs clients stop using the ACCESS RPC which they usually use to get an access decision from the server. Instead, they make the decision based on the file ownership and file mode permission bits.
Security-wise using this option can lead to illicit read access to data cached locally on the client if the server uses POSIX ACLs. Local access decisions are correct as long as the server does not support POSIX access control lists.
This approach was discussed with Trond Myklebust <[email protected]> and Olaf Kirch <[email protected]>. Requires a patch to mount (util-linux).
fs/nfs/dir.c +2 -1
@@ -1497,6 +1497,7 @@ out:int nfs_permission (struct inode *inode,int mask,struct nameidata *nd) { +struct nfs_server *server =NFS_SERVER (inode);struct rpc_cred *cred;int res;
@@ -1515,7 +1516,7 @@ int nfs_permission(struct inode *inode,lock_kernel (); -if (!NFS_PROTO (inode)->access) +if ((server->flags &NFS_MOUNT_NOACL ) || !NFS_PROTO (inode)->access) goto out_notsup; cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 );
fs/nfs/inode.c +1 -0
@@ -539,6 +539,7 @@ static int nfs_show_options(struct seq_f { NFS_MOUNT_NOAC, ",noac", "" }, { NFS_MOUNT_NONLM, ",nolock", ",lock" }, { NFS_MOUNT_BROKEN_SUID, ",broken_suid", "" }, + { NFS_MOUNT_NOACL, ",noacl", "" }, { 0, NULL, NULL } };struct proc_nfs_info *nfs_infop;
include/linux/nfs_mount.h +1 -0
@@ -58,6 +58,7 @@ struct nfs_mount_data {#define NFS_MOUNT_KERBEROS 0x0100/* 3 */ #define NFS_MOUNT_NONLM 0x0200/* 3 */ #define NFS_MOUNT_BROKEN_SUID 0x0400/* 4 */ +#define NFS_MOUNT_NOACL 0x0800/* 4 */ #define NFS_MOUNT_STRICTLOCK 0x1000/* reserved for NFSv4 */ #define NFS_MOUNT_SECFLAVOUR 0x2000/* 5 */ #define NFS_MOUNT_FLAGMASK 0xFFFF
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 10/16 Infrastructure and server side of nfsacl
In reply to Andreas GruenbacherThis adds functions for encoding and decoding POSIX ACLs for the NFSACL protocol extension, and the GETACL and SETACL RPCs. The implementation is compatible with NFSACL in Solaris.
fs/Kconfig +14 -0
@@ -1435,6 +1435,20 @@ config NFSD_V3 If you would like to include the NFSv3 server as well as the NFSv2 server, say Y here. If unsure, say Y. +config NFSD_ACL + bool "NFS_ACL protocol extension" + depends on NFSD_V3 + select NFS_ACL_SUPPORT + help + Implement the NFS_ACL protocol extension for manipulating POSIX + Access Control Lists on exported file systems. The clients must + also implement the NFS_ACL protocol extension; see the + CONFIG_NFS_ACL option. If unsure, say N. + +config NFS_ACL_SUPPORT + bool + select FS_POSIX_ACL + config NFSD_V4 bool "Provide NFSv4 server support (EXPERIMENTAL)" depends on NFSD_V3 && EXPERIMENTAL
fs/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat obj-$(CONFIG_FS_MBCACHE) += mbcache.o obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o +obj-$(CONFIG_NFS_ACL_SUPPORT) += nfsacl.o obj-$(CONFIG_QUOTA) += dquot.o obj-$(CONFIG_QFMT_V1) += quota_v1.o
fs/nfsacl.c new file +254 -0
254 lines not on this page · raw message
fs/nfsd/nfs3proc.c +118 -0
145 lines not on this page · raw message
fs/nfsd/nfs3xdr.c +114 -0
135 lines not on this page · raw message
fs/nfsd/nfssvc.c +24 -0
@@ -49,6 +49,9 @@#define SIG_NOCLEAN SIGHUPextern struct svc_program nfsd_program; +#ifdef CONFIG_NFSD_ACL +extern struct svc_program nfsd_acl_program; +#endif static void nfsd (struct svc_rqst *rqstp);struct timeval nfssvc_boot;static struct svc_serv *nfsd_serv;
@@ -370,8 +373,29 @@ static struct svc_version * nfsd_version#endif }; +#ifdef CONFIG_NFSD_ACL +extern struct svc_version nfsd_acl_version3; + +static struct svc_version * nfsd_acl_version[] = { + [3 ] = &nfsd_acl_version3, +}; + +#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0])) +struct svc_program nfsd_acl_program = { + .pg_prog =NFS3_ACL_PROGRAM , + .pg_nvers =NFSD_ACL_NRVERS , + .pg_vers = nfsd_acl_version, + .pg_name ="nfsd" , + .pg_stats = &nfsd_acl_svcstats, +}; +# define nfsd_acl_program_p &nfsd_acl_program +#else +# define nfsd_acl_program_p NULL +#endif +#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0]))struct svc_program nfsd_program = { + .pg_next = nfsd_acl_program_p, .pg_prog =NFS_PROGRAM ,/* program number */ .pg_nvers =NFSD_NRVERS ,/* nr of entries in nfsd_version */ .pg_vers = nfsd_version,/* version table */
fs/nfsd/stats.c +6 -0
@@ -40,6 +40,12 @@ struct svc_stat nfsd_svcstats = { .program = &nfsd_program, }; +#ifdef CONFIG_NFSD_ACL +struct svc_stat nfsd_acl_svcstats = { + .program = &nfsd_acl_program, +}; +#endif +static int nfsd_proc_show (struct seq_file *seq,void *v) {int i;
fs/nfsd/vfs.c +107 -0
116 lines not on this page · raw message
include/linux/nfs3.h +13 -0
@@ -37,6 +37,15 @@ enum nfs3_createmode { NFS3_CREATE_EXCLUSIVE = 2 }; +/* Flags for the getacl/setacl mode */ +#define NFS3_ACL 0x0001 +#define NFS3_ACLCNT 0x0002 +#define NFS3_DFACL 0x0004 +#define NFS3_DFACLCNT 0x0008 + +/* Flag for Default ACL entries */ +#define NFS3_ACL_DEFAULT 0x1000 +/* NFSv3 file system properties */ #define NFS3_FSF_LINK 0x0001#define NFS3_FSF_SYMLINK 0x0002
@@ -88,6 +97,10 @@ struct nfs3_fh {#define NFS3PROC_PATHCONF 20#define NFS3PROC_COMMIT 21 +#define NFS3_ACL_PROGRAM 100227 +#define NFS3PROC_GETACL 1 +#define NFS3PROC_SETACL 2 +#define NFS_MNT3_PROGRAM 100005#define NFS_MNT3_VERSION 3#define MOUNTPROC3_NULL 0
include/linux/nfsacl.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* File: linux/nfsacl.h +* +* (C) 2003 Andreas Gruenbacher <[email protected]> +*/ + + +#ifndef __LINUX_NFSACL_H +#define __LINUX_NFSACL_H + +#include <linux/posix_acl.h> + +/* Maximum number of ACL entries over NFS */ +#define NFS3_ACL_MAX_ENTRIES 1024 + +#define NFSACL_MAXWORDS (2*(2+3*NFS3_ACL_MAX_ENTRIES)) +#define NFSACL_MAXPAGES ((2*(8+12*NFS3_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \ + >> PAGE_SHIFT) + +static inline unsigned int +nfsacl_size (struct posix_acl *acl_access,struct posix_acl *acl_default) +{ +unsigned int w =16 ; + w +=max (acl_access ? (int )acl_access->a_count :3 ,4 ) *12 ; +if (acl_default) + w +=max ((int )acl_default->a_count,4 ) *12 ; +return w; +} + +extern unsigned int +nfsacl_encode (struct xdr_buf *buf,unsigned int base,struct inode *inode, +struct posix_acl *acl,int encode_entries,int typeflag); +extern unsigned int +nfsacl_decode (struct xdr_buf *buf,unsigned int base,unsigned int *aclcnt, +struct posix_acl **pacl); + +#endif /* __LINUX_NFSACL_H */
include/linux/nfsd/nfsd.h +19 -0
@@ -15,6 +15,7 @@#include <linux/unistd.h> #include <linux/dirent.h> #include <linux/fs.h> +#include <linux/posix_acl.h> #include <linux/mount.h> #include <linux/nfsd/debug.h>
@@ -60,6 +61,8 @@ extern struct svc_program nfsd_program;extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; +extern struct svc_program nfsd_acl_program; +extern struct svc_version nfsd_acl_version3;/* * Function prototypes. */
@@ -124,6 +127,22 @@ int nfsd_statfs(struct svc_rqst *, struint nfsd_notify_change (struct inode *,struct iattr *);int nfsd_permission (struct svc_export *,struct dentry *,int ); +#ifdef CONFIG_NFSD_ACL +struct posix_acl *nfsd_get_posix_acl (struct svc_fh *,int ); +int nfsd_set_posix_acl (struct svc_fh *,int ,struct posix_acl *); +#else +static inline struct posix_acl * +nfsd_get_posix_acl (struct svc_fh *fhp,int acl_type) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline int +nfsd_set_posix_acl (struct svc_fh *fhp,int type,struct posix_acl *acl) +{ +return -EOPNOTSUPP ; +} +#endif +/* * NFSv4 State
include/linux/nfsd/stats.h +1 -0
@@ -36,6 +36,7 @@ struct nfsd_stats {extern struct nfsd_stats nfsdstats;extern struct svc_stat nfsd_svcstats; +extern struct svc_stat nfsd_acl_svcstats;void nfsd_stat_init (void );void nfsd_stat_shutdown (void );
include/linux/nfsd/xdr3.h +32 -0
@@ -10,6 +10,7 @@#define _LINUX_NFSD_XDR3_H#include <linux/nfsd/xdr.h> +#include <linux/posix_acl.h> struct nfsd3_sattrargs {struct svc_fh fh;
@@ -110,6 +111,18 @@ struct nfsd3_commitargs {__u32 count; }; +struct nfsd3_getaclargs { +struct svc_fh fh; +int mask; +}; + +struct nfsd3_setaclargs { +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +struct nfsd3_attrstat {__u32 status;struct svc_fh fh;
@@ -209,6 +222,14 @@ struct nfsd3_commitres {struct svc_fh fh; }; +struct nfsd3_getaclres { +__u32 status; +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +/* dummy type for release */ struct nfsd3_fhandle_pair {__u32 dummy;
@@ -241,6 +262,7 @@ union nfsd3_xdrstore {struct nfsd3_fsinfores fsinfores;struct nfsd3_pathconfres pathconfres;struct nfsd3_commitres commitres; +struct nfsd3_getaclres getaclres; };#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
@@ -276,6 +298,10 @@ int nfs3svc_decode_readdirplusargs(struc struct nfsd3_readdirargs *);int nfs3svc_decode_commitargs (struct svc_rqst *,u32 *,struct nfsd3_commitargs *); +int nfs3svc_decode_getaclargs (struct svc_rqst *,u32 *, +struct nfsd3_getaclargs *); +int nfs3svc_decode_setaclargs (struct svc_rqst *,u32 *, +struct nfsd3_setaclargs *);int nfs3svc_encode_voidres (struct svc_rqst *,u32 *,void *);int nfs3svc_encode_attrstat (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);
@@ -305,11 +331,17 @@ int nfs3svc_encode_pathconfres(struct sv struct nfsd3_pathconfres *);int nfs3svc_encode_commitres (struct svc_rqst *,u32 *,struct nfsd3_commitres *); +int nfs3svc_encode_getaclres (struct svc_rqst *,u32 *, +struct nfsd3_getaclres *); +int nfs3svc_encode_setaclres (struct svc_rqst *,u32 *, +struct nfsd3_attrstat *);int nfs3svc_release_fhandle (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);int nfs3svc_release_fhandle2 (struct svc_rqst *,u32 *,struct nfsd3_fhandle_pair *); +int nfs3svc_release_getacl (struct svc_rqst *rqstp,u32 *p, +struct nfsd3_getaclres *resp);int nfs3svc_encode_entry (struct readdir_cd *,const char *name,int namlen,loff_t offset,ino_t ino,unsigned int );
include/linux/sunrpc/svc.h +21 -0
@@ -185,6 +185,27 @@ xdr_ressize_check(struct svc_rqst *rqstpreturn vec->iov_len <=PAGE_SIZE ; } +#if 0 +static inline struct page * +svc_take_arg_page (struct svc_rqst *rqstp) +{ +if (rqstp->rq_arghi <= rqstp->rq_argused) +return NULL ; +return rqstp->rq_argpages[rqstp->rq_argused++]; +} +#endif + +static inline struct page * +svc_take_res_page (struct svc_rqst *rqstp) +{ +if (rqstp->rq_arghi <= rqstp->rq_argused) +return NULL ; + rqstp->rq_arghi--; + rqstp->rq_respages[rqstp->rq_resused] = + rqstp->rq_argpages[rqstp->rq_arghi]; +return rqstp->rq_respages[rqstp->rq_resused++]; +} +static inline int svc_take_page (struct svc_rqst *rqstp) {if (rqstp->rq_arghi <= rqstp->rq_argused)
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
Re: [nfsacl v2 10/16] Infrastructure and server side of nfsacl
Quoted 3 lines · Andreas Gruenbacher
This adds functions for encoding and decoding POSIX ACLs for the NFSACL protocol extension, and the GETACL and SETACL RPCs. The implementation is compatible with NFSACL in Solaris.
This patch now uses Matt's heapsort.
Regards,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX PRODUCTS GMBH
From: Andreas Gruenbacher <[email protected]>
Subject: Infrastructure and server side of nfsacl
This adds functions for encoding and decoding POSIX ACLs for the NFSACL protocol extension, and the GETACL and SETACL RPCs. The implementation is compatible with NFSACL in Solaris.
fs/Kconfig +14 -0
@@ -1435,6 +1435,20 @@ config NFSD_V3 If you would like to include the NFSv3 server as well as the NFSv2 server, say Y here. If unsure, say Y. +config NFSD_ACL + bool "NFS_ACL protocol extension" + depends on NFSD_V3 + select NFS_ACL_SUPPORT + help + Implement the NFS_ACL protocol extension for manipulating POSIX + Access Control Lists on exported file systems. The clients must + also implement the NFS_ACL protocol extension; see the + CONFIG_NFS_ACL option. If unsure, say N. + +config NFS_ACL_SUPPORT + bool + select FS_POSIX_ACL + config NFSD_V4 bool "Provide NFSv4 server support (EXPERIMENTAL)" depends on NFSD_V3 && EXPERIMENTAL
fs/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat obj-$(CONFIG_FS_MBCACHE) += mbcache.o obj-$(CONFIG_FS_POSIX_ACL) += posix_acl.o xattr_acl.o +obj-$(CONFIG_NFS_ACL_SUPPORT) += nfsacl.o obj-$(CONFIG_QUOTA) += dquot.o obj-$(CONFIG_QFMT_V1) += quota_v1.o
fs/nfsacl.c new file +257 -0
257 lines not on this page · raw message
fs/nfsd/nfs3proc.c +118 -0
145 lines not on this page · raw message
fs/nfsd/nfs3xdr.c +114 -0
135 lines not on this page · raw message
fs/nfsd/nfssvc.c +24 -0
@@ -49,6 +49,9 @@#define SIG_NOCLEAN SIGHUPextern struct svc_program nfsd_program; +#ifdef CONFIG_NFSD_ACL +extern struct svc_program nfsd_acl_program; +#endif static void nfsd (struct svc_rqst *rqstp);struct timeval nfssvc_boot;static struct svc_serv *nfsd_serv;
@@ -370,8 +373,29 @@ static struct svc_version * nfsd_version#endif }; +#ifdef CONFIG_NFSD_ACL +extern struct svc_version nfsd_acl_version3; + +static struct svc_version * nfsd_acl_version[] = { + [3 ] = &nfsd_acl_version3, +}; + +#define NFSD_ACL_NRVERS (sizeof(nfsd_acl_version)/sizeof(nfsd_acl_version[0])) +struct svc_program nfsd_acl_program = { + .pg_prog =NFS3_ACL_PROGRAM , + .pg_nvers =NFSD_ACL_NRVERS , + .pg_vers = nfsd_acl_version, + .pg_name ="nfsd" , + .pg_stats = &nfsd_acl_svcstats, +}; +# define nfsd_acl_program_p &nfsd_acl_program +#else +# define nfsd_acl_program_p NULL +#endif +#define NFSD_NRVERS (sizeof(nfsd_version)/sizeof(nfsd_version[0]))struct svc_program nfsd_program = { + .pg_next = nfsd_acl_program_p, .pg_prog =NFS_PROGRAM ,/* program number */ .pg_nvers =NFSD_NRVERS ,/* nr of entries in nfsd_version */ .pg_vers = nfsd_version,/* version table */
fs/nfsd/stats.c +6 -0
@@ -40,6 +40,12 @@ struct svc_stat nfsd_svcstats = { .program = &nfsd_program, }; +#ifdef CONFIG_NFSD_ACL +struct svc_stat nfsd_acl_svcstats = { + .program = &nfsd_acl_program, +}; +#endif +static int nfsd_proc_show (struct seq_file *seq,void *v) {int i;
fs/nfsd/vfs.c +107 -0
116 lines not on this page · raw message
include/linux/nfs3.h +13 -0
@@ -37,6 +37,15 @@ enum nfs3_createmode { NFS3_CREATE_EXCLUSIVE = 2 }; +/* Flags for the getacl/setacl mode */ +#define NFS3_ACL 0x0001 +#define NFS3_ACLCNT 0x0002 +#define NFS3_DFACL 0x0004 +#define NFS3_DFACLCNT 0x0008 + +/* Flag for Default ACL entries */ +#define NFS3_ACL_DEFAULT 0x1000 +/* NFSv3 file system properties */ #define NFS3_FSF_LINK 0x0001#define NFS3_FSF_SYMLINK 0x0002
@@ -88,6 +97,10 @@ struct nfs3_fh {#define NFS3PROC_PATHCONF 20#define NFS3PROC_COMMIT 21 +#define NFS3_ACL_PROGRAM 100227 +#define NFS3PROC_GETACL 1 +#define NFS3PROC_SETACL 2 +#define NFS_MNT3_PROGRAM 100005#define NFS_MNT3_VERSION 3#define MOUNTPROC3_NULL 0
include/linux/nfsacl.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* File: linux/nfsacl.h +* +* (C) 2003 Andreas Gruenbacher <[email protected]> +*/ + + +#ifndef __LINUX_NFSACL_H +#define __LINUX_NFSACL_H + +#include <linux/posix_acl.h> + +/* Maximum number of ACL entries over NFS */ +#define NFS3_ACL_MAX_ENTRIES 1024 + +#define NFSACL_MAXWORDS (2*(2+3*NFS3_ACL_MAX_ENTRIES)) +#define NFSACL_MAXPAGES ((2*(8+12*NFS3_ACL_MAX_ENTRIES) + PAGE_SIZE-1) \ + >> PAGE_SHIFT) + +static inline unsigned int +nfsacl_size (struct posix_acl *acl_access,struct posix_acl *acl_default) +{ +unsigned int w =16 ; + w +=max (acl_access ? (int )acl_access->a_count :3 ,4 ) *12 ; +if (acl_default) + w +=max ((int )acl_default->a_count,4 ) *12 ; +return w; +} + +extern unsigned int +nfsacl_encode (struct xdr_buf *buf,unsigned int base,struct inode *inode, +struct posix_acl *acl,int encode_entries,int typeflag); +extern unsigned int +nfsacl_decode (struct xdr_buf *buf,unsigned int base,unsigned int *aclcnt, +struct posix_acl **pacl); + +#endif /* __LINUX_NFSACL_H */
include/linux/nfsd/nfsd.h +19 -0
@@ -15,6 +15,7 @@#include <linux/unistd.h> #include <linux/dirent.h> #include <linux/fs.h> +#include <linux/posix_acl.h> #include <linux/mount.h> #include <linux/nfsd/debug.h>
@@ -60,6 +61,8 @@ extern struct svc_program nfsd_program;extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; +extern struct svc_program nfsd_acl_program; +extern struct svc_version nfsd_acl_version3;/* * Function prototypes. */
@@ -124,6 +127,22 @@ int nfsd_statfs(struct svc_rqst *, struint nfsd_notify_change (struct inode *,struct iattr *);int nfsd_permission (struct svc_export *,struct dentry *,int ); +#ifdef CONFIG_NFSD_ACL +struct posix_acl *nfsd_get_posix_acl (struct svc_fh *,int ); +int nfsd_set_posix_acl (struct svc_fh *,int ,struct posix_acl *); +#else +static inline struct posix_acl * +nfsd_get_posix_acl (struct svc_fh *fhp,int acl_type) +{ +return ERR_PTR (-EOPNOTSUPP ); +} +static inline int +nfsd_set_posix_acl (struct svc_fh *fhp,int type,struct posix_acl *acl) +{ +return -EOPNOTSUPP ; +} +#endif +/* * NFSv4 State
include/linux/nfsd/stats.h +1 -0
@@ -36,6 +36,7 @@ struct nfsd_stats {extern struct nfsd_stats nfsdstats;extern struct svc_stat nfsd_svcstats; +extern struct svc_stat nfsd_acl_svcstats;void nfsd_stat_init (void );void nfsd_stat_shutdown (void );
include/linux/nfsd/xdr3.h +32 -0
@@ -10,6 +10,7 @@#define _LINUX_NFSD_XDR3_H#include <linux/nfsd/xdr.h> +#include <linux/posix_acl.h> struct nfsd3_sattrargs {struct svc_fh fh;
@@ -110,6 +111,18 @@ struct nfsd3_commitargs {__u32 count; }; +struct nfsd3_getaclargs { +struct svc_fh fh; +int mask; +}; + +struct nfsd3_setaclargs { +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +struct nfsd3_attrstat {__u32 status;struct svc_fh fh;
@@ -209,6 +222,14 @@ struct nfsd3_commitres {struct svc_fh fh; }; +struct nfsd3_getaclres { +__u32 status; +struct svc_fh fh; +int mask; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +}; +/* dummy type for release */ struct nfsd3_fhandle_pair {__u32 dummy;
@@ -241,6 +262,7 @@ union nfsd3_xdrstore {struct nfsd3_fsinfores fsinfores;struct nfsd3_pathconfres pathconfres;struct nfsd3_commitres commitres; +struct nfsd3_getaclres getaclres; };#define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore)
@@ -276,6 +298,10 @@ int nfs3svc_decode_readdirplusargs(struc struct nfsd3_readdirargs *);int nfs3svc_decode_commitargs (struct svc_rqst *,u32 *,struct nfsd3_commitargs *); +int nfs3svc_decode_getaclargs (struct svc_rqst *,u32 *, +struct nfsd3_getaclargs *); +int nfs3svc_decode_setaclargs (struct svc_rqst *,u32 *, +struct nfsd3_setaclargs *);int nfs3svc_encode_voidres (struct svc_rqst *,u32 *,void *);int nfs3svc_encode_attrstat (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);
@@ -305,11 +331,17 @@ int nfs3svc_encode_pathconfres(struct sv struct nfsd3_pathconfres *);int nfs3svc_encode_commitres (struct svc_rqst *,u32 *,struct nfsd3_commitres *); +int nfs3svc_encode_getaclres (struct svc_rqst *,u32 *, +struct nfsd3_getaclres *); +int nfs3svc_encode_setaclres (struct svc_rqst *,u32 *, +struct nfsd3_attrstat *);int nfs3svc_release_fhandle (struct svc_rqst *,u32 *,struct nfsd3_attrstat *);int nfs3svc_release_fhandle2 (struct svc_rqst *,u32 *,struct nfsd3_fhandle_pair *); +int nfs3svc_release_getacl (struct svc_rqst *rqstp,u32 *p, +struct nfsd3_getaclres *resp);int nfs3svc_encode_entry (struct readdir_cd *,const char *name,int namlen,loff_t offset,ino_t ino,unsigned int );
include/linux/sunrpc/svc.h +21 -0
@@ -185,6 +185,27 @@ xdr_ressize_check(struct svc_rqst *rqstpreturn vec->iov_len <=PAGE_SIZE ; } +#if 0 +static inline struct page * +svc_take_arg_page (struct svc_rqst *rqstp) +{ +if (rqstp->rq_arghi <= rqstp->rq_argused) +return NULL ; +return rqstp->rq_argpages[rqstp->rq_argused++]; +} +#endif + +static inline struct page * +svc_take_res_page (struct svc_rqst *rqstp) +{ +if (rqstp->rq_arghi <= rqstp->rq_argused) +return NULL ; + rqstp->rq_arghi--; + rqstp->rq_respages[rqstp->rq_resused] = + rqstp->rq_argpages[rqstp->rq_arghi]; +return rqstp->rq_respages[rqstp->rq_resused++]; +} +static inline int svc_take_page (struct svc_rqst *rqstp) {if (rqstp->rq_arghi <= rqstp->rq_argused)
PATCH v2 11/16 Solaris nfsacl workaround
In reply to Andreas GruenbacherIf the nfs_acl program is available, Solaris clients expect both version 2 and version 3 to be available; RPC_PROG_MISMATCH leads to a mount failure. Fake RPC_PROG_UNAVAIL when asked for nfs_acl version 2.
Trond has rejected this patch. I'm not sure how to deal with it in a truly clean way, so probably I won't care and still use this as a vendor patch.
net/sunrpc/svc.c +7 -0
@@ -455,6 +455,13 @@ err_bad_prog: goto sendit; err_bad_vers: +if (prog ==100227 && vers ==2 ) { +/* If the nfs_acl program is available, Solaris clients expect +both version 2 and version 3 to be available; +RPC_PROG_MISMATCH leads to a mount failure. Fake +RPC_PROG_UNAVAIL when asked for nfs_acl version 2. */ + goto err_bad_prog; + }#ifdef RPC_PARANOIA printk ("svc: unknown version (%d)\n" , vers);#endif
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 12/16 nfs mknod cleanup
In reply to Andreas GruenbacherTrond Myklebust <[email protected]> wrote:
[...] How about if we change the interfaces for NFS_PROTO()->mknod(), and mkdir, so that they take a dentry argument instead of the struct qstr, and then have them instantiate the dentry? The appended (untested) patch tries to do this for mknod()...
fs/nfs/nfs3proc.c +13 -10
@@ -639,23 +639,24 @@ nfs3_proc_readdir(struct dentry *dentry, }static int -nfs3_proc_mknod (struct inode *dir,struct qstr *name,struct iattr *sattr, -dev_t rdev,struct nfs_fh *fh,struct nfs_fattr *fattr) +nfs3_proc_mknod (struct inode *dir,struct dentry *dentry,struct iattr *sattr, +dev_t rdev) { -struct nfs_fattr dir_attr; +struct nfs_fh fh; +struct nfs_fattr fattr, dir_attr;struct nfs3_mknodargs arg = { .fh =NFS_FH (dir), - .name = name->name, - .len = name->len, + .name = dentry->d_name.name, + .len = dentry->d_name.len, .sattr = sattr, .rdev = rdev };struct nfs3_diropres res = { .dir_attr = &dir_attr, - .fh = fh, - .fattr = fattr + .fh = &fh, + .fattr = &fattr }; -int status; +int status;switch (sattr->ia_mode &S_IFMT ) {case S_IFBLK : arg.type =NF3BLK ;break ;
@@ -665,12 +666,14 @@ nfs3_proc_mknod(struct inode *dir, strucdefault :return -EINVAL ; } -dprintk ("NFS call mknod %s %u:%u\n" , name->name, +dprintk ("NFS call mknod %s %u:%u\n" , dentry->d_name.name,MAJOR (rdev),MINOR (rdev)); dir_attr.valid =0 ; - fattr->valid =0 ; + fattr.valid =0 ; status =rpc_call (NFS_CLIENT (dir),NFS3PROC_MKNOD , &arg, &res,0 );nfs_refresh_inode (dir, &dir_attr); +if (!status) + status =nfs_instantiate (dentry, &fh, &fattr);dprintk ("NFS reply mknod: %d\n" , status);return status; }
fs/nfs/nfs4proc.c +13 -12
@@ -1630,22 +1630,23 @@ static int nfs4_proc_readdir(struct dentreturn err; } -static int _nfs4_proc_mknod (struct inode *dir,struct qstr *name, -struct iattr *sattr,dev_t rdev,struct nfs_fh *fh, -struct nfs_fattr *fattr) +static int _nfs4_proc_mknod (struct inode *dir,struct dentry *dentry, +struct iattr *sattr,dev_t rdev) {struct nfs_server *server =NFS_SERVER (dir); +struct nfs_fh fh; +struct nfs_fattr fattr;struct nfs4_create_arg arg = { .dir_fh =NFS_FH (dir), .server = server, - .name = name, + .name = &dentry->d_name, .attrs = sattr, .bitmask = server->attr_bitmask, };struct nfs4_create_res res = { .server = server, - .fh = fh, - .fattr = fattr, + .fh = &fh, + .fattr = &fattr, };struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE ],
@@ -1655,7 +1656,7 @@ static int _nfs4_proc_mknod(struct inodeint status;int mode = sattr->ia_mode; - fattr->valid =0 ; + fattr.valid =0 ;BUG_ON (!(sattr->ia_valid &ATTR_MODE ));BUG_ON (!S_ISFIFO (mode) && !S_ISBLK (mode) && !S_ISCHR (mode) && !S_ISSOCK (mode));
@@ -1677,19 +1678,19 @@ static int _nfs4_proc_mknod(struct inode status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 );if (!status)update_changeattr (dir, &res.dir_cinfo); +if (!status) + status =nfs_instantiate (dentry, &fh, &fattr);return status; } -static int nfs4_proc_mknod (struct inode *dir,struct qstr *name, -struct iattr *sattr,dev_t rdev,struct nfs_fh *fh, -struct nfs_fattr *fattr) +static int nfs4_proc_mknod (struct inode *dir,struct dentry *dentry, +struct iattr *sattr,dev_t rdev) {struct nfs4_exception exception = { };int err;do { err =nfs4_handle_exception (NFS_SERVER (dir), -_nfs4_proc_mknod (dir, name, sattr, rdev, - fh, fattr), +_nfs4_proc_mknod (dir, dentry, sattr, rdev), &exception); }while (exception.retry);return err;
fs/nfs/proc.c +14 -10
@@ -248,22 +248,24 @@ nfs_proc_create(struct inode *dir, struc* In NFSv2, mknod is grafted onto the create call. */ static int -nfs_proc_mknod (struct inode *dir,struct qstr *name,struct iattr *sattr, -dev_t rdev,struct nfs_fh *fhandle,struct nfs_fattr *fattr) +nfs_proc_mknod (struct inode *dir,struct dentry *dentry,struct iattr *sattr, +dev_t rdev) { +struct nfs_fh fhandle; +struct nfs_fattr fattr;struct nfs_createargs arg = { .fh =NFS_FH (dir), - .name = name->name, - .len = name->len, + .name = dentry->d_name.name, + .len = dentry->d_name.len, .sattr = sattr };struct nfs_diropok res = { - .fh = fhandle, - .fattr = fattr + .fh = &fhandle, + .fattr = &fattr }; -int status, mode; +int status, mode; -dprintk ("NFS call mknod %s\n" , name->name); +dprintk ("NFS call mknod %s\n" , dentry->d_name.name); mode = sattr->ia_mode;if (S_ISFIFO (mode)) {
@@ -274,14 +276,16 @@ nfs_proc_mknod(struct inode *dir, struct sattr->ia_size =new_encode_dev (rdev);/* get out your barf bag */ } - fattr->valid =0 ; + fattr.valid =0 ; status =rpc_call (NFS_CLIENT (dir),NFSPROC_CREATE , &arg, &res,0 );if (status == -EINVAL &&S_ISFIFO (mode)) { sattr->ia_mode = mode; - fattr->valid =0 ; + fattr.valid =0 ; status =rpc_call (NFS_CLIENT (dir),NFSPROC_CREATE , &arg, &res,0 ); } +if (!status) + status =nfs_instantiate (dentry, &fhandle, &fattr);dprintk ("NFS reply mknod: %d\n" , status);return status; }
fs/nfs/dir.c +5 -10
@@ -938,7 +938,7 @@ static struct dentry *nfs_readdir_lookup/* * Code common to create, mkdir, and mknod. */ -static int nfs_instantiate (struct dentry *dentry,struct nfs_fh *fhandle, +int nfs_instantiate (struct dentry *dentry,struct nfs_fh *fhandle,struct nfs_fattr *fattr) {struct inode *inode;
@@ -1019,9 +1019,7 @@ static int nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) { struct iattr attr; -struct nfs_fattr fattr; -struct nfs_fh fhandle; -int error; +int status;dfprintk (VFS ,"NFS: mknod(%s/%ld, %s\n" , dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
@@ -1034,15 +1032,12 @@ nfs_mknod(struct inode *dir, struct dentlock_kernel ();nfs_begin_data_update (dir); - error =NFS_PROTO (dir)->mknod (dir, &dentry->d_name, &attr, rdev, - &fhandle, &fattr); + status =NFS_PROTO (dir)->mknod (dir, dentry, &attr, rdev);nfs_end_data_update (dir); -if (!error) - error =nfs_instantiate (dentry, &fhandle, &fattr); -else +if (status)d_drop (dentry);unlock_kernel (); -return error; +return status; }/*
include/linux/nfs_xdr.h +2 -2
@@ -698,8 +698,8 @@ struct nfs_rpc_ops {int (*rmdir) (struct inode *,struct qstr *);int (*readdir) (struct dentry *,struct rpc_cred *,u64 ,struct page *,unsigned int ,int ); -int (*mknod) (struct inode *,struct qstr *,struct iattr *, -dev_t ,struct nfs_fh *,struct nfs_fattr *); +int (*mknod) (struct inode *,struct dentry *,struct iattr *, +dev_t );int (*statfs) (struct nfs_server *,struct nfs_fh *,struct nfs_fsstat *); int (*fsinfo) (struct nfs_server *, struct nfs_fh *,
include/linux/nfs_fs.h +2 -0
@@ -345,6 +345,8 @@ extern struct inode_operations nfs_dir_iextern struct file_operations nfs_dir_operations;extern struct dentry_operations nfs_dentry_operations; +extern int nfs_instantiate (struct dentry *dentry,struct nfs_fh *fh,struct nfs_fattr *fattr); +/* * linux/fs/nfs/symlink.c */
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 13/16 nfs mkdir cleanup
In reply to Andreas GruenbacherTrond Myklebust <[email protected]> wrote:
[...] How about if we change the interfaces for NFS_PROTO()->mknod(), and mkdir, so that they take a dentry argument instead of the struct qstr, and then have them instantiate the dentry? The appended (untested) patch tries to do this for mknod()...
fs/nfs/nfs3proc.c +12 -10
@@ -540,28 +540,30 @@ nfs3_proc_symlink(struct inode *dir, str }static int -nfs3_proc_mkdir (struct inode *dir,struct qstr *name,struct iattr *sattr, -struct nfs_fh *fhandle,struct nfs_fattr *fattr) +nfs3_proc_mkdir (struct inode *dir,struct dentry *dentry,struct iattr *sattr) { -struct nfs_fattr dir_attr; +struct nfs_fattr fattr, dir_attr; +struct nfs_fh fh;struct nfs3_mkdirargs arg = { .fh =NFS_FH (dir), - .name = name->name, - .len = name->len, + .name = dentry->d_name.name, + .len = dentry->d_name.len, .sattr = sattr };struct nfs3_diropres res = { .dir_attr = &dir_attr, - .fh = fhandle, - .fattr = fattr + .fh = &fh, + .fattr = &fattr }; -int status; +int status; -dprintk ("NFS call mkdir %s\n" , name->name); +dprintk ("NFS call mkdir %s\n" , dentry->d_name.name); dir_attr.valid =0 ; - fattr->valid =0 ; + fattr.valid =0 ; status =rpc_call (NFS_CLIENT (dir),NFS3PROC_MKDIR , &arg, &res,0 );nfs_refresh_inode (dir, &dir_attr); +if (!status) + status =nfs_instantiate (dentry, &fh, &fattr);dprintk ("NFS reply mkdir: %d\n" , status);return status; }
fs/nfs/nfs4proc.c +15 -14
@@ -1539,49 +1539,50 @@ static int nfs4_proc_symlink(struct inodreturn err; } -static int _nfs4_proc_mkdir (struct inode *dir,struct qstr *name, -struct iattr *sattr,struct nfs_fh *fhandle, -struct nfs_fattr *fattr) +static int _nfs4_proc_mkdir (struct inode *dir,struct dentry *dentry, +struct iattr *sattr) {struct nfs_server *server =NFS_SERVER (dir); +struct nfs_fh fh; +struct nfs_fattr fattr;struct nfs4_create_arg arg = { .dir_fh =NFS_FH (dir), .server = server, - .name = name, + .name = &dentry->d_name, .attrs = sattr, .ftype =NF4DIR , .bitmask = server->attr_bitmask, };struct nfs4_create_res res = { .server = server, - .fh = fhandle, - .fattr = fattr, + .fh = &fh, + .fattr = &fattr, };struct rpc_message msg = { .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_CREATE ], .rpc_argp = &arg, .rpc_resp = &res, }; -int status; +int status; - fattr->valid =0 ; + fattr.valid =0 ; status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); -if (!status) +if (!status) {update_changeattr (dir, &res.dir_cinfo); + status =nfs_instantiate (dentry, &fh, &fattr); + }return status; } -static int nfs4_proc_mkdir (struct inode *dir,struct qstr *name, -struct iattr *sattr,struct nfs_fh *fhandle, -struct nfs_fattr *fattr) +static int nfs4_proc_mkdir (struct inode *dir,struct dentry *dentry, +struct iattr *sattr) {struct nfs4_exception exception = { };int err;do { err =nfs4_handle_exception (NFS_SERVER (dir), -_nfs4_proc_mkdir (dir, name, sattr, - fhandle, fattr), +_nfs4_proc_mkdir (dir, dentry, sattr), &exception); }while (exception.retry);return err;
fs/nfs/proc.c +11 -8
@@ -402,24 +402,27 @@ nfs_proc_symlink(struct inode *dir, stru }static int -nfs_proc_mkdir (struct inode *dir,struct qstr *name,struct iattr *sattr, -struct nfs_fh *fhandle,struct nfs_fattr *fattr) +nfs_proc_mkdir (struct inode *dir,struct dentry *dentry,struct iattr *sattr) { +struct nfs_fh fh; +struct nfs_fattr fattr;struct nfs_createargs arg = { .fh =NFS_FH (dir), - .name = name->name, - .len = name->len, + .name = dentry->d_name.name, + .len = dentry->d_name.len, .sattr = sattr };struct nfs_diropok res = { - .fh = fhandle, - .fattr = fattr + .fh = &fh, + .fattr = &fattr };int status; -dprintk ("NFS call mkdir %s\n" , name->name); - fattr->valid =0 ; +dprintk ("NFS call mkdir %s\n" , dentry->d_name.name); + fattr.valid =0 ; status =rpc_call (NFS_CLIENT (dir),NFSPROC_MKDIR , &arg, &res,0 ); +if (!status) + status =nfs_instantiate (dentry, &fh, &fattr);dprintk ("NFS reply mkdir: %d\n" , status);return status; }
fs/nfs/dir.c +4 -9
@@ -1046,9 +1046,7 @@ nfs_mknod(struct inode *dir, struct dentstatic int nfs_mkdir (struct inode *dir,struct dentry *dentry,int mode) {struct iattr attr; -struct nfs_fattr fattr; -struct nfs_fh fhandle; -int error; +int status;dfprintk (VFS ,"NFS: mkdir(%s/%ld, %s\n" , dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
@@ -1067,15 +1065,12 @@ static int nfs_mkdir(struct inode *dir,d_drop (dentry);#endif nfs_begin_data_update (dir); - error =NFS_PROTO (dir)->mkdir (dir, &dentry->d_name, &attr, &fhandle, - &fattr); + status =NFS_PROTO (dir)->mkdir (dir, dentry, &attr);nfs_end_data_update (dir); -if (!error) - error =nfs_instantiate (dentry, &fhandle, &fattr); -else +if (status)d_drop (dentry);unlock_kernel (); -return error; +return status; }static int nfs_rmdir (struct inode *dir,struct dentry *dentry)
include/linux/nfs_xdr.h +1 -2
@@ -693,8 +693,7 @@ struct nfs_rpc_ops {int (*symlink) (struct inode *,struct qstr *,struct qstr *,struct iattr *,struct nfs_fh *,struct nfs_fattr *); -int (*mkdir) (struct inode *,struct qstr *,struct iattr *, -struct nfs_fh *,struct nfs_fattr *); +int (*mkdir) (struct inode *,struct dentry *,struct iattr *);int (*rmdir) (struct inode *,struct qstr *);int (*readdir) (struct dentry *,struct rpc_cred *,u64 ,struct page *,unsigned int ,int );
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 14/16 Client side of nfsacl
In reply to Andreas GruenbacherThis adds acl support fo nfs clients via the NFSACL protocol extension, by implementing the getxattr, listxattr, setxattr, and removexattr iops for the system.posix_acl_access and system.posix_acl_default attributes. This patch implements a dumb version that uses no caching (and thus adds some overhead). (Another patch in this patchset adds caching as well.)
fs/Kconfig +11 -0
@@ -1362,6 +1362,16 @@ config NFS_V3 If unsure, say Y. +config NFS_ACL + bool "NFS_ACL protocol extension" + depends on NFS_V3 + 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
@@ -1405,6 +1415,7 @@ config NFSD select LOCKD select SUNRPC select EXPORTFS + select NFS_ACL_SUPPORT if NFS_ACL help If you want your Linux box to act as an NFS *server*, so that other computers on your local network which support NFS can access certain
fs/nfs/dir.c +21 -0
@@ -74,6 +74,27 @@ struct inode_operations nfs_dir_inode_op .setattr = nfs_setattr, }; +#ifdef CONFIG_NFS_V3 +struct inode_operations nfs3_dir_inode_operations = { + .create = nfs_create, + .lookup = nfs_lookup, + .link = nfs_link, + .unlink = nfs_unlink, + .symlink = nfs_symlink, + .mkdir = nfs_mkdir, + .rmdir = nfs_rmdir, + .mknod = nfs_mknod, + .rename = nfs_rename, + .permission = nfs_permission, + .getattr = nfs_getattr, + .setattr = nfs_setattr, + .listxattr = nfs_listxattr, + .getxattr = nfs_getxattr, + .setxattr = nfs_setxattr, + .removexattr = nfs_removexattr, +}; +#endif /* CONFIG_NFS_V3 */ +#ifdef CONFIG_NFS_V4 static struct dentry *nfs_atomic_lookup (struct inode *,struct dentry *,struct nameidata *);
fs/nfs/file.c +12 -0
@@ -67,6 +67,18 @@ struct inode_operations nfs_file_inode_o .setattr = nfs_setattr, }; +#ifdef CONFIG_NFS_V3 +struct inode_operations nfs3_file_inode_operations = { + .permission = nfs_permission, + .getattr = nfs_getattr, + .setattr = nfs_setattr, + .listxattr = nfs_listxattr, + .getxattr = nfs_getxattr, + .setxattr = nfs_setxattr, + .removexattr = nfs_removexattr, +}; +#endif /* CONFIG_NFS_v3 */ +/* Hack for future NFS swap support */ #ifndef IS_SWAPFILE # define IS_SWAPFILE (inode) (0)
fs/nfs/inode.c +55 -2
101 lines not on this page · raw message
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 \ delegation.o idmap.o \ callback.o callback_xdr.o callback_proc.o
fs/nfs/nfs3proc.c +218 -2
248 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 new file +114 -0
114 lines not on this page · raw message
include/linux/nfs_fs.h +20 -0
@@ -281,6 +281,8 @@ static inline int nfs_verify_change_attr/* * linux/fs/nfs/inode.c */ +extern struct inode_operations nfs3_special_inode_operations; +extern void nfs_zap_caches (struct inode *);extern struct inode *nfs_fhget (struct super_block *,struct nfs_fh *,struct nfs_fattr *);
@@ -314,6 +316,7 @@ extern u32 root_nfs_parse_addr(char *nam* linux/fs/nfs/file.c */ extern struct inode_operations nfs_file_inode_operations; +extern struct inode_operations nfs3_file_inode_operations;extern struct file_operations nfs_file_operations;extern struct address_space_operations nfs_file_aops;
@@ -329,6 +332,22 @@ static inline struct rpc_cred *nfs_file_ }/* +* 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 + +/* * linux/fs/nfs/direct.c */ extern ssize_t nfs_direct_IO(int, struct kiocb *, const struct iovec *, loff_t,
@@ -342,6 +361,7 @@ extern ssize_t nfs_file_direct_write(str* linux/fs/nfs/dir.c */ extern struct inode_operations nfs_dir_inode_operations; +extern struct inode_operations nfs3_dir_inode_operations;extern struct file_operations nfs_dir_operations;extern struct dentry_operations nfs_dentry_operations;
include/linux/nfs_fs_sb.h +3 -0
@@ -10,6 +10,9 @@struct nfs_server {struct rpc_clnt * client;/* RPC client handle */ struct rpc_clnt * client_sys;/* 2nd handle for FSINFO */ +#ifdef CONFIG_NFS_ACL +struct rpc_clnt * client_acl;/* ACL RPC client handle */ +#endif /* CONFIG_NFS_ACL */ struct nfs_rpc_ops * rpc_ops;/* NFS protocol vector */ struct backing_dev_info backing_dev_info;int flags;/* various flags */
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 +34 -0
@@ -2,6 +2,7 @@#define _LINUX_NFS_XDR_H#include <linux/sunrpc/xprt.h> +#include <linux/nfsacl.h> struct nfs4_fsid {__u64 major;
@@ -354,6 +355,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;
@@ -477,6 +492,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 ;
@@ -665,7 +689,9 @@ struct nfs_access_entry;struct nfs_rpc_ops {int version;/* Protocol version */ struct dentry_operations *dentry_ops; +struct inode_operations *file_inode_ops;struct inode_operations *dir_inode_ops; +struct inode_operations *special_inode_ops;int (*getroot) (struct nfs_server *,struct nfs_fh *,struct nfs_fsinfo *);
@@ -712,6 +738,11 @@ struct nfs_rpc_ops {int (*file_open) (struct inode *,struct file *);int (*file_release) (struct inode *,struct file *);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 (*setacls)(struct inode *,struct posix_acl *,struct posix_acl *); +#endif /* CONFIG_NFS_ACL */ };/*
@@ -733,4 +764,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
fs/nfs/nfs4proc.c +1 -0
@@ -2579,6 +2579,7 @@ nfs4_proc_lock(struct file *filp, int cmstruct nfs_rpc_ops nfs_v4_clientops = { .version =4 ,/* protocol version */ .dentry_ops = &nfs4_dentry_operations, + .file_inode_ops = &nfs_file_inode_operations, .dir_inode_ops = &nfs4_dir_inode_operations, .getroot = nfs4_proc_get_root, .getattr = nfs4_proc_getattr,
fs/nfs/proc.c +1 -0
@@ -626,6 +626,7 @@ nfs_proc_lock(struct file *filp, int cmdstruct nfs_rpc_ops nfs_v2_clientops = { .version =2 ,/* protocol version */ .dentry_ops = &nfs_dentry_operations, + .file_inode_ops = &nfs_file_inode_operations, .dir_inode_ops = &nfs_dir_inode_operations, .getroot = nfs_proc_get_root, .getattr = nfs_proc_getattr,
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
PATCH v2 15/16 ACL umask handling workaround in nfs client
In reply to Andreas GruenbacherNFSv3 has no concept of a umask on the server side: The client applies the umask locally, and sends the effective permissions to the server. This behavior is wrong when files are created in a directory that has a default ACL. In this case, the umask is supposed to be ignored, and only the default ACL determines the file's effective permissions.
Usually its the server's task to conditionally apply the umask. But since the server knows nothing about the umask, we have to do it on the client side. This patch tries to fetch the parent directory's default ACL before creating a new file, computes the appropriate create mode to send to the server, and finally sets the new file's access and default acl appropriately.
Many thanks to Buck Huppmann <[email protected]> for sending the initial version of this patch, as well as for arguing why we need this change.
fs/nfs/nfs3proc.c +51 -3
@@ -292,6 +292,38 @@ static int nfs3_proc_commit(struct nfs_wreturn status; } +static int nfs3_set_default_acl (struct inode *dir,struct inode *inode, +mode_t mode) +{ +#ifdef CONFIG_NFS_ACL +struct posix_acl *dfacl, *acl; +int error =0 ; + + dfacl =NFS_PROTO (dir)->getacl (dir,ACL_TYPE_DEFAULT ); +if (IS_ERR (dfacl)) { + error =PTR_ERR (dfacl); +return (error == -EOPNOTSUPP ) ?0 : error; + } +if (!dfacl) +return 0 ; + acl =posix_acl_clone (dfacl,GFP_KERNEL ); + error = -ENOMEM ; +if (!acl) + goto out; + error =posix_acl_create_masq (acl, &mode); +if (error <0 ) + goto out; + error =NFS_PROTO (inode)->setacls (inode, acl,S_ISDIR (inode->i_mode) ? + dfacl :NULL ); +out: +posix_acl_release (acl); +posix_acl_release (dfacl); +return error; +#else +return 0 ; +#endif +} +/* * Create a regular file. * For now, we don't implement O_EXCL.
@@ -314,8 +346,12 @@ nfs3_proc_create(struct inode *dir, stru .fh = &fhandle, .fattr = &fattr }; +mode_t mode;int status; + mode = sattr->ia_mode; + sattr->ia_mode &= ~current->fs->umask; +dprintk ("NFS call create %s\n" , dentry->d_name.name); arg.createmode =NFS3_CREATE_UNCHECKED ;if (flags &O_EXCL ) {
@@ -350,7 +386,6 @@ again: exit:dprintk ("NFS reply create: %d\n" , status); -if (status !=0 ) goto out;if (fhandle.size ==0 || !(fattr.valid &NFS_ATTR_FATTR )) {
@@ -384,9 +419,10 @@ exit:if (status ==0 ) {struct inode *inode; inode =nfs_fhget (dir->i_sb, &fhandle, &fattr); -if (inode) -return inode; status = -ENOMEM ; +if (!inode) + goto out; + status =nfs3_set_default_acl (dir, inode, mode); } out:return ERR_PTR (status);
@@ -556,8 +592,12 @@ nfs3_proc_mkdir(struct inode *dir, struc .fh = &fh, .fattr = &fattr }; +mode_t mode;int status; + mode = sattr->ia_mode; + sattr->ia_mode &= ~current->fs->umask; +dprintk ("NFS call mkdir %s\n" , dentry->d_name.name); dir_attr.valid =0 ; fattr.valid =0 ;
@@ -566,6 +606,8 @@ nfs3_proc_mkdir(struct inode *dir, strucif (!status) status =nfs_instantiate (dentry, &fh, &fattr);dprintk ("NFS reply mkdir: %d\n" , status); +if (!status) + status =nfs3_set_default_acl (dir, dentry->d_inode, mode);return status; }
@@ -659,6 +701,7 @@ nfs3_proc_mknod(struct inode *dir, struc .fh = &fh, .fattr = &fattr }; +mode_t mode;int status;switch (sattr->ia_mode &S_IFMT ) {
@@ -669,6 +712,9 @@ nfs3_proc_mknod(struct inode *dir, strucdefault :return -EINVAL ; } + mode = sattr->ia_mode; + sattr->ia_mode &= ~current->fs->umask; +dprintk ("NFS call mknod %s %u:%u\n" , dentry->d_name.name,MAJOR (rdev),MINOR (rdev)); dir_attr.valid =0 ;
@@ -678,6 +724,8 @@ nfs3_proc_mknod(struct inode *dir, strucif (!status) status =nfs_instantiate (dentry, &fh, &fattr);dprintk ("NFS reply mknod: %d\n" , status); +if (!status) + status =nfs3_set_default_acl (dir, dentry->d_inode, mode);return status; }
fs/nfs/inode.c +2 -0
@@ -485,6 +485,8 @@ nfs_fill_super(struct super_block *sb, s server->client_acl = clnt;/* Initially assume the nfsacl program is supported */ server->flags |=NFSACL ; +/* The nfs client applies the umask itself when needed. */ + sb->s_flags |= MS_POSIXACL; }#endif if (server->flags &NFS_MOUNT_VER3 ) {
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
Re: [nfsacl v2 15/16] ACL umask handling workaround in nfs client
Aurélien Francillon <[email protected]> found a bug in this patch. The delta is:
fs/nfs/nfs3proc.c +3 -0
@@ -423,6 +423,9 @@ exit:if (!inode) goto out; status =nfs3_set_default_acl (dir, inode, mode); +if (status) + goto out; +return inode; } out:return ERR_PTR (status);
Please find the fixed patch attached.
Regards,
Signature · 2 lines
Andreas Gruenbacher <[email protected]> SUSE Labs, SUSE LINUX GMBH
NFSv3 has no concept of a umask on the server side: The client applies the umask locally, and sends the effective permissions to the server. This behavior is wrong when files are created in a directory that has a default ACL. In this case, the umask is supposed to be ignored, and only the default ACL determines the file's effective permissions.
Usually its the server's task to conditionally apply the umask. But since the server knows nothing about the umask, we have to do it on the client side. This patch tries to fetch the parent directory's default ACL before creating a new file, computes the appropriate create mode to send to the server, and finally sets the new file's access and default acl appropriately.
Many thanks to Buck Huppmann <[email protected]> for sending the initial version of this patch, as well as for arguing why we need this change.
fs/nfs/nfs3proc.c +54 -3
116 lines not on this page · raw message
fs/nfs/inode.c +2 -0
@@ -485,6 +485,8 @@ nfs_fill_super(struct super_block *sb, s server->client_acl = clnt;/* Initially assume the nfsacl program is supported */ server->flags |=NFSACL ; +/* The nfs client applies the umask itself when needed. */ + sb->s_flags |= MS_POSIXACL; }#endif if (server->flags &NFS_MOUNT_VER3 ) {
PATCH v2 16/16 Cache acls on the nfs client side
In reply to Andreas GruenbacherAttach acls to inodes in the icache to avoid unnecessary GETACL RPC round-trips. As long as the client doesn't retrieve any acls itself, only the default acls of exiting directories and the default and access acls of new directories will end up in the cache, which preserves some memory compared to always caching the access and default acl of all files.
fs/nfs/inode.c +100 -2
@@ -64,6 +64,19 @@ static void nfs_umount_begin(struct supestatic int nfs_statfs (struct super_block *,struct kstatfs *);static int nfs_show_options (struct seq_file *,struct vfsmount *); +#ifdef CONFIG_NFS_ACL +static void nfs_forget_cached_acls (struct inode *); +static void __nfs_forget_cached_acls (struct nfs_inode *nfsi); +#else +static inline void nfs_forget_cached_acls (struct inode *inode) +{ +} + +static inline void __nfs_forget_cached_acls (struct nfs_inode *nfsi) +{ +} +#endif +static struct super_operations nfs_sops = { .alloc_inode = nfs_alloc_inode, .destroy_inode = nfs_destroy_inode,
@@ -619,6 +632,7 @@ nfs_zap_caches(struct inode *inode) nfsi->flags |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_DATA |NFS_INO_INVALID_ACCESS ; else nfsi->flags |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ACCESS; +nfs_forget_cached_acls (inode); }/*
@@ -1161,6 +1175,81 @@ void nfs_end_data_update_defer(struct in } } +#ifdef CONFIG_NFS_ACL +static void __nfs_forget_cached_acls (struct nfs_inode *nfsi) +{ +if (nfsi->acl_access !=ERR_PTR (-EAGAIN )) { +posix_acl_release (nfsi->acl_access); + nfsi->acl_access =ERR_PTR (-EAGAIN ); + } +if (nfsi->acl_default !=ERR_PTR (-EAGAIN )) { +posix_acl_release (nfsi->acl_default); + nfsi->acl_default =ERR_PTR (-EAGAIN ); + } +} +#endif /* CONFIG_NFS_ACL */ + +#ifdef CONFIG_NFS_ACL +static void nfs_forget_cached_acls (struct inode *inode) +{ +dprintk ("NFS: nfs_forget_cached_acls(%s/%ld)\n" , inode->i_sb->s_id, + inode->i_ino); +spin_lock (&inode->i_lock); +__nfs_forget_cached_acls (NFS_I (inode)); +spin_unlock (&inode->i_lock); +} +#endif + +#ifdef CONFIG_NFS_ACL +struct posix_acl *nfs_get_cached_acl (struct inode *inode,int type) +{ +struct nfs_inode *nfsi =NFS_I (inode); +struct posix_acl *acl =ERR_PTR (-EAGAIN ); + +spin_lock (&inode->i_lock); +if (time_after (jiffies, nfsi->acl_timestamp + nfsi->attrtimeo)) { +__nfs_forget_cached_acls (nfsi); + nfsi->acl_timestamp = jiffies; + }else switch (type) { +case ACL_TYPE_ACCESS : + acl = nfsi->acl_access; +break ; + +case ACL_TYPE_DEFAULT : + acl = nfsi->acl_default; +break ; + +default : +return ERR_PTR (-EINVAL ); + } +if (acl ==ERR_PTR (-EAGAIN )) + acl =ERR_PTR (-EAGAIN ); +else + acl =posix_acl_dup (acl); +spin_unlock (&inode->i_lock); +dprintk ("NFS: nfs_get_cached_acl(%s/%ld, %d) = %p\n" , inode->i_sb->s_id, + inode->i_ino, type, acl); +return acl; +} +#endif /* CONFIG_NFS_ACL */ + +#ifdef CONFIG_NFS_ACL +void nfs_cache_acls (struct inode *inode,struct posix_acl *acl, +struct posix_acl *dfacl) +{ +struct nfs_inode *nfsi =NFS_I (inode); + +dprintk ("nfs_cache_acls(%s/%ld, %p, %p)\n" , inode->i_sb->s_id, + inode->i_ino, acl, dfacl); +spin_lock (&inode->i_lock); +__nfs_forget_cached_acls (NFS_I (inode)); + nfsi->acl_access =posix_acl_dup (acl); + nfsi->acl_default =posix_acl_dup (dfacl); + nfsi->acl_timestamp = jiffies; +spin_unlock (&inode->i_lock); +} +#endif /* CONFIG_NFS_ACL */ +/** * nfs_refresh_inode - verify consistency of the inode attribute cache * @inode - pointer to inode
@@ -1221,8 +1310,10 @@ int nfs_refresh_inode(struct inode *inod/* Have any file permissions changed? */ if ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO ) || inode->i_uid != fattr->uid - || inode->i_gid != fattr->gid) + || inode->i_gid != fattr->gid) { nfsi->flags |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS ; +nfs_forget_cached_acls (inode); + }/* Has the link count changed? */ if (inode->i_nlink != fattr->nlink)
@@ -1339,8 +1430,10 @@ static int nfs_update_inode(struct inodeif ((inode->i_mode &S_IALLUGO ) != (fattr->mode &S_IALLUGO ) || inode->i_uid != fattr->uid || - inode->i_gid != fattr->gid) + inode->i_gid != fattr->gid) { invalid |=NFS_INO_INVALID_ATTR |NFS_INO_INVALID_ACCESS ; +nfs_forget_cached_acls (inode); + } inode->i_mode = fattr->mode; inode->i_nlink = fattr->nlink;
@@ -1912,6 +2005,7 @@ static struct inode *nfs_alloc_inode(strstatic void nfs_destroy_inode (struct inode *inode) { +__nfs_forget_cached_acls (NFS_I (inode));kmem_cache_free (nfs_inode_cachep,NFS_I (inode)); }
@@ -1932,6 +2026,10 @@ static void init_once(void * foo, kmem_c nfsi->ncommit =0 ; nfsi->npages =0 ;init_waitqueue_head (&nfsi->nfs_i_wait); +#ifdef CONFIG_NFS_ACL + nfsi->acl_access =ERR_PTR (-EAGAIN ); + nfsi->acl_default =ERR_PTR (-EAGAIN ); +#endif nfs4_init_once (nfsi); } }
fs/nfs/nfs3proc.c +20 -15
@@ -782,26 +782,29 @@ nfs3_proc_getacl(struct inode *inode, instruct nfs3_getaclres res = { .fattr = &fattr, }; -struct posix_acl *acl =NULL ; +struct posix_acl *acl;int status, count;if (!(server->flags &NFSACL ) || (server->flags &NFS_MOUNT_NOACL ))return ERR_PTR (-EOPNOTSUPP ); -switch (type) { -case ACL_TYPE_ACCESS : - args.mask =NFS3_ACLCNT |NFS3_ACL ; -break ; - -case ACL_TYPE_DEFAULT : -if (!S_ISDIR (inode->i_mode)) -return NULL ; - args.mask =NFS3_DFACLCNT |NFS3_DFACL ; -break ; - -default : -return ERR_PTR (-EINVAL ); - } + acl =nfs_get_cached_acl (inode, type); +if (acl !=ERR_PTR (-EAGAIN )) +return acl; + acl =NULL ; + +/* +* Only get the access acl when explicitly requested: We don't +* need it for access decisions, and only some applications use +* it. Applications which request the access acl first are not +* penalized from this optimization. +*/ +if (type ==ACL_TYPE_ACCESS ) + args.mask |=NFS3_ACLCNT |NFS3_ACL ; +if (S_ISDIR (inode->i_mode)) + args.mask |=NFS3_DFACLCNT |NFS3_DFACL ; +if (!args.mask) +return NULL ; args.fh =NFS_FH (inode);dprintk ("NFS call getacl\n" );
@@ -834,6 +837,7 @@ nfs3_proc_getacl(struct inode *inode, in res.acl_access =NULL ; } } +nfs_cache_acls (inode, res.acl_access, res.acl_default);switch (type) {case ACL_TYPE_ACCESS :
@@ -925,6 +929,7 @@ nfs3_proc_setacls(struct inode *inode, s acl =NULL ; } } +nfs_cache_acls (inode, acl, dfacl); status =nfs_refresh_inode (inode, &fattr); }
include/linux/nfs_fs.h +9 -0
@@ -104,6 +104,8 @@ struct nfs_open_context {*/ struct nfs_delegation ; +struct posix_acl ; +/* * nfs fs inode data in memory */
@@ -158,6 +160,11 @@ struct nfs_inode {atomic_t data_updates;struct nfs_access_entry cache_access; +#ifdef CONFIG_NFS_ACL +unsigned long acl_timestamp; +struct posix_acl *acl_access; +struct posix_acl *acl_default; +#endif /* * This is the cookie verifier used for NFSv3 readdir
@@ -286,6 +293,8 @@ extern struct inode_operations nfs3_specextern void nfs_zap_caches (struct inode *);extern struct inode *nfs_fhget (struct super_block *,struct nfs_fh *,struct nfs_fattr *); +extern struct posix_acl *nfs_get_cached_acl (struct inode *,int ); +extern void nfs_cache_acls (struct inode *,struct posix_acl *,struct posix_acl *);extern int nfs_refresh_inode (struct inode *,struct nfs_fattr *);extern int nfs_getattr (struct vfsmount *,struct dentry *,struct kstat *);extern int nfs_permission (struct inode *,int ,struct nameidata *);
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX PRODUCTS GMBH