From: James Bottomley <James.Bottomley@SteelEye.com>
To: brking@us.ibm.com
Cc: Matthew Wilcox <matthew@wil.cx>,
SCSI Mailing List <linux-scsi@vger.kernel.org>,
dwmw2@infradead.org
Subject: Re: [PATCH 1/1] scsicam_getgeo_odd_sector_size
Date: 13 Oct 2004 16:37:36 -0500 [thread overview]
Message-ID: <1097703463.2027.248.camel@mulgrave> (raw)
In-Reply-To: <416D8815.4010808@us.ibm.com>
On Wed, 2004-10-13 at 14:55, Brian King wrote:
> James Bottomley wrote:
> > How does the attached work for you?
>
> Not very well. It looks like it blows up in create_buffers() with this patch.
> Since the block size (522) is not a multiple of the host page size, we end up
> decrementing offset to a negative number in create_buffers, which then hits a BUG()
> in set_bh_page. It looks to me like the block layer assumes the device block size
> is a multiple of PAGE_SIZE, in more than one place. Here is the latest backtrace:
OK it seems that we get to bogus block size confusion before we see the
device's zero size. The least nasty fix seems to be to set a power of
two blocksize as well as zeroing the capacity for this problem.
How does the attached fare?
James
===== drivers/scsi/sd.c 1.160 vs edited =====
--- 1.160/drivers/scsi/sd.c 2004-09-19 11:55:03 -05:00
+++ edited/drivers/scsi/sd.c 2004-10-13 16:29:37 -05:00
@@ -1125,6 +1125,13 @@
* For this reason, we leave the thing in the table.
*/
sdkp->capacity = 0;
+ /*
+ * set a bogus sector size so the normal read/write
+ * logic in the block layer will eventually refuse any
+ * request on this device without tripping over power
+ * of two sector size assumptions
+ */
+ sector_size = 512;
}
{
/*
===== drivers/scsi/scsicam.c 1.16 vs edited =====
--- 1.16/drivers/scsi/scsicam.c 2004-06-19 09:45:02 -05:00
+++ edited/drivers/scsi/scsicam.c 2004-10-13 10:38:25 -05:00
@@ -29,10 +29,11 @@
unsigned char *res = kmalloc(66, GFP_KERNEL);
if (res) {
struct block_device *bdev = dev->bd_contains;
- struct buffer_head *bh = __bread(bdev, 0, block_size(bdev));
- if (bh) {
- memcpy(res, bh->b_data + 0x1be, 66);
- brelse(bh);
+ Sector sect;
+ void *data = read_dev_sector(bdev, 0, §);
+ if (data) {
+ memcpy(res, data + 0x1be, 66);
+ put_dev_sector(sect);
} else {
kfree(res);
res = NULL;
next prev parent reply other threads:[~2004-10-13 21:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-19 23:02 [PATCH 1/1] scsicam_getgeo_odd_sector_size brking
2004-10-13 14:01 ` Brian King
2004-10-13 14:04 ` Matthew Wilcox
2004-10-13 14:25 ` Brian King
2004-10-13 15:45 ` James Bottomley
2004-10-13 19:55 ` Brian King
2004-10-13 21:37 ` James Bottomley [this message]
2004-10-13 22:57 ` Brian King
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=1097703463.2027.248.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=brking@us.ibm.com \
--cc=dwmw2@infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=matthew@wil.cx \
/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