public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <dave@linux.vnet.ibm.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
	mdharm-usb@one-eyed-alien.net,
	linux-usb <linux-usb@vger.kernel.org>,
	usb-storage@lists.one-eyed-alien.net,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	linux-scsi <linux-scsi@vger.kernel.org>
Subject: Re: [RFC][PATCH] fix sign extension with 1.5TB usb-storage LBD=y
Date: Tue, 21 Apr 2009 15:49:10 -0700	[thread overview]
Message-ID: <1240354150.10627.36.camel@nimitz> (raw)
In-Reply-To: <20090421211858.GA1926@parisc-linux.org>

On Tue, 2009-04-21 at 15:18 -0600, Matthew Wilcox wrote:
> 
> this certainly fixes your problem.  I'd prefer this patch instead, just
> because I find the cast unaesthetic ...
> 
> ----
> 
> Fix READ CAPACITY 10 with drives over 1TB
> 
> Shifting an unsigned char implicitly casts it to a signed int.  This
> caused 'lba' to sign-extend and Linux would then try READ CAPACITY 16
> which was not supported by at least one drive.  Making 'lba' an
> unsigned
> int ensures that sign extension will not occur.
> 
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
> 
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 3fcb64b..c856b1b 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -1373,7 +1373,7 @@ static int read_capacity_10(struct scsi_disk
> *sdkp, struct scsi_device *sdp,
>         int sense_valid = 0;
>         int the_result;
>         int retries = 3;
> -       sector_t lba;
> +       unsigned lba;
>         unsigned sector_size;
> 
>         do {
> @@ -1413,7 +1413,7 @@ static int read_capacity_10(struct scsi_disk
> *sdkp, struct scsi_device *sdp,
>                 return -EOVERFLOW;
>         }
> 
> -       sdkp->capacity = lba + 1;
> +       sdkp->capacity = (sector_t)lba + 1;
>         return sector_size;
>  }

That's fine with me too.  This patch fixes my issue as well.

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>

-- Dave


      parent reply	other threads:[~2009-04-21 22:49 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
2009-04-21 21:18 ` Matthew Wilcox
2009-04-21 21:29   ` Randy Dunlap
2009-04-21 21:31     ` 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
2009-04-22 11:09       ` Matthew Wilcox
2009-04-22 11:27         ` Boaz Harrosh
2009-04-21 22:49   ` Dave Hansen [this message]

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=1240354150.10627.36.camel@nimitz \
    --to=dave@linux.vnet.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=usb-storage@lists.one-eyed-alien.net \
    /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