From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3112BC6FD20 for ; Fri, 24 Mar 2023 16:55:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231716AbjCXQzs (ORCPT ); Fri, 24 Mar 2023 12:55:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbjCXQzq (ORCPT ); Fri, 24 Mar 2023 12:55:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4BB212D for ; Fri, 24 Mar 2023 09:55:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 518B262A3E for ; Fri, 24 Mar 2023 16:55:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97EF5C433D2; Fri, 24 Mar 2023 16:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679676943; bh=ZEbjlpAh2WrqUnDW5ZNWKy6ydvQ8KRSfEkJ24vJOxjw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ffCp+pIcMsdyYgAbrBCxSn401DJbItZ+VxxFzMHcsXi2VWGOLY2bX/srw/reGOTFQ HqDM7b+qO2peo1iRH5gMoLIP79B6AGdrgv++ql4AAaOLvY43id26vhJQxmiQ5e0y9D HgLFg8NzMx3WDInKRPa8Pi52ceDBvoD8ian5IzW9zFBjjIKIuaAIgO29qphc08J9FK ioqq+J4QaKTZWQsgSxZWYBLajFvYL6lhDnBXUom+gcB5jvj/d+dq2CBdUCrQlYdxE4 NkMaM+xSythvSS17VvfO/pYobKS/b8MftiyS1DXAKaJUHFJhZwBvauOIfNZmn1KB4H 1iRgbhZ0SFQaQ== Date: Fri, 24 Mar 2023 09:55:42 -0700 From: Jaegeuk Kim To: "Colin King (gmail)" Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, "linux-kernel@vger.kernel.org" Subject: Re: f2fs: factor out discard_cmd usage from general rb_tree use Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/24, Colin King (gmail) wrote: > Hi, > > static analysis with clang scan build has detected a potential issue > introduced by the following commit: > > commit 7e9775a516ff6c1e73ee2b42ec563cafee38f42f > Author: Jaegeuk Kim > Date: Fri Mar 10 11:12:35 2023 -0800 > > f2fs: factor out discard_cmd usage from general rb_tree use Good catch! I found the bug and will post v2 soon. > > > The warning is as follows: > > fs/f2fs/segment.c:1425:4: warning: Value stored to 'tdc' is never read > [deadcode.DeadStores] > > The while loop in function __update_discard_tree_range is as follows (+ my > annotations): > > > while (1) { > struct rb_node *node; > struct discard_cmd *tdc = NULL; > > ### tdc is set to NULL > > if (prev_dc) { > di.lstart = prev_dc->di.lstart + prev_dc->di.len; > if (di.lstart < lstart) > di.lstart = lstart; > if (di.lstart >= end) > break; > > if (!next_dc || next_dc->di.lstart > end) > di.len = end - di.lstart; > else > di.len = next_dc->di.lstart - di.lstart; > di.start = start + di.lstart - lstart; > } > > if (!di.len) > goto next; > > if (prev_dc && prev_dc->state == D_PREP && > prev_dc->bdev == bdev && > __is_discard_back_mergeable(&di, &prev_dc->di, > > max_discard_blocks)) { > prev_dc->di.len += di.len; > dcc->undiscard_blks += di.len; > __relocate_discard_cmd(dcc, prev_dc); > di = prev_dc->di; > tdc = prev_dc; > > ### tdc is set to prev_dc, however, it is not not read any more with th > introduction of the "goto next"" statement introduced in the commit > mentioned earlier > > goto next; > } > > if (next_dc && next_dc->state == D_PREP && > next_dc->bdev == bdev && > __is_discard_front_mergeable(&di, &next_dc->di, > > max_discard_blocks)) { > next_dc->di.lstart = di.lstart; > next_dc->di.len += di.len; > next_dc->di.start = di.start; > dcc->undiscard_blks += di.len; > __relocate_discard_cmd(dcc, next_dc); > > ### tdc is always NULL, there is no path to this code where tdc is ever set > to a non-NULL value. > > if (tdc) > __remove_discard_cmd(sbi, tdc); > goto next; > } > > __insert_discard_cmd(sbi, bdev, di.lstart, di.start, > di.len); > next: > prev_dc = next_dc; > if (!prev_dc) > break; > > node = rb_next(&prev_dc->rb_node); > next_dc = rb_entry_safe(node, struct discard_cmd, rb_node); > } > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (unknown [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 69604C6FD1C for ; Fri, 24 Mar 2023 16:56:03 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pfkht-0003S9-BC; Fri, 24 Mar 2023 16:56:02 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pfkhk-0003S0-1R for linux-f2fs-devel@lists.sourceforge.net; Fri, 24 Mar 2023 16:55:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IeUI0dILKAxSbFsLZB41eqbavgPVFjZ83d4rKEO18SI=; b=JXhCmRMb5MnzNwR49swqTd93VO 99XSu8qlxX+IRiv45G9yU3Jt+m5KKSMGZkvdffk+ahIoanqzomaFZnSD62tEmyhy8lOOQN/3H3ZN+ mD8yo4pVAG7Jbtw4VlxHMDQA+rs/Bz3B4rvDUiz6V8xYGab1NIDeQEIh8g0PDrNQchJI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=IeUI0dILKAxSbFsLZB41eqbavgPVFjZ83d4rKEO18SI=; b=HRaxr+zLhYNEJThwMv7ejtIZR0 fMBwDJmlzHIOiFMYb7o6ZJkjDPVvizNcM+52R7l2oKLpZ9bxogM2HhJ22bmq/q6sPKxShAZwF/pKh FEg53DQjLSI5pwgkunJf5USr6315OYt/vfExfdRwqkDtIZbcN0+lCDZE+cDR3TWkjPKA=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pfkhi-0002c9-H6 for linux-f2fs-devel@lists.sourceforge.net; Fri, 24 Mar 2023 16:55:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 51B4762BE6; Fri, 24 Mar 2023 16:55:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97EF5C433D2; Fri, 24 Mar 2023 16:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679676943; bh=ZEbjlpAh2WrqUnDW5ZNWKy6ydvQ8KRSfEkJ24vJOxjw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ffCp+pIcMsdyYgAbrBCxSn401DJbItZ+VxxFzMHcsXi2VWGOLY2bX/srw/reGOTFQ HqDM7b+qO2peo1iRH5gMoLIP79B6AGdrgv++ql4AAaOLvY43id26vhJQxmiQ5e0y9D HgLFg8NzMx3WDInKRPa8Pi52ceDBvoD8ian5IzW9zFBjjIKIuaAIgO29qphc08J9FK ioqq+J4QaKTZWQsgSxZWYBLajFvYL6lhDnBXUom+gcB5jvj/d+dq2CBdUCrQlYdxE4 NkMaM+xSythvSS17VvfO/pYobKS/b8MftiyS1DXAKaJUHFJhZwBvauOIfNZmn1KB4H 1iRgbhZ0SFQaQ== Date: Fri, 24 Mar 2023 09:55:42 -0700 From: Jaegeuk Kim To: "Colin King (gmail)" Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1pfkhi-0002c9-H6 Subject: Re: [f2fs-dev] f2fs: factor out discard_cmd usage from general rb_tree use X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "linux-kernel@vger.kernel.org" , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 03/24, Colin King (gmail) wrote: > Hi, > > static analysis with clang scan build has detected a potential issue > introduced by the following commit: > > commit 7e9775a516ff6c1e73ee2b42ec563cafee38f42f > Author: Jaegeuk Kim > Date: Fri Mar 10 11:12:35 2023 -0800 > > f2fs: factor out discard_cmd usage from general rb_tree use Good catch! I found the bug and will post v2 soon. > > > The warning is as follows: > > fs/f2fs/segment.c:1425:4: warning: Value stored to 'tdc' is never read > [deadcode.DeadStores] > > The while loop in function __update_discard_tree_range is as follows (+ my > annotations): > > > while (1) { > struct rb_node *node; > struct discard_cmd *tdc = NULL; > > ### tdc is set to NULL > > if (prev_dc) { > di.lstart = prev_dc->di.lstart + prev_dc->di.len; > if (di.lstart < lstart) > di.lstart = lstart; > if (di.lstart >= end) > break; > > if (!next_dc || next_dc->di.lstart > end) > di.len = end - di.lstart; > else > di.len = next_dc->di.lstart - di.lstart; > di.start = start + di.lstart - lstart; > } > > if (!di.len) > goto next; > > if (prev_dc && prev_dc->state == D_PREP && > prev_dc->bdev == bdev && > __is_discard_back_mergeable(&di, &prev_dc->di, > > max_discard_blocks)) { > prev_dc->di.len += di.len; > dcc->undiscard_blks += di.len; > __relocate_discard_cmd(dcc, prev_dc); > di = prev_dc->di; > tdc = prev_dc; > > ### tdc is set to prev_dc, however, it is not not read any more with th > introduction of the "goto next"" statement introduced in the commit > mentioned earlier > > goto next; > } > > if (next_dc && next_dc->state == D_PREP && > next_dc->bdev == bdev && > __is_discard_front_mergeable(&di, &next_dc->di, > > max_discard_blocks)) { > next_dc->di.lstart = di.lstart; > next_dc->di.len += di.len; > next_dc->di.start = di.start; > dcc->undiscard_blks += di.len; > __relocate_discard_cmd(dcc, next_dc); > > ### tdc is always NULL, there is no path to this code where tdc is ever set > to a non-NULL value. > > if (tdc) > __remove_discard_cmd(sbi, tdc); > goto next; > } > > __insert_discard_cmd(sbi, bdev, di.lstart, di.start, > di.len); > next: > prev_dc = next_dc; > if (!prev_dc) > break; > > node = rb_next(&prev_dc->rb_node); > next_dc = rb_entry_safe(node, struct discard_cmd, rb_node); > } > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel