Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3333278ybz; Mon, 20 Apr 2020 00:14:04 -0700 (PDT) X-Google-Smtp-Source: APiQypIhknURjio63/OKK1dkDnAeKl+Zr0R//5iyXSKrGdFIOh7V18Cd8tFtA1dxEA8KR9UDSFr4 X-Received: by 2002:a50:9dc9:: with SMTP id l9mr12757132edk.39.1587366844415; Mon, 20 Apr 2020 00:14:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587366844; cv=none; d=google.com; s=arc-20160816; b=gPG+uAVfq3+yqGUrOZ87hL+XhGmZcvbv9CVRjf7MsPkai4X9xIeAnkWYa5/lNy8fAa gTmTdftUUe3+3NVnZbujZwbYA0zTxFURCJI2+udDJ8cglGVkiGeyNEwL1YyrmcOmav2B KUQspwwzcqAqcnaSCguaOnpbdD8bMogyg+P9I+Jj6EXksI7CfhvpwOdyfxmoCoM3Kl3Z 0QIPTczyGSTqzTibbZFzeSy+eYWWd/TgKiTrqEN23JBG43G1wH/t2rdu5Cucz28iplWZ dyGVQVijHRdRIG2DgNsID6Mr3Rp2iWfjGswjdnOy1r7Yq1zTWICOr3lGUbp9xyoFLSG7 S3Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=tOXC92/rn8okR99BUfj2V5a+ELVZPAHqtwVVb3X9Sxk=; b=mVWYLh6WvsumDZBYFOV2jvRdnSfguRl4wI+1ka9M4iEPZVZpoc7Ec7IQPV6yX9gCsy BgdggDGKMHt8YnoMGnix1EZpBelAd2A+j1gWjH22GMTc7so0gEq+OAdaBqhDkOllCy77 EQEFV20kjfU4CblRxiVfY3dhDdRnfL89/+K/weR1cUAsphqA4AeYk+QZlWSZHqvdlk58 aIEB3HGrFaOKu5sbSPUj/TACnlwukWWO4+UPuMG977ZZe66J706Vm9pbXuVJbmIg6CvS 8e9f/bM+upDQfKqyxQJUjmH1s39mz3fXLZzmKDTodDmnm1bNZCytb4kCZTXsXWA6mrNX GB4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si12469ejg.296.2020.04.20.00.13.41; Mon, 20 Apr 2020 00:14:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726183AbgDTHKl (ORCPT + 99 others); Mon, 20 Apr 2020 03:10:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:39200 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgDTHKk (ORCPT ); Mon, 20 Apr 2020 03:10:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B5D33AB76; Mon, 20 Apr 2020 07:10:37 +0000 (UTC) Subject: Re: bcache: unlock new_nodes[i]->write_lock in btree_gc_coalesce To: Zhiqiang Liu Cc: kmo@daterainc.com, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, "wubo (T)" , Mingfangsen , Yanxiaodan , linfeilong References: From: Coly Li Autocrypt: addr=colyli@suse.de; keydata= mQINBFYX6S8BEAC9VSamb2aiMTQREFXK4K/W7nGnAinca7MRuFUD4JqWMJ9FakNRd/E0v30F qvZ2YWpidPjaIxHwu3u9tmLKqS+2vnP0k7PRHXBYbtZE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CAAmAhsMFiEE6j5FL/T5SGCN6PrQxzkHk2t9+PwFAlxHziAFCRj7 5/EACgkQxzkHk2t9+PxgfA//cH5R1DvpJPwraTAl24SUcG9EWe+NXyqveApe05nk15zEuxxd e4zFEjo+xYZilSveLqYHrm/amvQhsQ6JLU+8N60DZHVcXbw1Eb8CEjM5oXdbcJpXh1/1BEwl 4phsQMkxOTns51bGDhTQkv4lsZKvNByB9NiiMkT43EOx14rjkhHw3rnqoI7ogu8OO7XWfKcL CbchjJ8t3c2XK1MUe056yPpNAT2XPNF2EEBPG2Y2F4vLgEbPv1EtpGUS1+JvmK3APxjXUl5z 6xrxCQDWM5AAtGfM/IswVjbZYSJYyH4BQKrShzMb0rWUjkpXvvjsjt8rEXpZEYJgX9jvCoxt oqjCKiVLpwje9WkEe9O9VxljmPvxAhVqJjX62S+TGp93iD+mvpCoHo3+CcvyRcilz+Ko8lfO hS9tYT0HDUiDLvpUyH1AR2xW9RGDevGfwGTpF0K6cLouqyZNdhlmNciX48tFUGjakRFsxRmX K0Jx4CEZubakJe+894sX6pvNFiI7qUUdB882i5GR3v9ijVPhaMr8oGuJ3kvwBIA8lvRBGVGn 9xvzkQ8Prpbqh30I4NMp8MjFdkwCN6znBKPHdjNTwE5PRZH0S9J0o67IEIvHfH0eAWAsgpTz +jwc7VKH7vkvgscUhq/v1/PEWCAqh9UHy7R/jiUxwzw/288OpgO+i+2l11Y= Message-ID: <94f5343a-66c6-713c-4ce9-78c12ae5fd7a@suse.de> Date: Mon, 20 Apr 2020 15:10:30 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/20 14:55, Zhiqiang Liu wrote: > friendly ping... > The patch is good. Just it would be better if the commit log can be more accurate and understandable for other readers who are not very familiar with bcache code. Thanks. Coly Li > On 2020/4/15 19:42, Zhiqiang Liu wrote: >> From: Zhiqiang Liu >> >> coccicheck reports: >> drivers/md//bcache/btree.c:1538:1-7: preceding lock on line 1417 >> >> After obtaining new_nodes[i]->write_lock, we may go to out_nocoalesce >> tag without releasing lock. Here, we add a new tag >> 'out_unlock_nocoalesce' before out_nocoalesce tag to release >> new_nodes[i]->write_lock. >> >> Fixes: 2a285686c1 ("bcache: btree locking rework") >> Signed-off-by: Zhiqiang Liu >> --- >> drivers/md/bcache/btree.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c >> index fa872df4e770..cad8b0b97e33 100644 >> --- a/drivers/md/bcache/btree.c >> +++ b/drivers/md/bcache/btree.c >> @@ -1447,7 +1447,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, >> if (__set_blocks(n1, n1->keys + n2->keys, >> block_bytes(b->c)) > >> btree_blocks(new_nodes[i])) >> - goto out_nocoalesce; >> + goto out_unlock_nocoalesce; >> >> keys = n2->keys; >> /* Take the key of the node we're getting rid of */ >> @@ -1476,7 +1476,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, >> >> if (__bch_keylist_realloc(&keylist, >> bkey_u64s(&new_nodes[i]->key))) >> - goto out_nocoalesce; >> + goto out_unlock_nocoalesce; >> >> bch_btree_node_write(new_nodes[i], &cl); >> bch_keylist_add(&keylist, &new_nodes[i]->key); >> @@ -1522,6 +1522,10 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op, >> /* Invalidated our iterator */ >> return -EINTR; >> >> +out_unlock_nocoalesce: >> + for (i = 0; i < nodes; i++) >> + mutex_unlock(&new_nodes[i]->write_lock); >> + >> out_nocoalesce: >> closure_sync(&cl); >> >