Subject: Re: Race in scsipi_execute_xs()? (Was: Re: More on se0)
To: Leo Weppelman <leo@wau.mis.ah.nl>
From: Julian Coleman <J.D.Coleman@newcastle.ac.uk>
List: tech-kern
Date: 08/12/1998 14:01:56
Leo Weppelman wrote:
> I think you've just found a race-condition in the scsi code... I think
> what happens is this:
> scsipi_execute_xs()
> scsipi_command_direct() = SUCCESSFULLY_QUEUED
> ..... Some interrupts happen along the way causing the
> scsi-command to have finished in the mean time. NOSLEEP
> is set, so no wakeup/return is done, the xs-structure
> is freed instead (argh!).
> -> now the resuming sections of scsipi_execute_xs() use an already
> freed xs....
This is very possible. Looking at my debug output, it's likely that there
are 2 calls going on simultaneously. Now, I think that one has SCSI_NOSLEEP
set but the other doesn't.
> One way that might work to get around this is the addition of a FREEWHENDONE
> flag. So the code in scsipi_execute_xs() looks like:
> ....
> switch (scsipi_command_direct(xs)) {
> case SUCCESSFULLY_QUEUED:
> if ((xs->flags & (SCSI_NOSLEEP | SCSI_POLL)) == SCSI_NOSLEEP) {
> xs->flags |= SCSI_FREEWHENDONE;
> return (EJUSTRETURN);
> }
> .....
>
> The tail of scsipi_done() will look like:
>
> .....
> if (xs->flags & SCSI_FREEWHENDONE)
> scsipi_free_xs(xs, SCSI_NOSLEEP);
> if (bp)
> .....
Erm, I'm not sure about this. I think [*] that scsipi_done() is called
from inside scsipi_command_direct(xs)), so the flag is getting clobbered
in scsipi_free_xs(). Thus, setting it after the 'case SUCCESSFULLY_QUEUED:'
won't have any effect. I'll check this evening though.
Thanks,
J
[*] I haven't got all my notes with me at work.
PS. For (most) people who have missed the start of the thread, I'm trying
to get a Cabletron EA412 SCSI<->ethernet box (if_se.c) to work with an
Atari TT.
--
1024/55A5BC19 0F 3F 62 56 18 10 8B 84 43 8F F4 94 93 37 76 AA
S.E.P.