fix race condition in sg.c
Subsystems (2)
PATCH 1/1 fix race condition in sg.c
This patch fixes a command completion race condition in the SCSI generic driver. There are several variations of this patch floating around:
#1: Original patch from me:
http://marc.theaimsgroup.com/?t=105664088400001&r=1&w=2
#2: Better patch from Brian King for lk 2.6.x:
http://marc.theaimsgroup.com/?t=107843139000002&r=1&w=2
#3: Patch for a related problem from Brian King for lk 2.6.x:
http://marc.theaimsgroup.com/?t=108636397100004&r=1&w=2
#4: Port of combined #2 and #3 to lk 2.4.x from Tom Coughlan:
http://marc.theaimsgroup.com/?t=109657360500004&r=1&w=2
#5: Correction of #4 by me:
http://marc.theaimsgroup.com/?l=linux-scsi&m=109658140509138&w=2
None of these fixes have made it into lk 2.4.x yet. Below is a port of patch #2 to 2.4.x which has been extensively tested by my company. Patch #5 which includes these changes would be better, but I haven't tested it. Please apply this patch, and the additional changes for patch #5 can be merged later if and when they are tested by those interested.
drivers/scsi/sg.c +2 -2
@@ -1253,7 +1253,6 @@ SRpnt->sr_request.rq_dev =MKDEV (0 ,0 );/* "sg" _disowns_ request blk */ srp->my_cmdp =NULL ; - srp->done =1 ;read_unlock (&sg_dev_arr_lock); SCSI_LOG_TIMEOUT(4, printk("sg...bh: dev=%d, pack_id=%d, res=0x%x\n",
@@ -1316,8 +1315,9 @@ }if (sfp && srp) {/* Now wake up any sg_read() that is waiting for this packet. */ -wake_up_interruptible (&sfp->read_wait);kill_fasync (&sfp->async_qp,SIGPOLL ,POLL_IN ); + srp->done =1 ; +wake_up_interruptible (&sfp->read_wait); } }
Anthony J. Battersby
Cybernetics