Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1ldaDq-0005ZW-SU for mharc-grub-devel@gnu.org; Mon, 03 May 2021 11:10:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldaDo-0005XD-LS for grub-devel@gnu.org; Mon, 03 May 2021 11:10:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ldaDm-0005Qu-Kz for grub-devel@gnu.org; Mon, 03 May 2021 11:10:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620054653; 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=mEfI09wahd7VzjrLoE9stofks/l0bnkpGRYxwj+z/ZA=; b=Mlb5p+uLykFuidhcIeLF1X899PSlURneJR2lhWHmDZcZmRDwJN7SIaEHcpdJPd/DTYHHhO wicvHoDRyi2SZeFidBtjsF02PsMChWSZlq6iQm+IfbVG6pu6Vvuz1Kn0k/mA47pUALrg5L RAHvLqZvelVIK6Muij7LDI+XZNVah3k= 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-589-ZISlSSYfOTmMRiFVAyto9A-1; Mon, 03 May 2021 11:10:47 -0400 X-MC-Unique: ZISlSSYfOTmMRiFVAyto9A-1 Received: by mail-wm1-f72.google.com with SMTP id l185-20020a1c25c20000b029014b0624775eso895799wml.6 for ; Mon, 03 May 2021 08:10:47 -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=mEfI09wahd7VzjrLoE9stofks/l0bnkpGRYxwj+z/ZA=; b=P1aR4knVcZiv6njKsvRbkxs7NyOWAbBmuODK679A7bSm0lmxTXbVMMdqyL2BXLTiTN jC55xyNlii6fwQYhxjsUSraX7Gvu4GG5BRCIJFhTgUv3O01cNDVG5RWpOjgX2AFWummE wTIhTCbNbKvvsjyWhYGG1AqrwPY5J14jXMFODyqyaYvAqXWbym88VPvXN4AhUgjgaacY ZVCUrIJnGYRCn3OqTjC/ej9yValkmLeEk0IEJCH4HUd9MYi8Db43gk6nsS7imdqVn1W8 mz6JC69Hspc6p5dCOXUCUvFA4YryIkhi0CTODEgtHPlYhb6PfIPocw53V636l51L+0by l9Hw== X-Gm-Message-State: AOAM533j0XhMX/nRE0hcMeQA0Q+QNdS9+0TENequ38Mgy2dZErGyLClO HDsyRVdJph2Zheeq8p7xA1rkFqxoOx3fVofd4OsBzP4jA0zJjki/SiQ/j6xHAKMDr8N9pr6j/BW c4jIeDX6AtsbSm4klC1eHfLgyba/yk9yY+JphGwGz/An/XzLMBHEOMDiwTkb6pw== X-Received: by 2002:adf:f38c:: with SMTP id m12mr20071670wro.282.1620054645922; Mon, 03 May 2021 08:10:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkjL7M8UTbWE8MUw2dkug3rID7hpCDJSwO9v4r7Vu/yBtyJ5jOpBhjx1sS76cFnfntTqpPCA== X-Received: by 2002:adf:f38c:: with SMTP id m12mr20071642wro.282.1620054645639; Mon, 03 May 2021 08:10:45 -0700 (PDT) Received: from minerva.redhat.com ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id f22sm11373606wmj.42.2021.05.03.08.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 May 2021 08:10:44 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Javier Martinez Canillas , Eric Sandeen , Carlos Maiolino , Daniel Kiper , Vladimir Serbinenko Subject: [PATCH v3] xfs: Include needsrepair in the supported incompat features list Date: Mon, 3 May 2021 17:10:40 +0200 Message-Id: <20210503151040.132155-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: -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.698, 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, 03 May 2021 15:10:56 -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. 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 that 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 GRUB doesn't attempt to detect if the filesystem is inconsistent nor replays the journal, just ignore if a filesystem needs to be repaired too. But print a message if grub_xfs_mount() fails, to give more information to the user about why that could had been the case. Suggested-by: Eric Sandeen Signed-off-by: Javier Martinez Canillas --- Hello, This is a v3 of the XFS needsrepair patch addressing the issue pointed out by Vladimir. As mentioned this patch isn't really optional if the feature flag XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR is set, since it will prevent GRUB to access the filesystem at all due detecting an unsupported feature flag. The patch is on top of Carlos' "[PATCH V2 0/2] Enable bigtime feature for xfs driver" series. There's no dependency really but it would make easier to pick the patches and avoid merge conflicts. [0]: https://www.mail-archive.com/grub-devel@gnu.org/msg32079.html Best regards, Javier Changes in v3: - Only print that the filesystem needs to be repaired if reading fails (phcoder). Changes in v2: - Add Carlos Reviewed-by tag - Improve commit message (dkiper) - Rename the grub_xfs_sb_needsrepair() function (dkiper) - Add more parenthesis to the need repair check (dkiper) - Drop curly brackets for single statement (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 2ce76ec70f9..c4c1bca39a8 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 @@ -949,6 +961,9 @@ grub_xfs_mount (grub_disk_t disk) return data; fail: + if (grub_xfs_sb_needs_repair(data)) + grub_dprintf("xfs", "Filesystem needs repair\n"); + if (grub_errno == GRUB_ERR_OUT_OF_RANGE) grub_error (GRUB_ERR_BAD_FS, "not an XFS filesystem"); -- 2.31.1