From 9560e011ef7b8d1538ec48d297813b8d55d2f09b Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 10 Dec 2015 17:34:58 -0700 Subject: [PATCH] LU-7542 obdclass: quiet lockdep recursive lock warning Lockdep complains about potential recursive locking during mount because the client configuration log is holding a lock on the MGC obd_device to prevent it from being torn down, while also getting locks on the MDC and OSC devices as they are instantiated: Lustre: Mounted myth-client ============================================= [ INFO: possible recursive locking detected ] --------------------------------------------- 2 locks held by ll_cfg_requeue/1460: #0: (&cli->cl_sem){.+.+..}, at mgc_requeue_thread+0x27d/0x5d8 [mgc] #1: (&cld->cld_lock){+.+...}, at mgc_process_log+0x88/0xc01 [mgc] CPU: 3 PID: 1460 Comm: ll_cfg_requeue Call Trace: [] dump_stack+0x4f/0x6f [] __lock_acquire+0xc06/0xc74 [] lock_acquire+0x16e/0x194 [] down_read+0x4c/0x61 [] sptlrpc_conf_client_adapt+0x95/0x142 [ptlrpc] [] mdc_set_info_async+0xeb/0x420 [mdc] [] class_notify_sptlrpc_conf+0x2f4/0x347 [obdclass] [] mgc_process_log+0xa31/0xc01 [mgc] [] mgc_requeue_thread+0x31f/0x5d8 [mgc] [] kthread+0xfa/0x102 Add a separate lock class for the MGC callpath, since it will always be held first, and none of the other obd_device locks should ever be held concurrently. Signed-off-by: Andreas Dilger Change-Id: Ic36e64608d12dcd4f5b12056e3e2072ca6500c1e Reviewed-on: http://review.whamcloud.com/17582 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Oleg Drokin --- lustre/include/obd.h | 6 ++++++ lustre/mgc/mgc_request.c | 9 ++++++--- lustre/ptlrpc/sec_config.c | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 385b8e2..b733c58 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -155,6 +155,12 @@ enum { */ #define OBD_MAX_DEFAULT_EA_SIZE 4096 +enum obd_cl_sem_lock_class { + OBD_CLI_SEM_NORMAL, + OBD_CLI_SEM_MGC, + OBD_CLI_SEM_MDCOSC, +}; + struct mdc_rpc_lock; struct obd_import; struct client_obd { diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 0d568d3..450ca24 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -553,10 +553,13 @@ static void do_requeue(struct config_llog_data *cld) LASSERT(atomic_read(&cld->cld_refcount) > 0); - /* Do not run mgc_process_log on a disconnected export or an + /* + * Do not run mgc_process_log on a disconnected export or an * export which is being disconnected. Take the client - * semaphore to make the check non-racy. */ - down_read(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem); + * semaphore to make the check non-racy. + */ + down_read_nested(&cld->cld_mgcexp->exp_obd->u.cli.cl_sem, + OBD_CLI_SEM_MGC); if (cld->cld_mgcexp->exp_obd->u.cli.cl_conn_count != 0) { CDEBUG(D_MGC, "updating log %s\n", cld->cld_logname); rc = mgc_process_log(cld->cld_mgcexp->exp_obd, cld); diff --git a/lustre/ptlrpc/sec_config.c b/lustre/ptlrpc/sec_config.c index e9f429a..fd248df 100644 --- a/lustre/ptlrpc/sec_config.c +++ b/lustre/ptlrpc/sec_config.c @@ -921,8 +921,8 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) == 0); CDEBUG(D_SEC, "obd %s\n", obd->u.cli.cl_target_uuid.uuid); - /* serialize with connect/disconnect import */ - down_read(&obd->u.cli.cl_sem); + /* serialize with connect/disconnect import */ + down_read_nested(&obd->u.cli.cl_sem, OBD_CLI_SEM_MDCOSC); imp = obd->u.cli.cl_import; if (imp) { -- 1.8.3.1