From patchwork Sat Jun 25 08:10:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 918132 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5P8AiOS027592 for ; Sat, 25 Jun 2011 08:10:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750981Ab1FYIKm (ORCPT ); Sat, 25 Jun 2011 04:10:42 -0400 Received: from jester.euphonynet.be ([212.87.96.13]:58812 "EHLO mailpush2.euphonynet.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750966Ab1FYIKk (ORCPT ); Sat, 25 Jun 2011 04:10:40 -0400 Received: from smtp2.euphonynet.be (smtp2.euphonynet.be [212.87.96.4]) by mailpush2.euphonynet.be (Postfix) with ESMTP id A59FB4F878B; Sat, 25 Jun 2011 10:10:38 +0200 (CEST) Received: from localhost (scan03.euphonynet.be [212.87.96.25]) by smtp2.euphonynet.be (Postfix) with ESMTP id E8B4D2CF91420; Sat, 25 Jun 2011 10:15:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at euphonynet.be Received: from smtp2.euphonynet.be ([212.87.96.4]) by localhost (scan03.euphonynet.be [212.87.96.23]) (amavisd-new, port 10024) with ESMTP id iwnMOEC5+X9p; Sat, 25 Jun 2011 10:10:32 +0200 (CEST) Received: from asus.localnet (unknown [85.10.74.16]) by smtp2.euphonynet.be (Postfix) with ESMTP id 072902CF91320; Sat, 25 Jun 2011 10:15:47 +0200 (CEST) From: Bart Van Assche To: linux-rdma@vger.kernel.org Subject: [PATCH] ib_srp: Avoid that LUN scanning creates duplicate devices Date: Sat, 25 Jun 2011 10:10:30 +0200 User-Agent: KMail/1.13.6 (Linux/2.6.38.8-scst; KDE/4.6.0; x86_64; ; ) Cc: David Dillow , Christoph Hellwig , Roland Dreier MIME-Version: 1.0 Message-Id: <201106251010.30994.bvanassche@acm.org> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sat, 25 Jun 2011 08:11:16 +0000 (UTC) SCSI scanning of a channel:id:lun triplet in Linux works as follows (function scsi_scan_target() in drivers/scsi/scsi_scan.c): - If lun == SCAN_WILD_CARD, send a REPORT LUNS command to the target and process the result. - If lun != SCAN_WILD_CARD, send an INQUIRY command to the LUN corresponding to the specified channel:id:lun triplet to verify whether the LUN exists. So a SCSI driver must either take the channel and target id values in account in its quecommand() function or it should declare that it only supports one channel and one target id. Currently the ib_srp driver does neither. As a result scanning the SCSI bus via e.g. rescan-scsi-bus.sh causes many duplicate SCSI devices to be created. For each 0:0:L device, several duplicates are created with the same LUN number and with (C:I) != (0:0). Fix this by declaring that the ib_srp driver only supports one channel and one target id. Signed-off-by: Bart Van Assche Cc: David Dillow Cc: Christoph Hellwig Cc: Roland Dreier Cc: Acked-by: David Dillow --- drivers/infiniband/ulp/srp/ib_srp.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index ee165fd..7d5109b 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2127,6 +2127,8 @@ static ssize_t srp_create_target(struct device *dev, return -ENOMEM; target_host->transportt = ib_srp_transport_template; + target_host->max_channel = 0; + target_host->max_id = 1; target_host->max_lun = SRP_MAX_LUN; target_host->max_cmd_len = sizeof ((struct srp_cmd *) (void *) 0L)->cdb;