mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: elendil@planet.nl
Cc: bzolnier@gmail.com, sparclinux@vger.kernel.org,
	linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ide-cd: Improve "weird block size" error message
Date: Tue, 23 Jun 2009 03:59:26 -0700 (PDT)	[thread overview]
Message-ID: <20090623.035926.155211513.davem@davemloft.net> (raw)
In-Reply-To: <200906230951.24615.elendil@planet.nl>

From: Frans Pop <elendil@planet.nl>
Date: Tue, 23 Jun 2009 09:51:23 +0200

> In that case I'd like to propose the following patch. Currently the error
> can get printed much to frequently when there's a disc in the drive.
> Example:
> 
> Jun 13 18:06:28 gimli kernel: ide-cd: hdd: weird block size 2352
> Jun 13 18:06:28 gimli kernel: ide-cd: hdd: default to 2kb block size
> Jun 13 18:06:32 gimli kernel: ide-cd: hdd: weird block size 2352
> Jun 13 18:06:42 gimli kernel: ide-cd: hdd: default to 2kb block size

Thinking about this a bit.  Let's look at what problem this is
trying to avoid, as per the commit message:

--------------------
    ide-cd: fix oops when using growisofs
    
    cdrom_read_capacity() will blindly return the capacity from the device
    without sanity-checking it.  This later causes code in fs/buffer.c to
    oops.
    
    Fix this by checking that the device is telling us sensible things.
--------------------

Well, for the values Frans's CDROM is giving, this OOPS would not
take place and the weird sector value is completely harmless.

Since SECTOR_BITS is 9:

(2352 >> 9) == (2048 >> 9) == 4

There is simply no benefit from this warning in this situation.

Therefore, any objections to something like this?

ide-cd: Don't warn on bogus block size unless it actually matters.

Frans Pop reported that his CDROM drive reports a blocksize of 2352,
and this causes new warnings due to commit
e8e7b9eb11c34ee18bde8b7011af41938d1ad667 ("ide-cd: fix oops when using
growisofs").

What we're trying to do is make sure that "blocklen >> SECTOR_BITS"
is something the block layer won't choke on.

And for Frans case "2352 >> SECTOR_BITS" is equal to
"2048 >> SECTOR_BITS", and thats "4".

So warning in this case gives no real benefit.

Reported-by: Frans Pop <elendil@planet.nl>
Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4a19686..a9a1bfb 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -876,9 +876,12 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
 		return stat;
 
 	/*
-	 * Sanity check the given block size
+	 * Sanity check the given block size, in so far as making
+	 * sure the sectors_per_frame we give to the caller won't
+	 * end up being bogus.
 	 */
 	blocklen = be32_to_cpu(capbuf.blocklen);
+	blocklen = (blocklen >> SECTOR_BITS) << SECTOR_BITS;
 	switch (blocklen) {
 	case 512:
 	case 1024:

  parent reply	other threads:[~2009-06-23 10:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200906211446.38598.elendil@planet.nl>
     [not found] ` <20090621.224510.96380426.davem@davemloft.net>
     [not found]   ` <200906220843.14337.elendil@planet.nl>
2009-06-22 11:21     ` cmd64x: irq 14: nobody cared - system is dreadfully slow Bartlomiej Zolnierkiewicz
2009-06-22 14:04       ` Frans Pop
2009-06-22 14:39         ` Bartlomiej Zolnierkiewicz
2009-06-22 15:16           ` Frans Pop
2009-06-22 17:38             ` Bartlomiej Zolnierkiewicz
2009-06-22 19:01               ` Frans Pop
2009-06-22 21:35                 ` Bartlomiej Zolnierkiewicz
2009-06-23  7:51                   ` [PATCH] ide-cd: Improve "weird block size" error message Frans Pop
2009-06-23  7:57                     ` Borislav Petkov
2009-06-23  8:02                       ` Borislav Petkov
2009-06-23 23:03                         ` David Miller
2009-06-23  8:20                       ` Frans Pop
2009-06-23 10:59                     ` David Miller [this message]
2009-06-23 11:13                       ` Frans Pop
2009-06-23 11:18                         ` David Miller
2009-06-23 21:30                       ` Frans Pop
2009-06-23 23:01                         ` David Miller
2009-06-29 11:19                       ` Jan Engelhardt
2009-06-23 10:15                   ` cmd64x: irq 14: nobody cared - system is dreadfully slow David Miller
2009-06-23 14:58                     ` Frans Pop
2009-06-23 16:13                       ` Bartlomiej Zolnierkiewicz
2009-06-23 23:04                         ` David Miller
2009-06-23 10:47                 ` David Miller
2009-06-23 10:43         ` David Miller

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=20090623.035926.155211513.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=bzolnier@gmail.com \
    --cc=elendil@planet.nl \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparclinux@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

all inboxes | Powered by JetHome®