Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4433800rdh; Wed, 29 Nov 2023 01:04:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHqBTjHJ+TNr/S2ghH8QT88lPq0ArGKhpWaHB/oKNQUGbvTKERqsazA2Ph0wEM9pNxN5e3q X-Received: by 2002:a17:902:7897:b0:1cf:ee16:84fd with SMTP id q23-20020a170902789700b001cfee1684fdmr5365163pll.53.1701248689232; Wed, 29 Nov 2023 01:04:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701248689; cv=none; d=google.com; s=arc-20160816; b=mmTuGojdQWBZuVM/s2UUwl9F5YbA+jSnAAKyujThD9b9CvV8Hxr+YGhyY5IUhpgK/b rfntVAQD9KORDtBsxpIEFc4Gk2IgDYN/yux+yOR4/SKW5WI5O9NNYNuXYXsv5NE/lTZs IgrGvTDKQdFkSGCZk5phc7RENnphet4ZEyAisIwADG6RbWNpHMNx5VlJC3SZ42hcYfVD LMPeLYCJvdAq5jSwzGfhz8IcTSsHaTexXPd3uvFhs7Y/84CKh/0Xsui/PXYqdC0LivDw 3SHgvvg/UT0czUXH0HmuGQRe3qdDkvJBRe+u4yj59BNjp8Hn2dySkVLkYaw2KRWBUmZc PZsw== 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=IJkUwFni1tyd1Oj/0WIsU7esF/PDsZcmLt4NR+sDyhA=; fh=Vgblhw35Ett2SW2/cHp8RiVzHY8ocmKb2G4bKu2VYdc=; b=wtzy/VTu8IDj8KH6ak32dqkobwld0fETRt/GIxUMjQfPuh83ySdXQHU4BmzMtNtofB 9fMuZhbuoOAfX2xcEMGvldu95XLOGGdQGUZONw0VGHv8Hg4uS//lB3+ngMxShydkte2H eIPJTBb3uF8+2kFvVKu2iDl4N485SboStJY0WuROW/SEEDksnO8vsbMoMCPtlFkMdVIW SqVC5AqwDAvrc/LQ88V72GEyegritbc9bVgFrCYrYr8+0bEzfRUURiPpitBXWsHSKuEW fzkgCzEhULubkCnhhrYVTjpyjQWolXRdKiEs0jqy4shmyBs02ZgDDagnN0c0ld1ZhHND szVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=1m7GaBJA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id z14-20020a170902ccce00b001ce16902d3dsi14834816ple.430.2023.11.29.01.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:04:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=1m7GaBJA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 738E180C65CB; Wed, 29 Nov 2023 01:04:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232049AbjK2JEf (ORCPT + 99 others); Wed, 29 Nov 2023 04:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbjK2JEe (ORCPT ); Wed, 29 Nov 2023 04:04:34 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE3F8F5 for ; Wed, 29 Nov 2023 01:04:40 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id 41be03b00d2f7-5c1a75a4b6cso3881712a12.2 for ; Wed, 29 Nov 2023 01:04:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1701248680; x=1701853480; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IJkUwFni1tyd1Oj/0WIsU7esF/PDsZcmLt4NR+sDyhA=; b=1m7GaBJAX/dBoRSQky6TREt+1U8mO1oI0WgxSpNuoJblzBB03cw5l5PT6qDgruRROw m8v07aPBQEdJEZeSiukVl4MwJH2ZDL+SlcdDiUJekhCniVJz45y5CMY1Ul61pvwQ3C3q ILs9TPFeFTcu8o8D+s+rfYvBsPcZM0LAocIG0qblC7cr6WCLQQSx9cIRxGn/aW5cLHmx jl0ZzQfb78/kTspGnb2HtgVPwmQCDYlylKmQTYdUBeKckNs7SZFS/P2iFGwYt7JAWNgG x+f/p7Jkq5zvTJ16ce7XqNmMjOIJXjKP/UETFhA6hakkF6g77YsuGKyprpsM+02HsN2K Ju2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701248680; x=1701853480; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=IJkUwFni1tyd1Oj/0WIsU7esF/PDsZcmLt4NR+sDyhA=; b=Fr6m3pwb6zMlQnSFC6RfJszqUi+JQhJDkLZpFnkFWo/tEL77Mm+QsrZQWLxsAIbBC7 zSQEwrHbmAC3l8UxwJ+7lgKw+Fv2DYxM+6x8SLhFPpU6F+2RO4ITQVc+rphJHku6D+CA TPaQeN2Huz00/97vsb9iMicDq/4bnCxnK3+1XWhqydQ+y32Vpoky3TqNjvYczzcfqi3p iXJPUVuaiCeKFNH7TVi37aQ6Lu27G1T3/lwIlEr6ADkshDyl8/jIZ+Is8eJKaV6DiIv+ cI/zlSXWlmzH+8XMWKfq2KsrkwQ2RZiBvuxJ8xB6DiAtxodR1hZVu9ksNpZjd/YOnh1V 8vfA== X-Gm-Message-State: AOJu0YwDwUZFkwXuxRfgS1W1G61/Ru1OoTUlG8BJyigm1QlN2Y6Gx9/Y dp1ok7E5onliHMIo01tELzMWYg== X-Received: by 2002:a05:6a20:728f:b0:18c:4b7:2da5 with SMTP id o15-20020a056a20728f00b0018c04b72da5mr17600536pzk.54.1701248680233; Wed, 29 Nov 2023 01:04:40 -0800 (PST) Received: from dread.disaster.area (pa49-180-125-5.pa.nsw.optusnet.com.au. [49.180.125.5]) by smtp.gmail.com with ESMTPSA id y10-20020a170902b48a00b001cfb52ebffesm7939595plr.147.2023.11.29.01.04.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 01:04:39 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1r8GUn-001Req-1b; Wed, 29 Nov 2023 20:04:37 +1100 Date: Wed, 29 Nov 2023 20:04:37 +1100 From: Dave Chinner To: Jiachen Zhang Cc: Chandan Babu R , "Darrick J. Wong" , Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , Ben Myers , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top, Christoph Hellwig Subject: Re: [PATCH v2 1/2] xfs: ensure logflagsp is initialized in xfs_bmap_del_extent_real Message-ID: References: <20231129075832.73600-1-zhangjiachen.jaycee@bytedance.com> <20231129075832.73600-2-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231129075832.73600-2-zhangjiachen.jaycee@bytedance.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 29 Nov 2023 01:04:47 -0800 (PST) On Wed, Nov 29, 2023 at 03:58:31PM +0800, Jiachen Zhang wrote: > In the case of returning -ENOSPC, ensure logflagsp is initialized by 0. > Otherwise the caller __xfs_bunmapi will set uninitialized illegal > tmp_logflags value into xfs log, which might cause unpredictable error > in the log recovery procedure. > > Also, remove the flags variable and set the *logflagsp directly, so that > the code should be more robust in the long run. > > Fixes: 1b24b633aafe ("xfs: move some more code into xfs_bmap_del_extent_real") > Signed-off-by: Jiachen Zhang > Reviewed-by: Christoph Hellwig > --- > fs/xfs/libxfs/xfs_bmap.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c > index be62acffad6c..9435bd6c950b 100644 > --- a/fs/xfs/libxfs/xfs_bmap.c > +++ b/fs/xfs/libxfs/xfs_bmap.c > @@ -5010,7 +5010,6 @@ xfs_bmap_del_extent_real( > xfs_fileoff_t del_endoff; /* first offset past del */ > int do_fx; /* free extent at end of routine */ > int error; /* error return value */ > - int flags = 0;/* inode logging flags */ > struct xfs_bmbt_irec got; /* current extent entry */ > xfs_fileoff_t got_endoff; /* first offset past got */ > int i; /* temp state */ > @@ -5023,6 +5022,8 @@ xfs_bmap_del_extent_real( > uint32_t state = xfs_bmap_fork_to_state(whichfork); > struct xfs_bmbt_irec old; > > + *logflagsp = 0; > + > mp = ip->i_mount; > XFS_STATS_INC(mp, xs_del_exlist); > > @@ -5048,10 +5049,12 @@ xfs_bmap_del_extent_real( > if (tp->t_blk_res == 0 && > ifp->if_format == XFS_DINODE_FMT_EXTENTS && > ifp->if_nextents >= XFS_IFORK_MAXEXT(ip, whichfork) && > - del->br_startoff > got.br_startoff && del_endoff < got_endoff) > - return -ENOSPC; > + del->br_startoff > got.br_startoff && del_endoff < got_endoff) { > + error = -ENOSPC; > + goto done; > + } Now that you've added initialisation of logflagsp, the need for the error stacking goto pattern goes away completely. Anywhere that has a "goto done" can be converted to a direct 'return error' call and the done label can be removed. -Dave. -- Dave Chinner david@fromorbit.com