Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lYVe7-00072k-4U for mharc-grub-devel@gnu.org; Mon, 19 Apr 2021 11:17:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50012) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYVe4-000715-U4 for grub-devel@gnu.org; Mon, 19 Apr 2021 11:17:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58209) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYVdz-0001rk-WB for grub-devel@gnu.org; Mon, 19 Apr 2021 11:17:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618845417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZRSZtoFtL25mXBp3I11iovudlJY6rX+r83BSQIxz/pY=; b=W131b+AxCJ980EVzVzEU+eiEC4ET4+B01bbHbWbaBA1zdHvabpe9TB8d+/Ys7bje/O2hXq PfhpJyHVVFo2Y9uv/kgTByNfPyFigBIaStJzYb3z+ZOFF5McKWO3fizFIbcMChALOfF/P+ fuR8+l9Z0mGZL7Xc+KvXB27R4oKALDU= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-1-izFCS2ANOzS0hB7pOOfRWw-1; Mon, 19 Apr 2021 11:16:56 -0400 X-MC-Unique: izFCS2ANOzS0hB7pOOfRWw-1 Received: by mail-wm1-f72.google.com with SMTP id x20-20020a7bc2140000b029012bb4d2b5d6so4618316wmi.1 for ; Mon, 19 Apr 2021 08:16:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZRSZtoFtL25mXBp3I11iovudlJY6rX+r83BSQIxz/pY=; b=LQ4ioWwLWcH28e9ZtoXQYSZCJ46b/mGujaue69F6y2AXrFySZow7kwnrnpy/WBbr7B l4a1Q2uqBAxejRIX//8Yygoex+lvrr2td8EBck9mLoFJgOV1930hguBkrTDpotO3Qj2V T86pt+01Q4jnJ4vDGH9TkxcDyNpRCbhcJ2kFBiZYJSxB4+f+tMgwp+0iqRAMYARj62WZ Z/CkyE59dSomzYvUZiqyGZksi4GHSc80BUGsp5P0Nx5bJ48R7R4eAyFZKj+mliBWdP2x 7Z8lnK3+lYlc2973dL5A2ZeI4gB+7u4O37UB1ldH0mSV1dSFGCEqNF5heataYllMoHVB ynsA== X-Gm-Message-State: AOAM533jgamI3prUyBlQb7enLfrkAd/emP6KhchBJMAzFsavxFAypPoB MtC/Xsgsf6QDHUZy5st91Yz1bW1R42u43Sze70XgxgzIdcJnvRd8Ry4gdpnZON0TG8wOEm55kyB uLJd6XH3Y8euY3DXt93O8PSQ6FtBKzH2JtrYjN+IWyKULbm5ERb+3vas8gC4wZw== X-Received: by 2002:adf:a40f:: with SMTP id d15mr14781268wra.375.1618845414608; Mon, 19 Apr 2021 08:16:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFq4dLpF3Uzjd6ldU3EzMtfmOIhowbhyl9zldXbjhWsYQ/+12V/XxlWqxqXNppHW0pS/Fhnw== X-Received: by 2002:adf:a40f:: with SMTP id d15mr14781242wra.375.1618845414391; Mon, 19 Apr 2021 08:16:54 -0700 (PDT) Received: from minerva.redhat.com ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id c15sm13290605wrr.3.2021.04.19.08.16.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Apr 2021 08:16:53 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Javier Martinez Canillas , Eric Sandeen , Carlos Maiolino , Daniel Kiper Subject: [PATCH] xfs: Print a warning if the filesystem needs to be repaired Date: Mon, 19 Apr 2021 17:16:50 +0200 Message-Id: <20210419151650.207380-1-javierm@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=javierm@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=216.205.24.124; envelope-from=javierm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Apr 2021 15:17:05 -0000 XFS now has an incompat feature flag to indicate that the filesystem needs to be repaired. The Linux kernel refuses to mount a filesystem that has it set and only the xfs_repair tool is able to clear that flag. One option is to make the GRUB behaviour consistent with the Linux kernel, and don't allow to mount a XFS filesystem that needs to be repaired. But that will prevent to even boot to a rescue environment for the OS in order to repair the filesystem. To prevent this situation, let's GRUB attempt to mount the filesystem even when needs to be repaired. Since after all, it currently attempts to mount even if is in an inconsistent state without trying to replay the jornal. For this reason, make it a best effort but print an error message when the filesystem is mounted if needs to be repaired. That way, if booting fails later due the inconsistencies when traversing the filesystem, the user can understand why that and take any needed action. Suggested-by: Eric Sandeen Signed-off-by: Javier Martinez Canillas --- grub-core/fs/xfs.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 43023e03fb3..22e7e61d574 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -79,6 +79,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ +#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ /* * Directory entries with ftype are explicitly handled by GRUB code. @@ -300,6 +301,16 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data) return 0; } +static int +grub_xfs_sb_needsrepair(struct grub_xfs_data *data) +{ + return ((data->sblock.version & + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5) && + data->sblock.sb_features_incompat & + grub_cpu_to_be32_compile_time(XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR)); +} + /* Filetype information as used in inodes. */ #define FILETYPE_INO_MASK 0170000 #define FILETYPE_INO_REG 0100000 @@ -915,6 +926,11 @@ grub_xfs_mount (grub_disk_t disk) if (!grub_xfs_sb_valid(data)) goto fail; + if (grub_xfs_sb_needsrepair(data)) + { + grub_printf (N_("Filesystem needs repair. Please run a XFS repair tool")); + } + if (grub_add (grub_xfs_inode_size (data), sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) + 1, &sz)) goto fail; -- 2.31.1