[PATCH] scsi: fix disk capacity too small by one sector
Tom Rini
trini at konsulko.com
Tue Oct 22 05:35:15 CEST 2024
On Mon, Oct 14, 2024 at 06:06:35PM +0200, Julius Lehmann wrote:
> SCSI READ CAPACITY reports the address of the last
> block and the block size. The total number of blocks
> is thus last block address plus one.
>
> ---
> This patch fixes the disk size reported by scsi. Up until now, the reported disk size is too small by one sector. Read/Write operations on other sectors have not been affected. Trying to partition scsi backed storage via ums has resulted in "storage too small" errors.
>
> doc: https://linux.die.net/man/8/sg_readcap
>
> Signed-off-by: Julius Lehmann <lehmanju at devpi.de>
> ---
> drivers/scsi/scsi.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 51cacf3479236be6c6ea3e7d15b87e03f10e7f3a..bcdeda95ed1514119057cc67974fec465cf5672c 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -309,6 +309,7 @@ static int scsi_read_capacity(struct udevice *dev, struct scsi_cmd *pccb,
> ((unsigned long)pccb->pdata[5] << 16) |
> ((unsigned long)pccb->pdata[6] << 8) |
> ((unsigned long)pccb->pdata[7]);
> + *capacity += 1;
> return 0;
> }
>
> @@ -332,6 +333,7 @@ static int scsi_read_capacity(struct udevice *dev, struct scsi_cmd *pccb,
> ((uint64_t)pccb->pdata[5] << 16) |
> ((uint64_t)pccb->pdata[6] << 8) |
> ((uint64_t)pccb->pdata[7]);
> + *capacity += 1;
>
> *blksz = ((uint64_t)pccb->pdata[8] << 56) |
> ((uint64_t)pccb->pdata[9] << 48) |
>
This leads to this failure in CI:
https://source.denx.de/u-boot/u-boot/-/jobs/926468#L288
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20241021/e5f23677/attachment.sig>
More information about the U-Boot
mailing list