From patchwork Mon May 20 12:50:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10951019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9CC717E0 for ; Mon, 20 May 2019 12:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B933128824 for ; Mon, 20 May 2019 12:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE0D828849; Mon, 20 May 2019 12:51:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33D4C2882C for ; Mon, 20 May 2019 12:51:40 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 4BEBB21F447; Mon, 20 May 2019 05:51:31 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6EBC821F1F8 for ; Mon, 20 May 2019 05:51:17 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 5D28D1005193; Mon, 20 May 2019 08:51:13 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 57CC42B7; Mon, 20 May 2019 08:51:13 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 20 May 2019 08:50:49 -0400 Message-Id: <1558356671-29599-8-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1558356671-29599-1-git-send-email-jsimmons@infradead.org> References: <1558356671-29599-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH v2 07/29] lustre: obd: collect all resource releasing for obj_type. X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: NeilBrown Now that obj_type is managed as a kobject, move all the freeing and deregistering into class_sysfs_release(). Only leave type->typ_lu handling since unloading obdecho can trigger an assert. lu_context_key_degister()) ASSERTION( atomic_read(&key->lct_used) >= 1 ) failed: lu_context_key_degister()) LBUG kernel: Pid: 10642, comm: rmmod Call Trace: [] libcfs_call_trace+0x8c/0xc0 [libcfs] [] lbug_with_loc+0x4c/0xa0 [libcfs] [] lu_context_key_degister+0x14c/0x160 [obdclass] [] lu_context_key_degister_many+0x72/0xb0 [obdclass] [] echo_type_fini+0x20/0x30 [obdecho] [] lu_device_type_fini+0x1b/0x20 [obdclass] [] class_sysfs_release+0x3e/0x6b0 [obdclass] [] kobject_release+0x81/0x1b0 [] kobject_put+0x28/0x60 [] class_unregister_type+0x23c/0x550 [obdclass] [] obdecho_exit+0x10/0x9da [obdecho] Reviewed-by: James Simmons Signed-off-by: NeilBrown --- fs/lustre/obdclass/genops.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/lustre/obdclass/genops.c b/fs/lustre/obdclass/genops.c index ccd8a42..2a5ec93 100644 --- a/fs/lustre/obdclass/genops.c +++ b/fs/lustre/obdclass/genops.c @@ -138,6 +138,15 @@ static void class_sysfs_release(struct kobject *kobj) { struct obd_type *type = container_of(kobj, struct obd_type, typ_kobj); + debugfs_remove_recursive(type->typ_debugfs_entry); + + spin_lock(&obd_types_lock); + list_del(&type->typ_chain); + spin_unlock(&obd_types_lock); + + kfree(type->typ_name); + kfree(type->typ_md_ops); + kfree(type->typ_dt_ops); kfree(type); } @@ -167,6 +176,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, if (!type) return -ENOMEM; + INIT_LIST_HEAD(&type->typ_chain); type->typ_kobj.kset = lustre_kset; rc = kobject_init_and_add(&type->typ_kobj, &class_ktype, &lustre_kset->kobj, "%s", name); @@ -205,9 +215,6 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, return 0; failed: - kfree(type->typ_name); - kfree(type->typ_md_ops); - kfree(type->typ_dt_ops); kobject_put(&type->typ_kobj); return rc; @@ -232,17 +239,9 @@ int class_unregister_type(const char *name) return -EBUSY; } - debugfs_remove_recursive(type->typ_debugfs_entry); - if (type->typ_lu) lu_device_type_fini(type->typ_lu); - spin_lock(&obd_types_lock); - list_del(&type->typ_chain); - spin_unlock(&obd_types_lock); - kfree(type->typ_name); - kfree(type->typ_dt_ops); - kfree(type->typ_md_ops); kobject_put(&type->typ_kobj); return 0;