From patchwork Tue Dec 5 05:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiachen Zhang X-Patchwork-Id: 17540 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3234262vqy; Mon, 4 Dec 2023 22:00:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHx+v3k1o9qXu0XhpYCv5Nj7poYLc4YWXp3MN2+0AMuAzkODYuaAfpnW/NaHsL1TNSVwPwn X-Received: by 2002:a05:6870:63ab:b0:1e9:a741:44f3 with SMTP id t43-20020a05687063ab00b001e9a74144f3mr7431764oap.14.1701756049293; Mon, 04 Dec 2023 22:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701756049; cv=none; d=google.com; s=arc-20160816; b=eI7Hql6k81rCkOqRWVYR6NGqReZjh4IAOdVMgncsQTsNzHepPuDdFq9liEL03mwpxw O0OXmiK4p2o2qUm5hccFOoqP9iqM4wPE+62hw8NkrLAlMHe4wTVqNvgTmdL+wVISDhuZ wtnjkt8kYf3QEPj8AWEU/05dZ5YYExyG9DdeQ1JyziwgVcyo8lYWO7q5T+DdsL0Muc56 19Nk1ZIE9J86cYdp00Khj8SpGbelJ9THVm5sHg4QZw0nk5Z2tX3t8oFfp8C75mGseVcN kAaeAWyvMdpgu6wi+ptE4gYthd5kRN9ix6Az6i1VbwCKqTGa8IGbWbfSnJfXLDhBI4uf iW6g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=HlsEF8HjcrD0vm5er1oT8WZvKcg7ME4zSDysaDBmuRU=; fh=CENchAFQ9s6ZDlEHpivGxu0XtNGBSHBXW25A2DGboZ0=; b=JtjOvyJcGyQlakHHBEq/xGrUXNlMkJzLTIEiZ7YG0JMSRAPk0cGqcBkL1pt9Jc9H9S QQqzAsjkis/2r9Yfsw9sxQLg5I7ovkE0qcWWfe5etQ38cQ9/b+JcQyaSerjpnMqqpzqu N9VeafHY8SbVTeXFrla7AToafwKuNwMr5xB76JSA9EDzcokQg8ouvdC0ehi89iCBbw9J y5A2bDLwk1Y+8BjqwDbIfYG4S4/7MdOfp/Vnc73lT5LshR+eXWKYWwOBJ+1PqKTony6T y7WODakxUJCYC/BCRHEB1YpZDJLEzyQbr7dPilTU37fzPQMx4cEWI+HaB4/HLlNo7mWU EGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=gU656waJ; 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 q78-20020a632a51000000b005bd3da15474si9009114pgq.839.2023.12.04.22.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 22:00:49 -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=gU656waJ; 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 BC97C80AE824; Mon, 4 Dec 2023 22:00:03 -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 S1344312AbjLEF7h (ORCPT + 99 others); Tue, 5 Dec 2023 00:59:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbjLEF7f (ORCPT ); Tue, 5 Dec 2023 00:59:35 -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 0DC71C0 for ; Mon, 4 Dec 2023 21:59:18 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6ce52d796d2so1613157b3a.3 for ; Mon, 04 Dec 2023 21:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1701755957; x=1702360757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=HlsEF8HjcrD0vm5er1oT8WZvKcg7ME4zSDysaDBmuRU=; b=gU656waJnSolRaCCjEYbesb4/Y2E4s++J4riEcjTmmxZudo2bkcTL0Ud5on6w1MNSi oSB0YdOd6/FhFLMjJRsZlib9HM/Endr5Cp7dHrjaT64OJeERH1WP4QEjbAU7/6F+rumz R0+XIIFCMhcNvS+pFljL0alzC/om4ByA9du/ZyJXYJNFwOIphf2Iq1xTyLN6AhcjAL6D l6znh1rKq37lazrps0D0AlPZPjgQI79+eXn6ntof4JwDgJ5ettFs8X1vCyX5ZGb0y5jN DWUM/wjjGIsBL6KwaWoa/5VxeaWAZTb9J4mdDUUgo+0luS6q3+o/CyVESkK4JpoHway8 tnJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701755957; x=1702360757; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HlsEF8HjcrD0vm5er1oT8WZvKcg7ME4zSDysaDBmuRU=; b=igzcHtnkH7Rf3vqsvy8vmZpHpjQRj5nZ8b8dCcCRCrK6tLriXSGSiqkCFO6AnzKzJQ +UGtunixeqpojqsnKyEfZu3MTsqbGLXpZGaL8a2wvvIWzv6VMl+zxHWuQyeIMDvzIxAV QszlDgIPHHNzjyYf8OKm7flJlHzWJX0jytTJ//Ld8wbpeeda9HBHlCo6x7Ho0U8BN4cr HUv9lU7k8ghPlv7rcB4OTpPrcfmdvxwVy2r48Omb9GBLSlSsSgUDiXnjGXcGP5oCcUTK 0n9ZlSDuKoWo+AFiL0vkRHMkaa2Jz0jBdlRcNzq++lr10gnBhA424smKYQ40x9SthqX8 jJHQ== X-Gm-Message-State: AOJu0YxJwtG+HGawvT0C6Rri0ul7NfkZxaxi1FEuoBfFP5ns6qM3TAQ5 SE4/TFdy6SfLNXQBRHXCp7XeAw== X-Received: by 2002:a05:6a20:a1a2:b0:14c:a2e1:65ec with SMTP id r34-20020a056a20a1a200b0014ca2e165ecmr5059457pzk.38.1701755957415; Mon, 04 Dec 2023 21:59:17 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 21:59:17 -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 Subject: [PATCH v4 0/3] Fixes for ENOSPC xfs_remove Date: Tue, 5 Dec 2023 13:58:57 +0800 Message-Id: <20231205055900.62855-1-zhangjiachen.jaycee@bytedance.com> X-Mailer: git-send-email 2.35.1 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:05 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784420550849657815 X-GMAIL-MSGID: 1784420550849657815 Hi, Recently, our use-case ran into 2 bugs in case doing xfs_remove when the disk space is in-pressure, which may cause xfs shutdown and kernel crash in the xfs log recovery procedure. Here are 2 patches to fix the problem, and a patch adding a helper to optimize the code structure. The 1st patch fixes an uninitialized variable issue. The 2nd patch ensures the blkno in the xfs_buf is updated when doing xfs_da3_swap_lastblock(). The 3rd patch adds a xfs_buf copy helper to optimize the code structure. Changes of v2: - directly set the *logflagsp value to make the code more robust in the 1st commit, - check xfs's crc-feature rather than magic in the 2nd commit, and - fixed code style and rebased onto the master branch. Changes of v3: - fix code style, and - add a new patch which does xfs_buf memcpy in a helper. Changes of v4: - optimize comments. Thanks, Jiachen Jiachen Zhang (1): xfs: ensure logflagsp is initialized in xfs_bmap_del_extent_real Zhang Tianci (2): xfs: update dir3 leaf block metadata after swap xfs: extract xfs_da_buf_copy() helper function fs/xfs/libxfs/xfs_attr_leaf.c | 12 ++---- fs/xfs/libxfs/xfs_bmap.c | 73 +++++++++++++++-------------------- fs/xfs/libxfs/xfs_da_btree.c | 69 +++++++++++++++------------------ fs/xfs/libxfs/xfs_da_btree.h | 2 + 4 files changed, 68 insertions(+), 88 deletions(-)