Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4207265rdh; Tue, 28 Nov 2023 15:16:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/dr+U+2aY2zF+CvQ5pidDUN0Lnnlo4KPcVq6SUxaCrQE5C6vX0/pxQEy5tQ9+y0yORM9Q X-Received: by 2002:a05:6a20:7f81:b0:18c:b464:eba3 with SMTP id d1-20020a056a207f8100b0018cb464eba3mr7351743pzj.7.1701213367456; Tue, 28 Nov 2023 15:16:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701213367; cv=none; d=google.com; s=arc-20160816; b=OGhXt5uI/4MV8MTlcrSNMS0WteIyOeOuo55tpd9t9lzbap23bCbGHklg8MdC7q0E/u MsqV6XahRlg+0HRL30P+d3lu6ebMR/O1yVZWMRrvhh2xpAMMooUlf956xFGSc9RaLh56 5obR0aE2Aith8Sc/ELW3SKfQGwG05zBnVebE38IgQa3hRGVpfBPau/uNLbI2XRTgsxko z1735Veu8EufGcNf/rX1WqX+vu7IHocxmlFkuzNl+Y+xeSCrfrE1MQMZZadtUHTHu3P7 2af2DnVv3hDyTwMSeGhu6qa7rFQGj6RS8Smfnm3qrmyDo61ehrKSh8YQeOdwPwRBDdQk E00g== 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=vykgSREbRTVKJqK+hnuQjRVRJhDGB/oVqFtrAotKoXw=; fh=fj0qAbZ4xhXorrWATNz35M5L5SZ9Tnytk+Yr0llgXF0=; b=zQJ3+B8pM06zWnhLPtXtDFD/t3pCnnYL+BlcUel0j04nuv4VXJlpludl/3xEt65DF8 x4y7cMllVKQiQJHybhZZjvIgTA7yIaZUuglFHkii10rnFOKjs4d5ZiaePJ2VSEJDulG/ VUlCq6NamqbOmQ0S3CsYSGNWiu4kAXBOKqoKFCS9Ai7oUFiDD4LSAeocKLf1X8vcnYfy Nm3CT7xtF/DkjynnppdNnCOWfXaGbKQn0n0i9RK3mhQt+ZpRv5LsM1HLt2S6G6qwZTYx yO1NySIz5pfy8SwvoyYL4IVmk5LtSZ1mK/4MSL6BECZMp2UL6aqBVXaFEOLqg07dMhfD IkoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=mLx43ofI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id d1-20020a17090a6f0100b00285b937aebdsi30987pjk.74.2023.11.28.15.16.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 15:16:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=mLx43ofI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id 8268A833967F; Tue, 28 Nov 2023 15:16:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376395AbjK1XPv (ORCPT + 99 others); Tue, 28 Nov 2023 18:15:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbjK1XPu (ORCPT ); Tue, 28 Nov 2023 18:15:50 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49330197 for ; Tue, 28 Nov 2023 15:15:56 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1cff3a03d8eso11643365ad.2 for ; Tue, 28 Nov 2023 15:15:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1701213356; x=1701818156; 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=vykgSREbRTVKJqK+hnuQjRVRJhDGB/oVqFtrAotKoXw=; b=mLx43ofIVFbBporVjlY/pQViCYGaHNO4DZGfYsubkQoSQBmcRuY91QSolDwm/CUmwP sYz1/FI+f0cR9WoTOIGcyUGmzyeGE9/CVn6/BIvWRluSh7VuP9h+zcHqfmsTZrJOAy2t PTu61K0nS4QICRMOaXJiYb20aZKpmKGCnz1EJENlg4zpSuZamfLs1IGpGTZbEDuIBSn3 clinHMmCe+D52xg8DiGqDJWuXnYB2c57BYMzG2jjFFvcRFt4qHprlp4J9CvwCYE6GIaV nJxNqKIvzszCUQv4KHHkdWdRXrNhnoh6Pr+2ERIgIOd9ft4igzteC4cU/xKxTQYhgivs W/pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701213356; x=1701818156; 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=vykgSREbRTVKJqK+hnuQjRVRJhDGB/oVqFtrAotKoXw=; b=i1UBFulVxmR9VrIut3hEwtxIsFVEhMPxHO2oGRdOkE31BlyXhRVXvEekpXegKqyQkS lEFZBh/WcCgF3Q49pONKxv5/6tKx3XXnexFCj1Qe/pnhvz2p8oSUNDERwgW4Kp7dyjgZ N7LROPgrry13IHwfuB3m5klj2r1iK2TG/BPIxs1fWKiCE2HEJG2HkwUkf4nY9SMge8QL 4KgVd/R9KPW8S+c3akX2+TGJU6+ZjxNTr1qW1a66GUA1aI36CN5zs2wCaTWlzuEX9Nld kxQIVgjWQWNTBG2QzG1k/wnIY8BhKPYMeXu+yZHhozbvr972cVYbZ067xK+4PwtK376M KPIA== X-Gm-Message-State: AOJu0Ywil+Td+eWV0RflrBgB1ZaZFxDtiMXSi45xiSW1pzA9sQ0Ui0u1 YtLIpwIJzxYe5ibjv33Ss+odZQ== X-Received: by 2002:a17:903:183:b0:1cf:68a3:d908 with SMTP id z3-20020a170903018300b001cf68a3d908mr19841471plg.24.1701213355501; Tue, 28 Nov 2023 15:15:55 -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 n6-20020a170902d2c600b001cfcf3dd317sm4399757plc.61.2023.11.28.15.15.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 15:15:55 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1r87J2-001GLK-1l; Wed, 29 Nov 2023 10:15:52 +1100 Date: Wed, 29 Nov 2023 10:15:52 +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 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: <20231128053202.29007-3-zhangjiachen.jaycee@bytedance.com> 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 howler.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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 15:16:04 -0800 (PST) On Tue, Nov 28, 2023 at 01:32:02PM +0800, Jiachen Zhang wrote: > From: Zhang Tianci > > xfs_da3_swap_lastblock() copy the last block content to the dead block, > but do not update the metadata in it. We need update some metadata > for some kinds of type block, such as dir3 leafn block records its > blkno, we shall update it to the dead block blkno. Otherwise, > before write the xfs_buf to disk, the verify_write() will fail in > blk_hdr->blkno != xfs_buf->b_bn, then xfs will be shutdown. > > We will get this warning: > > XFS (dm-0): Metadata corruption detected at xfs_dir3_leaf_verify+0xa8/0xe0 [xfs], xfs_dir3_leafn block 0x178 > XFS (dm-0): Unmount and run xfs_repair > XFS (dm-0): First 128 bytes of corrupted metadata buffer: > 00000000e80f1917: 00 80 00 0b 00 80 00 07 3d ff 00 00 00 00 00 00 ........=....... > 000000009604c005: 00 00 00 00 00 00 01 a0 00 00 00 00 00 00 00 00 ................ > 000000006b6fb2bf: e4 44 e3 97 b5 64 44 41 8b 84 60 0e 50 43 d9 bf .D...dDA..`.PC.. > 00000000678978a2: 00 00 00 00 00 00 00 83 01 73 00 93 00 00 00 00 .........s...... > 00000000b28b247c: 99 29 1d 38 00 00 00 00 99 29 1d 40 00 00 00 00 .).8.....).@.... > 000000002b2a662c: 99 29 1d 48 00 00 00 00 99 49 11 00 00 00 00 00 .).H.....I...... > 00000000ea2ffbb8: 99 49 11 08 00 00 45 25 99 49 11 10 00 00 48 fe .I....E%.I....H. > 0000000069e86440: 99 49 11 18 00 00 4c 6b 99 49 11 20 00 00 4d 97 .I....Lk.I. ..M. > XFS (dm-0): xfs_do_force_shutdown(0x8) called from line 1423 of file fs/xfs/xfs_buf.c. Return address = 00000000c0ff63c1 > XFS (dm-0): Corruption of in-memory data detected. Shutting down filesystem > XFS (dm-0): Please umount the filesystem and rectify the problem(s) > > From the log above, we know xfs_buf->b_no is 0x178, but the block's hdr record > its blkno is 0x1a0. > > Fixes: 24df33b45ecf ("xfs: add CRC checking to dir2 leaf blocks") > Signed-off-by: Zhang Tianci > --- > fs/xfs/libxfs/xfs_da_btree.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c > index e576560b46e9..35f70e4c6447 100644 > --- a/fs/xfs/libxfs/xfs_da_btree.c > +++ b/fs/xfs/libxfs/xfs_da_btree.c > @@ -2318,8 +2318,18 @@ xfs_da3_swap_lastblock( > * Copy the last block into the dead buffer and log it. > */ > memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize); > - xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1); > dead_info = dead_buf->b_addr; > + /* > + * 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. Cheers, Dave. -- Dave Chinner david@fromorbit.com