libata: device suspend/resume
Subsystems (10)
PATCH 1/1 libata: device suspend/resume
Patch 2/2 for review by the linux-scsi crowd.
Please do not apply.
Patch is via Mark Lord,
It's not ready for upstream, but I am posting it for two reasons:
1) People might find the feature useful (warning warning do not use in production, just a test feature, might cook your hard drive and all your data, standard disclaimer...)
2) Get comments from linux-scsi folks about the SCSI changes.
drivers/scsi/ahci.c (mode:100644) renamed from drivers/scsi/ahci.c (mode:100644 sha1:da5bd33d982d7e521b6b0603adcb0911395b184d) +4 -0
@@ -201,6 +201,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations ahci_ops = {
@@ -272,6 +274,8 @@ .id_table = ahci_pci_tbl, .probe = ahci_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, };
drivers/scsi/ata_piix.c (mode:100644) renamed from drivers/scsi/ata_piix.c (mode:100644 sha1:3867f91ef8c7bebe3d0edf0bd2e3b326a1d4061b) +4 -0
@@ -104,6 +104,8 @@ .id_table = piix_pci_tbl, .probe = piix_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template piix_sht = {
@@ -124,6 +126,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations piix_pata_ops = {
drivers/scsi/libata-core.c (mode:100644) renamed from drivers/scsi/libata-core.c (mode:100644 sha1:0b5d3a5b7edab5ce17889a0e698805ce346b4d1a) +122 -0
138 lines not on this page · raw message
drivers/scsi/libata-scsi.c (mode:100644) renamed from drivers/scsi/libata-scsi.c (mode:100644 sha1:4c96df060c3bad9af44ab4c4664d8cba38c63030) +16 -0
@@ -387,6 +387,22 @@ return 0; } +int ata_scsi_device_resume(struct scsi_device *sdev) +{ + struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; + struct ata_device *dev = &ap->device[sdev->id]; + + return ata_device_resume(ap, dev); +} + +int ata_scsi_device_suspend(struct scsi_device *sdev) +{ + struct ata_port *ap = (struct ata_port *) &sdev->host->hostdata[0]; + struct ata_device *dev = &ap->device[sdev->id]; + + return ata_device_suspend(ap, dev); +} + /** * ata_scsi_flush_xlat - Translate SCSI SYNCHRONIZE CACHE command * @qc: Storage for translated ATA taskfile
drivers/scsi/sata_nv.c (mode:100644) renamed from drivers/scsi/sata_nv.c (mode:100644 sha1:69009f853a4917f54a88aa0c2cf3e6fb0428c8f7) +4 -0
@@ -187,6 +187,8 @@ .id_table = nv_pci_tbl, .probe = nv_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template nv_sht = {
@@ -207,6 +209,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations nv_ops = {
drivers/scsi/sata_promise.c (mode:100644) renamed from drivers/scsi/sata_promise.c (mode:100644 sha1:19a13e3590f4eca5fab24675ffec12aaa56dd57f) +4 -0
@@ -103,6 +103,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations pdc_ata_ops = {
@@ -178,6 +180,8 @@ .id_table = pdc_ata_pci_tbl, .probe = pdc_ata_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, };
drivers/scsi/sata_qstor.c (mode:100644) renamed from drivers/scsi/sata_qstor.c (mode:100644 sha1:dfd3621047171dc748ba9a11c82a418f89faaed6) +4 -0
@@ -140,6 +140,8 @@ .dma_boundary = QS_DMA_BOUNDARY, .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations qs_ata_ops = {
@@ -191,6 +193,8 @@ .id_table = qs_ata_pci_tbl, .probe = qs_ata_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static int qs_check_atapi_dma(struct ata_queued_cmd *qc)
drivers/scsi/sata_sil.c (mode:100644) renamed from drivers/scsi/sata_sil.c (mode:100644 sha1:f0489dc302a03054d6461ba54c9705f30190a8f4) +4 -0
@@ -115,6 +115,8 @@ .id_table = sil_pci_tbl, .probe = sil_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template sil_sht = {
@@ -135,6 +137,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations sil_ops = {
drivers/scsi/sata_sis.c (mode:100644) renamed from drivers/scsi/sata_sis.c (mode:100644 sha1:5105ddd08447807df3710492f70c31bf6f0d8767) +4 -0
@@ -71,6 +71,8 @@ .id_table = sis_pci_tbl, .probe = sis_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template sis_sht = {
@@ -91,6 +93,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations sis_ops = {
drivers/scsi/sata_svw.c (mode:100644) renamed from drivers/scsi/sata_svw.c (mode:100644 sha1:8d1a5d25c05364e41e7f98198b94335ed30d0046) +4 -0
@@ -289,6 +289,8 @@ #endif .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, };
@@ -458,6 +460,8 @@ .id_table = k2_sata_pci_tbl, .probe = k2_sata_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, };
drivers/scsi/sata_sx4.c (mode:100644) renamed from drivers/scsi/sata_sx4.c (mode:100644 sha1:70118650c461e9d5d10ff0c3053ae5b49c6755a0) +4 -0
@@ -189,6 +189,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations pdc_20621_ops = {
@@ -235,6 +237,8 @@ .id_table = pdc_sata_pci_tbl, .probe = pdc_sata_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, };
drivers/scsi/sata_uli.c (mode:100644) renamed from drivers/scsi/sata_uli.c (mode:100644 sha1:0bff4f475f262c5c40254aecf85bd6a7137bd04e) +4 -0
@@ -63,6 +63,8 @@ .id_table = uli_pci_tbl, .probe = uli_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template uli_sht = {
@@ -83,6 +85,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations uli_ops = {
drivers/scsi/sata_via.c (mode:100644) renamed from drivers/scsi/sata_via.c (mode:100644 sha1:3a7830667277f35f71a83db5705b8cb2d376bafc) +4 -0
@@ -83,6 +83,8 @@ .id_table = svia_pci_tbl, .probe = svia_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, }; static Scsi_Host_Template svia_sht = {
@@ -103,6 +105,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, }; static struct ata_port_operations svia_sata_ops = {
drivers/scsi/sata_vsc.c (mode:100644) renamed from drivers/scsi/sata_vsc.c (mode:100644 sha1:2c28f0ad73c204420aa4b419a60341a8b801d7fa) +4 -0
@@ -206,6 +206,8 @@ .slave_configure = ata_scsi_slave_config, .bios_param = ata_std_bios_param, .ordered_flush = 1, + .resume = ata_scsi_device_resume, + .suspend = ata_scsi_device_suspend, };
@@ -382,6 +384,8 @@ .id_table = vsc_sata_pci_tbl, .probe = vsc_sata_init_one, .remove = ata_pci_remove_one, + .suspend = ata_pci_device_suspend, + .resume = ata_pci_device_resume, };
drivers/scsi/scsi_lib.c (mode:100644) renamed from drivers/scsi/scsi_lib.c (mode:100644 sha1:d18da21c9c57e0ef590369ea815b7b1adba4042b) +2 -1
@@ -1855,8 +1855,9 @@ void scsi_device_resume(struct scsi_device *sdev) { - if(scsi_device_set_state(sdev, SDEV_RUNNING)) + if (scsi_device_set_state(sdev, SDEV_RUNNING)) return; + scsi_run_queue(sdev->request_queue); } EXPORT_SYMBOL(scsi_device_resume);
drivers/scsi/scsi_sysfs.c (mode:100644) renamed from drivers/scsi/scsi_sysfs.c (mode:100644 sha1:e75ee4671ee3a0a6dcb608a73d6bd2f4007eff09) +31 -0
@@ -199,9 +199,40 @@ return (sdp->inq_periph_qual == SCSI_INQ_PQ_CON)? 1: 0; } +static int scsi_bus_suspend(struct device * dev, pm_message_t state) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_host_template *sht = sdev->host->hostt; + int err; + + err = scsi_device_quiesce(sdev); + if (err) + return err; + + if (sht->suspend) + err = sht->suspend(sdev); + + return err; +} + +static int scsi_bus_resume(struct device * dev) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct scsi_host_template *sht = sdev->host->hostt; + int err = 0; + + if (sht->resume) + err = sht->resume(sdev); + + scsi_device_resume(sdev); + return err; +} + struct bus_type scsi_bus_type = { .name = "scsi", .match = scsi_bus_match, + .suspend = scsi_bus_suspend, + .resume = scsi_bus_resume, }; int scsi_sysfs_register(void)
include/linux/ata.h (mode:100644) renamed from include/linux/ata.h (mode:100644 sha1:f178894edd04f954a4f650661175b5fe009011c6) +2 -0
@@ -125,6 +125,8 @@ ATA_CMD_PACKET = 0xA0, ATA_CMD_VERIFY = 0x40, ATA_CMD_VERIFY_EXT = 0x42, + ATA_CMD_STANDBYNOW1 = 0xE0, + ATA_CMD_IDLEIMMEDIATE = 0xE1, /* SETFEATURES stuff */ SETFEATURES_XFER = 0x03,
include/linux/libata.h (mode:100644) renamed from include/linux/libata.h (mode:100644 sha1:505160ab472b0198ec5393380ce7c21b2fad85d1) +7 -0
@@ -113,6 +113,7 @@ ATA_FLAG_MMIO = (1 << 6), /* use MMIO, not PIO */ ATA_FLAG_SATA_RESET = (1 << 7), /* use COMRESET */ ATA_FLAG_PIO_DMA = (1 << 8), /* PIO cmds via DMA */ + ATA_FLAG_SUSPENDED = (1 << 9), /* port is suspended */ ATA_QCFLAG_ACTIVE = (1 << 1), /* cmd not yet ack'd to scsi lyer */ ATA_QCFLAG_SG = (1 << 3), /* have s/g table? */
@@ -387,6 +388,8 @@ extern int ata_pci_init_one (struct pci_dev *pdev, struct ata_port_info **port_info, unsigned int n_ports); extern void ata_pci_remove_one (struct pci_dev *pdev); +extern int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t state); +extern int ata_pci_device_resume(struct pci_dev *pdev); #endif /* CONFIG_PCI */ extern int ata_device_add(struct ata_probe_ent *ent); extern int ata_scsi_detect(Scsi_Host_Template *sht);
@@ -395,6 +398,10 @@ extern int ata_scsi_error(struct Scsi_Host *host); extern int ata_scsi_release(struct Scsi_Host *host); extern unsigned int ata_host_intr(struct ata_port *ap, struct ata_queued_cmd *qc); +extern int ata_scsi_device_resume(struct scsi_device *); +extern int ata_scsi_device_suspend(struct scsi_device *); +extern int ata_device_resume(struct ata_port *, struct ata_device *); +extern int ata_device_suspend(struct ata_port *, struct ata_device *); /* * Default driver ops implementations */
include/scsi/scsi_host.h (mode:100644) renamed from include/scsi/scsi_host.h (mode:100644 sha1:1cee1e100943dafe00c14d5329b73659062a4d1a) +6 -0
@@ -270,6 +270,12 @@ int (*proc_info)(struct Scsi_Host *, char *, char **, off_t, int, int); /* + * suspend support + */ + int (*resume)(struct scsi_device *); + int (*suspend)(struct scsi_device *); + + /* * Name of proc directory */ char *proc_name;
Quoted 1 line · Jeff Garzik
Patch is via Mark Lord,
Um, it is? it looks identical to this one from Jens (down to the gratuitous style corrections)
http://marc.theaimsgroup.com/?t=111409327100001
However, before anything happens I'd like to get the SCSI pieces correct. The thread petered out before a resolution, however, I think at least disk devices should be doing a synchronize cache on suspend.
James
Quoted 7 lines · James Bottomley
Quoted 1 line · Jeff Garzik
Patch is via Mark Lord,
Um, it is? it looks identical to this one from Jens (down to the gratuitous style corrections)
Got it "via" Mark Lord; I didn't know the proper attribution.
Quoted 2 lines
However, before anything happens I'd like to get the SCSI pieces correct.
The "anything" I want to happen here is getting the SCSI pieces correct ;-)
Quoted 2 lines
The thread petered out before a resolution, however, I think at least disk devices should be doing a synchronize cache on suspend.
Agreed.
Jeff
Quoted 5 lines · Jeff Garzik
Quoted 2 lines · James Bottomley
The thread petered out before a resolution, however, I think at least disk devices should be doing a synchronize cache on suspend.
Agreed.
OK, try this as a straw horse. It plumbs our scsi bus model into suspend and resume via the driver (which would be the ULD) function. The only ULD which has an extra function is sd, and all it does is synchronize the cache if it was writeback. I believe you translate SYNC CACHE in libata, so this patch should be sufficient (unless we still have a problem with ATA devices that lie about their cache types?)
I think this is sufficient, because if the LLD also wants this information, it can get it from the model of the bus it's attached to.
James
drivers/scsi/scsi_sysfs.c +52 -2
@@ -199,10 +200,37 @@ static int scsi_bus_match(struct devicereturn (sdp->inq_periph_qual ==SCSI_INQ_PQ_CON )?1 :0 ; } +static int scsi_bus_suspend (struct device *dev,pm_message_t state) +{ +struct scsi_device *sdev =to_scsi_device (dev); +int err =scsi_device_quiesce (sdev); + +if (err) +return err; + +if (dev->driver && dev->driver->suspend) +return dev->driver->suspend (dev, state,0 ); +return 0 ; +} + +static int scsi_bus_resume (struct device *dev) +{ +struct scsi_device *sdev =to_scsi_device (dev); +int err =0 ; + +if (dev->driver && dev->driver->resume) + err = dev->driver->resume (dev,0 ); + +scsi_device_resume (sdev); +return err; +} +struct bus_type scsi_bus_type = { .name ="scsi" , .match = scsi_bus_match, + .suspend = scsi_bus_suspend, + .resume = scsi_bus_resume }; int scsi_sysfs_register(void) --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c
@@ -119,6 +119,7 @@ static void sd_rw_intr(struct scsi_cmndstatic int sd_probe (struct device *);static int sd_remove (struct device *);static void sd_shutdown (struct device *dev); +static int sd_suspend (struct device *dev,pm_message_t state,u32 level);static void sd_rescan (struct device *);static int sd_init_command (struct scsi_cmnd *);static int sd_issue_flush (struct device *,sector_t *);
@@ -134,6 +135,7 @@ static struct scsi_driver sd_template = .probe = sd_probe, .remove = sd_remove, .shutdown = sd_shutdown, + .suspend = sd_suspend, }, .rescan = sd_rescan, .init_command = sd_init_command,
@@ -1710,7 +1712,28 @@ static void sd_shutdown(struct device *dprintk (KERN_NOTICE "Synchronizing SCSI cache for disk %s: \n" , sdkp->disk->disk_name);sd_sync_cache (sdp); -} +} + +/* Just quietly quiesce the device and SYNCHRONIZE CACHE for suspend too */ +static int sd_suspend (struct device *dev,pm_message_t state,u32 level) +{ +struct scsi_device *sdp =to_scsi_device (dev); +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +if (!sdkp) +return 0 ;/* this can happen */ + +if (!sdkp->WCE) +return 0 ; + +/* don't try to sync an offline device ... it will only error */ +if (!scsi_device_online (sdp)) +return 0 ; + +if (sd_sync_cache (sdp)) +return -EIO ; +return 0 ; +}/** * init_sd - entry point for this driver (both when built in or when
Quoted 14 lines · James Bottomley
Quoted 5 lines · Jeff Garzik
Quoted 2 lines · James Bottomley
The thread petered out before a resolution, however, I think at least disk devices should be doing a synchronize cache on suspend.
Agreed.
OK, try this as a straw horse. It plumbs our scsi bus model into suspend and resume via the driver (which would be the ULD) function. The only ULD which has an extra function is sd, and all it does is synchronize the cache if it was writeback. I believe you translate SYNC CACHE in libata, so this patch should be sufficient (unless we still have a problem with ATA devices that lie about their cache types?)
Quoted 2 lines
I think this is sufficient, because if the LLD also wants this information, it can get it from the model of the bus it's attached to.
suspend/resume is a lot more complicated than just flushing a cache, the below will probably get you safe asleep but you will never get devices alive again after power-up on suspend-to-ram.
I also greatly prefer issuing a standby command to the drive after the flush, so that we don't risk using the emergency parks of the drive. If a drive happens to lie about wrt the flush command, it gets an extra chance to flush the cache as it now knows that power will be gone very soon. So I think the ->suspend/->resume hooks should belong to the LLD, not the ULD as the ULD has no idea how to suspend all devices types.
Signature · 1 line
Jens Axboe
Quoted 10 lines · Jens Axboe
suspend/resume is a lot more complicated than just flushing a cache, the below will probably get you safe asleep but you will never get devices alive again after power-up on suspend-to-ram.
I also greatly prefer issuing a standby command to the drive after the flush, so that we don't risk using the emergency parks of the drive. If a drive happens to lie about wrt the flush command, it gets an extra chance to flush the cache as it now knows that power will be gone very soon. So I think the ->suspend/->resume hooks should belong to the LLD, not the ULD as the ULD has no idea how to suspend all devices types.
You are right about issuing the standby command after flush. I don't think an LLD hook is the proper way to accomplish it, however.
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Jeff
Jeff Garzik wrote:
[ .. ]
Quoted 5 lines
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
Quoted 8 lines
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Divorced from SCSI? Care to elaborate?
Cheers,
Hannes
Signature · 8 lines
Dr. Hannes Reinecke [email protected] SuSE Linux AG S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Jeff Garzik
Quoted 10 lines · Jens Axboe
suspend/resume is a lot more complicated than just flushing a cache, the below will probably get you safe asleep but you will never get devices alive again after power-up on suspend-to-ram.
I also greatly prefer issuing a standby command to the drive after the flush, so that we don't risk using the emergency parks of the drive. If a drive happens to lie about wrt the flush command, it gets an extra chance to flush the cache as it now knows that power will be gone very soon. So I think the ->suspend/->resume hooks should belong to the LLD, not the ULD as the ULD has no idea how to suspend all devices types.
Quoted 7 lines
You are right about issuing the standby command after flush. I don't think an LLD hook is the proper way to accomplish it, however.
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
That sounds fine!
Quoted 4 lines
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
Quoted 8 lines
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
Signature · 1 line
Jens Axboe
Quoted 10 lines · Hannes Reinecke
Jeff Garzik wrote:
[ .. ]Quoted 8 lines
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
Quoted 7 lines
Quoted 5 lines
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Divorced from SCSI? Care to elaborate?
libata being a scsi citizen was just a temporary solution, Jeff has promised to turn it into a real block driver for years :)
Signature · 1 line
Jens Axboe
Quoted 4 lines · Jens Axboe
Quoted 1 line · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
hehe, nope. I promised Linus, and I plan to keep my promise :)
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
Bart even hinted at possibly using libata-without-SCSI for future /dev/hdX support. It's certainly doable.
Jeff
Quoted 8 lines · Jeff Garzik
Quoted 5 lines · Jens Axboe
Quoted 2 lines · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
hehe, nope. I promised Linus, and I plan to keep my promise :)
You promised me, too :)
Quoted 2 lines
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
We should start a list of items that could potentially be moved to the block layer that libata currently uses.
Quoted 5 lines
Bart even hinted at possibly using libata-without-SCSI for future
/dev/hdXsupport. It's certainly doable.From my point of view, I think it would be a good way to kick off
/dev/disk device agnostic mappings.
Signature · 1 line
Jens Axboe
Quoted 7 lines · Jeff Garzik
Quoted 5 lines · Jens Axboe
Quoted 2 lines · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
Quoted 8 lines
hehe, nope. I promised Linus, and I plan to keep my promise :)
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
Bart even hinted at possibly using libata-without-SCSI for future
/dev/hdXsupport. It's certainly doable.
AAArgh! No, not again!
We've finally succeeded in convincing everyone that having '/dev/sdX' instead of '/dev/hdX' was a neccessary step forward.
I think we're getting shot if we now tell them to reverse this _again_. Can we at least have it optional?
Or are you talking about linux-3.X ?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke [email protected] SuSE Linux AG S390 & zSeries Maxfeldstraße 5 +49 911 74053 688 90409 Nürnberg http://www.suse.de
Quoted 16 lines · Hannes Reinecke
Quoted 7 lines · Jeff Garzik
Quoted 5 lines · Jens Axboe
Quoted 2 lines · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
Quoted 8 lines
hehe, nope. I promised Linus, and I plan to keep my promise :)
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
Bart even hinted at possibly using libata-without-SCSI for future
/dev/hdXsupport. It's certainly doable.
Quoted 6 lines
AAArgh! No, not again!
We've finally succeeded in convincing everyone that having '
/dev/sdX' instead of '/dev/hdX' was a neccessary step forward.
I think we're getting shot if we now tell them to reverse this _again_. Can we at least have it optional?
Moving to /dev/sdX was never a step forward, it's was merely a necessary side ways step because libata used the scsi layer. A step forward would be device agnostic /dev/disk mappings instead.
Quoted 1 line
Or are you talking about linux-3.X ?
Hopefully before that :-)
Signature · 1 line
Jens Axboe
Quoted 10 lines · Hannes Reinecke
Jeff Garzik wrote:
[ .. ]Quoted 7 lines
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
Quoted 8 lines
Quoted 5 lines
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Divorced from SCSI? Care to elaborate?
General Linux thesis: translation and emulation are lame. Adds needless overhead. One should write a "bare metal" driver.
libata should be able to export a native block driver for ATA devices, making libata-scsi.c simply an optional "T10 SAT implementation" that users can retain for compatibility and certain features, or excise for lower overhead.
As ATAPI is converging with SCSI MMC -- the two committes are actively aligning the standards -- I would prefer to handle ATAPI devices through the SCSI layer.
Jeff
Quoted 4 lines · Hannes Reinecke
We've finally succeeded in convincing everyone that having '
/dev/sdX' instead of '/dev/hdX' was a neccessary step forward.
I think we're getting shot if we now tell them to reverse this _again_. Can we at least have it optional?
I will not break compatibility with /dev/sdX, don't worry :)
It will always be there as an optional piece, as I described in my other reply to you.
Jeff
Quoted 4 lines · Jeff Garzik
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
BTW, you also need to set host/device modes on resume. Where do you propose to do that currently, without the LLD hook?
Signature · 1 line
Jens Axboe
Quoted 7 lines · Jens Axboe
Quoted 1 line · Jeff Garzik
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
BTW, you also need to set host/device modes on resume. Where do you propose to do that currently, without the LLD hook?
In the START STOP UNIT emulation. SSU is basically a high level "do PM command".
As a tangent, I would like to try and convince you to stop thinking so much about hooks, and start thinking about adding new commands at the struct request level. Sending things down the request_queue is much nicer because commands can be sent using the normal rq mechanisms. Often, commands can be translated directly into ATA or SCSI commands in the prep function.
Two commands I have been thinking about, to add alongside READ, WRITE, READA, READ_SYNC, etc. are: SYNC_CACHE and PM_EVENT.
This would be quite useful for DM and md RAID, especially. It becomes trivial to clone a SYNC_CACHE command, and send it to 5 underlying ATA and SCSI devices in a RAID array. If the PM_EVENT or SYNC_CACHE command needs special processing, one can easily add code for that without needing any hooks -- just call your new code from the request_queue function that handles READ/WRITE/READA/...
This applies to the current thread (PM_EVENT), and also fits right into your barrier work, too (SYNC_CACHE).
Jeff
Quoted 9 lines · Jeff Garzik
Quoted 8 lines · Jens Axboe
Quoted 4 lines · Jeff Garzik
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
Quoted 5 lines
Quoted 2 lines
BTW, you also need to set host/device modes on resume. Where do you propose to do that currently, without the LLD hook?
In the START STOP UNIT emulation. SSU is basically a high level "do PM command".
Ok, works for me.
Quoted 17 lines
As a tangent, I would like to try and convince you to stop thinking so much about hooks, and start thinking about adding new commands at the struct request level. Sending things down the
request_queueis much nicer because commands can be sent using the normal rq mechanisms. Often, commands can be translated directly into ATA or SCSI commands in the prep function.Two commands I have been thinking about, to add alongside READ, WRITE, READA,
READ_SYNC, etc. are:SYNC_CACHEandPM_EVENT.This would be quite useful for DM and md RAID, especially. It becomes trivial to clone a
SYNC_CACHEcommand, and send it to 5 underlying ATA and SCSI devices in a RAID array. If thePM_EVENTorSYNC_CACHEcommand needs special processing, one can easily add code for that without needing any hooks -- just call your new code from therequest_queuefunction that handles READ/WRITE/READA/...
Quoted 2 lines
This applies to the current thread (
PM_EVENT), and also fits right into your barrier work, too (SYNC_CACHE).
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the rq->end_io() callback so everything doesn't have to go down sync, but that is in now as well.
I'll try and cook something up.
Signature · 1 line
Jens Axboe
Quoted 11 lines · Jeff Garzik
Quoted 4 lines · Hannes Reinecke
We've finally succeeded in convincing everyone that having '
/dev/sdX' instead of '/dev/hdX' was a neccessary step forward.
I think we're getting shot if we now tell them to reverse this _again_. Can we at least have it optional?I will not break compatibility with
/dev/sdX, don't worry :)It will always be there as an optional piece, as I described in my other reply to you.
Jeff,
At the risk of boring you but informing others, Serial Attached SCSI (SAS) is going to muddy things.
The SCSI ATA Translation (SAT
http://www.t10.org/ftp/t10/drafts/sat/sat-r04.pdf ) draft hopefully will find application any many areas other than libata (e.g. USB mass storage and 1394's SBP-2 drivers). The Scope section (section 1) of that draft makes interesting reading: in point a) the author sees SAT as presenting a unified command interface for block type devices across PATA, SATA and ATAPI!
However the primary reason that SAT started is the fact that SAS infrastructure can include SATA disks. SAS defines the Serial ATA Tunneled Protocol (STP) which in linux will first appear in a SAS LLD (i.e. a scsi subsystem Low Level Driver, something like aic7xxx). Connecting a SATA disk (transported via SAS) to the IDE subsystem and a /dev/hd? device node seems like an unnatural act (a bit like ide-scsi in reverse). A solution involving libata seems appropriate in this case.
Even more likely is that a SAT layer will be implemented in SAS enclosures just inches away from lots of SATA disks. From the point of view of a linux machine such SATA disks talk the SCSI command set and are connected via a SAS transport (Serial SCSI Protocol (SSP)). The only things that will probably care about the difference between such SATA disks and SAS disks are utilities like smartmontools (and that gap is being partially closed as well).
Even without SAS we already have many fibre channel enclosures that bridge to SATA disks. Hopefully a SAT layer will be retro-fitted into some of those.
Perhaps libata could be renamed libsat.
Doug Gilbert
Quoted 10 lines · Jens Axboe
suspend/resume is a lot more complicated than just flushing a cache, the below will probably get you safe asleep but you will never get devices alive again after power-up on suspend-to-ram.
I also greatly prefer issuing a standby command to the drive after the flush, so that we don't risk using the emergency parks of the drive. If a drive happens to lie about wrt the flush command, it gets an extra chance to flush the cache as it now knows that power will be gone very soon. So I think the ->suspend/->resume hooks should belong to the LLD, not the ULD as the ULD has no idea how to suspend all devices types.
Very, very true and very, very correct!
Luben
Quoted 7 lines · Jeff Garzik
You are right about issuing the standby command after flush. I don't think an LLD hook is the proper way to accomplish it, however.
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
An SSU command may not be viable as the device may be shared on the domain (i.e. accessed by another initiator).
Quoted 3 lines
Longer term, SATA PM through SCSI will have three facets:
* Device PM. This is best handled by the device class driver (sd/sr/st).
In terms of cache syncronization yes. But we may not be the only initiator.
Quoted 2 lines
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
This is tricky. Kudos to Doug's answer. One thing to remember is that this is intricately entangled with host PM. That is, if a device is unplugged from the domain -- would one want to computer to come out of its current power saving mode? Probably not.
Quoted 2 lines
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
Then D3->D0 would be equivalent to reinintialization of the PCI device, doing domain discovery as usual, etc.
Quoted 2 lines
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Please Jeff.
A concern is SATA devices behind SAS HAs (host adapters). A straightforward translation provided by libata would be a goal.
Luben
Quoted 8 lines · Jeff Garzik
Patch 2/2 for review by the linux-scsi crowd.
Please do not apply.
Patch is via Mark Lord,
The original patch was from Jens Axboe (now copied).
Cheers
--
Mark Lord
Mark Lord
Acked-by Andreas GruenbacherQuoted 3 lines
Quoted 1 line
Patch is via Mark Lord,
Um, it is? it looks identical to this one from Jens
...
As Jeff said, he got the patch "via" me.
Here are the first few lines from the file I sent to Jeff (below), just to make it clear I never tried to claim it as my own.
Cheers
--
Mark Lord
From: Hannes Reinecke <[email protected]>
Subject: Fix sata atapi error handling
References: 70918
SCSI commands which end up on the error handler need special attention; we have to make sure that eh_cmd_q is properly emptied or scsi_eh will try to forever finalize the command.
With this patch eh_cmd_q is explicitely emptied if not done so in the strategy handler and a proper abort sequence is executed for each command if required.
We rely on the strategy handler to fill out proper sense information for us as SATA is 'special' when it comes to command sense gathering.
...
Oh crap, wrong attachment..
It appears I did at some point trim off Jens's header. Sorry about that, Jens!
Cheers
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
Jeff
Quoted 2 lines · Douglas Gilbert
At the risk of boring you but informing others, Serial Attached SCSI (SAS) is going to muddy things.
Not necessarily... ;-)
But yes, I am keeping track of SAS, don't worry.
Quoted 8 lines
The SCSI ATA Translation (SAT
http://www.t10.org/ftp/t10/drafts/sat/sat-r04.pdf ) draft hopefully will find application any many areas other than libata (e.g. USB mass storage and 1394's SBP-2 drivers). The Scope section (section 1) of that draft makes interesting reading: in point a) the author sees SAT as presenting a unified command interface for block type devices across PATA, SATA and ATAPI!
In Linux's case, libata's SCSI<->ATA translation is merely a convenience so that I didn't have to bother writing all that storage infrastructure at the block layer. And SAT was merely a convenient standard I could follow during the exercise.
Quoted 9 lines
However the primary reason that SAT started is the fact that SAS infrastructure can include SATA disks. SAS defines the Serial ATA Tunneled Protocol (STP) which in linux will first appear in a SAS LLD (i.e. a scsi subsystem Low Level Driver, something like aic7xxx). Connecting a SATA disk (transported via SAS) to the IDE subsystem and a
/dev/hd? device node seems like an unnatural act (a bit like ide-scsi in reverse). A solution involving libata seems appropriate in this case.
Certainly there will be hardware that attaches to both SATA and SAS. I've been planning for this. I even have an Adaptec card (and docs).
It depends highly on the LLD how this is implemented. If a SCSI interface to SATA is forced upon us (i.e. SAT is implemented in a firmware somewhere), then there's not much you can do.
If the LLD provides direct access to either SCSI CDBs or ATA taskfiles (FIS's), then the OS should directly work with the device's native command set. Far from adding value, translation actually hinders progress, as users must either (a) find a way around the SAT layer to access an ATA feature, or (b) wait until the SAT layer is updated to support a translation for the desired feature.
One of the biggest requested features for libata is "ATA passthru", the ability to directly submit ATA commands to the device. That should tell you something about what -users- want.
SCSI and ATA are competing and evolving command sets, which implies that there is -increased- interest in -not- hiding ATA devices behind an emulation layer.
A SATA+SAS LLD would ideally register an instance of the SAS transport class with the SCSI layer, and an instance of the SATA transport class with the block layer. That's all it needs to do.
Everything else -- /dev/hdX versus /dev/sdX, emulation, sd/sr/st, etc. -- are all clients to either a SATA or SCSI transport class. Remember, to many users, the fact that SATA right now uses /dev/sdX is confusing and annoying: they would prefer /dev/hdX as IDE has been presenting for over a decadce.
With the right design, there is little value OR NEED in hiding ATA devices behind emulation.
Quoted 9 lines
Even more likely is that a SAT layer will be implemented in SAS enclosures just inches away from lots of SATA disks. From the point of view of a linux machine such SATA disks talk the SCSI command set and are connected via a SAS transport (Serial SCSI Protocol (SSP)). The only things that will probably care about the difference between such SATA disks and SAS disks are utilities like smartmontools (and that gap is being partially closed as well).
Linux will always want to talk to a device in its native command set, unless a firmware _forces_ us to do otherwise.
If the user considers a SAT layer added value, then they can certainly use such at their site.
Quoted 1 line
Perhaps libata could be renamed libsat.
s/libata/libata-scsi/
libata core is a SCSI-independent ATA transport, approaching the "ATA transport class" that I described above.
Jeff
Quoted 9 lines · Luben Tuikov
Quoted 3 lines · Jeff Garzik
You are right about issuing the standby command after flush. I don't think an LLD hook is the proper way to accomplish it, however.
The SCSI layer needs to issue the START STOP UNIT command in response to a suspend event, and libata-scsi will (per SAT spec) translate that into the ATA standby command. Merely following the relevant SCSI+SAT+ATA standards gets us there.
An SSU command may not be viable as the device may be shared on the domain (i.e. accessed by another initiator).
Yes. Don't worry, both James and I are quite aware of this.
Quoted 7 lines
Quoted 1 line
* Bus PM. This is best handled by the transport class driver (need to write for SATA and SAS).
This is tricky. Kudos to Doug's answer. One thing to remember is that this is intricately entangled with host PM. That is, if a device is unplugged from the domain -- would one want to computer to come out of its current power saving mode? Probably not.
In general, in a class-based system, one can easily see a situation where a host driver would provide "adaptec_sas_transport" class, which does a few host-specific things, then falls back to a generic "sas_transport" class.
That is how to do host-specific stuff, with transport classes.
However, with regards to your specific example: to come out of power-saving mode based on a certain event, the motherboard needs special circuitry. Example of this is wake-on-LAN or wake-on-serial.
Quoted 4 lines
Quoted 1 line
* Host PM. This is handled in the obvious manner, using existing PM driver hooks. PCI D0/D3, etc.
Then
D3->D0would be equivalent to reinintialization of the PCI device,
yes
Quoted 1 line
doing domain discovery as usual, etc.
Eventually, yes. At the moment, suspend is rather dumb, and things mostly assume that the devices present at suspend will be present at resume.
Quoted 7 lines
Quoted 1 line
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
Please Jeff.
A concern is SATA devices behind SAS HAs (host adapters). A straightforward translation provided by libata would be a goal.
No need for translation. The LLD driver would either use the high level libata interface (for SATA devices), or use the high level SCSI interface (for SAS devices).
Even though libata doesn't have an explicit notion of transport classes (it _is_ a transport class, really), this is doable today.
Jeff
Quoted 9 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
This is the base for it. It splits request->flags into two variables:
- cmd_type. this is not a bitmask, but a value indicating what type of request this is.
- cmd_flags. various command modified flags.
The idea is to add a REQ_TYPE_LINUX_BLOCK request type, where we define a set of command opcodes that signify an upper level defined function (such as flush) that is implemented differently at the hardware/driver level. Basically a way to pass down messages or commands generically.
I like this better than using scsi opcodes always, it's a cleaner abstraction. For sending generic commands to a device, we could add a function ala:
blk_send_message(queue, unsigned char cmd, completion_callback);
that would allocate the request, set it up, add to block layer queue, and call the completion_callback when it is done. So for a flush, a driver could do
blk_send_message(q, REQ_LB_OP_FLUSH, flush_done);
to a target queue.
What do you think?
drivers/block/as-iosched.c (mode:100644) +2 -2
@@ -1476,7 +1476,7 @@ } } else WARN_ON(blk_fs_request(rq) - && (!(rq->flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) ); + && (!(rq->cmd_flags & (REQ_HARDBARRIER|REQ_SOFTBARRIER))) ); /* Stop anticipating - let this request get through */ as_antic_stop(ad);
@@ -1522,7 +1522,7 @@ } /* barriers must flush the reorder queue */ - if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) + if (unlikely(rq->cmd_flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) && where == ELEVATOR_INSERT_SORT)) { WARN_ON(1); where = ELEVATOR_INSERT_BACK;
drivers/block/deadline-iosched.c (mode:100644) +1 -1
@@ -628,7 +628,7 @@ struct deadline_data *dd = q->elevator->elevator_data; /* barriers must flush the reorder queue */ - if (unlikely(rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) + if (unlikely(rq->cmd_flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) && where == ELEVATOR_INSERT_SORT)) where = ELEVATOR_INSERT_BACK;
drivers/block/elevator.c (mode:100644) +6 -6
@@ -272,7 +272,7 @@ if (blk_account_rq(rq)) q->in_flight--; - rq->flags &= ~REQ_STARTED; + rq->cmd_flags &= ~REQ_STARTED; if (e->ops->elevator_deactivate_req_fn) e->ops->elevator_deactivate_req_fn(q, rq);
@@ -285,7 +285,7 @@ /* * if this is the flush, requeue the original instead and drop the flush */ - if (rq->flags & REQ_BAR_FLUSH) { + if (rq->cmd_type == REQ_TYPE_FLUSH) { clear_bit(QUEUE_FLAG_FLUSH, &q->queue_flags); rq = rq->end_io_data; }
@@ -306,7 +306,7 @@ /* * barriers implicitly indicate back insertion */ - if (rq->flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) && + if (rq->cmd_flags & (REQ_SOFTBARRIER | REQ_HARDBARRIER) && where == ELEVATOR_INSERT_SORT) where = ELEVATOR_INSERT_BACK;
@@ -374,12 +374,12 @@ * that has been delayed should not be passed by new incoming * requests */ - rq->flags |= REQ_STARTED; + rq->cmd_flags |= REQ_STARTED; if (rq == q->last_merge) q->last_merge = NULL; - if ((rq->flags & REQ_DONTPREP) || !q->prep_rq_fn) + if ((rq->cmd_flags & REQ_DONTPREP) || !q->prep_rq_fn) break; ret = q->prep_rq_fn(q, rq);
@@ -395,7 +395,7 @@ nr_bytes = rq->data_len; blkdev_dequeue_request(rq); - rq->flags |= REQ_QUIET; + rq->cmd_flags |= REQ_QUIET; end_that_request_chunk(rq, 0, nr_bytes); end_that_request_last(rq); } else {
drivers/block/floppy.c (mode:100644) +2 -2
@@ -3001,8 +3001,8 @@ if (usage_count == 0) { printk("warning: usage count=0, current_req=%p exiting\n", current_req); - printk("sect=%ld flags=%lx\n", (long)current_req->sector, - current_req->flags); + printk("sect=%ld type=%x flags=%x\n", (long)current_req->sector, + current_req->cmd_type, current_req->cmd_flags); return; } if (test_bit(0, &fdc_busy)) {
drivers/block/ll_rw_blk.c (mode:100644) +33 -61
251 lines not on this page · raw message
drivers/block/nbd.c (mode:100644) +2 -2
@@ -428,7 +428,7 @@ dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%lx)\n", req->rq_disk->disk_name, req, req->flags); - if (!(req->flags & REQ_CMD)) + if (!blk_fs_request(req)) goto error_out; lo = req->rq_disk->private_data;
@@ -510,7 +510,7 @@ switch (cmd) { case NBD_DISCONNECT: printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name); - sreq.flags = REQ_SPECIAL; + sreq.cmd_type = REQ_TYPE_SPECIAL; nbd_cmd(&sreq) = NBD_CMD_DISC; /* * Set these to sane values in case server implementation
drivers/block/noop-iosched.c (mode:100644) +1 -1
@@ -39,7 +39,7 @@ /* * new merges must not precede this barrier */ - if (rq->flags & REQ_HARDBARRIER) + if (rq->cmd_flags & REQ_HARDBARRIER) q->last_merge = NULL; else if (!q->last_merge) q->last_merge = rq;
drivers/block/paride/pd.c (mode:100644) +1 -1
@@ -436,7 +436,7 @@ static enum action do_pd_io_start(void) { - if (pd_req->flags & REQ_SPECIAL) { + if (blk_special_request(pd_req)) { phase = pd_special; return pd_special(); }
drivers/block/pktcdvd.c (mode:100644) +3 -3
@@ -365,15 +365,15 @@ rq->sense = sense; memset(sense, 0, sizeof(sense)); rq->sense_len = 0; - rq->flags |= REQ_BLOCK_PC | REQ_HARDBARRIER; + rq->cmd_type = REQ_TYPE_BLOCK_PC; + rq->cmd_flags |= (REQ_HARDBARRIER | REQ_NOMERGE); if (cgc->quiet) - rq->flags |= REQ_QUIET; + rq->cmd_flags |= REQ_QUIET; memcpy(rq->cmd, cgc->cmd, CDROM_PACKET_SIZE); if (sizeof(rq->cmd) > CDROM_PACKET_SIZE) memset(rq->cmd + CDROM_PACKET_SIZE, 0, sizeof(rq->cmd) - CDROM_PACKET_SIZE); rq->ref_count++; - rq->flags |= REQ_NOMERGE; rq->waiting = &wait; rq->end_io = blk_end_sync_rq; elv_add_request(q, rq, ELEVATOR_INSERT_BACK, 1);
drivers/block/scsi_ioctl.c (mode:100644) +3 -3
@@ -276,7 +276,7 @@ rq->sense = sense; rq->sense_len = 0; - rq->flags |= REQ_BLOCK_PC; + rq->cmd_type = REQ_TYPE_BLOCK_PC; bio = rq->bio; /*
@@ -406,7 +406,7 @@ rq->data = buffer; rq->data_len = bytes; - rq->flags |= REQ_BLOCK_PC; + rq->cmd_type = REQ_TYPE_BLOCK_PC; blk_execute_rq(q, bd_disk, rq); err = rq->errors & 0xff; /* only 8 bit SCSI status */
@@ -553,7 +553,7 @@ close = 1; case CDROMEJECT: rq = blk_get_request(q, WRITE, __GFP_WAIT); - rq->flags |= REQ_BLOCK_PC; + rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->data = NULL; rq->data_len = 0; rq->timeout = BLK_DEFAULT_TIMEOUT;
drivers/block/xd.c (mode:100644) +1 -1
@@ -310,7 +310,7 @@ int res = 0; int retry; - if (!(req->flags & REQ_CMD)) { + if (!blk_fs_request(req)) { end_request(req, 0); continue; }
drivers/cdrom/cdrom.c (mode:100644) +1 -1
@@ -2125,7 +2125,7 @@ rq->cmd[9] = 0xf8; rq->cmd_len = 12; - rq->flags |= REQ_BLOCK_PC; + rq->cmd_type = REQ_TYPE_BLOCK_PC; rq->timeout = 60 * HZ; bio = rq->bio;
drivers/cdrom/cdu31a.c (mode:100644) +3 -1
@@ -1339,8 +1339,10 @@ } /* WTF??? */ - if (!(req->flags & REQ_CMD)) + if (!blk_fs_request(req)) { + end_request(req, 0); continue; + } if (rq_data_dir(req) == WRITE) { end_request(req, 0); continue;
drivers/ide/ide-cd.c (mode:100644) +34 -33
229 lines not on this page · raw message
drivers/ide/ide-disk.c (mode:100644) +2 -1
@@ -731,7 +731,8 @@ rq->cmd[0] = WIN_FLUSH_CACHE; - rq->flags |= REQ_DRIVE_TASK | REQ_SOFTBARRIER; + rq->cmd_type = REQ_TYPE_ATA_TASK; + rq->cmd_flags |= REQ_SOFTBARRIER; rq->buffer = rq->cmd; return 1; }
drivers/ide/ide-dma.c (mode:100644) +1 -1
@@ -210,7 +210,7 @@ ide_hwif_t *hwif = HWIF(drive); struct scatterlist *sg = hwif->sg_table; - if ((rq->flags & REQ_DRIVE_TASKFILE) && rq->nr_sectors > 256) + if ((rq->cmd_type == REQ_TYPE_ATA_TASKFILE) && rq->nr_sectors > 256) BUG(); ide_map_sg(drive, rq);
drivers/ide/ide-floppy.c (mode:100644) +6 -6
@@ -588,7 +588,7 @@ /* Why does this happen? */ if (!rq) return 0; - if (!(rq->flags & REQ_SPECIAL)) { //if (!IDEFLOPPY_RQ_CMD (rq->cmd)) { + if (!blk_special_request(rq)) { /* our real local end request function */ ide_end_request(drive, uptodate, nsecs); return 0;
@@ -687,7 +687,7 @@ ide_init_drive_cmd(rq); rq->buffer = (char *) pc; - rq->flags = REQ_SPECIAL; //rq->cmd = IDEFLOPPY_PC_RQ; + rq->cmd_type = REQ_TYPE_SPECIAL; rq->rq_disk = floppy->disk; (void) ide_do_drive_cmd(drive, rq, ide_preempt); }
@@ -1301,7 +1301,7 @@ idefloppy_do_end_request(drive, 0, 0); return ide_stopped; } - if (rq->flags & REQ_CMD) { + if (blk_fs_request(rq)) { if (((long)rq->sector % floppy->bs_factor) || (rq->nr_sectors % floppy->bs_factor)) { printk("%s: unsupported r/w request size\n",
@@ -1311,9 +1311,9 @@ } pc = idefloppy_next_pc_storage(drive); idefloppy_create_rw_cmd(floppy, pc, rq, block); - } else if (rq->flags & REQ_SPECIAL) { + } else if (blk_special_request(rq)) pc = (idefloppy_pc_t *) rq->buffer; - } else if (rq->flags & REQ_BLOCK_PC) { + } else if (blk_fs_request(rq)) { pc = idefloppy_next_pc_storage(drive); if (idefloppy_blockpc_cmd(floppy, pc, rq)) { idefloppy_do_end_request(drive, 0, 0);
@@ -1341,7 +1341,7 @@ ide_init_drive_cmd (&rq); rq.buffer = (char *) pc; - rq.flags = REQ_SPECIAL; // rq.cmd = IDEFLOPPY_PC_RQ; + rq.cmd_type = REQ_TYPE_SPECIAL; rq.rq_disk = floppy->disk; return ide_do_drive_cmd(drive, &rq, ide_wait);
drivers/ide/ide-io.c (mode:100644) +18 -16
@@ -60,7 +60,7 @@ { int ret = 1; - BUG_ON(!(rq->flags & REQ_STARTED)); + BUG_ON(!blk_rq_started(rq)); /* * if failfast is set on a request, override number of sectors and
@@ -310,7 +310,7 @@ rq = HWGROUP(drive)->rq; spin_unlock_irqrestore(&ide_lock, flags); - if (rq->flags & REQ_DRIVE_CMD) { + if (rq->cmd_type == REQ_TYPE_ATA_CMD) { u8 *args = (u8 *) rq->buffer; if (rq->errors == 0) rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
@@ -320,7 +320,7 @@ args[1] = err; args[2] = hwif->INB(IDE_NSECTOR_REG); } - } else if (rq->flags & REQ_DRIVE_TASK) { + } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { u8 *args = (u8 *) rq->buffer; if (rq->errors == 0) rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
@@ -334,7 +334,7 @@ args[5] = hwif->INB(IDE_HCYL_REG); args[6] = hwif->INB(IDE_SELECT_REG); } - } else if (rq->flags & REQ_DRIVE_TASKFILE) { + } else if (rq->cmd_type & REQ_TYPE_ATA_TASKFILE) { ide_task_t *args = (ide_task_t *) rq->special; if (rq->errors == 0) rq->errors = !OK_STAT(stat,READY_STAT,BAD_STAT);
@@ -530,7 +530,7 @@ return ide_stopped; /* retry only "normal" I/O: */ - if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) { + if (!blk_fs_request(rq)) { rq->errors = 1; ide_end_drive_cmd(drive, stat, err); return ide_stopped;
@@ -581,7 +581,7 @@ return ide_stopped; /* retry only "normal" I/O: */ - if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK | REQ_DRIVE_TASKFILE)) { + if (!blk_fs_request(rq)) { rq->errors = 1; ide_end_drive_cmd(drive, BUSY_STAT, 0); return ide_stopped;
@@ -751,7 +751,7 @@ if (hwif->sg_mapped) /* needed by ide-scsi */ return; - if ((rq->flags & REQ_DRIVE_TASKFILE) == 0) { + if (rq->cmd_type != REQ_TYPE_ATA_TASKFILE) { hwif->sg_nents = blk_rq_map_sg(drive->queue, rq, sg); } else { sg_init_one(sg, rq->buffer, rq->nr_sectors * SECTOR_SIZE);
@@ -787,7 +787,7 @@ struct request *rq) { ide_hwif_t *hwif = HWIF(drive); - if (rq->flags & REQ_DRIVE_TASKFILE) { + if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *args = rq->special; if (!args)
@@ -809,7 +809,7 @@ if (args->tf_out_flags.all != 0) return flagged_taskfile(drive, args); return do_rw_taskfile(drive, args); - } else if (rq->flags & REQ_DRIVE_TASK) { + } else if (rq->cmd_type == REQ_TYPE_ATA_TASK) { u8 *args = rq->buffer; u8 sel;
@@ -835,7 +835,7 @@ hwif->OUTB(sel, IDE_SELECT_REG); ide_cmd(drive, args[0], args[2], &drive_cmd_intr); return ide_started; - } else if (rq->flags & REQ_DRIVE_CMD) { + } else if (rq->cmd_type == REQ_TYPE_ATA_CMD) { u8 *args = rq->buffer; if (!args)
@@ -890,7 +890,7 @@ ide_startstop_t startstop; sector_t block; - BUG_ON(!(rq->flags & REQ_STARTED)); + BUG_ON(!blk_rq_started(rq)); #ifdef DEBUG printk("%s: start_request: current=0x%08lx\n",
@@ -948,9 +948,10 @@ if (!drive->special.all) { ide_driver_t *drv; - if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) + if (rq->cmd_type == REQ_TYPE_ATA_CMD || + rq->cmd_type == REQ_TYPE_ATA_TASK) return execute_drive_cmd(drive, rq); - else if (rq->flags & REQ_DRIVE_TASKFILE) + else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) return execute_drive_cmd(drive, rq); else if (blk_pm_request(rq)) { #ifdef DEBUG_PM
@@ -1193,7 +1194,8 @@ * unless the subdriver triggers such a thing in its own PM * state machine. */ - if (drive->blocked && !blk_pm_request(rq) && !(rq->flags & REQ_PREEMPT)) { + if (drive->blocked && !blk_pm_request(rq) && + !(rq->cmd_flags & REQ_PREEMPT)) { /* We clear busy, there should be no pending ATA command at this point. */ hwgroup->busy = 0; break;
@@ -1596,7 +1598,7 @@ void ide_init_drive_cmd (struct request *rq) { memset(rq, 0, sizeof(*rq)); - rq->flags = REQ_DRIVE_CMD; + rq->cmd_type = REQ_TYPE_ATA_CMD; rq->ref_count = 1; }
@@ -1659,7 +1661,7 @@ hwgroup->rq = NULL; if (action == ide_preempt || action == ide_head_wait) { where = ELEVATOR_INSERT_FRONT; - rq->flags |= REQ_PREEMPT; + rq->cmd_flags |= REQ_PREEMPT; } __elv_add_request(drive->queue, rq, where, 0); ide_do_request(hwgroup, IDE_NO_IRQ);
drivers/ide/ide-lib.c (mode:100644) +3 -2
@@ -458,13 +458,14 @@ spin_unlock(&ide_lock); if (!rq) return; - if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) { + if (rq->cmd_type == REQ_TYPE_ATA_CMD || + rq->cmd_type == REQ_TYPE_ATA_TASK) { char *args = rq->buffer; if (args) { opcode = args[0]; found = 1; } - } else if (rq->flags & REQ_DRIVE_TASKFILE) { + } else if (rq->cmd_type & REQ_TYPE_ATA_TASKFILE) { ide_task_t *args = rq->special; if (args) { task_struct_t *tf = (task_struct_t *) args->tfRegister;
drivers/ide/ide-tape.c (mode:100644) +3 -3
@@ -1774,7 +1774,7 @@ static void idetape_init_rq(struct request *rq, u8 cmd) { memset(rq, 0, sizeof(*rq)); - rq->flags = REQ_SPECIAL; + rq->cmd_type = REQ_TYPE_SPECIAL; rq->cmd[0] = cmd; }
@@ -2431,7 +2431,7 @@ rq->sector, rq->nr_sectors, rq->current_nr_sectors); #endif /* IDETAPE_DEBUG_LOG */ - if ((rq->flags & REQ_SPECIAL) == 0) { + if (!blk_special_request(rq)) { /* * We do not support buffer cache originated requests. */
@@ -2760,7 +2760,7 @@ idetape_tape_t *tape = drive->driver_data; #if IDETAPE_DEBUG_BUGS - if (rq == NULL || (rq->flags & REQ_SPECIAL) == 0) { + if (rq == NULL || !blk_special_request(rq)) { printk (KERN_ERR "ide-tape: bug: Trying to sleep on non-valid request\n"); return; }
drivers/ide/ide-taskfile.c (mode:100644) +4 -4
@@ -366,7 +366,7 @@ static void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) { - if (rq->flags & REQ_DRIVE_TASKFILE) { + if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) { ide_task_t *task = rq->special; if (task->tf_out_flags.all) {
@@ -471,7 +471,7 @@ struct request rq; memset(&rq, 0, sizeof(rq)); - rq.flags = REQ_DRIVE_TASKFILE; + rq.cmd_type = REQ_TYPE_ATA_TASKFILE; rq.buffer = buf; /*
@@ -496,7 +496,7 @@ rq.hard_cur_sectors = rq.current_nr_sectors = rq.nr_sectors; if (args->command_type == IDE_DRIVE_TASK_RAW_WRITE) - rq.flags |= REQ_RW; + rq.cmd_flags |= REQ_RW; } rq.special = args;
@@ -739,7 +739,7 @@ struct request rq; ide_init_drive_cmd(&rq); - rq.flags = REQ_DRIVE_TASK; + rq.cmd_type = REQ_TYPE_ATA_TASK; rq.buffer = buf; return ide_do_drive_cmd(drive, &rq, ide_wait); }
drivers/ide/ide.c (mode:100644) +2 -2
@@ -1381,7 +1381,7 @@ memset(&rq, 0, sizeof(rq)); memset(&rqpm, 0, sizeof(rqpm)); memset(&args, 0, sizeof(args)); - rq.flags = REQ_PM_SUSPEND; + rq.cmd_type = REQ_TYPE_PM_SUSPEND; rq.special = &args; rq.pm = &rqpm; rqpm.pm_step = ide_pm_state_start_suspend;
@@ -1400,7 +1400,7 @@ memset(&rq, 0, sizeof(rq)); memset(&rqpm, 0, sizeof(rqpm)); memset(&args, 0, sizeof(args)); - rq.flags = REQ_PM_RESUME; + rq.cmd_type = REQ_TYPE_PM_RESUME; rq.special = &args; rq.pm = &rqpm; rqpm.pm_step = ide_pm_state_start_resume;
drivers/ide/legacy/hd.c (mode:100644) +1 -1
@@ -624,7 +624,7 @@ req->rq_disk->disk_name, (req->cmd == READ)?"read":"writ", cyl, head, sec, nsect, req->buffer); #endif - if (req->flags & REQ_CMD) { + if (blk_fs_request(req)) { switch (rq_data_dir(req)) { case READ: hd_out(disk,nsect,sec,head,cyl,WIN_READ,&read_intr);
drivers/message/i2o/i2o_block.c (mode:100644) +4 -3
@@ -352,9 +352,9 @@ struct i2o_block_request *ireq; /* request is already processed by us, so return */ - if (req->flags & REQ_SPECIAL) { + if (blk_special_request(req)) { osm_debug("REQ_SPECIAL already set!\n"); - req->flags |= REQ_DONTPREP; + req->cmd_flags |= REQ_DONTPREP; return BLKPREP_OK; }
@@ -373,7 +373,8 @@ ireq = req->special; /* do not come back here */ - req->flags |= REQ_DONTPREP | REQ_SPECIAL; + req->cmd_type = REQ_TYPE_SPECIAL; + req->cmd_flags |= REQ_DONTPREP; return BLKPREP_OK; };
drivers/mmc/mmc_queue.c (mode:100644) +2 -2
@@ -28,7 +28,7 @@ struct mmc_queue *mq = q->queuedata; int ret = BLKPREP_KILL; - if (req->flags & REQ_SPECIAL) { + if (blk_special_request(req)) { /* * Special commands already have the command * blocks already setup in req->special.
@@ -36,7 +36,7 @@ BUG_ON(!req->special); ret = BLKPREP_OK; - } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { + } else if (blk_fs_request(req) || blk_pc_request(req)) { /* * Block I/O requests need translating according * to the protocol.
drivers/mtd/mtd_blkdevs.c (mode:100644) +1 -1
@@ -47,7 +47,7 @@ nsect = req->current_nr_sectors; buf = req->buffer; - if (!(req->flags & REQ_CMD)) + if (!blk_fs_request(req)) return 0; if (block + nsect > get_capacity(req->rq_disk))
drivers/scsi/ide-scsi.c (mode:100644) +7 -7
@@ -317,7 +317,7 @@ pc->buffer = buf; pc->c[0] = REQUEST_SENSE; pc->c[4] = pc->request_transfer = pc->buffer_size = SCSI_SENSE_BUFFERSIZE; - rq->flags = REQ_SENSE; + rq->cmd_type = REQ_TYPE_SENSE; pc->timeout = jiffies + WAIT_READY; /* NOTE! Save the failed packet command in "rq->buffer" */ rq->buffer = (void *) failed_command->special;
@@ -370,12 +370,12 @@ u8 *scsi_buf; unsigned long flags; - if (!(rq->flags & (REQ_SPECIAL|REQ_SENSE))) { + if (!blk_special_request(rq) || !blk_sense_request(rq)) { ide_end_request(drive, uptodate, nrsecs); return 0; } ide_end_drive_cmd (drive, 0, 0); - if (rq->flags & REQ_SENSE) { + if (blk_sense_request(rq)) { idescsi_pc_t *opc = (idescsi_pc_t *) rq->buffer; if (log) { printk ("ide-scsi: %s: wrap up check %lu, rst = ", drive->name, opc->scsi_cmd->serial_number);
@@ -686,7 +686,7 @@ printk (KERN_INFO "sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n",rq->sector,rq->nr_sectors,rq->current_nr_sectors); #endif /* IDESCSI_DEBUG_LOG */ - if (rq->flags & (REQ_SPECIAL|REQ_SENSE)) { + if (blk_sense_request(rq) || blk_special_request(rq)) { return idescsi_issue_pc (drive, (idescsi_pc_t *) rq->special); } blk_dump_rq_flags(rq, "ide-scsi: unsup command");
@@ -921,7 +921,7 @@ ide_init_drive_cmd (rq); rq->special = (char *) pc; - rq->flags = REQ_SPECIAL; + rq->cmd_type = REQ_TYPE_SPECIAL; spin_unlock_irq(host->host_lock); rq->rq_disk = scsi->disk; (void) ide_do_drive_cmd (drive, rq, ide_end);
@@ -975,7 +975,7 @@ */ printk (KERN_ERR "ide-scsi: cmd aborted!\n"); - if (scsi->pc->rq->flags & REQ_SENSE) + if (blk_sense_request(scsi->pc->rq)) kfree(scsi->pc->buffer); kfree(scsi->pc->rq); kfree(scsi->pc);
@@ -1023,7 +1023,7 @@ /* kill current request */ blkdev_dequeue_request(req); end_that_request_last(req); - if (req->flags & REQ_SENSE) + if (blk_sense_request(req)) kfree(scsi->pc->buffer); kfree(scsi->pc); scsi->pc = NULL;
drivers/scsi/scsi_lib.c (mode:100644) +10 -10
@@ -90,7 +90,7 @@ * Because users of this function are apt to reuse requests with no * modification, we have to sanitise the request flags here */ - sreq->sr_request->flags &= ~REQ_DONTPREP; + sreq->sr_request->cmd_flags &= ~REQ_DONTPREP; blk_insert_request(sreq->sr_device->request_queue, sreq->sr_request, at_head, sreq, 0); return 0;
@@ -485,7 +485,7 @@ */ static void scsi_requeue_command(struct request_queue *q, struct scsi_cmnd *cmd) { - cmd->request->flags &= ~REQ_DONTPREP; + cmd->request->cmd_flags &= ~REQ_DONTPREP; blk_insert_request(q, cmd->request, 1, cmd, 1); scsi_run_queue(q);
@@ -922,7 +922,7 @@ /* * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer */ - if ((req->flags & REQ_BLOCK_PC) && !req->bio) { + if (blk_pc_request(req) && req->bio) { cmd->request_bufflen = req->data_len; cmd->request_buffer = req->data; req->buffer = req->data;
@@ -942,7 +942,7 @@ */ sgpnt = scsi_alloc_sgtable(cmd, GFP_ATOMIC); if (unlikely(!sgpnt)) { - req->flags |= REQ_SPECIAL; + req->cmd_type = REQ_TYPE_SPECIAL; return BLKPREP_DEFER; }
@@ -1066,7 +1066,7 @@ * these two cases differently. We differentiate by looking * at request->cmd, as this tells us the real story. */ - if (req->flags & REQ_SPECIAL) { + if (req->cmd_type == REQ_TYPE_SPECIAL) { struct scsi_request *sreq = req->special; if (sreq->sr_magic == SCSI_REQ_MAGIC) {
@@ -1076,7 +1076,7 @@ scsi_init_cmd_from_req(cmd, sreq); } else cmd = req->special; - } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { + } else if (blk_fs_request(req) || blk_pc_request(req)) { if(unlikely(specials_only)) { if(specials_only == SDEV_QUIESCE ||
@@ -1119,7 +1119,7 @@ * lock. We hope REQ_STARTED prevents anything untoward from * happening now. */ - if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { + if (blk_fs_request(req) || blk_pc_request(req)) { struct scsi_driver *drv; int ret;
@@ -1158,7 +1158,7 @@ /* * The request is now prepped, no need to come back here */ - req->flags |= REQ_DONTPREP; + req->cmd_flags |= REQ_DONTPREP; return BLKPREP_OK; defer:
@@ -1250,7 +1250,7 @@ while ((req = elv_next_request(q)) != NULL) { blkdev_dequeue_request(req); - req->flags |= REQ_QUIET; + req->cmd_flags |= REQ_QUIET; while (end_that_request_first(req, 0, req->nr_sectors)) ; end_that_request_last(req);
@@ -1305,7 +1305,7 @@ printk(KERN_ERR "scsi%d (%d:%d): rejecting I/O to offline device\n", sdev->host->host_no, sdev->id, sdev->lun); blkdev_dequeue_request(req); - req->flags |= REQ_QUIET; + req->cmd_flags |= REQ_QUIET; while (end_that_request_first(req, 0, req->nr_sectors)) ; end_that_request_last(req);
drivers/scsi/sd.c (mode:100644) +3 -6
@@ -329,13 +329,9 @@ } SCpnt->cmnd[0] = WRITE_6; SCpnt->sc_data_direction = DMA_TO_DEVICE; - } else if (rq_data_dir(rq) == READ) { + } else { SCpnt->cmnd[0] = READ_6; SCpnt->sc_data_direction = DMA_FROM_DEVICE; - } else { - printk(KERN_ERR "sd: Unknown command %lx\n", rq->flags); -/* overkill panic("Unknown sd command %lx\n", rq->flags); */ - return 0; } SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%ld 512 byte blocks.\n",
@@ -769,7 +765,8 @@ if (sdkp->WCE) { memset(rq->cmd, 0, sizeof(rq->cmd)); - rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; + rq->cmd_type = REQ_TYPE_BLOCK_PC; + rq->cmd_flags |= REQ_SOFTBARRIER; rq->timeout = SD_TIMEOUT; rq->cmd[0] = SYNCHRONIZE_CACHE; return 1;
drivers/scsi/sr.c (mode:100644) +1 -1
@@ -349,7 +349,7 @@ goto queue; } - if (!(SCpnt->request->flags & REQ_CMD)) { + if (!blk_fs_request(SCpnt->request)) { blk_dump_rq_flags(SCpnt->request, "sr unsup command"); return 0; }
drivers/scsi/sun3_NCR5380.c (mode:100644) +1 -1
@@ -2017,7 +2017,7 @@ if((count > SUN3_DMA_MINSIZE) && (sun3_dma_setup_done != cmd)) { - if(cmd->request->flags & REQ_CMD) { + if(blk_fs_request(cmd->request)) { sun3scsi_dma_setup(d, count, rq_data_dir(cmd->request)); sun3_dma_setup_done = cmd;
drivers/scsi/sun3_scsi.c (mode:100644) +1 -1
@@ -524,7 +524,7 @@ static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, int write_flag) { - if(cmd->request->flags & REQ_CMD) + if(blk_fs_request(cmd->request)) return wanted; else return 0;
drivers/scsi/sun3_scsi_vme.c (mode:100644) +1 -1
@@ -458,7 +458,7 @@ static inline unsigned long sun3scsi_dma_xfer_len(unsigned long wanted, Scsi_Cmnd *cmd, int write_flag) { - if(cmd->request->flags & REQ_CMD) + if(blk_fs_request(cmd->request)) return wanted; else return 0;
include/linux/blkdev.h (mode:100644) +62 -45
176 lines not on this page · raw message
include/scsi/scsi_tcq.h (mode:100644) +1 -1
@@ -98,7 +98,7 @@ struct scsi_device *sdev = cmd->device; if (blk_rq_tagged(req)) { - if (sdev->ordered_tags && req->flags & REQ_HARDBARRIER) + if (sdev->ordered_tags && req->cmd_flags & REQ_HARDBARRIER) *msg++ = MSG_ORDERED_TAG; else *msg++ = MSG_SIMPLE_TAG;
Signature · 1 line
Jens Axboe
Quoted 33 lines · Jens Axboe
Quoted 9 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
This is the base for it. It splits
request->flagsinto two variables:-
cmd_type. this is not a bitmask, but a value indicating what type of request this is.-
cmd_flags. various command modified flags.The idea is to add a
REQ_TYPE_LINUX_BLOCKrequest type, where we define a set of command opcodes that signify an upper level defined function (such as flush) that is implemented differently at the hardware/driver level. Basically a way to pass down messages or commands generically.I like this better than using scsi opcodes always, it's a cleaner abstraction. For sending generic commands to a device, we could add a function ala:
blk_send_message(queue, unsigned char cmd, completion_callback);that would allocate the request, set it up, add to block layer queue, and call the
completion_callbackwhen it is done. So for a flush, a driver could do
Quoted 5 lines
blk_send_message(q, REQ_LB_OP_FLUSH, flush_done);to a target queue.
What do you think?
Heh, very nice! Just what's needed for nbd!:-) NBD has several "threads":
1. the one running in the original nbd-client context, receiving answers from the server and completing requests,
2. the block queue
3. (my addition) block-device operations open, close, ioctl...
1. and 2. are already working in the block queue context, to simplify 3. I also faked those operations with block requests. I didn't go as far as really submitting them to the block layer and completing them respectively, I just used the same request object and inserted it directly into the internal list to process replies in 1. With the current patch from Jens (with some minor extensions) this could be done even nicer.
(see also my another post today to linux-scsi)
Thanks
Guennadi
---
Guennadi Liakhovetski
Quoted 21 lines · Jens Axboe
Quoted 10 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
This is the base for it. It splits
request->flagsinto two variables:-
cmd_type. this is not a bitmask, but a value indicating what type of request this is.-
cmd_flags. various command modified flags.
Quoted 8 lines
The idea is to add a
REQ_TYPE_LINUX_BLOCKrequest type, where we define a set of command opcodes that signify an upper level defined function (such as flush) that is implemented differently at the hardware/driver level. Basically a way to pass down messages or commands generically.I like this better than using scsi opcodes always, it's a cleaner abstraction. For sending generic commands to a device, we could add a function ala:
cmd_type just adds a needless layer of switch{} statements in block drivers, and its information that can be trivially derived from the command opcode itself.
cmd_type = cmd_types[opcode];
HOWEVER, don't fall in love with SCSI opcodes.
We want _Linux_ commands, not SCSI commands. Just think of a request_queue as having its own command protocol, one that you can _change at will_.
Yes, often request_queue commands may map seamlessly to SCSI (or ATA or I2O) commands. And that's good. But don't let yourself be locked into SCSI. SCSI is not generic enough, nor mutable enough for all our needs.
Just the other day I was thinking about the simpler approach, like the attached :) It
* adds RQ_ to avoid namespace conflicts
* adds RQ_FLUSH, RQ_PM_EVENT
So, overall, I would say "think Linux opcodes" as the preferred direction.
Jeff
include/linux/fs.h +18 -7
@@ -66,13 +66,24 @@ extern int dir_notify_enable;#define RW_MASK 1#define RWA_MASK 2 -#define READ 0 -#define WRITE 1 -#define READA 2/* read-ahead - don't block if no resources */ -#define SPECIAL 4/* For non-blockdevice requests in request queue */ -#define READ_SYNC (READ | (1 << BIO_RW_SYNC)) -#define WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) -#define WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER)) +#define RQ_READ 0 +#define RQ_WRITE 1 +#define RQ_READA 2/* read-ahead - don't block if no resources */ +#define RQ_SPECIAL 4/* For non-blockdevice requests in request queue */ +#define RQ_READ_SYNC (READ | (1 << BIO_RW_SYNC)) +#define RQ_WRITE_SYNC (WRITE | (1 << BIO_RW_SYNC)) +#define RQ_WRITE_BARRIER ((1 << BIO_RW) | (1 << BIO_RW_BARRIER)) +#define RQ_FLUSH 7 +#define RQ_PM_EVENT 8 + +/* compatibility with existing code */ +#define READ RQ_READ +#define WRITE RQ_WRITE +#define READA RQ_READA +#define SPECIAL RQ_SPECIAL +#define READ_SYNC RQ_READ_SYNC +#define WRITE_SYNC RQ_WRITE_SYNC +#define WRITE_BARRIER RQ_WRITE_BARRIER#define SEL_IN 1#define SEL_OUT 2
Quoted 31 lines · Jeff Garzik
Quoted 21 lines · Jens Axboe
Quoted 10 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
This is the base for it. It splits
request->flagsinto two variables:-
cmd_type. this is not a bitmask, but a value indicating what type of request this is.-
cmd_flags. various command modified flags.Quoted 8 lines
The idea is to add a
REQ_TYPE_LINUX_BLOCKrequest type, where we define a set of command opcodes that signify an upper level defined function (such as flush) that is implemented differently at the hardware/driver level. Basically a way to pass down messages or commands generically.I like this better than using scsi opcodes always, it's a cleaner abstraction. For sending generic commands to a device, we could add a function ala:
Quoted 7 lines
cmd_typejust adds a needless layer of switch{} statements in block drivers, and its information that can be trivially derived from the command opcode itself.cmd_type = cmd_types[opcode];HOWEVER, don't fall in love with SCSI opcodes.
Eh, I don't follow. The opcode is only valid for cmd_type REQ_TYPE_LINUX_MSG, not for anything else. Or for REQ_TYPE_BLOCK_PC of course, like it is right now as well.
Quoted 8 lines
We want _Linux_ commands, not SCSI commands. Just think of a
request_queueas having its own command protocol, one that you can_changeatwill_.Yes, often
request_queuecommands may map seamlessly to SCSI (or ATA or I2O) commands. And that's good. But don't let yourself be locked into SCSI. SCSI is not generic enough, nor mutable enough for all our needs.
Quoted 6 lines
Just the other day I was thinking about the simpler approach, like the attached :) It
* addsRQ_to avoid namespace conflicts
* addsRQ_FLUSH,RQ_PM_EVENTSo, overall, I would say "think Linux opcodes" as the preferred direction.
And that's exactly what I proposed, the REQ_LB_OP_xxx are the linux specific opcodes that can be defined at will. I'm not locking myself into SCSI at all, I'm just putting ->cmd[] to use for a new command type.
Don't confuse/mixup fs.h and the block layer, I don't see your proposal adding anything of use. The fs.h READ/WRITE/etc were divorced from the block layer in 2.5.
Signature · 1 line
Jens Axboe
Nice work Jens, some feedback below:
Quoted 7 lines · Jens Axboe
Index:
drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c (mode:100644) +0
-0@@ -1311,9 +1311,9 @@ }
drivers/ide/ide-floppy.c (mode:100644) line 1319
Quoted 10 lines
drivers/ide/ide-floppy.c (mode:100644) +2
-2pc = idefloppy_next_pc_storage(drive); idefloppy_create_rw_cmd(floppy, pc, rq, block); - } else if (rq->flags & REQ_SPECIAL) { + } else if (blk_special_request(rq)) pc = (idefloppy_pc_t *) rq->buffer; - } else if (rq->flags & REQ_BLOCK_PC) { + } else if (blk_fs_request(rq)) { pc = idefloppy_next_pc_storage(drive); if (idefloppy_blockpc_cmd(floppy, pc, rq)) { idefloppy_do_end_request(drive, 0, 0);
blk_pc_request(rq)
Quoted 8 lines
Index:
drivers/ide/ide-io.c
===================================================================drivers/ide/ide-io.c (mode:100644) +0
-0@@ -948,9 +948,10 @@ if (!drive->special.all) { ide_driver_t *drv;
drivers/ide/ide-io.c (mode:100644) line 957
Quoted 10 lines
drivers/ide/ide-io.c (mode:100644) +3
-2- if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) + if (rq->cmd_type == REQ_TYPE_ATA_CMD || + rq->cmd_type == REQ_TYPE_ATA_TASK) return execute_drive_cmd(drive, rq); - else if (rq->flags & REQ_DRIVE_TASKFILE) + else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) return execute_drive_cmd(drive, rq); else if (blk_pm_request(rq)) { #ifdef DEBUG_PM
|| rq->cmd_type == REQ_TYPE_ATA_TASKFILE while at it
Quoted 6 lines
Index:
drivers/scsi/ide-scsi.c
===================================================================
drivers/scsi/ide-scsi.c (mode:100644) line 376
Quoted 8 lines
drivers/scsi/ide-scsi.c (mode:100644) +1
-1@@ -370,12 +370,12 @@ u8 *scsi_buf; unsigned long flags; - if (!(rq->flags & (REQ_SPECIAL|REQ_SENSE))) { + if (!blk_special_request(rq) || !blk_sense_request(rq)) { ide_end_request(drive, uptodate, nrsecs); return 0; }
!blk_special_request(rq) && !blk_sense_request(rq)
Quoted 6 lines
Index:
drivers/scsi/scsi_lib.c
===================================================================
drivers/scsi/scsi_lib.c (mode:100644) line 928
Quoted 8 lines
drivers/scsi/scsi_lib.c (mode:100644) +1
-1@@ -922,7 +922,7 @@ /* * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer */ - if ((req->flags & REQ_BLOCK_PC) && !req->bio) { + if (blk_pc_request(req) && req->bio) { cmd->request_bufflen = req->data_len; cmd->request_buffer = req->data; req->buffer = req->data;
!req->bio
I assume they you've verified that there are no odd cases possible like rq->flags = REQ_DRIVE_TASKFILE | REQ_BAR_FLUSH or rq->flags = REQ_PC (without REQ_BLOCK_PC) which would be obviously broken by this patch?
Bartlomiej
Quoted 9 lines · Jens Axboe
Quoted 8 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Quoted 8 lines
Quoted 1 line
Very cool ;)
This is the base for it. It splits
request->flagsinto two variables:-
cmd_type. this is not a bitmask, but a value indicating what type of request this is.-
cmd_flags. various command modified flags.
I like it too. It's a long overdue cleanup :)
Another thing is we should/could probably move some of the other fields in the struct request into a union of structs. Some of them are never present simultaneously ...
Ben.
libata, SCSI and storage drivers
In reply to Jens AxboeQuoted 13 lines · Jens Axboe
Quoted 9 lines · Jeff Garzik
Quoted 5 lines · Jens Axboe
Quoted 1 line · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
hehe, nope. I promised Linus, and I plan to keep my promise :)
Quoted 8 lines
You promised me, too :)
Quoted 1 line
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
We should start a list of items that could potentially be moved to the block layer that libata currently uses.
Here are the two broad categories of things that immediately come to mind.
1. Hardware in pre-production right now can do SAS or SATA on the same card. So, real soon, a driver will need to do both SCSI and ATA depending on runtime conditions.
The SCSI transport class is a very nice way to connect low-level drivers and the class drivers (disk/cdrom/tape/...). It works well with the device model, and is modular in just the right location.
I would like to develop ATA transport class(es). In order to work well with SATA/SAS hardware, there will need to be at least one.
And as I hoped you have guessed..... the ATA transport class should be a child of the block layer, not the SCSI layer.
2. driver API. Linux SCSI layer provides several services which are generalized to any "packet transport":
* mapping of devices to protocol buses (domain topology, etc.)
* command queueing
* error handling
For hardware like ATA or I2O, this "send-command" type of API is the most natural way to implement a low-level driver, particularly if the core code provides all the necessary queueing/mapping/EH services as well.
This infrastructure is -not- specific to SCSI at all. And it is this infrastructure that allowed me to bring up libata so rapidly.
Jeff
Quoted 8 lines · James Bottomley
drivers/scsi/scsi_sysfs.c +8
-0+/* Just quietly quiesce the device and SYNCHRONIZE CACHE for suspend too */ +static int sd_suspend (struct device *dev,pm_message_t state,u32 level) +{ +struct scsi_device *sdp =to_scsi_device (dev); +struct scsi_disk *sdkp =dev_get_drvdata (dev); + +if (!sdkp) +return 0 ;/* this can happen */
drivers/scsi/scsi_sysfs.c static void sd_shutdown(struct device *d · line 1734
Quoted 10 lines
drivers/scsi/scsi_sysfs.c +10
-0+ +if (!sdkp->WCE) +return 0 ; + +/* don't try to sync an offline device ... it will only error */ +if (!scsi_device_online (sdp)) +return 0 ; + +if (sd_sync_cache (sdp)) +return -EIO ;
Add
if (I_can_PM_this_disk && sd_start_stop_unit(sdp)) return -EIO;
and libata is happy.
Jeff
Re: libata, SCSI and storage drivers
In reply to Jeff GarzikQuoted 33 lines · Jeff Garzik
Quoted 19 lines · Jens Axboe
Quoted 11 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
Quoted 1 line · Jeff Garzik
I can describe how this will look when libata is divorced from SCSI, if you would like, too...
I was beginning to dispair you had given up that plan...
hehe, nope. I promised Linus, and I plan to keep my promise :)
You promised me, too :)
Quoted 6 lines
Quoted 1 line
I know how to do it. Internally things have been kept as separate as possible from the SCSI layer.
We should start a list of items that could potentially be moved to the block layer that libata currently uses.
Here are the two broad categories of things that immediately come to mind.
Quoted 7 lines
1. Hardware in pre-production right now can do SAS or SATA on the same card. So, real soon, a driver will need to do both SCSI and ATA depending on runtime conditions.
The SCSI transport class is a very nice way to connect low-level drivers and the class drivers (disk/cdrom/tape/...). It works well with the device model, and is modular in just the right location.
I would like to develop ATA transport class(es). In order to work well with SATA/SAS hardware, there will need to be at least one.
And as I hoped you have guessed..... the ATA transport class should be a child of the block layer, not the SCSI layer.
Jeff,
Yes, the SAS HBAs that I'm aware of can connect to SATA I/II disks "directly" on their phys.
So here are two scenarios for connecting SATA disks:
a)
SAS HBA < -------------------------> SATA disk
b)
SAS HBA <------>SAS_expander<------> SATA disk
In a) the interconnect is SATA. Still it is hard to believe that the SAS HBA LLD would belong to anything other than the SCSI subsystem (since SAS HBAs come with 4 or 8 phys, others of which could be in scenario b) and/or connected to SAS disks). Hence the initiator_ports/phys/target_ports on and seen by that SAS HBA should (also) have SAS transport classes.
When a SAS HBA phy is not connected to anything is it a member of a SAS transport class or a ATA transport class (or both)?
In scenario b) the left interconnect is SAS and the right interconnect is SATA. The SAS_expander contains the STP<->SATA bridging function (and, for sake of argument, no SCSI-ATA Translation (SAT) layer). Would scenario b) also have a ATA transport class? I'll assume it does. To be discovered it also needs a SAS transport class. Larger enclosures are likely to be amplifications of scenario b). The presence of the SATA disk in scenario b) will be discovered via the SAS SMP (i.e. talking to the SAS_expander) or via the SES protocol (i.e. a SCSI Enclosure Services target running near the SAS_expander). Either way if there are a lot of SATA disks then they are likely to be held in their initialization sequence to stop them spinning up all at once. SAS transport intervention may be required (staggered timers are another possibility).
Now I may be wrong but I think that one of the SAS HBAs that I have read about that looks (externally) like scenario a) but is actually scenario b). In other words the SAS_expander is silicon on the HBA and it is not controlled via the PCI bus, but rather by SMP.
This suggests to me we would need an ordered sequence of transport classes. I really wonder about trying to model this level of complexity in sysfs, plus the nightmare of keeping state data of (topologically) distant nodes up to date. At some point one needs to supply a management pass through and hand the problem over to the user space. The question is, at what point.
There are already FCP enclosures filled with SATA disks on the market so this problem in not unique to SAS. However they have (I presume) a SAT layer in their FC enclosures so the OS thinks it is taking to SCSI disks.
Doug Gilbert
Quoted 9 lines · Bartlomiej Zolnierkiewicz
Nice work Jens, some feedback below:
Quoted 4 lines · Jens Axboe
Index:
drivers/ide/ide-floppy.c
===================================================================drivers/ide/ide-floppy.c (mode:100644) +0
-0
Quoted 14 lines
drivers/ide/ide-floppy.c (mode:100644) line 1319
Quoted 12 lines
drivers/ide/ide-floppy.c (mode:100644) +2
-2@@ -1311,9 +1311,9 @@ } pc = idefloppy_next_pc_storage(drive); idefloppy_create_rw_cmd(floppy, pc, rq, block); - } else if (rq->flags & REQ_SPECIAL) { + } else if (blk_special_request(rq)) pc = (idefloppy_pc_t *) rq->buffer; - } else if (rq->flags & REQ_BLOCK_PC) { + } else if (blk_fs_request(rq)) { pc = idefloppy_next_pc_storage(drive); if (idefloppy_blockpc_cmd(floppy, pc, rq)) { idefloppy_do_end_request(drive, 0, 0);
blk_pc_request(rq)
Indeed, thanks!
Quoted 9 lines
Quoted 9 lines
Index:
drivers/ide/ide-io.c
===================================================================drivers/ide/ide-io.c (mode:100644) +0
-0@@ -948,9 +948,10 @@ if (!drive->special.all) { ide_driver_t *drv;
Quoted 11 lines
drivers/ide/ide-io.c (mode:100644) line 957
Quoted 9 lines
drivers/ide/ide-io.c (mode:100644) +3
-2- if (rq->flags & (REQ_DRIVE_CMD | REQ_DRIVE_TASK)) + if (rq->cmd_type == REQ_TYPE_ATA_CMD || + rq->cmd_type == REQ_TYPE_ATA_TASK) return execute_drive_cmd(drive, rq); - else if (rq->flags & REQ_DRIVE_TASKFILE) + else if (rq->cmd_type == REQ_TYPE_ATA_TASKFILE) return execute_drive_cmd(drive, rq); else if (blk_pm_request(rq)) { #ifdef DEBUG_PM||
rq->cmd_type==REQ_TYPE_ATA_TASKFILEwhile at it
Didn't even notice that, fixed.
Quoted 9 lines
Quoted 9 lines
Index:
drivers/scsi/ide-scsi.c
===================================================================drivers/scsi/ide-scsi.c (mode:100644) +0
-0@@ -370,12 +370,12 @@ u8 *scsi_buf; unsigned long flags;
Quoted 7 lines
drivers/scsi/ide-scsi.c (mode:100644) line 376
Quoted 5 lines
drivers/scsi/ide-scsi.c (mode:100644) +1
-1- if (!(rq->flags & (REQ_SPECIAL|REQ_SENSE))) { + if (!blk_special_request(rq) || !blk_sense_request(rq)) { ide_end_request(drive, uptodate, nrsecs); return 0; }!blk_special_request(rq) && !blk_sense_request(rq)
Thanks.
Quoted 5 lines
Quoted 4 lines
Index:
drivers/scsi/scsi_lib.c
===================================================================drivers/scsi/scsi_lib.c (mode:100644) +0
-0
Quoted 11 lines
drivers/scsi/scsi_lib.c (mode:100644) line 928
Quoted 9 lines
drivers/scsi/scsi_lib.c (mode:100644) +1
-1@@ -922,7 +922,7 @@ /* * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer */ - if ((req->flags & REQ_BLOCK_PC) && !req->bio) { + if (blk_pc_request(req) && req->bio) { cmd->request_bufflen = req->data_len; cmd->request_buffer = req->data; req->buffer = req->data;!req->bio
Yeah, this one I already found while trying to boot the patch, SG_IO barfed quickly without it.
Quoted 3 lines
I assume they you've verified that there are no odd cases possible like
rq->flags=REQ_DRIVE_TASKFILE|REQ_BAR_FLUSHorrq->flags=REQ_PC(withoutREQ_BLOCK_PC) which would be obviously broken by this patch?
Not fully verified yet, there's some work to be done there. REQ_PC never had REQ_BLOCK_PC set, I want to unify those two in ide-cd though. Should be pretty trivial, I hope to even kill of the old pc_interrupt handling and just use newpc_interrupt at the same time.
But that really should be on top of this patch, done afterwards!
Signature · 1 line
Jens Axboe
Quoted 12 lines · Benjamin Herrenschmidt
Quoted 11 lines · Jens Axboe
Quoted 9 lines · Jeff Garzik
Quoted 6 lines · Jens Axboe
I agree, it's a cleaner approach, with the rq being a container for generel messages as well not just SCSI commands. The one missing piece for that was the
rq->end_io()callback so everything doesn't have to go down sync, but that is in now as well.I'll try and cook something up.
Very cool ;)
Quoted 8 lines
Quoted 6 lines
This is the base for it. It splits
request->flagsinto two variables:-
cmd_type. this is not a bitmask, but a value indicating what type of request this is.-
cmd_flags. various command modified flags.I like it too. It's a long overdue cleanup :)
Indeed, it is something I wish I had done originally when moving away from the 2.4 rq->cmd setup. Better late than never :)
Quoted 3 lines
Another thing is we should/could probably move some of the other fields in the struct request into a union of structs. Some of them are never present simultaneously ...
Yes, that would be a nice way to save some space.
Signature · 1 line
Jens Axboe
Re: libata, SCSI and storage drivers
In reply to Douglas GilbertQuoted 8 lines · Douglas Gilbert
In a) the interconnect is SATA. Still it is hard to believe that the SAS HBA LLD would belong to anything other than the SCSI subsystem (since SAS HBAs come with 4 or 8 phys, others of which could be in scenario b) and/or connected to SAS disks). Hence the initiator_ports/phys/target_ports on and seen by that SAS HBA should (also) have SAS transport classes.
It should register with the SAS transport class, where the SAS discover "function" is. The Discover function would find out what is out on the domain and "register" it with the proper "transport" (a more correct way to put it there is).
For SSP devices that would be a "scsi disk", for SATA devices that would be a "libata disk" or something like this. The LLDD would either get a CDB for SSP, or taskfile for STP, and pass it along to the hardware.
Quoted 3 lines
When a SAS HBA phy is not connected to anything is it a member of a SAS transport class or a ATA transport class (or both)?
Quite possibly both: SAS transport class, since it is a super class in meaning that the Discover function is in there.
Quoted 6 lines
In scenario b) the left interconnect is SAS and the right interconnect is SATA. The
SAS_expandercontains the STP<->SATA bridging function (and, for sake of argument, no SCSI-ATA Translation (SAT) layer). Would scenario b) also have a ATA transport class? I'll assume it does. To be discovered it also
Yes it would. As far as the class is concerned it is a SATA device -- how you get to it (direct or through an expander) is the LLDD/firmware/Host Adapter concern.
Quoted 10 lines
needs a SAS transport class. Larger enclosures are likely to be amplifications of scenario b). The presence of the SATA disk in scenario b) will be discovered via the SAS SMP (i.e. talking to the
SAS_expander) or via the SES protocol (i.e. a SCSI Enclosure Services target running near theSAS_expander). Either way if there are a lot of SATA disks then they are likely to be held in their initialization sequence to stop them spinning up all at once. SAS transport intervention may be required (staggered timers are another possibility).
Yes, spinup-hold states would be managed by the Discover function, or by the FW on the expander/ses device.
BTW, very nice to mention SES devices. We'll have to bring that up more as they'd be very much en vogue with expanders.
Quoted 5 lines
Now I may be wrong but I think that one of the SAS HBAs that I have read about that looks (externally) like scenario a) but is actually scenario b). In other words the
SAS_expanderis silicon on the HBA and it is not controlled via the PCI bus, but rather by SMP.
I know of such a SAS HA (Host Adapter), and from what it seems the role of the expander-on-chip is to simulate a larger number of phys than actually/physically supported by the HA. By design, this should be transparent to the Discover function, and if it is not, I believe the Discover fn. would do the right thing (i.e. treat is as an expander).
Quoted 5 lines
This suggests to me we would need an ordered sequence of transport classes. I really wonder about trying to model this level of complexity in sysfs, plus the nightmare of keeping state data of (topologically) distant nodes up to date. At some point one needs to supply a management
When a SSP talking device is found it is registered as a "scsi device". When a STP talking device is discovered (directly attached or elsewhere) it would be registered as a "libata device".
Quoted 2 lines
pass through and hand the problem over to the user space. The question is, at what point.
I'm not 100% sure about user space. The Discover function is pretty straightforward, and simple. Plus the root/bootable device could be a SATA device on an expander or even deeper in the domain.
Thanks,
Luben