From patchwork Thu Dec 13 22:52:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 1996 Return-Path: Received: from mail01.ipfire.org (mail01.i.ipfire.org [172.28.1.200]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail01.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web07.i.ipfire.org (Postfix) with ESMTPS id DA33A8ABD88 for ; Thu, 13 Dec 2018 11:52:59 +0000 (GMT) Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 5DD502019646; Thu, 13 Dec 2018 11:52:58 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1544701978; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:list-id:list-unsubscribe:list-subscribe:list-post; bh=xUAmM9ULzSbJ7Y0BURC4FVSwvo2j2mOP116xG6JWJsA=; b=TiairGiBxwKHuW1kpAZYOR9FwTZuohlRyHRQdlwqqEWyw7MYXwZtSeImaIjNiyMFn/0pdO 095Jydf1r/n+a7heHlGERcagyCAV1t163NWG9p9MipgF91Z7E6lJqGFcR0MpPKpcdpV/A/ LP+SxHA/wfOQH5sk33ljE6xP868mJo6D1PlJec8lu1Mc3T7VsGieZIRvDTJfwfDEzksM5j q/MynpwY0gPLtzUjTckqqxf2PpfDCyc/CBMCOiS0vkfvVPmEnfSkipVmXAHQaSoh7VP7Ao i8TrTWcZpT6PlYX5T05kItlaIXnARPzrInWtf91ixoc1X7VXHIcZKhNNkj2/1g== Received: from tuxedo.stevee (213162073201.public.t-mobile.at [213.162.73.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id E7DFC21B9E54; Thu, 13 Dec 2018 11:52:55 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=201801; t=1544701976; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=xUAmM9ULzSbJ7Y0BURC4FVSwvo2j2mOP116xG6JWJsA=; b=SY0MlKFLOEH6zDxVG00oUagd+hsH1MLu9nIxV3ZhdrJ2bH7SUb76A15pvKDttfeizl6eSC CAqvU0MeWJl/id5wDeI8P5RXVI9YwfIfL6/4hN5nG0d0bd1T3t/4TDAN02u4mORC5VTFJA wcvGX+ipGcBsYrM0zioNnYS673C1JmMXJtzdbW+Tn+k/xBLp+lIWlmDerwBpl/qVRnPfZa CaEbTvEIoXfXAUofDRNRuMpSpF4bXOQpDINvVGytVmHvXNS8P9cNuhGQs4pESTMe/Pf20f CVIPQMVY8rOkd5XMMSBMUe7WPVmBG0BlMVkCSvD6JC7f7s8Vog+98oUHLfbEYw== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] grub: xfs: Accept filesystem with sparse inodes Date: Thu, 13 Dec 2018 12:52:50 +0100 Message-Id: <20181213115250.17494-1-stefan.schantl@ipfire.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Spam-Status: No, score=4.90 X-Rspamd-Server: mail01.i.ipfire.org Authentication-Results: mail01.ipfire.org; auth=pass smtp.auth=stevee smtp.mailfrom=stefan.schantl@ipfire.org X-Spamd-Result: default: False [4.90 / 11.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; DKIM_SIGNED(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8412, ipnet:213.162.64.0/19, country:AT]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: **** X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Stefan Schantl Tested-by: Stefan Schantl --- lfs/grub | 1 + ...accept-filesystem-with-sparse-inodes.patch | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 src/patches/grub-2.02-xfs-accept-filesystem-with-sparse-inodes.patch diff --git a/lfs/grub b/lfs/grub index 1a10c2aa5..e6131f2f5 100644 --- a/lfs/grub +++ b/lfs/grub @@ -99,6 +99,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @rm -rf $(DIR_APP) $(DIR_APP_EFI) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-2.02_disable_vga_fallback.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/grub-2.02-xfs-accept-filesystem-with-sparse-inodes.patch # Install unifont cp -v $(DIR_DL)/unifont-7.0.03.pcf.gz $(DIR_APP)/unifont.pcf.gz diff --git a/src/patches/grub-2.02-xfs-accept-filesystem-with-sparse-inodes.patch b/src/patches/grub-2.02-xfs-accept-filesystem-with-sparse-inodes.patch new file mode 100644 index 000000000..6c6a750b4 --- /dev/null +++ b/src/patches/grub-2.02-xfs-accept-filesystem-with-sparse-inodes.patch @@ -0,0 +1,60 @@ +From cda0a857dd7a27cd5d621747464bfe71e8727fff Mon Sep 17 00:00:00 2001 +From: Daniel Kiper +Date: Tue, 29 May 2018 16:16:02 +0200 +Subject: xfs: Accept filesystem with sparse inodes + +The sparse inode metadata format became a mkfs.xfs default in +xfsprogs-4.16.0, and such filesystems are now rejected by grub as +containing an incompatible feature. + +In essence, this feature allows xfs to allocate inodes into fragmented +freespace. (Without this feature, if xfs could not allocate contiguous +space for 64 new inodes, inode creation would fail.) + +In practice, the disk format change is restricted to the inode btree, +which as far as I can tell is not used by grub. If all you're doing +today is parsing a directory, reading an inode number, and converting +that inode number to a disk location, then ignoring this feature +should be fine, so I've added it to XFS_SB_FEAT_INCOMPAT_SUPPORTED + +I did some brief testing of this patch by hacking up the regression +tests to completely fragment freespace on the test xfs filesystem, and +then write a large-ish number of inodes to consume any existing +contiguous 64-inode chunk. This way any files the grub tests add and +traverse would be in such a fragmented inode allocation. Tests passed, +but I'm not sure how to cleanly integrate that into the test harness. + +Signed-off-by: Eric Sandeen +Reviewed-by: Daniel Kiper +Tested-by: Chris Murphy +--- + grub-core/fs/xfs.c | 11 ++++++++++- + 1 file changed, 10 insertions(+), 1 deletion(-) + +diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c +index c6031bd..3b00c74 100644 +--- a/grub-core/fs/xfs.c ++++ b/grub-core/fs/xfs.c +@@ -79,9 +79,18 @@ 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 */ + +-/* We do not currently verify metadata UUID so it is safe to read such filesystem */ ++/* ++ * Directory entries with ftype are explicitly handled by GRUB code. ++ * ++ * We do not currently read the inode btrees, so it is safe to read filesystems ++ * with the XFS_SB_FEAT_INCOMPAT_SPINODES feature. ++ * ++ * We do not currently verify metadata UUID, so it is safe to read filesystems ++ * with the XFS_SB_FEAT_INCOMPAT_META_UUID feature. ++ */ + #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ + (XFS_SB_FEAT_INCOMPAT_FTYPE | \ ++ XFS_SB_FEAT_INCOMPAT_SPINODES | \ + XFS_SB_FEAT_INCOMPAT_META_UUID) + + struct grub_xfs_sblock +-- +cgit v1.0-41-gc330 +