Skip to contentSkip to conversation

./fs/partitions/check.c: off-by-one error ?

DISCUSSION Toralf Förster 4 participants 6 messages Apr 20, 2008 – Apr 28, 2008

lore
Share & tools
lore
#0 lore raw

Inserting an 2 GB SD Card into my digikam and mounting it as an USB drive I've in my system log :

Apr 20 12:27:54 n22 usb 2-2: new full speed USB device using uhci_hcd and address 4
Apr 20 12:27:54 n22 usb 2-2: configuration #1 chosen from 1 choice
Apr 20 12:27:54 n22 SCSI subsystem initialized
Apr 20 12:27:54 n22 Initializing USB Mass Storage driver...
Apr 20 12:27:54 n22 scsi0 : SCSI emulation for USB Mass Storage devices
Apr 20 12:27:54 n22 usbcore: registered new interface driver usb-storage
Apr 20 12:27:54 n22 USB Mass Storage support registered.
Apr 20 12:27:54 n22 usb-storage: device found at 4
Apr 20 12:27:54 n22 usb-storage: waiting for device to settle before scanning
Apr 20 12:27:59 n22 scsi 0:0:0:0: Direct-Access     MATSHITA DMC-TZ3          0100 PQ: 0 ANSI: 2
Apr 20 12:27:59 n22 usb-storage: device scan complete
Apr 20 12:27:59 n22 Driver 'sd' needs updating - please use bus_type methods
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sda: sda1
Apr 20 12:27:59 n22 sda: p1 exceeds device capacity
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Attached SCSI removable disk
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334

My system is a :

tfoerste@n22 ~/devel/linux-2.6/fs/partitions $ uname -a
Linux n22 2.6.24-gentoo-r4 #4 Sun Apr 20 12:16:18 CEST 2008 i686 Intel(R) Pentium(R) M processor 1700MHz GenuineIntel GNU/Linux

I already re-formatted the card under Linux as well as under Windows XP and got always the same behaviour.

Signature · 4 lines
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
#1 lore raw
Quoted 54 lines

Inserting an 2 GB SD Card into my digikam and mounting it as an USB drive I've in my system log :

Apr 20 12:27:54 n22 usb 2-2: new full speed USB device using uhci_hcd and address 4
Apr 20 12:27:54 n22 usb 2-2: configuration #1 chosen from 1 choice
Apr 20 12:27:54 n22 SCSI subsystem initialized
Apr 20 12:27:54 n22 Initializing USB Mass Storage driver...
Apr 20 12:27:54 n22 scsi0 : SCSI emulation for USB Mass Storage devices
Apr 20 12:27:54 n22 usbcore: registered new interface driver usb-storage
Apr 20 12:27:54 n22 USB Mass Storage support registered.
Apr 20 12:27:54 n22 usb-storage: device found at 4
Apr 20 12:27:54 n22 usb-storage: waiting for device to settle before scanning
Apr 20 12:27:59 n22 scsi 0:0:0:0: Direct-Access     MATSHITA DMC-TZ3          0100 PQ: 0 ANSI: 2
Apr 20 12:27:59 n22 usb-storage: device scan complete
Apr 20 12:27:59 n22 Driver 'sd' needs updating - please use bus_type methods
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sda: sda1
Apr 20 12:27:59 n22 sda: p1 exceeds device capacity
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Attached SCSI removable disk
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Quoted 8 lines

My system is a :

tfoerste@n22 ~/devel/linux-2.6/fs/partitions $ uname -a
Linux n22 2.6.24-gentoo-r4 #4 Sun Apr 20 12:16:18 CEST 2008 i686 Intel(R) Pentium(R) M processor 1700MHz GenuineIntel GNU/Linux

I already re-formatted the card under Linux as well as under Windows XP and got always the same behaviour.

This looks more like a strange interaction of your device size (it
claims to have 3902463 sectors) and your partitioning programs which create partition ending at sector 3902464. Can you send the partition table you have on the device? E.g:
fdisk /dev/sda
x
p

will print detailed information about the partition table.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SuSE CR Labs
#2 lore raw
Quoted 70 lines · On Tue, 22 Apr 2008 12:38:29 +0200 Jan Kara wrote:
Quoted 54 lines

Inserting an 2 GB SD Card into my digikam and mounting it as an USB drive I've in my system log :

Apr 20 12:27:54 n22 usb 2-2: new full speed USB device using uhci_hcd and address 4
Apr 20 12:27:54 n22 usb 2-2: configuration #1 chosen from 1 choice
Apr 20 12:27:54 n22 SCSI subsystem initialized
Apr 20 12:27:54 n22 Initializing USB Mass Storage driver...
Apr 20 12:27:54 n22 scsi0 : SCSI emulation for USB Mass Storage devices
Apr 20 12:27:54 n22 usbcore: registered new interface driver usb-storage
Apr 20 12:27:54 n22 USB Mass Storage support registered.
Apr 20 12:27:54 n22 usb-storage: device found at 4
Apr 20 12:27:54 n22 usb-storage: waiting for device to settle before scanning
Apr 20 12:27:59 n22 scsi 0:0:0:0: Direct-Access     MATSHITA DMC-TZ3          0100 PQ: 0 ANSI: 2
Apr 20 12:27:59 n22 usb-storage: device scan complete
Apr 20 12:27:59 n22 Driver 'sd' needs updating - please use bus_type methods
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] 3902463 512-byte hardware sectors (1998 MB)
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Write Protect is off
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Mode Sense: 04 00 00 00
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Assuming drive cache: write through
Apr 20 12:27:59 n22 sda: sda1
Apr 20 12:27:59 n22 sda: p1 exceeds device capacity
Apr 20 12:27:59 n22 sd 0:0:0:0: [sda] Attached SCSI removable disk
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Apr 20 12:27:59 n22 attempt to access beyond end of device
Apr 20 12:27:59 n22 sda: rw=0, want=3902464, limit=3902463
Apr 20 12:27:59 n22 Buffer I/O error on device sda1, logical block 3902334
Quoted 8 lines

My system is a :

tfoerste@n22 ~/devel/linux-2.6/fs/partitions $ uname -a
Linux n22 2.6.24-gentoo-r4 #4 Sun Apr 20 12:16:18 CEST 2008 i686 Intel(R) Pentium(R) M processor 1700MHz GenuineIntel GNU/Linux

I already re-formatted the card under Linux as well as under Windows XP and got always the same behaviour.

This looks more like a strange interaction of your device size (it
claims to have 3902463 sectors) and your partitioning programs which create partition ending at sector 3902464. Can you send the partition table you have on the device? E.g:
fdisk /dev/sda
x
p

Quoted 1 line

will print detailed information about the partition table.

Is this something that using US_FL_FIX_CAPACITY will fix?

US_FL_FIX_CAPACITY -> sets ->fix_capacity, then:

	/* Some devices return the total number of sectors, not the
	 * highest sector number.  Make the necessary adjustment. */
	if (sdp->fix_capacity) {
		--sdkp->capacity;

---
~Randy

#3 lore raw
Quoted 14 lines · Randy Dunlap
Quoted 11 lines · On Tue, 22 Apr 2008 12:38:29 +0200 Jan Kara wrote:
Quoted 2 lines

I already re-formatted the card under Linux as well as under Windows XP and got always the same behaviour.

This looks more like a strange interaction of your device size (it
claims to have 3902463 sectors) and your partitioning programs which create partition ending at sector 3902464. Can you send the partition table you have on the device? E.g:
fdisk /dev/sda
x
p

will print detailed information about the partition table.

Quoted 8 lines

Is this something that using US_FL_FIX_CAPACITY will fix?

US_FL_FIX_CAPACITY -> sets ->fix_capacity, then:

	/* Some devices return the total number of sectors, not the
	 * highest sector number.  Make the necessary adjustment. */
	if (sdp->fix_capacity) {
		--sdkp->capacity;

FIX_CAPACITY will make it worse. The device would appear to have only 3902462 sectors and the partition table will still refer sector 3902464.

The card should be repartitioned as well as reformatted, both under Linux.

Alan Stern

#4 lore raw
In reply to Jan Kara
Quoted 10 lines · At Tuesday 22 April 2008 12:38:29 Jan Kara wrote :

  This looks more like a strange interaction of your device size (it claims to have 3902463 sectors) and your partitioning programs which create partition ending at sector 3902464. Can you send the partition table you have on the device? E.g:
  fdisk /dev/sda
  x
  p

  will print detailed information about the partition table.

n22 ~ # fdisk /dev/sda

The number of cylinders for this disk is set to 1267. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): x

Expert command (m for help): p

Disk /dev/sda: 56 heads, 55 sectors, 1267 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
 1 00   2   4    0  55  55  967        129    3902335 06
 2 00   0   0    0   0   0    0          0          0 00
 3 00   0   0    0   0   0    0          0          0 00
 4 00   0   0    0   0   0    0          0          0 00

Expert command (m for help): q

n22 ~ # fdisk -l /dev/sda

Disk /dev/sda: 1998 MB, 1998061056 bytes
56 heads, 55 sectors/track, 1267 cylinders
Units = cylinders of 3080 * 512 = 1576960 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 1 1268 1951167+ 6 FAT16

I deleted +created the partition both manually and by the digikam but w/o success...

Signature · 4 lines
MfG/Sincerely

Toralf Förster
pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6 9DA3
#5 lore raw
Quoted 42 lines · Toralf Förster
Quoted 10 lines · At Tuesday 22 April 2008 12:38:29 Jan Kara wrote :

  This looks more like a strange interaction of your device size (it claims to have 3902463 sectors) and your partitioning programs which create partition ending at sector 3902464. Can you send the partition table you have on the device? E.g:
  fdisk /dev/sda
  x
  p

  will print detailed information about the partition table.

n22 ~ # fdisk /dev/sda

The number of cylinders for this disk is set to 1267. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): x

Expert command (m for help): p

Disk /dev/sda: 56 heads, 55 sectors, 1267 cylinders

Nr AF  Hd Sec  Cyl  Hd Sec  Cyl     Start      Size ID
 1 00   2   4    0  55  55  967        129    3902335 06
 2 00   0   0    0   0   0    0          0          0 00
 3 00   0   0    0   0   0    0          0          0 00
 4 00   0   0    0   0   0    0          0          0 00

Expert command (m for help): q

n22 ~ # fdisk -l /dev/sda

Disk /dev/sda: 1998 MB, 1998061056 bytes
56 heads, 55 sectors/track, 1267 cylinders
Units = cylinders of 3080 * 512 = 1576960 bytes
Disk identifier: 0x00000000

Quoted 5 lines

Device Boot Start End Blocks Id System
/dev/sda1 1 1268 1951167+ 6 FAT16

I deleted +created the partition both manually and by the digikam but w/o success...

Hmm, ok. This doesn't look like a kernel bug. At least if you created the
partition table in linux by fdisk (or some other partitioning program), it should have created the partition one sector shorter. So please report this as a bug of the partitioning program. Thanks.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR