From patchwork Fri Oct 30 22:08:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 7529471 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 5B02F9F2F7 for ; Fri, 30 Oct 2015 22:08:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A8552077C for ; Fri, 30 Oct 2015 22:08:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E628F2077A for ; Fri, 30 Oct 2015 22:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031208AbbJ3WIS (ORCPT ); Fri, 30 Oct 2015 18:08:18 -0400 Received: from mail-bn1on0090.outbound.protection.outlook.com ([157.56.110.90]:34816 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1030338AbbJ3WIQ (ORCPT ); Fri, 30 Oct 2015 18:08:16 -0400 Received: from BLUPR0201CA0003.namprd02.prod.outlook.com (10.163.116.13) by BN3PR0201MB0980.namprd02.prod.outlook.com (10.161.207.139) with Microsoft SMTP Server (TLS) id 15.1.312.18; Fri, 30 Oct 2015 22:08:14 +0000 Received: from BL2FFO11FD051.protection.gbl (2a01:111:f400:7c09::197) by BLUPR0201CA0003.outlook.office365.com (2a01:111:e400:52e7::13) with Microsoft SMTP Server (TLS) id 15.1.312.18 via Frontend Transport; Fri, 30 Oct 2015 22:08:14 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.172) smtp.mailfrom=sandisk.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.172 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.172; helo=milsmgep11.sandisk.com; Received: from milsmgep11.sandisk.com (63.163.107.172) by BL2FFO11FD051.mail.protection.outlook.com (10.173.161.213) with Microsoft SMTP Server id 15.1.318.9 via Frontend Transport; Fri, 30 Oct 2015 22:08:13 +0000 Received: from MILHUBIP03.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep11.sandisk.com (Symantec Messaging Gateway) with SMTP id A8.EC.04667.C4AE3365; Fri, 30 Oct 2015 15:08:12 -0700 (PDT) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.248.2; Fri, 30 Oct 2015 15:08:13 -0700 X-AuditID: ac160a68-f790b6d00000123b-24-5633ea4c9a86 Received: from [10.60.52.33] ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id C0.AC.03643.C4AE3365; Fri, 30 Oct 2015 15:08:12 -0700 (PDT) Subject: [PATCH 1/2] Separate target visibility from reaped state information To: James Bottomley References: <5633E9F2.5080209@sandisk.com> CC: Johannes Thumshirn , Christoph Hellwig , Dan Williams , "linux-scsi@vger.kernel.org" From: Bart Van Assche Message-ID: <5633EA4C.10608@sandisk.com> Date: Fri, 30 Oct 2015 15:08:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <5633E9F2.5080209@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42JZI8azSNfnlXGYwe13FhbTp15gtFi5+iiT xaXeJawWj7tmsFp0X9/B5sDqsXjPSyaP3Tcb2DxOzvvJ5rH5dLXH501yAaxRXDYpqTmZZalF +nYJXBnfPjWxFzzTqDj+8yNrA+MBxS5GTg4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J+bmbGMGh yxm5g/HpRPNDjEwcnFINjBsNgxZ7BVkeueTcbJR8/mHH/RVPnH9fadii8u3mhLZfckYph959 T5Q1mxIwQX2f2S1m7uoZB3fyLiua+XkrX8Reu0ihXDMXHrfZ6ydGZXzRW9MgHPVnqt+DAymH dqj2bNyglZeygEE2LFHLcOv8Qqfq7VfUZ/FdMX15ItBNVO28/vGHq3/GrlFiKc5INNRiLipO BAChZzT8DQIAAA== X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD051; 1:w4EtLzaVydg8+PS5k4oHF7kLZSlM34QeNuUB90qKmT7TZt5/G2H26R9+pnOt1bSai8g0VHLD+HhcQ8oanvqp+QzOm/PS6wPbp3o0eu+hSwem+/0Ud0fCNUN1D5ymQJhXZfyGkgnmrIcSYtujKYYfWtbVMK1Vr4a5bEF1MdYDjQp21wZF+BkI4bO8RjKF0nPi70NoQRfa7kkEHlTRvzpG4iUGcMBtxxvuUMpj34O6fl3Io+9TFjiHsrlqM1tUf6OHThvIWxJb6TWl9F+4JzFUo3wKrz/CQZ5lPwzYZeNwJ/3BsQMyX+vVvm/TvI1AQSz8TvZzikDm5fBXFD0IqUhiymOePrHICKOlociddundZkAWEVMHszvWiHg7XnIyVl9/Eez6vOgT27gH6tjsHuR74A== X-Forefront-Antispam-Report: CIP:63.163.107.172; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(54356999)(47776003)(5008740100001)(5001960100002)(23676002)(65816999)(76176999)(83506001)(64126003)(230700001)(50986999)(86362001)(87936001)(2950100001)(36756003)(33656002)(92566002)(106466001)(97736004)(19580395003)(11100500001)(77096005)(189998001)(65806001)(19580405001)(81156007)(4001350100001)(5007970100001)(229853001)(110136002)(65956001)(69596002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0201MB0980; H:milsmgep11.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0201MB0980; 2:hUNVcySqzghaq0qBS7M8wpZ5AZnxnWDgEnuZL5Q9hC0+iSG0MVkZbgTzH31E9CCcG7r2q0rHu4W9FEGGm1N82IAAZye7zc0r4RJd3sdKCqV86y6enm8tA4d8KfsGmSXhivlu4SXMt1rThV8k3IxiBII+bOMG56QWiqFJF7TxhQ4=; 3:4gyKx/Uq4MvjFeJlgV8+HDxgM74SZ1VVsN89VMd1iVsiUJPZ1B6K408k8qCmU+ggxu5MNV1/n4tQhOJD5CqVX72oEhECCu2Ksh53WXW7y44CkFQNO2moeBzD4Vk93drkE6mZRLB3j8vwoBNvprloQFmfs0HGL10b/yC7ksmH0WsCrdX0dzCys2SrTL1CgsQr4bYpV8FtL8koX7Qw3mPj8y2TUghsKZ19zeuptBpLmyGUzkh02UXnxyLFZsrLWQfS2moP4YZGMiEE5sLowOL2+w==; 25:dPbBxBssbfGkPzbUqjnwUBQePKakoH8Xej0zM2VnGiQCfbIWDGUTbfwC+5xAe97RK1hyS3BRd0JvsblhoGamUXlq35xUhmiKnXv99IB5yrSmX8+a2xipQForRY2o97KdsqYQjimojHi7o+5Wj3tmsBZVcGM0cXGy1KAtqJZrpF7S26S7m+lUiSqiIsvLxBKBUjvzJucc/1hgroFl+NvqWLpEwfvIg8ducWus79C2yAP5bJmyZJTKmSAa607tn8O1FBxzgFYgvujV+RXHZAdhKg== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501001); SRVR:BN3PR0201MB0980; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0201MB0980; 20:qwMVzihS1OwrcT0BFyj1ryR+LGuQxpWMoPksTBMjPUqs1Kixb5ZrAjiANyDlFrtbBht3wjHOoYjfUH+8Jpf/aVw2dM5FmHKhDprD8GalTLpVTNjkdbKpgMjNv1zB+8U39VE6+Q27VAKxP/H1mGBu9+zHlxkj4qhgeFgcAPVL5BfFSWth8KB3Y2wads4rOci1kw18QXBxxHNriAbATMns4DBzpfVP2zcPBUMGqPyJy+mni//569/6lCi8cQsWkt6g4IccL09p4yKtFqLK8pXLu4a0OxSLEe7YsAczCt4qeqoeXtlnpvJ5Iv2tZ82NzK+GeY01KIptMYRTZqS11dNkHSgQN5LcOBiG/mxKDUDk3uMOJzf3WxP2zjwlrwRgf62RvMwCBWyQa3iMdzy6elIPapN+UJOzPkzsJi0Q7+MYkUoPTPHykKHG073wmxeTFqbTdEDzL4pfzZ9XCOEkB4nbpTnf1h9OnNk0PWAl2PcSU44ooxW9QB4tREwP5Ed8ea2H; 4:pzeVMkpIBiY1WTgyHjyOZQpF072ZoaiKDypsC/2vIrtpbaPhvAuZLne9IAG9zlW0+XotmOvzOzBf4t1eyfseiYgbzeptgLTMNq8my4BSttQYDkgHCnxjmQenohxcJgXBzQTJN69ABf6Sb/PK0EG/QYNwxqqpDgCHU8iQLKcGwGpAoAu1K22Q1HGAlbvTstnfPej5jWO57Yg2Nh8Pn8qssfgJwkSDMwJMMrHcakTVBpiwDCpXz00/jts2WgokXU1iDfhpWRxtGfPeCsvjSwS4M/HxNu445WaQv0u1QMYPF7xHKqEUOlICEi9TR/iDapPCQT4veGr+T6sWGYSeFTYG+1d/vWNvYDXSZyNPo3HnKAVqTuScAvombEH/nuObbX5g X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001); SRVR:BN3PR0201MB0980; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0201MB0980; X-Forefront-PRVS: 07459438AA X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjNQUjAyMDFNQjA5ODA7MjM6dWd0WTB0NXA3ZnpTcTF4dzZ2cExldUwz?= =?utf-8?B?QkNUdHVSZDIzQXQ3RXFTZG1IbVRDdjN6WTZpeHhjTU1JRndUTTI5QzM4SCtS?= =?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CdJO9r SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2015 22:08:13.2485 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.172]; Helo=[milsmgep11.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0201MB0980 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Instead of representing the states "visible in sysfs" and "has been removed from the target list" by a single state variable, use two variables to represent this information. Signed-off-by: Bart Van Assche Cc: Johannes Thumshirn Cc: Christoph Hellwig Cc: Dan Williams Cc: stable Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_scan.c | 31 +++---------------------------- drivers/scsi/scsi_sysfs.c | 7 ++++--- include/scsi/scsi_device.h | 3 ++- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index f9f3f82..80b8c3f 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -314,7 +314,6 @@ static void scsi_target_destroy(struct scsi_target *starget) struct Scsi_Host *shost = dev_to_shost(dev->parent); unsigned long flags; - starget->state = STARGET_DEL; transport_destroy_device(dev); spin_lock_irqsave(shost->host_lock, flags); if (shost->hostt->target_destroy) @@ -379,19 +378,15 @@ static void scsi_target_reap_ref_release(struct kref *kref) struct scsi_target *starget = container_of(kref, struct scsi_target, reap_ref); - /* - * if we get here and the target is still in the CREATED state that - * means it was allocated but never made visible (because a scan - * turned up no LUNs), so don't call device_del() on it. - */ - if (starget->state != STARGET_CREATED) { + if (starget->visible) { + starget->visible = false; transport_remove_device(&starget->dev); device_del(&starget->dev); } scsi_target_destroy(starget); } -static void scsi_target_reap_ref_put(struct scsi_target *starget) +void scsi_target_reap(struct scsi_target *starget) { kref_put(&starget->reap_ref, scsi_target_reap_ref_release); } @@ -437,7 +432,6 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, starget->can_queue = 0; INIT_LIST_HEAD(&starget->siblings); INIT_LIST_HEAD(&starget->devices); - starget->state = STARGET_CREATED; starget->scsi_level = SCSI_2; starget->max_target_blocked = SCSI_DEFAULT_TARGET_BLOCKED; retry: @@ -498,25 +492,6 @@ static struct scsi_target *scsi_alloc_target(struct device *parent, } /** - * scsi_target_reap - check to see if target is in use and destroy if not - * @starget: target to be checked - * - * This is used after removing a LUN or doing a last put of the target - * it checks atomically that nothing is using the target and removes - * it if so. - */ -void scsi_target_reap(struct scsi_target *starget) -{ - /* - * serious problem if this triggers: STARGET_DEL is only set in the if - * the reap_ref drops to zero, so we're trying to do another final put - * on an already released kref - */ - BUG_ON(starget->state == STARGET_DEL); - scsi_target_reap_ref_put(starget); -} - -/** * sanitize_inquiry_string - remove non-graphical chars from an INQUIRY result string * @s: INQUIRY result string to sanitize * @len: length of the string diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index b333389..b9fb61a 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -974,7 +974,7 @@ static int scsi_target_add(struct scsi_target *starget) { int error; - if (starget->state != STARGET_CREATED) + if (starget->visible) return 0; error = device_add(&starget->dev); @@ -983,7 +983,7 @@ static int scsi_target_add(struct scsi_target *starget) return error; } transport_add_device(&starget->dev); - starget->state = STARGET_RUNNING; + starget->visible = true; pm_runtime_set_active(&starget->dev); pm_runtime_enable(&starget->dev); @@ -1166,11 +1166,12 @@ void scsi_remove_target(struct device *dev) */ spin_lock_irqsave(shost->host_lock, flags); list_for_each_entry(starget, &shost->__targets, siblings) { - if (starget->state == STARGET_DEL) + if (starget->reaped) continue; if (starget->dev.parent == dev || &starget->dev == dev) { /* assuming new targets arrive at the end */ kref_get(&starget->reap_ref); + starget->reaped = true; spin_unlock_irqrestore(shost->host_lock, flags); if (last) scsi_target_reap(last); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index fe89d7c..a734656 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -267,6 +267,8 @@ struct scsi_target { unsigned int expecting_lun_change:1; /* A device has reported * a 3F/0E UA, other devices on * the same target will also. */ + unsigned int visible:1; /* visible in sysfs */ + unsigned int reaped:1; /* removed from target list */ /* commands actually active on LLD. */ atomic_t target_busy; atomic_t target_blocked; @@ -280,7 +282,6 @@ struct scsi_target { #define SCSI_DEFAULT_TARGET_BLOCKED 3 char scsi_level; - enum scsi_target_state state; void *hostdata; /* available to low-level driver */ unsigned long starget_data[0]; /* for the transport */ /* starget_data must be the last element!!!! */