Whamcloud - gitweb
b=17445
authoryury <yury>
Fri, 7 Nov 2008 15:14:29 +0000 (15:14 +0000)
committeryury <yury>
Fri, 7 Nov 2008 15:14:29 +0000 (15:14 +0000)
r=tappro,johann

- proper locking in rq pool freeing time

lustre/ldlm/ldlm_lib.c
lustre/mdc/mdc_request.c
lustre/osc/osc_request.c
lustre/ptlrpc/client.c

index 5e3e9d6..3431f63 100644 (file)
@@ -518,7 +518,10 @@ int client_disconnect_export(struct obd_export *exp)
          * in obd_namespace. bug 14260 */
         obd->obd_namespace = NULL;
 
-        ptlrpc_free_rq_pool(imp->imp_rq_pool);
+        if (imp->imp_rq_pool) {
+                ptlrpc_free_rq_pool(imp->imp_rq_pool);
+                imp->imp_rq_pool = NULL;
+        }
         destroy_import(imp);
         cli->cl_import = NULL;
 
index e5b01f0..75bc4b6 100644 (file)
@@ -1610,11 +1610,12 @@ static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                    client import will not have been cleaned. */
                 if (obd->u.cli.cl_import) {
                         struct obd_import *imp;
+                        down_write(&obd->u.cli.cl_sem);
                         imp = obd->u.cli.cl_import;
                         CERROR("client import never connected\n");
                         ptlrpc_invalidate_import(imp);
-                        ptlrpc_free_rq_pool(imp->imp_rq_pool);
                         class_destroy_import(imp);
+                        up_write(&obd->u.cli.cl_sem);
                         obd->u.cli.cl_import = NULL;
                 }
                 rc = obd_llog_finish(obd, 0);
index a00185f..299b3c7 100644 (file)
@@ -4091,12 +4091,17 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
                    client import will not have been cleaned. */
                 if (obd->u.cli.cl_import) {
                         struct obd_import *imp;
+                        down_write(&obd->u.cli.cl_sem);
                         imp = obd->u.cli.cl_import;
                         CDEBUG(D_CONFIG, "%s: client import never connected\n",
                                obd->obd_name);
                         ptlrpc_invalidate_import(imp);
-                        ptlrpc_free_rq_pool(imp->imp_rq_pool);
+                        if (imp->imp_rq_pool) {
+                                ptlrpc_free_rq_pool(imp->imp_rq_pool);
+                                imp->imp_rq_pool = NULL;
+                        }
                         class_destroy_import(imp);
+                        up_write(&obd->u.cli.cl_sem);
                         obd->u.cli.cl_import = NULL;
                 }
                 rc = obd_llog_finish(obd, 0);
index 69259bb..4ff4665 100644 (file)
@@ -356,9 +356,9 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
         struct list_head *l, *tmp;
         struct ptlrpc_request *req;
 
-        if (!pool)
-                return;
+        LASSERT(pool != NULL);
 
+        spin_lock(&pool->prp_lock);
         list_for_each_safe(l, tmp, &pool->prp_req_list) {
                 req = list_entry(l, struct ptlrpc_request, rq_list);
                 list_del(&req->rq_list);
@@ -367,6 +367,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
                 OBD_FREE(req->rq_reqbuf, pool->prp_rq_size);
                 OBD_FREE(req, sizeof(*req));
         }
+        spin_unlock(&pool->prp_lock);
         OBD_FREE(pool, sizeof(*pool));
 }