Mailinglist Archive: opensuse-bugs (7818 mails)

< Previous Next >
[Bug 237446] kernel reports too-small size for usb-attached hard disk (usb-storage)
  • From: bugzilla_noreply@xxxxxxxxxx
  • Date: Sat, 3 Feb 2007 14:27:56 -0700 (MST)
  • Message-id: <20070203212756.C433825C887@xxxxxxxxxxxxxxxxxxxxxx>
https://bugzilla.novell.com/show_bug.cgi?id=237446





------- Comment #19 from ag@xxxxxxxxxxxxx 2007-02-03 14:27 MST -------
your patch results in an unresolved symbol in the scsi-hdd module:

WARNING: /lib/modules/2.6.18.2-34-default/kernel/drivers/scsi/sd_mod.ko needs
unknown symbol __umoddi3

i found, that these lines you add to sd.c cause it:

if (sdkp->capacity % (63 * 255))
--sdkp->capacity;

it seems that sdkp->capacity is a 64bit number and so % requires 64bit
arithmetics. i am using a 32bit platform. could it be, that you're developing
on a 64bit platform, and so did not notice this when compiling?

i found, as a suggested fix that <asm/div64.h> defines (do_div() which can be
used on 32bit architectures. but since do_div modifies in place this would not
be very elegant.

also, i noted one other thing. when testing your patch, i was forced to use
another harddisk than the one i had used when reporting the bug since that one
was needed elsewhere, and while the first disk had a number of sectors that
was divisible by 255*63 (it has 78140160 sectors), the new one, a samsung
MP0804H according to specification has 156368016 sectors, which is _not_
divisible by 255*63. so your heuristic would not work for a hard disk like
that.

i am no wizard in hard disk geometry, but the values of 255 heads and 63
sectors/track are a result of LBA, right? looking at the output of several hard
drives, it seems that with LBA, the reported capacity is the actual capacity of
the hard disk. while the number of heads and sectors/track are fixed to 255 and
63, the number of cylinders gets chosen in a way that it fits on the harddisk,
posibly rounding down and decreasing the available size.

for the hitachi drive, the number of sectors was 78140160, which is exactly
255*63*4864 so no rounding was needed. but the samsung has 156368016 sectors,
so
156368016/(255*63) = 9733.4588.. which then gets rounded down to 9733
cylinders, leaving 7371 sectors inacessible.

this is also what fdisk reports (when usb-storage works correctly):

Disk /dev/sda: 80.0 GB, 80060424192 bytes
255 heads, 63 sectors/track, 9733 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

so here, because of the rounding, the capacity does not equal
heads*sectors/track*cylinders.

on the other hand, this also means that this off-by-one problem for the ide/usb
converters only makes a difference, if the real number of sectors actually is
divisible by 63*255 like with the hitachi above, since otherwise the missing
sector would not be available via LBA anyway..

so, following the even/odd-idea i wrote about earlier, i changed your patch for
sd.c into

if ((sdkp->capacity & 0x01))
--sdkp->capacity;

and now the samsung disk is reported correctly (like quoted above).

on the other hand, since my ide/usb converter works ok anyway, this really
doesn't mean much. it would be more interesting to test this patch with a
broken converter.

i'll try to get hold of the hitachi disk again and try that one as well, next
week.

hmmm, i hope i did not get confused somewhere along the way (i probably did,
since much of the stuff about geometry above was more guessing than knowing)
%-}


--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

< Previous Next >