From: Tejun Heo <htejun@gmail.com>
To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Cc: Jeff Garzik <jgarzik@pobox.com>,
linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: ata_tf_read_block() question
Date: Sun, 16 Aug 2009 11:15:31 +0900 [thread overview]
Message-ID: <4A876BC3.3020407@gmail.com> (raw)
In-Reply-To: <20090815.224843.240484147.anemo@mba.ocn.ne.jp>
Hello, Atsushi.
Atsushi Nemoto wrote:
> I have a question on CHS calculation in ata_tf_read_block().
>
> The calculation in ata_tf_read_block() is:
> block = (cyl * dev->heads + head) * dev->sectors + sect;
>
> but ata_build_rw_tf() does:
> track = (u32)block / dev->sectors;
> cyl = track / dev->heads;
> head = track % dev->heads;
> sect = (u32)block % dev->sectors + 1;
>
> It seems inconsistent. The correct calculation is:
> block = (cyl * dev->heads + head) * dev->sectors + sect - 1;
> isn't it?
Yes, indeed.
> I don't have any real problem. Just noticed by code reading.
ata_tf_read_block() currently is used only when reporting failed block
address to upper layer so off-by-one bug there wouldn't be too
visible, especially for the venerable CHS addressing.
Care to submit a patch w/ warning message and capping for sect == 0
case?
Thanks.
--
tejun
next prev parent reply other threads:[~2009-08-16 2:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-15 13:48 ata_tf_read_block() question Atsushi Nemoto
2009-08-16 2:15 ` Tejun Heo [this message]
2009-08-16 9:33 ` Atsushi Nemoto
2009-08-16 12:21 ` [PATCH #upstream-fixes] libata: fix off-by-one error in ata_tf_read_block() Tejun Heo
2009-09-09 1:19 ` Jeff Garzik
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=4A876BC3.3020407@gmail.com \
--to=htejun@gmail.com \
--cc=anemo@mba.ocn.ne.jp \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).