Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys



On 27 Aug 2015, at 13:26, Michael van Elst <mlelstv%serpens.de@localhost> wrote:

> On Thu, Aug 27, 2015 at 11:48:15AM +0200, J. Hannken-Illjes wrote:
> 
>>                disk_busy(&dksc->sc_dkdev);
>> +               mutex_exit(&dksc->sc_iolock);
>>                error = dkd->d_diskstart(dksc->sc_dev, bp);
>> +               mutex_enter(&dksc->sc_iolock);
>>                if (error == EAGAIN) {
>> +                       dksc->sc_deferred = bp;
>>                        disk_unbusy(&dksc->sc_dkdev, 0, (bp->b_flags & B_READ));
>>                        break;
>>                }
>> 
>> Looks racy: what if two threads run  dk_strategy() -> dk_start() and
>> both get EAGAIN.  Will it leak a buffer when the second thread tries
>> to save bp and dksc->sc_deferred already holds the buffer from the
>> first thread?
> 
> Looks like it. sc_deferred probably needs to become a fcfs bufq.
> Currently this could happen for the ld driver (others are not MP_SAFE).
> 
> It would be simpler if you could unget something into the original
> bufq.

Another approach is to enqueue the buffer from dk_strategy(), use
dk_start() without bp to notify the device.  The device start
routine would take buffers from the queue and start them until
it gets out of resources and the device would call its start
routine on completion of a request.

--
J. Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig (Germany)



Home | Main Index | Thread Index | Old Index