linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sd: disentangle barriers in SCSI
@ 2007-08-03 21:41 James Bottomley
  2007-08-04  8:51 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: James Bottomley @ 2007-08-03 21:41 UTC (permalink / raw)
  To: linux-scsi, Tejun Heo

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.

James

Index: BUILD-2.6/drivers/scsi/scsi_lib.c
===================================================================
--- BUILD-2.6.orig/drivers/scsi/scsi_lib.c	2007-08-03 16:00:43.000000000 -0500
+++ BUILD-2.6/drivers/scsi/scsi_lib.c	2007-08-03 16:01:08.000000000 -0500
@@ -1038,22 +1038,6 @@ static int scsi_init_io(struct scsi_cmnd
 	return BLKPREP_KILL;
 }
 
-static int scsi_issue_flush_fn(struct request_queue *q, struct gendisk *disk,
-			       sector_t *error_sector)
-{
-	struct scsi_device *sdev = q->queuedata;
-	struct scsi_driver *drv;
-
-	if (sdev->sdev_state != SDEV_RUNNING)
-		return -ENXIO;
-
-	drv = *(struct scsi_driver **) disk->private_data;
-	if (drv->issue_flush)
-		return drv->issue_flush(&sdev->sdev_gendev, error_sector);
-
-	return -EOPNOTSUPP;
-}
-
 static struct scsi_cmnd *scsi_get_cmd_from_req(struct scsi_device *sdev,
 		struct request *req)
 {
@@ -1596,7 +1580,6 @@ struct request_queue *scsi_alloc_queue(s
 		return NULL;
 
 	blk_queue_prep_rq(q, scsi_prep_fn);
-	blk_queue_issue_flush_fn(q, scsi_issue_flush_fn);
 	blk_queue_softirq_done(q, scsi_softirq_done);
 	blk_queue_protocol(q, BLK_PROTOCOL_SCSI);
 	return q;
Index: BUILD-2.6/drivers/scsi/sd.c
===================================================================
--- BUILD-2.6.orig/drivers/scsi/sd.c	2007-08-03 16:00:37.000000000 -0500
+++ BUILD-2.6/drivers/scsi/sd.c	2007-08-03 16:39:13.000000000 -0500
@@ -241,7 +241,6 @@ static struct scsi_driver sd_template = 
 	},
 	.rescan			= sd_rescan,
 	.init_command		= sd_init_command,
-	.issue_flush		= sd_issue_flush,
 };
 
 /*
@@ -800,10 +799,17 @@ static int sd_sync_cache(struct scsi_dis
 	return 0;
 }
 
-static int sd_issue_flush(struct device *dev, sector_t *error_sector)
+static int sd_issue_flush(struct request_queue *q, struct gendisk *disk,
+			  sector_t *error_sector)
 {
 	int ret = 0;
-	struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev);
+	struct scsi_device *sdp = q->queuedata;
+	struct scsi_disk *sdkp;
+
+	if (sdp->sdev_state != SDEV_RUNNING)
+		return -ENXIO;
+
+	sdkp = scsi_disk_get_from_dev(&sdp->sdev_gendev);
 
 	if (!sdkp)
                return -ENODEV;
@@ -1663,6 +1669,8 @@ static int sd_probe(struct device *dev)
 
 	sd_revalidate_disk(gd);
 
+	blk_queue_issue_flush_fn(sdp->request_queue, sd_issue_flush);
+
 	gd->driverfs_dev = &sdp->sdev_gendev;
 	gd->flags = GENHD_FL_DRIVERFS;
 	if (sdp->removable)
Index: BUILD-2.6/include/scsi/scsi_driver.h
===================================================================
--- BUILD-2.6.orig/include/scsi/scsi_driver.h	2007-08-03 16:00:30.000000000 -0500
+++ BUILD-2.6/include/scsi/scsi_driver.h	2007-08-03 16:00:50.000000000 -0500
@@ -13,8 +13,6 @@ struct scsi_driver {
 
 	int (*init_command)(struct scsi_cmnd *);
 	void (*rescan)(struct device *);
-	int (*issue_flush)(struct device *, sector_t *);
-	int (*prepare_flush)(struct request_queue *, struct request *);
 };
 #define to_scsi_driver(drv) \
 	container_of((drv), struct scsi_driver, gendrv)
Index: BUILD-2.6/include/scsi/sd.h
===================================================================
--- BUILD-2.6.orig/include/scsi/sd.h	2007-08-03 16:06:29.000000000 -0500
+++ BUILD-2.6/include/scsi/sd.h	2007-08-03 16:06:44.000000000 -0500
@@ -56,8 +56,6 @@ static int sd_suspend(struct device *dev
 static int sd_resume(struct device *dev);
 static void sd_rescan(struct device *);
 static int  sd_init_command(struct scsi_cmnd *);
-static int  sd_issue_flush(struct device *, sector_t *);
-static void sd_prepare_flush(struct request_queue *, struct request *);
 static void sd_read_capacity(struct scsi_disk *sdkp, unsigned char *buffer);
 static void scsi_disk_release(struct class_device *cdev);
 static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *);



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sd: disentangle barriers in SCSI
  2007-08-03 21:41 [PATCH] sd: disentangle barriers in SCSI James Bottomley
@ 2007-08-04  8:51 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2007-08-04  8:51 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi

James Bottomley wrote:
> 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.

Looks good to me.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-04  8:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-03 21:41 [PATCH] sd: disentangle barriers in SCSI James Bottomley
2007-08-04  8:51 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).