From 504ca288d99779812495a91345421ad4ad8f7d95 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Mon, 24 Aug 2015 23:07:34 -0400 Subject: [PATCH] LU-7030 security: put imp_sec after all requests drained off imp_sec should be put after all requests being drained off. Signed-off-by: Niu Yawei Change-Id: I35f572fcc79b2bd1991db14577226a3ea735630d Reviewed-on: http://review.whamcloud.com/16071 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Sebastien Buisson Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/obd_class.h | 1 + lustre/ldlm/ldlm_lib.c | 3 --- lustre/obdclass/genops.c | 6 ++++++ lustre/ptlrpc/ptlrpc_module.c | 1 + lustre/ptlrpc/sec.c | 6 ++---- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 9033e79..be9849d 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1686,6 +1686,7 @@ struct lwp_register_item { * // XXX do not look into _superhack with remaining eye * // XXX if this were any uglier, I'd get my own show on MTV */ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); +extern void (*sptlrpc_sec_put_superhack)(struct obd_import *imp); /* obd_mount.c */ #ifdef HAVE_SERVER_SUPPORT diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 0ded843..dd518e5 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -219,11 +219,8 @@ EXPORT_SYMBOL(client_import_find_conn); void client_destroy_import(struct obd_import *imp) { - /* Drop security policy instance after all RPCs have finished/aborted - * to let all busy contexts be released. */ class_import_get(imp); class_destroy_import(imp); - sptlrpc_import_sec_put(imp); class_import_put(imp); } EXPORT_SYMBOL(client_destroy_import); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 7ca03f0..2cc5e04 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -70,6 +70,8 @@ atomic_t obd_stale_export_num; int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c); EXPORT_SYMBOL(ptlrpc_put_connection_superhack); +void (*sptlrpc_sec_put_superhack)(struct obd_import *imp); +EXPORT_SYMBOL(sptlrpc_sec_put_superhack); /* * support functions: we could use inter-module communication, but this @@ -1025,6 +1027,10 @@ void class_import_put(struct obd_import *imp) if (atomic_dec_and_test(&imp->imp_refcount)) { CDEBUG(D_INFO, "final put import %p\n", imp); + /* Drop security policy instance after all RPCs have + * finished/aborted to let all busy contexts be released. */ + sptlrpc_sec_put_superhack(imp); + obd_zombie_import_add(imp); } diff --git a/lustre/ptlrpc/ptlrpc_module.c b/lustre/ptlrpc/ptlrpc_module.c index d6a58a0..1038b24 100644 --- a/lustre/ptlrpc/ptlrpc_module.c +++ b/lustre/ptlrpc/ptlrpc_module.c @@ -90,6 +90,7 @@ static __init int ptlrpc_init(void) GOTO(err_portals, rc); ptlrpc_put_connection_superhack = ptlrpc_connection_put; + sptlrpc_sec_put_superhack = sptlrpc_import_sec_put; rc = ptlrpc_start_pinger(); if (rc) diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 254aed5..94ae681 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -398,11 +398,9 @@ static int import_sec_validate_get(struct obd_import *imp, } *sec = sptlrpc_import_sec_ref(imp); - /* Only output an error when the import is still active */ if (*sec == NULL) { - if (list_empty(&imp->imp_zombie_chain)) - CERROR("import %p (%s) with no sec\n", - imp, ptlrpc_import_state_name(imp->imp_state)); + CERROR("import %p (%s) with no sec\n", + imp, ptlrpc_import_state_name(imp->imp_state)); return -EACCES; } -- 1.8.3.1