Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4426300rdh; Wed, 29 Nov 2023 00:46:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJVb4rfSY14f3zkoNOB2yMGY1iM4FJTA8qWbblq3RtICD/7FSHmIhcBM+NnSeXz+vydYHF X-Received: by 2002:a05:6a00:2296:b0:6cb:735c:67af with SMTP id f22-20020a056a00229600b006cb735c67afmr26152887pfe.0.1701247601424; Wed, 29 Nov 2023 00:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701247601; cv=none; d=google.com; s=arc-20160816; b=UYS1tz5BNF6pw/jwrF8e9v3KI6GlFI2rqj/8BJ0maiij/ov6n5mdhz+G3YMNKR8hzI T6YckofEXh2PxpitHkCcJUz1ZbYLuqZiz7Xi5t/DyioGaPLjuPm08xi2fLQfmWH65jp0 Bs/z5DF+jkQWTJIIr6FefWFwb0TcQzu3qh3rn0L0vBwU9r/SYgvD9m4XyL0vXUo/7wXJ EscjioJDy6bwnvMR1nOWB7szUUPzgzaPTqwaPP2+4V4C9G2pyBGIoFV6vE6KG/oS8A+6 p1ISRtyRYFygMjctnu0Hx42RrT52gm6zZ8ES+oNzxmg5DLYWWoaO/JrsCKCnIZFiMxAl n03w== 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=sZKM4U35noERGcY1ovETgfkyHKzxojpfXxj8pJoYn48=; fh=p5rAe4AdJWGPN5fspxjdGLqc13fxC2plxF//tVGrAgI=; b=zO9zNdwYBJsRGSvTxImLcuW0dw42RJvv7TTtTvgrTrF1T0DUGYEm08uroNKhvxwyvx Oe0QbHIpLdwB9GbJ4sDvuZoskYuTRpESK2ER1hrLoSzHyY+dA2mSf6DBP0a9M8cmXRG7 rLjwiKTCELHmqxuZ4ITHCUXW/QfDoILfE7hQ1YP+pHoaIKPyVcNxNN6Gi0N6tHTUVLDy bnL49yAD8m/UJow6fPewe9jGqcrcgnJh6dLwTnySzP/e2wIFs6CJ5iXfLahl+w4lKi6m ZGMKJnJyiJk7XWAM5QZ8bCv5ZSPy7v0uOlrA5OoTTqzMWFKQTqj2Evsy2uyV6hQ/+ySY yFvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=ZhGZC36q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id f13-20020a056a00228d00b006cd82b3585esi8573037pfe.287.2023.11.29.00.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:46:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=ZhGZC36q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id D94E2804F459; Wed, 29 Nov 2023 00:46:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbjK2IqU (ORCPT + 99 others); Wed, 29 Nov 2023 03:46:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbjK2IqM (ORCPT ); Wed, 29 Nov 2023 03:46:12 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555E11BD4 for ; Wed, 29 Nov 2023 00:46:18 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6cbd24d9557so516747b3a.1 for ; Wed, 29 Nov 2023 00:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1701247578; x=1701852378; 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=sZKM4U35noERGcY1ovETgfkyHKzxojpfXxj8pJoYn48=; b=ZhGZC36qeM4t2enk4yUmEs22fambWvct/lno4TkeV9D4zfNadw3mXf0Bdvm5lDToSt 4S6NUyIOhQoabp+jQX7TUuqH9qUrjNmXg5jp70vAQKtLCWmmt3foXGCr13poI7Z64gKL ROUcITOoL8DfFdRtsgDtLja+05DKv4u0Ofsvd46ilsYPRHFhw5dfvltIJtuvy77f8N2M U8TgT0GUk9alKQiFa2tr1EZUcCD7clnCIHYjaLG+H9cMilUjVKUhap5ihZoH7ZZAcVqS fGPrgrSoUC2lT14m4amukiHmpagxb3w4SgM7nc4/E+ylyY5dn9rigu8z6QBhxXZF/Biw O+jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701247578; x=1701852378; 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=sZKM4U35noERGcY1ovETgfkyHKzxojpfXxj8pJoYn48=; b=cVC4QaLqL2GtDUy4UN3+oJViIoj7AEJDUSshya4tX+k8PRkW/QmLzo2W3H1X39rR+e MDOMxrIkDqp31ir1DsNvdPfFEM37i0dXW2HZdu2/uZuB1Zei2YnacZUJvA4T8HNi8SMx Nlc5U9YGwAwNGtYuCueIOh72a8+N+20gtA2DepyE8LfhYoJIjnP0UsOI5bQpdj1jo2ex 53yjVc2NMoFSn80kpP2VEdjFooWyTqfgmeqod54k0f4C1EM020xKPnrnvC3U912kwFRD ngs9sT720uEMwjiBPARuFDlDeMPES6mfEYktwTg4wov92mJia6ER3YaIGGdiIg4QcL9w nwKA== X-Gm-Message-State: AOJu0YwCWs/YOdoVesxsWwy9kG8ke31WHkRPeZTrRaiNvnuMkKMNS7o6 zawqVp+IJ5G5oRwBJdbljCEm4Q== X-Received: by 2002:a05:6a00:3986:b0:6c3:415a:5c05 with SMTP id fi6-20020a056a00398600b006c3415a5c05mr25465361pfb.14.1701247577726; Wed, 29 Nov 2023 00:46:17 -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 fa21-20020a056a002d1500b006c33ae95898sm10221200pfb.78.2023.11.29.00.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 00:46:17 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1r8GD0-001RDE-0s; Wed, 29 Nov 2023 19:46:14 +1100 Date: Wed, 29 Nov 2023 19:46:14 +1100 From: Dave Chinner To: Christoph Hellwig Cc: Jiachen Zhang , 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 Subject: Re: [PATCH 2/2] xfs: update dir3 leaf block metadata after swap Message-ID: References: <20231128053202.29007-1-zhangjiachen.jaycee@bytedance.com> <20231128053202.29007-3-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Wed, 29 Nov 2023 00:46:39 -0800 (PST) On Tue, Nov 28, 2023 at 10:34:09PM -0800, Christoph Hellwig wrote: > On Wed, Nov 29, 2023 at 10:15:52AM +1100, Dave Chinner wrote: > > > + /* > > > + * Update the moved block's blkno if it's a dir3 leaf block > > > + */ > > > + if (dead_info->magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) || > > > + dead_info->magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC) || > > > + dead_info->magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC)) { > > > > a.k.a. > > > > if (xfs_has_crc(mp)) { > > > > i.e. this is not specific to the buffer type being processed, it's > > specific to v4 vs v5 on-disk format. Hence it's a fs-feature check, > > not a block magic number check. > > We have these magic based checks in quite a few places right now, > so I'm not surprised that Jiachen picked it up from there.. Yes, but that doesn't mean the magic number check has been used correctly here. That is, we use the magic number check when the code has a conditional on the type of buffer being processed (i.e. what block type are we operating on? e.g. DANODE vs LEAFN as is checked a few lines further down in this code). When the conditional is "what on-disk format are we operating on?" such as when we are decoding headers or running verifiers, we use xfs_has_crc() because we can't trust magic numbers to be correct prior to validation. Hence we use xfs_has_crc() to determine how to decode/encode/verify the structure header, not the magic number in the block. Cheers, Dave. -- Dave Chinner david@fromorbit.com