Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1lgr4i-00082d-UT for mharc-grub-devel@gnu.org; Wed, 12 May 2021 11:47:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgr4V-0007sh-Ij for grub-devel@gnu.org; Wed, 12 May 2021 11:46:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgr4A-000155-Nh for grub-devel@gnu.org; Wed, 12 May 2021 11:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620834390; 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=NpI4pdXp0kg3AJsk8KnESd9yYRtKgwCBaNJZTa2Qf5w=; b=Y7Mp7rlijekZIRVLT19KI0iXEjaHHnWgRpvh48KjZHWPK1WDXL/jX8ZIoe0JnJpNcCOfYS m6NY/Ee7dVv1EjIYe3CK8RqAPV8+l0e7da3FqWXQwG2RkR+OjFSbYg+Sb7RO7R60QUE+M6 vMYbM5yzQV253lhiUb0Y0INAp0HiLIQ= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-XPUE5wugPMS7hDsO3Y9BSw-1; Wed, 12 May 2021 11:46:28 -0400 X-MC-Unique: XPUE5wugPMS7hDsO3Y9BSw-1 Received: by mail-wr1-f72.google.com with SMTP id u5-20020adf9e050000b029010df603f280so10281626wre.18 for ; Wed, 12 May 2021 08:46:28 -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=NpI4pdXp0kg3AJsk8KnESd9yYRtKgwCBaNJZTa2Qf5w=; b=K8kcaQokw8XguEuNBV8h0HG02a/S/SGJWWVRlowwc/JhTeGca3p13VwIno9pO90NeQ np9Z4RSkAcuBRgHJcC2uwXVfbIxPMReky6FjfyVvDYc7oIo5npw5PMoCN9oz2+uOW3Mo rYO5BGcwJAk9fumsNvgs7GUppz/64WTfCsySeeoxIwbMmPfmEMrajb31eXgWa1S+PlQO oAB3lU8tKazj9WZ2ZisI9QkhNim8bgS+fEX9IsIMMSQxRaaMukLTCgDBsxfqdA9H3b5J M1OVKytwn7Z2likkiJJrSN0sQgdTZ5v3MneJW/Y0XkZwB4cERptXsdeE3Bivha/3l/vk 9wFA== X-Gm-Message-State: AOAM5325LOz6f71NDBXlz3xAnI+6cFGfqH4oyx0htAdhhKAVl31AHc54 8IIU5ZEGXMJ/Cyme4Iz5vFyU9D+b97F8wKGe4lcRc/peIZ70Aes3FiNX7XtdPo+bX5PzYf+h+7u yT7KT6UVysmmULf2uhKpYMSYUCPm6ZQqL0gGzj6GKrW7J88Q8wgQ5ZF+MT6dSEg== X-Received: by 2002:a5d:6752:: with SMTP id l18mr44946658wrw.422.1620834387151; Wed, 12 May 2021 08:46:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8OWt3TX7RiAaDCNyEAGKa8ifDjHlgmGC5TvDQwI4B28dK7lT17vF4tXuKGRUdo62YkLRngg== X-Received: by 2002:a5d:6752:: with SMTP id l18mr44946627wrw.422.1620834386907; Wed, 12 May 2021 08:46:26 -0700 (PDT) Received: from minerva.redhat.com ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id w7sm46285wru.51.2021.05.12.08.46.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 May 2021 08:46:26 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Carlos Maiolino , Daniel Kiper , Eric Sandeen , Javier Martinez Canillas Subject: [2.06 RELEASE PATCH v2 4/4] fs/xfs: Add needsrepair incompat feature support Date: Wed, 12 May 2021 17:46:16 +0200 Message-Id: <20210512154616.998242-5-javierm@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512154616.998242-1-javierm@redhat.com> References: <20210512154616.998242-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=170.10.133.124; envelope-from=javierm@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, 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=unavailable 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: Wed, 12 May 2021 15:46:58 -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 attempt 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, just ignore if a filesystem needs to be repaired. For this reason, make it a best effort but print a debug message when the XFS filesystem is accessed if should be repaired. That way, if the reading or later booting fail, the user can figure out that may be related to this. Suggested-by: Eric Sandeen Signed-off-by: Javier Martinez Canillas --- 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 bcf281cf80d..6056bf44e32 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -84,6 +84,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. @@ -98,7 +99,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 { @@ -307,6 +309,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 @@ -922,6 +934,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, can lead to failures\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