Re: [PATCH] block: fix mis-synchronisation in blkdev_issue_zeroout()

From: Jeff Moyer
Date: Fri Mar 04 2011 - 10:15:51 EST


Lukas Czerner <lczerner@xxxxxxxxxx> writes:

> On Fri, 4 Mar 2011, Jeff Moyer wrote:
>> It seems to me like it might be better to just not complete anything
>> until the count is zero. Why issue a wakeup for every bio?
>> fs/direct-io does something similar, maybe take a look at the
>> dio_bio_end* routines and see if that would fit well here. With your
>> scheme, I worry about missing a completion, maybe because the first bio
>> completes before you are done submitting bios. Is that possible?
>
> I do not think it is possible. For every bio submitted there is
> wait_for_completion called. When bio complete()s completion->done is
> incremented (under the wait->lock). In wait_for_completion() we are
> waiting for single submitted bio to complete (completion->done > 0),
> then completion->done is decremented. It seems like simple
> synchronization.
>
> I am not sure what wakeup you have in mind, but thanks for the tip I'll
> look in fs/direct-io.

Let's say you have several bios to submit, and the first bio is errored
immediately in submit_bio. Since you didn't add yourself to the
waitqueue yet, you might miss the wakeup and sleep forever.

Cheers,
Jeff
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/