Patchwork [BUG:1280,09/12] nfsrpc: Introduce THIS-setting support to fix mem-accounting

login
register
Submitter Shehjar Tikoo
Date 2010-08-31 12:20:34
Message ID <1283257237-18659-9-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/4426/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Shehjar Tikoo - 2010-08-31 12:20:34
From: Shehjar Tikoo <shehjart@gluster.com>

Not setting THIS in nfs/rpc has been a blocker for NFS on mainline because
without THIS set correctly to nfsx, mem-accounting goes looking into
translators other than nfsx for nfs memory allocations, resulting in
dereferencing bad addresses.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/lib/src/rpcsvc.c |    2 ++
 xlators/nfs/lib/src/rpcsvc.h |    8 ++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

Patch

diff --git a/xlators/nfs/lib/src/rpcsvc.c b/xlators/nfs/lib/src/rpcsvc.c
index 930634d..4698e2e 100644
--- a/xlators/nfs/lib/src/rpcsvc.c
+++ b/xlators/nfs/lib/src/rpcsvc.c
@@ -1897,6 +1897,7 @@  nfs_rpcsvc_handle_rpc_call (rpcsvc_conn_t *conn)
                 goto err_reply;
 
         if ((actor) && (actor->actor)) {
+                THIS = nfs_rpcsvc_request_actorxl (req);
                 nfs_rpcsvc_conn_ref (conn);
                 ret = actor->actor (req);
         }
@@ -2201,6 +2202,7 @@  nfs_rpcsvc_record_vectored_call_actor (rpcsvc_conn_t *conn)
 
         if (actor->vector_actor) {
                 nfs_rpcsvc_conn_ref (conn);
+                THIS = nfs_rpcsvc_request_actorxl (req);
                 ret = actor->vector_actor (req, rs->vectoriob);
         } else {
                 nfs_rpcsvc_request_seterr (req, PROC_UNAVAIL);
diff --git a/xlators/nfs/lib/src/rpcsvc.h b/xlators/nfs/lib/src/rpcsvc.h
index a56b70d..6d3834c 100644
--- a/xlators/nfs/lib/src/rpcsvc.h
+++ b/xlators/nfs/lib/src/rpcsvc.h
@@ -34,6 +34,7 @@ 
 #include "iobuf.h"
 #include "xdr-rpc.h"
 #include "glusterfs.h"
+#include "xlator.h"
 
 #include <pthread.h>
 #include <sys/uio.h>
@@ -369,6 +370,8 @@  struct rpcsvc_request {
 #define nfs_rpcsvc_request_program(req) ((rpcsvc_program_t *)((req)->conn->program))
 #define nfs_rpcsvc_request_program_private(req) (((rpcsvc_program_t *)((req)->conn->program))->private)
 #define nfs_rpcsvc_request_conn(req)        (req)->conn
+#define nfs_rpcsvc_program_xlator(prg)      ((prg)->actorxl)
+#define nfs_rpcsvc_request_actorxl(rq)      (nfs_rpcsvc_request_program(rq))->actorxl
 #define nfs_rpcsvc_request_accepted(req)    ((req)->rpc_stat == MSG_ACCEPTED)
 #define nfs_rpcsvc_request_accepted_success(req) ((req)->rpc_err == SUCCESS)
 #define nfs_rpcsvc_request_uid(req)         ((req)->uid)
@@ -484,6 +487,11 @@  struct rpc_svc_program {
          * See RFC 1813, Section 5.2.1.
          */
         int                     min_auth;
+
+        /* The translator in whose context the actor must execute. This is
+         * needed to setup THIS for memory accounting to work correctly.
+         */
+        xlator_t                *actorxl;
 };