From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <010701a1a6d3ade1-17ae2bc0-05a2-4dd4-8572-79c2c51cd2e9-000000@eu-central-1.amazonses.com> Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11020106.outbound.protection.outlook.com [52.101.84.106]) by lore.virtuozzo.com (Postfix) with ESMTPS id C61108045D for ; Wed, 4 Nov 2026 13:50:58 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eSPdefGfP+Q+9jEiKEGGVZeoVAqm8j41Z3rCB4seIME+rRsyiciPhWFYIF7GBPgs7Ln6u1sAVIOZkN8RpC5fzHLv8FxaiVKZpDYP/B9Sdr0Zf1VPkTAa6gP8nPSvNHhbB3vjvgSsI8Qr6+SiAsOkZOIXnG5DNbc5hPT7uWUcA/DkeGToVfgsyX23xc4FOyw8rxKEsAZWBgYNK53/Dg4j85aW15sQD0299H/mfQMchhohFTd7H0KqIZen3oBRgahMPdUOJY7qVpFK72UQI5yLYjRmq7o+Q0+h/I+FxpFN4cFzAOmNkS24A418wBmO4bpac6sJfu3I3WaRh/bnh6vzdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pkdEppWblwBvBKMusBMI4ee2mv8DlWT+1vRCIq8nweU=; b=myJ9bJ123NTPUii5vsus+bVQYa7pq9Uk3Q3nE83O5kAz/ghOaOdGxVTI+MfIG2JedO9v1IqE8p1ohm1rOu4Ppsia1Kg1+bViwRhODUVxpuMhddBWkDQOaOc50UXmF7/BoirndXISTsnO0l5k5SG6YLV9NaQ/UaN7PYLymx+A9LL7vABU5HDsh9EhNTc3m4ELN+fq5b0lHo8/0WShyenrvZzzsBIbD5wNV4tP6B6ayVslbgbHPDP1jEFlkNxPmoX1CaeB5b79K3SJ9E975ZqtkKSoMgx2pXAyW3qP3WVP5fHuhsH/CGGhkjf9h6jGVEowSdMY+MEGt10buAuBDYkfcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 69.169.224.6) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=eu-central-1.amazonses.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com; dkim=pass (signature was verified) header.d=amazonses.com; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pkdEppWblwBvBKMusBMI4ee2mv8DlWT+1vRCIq8nweU=; b=ogdpKJ1L7SxBx5bTFMRQl+e1rbvD+CRSaplAPLMsuDAWELjnOHKZzabgSjxS6C5rBuUTZ5zUY5T+JLaKVI+HuCbCfa/8ALFQGa9x8uMk8BwdxcmFA5bKTtui9/TGtB0v6ggh6hQuowOLHwL50PqyiC3r29JHWu3tyauk840ZXM8= Received: from PA7P264CA0476.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3dc::8) by DB4PR08MB7936.eurprd08.prod.outlook.com (2603:10a6:10:378::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.9; Wed, 4 Nov 2026 13:50:53 +0000 Received: from MI3PEPF0000847F.eurprd02.prod.outlook.com (2603:10a6:102:3dc:cafe::5a) by PA7P264CA0476.outlook.office365.com (2603:10a6:102:3dc::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.9 via Frontend Transport; Wed, 4 Nov 2026 13:50:53 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 69.169.224.6) smtp.mailfrom=eu-central-1.amazonses.com; dkim=pass (signature was verified) header.d=sashiko.virtuozzo.com;dkim=pass (signature was verified) header.d=amazonses.com;dmarc=pass action=none header.from=sashiko.virtuozzo.com; Received-SPF: Pass (protection.outlook.com: domain of eu-central-1.amazonses.com designates 69.169.224.6 as permitted sender) receiver=protection.outlook.com; client-ip=69.169.224.6; helo=b224-6.smtp-out.eu-central-1.amazonses.com; pr=C Received: from b224-6.smtp-out.eu-central-1.amazonses.com (69.169.224.6) by MI3PEPF0000847F.mail.protection.outlook.com (10.167.240.166) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.5 via Frontend Transport; Wed, 4 Nov 2026 13:50:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=23yjbh4k34hwzfubhuiim7m4inbd3ick; d=sashiko.virtuozzo.com; t=1793800253; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zJTUwj/ih0vvZXCeeOGRwUukfCw+Qykp0Ip+pwOaGpE=; b=irgZ1ji0s4iGcNFzMEI9b8X0AJNa0JvLMFf/KyPEXQoxPQ/mBVruKM1WUYZT3wUz sTKGxEYDaROi2OlWR9RluVOnYy1jEnEbz5JtoS+l/j9X1GY/k6iEpM9dhHBLVvAADzr BOvsoW2b5JTzrGQPO/f+rCIiYE0xc5HNCygQR+8WJAT2h4+moLRNFCwvT7P3OKonKUk gYorpbJF0iBKqj5e7uINhSjq2rY6/6LL5Me7rgDRahVsP+4x/zx5XUjZ/jCDnrGkocj +3hkLyqUiih/FnLp1dawTKEqKaqg68iIv7lM1/7MNPPLeGUxhqlsYFJ55ksEcJYTIas NyrFNrkFHg== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qftdzk2dqsatjnlrq4r5brjbihpfcrsh; d=amazonses.com; t=1793800253; h=Message-ID:From:Subject:To:Cc:In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date:Feedback-ID; bh=zJTUwj/ih0vvZXCeeOGRwUukfCw+Qykp0Ip+pwOaGpE=; b=gYSx1fP9vZv4qlsuzGYWqIuWuD0DpnucEzE8c+EcCbTAA4nFmpetuARuG37AbIz4 6Ox1PA+vu5aazLlAjYJRrJ0ZLjlLptjmO32xV/KGrmvW5zjU663aHle1KuBEcdiGOS5 HRhWAhi5NgS4KURtRt4VSh65EIJMHQzw8/yLzCG0= Message-ID: <010701a1a6d3ade1-17ae2bc0-05a2-4dd4-8572-79c2c51cd2e9-000000@eu-central-1.amazonses.com> From: no-reply@sashiko.virtuozzo.com Subject: Re: [PATCH hci-dev 3/6] scsi-disk: refresh the cached capacity from the resize callback #VSTOR-130961 To: andrey.drobyshev@virtuozzo.com, "Denis V. Lunev" Cc: svt-core@virtuozzo.com, den@openvz.org In-Reply-To: <20261104134539.1519657-4-den@openvz.org> References: <20261104134539.1519657-1-den@openvz.org> <20261104134539.1519657-4-den@openvz.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 4 Nov 2026 13:50:52 +0000 Feedback-ID: ::1.eu-central-1.2wRQJBpg9g1fGRYexx3dUuYGS25Bux+2TEOx72/m6U4=:AmazonSES X-SES-Outgoing: 2026.11.04-69.169.224.6 X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MI3PEPF0000847F:EE_|DB4PR08MB7936:EE_ MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 9eeeecbd-1ab3-4e5c-54fb-08df3a7aa4c0 X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|61400799027|32142699015|48200799018|376014|9140799003|4143699003|56012099006|5063699009|261021121427099003|261009223027099003|261026135527099003|261102123227099003|261026140227099003|261028144727099003|261026121527099003|261022105027099003|261022075727099003|10067099003|55112099003|22082099003|18002099003|16102099003|5113699003|4113699003|13003099007; X-Microsoft-Antispam-Message-Info: m34lqTnnW8f4kpwMgKImB1xY6ZNDE0K3EdRxw3xqL/EjOQYHfKv/izbmmOYMSsp0SZFuITlQgECPEQTCMx5dSvoug63mA43k8g1cfQGWZj6cbfl1dLHKzt3mAeD8Lg7gAW8PNj+M40164OP8Cq6n9PIFKNUzRfnfFXKrWzQvaEPG2ESStkQ2qGyKK5S61O/1yjuTVDcOhsNHq9Bl3gsc6NsCSbHxxNgF00DhxJ1yoDtDSu813mqopzNB/r0VsEb0DYprcnitaR/tFGw29V43EAYB/k/Emi4gi+ynHkmdoTmnA7do6nX4Qwq55UvcWppJgzNWnMLDwU5jco0Yv0TGw5lcmdeAtcWFE3pqnfyprV2GZ0GlyA5UwmT7nLMvI37CCQPv96DjzY9SdYlJMqeTBdQ9qT4F6EEJAWry0JnTMM+KAvQ2gLdUpqGiAJUY4d4/0kNccVbSWjKNZZ/I1HM0EN3WRD9eAsgR2jQxf/9ighneUnDjOl6TTucHbFpTRzsTZcZTTmV7oSRZCM8Ki1OEsemiQIKxqpFgsHUSzlsnIC0vcx0ox1l04/vr4qbT1rx3cax4HBqaMnkk9wR2dv1soYCryn6WItJsQAmve7N8ssy2IpRhMwNb5vroylHRcKh7e/C9IHjaTLTdX49Y7MdeWKJJKCH3emSYSLXmQxkpXDTv7newna6sMRD5DA4dXlyJFAWHusiR2NuIzz8KL9G4LOiv7du8clB8k08jwfV9YVcYOS3SFVn/mk6gPlvC1Pe/Bstf0G/zQ3STe53Pra8CnGNk/SxpsHYul4pqx2tRZrjSTsHeStDMMbv0Cm1gM482Z/F969aaLmSs5EWCMO92Ve5z5QQyCRwvtoCKnDZHW6emfXfDemrzrfrr8AGUM31gcWIQ8pTAV8Fxf9H5biFJ4b3XdC/weeFphDZJoQOkvIJpnKIMwq7YCOxcS7v4UxfZ X-Forefront-Antispam-Report: CIP:69.169.224.6;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:b224-6.smtp-out.eu-central-1.amazonses.com;PTR:b224-6.smtp-out.eu-central-1.amazonses.com;CAT:NONE;SFS:(13230040)(61400799027)(32142699015)(48200799018)(376014)(9140799003)(4143699003)(56012099006)(5063699009)(261021121427099003)(261009223027099003)(261026135527099003)(261102123227099003)(261026140227099003)(261028144727099003)(261026121527099003)(261022105027099003)(261022075727099003)(10067099003)(55112099003)(22082099003)(18002099003)(16102099003)(5113699003)(4113699003)(13003099007);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZgJY+OuZB6ytukMGK44NS66GCMOrENBxqMPnNZHtpJxGS1BX1+1S1efPaAExfLkitUF393g3xBrY02Udkuw2kU++swuQ18qzL/Ql5UwKcTvBPe4FTFMsoMYr+81zGhxu/AnACyJaLnsxwkpE+evXGKZE0P7FRbEBw8D92IvKtUFXY2ZDwB62mmOjjG4Wn4hWMU/PFd8y5dbgc+fFC7ZPBJLs1n1qFqHK9iyQ2/NzZs8CQJhHeHwzU2zarvMupniH1ilSUOvBtRKB6OQRVYaXn8qBDJ8dUCszTfiB1X6LgLljsBtoxJ7u/bEo4iWPnj92AwQ7I4ZxHhY5Chqx6+eyALbibdE/T1ruR6t+OEWpn2PRO68V49r8eK4gqRzJEXtSk0JsmAyPyf2+HaQSItBlBNMTdz7Hi9eAoXcOFZqughi6oMyAROq7xKpXzPmxDiVn X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2026 13:50:53.3687 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9eeeecbd-1ab3-4e5c-54fb-08df3a7aa4c0 X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: MI3PEPF0000847F.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB7936 Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: - [Low] scsi-disk: scsi_disk_refresh_max_lba() leaves max_lba 0 for a zero-= size backend -- commit 0d24fb2b136b4040fa253df9cd5bb8b0c4064335 Author: Denis V. Lunev scsi-disk: refresh the cached capacity from the resize callback This commit moves the max_lba computation out of scsi_disk_reset() into a new helper, scsi_disk_refresh_max_lba(). It then calls the helper from scsi_disk_resize_cb() so the cached capacity follows a backend resize. Message-ID: <20260812121500.1034178-3-den@openvz.org> > diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c > --- a/hw/scsi/scsi-disk.c > +++ b/hw/scsi/scsi-disk.c [ ... ] > +static void scsi_disk_refresh_max_lba(SCSIDiskState *s) > { > uint64_t nb_sectors; > =20 > blk_get_geometry(s->qdev.conf.blk, &nb_sectors); > =20 > nb_sectors /=3D s->qdev.blocksize / BDRV_SECTOR_SIZE; > if (nb_sectors) { > nb_sectors--; > } > s->qdev.max_lba =3D nb_sectors; > +} [Severity: Low] Can max_lba end up describing a one-block device when the backend has zero sectors? blk_get_geometry() maps a negative blk_nb_sectors() to 0. The helper only decrements when nb_sectors is non-zero, so max_lba stays 0 in that case. check_lba_range() then evaluates a request for LBA 0 with length 1 as: sector_num + nb_sectors <=3D s->qdev.max_lba + 1 which is 0 + 1 <=3D 0 + 1, so the request is accepted. It is not refused with LOGICAL BLOCK ADDRESS OUT OF RANGE. The guard in scsi_disk_dma_command() does not cover this: if (!blk_is_available(s->qdev.conf.blk)) { scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); return 0; } It only tests for a missing medium, not a present medium that was resized to 0 sectors. The READ CAPACITY handling in scsi_disk_emulate_command_complete() takes a different approach for a zero-size backend: blk_get_geometry(s->qdev.conf.blk, &nb_sectors); if (!nb_sectors) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_READY)); return 0; } That path returns LUN_NOT_READY and does not touch max_lba. The new helper has no equivalent check. The zero-size handling was already in scsi_disk_reset(). This patch newly applies it at runtime from scsi_disk_resize_cb(), for example after a resize to 0 sectors or a failed size query during a replace. I did not check how the block layer treats the request after it passes check_lba_range(). The result is at least a wrong sense code, and possibly an error from the backend. Should the helper handle the zero-sector case separately, so that check_lba_range() refuses every request in that state? --=20 Sashiko AI review =C2=B7 https://sashiko.vzint.dev/#/patchset/2026110413453= 9.1519657-1-den@openvz.org?part=3D3