From patchwork Tue Jul 21 00:04:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 6831401 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C2DD29F380 for ; Tue, 21 Jul 2015 00:10:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D73422069D for ; Tue, 21 Jul 2015 00:10:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9CB72064E for ; Tue, 21 Jul 2015 00:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756882AbbGUAKe (ORCPT ); Mon, 20 Jul 2015 20:10:34 -0400 Received: from mga01.intel.com ([192.55.52.88]:15696 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754812AbbGUAKd (ORCPT ); Mon, 20 Jul 2015 20:10:33 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 20 Jul 2015 17:10:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,511,1432623600"; d="scan'208";a="751134301" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.11]) by fmsmga001.fm.intel.com with ESMTP; 20 Jul 2015 17:10:32 -0700 Subject: [PATCH resend] libsas: fix "sysfs group not found" warnings at port teardown time From: Dan Williams To: akpm@linux-foundation.org Cc: Praveen Murali , linux-scsi@vger.kernel.org, JBottomley@odin.com, stable@vger.kernel.org, Hannes Reinecke , hch@lst.de Date: Mon, 20 Jul 2015 20:04:50 -0400 Message-ID: <20150721000032.35782.27427.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-8-g92dd MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Praveen reports: After some debugging this is what I have found sas_phye_loss_of_signal gets triggered on phy_event from mvsas sas_phye_loss_of_signal calls sas_deform_port sas_deform_port posts a DISCE_DESTRUCT event (sas_unregister_domain_devices-> sas_unregister_dev) sas_deform_port calls sas_port_delete sas_port_delete calls sas_port_delete_link sysfs_remove_group: kobject 'port-X:Y' sas_port_delete calls device_del sysfs_remove_group: kobject 'port-X:Y' sas_destruct_devices gets triggered for the destruct event (DISCE_DESTRUCT) sas_destruct_devices calls sas_rphy_delete sas_rphy_delete calls scsi_remove_device scsi_remove_device calls __scsi_remove_device __scsi_remove_device calls bsg_unregister_queue bsg_unregister_queue -> device_unregister -> device_del -> sysfs_remove_group: kobject 'X:0:0:0' Since X:0:0:0 falls under port-X:Y (which got deleted during sas_port_delete), this call results in the warning. All the later warnings in the dmesg output I sent earlier are trying to delete objects under port-X:Y. Since port-X:Y got recursively deleted, all these calls result in warnings. Since, the PHY and DISC events are processed in two different work queues (and one triggers the other), is there any way other than checking if the object exists in sysfs (in device_del) before deleting? WARNING: CPU: 2 PID: 6 at fs/sysfs/group.c:219 device_del+0x40/0x1c0() sysfs group ffffffff818b97e0 not found for kobject '2:0:4:0' [..] CPU: 2 PID: 6 Comm: kworker/u8:0 Tainted: P W O 3.16.7-ckt9-logicube-ng.3 #1 Hardware name: To be filled by O.E.M. To be filled by O.E.M./VT6085, BIOS 4.6.5 01/23/2015 Workqueue: scsi_wq_2 sas_destruct_devices [libsas] 0000000000000009 ffffffff8151cd18 ffff88011b35bcd8 ffffffff810687b7 ffff88011a661400 ffff88011b35bd28 ffff8800c6e5e968 ffff880000028810 ffff8800c89f2c00 ffffffff8106881c ffffffff81733b68 0000000000000028 Call Trace: [] ? dump_stack+0x41/0x51 [] ? warn_slowpath_common+0x77/0x90 [] ? warn_slowpath_fmt+0x4c/0x50 [] ? device_del+0x40/0x1c0 [] ? device_unregister+0x1a/0x70 [] ? bsg_unregister_queue+0x5e/0xb0 [] ? __scsi_remove_device+0xa9/0xd0 [scsi_mod] It appears we've always been double deleting the devices below sas_port, but recent sysfs changes now exposes this problem. Libsas should delete all the devices from rphy down before deleting the parent port. Cc: Reported-by: Praveen Murali Tested-by: Praveen Murali Reviewed-by: Hannes Reinecke Signed-off-by: Dan Williams --- Hi Andrew, Can you take this through -mm. It's been on linux-scsi for a couple months, and Hannes has reviewed it. drivers/scsi/libsas/sas_discover.c | 6 +++--- drivers/scsi/libsas/sas_port.c | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c index 60de66252fa2..a4db770fe8b0 100644 --- a/drivers/scsi/libsas/sas_discover.c +++ b/drivers/scsi/libsas/sas_discover.c @@ -362,11 +362,14 @@ static void sas_destruct_devices(struct work_struct *work) clear_bit(DISCE_DESTRUCT, &port->disc.pending); list_for_each_entry_safe(dev, n, &port->destroy_list, disco_list_node) { + struct sas_port *sas_port = dev_to_sas_port(dev->rphy->dev.parent); + list_del_init(&dev->disco_list_node); sas_remove_children(&dev->rphy->dev); sas_rphy_delete(dev->rphy); sas_unregister_common_dev(port, dev); + sas_port_delete(sas_port); } } @@ -400,9 +403,6 @@ void sas_unregister_domain_devices(struct asd_sas_port *port, int gone) list_for_each_entry_safe(dev, n, &port->disco_list, disco_list_node) sas_unregister_dev(port, dev); - - port->port->rphy = NULL; - } void sas_device_set_phy(struct domain_device *dev, struct sas_port *port) diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c index d3c5297c6c89..9a25ae3a52a4 100644 --- a/drivers/scsi/libsas/sas_port.c +++ b/drivers/scsi/libsas/sas_port.c @@ -219,7 +219,6 @@ void sas_deform_port(struct asd_sas_phy *phy, int gone) if (port->num_phys == 1) { sas_unregister_domain_devices(port, gone); - sas_port_delete(port->port); port->port = NULL; } else { sas_port_delete_phy(port->port, phy->phy);