Whamcloud - gitweb
b=21804 protect rpc by refcount in ptlrpc_server_handle_req_in()
authorVitaly Fertman <vitaly.fertman@oracle.com>
Tue, 7 Dec 2010 22:00:13 +0000 (01:00 +0300)
committerVitaly Fertman <vitaly.fertman@oracle.com>
Tue, 7 Dec 2010 22:08:07 +0000 (01:08 +0300)
i=johann
i=adilger

ptlrpc_hpreq_init() inserts rpc to the export list and by the time
of ptlrpc_server_request_add() it could be already handled and
released. To not lose request in between, take an extra reference
on the request.

lustre/ptlrpc/service.c

index 3b9faab..cfb798f 100644 (file)
@@ -1477,6 +1477,11 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
         svc->srv_n_queued_reqs--;
         /* Consider this still a "queued" request as far as stats are
            concerned */
+        /* ptlrpc_hpreq_init() inserts it to the export list and by the time
+         * of ptlrpc_server_request_add() it could be already handled and
+         * released. To not lose request in between, take an extra reference
+         * on the request. */
+        ptlrpc_request_addref(req);
         cfs_spin_unlock(&svc->srv_lock);
 
         /* go through security check/transform */
@@ -1586,9 +1591,11 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service *svc)
         if (rc)
                 GOTO(err_req, rc);
         cfs_waitq_signal(&svc->srv_waitq);
+        ptlrpc_server_drop_request(req);
         RETURN(1);
 
 err_req:
+        ptlrpc_server_drop_request(req);
         cfs_spin_lock(&svc->srv_rq_lock);
         svc->srv_n_active_reqs++;
         cfs_spin_unlock(&svc->srv_rq_lock);