]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
zfs: recognize zpools formatted with features support
authorWHR <whr@rivoreo.one>
Tue, 30 Apr 2024 16:28:32 +0000 (00:28 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 13 May 2024 22:51:13 +0000 (16:51 -0600)
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>
fs/zfs/zfs.c
include/zfs/zfs.h

index c44e7ece5dfb0fb17d08b99a1cc744bfd841c978..06221e68b3505432c079d35d74a6accab376c94d 100644 (file)
@@ -333,6 +333,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.
@@ -354,14 +360,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) {
@@ -1787,7 +1791,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,
index 17b93c10c81c2231c9d447a5300c0171325c6576..72d87452ddf42b410d7e3ac2c144e0e1aa5cd72c 100644 (file)
@@ -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