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

[SCSI] sd: fix issue_flush

sd_issue_flush() is called from atomic context so we can't use the
semaphore based routines to get a reference to the scsi_disk. Assume
something else already got the reference so we can safely use it.

Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>

authored by

James Bottomley and committed by
James Bottomley
c0ed79a3 2ef89198

+9 -13
+9 -13
drivers/scsi/sd.c
··· 769 769 static int sd_prepare_flush(request_queue_t *q, struct request *rq) 770 770 { 771 771 struct scsi_device *sdev = q->queuedata; 772 - struct scsi_disk *sdkp = scsi_disk_get_from_dev(&sdev->sdev_gendev); 773 - int ret = 0; 772 + struct scsi_disk *sdkp = dev_get_drvdata(&sdev->sdev_gendev); 774 773 775 - if (sdkp) { 776 - if (sdkp->WCE) { 777 - memset(rq->cmd, 0, sizeof(rq->cmd)); 778 - rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; 779 - rq->timeout = SD_TIMEOUT; 780 - rq->cmd[0] = SYNCHRONIZE_CACHE; 781 - ret = 1; 782 - } 783 - scsi_disk_put(sdkp); 784 - } 785 - return ret; 774 + if (!sdkp || !sdkp->WCE) 775 + return 0; 776 + 777 + memset(rq->cmd, 0, sizeof(rq->cmd)); 778 + rq->flags |= REQ_BLOCK_PC | REQ_SOFTBARRIER; 779 + rq->timeout = SD_TIMEOUT; 780 + rq->cmd[0] = SYNCHRONIZE_CACHE; 781 + return 1; 786 782 } 787 783 788 784 static void sd_rescan(struct device *dev)