From: Lai Siyao Date: Mon, 19 Mar 2012 08:41:54 +0000 (+0800) Subject: LU-1092 ptlrpc: take export refcount during connect X-Git-Tag: 2.2.51~47 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=893cf2014a38c5bd94890d3522fafe55f024a958 LU-1092 ptlrpc: take export refcount during connect In the process of (re)connect, a refcount of export should be taken, otherwise disconnect of this export may be called, and it will put the last refcount of this export and make access to this export invalid. Signed-off-by: Lai Siyao Change-Id: Iaf27e842ed516b8968c90bfce396609e39f52c85 Reviewed-on: http://review.whamcloud.com/2345 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Mike Pershin Reviewed-by: Liang Zhen Reviewed-by: Oleg Drokin --- diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 0541f7b..6026670 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -857,7 +857,6 @@ int target_handle_connect(struct ptlrpc_request *req) cfs_spin_lock(&export->exp_lock); export->exp_connecting = 1; cfs_spin_unlock(&export->exp_lock); - class_export_put(export); LASSERT(export->exp_obd == target); rc = target_handle_reconnect(&conn, export, &cluuid); @@ -945,8 +944,12 @@ dont_check_exports: rc = obd_connect(req->rq_svc_thread->t_env, &export, target, &cluuid, data, client_nid); - if (rc == 0) + if (rc == 0) { conn.cookie = export->exp_handle.h_cookie; + /* LU-1092 reconnect put export refcount in the + * end, connect needs take one here too. */ + class_export_get(export); + } } } else { rc = obd_reconnect(req->rq_svc_thread->t_env, @@ -1129,6 +1132,8 @@ out: cfs_spin_lock(&export->exp_lock); export->exp_connecting = 0; cfs_spin_unlock(&export->exp_lock); + + class_export_put(export); } if (targref) class_decref(targref, __FUNCTION__, cfs_current());