Hi,
I have two small bug fixes for the sg device.
- sg might need to restart the sd queue (this is done in scsi_ioctl.c but
not in sg.c)
- initializing my_cmdp in a new Sg_request with 0 marks it free and until
it's really initialized, sg_write might sleep and sg_read removes this as
finished command (this is a problem for mutlithreaded applications, which
use a seperate threads for reading/writing scsi commands).
This patch is for 2.2.15, but I think the first problem also exists in
2.3.x.
bye, Roman
Index: linux-2.2/drivers/scsi/sg.c
===================================================================
RCS file: /dump/cvs/linux-2.2/drivers/scsi/sg.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 sg.c
--- linux-2.2/drivers/scsi/sg.c 2000/03/22 12:15:31 1.1.1.1
+++ linux-2.2/drivers/scsi/sg.c 2000/05/24 09:10:37
@@ -691,6 +691,8 @@
Sg_device * sdp;
Sg_fd * sfp;
Sg_request * srp = NULL;
+ Scsi_Device * SDpnt;
+ unsigned long flags;
static const int min_sb_len =
SG_MAX_SENSE > sizeof(SCpnt->sense_buffer) ?
sizeof(SCpnt->sense_buffer) : SG_MAX_SENSE;
@@ -790,7 +792,7 @@
wake_up(&SCpnt->device->device_wait);
scsi_release_command(SCpnt);
- SCpnt = NULL;
+
if (sfp->closed) { /* whoops this fd already released, cleanup */
SCSI_LOG_TIMEOUT(1,
printk("sg__done: already closed, freeing ...\n"));
@@ -810,6 +812,12 @@
if (sfp->async_qp)
kill_fasync(sfp->async_qp, SIGPOLL);
}
+
+ spin_lock_irqsave(&io_request_lock, flags);
+ SDpnt = SCpnt->device;
+ if (!SDpnt->was_reset && SDpnt->scsi_request_fn)
+ (*SDpnt->scsi_request_fn)();
+ spin_unlock_irqrestore(&io_request_lock, flags);
}
static void sg_debug_all(const Sg_fd * sfp)
@@ -1463,7 +1471,7 @@
resp->res_used = 0;
memset(&resp->data, 0, sizeof(Sg_scatter_hold));
memset(&resp->header, 0, sizeof(struct sg_header));
- resp->my_cmdp = NULL;
+ resp->my_cmdp = (Scsi_Cmnd *)-1;
}
return resp;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]