From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F7A8C4332F for ; Sat, 19 Nov 2022 02:24:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235943AbiKSCYz (ORCPT ); Fri, 18 Nov 2022 21:24:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235592AbiKSCXE (ORCPT ); Fri, 18 Nov 2022 21:23:04 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B78467D52B; Fri, 18 Nov 2022 18:15:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 39BB3B82670; Sat, 19 Nov 2022 02:15:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15801C433B5; Sat, 19 Nov 2022 02:15:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668824125; bh=3Fl/lTr9ZgkUmjDwLHEC1qgd+cjLAfMzyEJmOZGYwEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1uRq3u4P6Wne6QXRsh/Q5//8wgLXGyNyRDtW1bFSkjUPYZAUsjfG0y/4C2g8XYoC GVibcj3tlNH/MxwOI0YdljVEZgD67uWr2J8KstrrJusuPg2l29AAly7c63+mbXKbcr pHcF6hKPTwVDqQlkAkgJDtQryLf2ZJlHfpkVZ9n/6jZRAzRy7fmmb9VJWunFtAEZcF o6SbIUOjE6ORA1zMku9cMk0YNkCevluAmeHd74q+wzw5AOM1rYXgwuhhtY7iYR3K1E 6e6UGYHDizsN75hgYaS3Wv24MWrMGTnegkO9IlV/T2xvjND0Km0mQqGpvLEFsgwBqF P8I+Y/uZdE5oQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bart Van Assche , Douglas Gilbert , Damien Le Moal , "Martin K . Petersen" , Sasha Levin , jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 13/18] scsi: scsi_debug: Make the READ CAPACITY response compliant with ZBC Date: Fri, 18 Nov 2022 21:14:54 -0500 Message-Id: <20221119021459.1775052-13-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221119021459.1775052-1-sashal@kernel.org> References: <20221119021459.1775052-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Bart Van Assche [ Upstream commit ecb8c2580d37dbb641451049376d80c8afaa387f ] >From ZBC-1: - RC BASIS = 0: The RETURNED LOGICAL BLOCK ADDRESS field indicates the highest LBA of a contiguous range of zones that are not sequential write required zones starting with the first zone. - RC BASIS = 1: The RETURNED LOGICAL BLOCK ADDRESS field indicates the LBA of the last logical block on the logical unit. The current scsi_debug READ CAPACITY response does not comply with the above if there are one or more sequential write required zones. SCSI initiators need a way to retrieve the largest valid LBA from SCSI devices. Reporting the largest valid LBA if there are one or more sequential zones requires to set the RC BASIS field in the READ CAPACITY response to one. Hence this patch. Cc: Douglas Gilbert Cc: Damien Le Moal Suggested-by: Damien Le Moal Signed-off-by: Bart Van Assche Link: https://lore.kernel.org/r/20221102193248.3177608-1-bvanassche@acm.org Reviewed-by: Damien Le Moal Acked-by: Douglas Gilbert Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/scsi_debug.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5eb959b5f701..8fe4deca7499 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -1878,6 +1878,13 @@ static int resp_readcap16(struct scsi_cmnd *scp, arr[14] |= 0x40; } + /* + * Since the scsi_debug READ CAPACITY implementation always reports the + * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices. + */ + if (devip->zmodel == BLK_ZONED_HM) + arr[12] |= 1 << 4; + arr[15] = sdebug_lowest_aligned & 0xff; if (have_dif_prot) { -- 2.35.1