From: "WHR" <whr@rivoreo.one>
To: u-boot@lists.denx.de
Cc: "Tom Rini" <trini@konsulko.com>, mwleeds@mailtundra.com
Subject: [PATCH v2] zfs: recognize zpools formatted with features support
Date: Wed, 1 May 2024 00:28:32 +0800 [thread overview]
Message-ID: <ef1e359cca14def7a46d81a525ed1eb2.squirrel@_> (raw)
[-- Attachment #1: Type: text/plain, Size: 388 bytes --]
Currently no features are implemented, only the zpool version 5000 that
indicating the features support, is recognized. Since it is possible for
OpenZFS to create a pool with features support enabled, but without
enabling any actual feature, this change enables U-Boot to read such
pools.
Signed-off-by: WHR <msl0000023508@gmail.com>
---
v2:
Remove an unused local variable definition.
[-- Attachment #2: 0001-zfs-recognize-zpools-formatted-with-features-support --]
[-- Type: text/plain, Size: 2011 bytes --]
diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index 4896cc18ef..113b428a93 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -336,6 +336,12 @@ vdev_uberblock_compare(uberblock_t *ub1, uberblock_t *ub2)
return 0;
}
+static inline int
+is_supported_spa_version(uint64_t version) {
+ return version == FEATURES_SUPPORTED_SPA_VERSION ||
+ (version > 0 && version <= SPA_VERSION);
+}
+
/*
* Three pieces of information are needed to verify an uberblock: the magic
* number, the version number, and the checksum.
@@ -357,14 +363,12 @@ uberblock_verify(uberblock_t *uber, int offset, struct zfs_data *data)
return ZFS_ERR_BAD_FS;
}
- if (zfs_to_cpu64(uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC
- && zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN) > 0
- && zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN) <= SPA_VERSION)
+ if (zfs_to_cpu64(uber->ub_magic, LITTLE_ENDIAN) == UBERBLOCK_MAGIC &&
+ is_supported_spa_version(zfs_to_cpu64(uber->ub_version, LITTLE_ENDIAN)))
endian = LITTLE_ENDIAN;
- if (zfs_to_cpu64(uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC
- && zfs_to_cpu64(uber->ub_version, BIG_ENDIAN) > 0
- && zfs_to_cpu64(uber->ub_version, BIG_ENDIAN) <= SPA_VERSION)
+ if (zfs_to_cpu64(uber->ub_magic, BIG_ENDIAN) == UBERBLOCK_MAGIC &&
+ is_supported_spa_version(zfs_to_cpu64(uber->ub_version, BIG_ENDIAN)))
endian = BIG_ENDIAN;
if (endian == UNKNOWN_ENDIAN) {
@@ -1790,7 +1794,7 @@ check_pool_label(struct zfs_data *data)
return ZFS_ERR_BAD_FS;
}
- if (version > SPA_VERSION) {
+ if (!is_supported_spa_version(version)) {
free(nvlist);
printf("SPA version too new %llu > %llu\n",
(unsigned long long) version,
diff --git a/include/zfs/zfs.h b/include/zfs/zfs.h
index 17b93c10c8..72d87452dd 100644
--- a/include/zfs/zfs.h
+++ b/include/zfs/zfs.h
@@ -15,6 +15,7 @@
* On-disk version number.
*/
#define SPA_VERSION 28ULL
+#define FEATURES_SUPPORTED_SPA_VERSION 5000ULL
/*
* The following are configuration names used in the nvlist describing a pool's
next reply other threads:[~2024-04-30 16:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 16:28 WHR [this message]
2024-05-14 16:15 ` [PATCH v2] zfs: recognize zpools formatted with features support Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ef1e359cca14def7a46d81a525ed1eb2.squirrel@_ \
--to=whr@rivoreo.one \
--cc=mwleeds@mailtundra.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).