Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3357916ybz; Mon, 20 Apr 2020 00:50:19 -0700 (PDT) X-Google-Smtp-Source: APiQypLWaz+CSE23YyrgNg/xS1GQczzQHLPbNL5A6mSU+gs5U9JnyKMJXaqh1ZI0DUeQQT+7P3EF X-Received: by 2002:a17:906:af99:: with SMTP id mj25mr14427140ejb.151.1587369018938; Mon, 20 Apr 2020 00:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587369018; cv=none; d=google.com; s=arc-20160816; b=dKfIBWU1KUF7NYgZ8vS3nY8VdEQi3J/Tr/TjKitCVSt0j9Rn3biiNKKfyWQkcbMwm8 p0T9JgoNvejiCTgE5H1dwEh3FdjUvzJQEtSxLq+Cu0YYDqjQ6wcEJ7ayy8E0s8KmQQwX lVnreOatQPEne+OdZN9bHk9L3fR37vpYcfM8iO2S2xCGJS/1vF7XlyQ1bi2cqiS993wh WqCh1GXL8n3sx7biqQf0GxP4+KAe6+a3PnQP1Gc+6/LEFCumt0jR8emmCtLsTItLJprG QzUQwUBNtyVS0cotSu+L6zvW8Z81lKrvsEALnXB8QLrHyIEwwiT/G4gDKw2sP/TwE0dd s3Bg== 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:from:references:cc:to:subject; bh=22hJjOhyOnL5jTu9O1G0Q7Ns2WCe1MTet/dzMQHkzFI=; b=oy9mbTkrQ8D7VMP90uYwglrICq7uHvI7a4LWz1EIFf5J+PISnWvvgqp8E8rdB9cL28 xwY+4Pv566NACVy1P9M9z8ikWa1ljBvyxzx8JE0QsUsYx8sGJyXIIYtplG2MBTcoJ8bX +L2ogvLtc5mISFUlqNxH5Pp8UyHNNWAE0uJSnILPB0EQSEP53XBq6kwJ8t/xLL7AMT0j qc6QewzUAHl3XMjmfHG7SRsLjwMpeeXmq0GP0J7zRwWivVIyoMW3JcsFz9bILAY2sFZX ZKTwyDEM+6I1+iARkceaJvTlZrzA3JcTSV+0GzWmNzNQG1ubBHZpMbSyispvgK6tLb6R gCJA== 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 j3si57260ejb.482.2020.04.20.00.49.56; Mon, 20 Apr 2020 00:50:18 -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 S1726079AbgDTHs0 (ORCPT + 99 others); Mon, 20 Apr 2020 03:48:26 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:47458 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725930AbgDTHs0 (ORCPT ); Mon, 20 Apr 2020 03:48:26 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 9753B57C67BC89FC2A2A; Mon, 20 Apr 2020 15:48:12 +0800 (CST) Received: from [127.0.0.1] (10.166.215.235) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Mon, 20 Apr 2020 15:48:03 +0800 Subject: Re: bcache: unlock new_nodes[i]->write_lock in btree_gc_coalesce To: Coly Li CC: , , , "wubo (T)" , Mingfangsen , Yanxiaodan , linfeilong References: <94f5343a-66c6-713c-4ce9-78c12ae5fd7a@suse.de> From: Zhiqiang Liu Message-ID: Date: Mon, 20 Apr 2020 15:48:01 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <94f5343a-66c6-713c-4ce9-78c12ae5fd7a@suse.de> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.166.215.235] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/4/20 15:10, Coly Li wrote: > 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 Thanks for your reply. I will try my best to rewrite the commit log. Regards. Zhiqiang Liu. > > >> 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); >>> >> > >