linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Patch "sd: Disable support for 256 byte/sector disks" has been added to the 4.0-stable tree
       [not found] ` <556EC8F4.7030507@suse.cz>
@ 2015-06-03 13:37   ` James Bottomley
  2015-06-03 13:54     ` James Bottomley
  0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2015-06-03 13:37 UTC (permalink / raw)
  To: jslaby@suse.cz
  Cc: geert@linux-m68k.org, linux-scsi@vger.kernel.org,
	dmarkh@cfl.rr.com, hare@suse.de, gregkh@linuxfoundation.org,
	stable@vger.kernel.org, stable-commits@vger.kernel.org

On Wed, 2015-06-03 at 11:29 +0200, Jiri Slaby wrote:
> On 06/03/2015, 08:35 AM, gregkh@linuxfoundation.org wrote:
> > From 74856fbf441929918c49ff262ace9835048e4e6a Mon Sep 17 00:00:00 2001
> > From: Mark Hounschell <dmarkh@cfl.rr.com>
> > Date: Wed, 13 May 2015 10:49:09 +0200
> > Subject: sd: Disable support for 256 byte/sector disks
> > 
> > From: Mark Hounschell <dmarkh@cfl.rr.com>
> > 
> > commit 74856fbf441929918c49ff262ace9835048e4e6a upstream.
> > 
> > 256 bytes per sector support has been broken since 2.6.X,
> > and no-one stepped up to fix this.
> > So disable support for it.
> > 
> > Signed-off-by: Mark Hounschell <dmarkh@cfl.rr.com>
> > Signed-off-by: Hannes Reinecke <hare@suse.de>
> > Signed-off-by: James Bottomley <JBottomley@Odin.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > ---
> >  drivers/scsi/sd.c |   19 +++++--------------
> >  1 file changed, 5 insertions(+), 14 deletions(-)
> > 
> > --- a/drivers/scsi/sd.c
> > +++ b/drivers/scsi/sd.c
> > @@ -1624,6 +1624,7 @@ static unsigned int sd_completed_bytes(s
> >  {
> >  	u64 start_lba = blk_rq_pos(scmd->request);
> >  	u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
> > +	u64 factor = scmd->device->sector_size / 512;
> >  	u64 bad_lba;
> >  	int info_valid;
> >  	/*
> > @@ -1645,16 +1646,9 @@ static unsigned int sd_completed_bytes(s
> >  	if (scsi_bufflen(scmd) <= scmd->device->sector_size)
> >  		return 0;
> >  
> > -	if (scmd->device->sector_size < 512) {
> > -		/* only legitimate sector_size here is 256 */
> > -		start_lba <<= 1;
> > -		end_lba <<= 1;
> > -	} else {
> > -		/* be careful ... don't want any overflows */
> > -		unsigned int factor = scmd->device->sector_size / 512;
> > -		do_div(start_lba, factor);
> > -		do_div(end_lba, factor);
> > -	}
> 
> Hmm, you do 'unsigned int' -> 'u64' switch of factor type here. But this
> commit:
> commit ef80d1e18b014af08741cf688e3fdda1fb71363f
> Author: Geert Uytterhoeven <geert@linux-m68k.org>
> Date:   Mon Nov 4 10:21:05 2013 +0100
> 
>     [SCSI] sd: Do not call do_div() with a 64-bit divisor
> 
> did the switch in the opposite direction deliberately.
> 
> So why did you do the change, given sector_size is uint?

Primarily because no-one spotted the reversal and none of the static
checkers warns about it.

This is the trivial fix, but we should do something about the checkers.

James

---

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 3b2fcb4..3e137dd 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1600,7 +1600,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd)
 {
 	u64 start_lba = blk_rq_pos(scmd->request);
 	u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
-	u64 factor = scmd->device->sector_size / 512;
+	unsigned int factor = scmd->device->sector_size / 512;
 	u64 bad_lba;
 	int info_valid;
 	/*


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: Patch "sd: Disable support for 256 byte/sector disks" has been added to the 4.0-stable tree
  2015-06-03 13:37   ` Patch "sd: Disable support for 256 byte/sector disks" has been added to the 4.0-stable tree James Bottomley
@ 2015-06-03 13:54     ` James Bottomley
  2015-06-03 14:37       ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: James Bottomley @ 2015-06-03 13:54 UTC (permalink / raw)
  To: jslaby@suse.cz
  Cc: geert@linux-m68k.org, linux-scsi@vger.kernel.org,
	dmarkh@cfl.rr.com, hare@suse.de, gregkh@linuxfoundation.org,
	stable@vger.kernel.org, stable-commits@vger.kernel.org

On Wed, 2015-06-03 at 13:37 +0000, James Bottomley wrote:
> On Wed, 2015-06-03 at 11:29 +0200, Jiri Slaby wrote:
> > On 06/03/2015, 08:35 AM, gregkh@linuxfoundation.org wrote:
> > > From 74856fbf441929918c49ff262ace9835048e4e6a Mon Sep 17 00:00:00 2001
> > > From: Mark Hounschell <dmarkh@cfl.rr.com>
> > > Date: Wed, 13 May 2015 10:49:09 +0200
> > > Subject: sd: Disable support for 256 byte/sector disks
> > > 
> > > From: Mark Hounschell <dmarkh@cfl.rr.com>
> > > 
> > > commit 74856fbf441929918c49ff262ace9835048e4e6a upstream.
> > > 
> > > 256 bytes per sector support has been broken since 2.6.X,
> > > and no-one stepped up to fix this.
> > > So disable support for it.
> > > 
> > > Signed-off-by: Mark Hounschell <dmarkh@cfl.rr.com>
> > > Signed-off-by: Hannes Reinecke <hare@suse.de>
> > > Signed-off-by: James Bottomley <JBottomley@Odin.com>
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > > 
> > > ---
> > >  drivers/scsi/sd.c |   19 +++++--------------
> > >  1 file changed, 5 insertions(+), 14 deletions(-)
> > > 
> > > --- a/drivers/scsi/sd.c
> > > +++ b/drivers/scsi/sd.c
> > > @@ -1624,6 +1624,7 @@ static unsigned int sd_completed_bytes(s
> > >  {
> > >  	u64 start_lba = blk_rq_pos(scmd->request);
> > >  	u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
> > > +	u64 factor = scmd->device->sector_size / 512;
> > >  	u64 bad_lba;
> > >  	int info_valid;
> > >  	/*
> > > @@ -1645,16 +1646,9 @@ static unsigned int sd_completed_bytes(s
> > >  	if (scsi_bufflen(scmd) <= scmd->device->sector_size)
> > >  		return 0;
> > >  
> > > -	if (scmd->device->sector_size < 512) {
> > > -		/* only legitimate sector_size here is 256 */
> > > -		start_lba <<= 1;
> > > -		end_lba <<= 1;
> > > -	} else {
> > > -		/* be careful ... don't want any overflows */
> > > -		unsigned int factor = scmd->device->sector_size / 512;
> > > -		do_div(start_lba, factor);
> > > -		do_div(end_lba, factor);
> > > -	}
> > 
> > Hmm, you do 'unsigned int' -> 'u64' switch of factor type here. But this
> > commit:
> > commit ef80d1e18b014af08741cf688e3fdda1fb71363f
> > Author: Geert Uytterhoeven <geert@linux-m68k.org>
> > Date:   Mon Nov 4 10:21:05 2013 +0100
> > 
> >     [SCSI] sd: Do not call do_div() with a 64-bit divisor
> > 
> > did the switch in the opposite direction deliberately.
> > 
> > So why did you do the change, given sector_size is uint?
> 
> Primarily because no-one spotted the reversal and none of the static
> checkers warns about it.
> 
> This is the trivial fix, but we should do something about the checkers.

Actually, I think there's no problem: all the architectures now have the
correct conversion of the base argument.

Author: Andreas Schwab <schwab@linux-m68k.org>
Date:   Fri Aug 9 15:14:08 2013 +0200

    m68k: Truncate base in do_div()

Fixed this in m68k, which was the last one, so it looks like there's no
issue and ef80d1e18b014af08741cf688e3fdda1fb71363f was pointless.

James


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Patch "sd: Disable support for 256 byte/sector disks" has been added to the 4.0-stable tree
  2015-06-03 13:54     ` James Bottomley
@ 2015-06-03 14:37       ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2015-06-03 14:37 UTC (permalink / raw)
  To: James Bottomley
  Cc: jslaby@suse.cz, linux-scsi@vger.kernel.org, dmarkh@cfl.rr.com,
	hare@suse.de, gregkh@linuxfoundation.org, stable@vger.kernel.org,
	stable-commits@vger.kernel.org

On Wed, Jun 3, 2015 at 3:54 PM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
> On Wed, 2015-06-03 at 13:37 +0000, James Bottomley wrote:
>> On Wed, 2015-06-03 at 11:29 +0200, Jiri Slaby wrote:
>> > On 06/03/2015, 08:35 AM, gregkh@linuxfoundation.org wrote:
>> > > From 74856fbf441929918c49ff262ace9835048e4e6a Mon Sep 17 00:00:00 2001
>> > > From: Mark Hounschell <dmarkh@cfl.rr.com>
>> > > Date: Wed, 13 May 2015 10:49:09 +0200
>> > > Subject: sd: Disable support for 256 byte/sector disks
>> > >
>> > > From: Mark Hounschell <dmarkh@cfl.rr.com>
>> > >
>> > > commit 74856fbf441929918c49ff262ace9835048e4e6a upstream.
>> > >
>> > > 256 bytes per sector support has been broken since 2.6.X,
>> > > and no-one stepped up to fix this.
>> > > So disable support for it.
>> > >
>> > > Signed-off-by: Mark Hounschell <dmarkh@cfl.rr.com>
>> > > Signed-off-by: Hannes Reinecke <hare@suse.de>
>> > > Signed-off-by: James Bottomley <JBottomley@Odin.com>
>> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> > >
>> > > ---
>> > >  drivers/scsi/sd.c |   19 +++++--------------
>> > >  1 file changed, 5 insertions(+), 14 deletions(-)
>> > >
>> > > --- a/drivers/scsi/sd.c
>> > > +++ b/drivers/scsi/sd.c
>> > > @@ -1624,6 +1624,7 @@ static unsigned int sd_completed_bytes(s
>> > >  {
>> > >   u64 start_lba = blk_rq_pos(scmd->request);
>> > >   u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512);
>> > > + u64 factor = scmd->device->sector_size / 512;
>> > >   u64 bad_lba;
>> > >   int info_valid;
>> > >   /*
>> > > @@ -1645,16 +1646,9 @@ static unsigned int sd_completed_bytes(s
>> > >   if (scsi_bufflen(scmd) <= scmd->device->sector_size)
>> > >           return 0;
>> > >
>> > > - if (scmd->device->sector_size < 512) {
>> > > -         /* only legitimate sector_size here is 256 */
>> > > -         start_lba <<= 1;
>> > > -         end_lba <<= 1;
>> > > - } else {
>> > > -         /* be careful ... don't want any overflows */
>> > > -         unsigned int factor = scmd->device->sector_size / 512;
>> > > -         do_div(start_lba, factor);
>> > > -         do_div(end_lba, factor);
>> > > - }
>> >
>> > Hmm, you do 'unsigned int' -> 'u64' switch of factor type here. But this
>> > commit:
>> > commit ef80d1e18b014af08741cf688e3fdda1fb71363f
>> > Author: Geert Uytterhoeven <geert@linux-m68k.org>
>> > Date:   Mon Nov 4 10:21:05 2013 +0100
>> >
>> >     [SCSI] sd: Do not call do_div() with a 64-bit divisor
>> >
>> > did the switch in the opposite direction deliberately.
>> >
>> > So why did you do the change, given sector_size is uint?
>>
>> Primarily because no-one spotted the reversal and none of the static
>> checkers warns about it.
>>
>> This is the trivial fix, but we should do something about the checkers.
>
> Actually, I think there's no problem: all the architectures now have the
> correct conversion of the base argument.
>
> Author: Andreas Schwab <schwab@linux-m68k.org>
> Date:   Fri Aug 9 15:14:08 2013 +0200
>
>     m68k: Truncate base in do_div()
>
> Fixed this in m68k, which was the last one, so it looks like there's no
> issue and ef80d1e18b014af08741cf688e3fdda1fb71363f was pointless.

FWIW, "[PATCH] mn10300: Truncate base in do_div()"
(http://lkml.iu.edu/hypermail/linux/kernel/1308.2/03544.html)
hasn't been applied yet. But as mn10300 is little endian, it shouldn't
suffer from the bug like m68k did.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-03 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <14333133244847@kroah.com>
     [not found] ` <556EC8F4.7030507@suse.cz>
2015-06-03 13:37   ` Patch "sd: Disable support for 256 byte/sector disks" has been added to the 4.0-stable tree James Bottomley
2015-06-03 13:54     ` James Bottomley
2015-06-03 14:37       ` Geert Uytterhoeven

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).