From patchwork Sun May 6 18:18:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 157140 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B8AF7B6FB7 for ; Mon, 7 May 2012 04:02:48 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754529Ab2EFSC3 (ORCPT ); Sun, 6 May 2012 14:02:29 -0400 Received: from mga03.intel.com ([143.182.124.21]:34037 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754452Ab2EFSCZ (ORCPT ); Sun, 6 May 2012 14:02:25 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 06 May 2012 11:02:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="139523090" Received: from dwillia2-linux.jf.intel.com ([10.23.45.110]) by azsmga001.ch.intel.com with ESMTP; 06 May 2012 11:02:24 -0700 Received: from dwillia2-linux.jf.intel.com (localhost.localdomain [IPv6:::1]) by dwillia2-linux.jf.intel.com (Postfix) with ESMTP id BFB3880010; Sun, 6 May 2012 11:18:17 -0700 (PDT) Subject: [PATCH 04/18] scsi_transport_sas: fix delete vs scan race To: linux-scsi@vger.kernel.org From: Dan Williams Cc: linux-ide@vger.kernel.org Date: Sun, 06 May 2012 11:18:17 -0700 Message-ID: <20120506181817.17912.17194.stgit@dwillia2-linux.jf.intel.com> In-Reply-To: <20120506181611.17912.3798.stgit@dwillia2-linux.jf.intel.com> References: <20120506181611.17912.3798.stgit@dwillia2-linux.jf.intel.com> User-Agent: StGit/0.16-1-g7004 MIME-Version: 1.0 Sender: linux-ide-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org The following crash results from cases where the end_device has been removed before scsi_sysfs_add_sdev has had a chance to run. BUG: unable to handle kernel NULL pointer dereference at 0000000000000098 IP: [] sysfs_create_dir+0x32/0xb6 ... Call Trace: [] kobject_add_internal+0x120/0x1e3 [] ? trace_hardirqs_on+0xd/0xf [] kobject_add_varg+0x41/0x50 [] kobject_add+0x64/0x66 [] device_add+0x12d/0x63a [] ? _raw_spin_unlock_irqrestore+0x47/0x56 [] ? module_refcount+0x89/0xa0 [] scsi_sysfs_add_sdev+0x4e/0x28a [] do_scan_async+0x9c/0x145 ...teach sas_rphy_remove to wait for async scanning to quiesce before removing the end_device. It seems this is a more general problem [1], but this patch only addresses sas transport. [1]: 23edb6e [SCSI] mpt2sas: Do not set sas_device->starget to NULL from the slave_destroy callback when all the LUNS have been deleted Signed-off-by: Dan Williams --- drivers/scsi/scsi_transport_sas.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-ide" 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/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c index f7565fc..47abb90 100644 --- a/drivers/scsi/scsi_transport_sas.c +++ b/drivers/scsi/scsi_transport_sas.c @@ -33,8 +33,9 @@ #include #include -#include #include +#include +#include #include #include @@ -1667,6 +1668,9 @@ sas_rphy_remove(struct sas_rphy *rphy) { struct device *dev = &rphy->dev; + /* prevent device_del() while child device_add() may be in-flight */ + scsi_complete_async_scans(); + switch (rphy->identify.device_type) { case SAS_END_DEVICE: scsi_remove_target(dev);