Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] sd: disentangle barriers in SCSI

Our current implementation has a generic set of barrier functions that
go through the SCSI driver model. Realistically, this is unnecessary,
because the only device that can use barriers (sd) can set the flush
functions up at probe or revalidate time. This patch pulls the barrier
functions out of the mid layer and scsi driver model and relocates them
directly in sd.

Acked-by: Tejun Heo <htejun@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

James Bottomley and committed by
James Bottomley
03a5743a 66dbfbe6

+11 -24
-17
drivers/scsi/scsi_lib.c
··· 1038 1038 return BLKPREP_KILL; 1039 1039 } 1040 1040 1041 - static int scsi_issue_flush_fn(struct request_queue *q, struct gendisk *disk, 1042 - sector_t *error_sector) 1043 - { 1044 - struct scsi_device *sdev = q->queuedata; 1045 - struct scsi_driver *drv; 1046 - 1047 - if (sdev->sdev_state != SDEV_RUNNING) 1048 - return -ENXIO; 1049 - 1050 - drv = *(struct scsi_driver **) disk->private_data; 1051 - if (drv->issue_flush) 1052 - return drv->issue_flush(&sdev->sdev_gendev, error_sector); 1053 - 1054 - return -EOPNOTSUPP; 1055 - } 1056 - 1057 1041 static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev, 1058 1042 struct request *req) 1059 1043 { ··· 1580 1596 return NULL; 1581 1597 1582 1598 blk_queue_prep_rq(q, scsi_prep_fn); 1583 - blk_queue_issue_flush_fn(q, scsi_issue_flush_fn); 1584 1599 blk_queue_softirq_done(q, scsi_softirq_done); 1585 1600 return q; 1586 1601 }
+11 -3
drivers/scsi/sd.c
··· 241 241 }, 242 242 .rescan = sd_rescan, 243 243 .init_command = sd_init_command, 244 - .issue_flush = sd_issue_flush, 245 244 }; 246 245 247 246 /* ··· 799 800 return 0; 800 801 } 801 802 802 - static int sd_issue_flush(struct device *dev, sector_t *error_sector) 803 + static int sd_issue_flush(struct request_queue *q, struct gendisk *disk, 804 + sector_t *error_sector) 803 805 { 804 806 int ret = 0; 805 - struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); 807 + struct scsi_device *sdp = q->queuedata; 808 + struct scsi_disk *sdkp; 809 + 810 + if (sdp->sdev_state != SDEV_RUNNING) 811 + return -ENXIO; 812 + 813 + sdkp = scsi_disk_get_from_dev(&sdp->sdev_gendev); 806 814 807 815 if (!sdkp) 808 816 return -ENODEV; ··· 1668 1662 gd->queue = sdkp->device->request_queue; 1669 1663 1670 1664 sd_revalidate_disk(gd); 1665 + 1666 + blk_queue_issue_flush_fn(sdp->request_queue, sd_issue_flush); 1671 1667 1672 1668 gd->driverfs_dev = &sdp->sdev_gendev; 1673 1669 gd->flags = GENHD_FL_DRIVERFS;
-2
include/scsi/scsi_driver.h
··· 13 13 14 14 int (*init_command)(struct scsi_cmnd *); 15 15 void (*rescan)(struct device *); 16 - int (*issue_flush)(struct device *, sector_t *); 17 - int (*prepare_flush)(struct request_queue *, struct request *); 18 16 }; 19 17 #define to_scsi_driver(drv) \ 20 18 container_of((drv), struct scsi_driver, gendrv)
-2
include/scsi/sd.h
··· 56 56 static int sd_resume(struct device *dev); 57 57 static void sd_rescan(struct device *); 58 58 static int sd_init_command(struct scsi_cmnd *); 59 - static int sd_issue_flush(struct device *, sector_t *); 60 - static void sd_prepare_flush(struct request_queue *, struct request *); 61 59 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer); 62 60 static void scsi_disk_release(struct class_device *cdev); 63 61 static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);