From: John Garry <john.g.garry@oracle.com>
To: Chaotian Jing <chaotian.jing@mediatek.com>,
James.Bottomley@HansenPartnership.com,
martin.petersen@oracle.com
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com
Subject: Re: [PATCH] scsi: fix the return value of scsi_logical_block_count
Date: Wed, 7 Aug 2024 09:47:55 +0100 [thread overview]
Message-ID: <9c475f0e-d550-4ff7-9d6c-94dfc300908a@oracle.com> (raw)
In-Reply-To: <20240806072714.29756-1-chaotian.jing@mediatek.com>
On 06/08/2024 08:26, Chaotian Jing wrote:
> scsi_logical_block_count() should return the block count of scsi device,
scsi command, not scsi device
> but the original code has a wrong implement.
>
> Signed-off-by: Chaotian Jing <chaotian.jing@mediatek.com>
> ---
> include/scsi/scsi_cmnd.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 45c40d200154..f0be0caa295a 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -236,7 +236,7 @@ static inline unsigned int scsi_logical_block_count(struct scsi_cmnd *scmd)
I find it questionable why we have this in the core code, since it's
only used in error handling logs for one driver. And obviously no one
was paying attention to it.
> {
> unsigned int shift = ilog2(scmd->device->sector_size) - SECTOR_SHIFT;
>
> - return blk_rq_bytes(scsi_cmd_to_rq(scmd)) >> shift;
> + return blk_rq_sectors(scsi_cmd_to_rq(scmd)) >> shift;
blk_rq_sectors() converts from bytes to linux sectors, and then we shift
it by diff in linux sectors and LBS.
To me, if this were used in fastpath - which it isn't - the following
seems better:
return blk_rq_bytes(scsi_cmd_to_rq(scmd)) / scmd->device->sector_size;
> }
>
> /*
next prev parent reply other threads:[~2024-08-07 8:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-06 7:26 [PATCH] scsi: fix the return value of scsi_logical_block_count Chaotian Jing
2024-08-06 20:51 ` Bart Van Assche
2024-08-07 8:47 ` John Garry [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-08-07 0:57 Chaotian Jing
2024-08-13 1:52 ` Martin K. Petersen
2024-08-13 3:35 ` Chaotian Jing (井朝天)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9c475f0e-d550-4ff7-9d6c-94dfc300908a@oracle.com \
--to=john.g.garry@oracle.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chaotian.jing@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=srv_heupstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox