From: wang di Date: Sun, 26 Jul 2015 14:42:36 +0000 (-0700) Subject: LU-6916 target: fix ted_lcd_lock init X-Git-Tag: 2.7.58~41 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=96a352c9ddeafe139097762211c7f64086016717;p=fs%2Flustre-release.git LU-6916 target: fix ted_lcd_lock init Move ted_lcd_lock init from tgt_client_new() to tgt_client_alloc(), otherwise if error happens in client_new_export(), the error handler path will cause panic like this <1>BUG: unable to handle kernel NULL pointer dereference at (null) <1>IP: [] __list_add+0x26/0xa0 <4> [] __mutex_lock_slowpath+0xcf/0x180 <4> [] ? cfs_hash_putref+0x2e7/0x480 [libcfs] <4> [] mutex_lock+0x2b/0x50 <4> [] tgt_client_free+0x62/0x610 [ptlrpc] <4> [] mdt_destroy_export+0x74/0x220 [mdt] <4> [] class_new_export+0x315/0x9c0 [obdclass] <4> [] class_connect+0xae/0x250 [obdclass] <4> [] mdt_obd_connect+0xb1/0x720 [mdt] <4> [] target_handle_connect+0xe58/0x2d30 [ptlrpc] <4> [] ? string+0x40/0x100 <4> [] tgt_request_handle+0x5b2/0x1230 [ptlrpc] <4> [] ptlrpc_main+0xe41/0x1920 [ptlrpc] <4> [] ? ptlrpc_main+0x0/0x1920 [ptlrpc] <4> [] kthread+0x96/0xa0 <4> [] child_rip+0xa/0x20 <4> [] ? kthread+0x0/0xa0 <4> [] ? child_rip+0x0/0x20 Signed-off-by: wang di Change-Id: If09c019384f53a63107aeaa293ef93d6415f81b5 Reviewed-on: http://review.whamcloud.com/15770 Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Mike Pershin Reviewed-by: Oleg Drokin --- diff --git a/lustre/target/tgt_lastrcvd.c b/lustre/target/tgt_lastrcvd.c index 558ee6b..4b5041a 100644 --- a/lustre/target/tgt_lastrcvd.c +++ b/lustre/target/tgt_lastrcvd.c @@ -383,6 +383,7 @@ int tgt_client_alloc(struct obd_export *exp) /* Mark that slot is not yet valid, 0 doesn't work here */ exp->exp_target_data.ted_lr_idx = -1; INIT_LIST_HEAD(&exp->exp_target_data.ted_reply_list); + mutex_init(&exp->exp_target_data.ted_lcd_lock); RETURN(0); } EXPORT_SYMBOL(tgt_client_alloc); @@ -886,8 +887,6 @@ int tgt_client_new(const struct lu_env *env, struct obd_export *exp) if (!strcmp(ted->ted_lcd->lcd_uuid, tgt->lut_obd->obd_uuid.uuid)) RETURN(0); - mutex_init(&ted->ted_lcd_lock); - if (exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) RETURN(0);