Whamcloud - gitweb
LU-2059 mgs: don't fail on missing params log
[fs/lustre-release.git] / lustre / ptlrpc / sec_null.c
index 4c01682..1d02bc5 100644 (file)
@@ -49,7 +49,6 @@
 #include <obd_class.h>
 #include <lustre_net.h>
 #include <lustre_sec.h>
-#include "ptlrpc_internal.h"
 
 static struct ptlrpc_sec_policy null_policy;
 static struct ptlrpc_sec        null_sec;
@@ -239,9 +238,9 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
                         struct ptlrpc_request *req,
                         int segment, int newsize)
 {
+        struct lustre_msg      *newbuf;
         struct lustre_msg      *oldbuf = req->rq_reqmsg;
-        int                     oldsize, newmsg_size;
-       int rc;
+        int                     oldsize, newmsg_size, alloc_size;
 
         LASSERT(req->rq_reqbuf);
         LASSERT(req->rq_reqbuf == req->rq_reqmsg);
@@ -258,10 +257,29 @@ int null_enlarge_reqbuf(struct ptlrpc_sec *sec,
         LASSERT(!req->rq_pool || req->rq_reqbuf_len >= newmsg_size);
 
         if (req->rq_reqbuf_len < newmsg_size) {
-               rc = ptlrpc_enlarge_req_buffer(req, newmsg_size);
-               if (rc != 0)
-                       return rc;
-       }
+                alloc_size = size_roundup_power2(newmsg_size);
+
+                OBD_ALLOC_LARGE(newbuf, alloc_size);
+                if (newbuf == NULL)
+                        return -ENOMEM;
+
+               /* Must lock this, so that otherwise unprotected change of
+                * rq_reqmsg is not racing with parallel processing of
+                * imp_replay_list traversing threads. See LU-3333
+                * This is a bandaid at best, we really need to deal with this
+                * in request enlarging code before unpacking that's already
+                * there */
+               if (req->rq_import)
+                       spin_lock(&req->rq_import->imp_lock);
+                memcpy(newbuf, req->rq_reqbuf, req->rq_reqlen);
+
+                OBD_FREE_LARGE(req->rq_reqbuf, req->rq_reqbuf_len);
+                req->rq_reqbuf = req->rq_reqmsg = newbuf;
+                req->rq_reqbuf_len = alloc_size;
+
+               if (req->rq_import)
+                       spin_unlock(&req->rq_import->imp_lock);
+        }
 
         _sptlrpc_enlarge_msg_inplace(req->rq_reqmsg, segment, newsize);
         req->rq_reqlen = newmsg_size;