summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rpc/rpc-lib/src/rpcsvc.h1
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c38
-rw-r--r--xlators/storage/posix/src/Makefile.am8
-rw-r--r--xlators/storage/posix/src/posix.c5
4 files changed, 39 insertions, 13 deletions
diff --git a/rpc/rpc-lib/src/rpcsvc.h b/rpc/rpc-lib/src/rpcsvc.h
index 06b0aad222e..10b20af0a88 100644
--- a/rpc/rpc-lib/src/rpcsvc.h
+++ b/rpc/rpc-lib/src/rpcsvc.h
@@ -39,6 +39,7 @@
#include <pthread.h>
#include <sys/uio.h>
#include <inttypes.h>
+#include <rpc/rpc_msg.h>
#include "compat.h"
#ifndef NGRPS
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 69f37d6b370..c73f3df15be 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -3868,9 +3868,10 @@ out:
int
server_readdirp (rpcsvc_request_t *req)
{
- server_state_t *state = NULL;
- call_frame_t *frame = NULL;
- gfs3_readdirp_req args = {0,};
+ server_state_t *state = NULL;
+ call_frame_t *frame = NULL;
+ gfs3_readdirp_req args = {0,};
+ size_t headers_size = 0;
if (!req)
return 0;
@@ -3896,9 +3897,19 @@ server_readdirp (rpcsvc_request_t *req)
goto out;
}
+ /* FIXME: this should go away when variable sized iobufs are introduced
+ * and transport layer can send msgs bigger than current page-size.
+ */
+ headers_size = sizeof (struct rpc_msg) + sizeof (gfs3_readdir_rsp);
+ if ((frame->this->ctx->page_size < args.size)
+ || ((frame->this->ctx->page_size - args.size) < headers_size)) {
+ state->size = frame->this->ctx->page_size - headers_size;
+ } else {
+ state->size = args.size;
+ }
+
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
- state->size = args.size;
state->offset = args.offset;
resolve_and_resume (frame, server_readdirp_resume);
@@ -3909,9 +3920,10 @@ out:
int
server_readdir (rpcsvc_request_t *req)
{
- server_state_t *state = NULL;
- call_frame_t *frame = NULL;
- gfs3_readdir_req args = {0,};
+ server_state_t *state = NULL;
+ call_frame_t *frame = NULL;
+ gfs3_readdir_req args = {0,};
+ size_t headers_size = 0;
if (!req)
return 0;
@@ -3937,9 +3949,19 @@ server_readdir (rpcsvc_request_t *req)
goto out;
}
+ /* FIXME: this should go away when variable sized iobufs are introduced
+ * and transport layer can send msgs bigger than current page-size.
+ */
+ headers_size = sizeof (struct rpc_msg) + sizeof (gfs3_readdir_rsp);
+ if ((frame->this->ctx->page_size < args.size)
+ || ((frame->this->ctx->page_size - args.size) < headers_size)) {
+ state->size = frame->this->ctx->page_size - headers_size;
+ } else {
+ state->size = args.size;
+ }
+
state->resolve.type = RESOLVE_MUST;
state->resolve.fd_no = args.fd;
- state->size = args.size;
state->offset = args.offset;
resolve_and_resume (frame, server_readdir_resume);
diff --git a/xlators/storage/posix/src/Makefile.am b/xlators/storage/posix/src/Makefile.am
index 0fdcfdcecb4..b8d1668aee9 100644
--- a/xlators/storage/posix/src/Makefile.am
+++ b/xlators/storage/posix/src/Makefile.am
@@ -9,10 +9,10 @@ posix_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
noinst_HEADERS = posix.h posix-mem-types.h
-AM_CFLAGS = -fPIC -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS) -Wall \
- -I$(top_srcdir)/libglusterfs/src -shared -nostartfiles \
- -I$(top_srcdir)/contrib/md5 \
- $(GF_CFLAGS)
+AM_CFLAGS = -fPIC -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE \
+ -D$(GF_HOST_OS) -Wall -I$(top_srcdir)/libglusterfs/src -shared \
+ -nostartfiles -I$(top_srcdir)/contrib/md5 -I$(top_srcdir)/rpc/xdr/src \
+ -I$(top_srcdir)/rpc/rpc-lib/src $(GF_CFLAGS)
CLEANFILES =
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 1fd369b8ffe..c75429b0eb5 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -52,6 +52,7 @@
#include "statedump.h"
#include "locking.h"
#include "timer.h"
+#include "glusterfs3-xdr.h"
#undef HAVE_SET_FSID
#ifdef HAVE_SET_FSID
@@ -4016,7 +4017,9 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
&& (!strcmp(entry->d_name, GF_REPLICATE_TRASH_DIR)))
continue;
- this_size = dirent_size (entry);
+ this_size = max (sizeof (gf_dirent_t),
+ sizeof (gfs3_dirplist))
+ + strlen (entry->d_name) + 1;
if (this_size + filled > size) {
seekdir (dir, in_case);