Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1408207rwl; Fri, 24 Mar 2023 10:05:59 -0700 (PDT) X-Google-Smtp-Source: AKy350bMLEVGrK5NnYP2JPavci6lAvJNQutoGZKZc0vPw2kDpFpTdUGYin246MLp3sfI3nUlFWN4 X-Received: by 2002:a17:902:d195:b0:1a1:b8cc:59cc with SMTP id m21-20020a170902d19500b001a1b8cc59ccmr2493946plb.39.1679677559276; Fri, 24 Mar 2023 10:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679677559; cv=none; d=google.com; s=arc-20160816; b=W7f3kyYANPP4d0jHX2LCcFlRKhQOgqcoxiVKVrPrVET6EO/w0xfN7WhwT32UZsJFs8 XaQPMmHrwV8av0kH06g0cYu9muuaT3QjqLamUm7kzEYFHn87P8xKGYXwpMtq/9KF7eNV VujCnkjiP7OBoyWdWomBShPU4YHjDLiLRXTnmb27wpsqBM8ucw7QdR3pcBaMU9rgdTU/ yK4Fs8BZpCIIJ1kCvqpC5t6XWQZ6H3hYBMeP1MTsEomBuYY/SXQ01ExGNpkK+imrliMO wZgwpzGypA4lBDpo3npfUhlbOyvu5cEtjmwcVyWCKZsjYRScuTpUEpJU49iL9b86ez/L ywCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=IeUI0dILKAxSbFsLZB41eqbavgPVFjZ83d4rKEO18SI=; b=nETF6qlpv8Mj6l8LTCEUIJQRafXotkLFrbUnj1xtY9ZBfSavk/RpFZ3x5YScnLl3sj Iygqo4UJJGizKc90Fj3KtokVIDDEYy1EW/i+qaBWS+QUJgnjd03HEF5yezFoI8RfufS7 GeSQGvUk66qov+FBqCxFNtxg/IDu3YAobFRv6e2LA1OOInZS+nHnMHhepQfNLiVKi1BV 1nnbAM+amXj4bpc7XtsgxouFelkg2JsLe5v6AbrPLxQGM/sbIxPdTZ7pw/w7UQoCHOIS FsG+JQzFjA4VFG/ywHBJ+IsmjCr/eQ10cWHIUUrgfZ1W5emf3IYw905TQyAMVU9WjqYJ YIUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ffCp+pIc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a170903028300b001a20c983d05si3393553plr.235.2023.03.24.10.05.44; Fri, 24 Mar 2023 10:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ffCp+pIc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbjCXQzr (ORCPT + 99 others); Fri, 24 Mar 2023 12:55:47 -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: X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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); > } >