Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1llEZ5-0000Xu-A2 for mharc-grub-devel@gnu.org; Mon, 24 May 2021 13:40:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llEZ3-0000Qx-II for grub-devel@gnu.org; Mon, 24 May 2021 13:40:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54014) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1llEYz-0004ct-FU for grub-devel@gnu.org; Mon, 24 May 2021 13:40:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621878024; 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: in-reply-to:in-reply-to:references:references; bh=qhk0QoZ5q7GmYLFwqOqWoCiVelRbZXeQpZZrgl2tK38=; b=gRC8xiYYUVa/o8qEGTZwOOa/aRngDTPa28AMojEvx9fLM/Q7FGHEwT74Rlu+zw9cNcE+vY 9RY0afwdL1Zt9ccRM9nFpzHIAQtyKL64CB67qBCGBZhQ2dfBEcnnpiJ0JjQ65N3g9o0Dz3 GdhK6z+LY/owyZX8wSxsjnwTmwRBG8g= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-kh1EhnovP-2A3_izz3wCOw-1; Mon, 24 May 2021 13:40:23 -0400 X-MC-Unique: kh1EhnovP-2A3_izz3wCOw-1 Received: by mail-wr1-f70.google.com with SMTP id a9-20020adfc4490000b0290112095ca785so8184025wrg.14 for ; Mon, 24 May 2021 10:40:22 -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:in-reply-to :references:mime-version:content-transfer-encoding; bh=qhk0QoZ5q7GmYLFwqOqWoCiVelRbZXeQpZZrgl2tK38=; b=LYm16ODgySHCT7bZQjhowE17JMCC9K45QMOm4GFmh1ok+NKlgz4yHwb4d9VYGNK85v pVEZRTPppd2EqD3a5RKKGY4WEcKBlQOIZzdTT4DQ8Y5DHxAzPUwQ8DpipVER/p68DB9a nUiobKTPyea6x5ePtsfAAKp5BgqBfv9jp0AFM4iysx9NfGfrGfHL5o8o14uIECeA137s yq7r7FatfSTa5IASA2OgaemXEtqIkEZmm/sG+aap2laFGFvzvzBEjKVxncbkSMYo8Yx0 aiHOWe1GGdVZJ6QPKRSKGCS2tSO6gmtWQJMV4HDP39f3CPXlyxMJNfUws4rL1maKK6LT BFdQ== X-Gm-Message-State: AOAM531YCIHvlJhU6oMO9BqN61hc8F2TG/IHvzqmL9bQYsGL3RoCHLMz 17l6ej0RTKm88ilR613nkXjbr9OpHCKWwBTyb0VTABuOOCaOSDVUB/hOrjwOPizQUTsDxXLf3MY Af6baSSYovUc2i+kMr74gcVJHeGBbF+KodSHUrmCtzt8Oi3xS9qf7zrZIQo1TVQ== X-Received: by 2002:adf:db4e:: with SMTP id f14mr22873135wrj.48.1621878021492; Mon, 24 May 2021 10:40:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztlBj3js6QeyhmRaSXZRoMcahByvp8W1Y2dhKnajKRRHeJw/noEsNxdW+Zi5d1g+1i8oR82A== X-Received: by 2002:adf:db4e:: with SMTP id f14mr22873118wrj.48.1621878021248; Mon, 24 May 2021 10:40:21 -0700 (PDT) Received: from minerva.home ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id d3sm13004717wrs.41.2021.05.24.10.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 May 2021 10:40:20 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Carlos Maiolino , Eric Sandeen , Daniel Kiper , Javier Martinez Canillas Subject: [2.06 RELEASE PATCH v3 4/4] fs/xfs: Add needsrepair incompat feature support Date: Mon, 24 May 2021 19:40:07 +0200 Message-Id: <20210524174007.3201036-5-javierm@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524174007.3201036-1-javierm@redhat.com> References: <20210524174007.3201036-1-javierm@redhat.com> 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: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, 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, 24 May 2021 17:40:29 -0000 The 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. The GRUB doesn't have the concept of mounting filesystems and just attempts to read the files. But it does some sanity checking before attempting to read from a filesystem. Among the things which are tested, is if the super block only has set the incompatible features flags that are supported by GRUB. If it contains any flags that are not listed as supported, reading the XFS filesystem fails. Since the GRUB doesn't attempt to detect if the filesystem is inconsistent nor replays the journal, the filesystem access is a best effort. For This reason, also ignore if a filesystem needs to be repaired and just print a debug message in this case. That way, if later reading or booting fails, the user can figure out that the failures may be related to the XFS filesystem needing to be repaired. Suggested-by: Eric Sandeen Signed-off-by: Javier Martinez Canillas --- Changes in v3: - Improved commit message in patch #4 (dkiper). - Make the debug message more clear (dkiper). Changes in v2: - Improve commit message of patch #4 (dkiper). - Fix typo in debug message of patch #4 (dkiper). grub-core/fs/xfs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 2e6a24d034a..6452961ecbb 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -85,6 +85,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #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_BIGTIME (1 << 3) /* large timestamps */ +#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ /* * Directory entries with ftype are explicitly handled by GRUB code. @@ -99,7 +100,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); (XFS_SB_FEAT_INCOMPAT_FTYPE | \ XFS_SB_FEAT_INCOMPAT_SPINODES | \ XFS_SB_FEAT_INCOMPAT_META_UUID | \ - XFS_SB_FEAT_INCOMPAT_BIGTIME) + XFS_SB_FEAT_INCOMPAT_BIGTIME | \ + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) struct grub_xfs_sblock { @@ -310,6 +312,16 @@ static int grub_xfs_sb_valid(struct grub_xfs_data *data) return 0; } +static int +grub_xfs_sb_needs_repair (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 @@ -925,6 +937,9 @@ grub_xfs_mount (grub_disk_t disk) if (!grub_xfs_sb_valid(data)) goto fail; + if (grub_xfs_sb_needs_repair (data)) + grub_dprintf ("xfs", "XFS filesystem needs repair, boot may fail\n"); + 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