From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751366AbdEaIa1 (ORCPT ); Wed, 31 May 2017 04:30:27 -0400 Received: from m12-17.163.com ([220.181.12.17]:33780 "EHLO m12-17.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbdEaIaZ (ORCPT ); Wed, 31 May 2017 04:30:25 -0400 Message-ID: <592E7F56.7050400@163.com> Date: Wed, 31 May 2017 16:31:18 +0800 From: Jia-Ju Bai User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1 MIME-Version: 1.0 To: Jia-Ju Bai CC: kent.overstreet@gmail.com, shli@kernel.org, axboe@fb.com, mchristi@redhat.com, git@linux.ewheeler.net, colyli@suse.de, akpm@linux-foundation.org, wangyijing@huawei.com, mingo@kernel.org, mhocko@suse.com, linux-bcache@vger.kernel.org, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bcache: Fix a sleep-in-atomic bug References: <1496215420-15819-1-git-send-email-baijiaju1990@163.com> In-Reply-To: <1496215420-15819-1-git-send-email-baijiaju1990@163.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-CM-TRANSID: EcCowACXrCzRfi5ZqLudHQ--.59546S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7XryfCw18tFy5uF1xXrWkJFb_yoWDXrgE9F 15XFW2vwsxKr43Zw1xGr4furWY9F1DWr95Ga1ftayakFy3Ja97Gr1Dtw1UJr18Za1xCFy5 Gw4qq3y0v3sI9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8RMKtUUUUU== X-Originating-IP: [166.111.70.19] X-CM-SenderInfo: xedlyx5dmximizq6il2tof0z/1tbiHh3oelSIVVO+dgAAsD Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/31/2017 03:23 PM, Jia-Ju Bai wrote: > The driver may sleep under a spin lock, and the function call path is: > journal_wait_for_write (acquire the lock by spin_lock) > closure_sync > schedule --> may sleep > > To fix it, the lock is released before "closure_sync", and the lock is > acquired again after this function. > > Signed-off-by: Jia-Ju Bai > --- > drivers/md/bcache/journal.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c > index 1198e53..ad47c36 100644 > --- a/drivers/md/bcache/journal.c > +++ b/drivers/md/bcache/journal.c > @@ -724,6 +724,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c, > btree_flush_write(c); > } > > + spin_unlock(&c->journal.lock); > closure_sync(&cl); > spin_lock(&c->journal.lock); > wait = true; Sorry, my patch is not correct, and it will cause double unlock. Please ignore my patch. Jia-Ju Bai