Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1leCxp-0007vj-Cs for mharc-grub-devel@gnu.org; Wed, 05 May 2021 04:33:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCxn-0007sf-Ic for grub-devel@gnu.org; Wed, 05 May 2021 04:32:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leCxl-0001b6-KV for grub-devel@gnu.org; Wed, 05 May 2021 04:32:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620203577; 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=qWSb8t65XpimX9/SxMgNywq2AyXIuhBILF6ZyXxVAfU=; b=ZUmtGrRqTcpOiv3okwVRx9OCWSo9zUcEtIEVifnxmfqOzpgNPRXYz2/fy0+CACXhxZzGNy cMuZpRCCbXGsmFpJpnEQO49fcdjZTsuVGoLgtnR4aKQbDwyCYzVfVXqK+aNxiYyfXcIG/0 3Oi7LgoIqprqF5npLrqRoPToRBwsaL8= 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-416-ELC1b335O-GyOhxCB32QwQ-1; Wed, 05 May 2021 04:32:54 -0400 X-MC-Unique: ELC1b335O-GyOhxCB32QwQ-1 Received: by mail-wm1-f72.google.com with SMTP id j3-20020a1c55030000b029012e7c06101aso339419wmb.5 for ; Wed, 05 May 2021 01:32:54 -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=qWSb8t65XpimX9/SxMgNywq2AyXIuhBILF6ZyXxVAfU=; b=h+J2kqkivGLp0z5D69oc+9TSo5vOyJ0OyRDi8jlS4Gn/wq6UJYC9+e4UP+dWqD0hAZ f9A9B1a3z3MUAvi3B2o4mZgI+1q9YPcud4uDt4vHIAMdgSJBYWPpzSd8F1BYaH/rWnZi 726s0zFIG/jkXozFvGdMcGCPJJh8+xBPHOeeORHKrhlkw0SWLJxPdPZuzQTwB3S7WHgW Wu/C9xLYz9tivs8n03s+HQJBweEuIL3GAICc6qhAfg5Th6DoH2yFNseaBwhLo2nDhaXb dQIfbqpm+uqO7tjHgUmJV3OOmhb3n63JKgaMFTPtrAd9jhlDWasPztvxne1QYJM2Chpz yFYw== X-Gm-Message-State: AOAM532d+PALIxMx8pwQeD0qwxCQqh13LSI4HoS8/6DuYS8JKJeAp/I/ 3HmeFuhMLfTTCG0zrtL4+kznqao+jMB5pcyCbBt84QIThX8YhKLIIG9YyP3VCJZSbVBDAIqNnCl NhlFMUgMWohNACBbDtbRV5zpSMuVjfZSR8BjhmvQJJ1NBaYuuenVO46D6OWt7kA== X-Received: by 2002:a1c:2c0a:: with SMTP id s10mr8500232wms.158.1620203572851; Wed, 05 May 2021 01:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3Sa+wpfzbpKbauGSC4VF1/nBPCJyTNlQA8aZXaCe2vWrJY3cv49lQiGPiSEth0ebOoihb8w== X-Received: by 2002:a1c:2c0a:: with SMTP id s10mr8500206wms.158.1620203572634; Wed, 05 May 2021 01:32:52 -0700 (PDT) Received: from minerva.redhat.com ([92.176.231.106]) by smtp.gmail.com with ESMTPSA id d9sm9902441wrp.47.2021.05.05.01.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 01:32:52 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Daniel Kiper , Eric Sandeen , Carlos Maiolino , Javier Martinez Canillas Subject: [2.06 RELEASE PATCH 3/3] fs/xfs: Add needsrepair incompat feature support Date: Wed, 5 May 2021 10:32:33 +0200 Message-Id: <20210505083233.332691-4-javierm@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210505083233.332691-1-javierm@redhat.com> References: <20210505083233.332691-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.697, 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: Wed, 05 May 2021 08:32:59 -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 --- 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..9e290a144a0 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", "Filesystem needs repair, could cause reads to 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