From patchwork Thu Dec 28 01:40:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhihao Cheng X-Patchwork-Id: 18569 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp1757090dyb; Wed, 27 Dec 2023 17:38:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IG911TG2H4NcMi6vdpqDRyBfIVja2aq+lA95MOTezOpWjC8LV6HmT+3ykGsIPsvuGimYIEi X-Received: by 2002:a05:6870:a686:b0:1fa:e282:3a81 with SMTP id i6-20020a056870a68600b001fae2823a81mr10859524oam.25.1703727509461; Wed, 27 Dec 2023 17:38:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703727509; cv=none; d=google.com; s=arc-20160816; b=WH5Pw+qUgb+hCmYmojlc0cXj64BKfywwyYCtf7Uoy0/wMnKfIgOExCbdT5fiU7XpXY kMGaXNk1CeTWUhCDoNZy6Ud6S0KaekKFYDlt06DNV0aocoTK7j8tukxlkEGbp6LgEbfj /sZCNZ3A47WJ7d+BgPPLBmZj9h+OttLpNiHk0umN1qa86VvuIRG6NyJc096QE1mVfdt+ l2NH5ewL9vmORxiidG4O3tBd/q5mXt41/QnaNzRIJ+DWvYXzOTqrlIVWReGhtkZ2DOLm gxmKt+rwHDDixBpaRf9dGqKvhnqFKUEoy3d0YncWoGe75Q13DpLXHMCX+rjRlu4ctw6f PYDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=Cwd3puWL1uh73pNRNp7Av0rxka+YLdftGPOJ8oTLK2c=; fh=3kaVOPShTC55oj708yh1yJALapWuogKx6Yvc3sQq9zY=; b=SNyPJm96TSA/bnu7hGVgCA78krCdvtZK4+CtfxnjJjIn0iXNzttb+bD4umqra99Fpq 1R4upuLK6xhWHfugzHOadbT1aEz+ccJ/8TrYLC+cHC4Kjma8yS1aaVv4SGA5dizIEbZo 1QYDCSaDWzCYdQmqjijf45wMCQIQP65OIWJmjCbP4sw+yoYCtebKplVLtGAW5/fd+jfW 7CEoaXZVR4H7ZXWss6C2tbToL2YJlOKgp0TvQXYM3cBnb45drsuMrVBF3CgLTQu3lkLp BXnL4AV5REVdSUdGzHeew+ztjkMo3tGOVcj4d1YDS2n6rkj2P12ZMnoIqDAvDmRFgqQU Qd4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v33-20020a631521000000b005cdfdd2625dsi8758573pgl.273.2023.12.27.17.38.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Dec 2023 17:38:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-12348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-12348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-12348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2AFFE28285A for ; Thu, 28 Dec 2023 01:38:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1ECEB1FB9; Thu, 28 Dec 2023 01:38:13 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE26010E6 for ; Thu, 28 Dec 2023 01:38:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4T0rjg1yJMzMprn; Thu, 28 Dec 2023 09:37:43 +0800 (CST) Received: from kwepemm000013.china.huawei.com (unknown [7.193.23.81]) by mail.maildlp.com (Postfix) with ESMTPS id 813261402E0; Thu, 28 Dec 2023 09:38:06 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemm000013.china.huawei.com (7.193.23.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 28 Dec 2023 09:38:05 +0800 From: Zhihao Cheng To: , , , , CC: , Subject: [PATCH RFC 00/17] ubifs: Add filesystem repair support Date: Thu, 28 Dec 2023 09:40:55 +0800 Message-ID: <20231228014112.2836317-1-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000013.china.huawei.com (7.193.23.81) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786487776800914360 X-GMAIL-MSGID: 1786487776800914360 UBIFS repair provides a way to fix inconsistent UBIFS image(which is corrupted by hardware exceptions or UBIFS realization bugs) and makes filesystem become consistent, just like fsck tools(eg. fsck.ext4, fsck.f2fs, fsck.fat, etc.) do. About why do we need it, how it works, what it can fix or it can not fix, when and how to use it, see more details in Documentation/filesystems/ubifs/repair.rst (Patch 17). Testing on UBIFS repair refers to https://bugzilla.kernel.org/show_bug.cgi?id=218327 Whatever, we finally have a way to fix inconsistent UBFIS image instead of formatting UBI when UBIFS becomes inconsistent. Zhihao Cheng (17): ubifs: repair: Load filesystem info from volume ubifs: repair: Scan nodes from volume ubifs: repair: Remove deleted nodes from valid node tree ubifs: repair: Add valid nodes into file ubifs: repair: Filter invalid files ubifs: repair: Extract reachable directory entries tree ubifs: repair: Check and correct files' information ubifs: repair: Record used LEBs ubifs: repair: Re-write data ubifs: repair: Create new root dir if there are no scanned files ubifs: repair: Build TNC ubifs: Extract a helper function to create lpt ubifs: repair: Build LPT ubifs: repair: Clean up log and orphan area ubifs: repair: Write master node ubifs: Enable ubifs_repair in '/sys/kernel/debug/ubifs/repair_fs' Documentation: ubifs: Add ubifs repair whitepaper Documentation/filesystems/index.rst | 3 +- .../authentication.rst} | 0 Documentation/filesystems/ubifs/index.rst | 11 + .../filesystems/{ubifs.rst => ubifs/main.rst} | 0 Documentation/filesystems/ubifs/repair.rst | 235 ++ MAINTAINERS | 5 +- fs/ubifs/Makefile | 2 +- fs/ubifs/debug.c | 57 +- fs/ubifs/debug.h | 2 + fs/ubifs/journal.c | 39 +- fs/ubifs/lpt.c | 140 +- fs/ubifs/repair.c | 2651 +++++++++++++++++ fs/ubifs/repair.h | 176 ++ fs/ubifs/sb.c | 24 +- fs/ubifs/super.c | 10 +- fs/ubifs/ubifs.h | 113 +- 16 files changed, 3315 insertions(+), 153 deletions(-) rename Documentation/filesystems/{ubifs-authentication.rst => ubifs/authentication.rst} (100%) create mode 100644 Documentation/filesystems/ubifs/index.rst rename Documentation/filesystems/{ubifs.rst => ubifs/main.rst} (100%) create mode 100644 Documentation/filesystems/ubifs/repair.rst create mode 100644 fs/ubifs/repair.c create mode 100644 fs/ubifs/repair.h