From: Jeff Moyer Subject: Re: [PATCH] block: fix mis-synchronisation in blkdev_issue_zeroout() Date: Fri, 04 Mar 2011 10:15:43 -0500 Message-ID: References: <1299231968-5730-1-git-send-email-lczerner@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Lukas Czerner Return-path: In-Reply-To: (Lukas Czerner's message of "Fri, 4 Mar 2011 16:04:16 +0100 (CET)") Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Lukas Czerner 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