Skip to contentSkip to conversation

2.4.9: strange stale buffers when reading partition table (USB/SCSI)

DISCUSSION Jeremy Fitzhardinge 2 participants 2 messages Sep 27, 2001

lore
Share & tools
lore
#0 lore raw

I have a Sony DSC F505V digital camera, which allows you to download images by presenting itself as a USB storage device containing a single partition with a FAT filesystem on it.

The camera is detected by USB, and SCSI will talk to it, but it fails to find the partition table. I added some code after the bread() in fs/partitions/msdos.c:443 to dump the read data, which shows that it is getting garbage. It has relation to anything on the actual device, and it changes from time to time.

The strange thing is that reading the device via /dev/sda works fine. fdisk shows a valid partition table, and the partition itself looks fine.

If I add:

        bh = getblk(dev, 0, get_ptable_blocksize(dev));
        if (bh)
                bforget(bh);

just before the bread(), the bread gets the correct stuff and can read the partition table. Everything works fine from there on:

hub.c: USB new device connect on bus1/1, assigned device number 2 scsi0 : SCSI emulation for USB Mass Storage devices
Vendor: Sony Model: Sony DSC Rev: 2.10
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0 SCSI device sda: 253696 512-byte hdwr sectors (130 MB) usb-uhci.c: interrupt, status 3, frame# 207
usb-uhci.c: interrupt, status 3, frame# 213
sda: Write Protect is off
/dev/scsi/host0/bus0/target0/lun0: p1
WARNING: USB Mass Storage data integrity not assured USB Mass Storage device found at 2
scsi singledevice 0 0 0 0
usb-uhci.c: interrupt, status 3, frame# 48
...

So it looks like someone is leaking buffers or something. The bforget() looks like its simply papering over the symptoms of some other problem, but I don't know where to start looking. Perhaps there's a SCSI problem which is leaving stale blocks around, perhaps related to it being a removeable device?

This is 2.4.9-linus with ext3 (though plain 2.4.9 without ext3 behaves in exactly the same way).

I haven't tried 2.4.10 yet, but it sounds like everything has changed in this area anyway...

J

#1 lore raw
Quoted 3 lines · Jeremy Fitzhardinge

This is 2.4.9-linus with ext3

Handy. You can enable ext3's buffer tracing, then add a

	print_buffer_trace(bh);

to the buffer to find out where it has been.

If that doesn't provide enough info then add more BUFFER_TRACE() calls in strategic places.

-