From patchwork Tue Aug 20 09:04:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 11103449 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E2461813 for ; Tue, 20 Aug 2019 09:04:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3CAF222DBF for ; Tue, 20 Aug 2019 09:04:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="Hf+CgrYr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729333AbfHTJE4 (ORCPT ); Tue, 20 Aug 2019 05:04:56 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:16075 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728842AbfHTJE4 (ORCPT ); Tue, 20 Aug 2019 05:04:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1566291897; x=1597827897; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=N6U+iFU3I1ObSGYxaMPWqYiwaAzsH4dwhnKXRvXgoFk=; b=Hf+CgrYrVVCmqpnMZ86MxI2T7WETKfSl2q5bddPfuZPiwbcIuDNUPArG EODCyly0hrrZEPc8c/66vdt4xagrpk0ArE6WQMc+JAt1wzAC4AgIu1i0n cKxiUr65vwXIeQjghltIrU7nd2sZSVd757VtjFpFMeEi4th+AhYxfcORJ 7qcsDjG8TUbl87EbDm+LbppuHXQa0dSeYG2OQZW4AgvrUVxC3Ady3XQbF ih88itlGuQeJHm/fn9jQv5moKKEsGX2SEasRgRnaZNVgvLlhLv/IfC9Rt mlTA3XfR/qDYNGU1xSmTw6PuhJZrO21XyPi+B6CyUDjrjR8ZVxoRGdytj A==; IronPort-SDR: dhYOHztZwsvsC+eGfpNZMjUY0NYR2G97ftHOAaqX+Gd8VGRfsZxH3xNewOIIAsuwyo39iIWmXX 6q4MwGhMd35oWclXFPOOqWk9LTQKikKa0fT4TP0mS83OEC6Yju9vcjWqnOHHeooE5Z4DHqfTjC zy9wzIA9JSf48mdm24wMa8nLuZtwRugybe+ZjRL1crqHzsANfMx/fbs4lwElJTiwPv9pGG1ApP cufatIiqu67Edz3GziG9woXbnszgTKDjqPsUw1Fw9F775sg4FMWYauZQte7KrqrU9rm5cC5Tf0 Sa8= X-IronPort-AV: E=Sophos;i="5.64,408,1559491200"; d="scan'208";a="216621446" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Aug 2019 17:04:56 +0800 IronPort-SDR: NhsAtYlw8JeFLKj5EtsNsRis+GHgeSBtnJpvIFgZHTMKrzu7945uUUIe1yBYrU2rQGc7tFt9n3 j1j0ABuKCdhiy/aF0HSAoBsRLgSp9pud0jX1bTejnGMsAyRDUOUN+XHFrtOjn1vVaeyeAXl6JM 1qRGIjZ+JTL3aXuWIRsTHDOnGGgbzfuR/yAUigxgkAE4fckZe0uePknf+yQbCT2YkQp6yAlor9 3o1HcG2Mli+AQbUAaZnxsdMMatJIaLtQzH3ici7Ta/a5pibRMjogPaQMJyrgLIb9MbR2FOTCN3 oknLvkYbFo4nMTOF3avpbYMv Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 02:02:18 -0700 IronPort-SDR: LaXarf7EZDW3MYdUaentUq8JX8Kwi4FMMCiEqc6hVQH+ijlFVcFndwoXq6pYGmhIavNsHdiChm a6f9axgf2adCjiXQCy4eed7wrqJFrrDQOjPMJaPkYnSTFpY/MVXyYgnCvzMMOeKyj9bu13C3db sgtqpPbF9woFuzsfBmy77kSAxsegFYvsix9d18lU12jDrmEfjh0iWnLO+8pOYsPi7uo9T0elKq kEgFhhqZw4ePK1QMZkcZ4iOKb94xs5Id5Z2FkXOhCXeNi9DgSVay95Yy7M5eBzxXelhsV1DhPW T3M= Received: from naota.dhcp.fujisawa.hgst.com (HELO naota.fujisawa.hgst.com) ([10.149.53.115]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 02:04:54 -0700 From: Naohiro Aota To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie , Nicholas Bellinger , "Martin K . Petersen" , Naohiro Aota Subject: [PATCH v2 1/2] scsi: target/tcm_loop: ignore already deleted scsi device Date: Tue, 20 Aug 2019 18:04:28 +0900 Message-Id: <20190820090429.1961085-1-naohiro.aota@wdc.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org If there is no corresponding scsi_device for a LUN, tcm_loop_port_unlink() complains that it "Unable to locate struct scsi_device for " the device and keep %tl_tpg_port_count as is. However, such situation is legal when we delete a SCSI device using /sys/class/scsi_device/${lun}/device/delete. We can safely ignore the missing SCSI device case here. Signed-off-by: Naohiro Aota --- drivers/target/loopback/tcm_loop.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 3305b47fdf53..0942f3bd7eec 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -654,16 +654,16 @@ static void tcm_loop_port_unlink( sd = scsi_device_lookup(tl_hba->sh, 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun); - if (!sd) { - pr_err("Unable to locate struct scsi_device for %d:%d:%llu\n", - 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun); - return; + if (sd) { + /* + * Remove Linux/SCSI struct scsi_device by HCTL + */ + scsi_remove_device(sd); + scsi_device_put(sd); + } else { + pr_debug("Unable to locate struct scsi_device for %d:%d:%llu\n", + 0, tl_tpg->tl_tpgt, se_lun->unpacked_lun); } - /* - * Remove Linux/SCSI struct scsi_device by HCTL - */ - scsi_remove_device(sd); - scsi_device_put(sd); atomic_dec_mb(&tl_tpg->tl_tpg_port_count); From patchwork Tue Aug 20 09:04:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 11103451 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C5A9C912 for ; Tue, 20 Aug 2019 09:05:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A42F422CF7 for ; Tue, 20 Aug 2019 09:05:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="EP9KgOdD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729312AbfHTJFA (ORCPT ); Tue, 20 Aug 2019 05:05:00 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:16080 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728698AbfHTJFA (ORCPT ); Tue, 20 Aug 2019 05:05:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1566291904; x=1597827904; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MnC9I/+eq+q2Ei5v2mBRNNadmxEq1GlCxXcT3BpX/mk=; b=EP9KgOdDLnzAW16bHgJGfp0zIIsqAKy9iZiql7Bm29bWzigvFl0FLh+a Y8x5LPuLd+VG7loJItYklhNGia1kC7Lgc759o+aN1WGGe+mDKv3eBpnkI pwThyzQjdzNw/0x2fbQgrL/mAx+BQGvpVRhrF8OX04fLXbvqP3JW0rz3B 2iXTnf1XPjwqtkzS6CoIc1HRkibDtgIlPEaksO+9j+jFh9h3BpdgdLQua y8whPkJ3wMGBlVxR6bxsPx1sIKOEW4ziyOVo6mMY7hob+w7aGv6CoWd/j NyJCtnU+zS60qtBpRWB6OElIHsgQEKJSuYAqMkz0KYBsN955xN6N1e3Qv Q==; IronPort-SDR: ByVHicBDJWbirCzrZ7Ef0+lruTDPMrYseR8FA+3LSrBQ7j0LBYR3BnM5xgTLeF1U4BSPARAVF7 QjfIguPG9XhzEHoEFcK0u4nl+wQA+T1kZpWsx3SOOjBJJ36I54LJmaYU3iJTUMBpYT77mACsc5 RTvYJo3et6In3d2nxFKyx+xgiFXbH69SkHNi8XRYHp49vy5kiBGvgitMzomNaEmM0oEkPLt+bL 0A/5DTKpsX11SQTx+XCozt38pv0rqnJsvThRCFYhM9x8vDK3zHd21kT/40YKY4+++x/NLtkEYm kvM= X-IronPort-AV: E=Sophos;i="5.64,408,1559491200"; d="scan'208";a="216621449" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 20 Aug 2019 17:05:03 +0800 IronPort-SDR: 7GAmPa1U8WzWjP77iMJfEQ3vogNrg8p6Xg6V6Tc19jM43InSVJShbM4+WbOaUXaGo0mRMkxNr+ dbiW9mUqTT0FL/IoeMexztIjdm6t4ue1wENUIGesiB6JHHFLGnuUW4TmDgeb01QjqSXo4kLMaZ SojxFgREid36g9wOsZfNsPZxQ9PC660h0JvQPrqTWHxbWIR1J++XPVO1ekAkgwRvK5UwayfQL6 wxOYAXBxAWeEqVMc80j8ntrxAFVxbjU+Y3lPOO20bbdyIPwsUL3AphoaPfOHZW39cy2DiKUaWR WgSRh9ulpg5ReDa3Kc6HRRFQ Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Aug 2019 02:02:22 -0700 IronPort-SDR: sRH6lXI2d7s0zVPGznpsL3FE6x+nFHv05UYQvz2F7SfTGmMt5uQP1gEefGy0sW2jonkZTQGB+/ M+y9MN5lDrM2+oU4y/hxI0auzrNMkNRzrXrnKsAX4r6bvKFozK2Os/NXKcKGZkrXwK6gtEIsh6 Z0O81WzIk0seDSDRbL6doWvRgcZdDsLjMcS6MzfUFf7a2VQtdlSw4ngR0NwZrDuVyUw/9J8R4N 7QOXkqCbSOYuW7FUtgWs+LtHUQM+MzYJdYrRZRAdnAv3YD2eswmTmJw95IqH/LJu0W/86am3Oz glw= Received: from naota.dhcp.fujisawa.hgst.com (HELO naota.fujisawa.hgst.com) ([10.149.53.115]) by uls-op-cesaip01.wdc.com with ESMTP; 20 Aug 2019 02:04:59 -0700 From: Naohiro Aota To: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org Cc: Mike Christie , Nicholas Bellinger , "Martin K . Petersen" , Naohiro Aota Subject: [PATCH v2 2/2] scsi: target/tcm_loop: update upper limit of LUN Date: Tue, 20 Aug 2019 18:04:29 +0900 Message-Id: <20190820090429.1961085-2-naohiro.aota@wdc.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190820090429.1961085-1-naohiro.aota@wdc.com> References: <20190820090429.1961085-1-naohiro.aota@wdc.com> MIME-Version: 1.0 Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org targetcli-fb (or its library: rtslib-fb) allows us to create LUN up to 65535. On the other hand, the kernel driver is limiting max_lun to 0. This limitation causes actual problem when you delete a loopback device (using /sys/class/scsi_device/${lun}/device/delete) and rescan it (using /sys/class/scsi_host/host${h}/scan). You can delete the device, but cannot rescan it because its LUN is larger than max_lun and so the scan request results in -EINVAL error in scsi_scan_host_selected(). This commit fix the upper limit to a max possible value: U64_MAX. Signed-off-by: Naohiro Aota --- drivers/target/loopback/tcm_loop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 0942f3bd7eec..50e93b487375 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -336,10 +336,10 @@ static int tcm_loop_driver_probe(struct device *dev) */ *((struct tcm_loop_hba **)sh->hostdata) = tl_hba; /* - * Setup single ID, Channel and LUN for now.. + * Setup single ID, and Channel for now.. */ sh->max_id = 2; - sh->max_lun = 0; + sh->max_lun = U64_MAX; sh->max_channel = 0; sh->max_cmd_len = SCSI_MAX_VARLEN_CDB_SIZE;