From: Al Viro <viro-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org>
To: Dave Hansen <dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: linux-kernel
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Matthew Wilcox <matthew-Ztpu424NOJ8@public.gmane.org>,
mdharm-usb-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org,
linux-usb <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
usb-storage-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.org,
James Bottomley
<James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>,
linux-scsi <linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [RFC][PATCH] fix sign extension with 1.5TB usb-storage LBD=y
Date: Tue, 21 Apr 2009 22:01:45 +0100 [thread overview]
Message-ID: <20090421210145.GF8633@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1240347174.10627.20.camel@nimitz>
On Tue, Apr 21, 2009 at 01:52:54PM -0700, Dave Hansen wrote:
> This is with current git as of this morning, which is at v2.6.30-rc2.
>
> I have a 1.5TB USB device which gets a bit angry when I plug it in. It
> ends up with a scsi_disk->capacity of ffffffffaea87b30. I tracked it
> down to the lba calculation in read_capacity_10():
>
> lba = (buffer[0] << 24) | (buffer[1] << 16) |
> (buffer[2] << 8) | buffer[3];
>
> lba is getting all 0xf's in its high 32 bits. It seems odd that this
> would happen since 'buffer' is an 'unsigned char', but that is
> apparently what is going on.
Nothing odd here; you get unsigned char promoted to int (since the entire
range fits into the range of int), then calculations are carried within
int and in the end you have (overflown into negative) int sign-extended
into u64.
Solution is correct, but perhaps use of get_unaligned_be32(buffer) would be
better.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-04-21 21:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-21 20:52 [RFC][PATCH] fix sign extension with 1.5TB usb-storage LBD=y Dave Hansen
2009-04-21 21:01 ` Al Viro [this message]
2009-04-21 21:18 ` Matthew Wilcox
2009-04-21 22:00 ` [PATCH v2] " Dave Hansen
2009-04-21 23:03 ` Matthew Wilcox
2009-04-21 23:43 ` Dave Hansen
2009-04-22 7:32 ` Boaz Harrosh
[not found] ` <49EEC82B.5040603-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2009-04-22 11:09 ` Matthew Wilcox
2009-04-22 11:27 ` Boaz Harrosh
[not found] ` <20090421211858.GA1926-6jwH94ZQLHl74goWV3ctuw@public.gmane.org>
2009-04-21 21:29 ` [RFC][PATCH] " Randy Dunlap
2009-04-21 21:31 ` Matthew Wilcox
2009-04-21 22:49 ` Dave Hansen
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=20090421210145.GF8633@ZenIV.linux.org.uk \
--to=viro-3bdd1+5odreifsdqtta3olvcufugdwfn@public.gmane.org \
--cc=James.Bottomley-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org \
--cc=dave-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=matthew-Ztpu424NOJ8@public.gmane.org \
--cc=mdharm-usb-JGfshJpz5UybPZpvUQj5UqxOck334EZe@public.gmane.org \
--cc=usb-storage-ijkIwGHArpdIPJnuZ7Njw4oP9KaGy4wf@public.gmane.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).