From 5604b35a61e22930873ffc4e9971002f578e7978 Mon Sep 17 00:00:00 2001 From: Sean Finney Date: Tue, 19 Apr 2011 11:04:35 -0400 Subject: nfs-utils: Increase the stdio file buffer size for procfs files Previously, when writing to /proc/net/rpc/*/channel, if a cache line were larger than the default buffer size (likely 1024 bytes), mountd and svcgssd would split writes into a number of buffer-sized writes. Each of these writes would get an EINVAL error back from the kernel procfs handle (it expects line-oriented input and does not account for multiple/split writes), and no cache update would occur. When such behavior occurs, NFS clients depending on mountd to finish the cache operation would block/hang, or receive EPERM, depending on the context of the operation. This is likely to happen if a user is a member of a large (~100-200) number of groups. Instead, every fopen() on the procfs files in question is followed by a call to setvbuf(), using a per-file dedicated buffer of RPC_CHAN_BUF_SIZE length. Really, mountd should not be using stdio-style buffered file operations on files in /proc to begin with. A better solution would be to use internally managed buffers and calls to write() instead of these stdio calls, but that would be a more extensive change; so this is proposed as a quick and not-so-dirty fix in the meantime. Signed-off-by: Sean Finney Signed-off-by: Steve Dickson --- utils/mountd/cache.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'utils/mountd/cache.c') diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index ce93e3c..df6b38f 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -825,6 +825,7 @@ struct { char *cache_name; void (*cache_handle)(FILE *f); FILE *f; + char vbuf[RPC_CHAN_BUF_SIZE]; } cachelist[] = { { "auth.unix.ip", auth_unix_ip, NULL}, { "auth.unix.gid", auth_unix_gid, NULL}, @@ -848,6 +849,10 @@ void cache_open(void) continue; sprintf(path, "/proc/net/rpc/%s/channel", cachelist[i].cache_name); cachelist[i].f = fopen(path, "r+"); + if (cachelist[i].f != NULL) { + setvbuf(cachelist[i].f, cachelist[i].vbuf, _IOLBF, + RPC_CHAN_BUF_SIZE); + } } } -- cgit