linux-stable/include/scsi
Linus Torvalds 7b3d9545f9 Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done""
This reverts commit ac40532ef0, which gets
us back the original cleanup of 6f5391c283.

It turns out that the bug that was triggered by that commit was
apparently not actually triggered by that commit at all, and just the
testing conditions had changed enough to make it appear to be due to it.

The real problem seems to have been found by Peter Osterlund:

  "pktcdvd sets it [block device size] when opening the /dev/pktcdvd
   device, but when the drive is later opened as /dev/scd0, there is
   nothing that sets it back.  (Btw, 40944 is possible if the disk is a
   CDRW that was formatted with "cdrwtool -m 10236".)

   The problem is that pktcdvd opens the cd device in non-blocking mode
   when pktsetup is run, and doesn't close it again until pktsetup -d is
   run.  The effect is that if you meanwhile open the cd device,
   blkdev.c:do_open() doesn't call bd_set_size() because
   bdev->bd_openers is non-zero."

In particular, to repeat the bug (regardless of whether commit
6f5391c283 is applied or not):

  " 1. Start with an empty drive.
    2. pktsetup 0 /dev/scd0
    3. Insert a CD containing an isofs filesystem.
    4. mount /dev/pktcdvd/0 /mnt/tmp
    5. umount /mnt/tmp
    6. Press the eject button.
    7. Insert a DVD containing a non-writable filesystem.
    8. mount /dev/scd0 /mnt/tmp
    9. find /mnt/tmp -type f -print0 | xargs -0 sha1sum >/dev/null
    10. If the DVD contains data beyond the physical size of a CD, you
        get I/O errors in the terminal, and dmesg reports lots of
        "attempt to access beyond end of device" errors."

which in turn is because the nested open after the media change won't
cause the size to be set properly (because the original open still holds
the block device, and we only do the bd_set_size() when we don't have
other people holding the device open).

The proper fix for that is probably to just do something like

	bdev->bd_inode->i_size = (loff_t)get_capacity(disk)<<9;

in fs/block_dev.c:do_open() even for the cases where we're not the
original opener (but *not* call bd_set_size(), since that will also
change the block size of the device).

Cc: Peter Osterlund <petero2@telia.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-01-06 10:17:12 -08:00
..
iscsi_if.h [SCSI] iscsi class, iscsi_tcp, iser, qla4xxx: add netdevname sysfs attr 2007-06-02 15:38:04 -04:00
iscsi_proto.h [SCSI] iscsi: rename DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH 2007-03-11 11:26:50 -05:00
libiscsi.h [SCSI] libiscsi: sync up iscsi and scsi eh's access to the connection 2007-08-15 13:09:21 -05:00
libsas.h cleanup asm/scatterlist.h includes 2007-11-02 08:47:06 +01:00
libsrp.h [SCSI] tgt: convert libsrp and ibmvstgt to use srp_transport 2007-10-12 14:37:57 -04:00
sas.h [SCSI] aci94xx: implement link rate setting 2006-09-07 15:20:23 -05:00
sas_ata.h [SCSI] libsas: make ATA functions selectable by a config option 2007-07-22 13:23:13 -05:00
scsi.h SCSI: support for allocating large scatterlists 2007-10-16 11:12:53 +02:00
scsi_cmnd.h Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done"" 2008-01-06 10:17:12 -08:00
scsi_dbg.h [SCSI] Fix device not ready printk 2007-10-12 14:51:56 -04:00
scsi_device.h esp_scsi: fix reset cleanup spinlock recursion 2007-12-10 19:43:55 -08:00
scsi_devinfo.h
scsi_driver.h Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done"" 2008-01-06 10:17:12 -08:00
scsi_eh.h [SCSI] include linux/scatterlist.h in scsi_eh.h 2007-10-17 21:53:56 -04:00
scsi_host.h [SCSI] add use_sg_chaining option to scsi_host_template 2007-10-16 11:24:32 +02:00
scsi_ioctl.h
scsi_netlink.h [SCSI] SCSI & FC transport: extend event vendor id's to 64bits 2006-09-02 15:35:15 -05:00
scsi_netlink_fc.h [SCSI] SCSI & FC transport: extend event vendor id's to 64bits 2006-09-02 15:35:15 -05:00
scsi_tcq.h [PATCH] helper function for retrieving scsi_cmd given host based block layer tag 2006-10-04 19:32:09 +02:00
scsi_tgt.h [SCSI] tgt: add I_T nexus support 2007-10-12 14:37:50 -04:00
scsi_tgt_if.h [SCSI] tgt: add I_T nexus support 2007-10-12 14:37:50 -04:00
scsi_transport.h [SCSI] tgt: move tsk_mgmt_response callback to transport class 2007-10-12 14:38:01 -04:00
scsi_transport_fc.h [SCSI] fc_transport: add target driver support 2007-10-12 14:46:58 -04:00
scsi_transport_iscsi.h [SCSI] scsi_transport_iscsi: add list, mutex includes 2007-10-12 14:54:38 -04:00
scsi_transport_sas.h [SCSI] scsi_transport_sas: add destructor for bsg 2007-07-20 12:29:07 -05:00
scsi_transport_spi.h [SCSI] spi transport class: export spi_dv_pending 2007-02-02 20:44:25 -06:00
scsi_transport_srp.h [SCSI] tgt: move tsk_mgmt_response callback to transport class 2007-10-12 14:38:01 -04:00
scsicam.h
sd.h Revert "scsi: revert "[SCSI] Get rid of scsi_cmnd->done"" 2008-01-06 10:17:12 -08:00
sg.h [SCSI] sg: fixes for large page_size 2006-09-26 09:23:15 -07:00
srp.h [SCSI] srp.h: Add I/O Class values 2006-06-17 20:37:38 -07:00