From patchwork Tue Dec 5 05:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiachen Zhang X-Patchwork-Id: 173719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3233680vqy; Mon, 4 Dec 2023 21:59:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkafLtFp0ezCsj0bU7KvNB6nIEFA3jwwEteoWu+2B1ZekKGCJ7fwP2/fYU8LTmXz2wnb/I X-Received: by 2002:a17:902:f68a:b0:1d0:7844:5086 with SMTP id l10-20020a170902f68a00b001d078445086mr5800446plg.7.1701755983954; Mon, 04 Dec 2023 21:59:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701755983; cv=none; d=google.com; s=arc-20160816; b=MJP0Wr0kPdbQBu5psgvdomYiZlD1TXRMyG/n/jQxCwmVtXxUUt6GiP3G148mi4GMcw 31tA//Pt7bpXdgv4Yax5VSfXIjpXRMhA8/uqe2TFPc7upzfX+NBSpC8spBzRUKqYYwZV NdEMB9MC9XUi21/6r0n/Fneghf27E4ohyu5pY4kvpyWWih3MsikzzuVVJZj+qPWJP8IF rKzxSxkhL25qolGYxg8s2u3OsZgaboco6mq2K36l85wzohhSXlImzmlVKiCDkcr6EUaE kZLi14a5lJKLsitW/TF2HMCZCo4NgW3gPDQz4YO2haEesdYq36xCeVfqi4LdH6R6CJEk 9zIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P+odzlx0iKgbFxvPhRnZ5hpchFT389azLhhLZpDzZwc=; fh=w4XPsY9C5w/xV71ikxuDW474uWdeUXctNEWSncTMwiY=; b=BtY9WKVXcyezEdhIHsevswRcvK7u90l+jKwhbcnta6/LqnWenL73LAdDKuGvD/GG6d S6GBQInc25JBphqfoRK44BT9CCpZ6L/+O/CtLgXndLk7rXSMqnBpAacomhbOmqqkXwL8 uaOXmhvaBsTZrqlc+ac16IyALlpHb6Gd2yMGYxLPrhPvG/9XmlOz9W/i5WzADb+yjsc8 XkJl8eHGJmJMdvePYw/KG2Yybo1jSFtM+hmjk+iUwKs4K20uWwnreC6o+OM/2rQoClf0 z8N+KmSMxCSNpWjMNJS3AF5OsNUP5iFePTncF0035dhRO8IvhaX2F/CoGbgAuTRzJI2P FDIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=SbLcaCDs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id n10-20020a170902d2ca00b001d0bcb88302si1458303plc.580.2023.12.04.21.59.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=SbLcaCDs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3DBC780AE811; Mon, 4 Dec 2023 21:59:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229867AbjLEF7W (ORCPT + 99 others); Tue, 5 Dec 2023 00:59:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjLEF7V (ORCPT ); Tue, 5 Dec 2023 00:59:21 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E31E116 for ; Mon, 4 Dec 2023 21:59:27 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d06d42a58aso27238105ad.0 for ; Mon, 04 Dec 2023 21:59:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701755967; x=1702360767; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=P+odzlx0iKgbFxvPhRnZ5hpchFT389azLhhLZpDzZwc=; b=SbLcaCDseqofjPkjQX7Y5q8bEUKijUthvO4DuGLHxVhq08tlfQft+lgv3dzS1H6zSL aoNGsiHigig1VOs4fZwALn+kC/7vr+YSdRv+9OkBW2EfopmZM1ocHXDWwwLtf6LRnBv1 YGzd3JVsOY+6ChOD8lREiKsVupYwrX+lDSwSKusRJAVmyNhcItSge1+Iz8u8zsXby0JE LHKzWIlQNVBOZFqkzpi/IFFx44HShIyu0HmKjW+J7+If7yPHIfUYDuWRe0Ws5vv1P2HE tdKzDdj1Nn45eO3zdMLErNyrauyJEYhwOAI0HLZzVvLBAlNH92tHj75DjWXmGvzb49Sp fvlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701755967; x=1702360767; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=P+odzlx0iKgbFxvPhRnZ5hpchFT389azLhhLZpDzZwc=; b=B0K0Yr9dNiUxrL5r974v28c3RvAGXSma8TYORDpvokPwlszoldgWn+BXc0K6MDCy2Z pUEPzt3J/I1aX59WllnltLWQqdtCHKr2GClpWHeCeU/cMv0fv4pZBjEC8VRr4T76qM2z vI2Y0Tug+vutn703wQLEnp2tLzSwWno+Jb32btYzqBL/wY3DgtYQiGSGm4FMXdTkF0Uk baj+wbR/6YqSRcdOhFP5euEVkgxU3n0i6d4BshXVF1q6v0OS6PPvlNgzcJUqZoTnByL7 ik3iF+G6tbz1KHy422M7pphREjDxnGfrBpTvDcj17za0ebh9j4gmgbBYIYiHestS2HMh CyCw== X-Gm-Message-State: AOJu0YwIx65/n+GbFiBDWz3IerZjzjFIR1NPCNrt0avU+SNkKtmyUnu5 4BAjwTEgJRidAt6RtEwEe0Bkxw== X-Received: by 2002:a17:902:d586:b0:1d0:3358:4e26 with SMTP id k6-20020a170902d58600b001d033584e26mr6983846plh.1.1701755966931; Mon, 04 Dec 2023 21:59:26 -0800 (PST) Received: from localhost.localdomain ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id jb7-20020a170903258700b001d05bb77b43sm7111605plb.19.2023.12.04.21.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:26 -0800 (PST) From: Jiachen Zhang To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top, Jiachen Zhang , Christoph Hellwig Subject: [PATCH v4 1/3] xfs: ensure logflagsp is initialized in xfs_bmap_del_extent_real Date: Tue, 5 Dec 2023 13:58:58 +0800 Message-Id: <20231205055900.62855-2-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> References: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 21:59:39 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784420482801568116 X-GMAIL-MSGID: 1784420482801568116 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 Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 73 +++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index be62acffad6c..eacd7f43c952 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); @@ -5035,7 +5036,6 @@ xfs_bmap_del_extent_real( ASSERT(got_endoff >= del_endoff); ASSERT(!isnullstartblock(got.br_startblock)); qfield = 0; - error = 0; /* * If it's the case where the directory code is running with no block @@ -5051,13 +5051,13 @@ xfs_bmap_del_extent_real( del->br_startoff > got.br_startoff && del_endoff < got_endoff) return -ENOSPC; - flags = XFS_ILOG_CORE; + *logflagsp = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { if (!(bflags & XFS_BMAPI_REMAP)) { error = xfs_rtfree_blocks(tp, del->br_startblock, del->br_blockcount); if (error) - goto done; + return error; } do_fx = 0; @@ -5072,11 +5072,9 @@ xfs_bmap_del_extent_real( if (cur) { error = xfs_bmbt_lookup_eq(cur, &got, &i); if (error) - goto done; - if (XFS_IS_CORRUPT(mp, i != 1)) { - error = -EFSCORRUPTED; - goto done; - } + return error; + if (XFS_IS_CORRUPT(mp, i != 1)) + return -EFSCORRUPTED; } if (got.br_startoff == del->br_startoff) @@ -5093,17 +5091,15 @@ xfs_bmap_del_extent_real( xfs_iext_prev(ifp, icur); ifp->if_nextents--; - flags |= XFS_ILOG_CORE; + *logflagsp |= XFS_ILOG_CORE; if (!cur) { - flags |= xfs_ilog_fext(whichfork); + *logflagsp |= xfs_ilog_fext(whichfork); break; } if ((error = xfs_btree_delete(cur, &i))) - goto done; - if (XFS_IS_CORRUPT(mp, i != 1)) { - error = -EFSCORRUPTED; - goto done; - } + return error; + if (XFS_IS_CORRUPT(mp, i != 1)) + return -EFSCORRUPTED; break; case BMAP_LEFT_FILLING: /* @@ -5114,12 +5110,12 @@ xfs_bmap_del_extent_real( got.br_blockcount -= del->br_blockcount; xfs_iext_update_extent(ip, state, icur, &got); if (!cur) { - flags |= xfs_ilog_fext(whichfork); + *logflagsp |= xfs_ilog_fext(whichfork); break; } error = xfs_bmbt_update(cur, &got); if (error) - goto done; + return error; break; case BMAP_RIGHT_FILLING: /* @@ -5128,12 +5124,12 @@ xfs_bmap_del_extent_real( got.br_blockcount -= del->br_blockcount; xfs_iext_update_extent(ip, state, icur, &got); if (!cur) { - flags |= xfs_ilog_fext(whichfork); + *logflagsp |= xfs_ilog_fext(whichfork); break; } error = xfs_bmbt_update(cur, &got); if (error) - goto done; + return error; break; case 0: /* @@ -5150,18 +5146,18 @@ xfs_bmap_del_extent_real( new.br_state = got.br_state; new.br_startblock = del_endblock; - flags |= XFS_ILOG_CORE; + *logflagsp |= XFS_ILOG_CORE; if (cur) { error = xfs_bmbt_update(cur, &got); if (error) - goto done; + return error; error = xfs_btree_increment(cur, 0, &i); if (error) - goto done; + return error; cur->bc_rec.b = new; error = xfs_btree_insert(cur, &i); if (error && error != -ENOSPC) - goto done; + return error; /* * If get no-space back from btree insert, it tried a * split, and we have a zero block reservation. Fix up @@ -5174,33 +5170,28 @@ xfs_bmap_del_extent_real( */ error = xfs_bmbt_lookup_eq(cur, &got, &i); if (error) - goto done; - if (XFS_IS_CORRUPT(mp, i != 1)) { - error = -EFSCORRUPTED; - goto done; - } + return error; + if (XFS_IS_CORRUPT(mp, i != 1)) + return -EFSCORRUPTED; /* * Update the btree record back * to the original value. */ error = xfs_bmbt_update(cur, &old); if (error) - goto done; + return error; /* * Reset the extent record back * to the original value. */ xfs_iext_update_extent(ip, state, icur, &old); - flags = 0; - error = -ENOSPC; - goto done; - } - if (XFS_IS_CORRUPT(mp, i != 1)) { - error = -EFSCORRUPTED; - goto done; + *logflagsp = 0; + return -ENOSPC; } + if (XFS_IS_CORRUPT(mp, i != 1)) + return -EFSCORRUPTED; } else - flags |= xfs_ilog_fext(whichfork); + *logflagsp |= xfs_ilog_fext(whichfork); ifp->if_nextents++; xfs_iext_next(ifp, icur); @@ -5224,7 +5215,7 @@ xfs_bmap_del_extent_real( ((bflags & XFS_BMAPI_NODISCARD) || del->br_state == XFS_EXT_UNWRITTEN)); if (error) - goto done; + return error; } } @@ -5239,9 +5230,7 @@ xfs_bmap_del_extent_real( if (qfield && !(bflags & XFS_BMAPI_REMAP)) xfs_trans_mod_dquot_byino(tp, ip, qfield, (long)-nblks); -done: - *logflagsp = flags; - return error; + return 0; } /* From patchwork Tue Dec 5 05:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiachen Zhang X-Patchwork-Id: 173721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3234224vqy; Mon, 4 Dec 2023 22:00:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPG8m9jPbdAUYOpD9vi0tDrtBxseDiVF7vXeZIHL6ij+aH2dzsA1PuDlTl/Q8f3wR+EAOC X-Received: by 2002:a05:6808:f13:b0:3b8:4dd1:9770 with SMTP id m19-20020a0568080f1300b003b84dd19770mr6777936oiw.23.1701756044241; Mon, 04 Dec 2023 22:00:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701756044; cv=none; d=google.com; s=arc-20160816; b=oa0O4L5ktNHo3pkh40AAMean7MCeIs/qrzBXWq/WiUCgcuTjFlNlADcthPXWfkCqZf A7PQd7rVJb0u/PLD6yKbhldnEMz0LFU1BlLfNUtOep9nLT6+Lkm/teLzkLRnB9WHBoRK FkUSeKBWOS/2X0tbnWvoTFeDNmwOBm0FWnPa24cf1jZ+3jpP6o2lKWbhXuT3H4ZEDVgj cuko41TTb2oKJySdXX+CpV5NUdatwOEj1+nZFSEtY0X75pESbaq0gtyI4MC2PFB0su+L e3Wrra8hFQqddhbynFO1mldkSWXh6rtP0rdfnVDEM1WXj3mAtEZR45qF/QPNAaB5OnVb 61Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nyBGwSV+iJralP4K3/kIwnYMScArE6+I+gopISjyQyw=; fh=4iLs2QAZfwC0JIm6x9zjIhpwoOot1LSNFB7mwQorO68=; b=NpbmkveUOv/RXZXjKbWO4EwmTW13PBMi5gPSHYUIhvO5JiJUGPtW7JhIk1pBymTPgl OU2ISAmI4Lu02az8c2se3dG2t6eU3Nh0+KedqHypy22NF7PDA+b7ftpy2RvkDhwvgw5Z hUqj+uF776FAIE5/GVFHk2xEVueJjiDe1UZHaA9dcx/BMrNepFItxUlDcxWWKUu5bAlr /JODYMcRzhWXKhKij/kl9D2us6cjK+zqutvnVJzHXuwgeYkZIZVXME29JjaVxUVS5Y92 9KoaIykC4p0a5PBIN2n1QyK8CJ/nDLYydzwwXzPwZu4zc+nIFj78sSJHIgHuhuLGS3kR mL4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="k1Kgw8/Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id fc24-20020a056a002e1800b006cb88a284dfsi9107840pfb.164.2023.12.04.22.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 22:00:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b="k1Kgw8/Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A1C75807E8A0; Mon, 4 Dec 2023 22:00:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234906AbjLEF76 (ORCPT + 99 others); Tue, 5 Dec 2023 00:59:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234843AbjLEF7s (ORCPT ); Tue, 5 Dec 2023 00:59:48 -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 867BD116 for ; Mon, 4 Dec 2023 21:59:31 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1d0897e99e0so12914145ad.3 for ; Mon, 04 Dec 2023 21:59:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701755971; x=1702360771; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nyBGwSV+iJralP4K3/kIwnYMScArE6+I+gopISjyQyw=; b=k1Kgw8/QWCUAslUlV7mcNpAZr7OUCSZFq7SoHbXtdnLEWCK5OKFcNE09qlygP6FQfl UXnF2zOo/eubNgQZZcmMSj86yCiSop7ly/J4z+0OgT+T4ItvDTmx9pYCxo3mCu0fUair xfQcYRuMlwVo9YrT8rXxIQDT4pNpEG/x7GNQjww+hUvruJpkmw1SJJIeOE25WtdaiN3I m3SopzffE5a3cyknxyeW96lLYIyS9AUpbfZ6dELlF1ruUAv1+O0sHeR3OBIeLbR8koVU DVVMC0JDeoQteG0XBptSIo132Ig2rEAZ70Es3LqvBiNP3nkrIRddOmW4Dud+jyS8InMg BIYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701755971; x=1702360771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nyBGwSV+iJralP4K3/kIwnYMScArE6+I+gopISjyQyw=; b=CtREXwxDnywFEMqqiEDHFtmVP6PbNwbWK8T5d/tSD4hDgWcfZEDJG024LOwSZOtXVo 3E0J4r5JOC/BwIoIg9LknTK5Ii4GPGeWNHfSYtoW6jY2VHMHbddrTfN6e2SHXjhIF85z /J+TetKciVLMZlyjoHtIlkCQsjtLPwlU1NKQD6egA+qGb1b1YO0yJFmzYHUHcfDBADid 6hLHtoTGun1ojf+QRf6MTDSTqTseh0xCLLTiF4rKE9lfcf4Cb1ewaGN73Nq85dtShuNy hX6530hTJ3aTnHGksab3y61Ly5tEhgucw5B1xzw013km+G5xMaQJXnUx/T+CzoXdW69k SnSw== X-Gm-Message-State: AOJu0YwK4JNx95U1tXre6WQpqZZbg7VoZrm8gjL0Yz8MhZ/0s9mjEEa1 5OhY9DLwvdSWvxX/EcIZ7E68kg== X-Received: by 2002:a17:903:1207:b0:1ce:5f67:cfd3 with SMTP id l7-20020a170903120700b001ce5f67cfd3mr2605429plh.18.1701755970999; Mon, 04 Dec 2023 21:59:30 -0800 (PST) Received: from localhost.localdomain ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id jb7-20020a170903258700b001d05bb77b43sm7111605plb.19.2023.12.04.21.59.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:30 -0800 (PST) From: Jiachen Zhang To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top, Dave Chinner Subject: [PATCH v4 2/3] xfs: update dir3 leaf block metadata after swap Date: Tue, 5 Dec 2023 13:58:59 +0800 Message-Id: <20231205055900.62855-3-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> References: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 04 Dec 2023 22:00:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784420545484450521 X-GMAIL-MSGID: 1784420545484450521 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 Suggested-by: Dave Chinner Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_da_btree.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index e576560b46e9..282c7cf032f4 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2316,10 +2316,17 @@ xfs_da3_swap_lastblock( return error; /* * Copy the last block into the dead buffer and log it. + * On CRC-enabled file systems, also update the stamped in blkno. */ memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize); + if (xfs_has_crc(mp)) { + struct xfs_da3_blkinfo *da3 = dead_buf->b_addr; + + da3->blkno = cpu_to_be64(xfs_buf_daddr(dead_buf)); + } xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1); dead_info = dead_buf->b_addr; + /* * Get values from the moved block. */ From patchwork Tue Dec 5 05:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiachen Zhang X-Patchwork-Id: 173720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3233713vqy; Mon, 4 Dec 2023 21:59:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqhcEbUY6WM4f0zZdwEkLZM3+l9HsWqaq7tUsMQpT4qYwAm9bTpI889XD1D2154cI1+Loe X-Received: by 2002:a81:b80b:0:b0:5d2:bb18:5834 with SMTP id v11-20020a81b80b000000b005d2bb185834mr4365702ywe.15.1701755990074; Mon, 04 Dec 2023 21:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701755990; cv=none; d=google.com; s=arc-20160816; b=Z5i3Z+p5JfVkoVfHAgHDIqOZUqegl7+OTT3e30Vw0zZWzBQaUoHlFR0lg1t1ZSSe9q XapPp5UBMefh2Y/E5ViwNxVpQFAiYTe/o/CvonbiCN2gdJvu4+nEOMOLouFiQ9xuLyge 2D2iJUNWOTgKoAUhd9f1qXY0QQuuJpyYRrzaIn+ZnsWScxXxUwdY/pK/bXt0Gq1DEWtG DrBp+hrFmf51TlqDlnZ28VaDqJFAjQmgWcjEDF+HtjISCrRZmzEqjIE6N0A21aF0x4ld Q2yCBRxCTqfYmR4MVrYsipBdF50q3uFtJVOmtMBkL4f9FeArmQYIWWLQWewgkFUAp43K 4HNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XSezztPpzbnoN5Gm9WnigSfdiZPls8znLUzzdIBA48c=; fh=PWR/LrZkVlJWqHsYkoQLEhm3iuIjiRb90OSwLyP8FKw=; b=J8XToBkpoHMVzgryCkXRfXQtFTmf55seXDZVXTbfNzCS4g1vsmd8pVKpNUPIGRXqUr tgdTuqHAnckleFk2CeHuVhO8YIa6FkXXaoQpDISfGvH87qFvGiO6EtFoGucsMSJOUWze fcr9YeKVVKMtcEsYHrMF16sEz2pf/mhHyXUEDDPpvu+KpCytGou5jrvCbAHNaakD53Be RLtwH09lM4aCumRmfDf/AHMllHI3+4/LU8hzKXTe6vipifXemogktyn47rordOcXFSpI 4f1vuViYXbCCp/tmPPKMoAp3EmkZg5/ma+ASwFL+UIuaCQ6q3iHmyEru8hsWefBN1mt3 oXrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Wl2jk2W6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id p2-20020a17090ab90200b002851727a227si4490211pjr.32.2023.12.04.21.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=Wl2jk2W6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id A68818021709; Mon, 4 Dec 2023 21:59:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344268AbjLEF7b (ORCPT + 99 others); Tue, 5 Dec 2023 00:59:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbjLEF73 (ORCPT ); Tue, 5 Dec 2023 00:59:29 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8E57AA for ; Mon, 4 Dec 2023 21:59:35 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-5c1a75a4b6cso1762402a12.2 for ; Mon, 04 Dec 2023 21:59:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701755975; x=1702360775; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XSezztPpzbnoN5Gm9WnigSfdiZPls8znLUzzdIBA48c=; b=Wl2jk2W6B7HPT6M6mVcvffSkk0T4RcgcDfxY3YbOHs1nrAhEsNnO2GyTyd114+MPPJ vq+dXaAescZgq+ikkfC+dBuhduJNcYVcKb/tF4X6vJKQm4n47i+ZyG3vN1TSC4iFiaZn gjKHhow90OLn2SiFPUA9PYCmqCEXWG3mqKQsBX7D9Yz+FZsWZTkY3TDFErDDbP54eT4L OdydVgdP+Yo2wgyp3i/J+lwEEUuLkYz4YAacMgenQnUOomddyfLFNtChqov2jRG5c9bX IJZRbpydGHklaNCObbCwhptnryowAbnzi7zutGpifksjd/y0f2JzErPHbxhheQhYzE3r LKxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701755975; x=1702360775; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XSezztPpzbnoN5Gm9WnigSfdiZPls8znLUzzdIBA48c=; b=svjKiulTsQMu+QuIOuQ+eryvJqLHVPC2hf6b6618q/3sW6fXifR3wfoOANDWjTjKVg h5yRGt4OGk+/6Zq2ZiBkOE/bACsErq+qVqXFfJ2Yw4DYP9Obpo2smKhyz8deq8nP2ss+ d950fHU68fiLCDlV5k9xjP5VuuwJnpnJXEHA2jYnYt1RlrB1Jkc+Luj6uLvIdBw6kjp4 jeUG7R9cVWzuq+VMaF4rNsEzCFo6+1KDTYbmbg5jJUnzMYx7dqlo1YSXzqSzBA+LRhd2 ct34kBXkbx9FauPq9FXg3grZCmXlZFbVBtESyElKtOKxnNpx/50jAr/iHPr0pNDJz5BH OAiw== X-Gm-Message-State: AOJu0YyKC6HIGyt7iSHSzJQgJHLiu3MpOJkAqItaQuA5KTWbh7MMH07l XKKt1XtDnCADNM8pzFeF8KQsL19Z3mjZn6+AD0jgc7D+ X-Received: by 2002:a17:902:8b85:b0:1d0:6ffd:ae0e with SMTP id ay5-20020a1709028b8500b001d06ffdae0emr2561663plb.117.1701755975368; Mon, 04 Dec 2023 21:59:35 -0800 (PST) Received: from localhost.localdomain ([61.213.176.5]) by smtp.gmail.com with ESMTPSA id jb7-20020a170903258700b001d05bb77b43sm7111605plb.19.2023.12.04.21.59.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:35 -0800 (PST) From: Jiachen Zhang To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , Allison Henderson , Zhang Tianci , Brian Foster , linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, xieyongji@bytedance.com, me@jcix.top, Christoph Hellwig Subject: [PATCH v4 3/3] xfs: extract xfs_da_buf_copy() helper function Date: Tue, 5 Dec 2023 13:59:00 +0800 Message-Id: <20231205055900.62855-4-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> References: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 21:59:46 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784420489024052105 X-GMAIL-MSGID: 1784420489024052105 From: Zhang Tianci This patch does not modify logic. xfs_da_buf_copy() will copy one block from src xfs_buf to dst xfs_buf, and update the block metadata in dst directly. Signed-off-by: Zhang Tianci Suggested-by: Christoph Hellwig Reviewed-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_attr_leaf.c | 12 ++---- fs/xfs/libxfs/xfs_da_btree.c | 74 ++++++++++++++--------------------- fs/xfs/libxfs/xfs_da_btree.h | 2 + 3 files changed, 36 insertions(+), 52 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 2580ae47209a..654e17e6610d 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c @@ -1244,14 +1244,10 @@ xfs_attr3_leaf_to_node( if (error) goto out; - /* copy leaf to new buffer, update identifiers */ - xfs_trans_buf_set_type(args->trans, bp2, XFS_BLFT_ATTR_LEAF_BUF); - bp2->b_ops = bp1->b_ops; - memcpy(bp2->b_addr, bp1->b_addr, args->geo->blksize); - if (xfs_has_crc(mp)) { - struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; - hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp2)); - } + /* + * Copy leaf to new buffer and log it. + */ + xfs_da_buf_copy(bp2, bp1, args->geo->blksize); xfs_trans_log_buf(args->trans, bp2, 0, args->geo->blksize - 1); /* diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 282c7cf032f4..5457188bb4de 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -421,6 +421,25 @@ xfs_da3_node_read_mapped( return xfs_da3_node_set_type(tp, *bpp); } +/* + * Copy src directory/attr leaf/node buffer to the dst. + * For v5 file systems make sure the right blkno is stamped in. + */ +void +xfs_da_buf_copy( + struct xfs_buf *dst, + struct xfs_buf *src, + size_t size) +{ + struct xfs_da3_blkinfo *da3 = dst->b_addr; + + memcpy(dst->b_addr, src->b_addr, size); + dst->b_ops = src->b_ops; + xfs_trans_buf_copy_type(dst, src); + if (xfs_has_crc(dst->b_mount)) + da3->blkno = cpu_to_be64(xfs_buf_daddr(dst)); +} + /*======================================================================== * Routines used for growing the Btree. *========================================================================*/ @@ -690,12 +709,6 @@ xfs_da3_root_split( btree = icnodehdr.btree; size = (int)((char *)&btree[icnodehdr.count] - (char *)oldroot); level = icnodehdr.level; - - /* - * we are about to copy oldroot to bp, so set up the type - * of bp while we know exactly what it will be. - */ - xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DA_NODE_BUF); } else { struct xfs_dir3_icleaf_hdr leafhdr; @@ -707,31 +720,17 @@ xfs_da3_root_split( size = (int)((char *)&leafhdr.ents[leafhdr.count] - (char *)leaf); level = 0; - - /* - * we are about to copy oldroot to bp, so set up the type - * of bp while we know exactly what it will be. - */ - xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAFN_BUF); } /* - * we can copy most of the information in the node from one block to - * another, but for CRC enabled headers we have to make sure that the - * block specific identifiers are kept intact. We update the buffer - * directly for this. + * Copy old root to new buffer and log it. */ - memcpy(node, oldroot, size); - if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC) || - oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { - struct xfs_da3_intnode *node3 = (struct xfs_da3_intnode *)node; - - node3->hdr.info.blkno = cpu_to_be64(xfs_buf_daddr(bp)); - } + xfs_da_buf_copy(bp, blk1->bp, size); xfs_trans_log_buf(tp, bp, 0, size - 1); - bp->b_ops = blk1->bp->b_ops; - xfs_trans_buf_copy_type(bp, blk1->bp); + /* + * Update blk1 to point to new buffer. + */ blk1->bp = bp; blk1->blkno = blkno; @@ -1220,21 +1219,14 @@ xfs_da3_root_join( xfs_da_blkinfo_onlychild_validate(bp->b_addr, oldroothdr.level); /* - * This could be copying a leaf back into the root block in the case of - * there only being a single leaf block left in the tree. Hence we have - * to update the b_ops pointer as well to match the buffer type change - * that could occur. For dir3 blocks we also need to update the block - * number in the buffer header. + * Copy child to root buffer and log it. */ - memcpy(root_blk->bp->b_addr, bp->b_addr, args->geo->blksize); - root_blk->bp->b_ops = bp->b_ops; - xfs_trans_buf_copy_type(root_blk->bp, bp); - if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { - struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; - da3->blkno = cpu_to_be64(xfs_buf_daddr(root_blk->bp)); - } + xfs_da_buf_copy(root_blk->bp, bp, args->geo->blksize); xfs_trans_log_buf(args->trans, root_blk->bp, 0, args->geo->blksize - 1); + /* + * Now we can drop the child buffer. + */ error = xfs_da_shrink_inode(args, child, bp); return error; } @@ -2316,14 +2308,8 @@ xfs_da3_swap_lastblock( return error; /* * Copy the last block into the dead buffer and log it. - * On CRC-enabled file systems, also update the stamped in blkno. */ - memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize); - if (xfs_has_crc(mp)) { - struct xfs_da3_blkinfo *da3 = dead_buf->b_addr; - - da3->blkno = cpu_to_be64(xfs_buf_daddr(dead_buf)); - } + xfs_da_buf_copy(dead_buf, last_buf, args->geo->blksize); xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1); dead_info = dead_buf->b_addr; diff --git a/fs/xfs/libxfs/xfs_da_btree.h b/fs/xfs/libxfs/xfs_da_btree.h index ffa3df5b2893..706baf36e175 100644 --- a/fs/xfs/libxfs/xfs_da_btree.h +++ b/fs/xfs/libxfs/xfs_da_btree.h @@ -219,6 +219,8 @@ int xfs_da_reada_buf(struct xfs_inode *dp, xfs_dablk_t bno, const struct xfs_buf_ops *ops); int xfs_da_shrink_inode(xfs_da_args_t *args, xfs_dablk_t dead_blkno, struct xfs_buf *dead_buf); +void xfs_da_buf_copy(struct xfs_buf *dst, struct xfs_buf *src, + size_t size); uint xfs_da_hashname(const uint8_t *name_string, int name_length); enum xfs_dacmp xfs_da_compname(struct xfs_da_args *args,