From 108339f1543fb006f4ddd16830e7266df0b46723 Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Wed, 24 Aug 2016 19:44:41 -0400 Subject: [PATCH] LU-8500 ldlm: fix export reference problem 1, in client_import_del_conn, the export returned from class_conn2export is not released after using it. 2, in ptlrpc_connect_interpret, the export is not released if the connect_flags isn't compatible. Change-Id: Ie7ef9cb0de2fa1aba71d3981ce47ae87c75e82d8 Signed-off-by: Hongchao Zhang Reviewed-on: http://review.whamcloud.com/22031 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Bobi Jam Reviewed-by: Oleg Drokin --- lustre/ldlm/ldlm_lib.c | 19 +++++++++++-------- lustre/ptlrpc/import.c | 15 ++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index f863f13..e31274b 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -167,14 +167,17 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid) ptlrpc_connection_put(imp->imp_connection); imp->imp_connection = NULL; - dlmexp = class_conn2export(&imp->imp_dlm_handle); - if (dlmexp && dlmexp->exp_connection) { - LASSERT(dlmexp->exp_connection == - imp_conn->oic_conn); - ptlrpc_connection_put(dlmexp->exp_connection); - dlmexp->exp_connection = NULL; - } - } + dlmexp = class_conn2export(&imp->imp_dlm_handle); + if (dlmexp && dlmexp->exp_connection) { + LASSERT(dlmexp->exp_connection == + imp_conn->oic_conn); + ptlrpc_connection_put(dlmexp->exp_connection); + dlmexp->exp_connection = NULL; + } + + if (dlmexp != NULL) + class_export_put(dlmexp); + } list_del(&imp_conn->oic_item); ptlrpc_connection_put(imp_conn->oic_conn); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 54be719..ef0df00 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -1049,6 +1049,14 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, spin_unlock(&imp->imp_lock); + if (!exp) { + /* This could happen if export is cleaned during the + connect attempt */ + CERROR("%s: missing export after connect\n", + imp->imp_obd->obd_name); + GOTO(out, rc = -ENODEV); + } + /* check that server granted subset of flags we asked for. */ if ((ocd->ocd_connect_flags & imp->imp_connect_flags_orig) != ocd->ocd_connect_flags) { @@ -1094,13 +1102,6 @@ static int ptlrpc_connect_interpret(const struct lu_env *env, } } - if (!exp) { - /* This could happen if export is cleaned during the - connect attempt */ - CERROR("%s: missing export after connect\n", - imp->imp_obd->obd_name); - GOTO(out, rc = -ENODEV); - } old_connect_flags = exp_connect_flags(exp); exp->exp_connect_data = *ocd; imp->imp_obd->obd_self_export->exp_connect_data = *ocd; -- 1.8.3.1