bcachefs: 2023-06-28 -> 2023-09-29

Includes prep work for mainline bcachefs release.

authored by Daniel Hill and committed by Jörg Thalheim d6bf8b47 6c1a24a6

+351 -46
+14
nixos/modules/installer/tools/nixos-generate-config.pl
··· 273 274 # Add bcache module, if needed. 275 my @bcacheDevices = glob("/dev/bcache*"); 276 if (scalar @bcacheDevices > 0) { 277 push @initrdAvailableKernelModules, "bcache"; 278 } ··· 482 # Don't emit tmpfs entry for /tmp, because it most likely comes from the 483 # boot.tmp.useTmpfs option in configuration.nix (managed declaratively). 484 next if ($mountPoint eq "/tmp" && $fsType eq "tmpfs"); 485 486 # Emit the filesystem. 487 $fileSystems .= <<EOF;
··· 273 274 # Add bcache module, if needed. 275 my @bcacheDevices = glob("/dev/bcache*"); 276 + @bcacheDevices = grep(!qr#dev/bcachefs.*#, @bcacheDevices); 277 if (scalar @bcacheDevices > 0) { 278 push @initrdAvailableKernelModules, "bcache"; 279 } ··· 483 # Don't emit tmpfs entry for /tmp, because it most likely comes from the 484 # boot.tmp.useTmpfs option in configuration.nix (managed declaratively). 485 next if ($mountPoint eq "/tmp" && $fsType eq "tmpfs"); 486 + 487 + # This should work for single and multi-device systems. 488 + # still needs subvolume support 489 + if ($fsType eq "bcachefs") { 490 + my ($status, @info) = runCommand("bcachefs fs usage $rootDir$mountPoint"); 491 + my $UUID = $info[0]; 492 + 493 + if ($status == 0 && $UUID =~ /^Filesystem:[ \t\n]*([0-9a-z-]+)/) { 494 + $stableDevPath = "UUID=$1"; 495 + } else { 496 + print STDERR "warning: can't find bcachefs mount UUID falling back to device-path"; 497 + } 498 + } 499 500 # Emit the filesystem. 501 $fileSystems .= <<EOF;
+33 -18
nixos/modules/tasks/filesystems/bcachefs.nix
··· 6 7 bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems; 8 9 - mountCommand = pkgs.runCommand "mount.bcachefs" {} '' 10 - mkdir -p $out/bin 11 - cat > $out/bin/mount.bcachefs <<EOF 12 - #!/bin/sh 13 - exec "/bin/bcachefs" mount "\$@" 14 - EOF 15 - chmod +x $out/bin/mount.bcachefs 16 - ''; 17 - 18 commonFunctions = '' 19 prompt() { 20 local name="$1" 21 printf "enter passphrase for $name: " 22 } 23 tryUnlock() { 24 local name="$1" 25 local path="$2" 26 if bcachefs unlock -c $path > /dev/null 2> /dev/null; then # test for encryption 27 prompt $name 28 until bcachefs unlock $path 2> /dev/null; do # repeat until successfully unlocked ··· 30 prompt $name 31 done 32 printf "unlocking successful.\n" 33 fi 34 } 35 ''; ··· 51 { 52 config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [ 53 { 54 - # We do not want to include bachefs in the fsPackages for systemd-initrd 55 - # because we provide the unwrapped version of mount.bcachefs 56 - # through the extraBin option, which will make it available for use. 57 - system.fsPackages = lib.optional (!config.boot.initrd.systemd.enable) pkgs.bcachefs-tools; 58 - environment.systemPackages = lib.optional (config.boot.initrd.systemd.enable) pkgs.bcachefs-tools; 59 60 # use kernel package with bcachefs support until it's in mainline 61 boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs; 62 } 63 64 (mkIf ((elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) { 65 # chacha20 and poly1305 are required only for decryption attempts 66 boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ]; 67 - 68 boot.initrd.systemd.extraBin = { 69 "bcachefs" = "${pkgs.bcachefs-tools}/bin/bcachefs"; 70 - "mount.bcachefs" = "${mountCommand}/bin/mount.bcachefs"; 71 }; 72 - 73 boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 74 copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs 75 - copy_bin_and_libs ${mountCommand}/bin/mount.bcachefs 76 ''; 77 boot.initrd.extraUtilsCommandsTest = '' 78 $out/bin/bcachefs version
··· 6 7 bootFs = filterAttrs (n: fs: (fs.fsType == "bcachefs") && (utils.fsNeededForBoot fs)) config.fileSystems; 8 9 commonFunctions = '' 10 prompt() { 11 local name="$1" 12 printf "enter passphrase for $name: " 13 } 14 + 15 tryUnlock() { 16 local name="$1" 17 local path="$2" 18 + local success=false 19 + local target 20 + local uuid=$(echo -n $path | sed -e 's,UUID=\(.*\),\1,g') 21 + 22 + printf "waiting for device to appear $path" 23 + for try in $(seq 10); do 24 + if [ -e $path ]; then 25 + success=true 26 + break 27 + else 28 + target=$(blkid --uuid $uuid) 29 + if [ $? == 0 ]; then 30 + success=true 31 + break 32 + fi 33 + fi 34 + echo -n "." 35 + sleep 1 36 + done 37 + printf "\n" 38 + if [ $success == true ]; then 39 + path=$target 40 + fi 41 + 42 if bcachefs unlock -c $path > /dev/null 2> /dev/null; then # test for encryption 43 prompt $name 44 until bcachefs unlock $path 2> /dev/null; do # repeat until successfully unlocked ··· 46 prompt $name 47 done 48 printf "unlocking successful.\n" 49 + else 50 + echo "Cannot unlock device $uuid with path $path" >&2 51 fi 52 } 53 ''; ··· 69 { 70 config = mkIf (elem "bcachefs" config.boot.supportedFilesystems) (mkMerge [ 71 { 72 + # needed for systemd-remount-fs 73 + system.fsPackages = [ pkgs.bcachefs-tools ]; 74 75 # use kernel package with bcachefs support until it's in mainline 76 + # TODO replace with requireKernelConfig 77 boot.kernelPackages = pkgs.linuxPackages_testing_bcachefs; 78 } 79 80 (mkIf ((elem "bcachefs" config.boot.initrd.supportedFilesystems) || (bootFs != {})) { 81 # chacha20 and poly1305 are required only for decryption attempts 82 boot.initrd.availableKernelModules = [ "bcachefs" "sha256" "chacha20" "poly1305" ]; 83 boot.initrd.systemd.extraBin = { 84 + # do we need this? boot/systemd.nix:566 & boot/systemd/initrd.nix:357 85 "bcachefs" = "${pkgs.bcachefs-tools}/bin/bcachefs"; 86 + "mount.bcachefs" = "${pkgs.bcachefs-tools}/bin/mount.bcachefs"; 87 }; 88 boot.initrd.extraUtilsCommands = lib.mkIf (!config.boot.initrd.systemd.enable) '' 89 copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs 90 + copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs 91 ''; 92 boot.initrd.extraUtilsCommandsTest = '' 93 $out/bin/bcachefs version
+5
pkgs/os-specific/linux/kernel/bcachefs.json
···
··· 1 + { 2 + "diffHash": "sha256-BmXd/5Hn/xr7gNFp6BsBMG2XeKFlPGxv66IQ8DEwh5k=", 3 + "commit": "4d2faeb4fb58c389dc9f76b8d5ae991ef4497e04", 4 + "date": "2023-09-28" 5 + }
+6 -8
pkgs/os-specific/linux/kernel/linux-testing-bcachefs.nix
··· 2 , stdenv 3 , fetchpatch 4 , kernel 5 - , commitDate ? "2023-06-28" 6 # bcachefs-tools stores the expected-revision in: 7 # https://evilpiepirate.org/git/bcachefs-tools.git/tree/.bcachefs_revision 8 # but this does not means that it'll be the latest-compatible revision 9 - , currentCommit ? "84f132d5696138bb038d2dc8f1162d2fab5ac832" 10 - , diffHash ? "sha256-RaBWBU7rXjJFb1euFAFBHWCBQAG7npaCodjp/vMYpyw=" 11 , kernelPatches # must always be defined in bcachefs' all-packages.nix entry because it's also a top-level attribute supplied by callPackage 12 , argsOverride ? {} 13 , ... ··· 15 16 # NOTE: bcachefs-tools should be updated simultaneously to preserve compatibility 17 (kernel.override ( args // { 18 - version = "${kernel.version}-bcachefs-unstable-${commitDate}"; 19 20 extraMeta = { 21 branch = "master"; ··· 32 }; 33 34 kernelPatches = [ { 35 - name = "bcachefs-${currentCommit}"; 36 37 patch = fetchpatch { 38 - name = "bcachefs-${currentCommit}.diff"; 39 - url = "https://evilpiepirate.org/git/bcachefs.git/rawdiff/?id=${currentCommit}&id2=v${lib.versions.majorMinor kernel.version}"; 40 - sha256 = diffHash; 41 }; 42 } ] ++ kernelPatches; 43 }))
··· 2 , stdenv 3 , fetchpatch 4 , kernel 5 # bcachefs-tools stores the expected-revision in: 6 # https://evilpiepirate.org/git/bcachefs-tools.git/tree/.bcachefs_revision 7 # but this does not means that it'll be the latest-compatible revision 8 + , version ? lib.importJSON ./bcachefs.json 9 , kernelPatches # must always be defined in bcachefs' all-packages.nix entry because it's also a top-level attribute supplied by callPackage 10 , argsOverride ? {} 11 , ... ··· 13 14 # NOTE: bcachefs-tools should be updated simultaneously to preserve compatibility 15 (kernel.override ( args // { 16 + version = "${kernel.version}-bcachefs-unstable-${version.date}"; 17 18 extraMeta = { 19 branch = "master"; ··· 30 }; 31 32 kernelPatches = [ { 33 + name = "bcachefs-${version.commit}"; 34 35 patch = fetchpatch { 36 + name = "bcachefs-${version.commit}.diff"; 37 + url = "https://evilpiepirate.org/git/bcachefs.git/rawdiff/?id=${version.commit}&id2=v${lib.versions.majorMinor kernel.version}"; 38 + sha256 = version.diffHash; 39 }; 40 } ] ++ kernelPatches; 41 }))
+277
pkgs/os-specific/linux/util-linux/bcachefs-patch-set.patch
···
··· 1 + commit 68564ebb50f8afab5a9527c534417e247cca0b27 2 + Author: Filipe Manana <fdmanana@kernel.org> 3 + Date: Thu Aug 17 10:20:13 2023 +0100 4 + 5 + libmount: Fix regression when mounting with atime 6 + 7 + A regression was introduced in v2.39 that causes mounting with the atime 8 + option to fail: 9 + 10 + $ mkfs.ext4 -F /dev/sdi 11 + $ mount -o atime /dev/sdi /mnt/sdi 12 + mount: /mnt/sdi: not mount point or bad option. 13 + dmesg(1) may have more information after failed mount system call. 14 + 15 + The failure comes from the mount_setattr(2) call returning -EINVAL. This 16 + is because we pass an invalid value for the attr_clr argument. From a 17 + strace capture we have: 18 + 19 + mount_setattr(4, "", AT_EMPTY_PATH, {attr_set=0, attr_clr=MOUNT_ATTR_NOATIME, propagation=0 /* MS_??? */, userns_fd=0}, 32) = -1 EINVAL (Invalid argument) 20 + 21 + We can't pass MOUNT_ATTR_NOATIME to mount_setattr(2) through the attr_clr 22 + argument because all atime options are exclusive, so in order to set atime 23 + one has to pass MOUNT_ATTR__ATIME to attr_clr and leave attr_set as 24 + MOUNT_ATTR_RELATIME (which is defined as a value of 0). 25 + 26 + This can be read from the man page for mount_setattr(2) and also from the 27 + kernel source: 28 + 29 + $ cat fs/namespace.c 30 + static int build_mount_kattr(const struct mount_attr *attr, size_t usize, 31 + struct mount_kattr *kattr, unsigned int flags) 32 + { 33 + (...) 34 + /* 35 + * Since the MOUNT_ATTR_<atime> values are an enum, not a bitmap, 36 + * users wanting to transition to a different atime setting cannot 37 + * simply specify the atime setting in @attr_set, but must also 38 + * specify MOUNT_ATTR__ATIME in the @attr_clr field. 39 + * So ensure that MOUNT_ATTR__ATIME can't be partially set in 40 + * @attr_clr and that @attr_set can't have any atime bits set if 41 + * MOUNT_ATTR__ATIME isn't set in @attr_clr. 42 + */ 43 + if (attr->attr_clr & MOUNT_ATTR__ATIME) { 44 + if ((attr->attr_clr & MOUNT_ATTR__ATIME) != MOUNT_ATTR__ATIME) 45 + return -EINVAL; 46 + 47 + /* 48 + * Clear all previous time settings as they are mutually 49 + * exclusive. 50 + */ 51 + kattr->attr_clr |= MNT_RELATIME | MNT_NOATIME; 52 + switch (attr->attr_set & MOUNT_ATTR__ATIME) { 53 + case MOUNT_ATTR_RELATIME: 54 + kattr->attr_set |= MNT_RELATIME; 55 + break; 56 + case MOUNT_ATTR_NOATIME: 57 + kattr->attr_set |= MNT_NOATIME; 58 + break; 59 + case MOUNT_ATTR_STRICTATIME: 60 + break; 61 + default: 62 + return -EINVAL; 63 + } 64 + (...) 65 + 66 + So fix this by setting attr_clr MOUNT_ATTR__ATIME if we want to clear any 67 + atime related option. 68 + 69 + Signed-off-by: Filipe Manana <fdmanana@kernel.org> 70 + 71 + diff --git a/libmount/src/optlist.c b/libmount/src/optlist.c 72 + index 1e962ec6d..0702adae7 100644 73 + --- a/libmount/src/optlist.c 74 + +++ b/libmount/src/optlist.c 75 + @@ -875,7 +875,18 @@ int mnt_optlist_get_attrs(struct libmnt_optlist *ls, uint64_t *set, uint64_t *cl 76 + 77 + if (opt->ent->mask & MNT_INVERT) { 78 + DBG(OPTLIST, ul_debugobj(ls, " clr: %s", opt->ent->name)); 79 + - *clr |= x; 80 + + /* 81 + + * All atime settings are mutually exclusive so *clr must 82 + + * have MOUNT_ATTR__ATIME set. 83 + + * 84 + + * See the function fs/namespace.c:build_mount_kattr() 85 + + * in the linux kernel source. 86 + + */ 87 + + if (x == MOUNT_ATTR_RELATIME || x == MOUNT_ATTR_NOATIME || 88 + + x == MOUNT_ATTR_STRICTATIME) 89 + + *clr |= MOUNT_ATTR__ATIME; 90 + + else 91 + + *clr |= x; 92 + } else { 93 + DBG(OPTLIST, ul_debugobj(ls, " set: %s", opt->ent->name)); 94 + *set |= x; 95 + diff --git a/tests/expected/libmount/context-mount-flags b/tests/expected/libmount/context-mount-flags 96 + index 960641863..eb71323dd 100644 97 + --- a/tests/expected/libmount/context-mount-flags 98 + +++ b/tests/expected/libmount/context-mount-flags 99 + @@ -3,3 +3,6 @@ ro,nosuid,noexec 100 + successfully mounted 101 + rw,nosuid,noexec 102 + successfully umounted 103 + +successfully mounted 104 + +rw,relatime 105 + +successfully umounted 106 + diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context 107 + index f5b47185e..a5d2e81a3 100755 108 + --- a/tests/ts/libmount/context 109 + +++ b/tests/ts/libmount/context 110 + @@ -116,8 +116,15 @@ $TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPU 111 + 112 + ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG 113 + is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG 114 + -ts_finalize_subtest 115 + 116 + +# Test that the atime option works after the migration to use the new kernel mount APIs. 117 + +ts_run $TESTPROG --mount -o atime $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG 118 + +$TS_CMD_FINDMNT --kernel --mountpoint $MOUNTPOINT -o VFS-OPTIONS -n >> $TS_OUTPUT 2>> $TS_ERRLOG 119 + +is_mounted $DEVICE || echo "$DEVICE not mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG 120 + +ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>> $TS_ERRLOG 121 + +is_mounted $DEVICE && echo "$DEVICE still mounted" >> $TS_OUTPUT 2>> $TS_ERRLOG 122 + + 123 + +ts_finalize_subtest 124 + 125 + ts_init_subtest "mount-loopdev" 126 + mkdir -p $MOUNTPOINT &> /dev/null 127 + 128 + commit 1ec71634aa4ef5ddca23d65c8a296f3614231e8a 129 + Author: Colin Gillespie <colin@cgillespie.xyz> 130 + Date: Wed Aug 9 18:28:07 2023 +1000 131 + 132 + libblkid: (bcachefs) fix not detecting large superblocks 133 + 134 + Probing does not detect bcachefs filesystems with a superblock larger 135 + than 4KiB. Bcachefs superblocks grow in size and can become much larger 136 + than this. 137 + 138 + Increase the superblock maximum size limit to 1MiB. 139 + 140 + Validate the superblock isn't larger than the maximum size defined in 141 + the superblocks layout section. 142 + 143 + (cherry picked from commit 48d573797797650d96456979797c0155d58f61cb) 144 + 145 + diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c 146 + index 40e702d75..236877042 100644 147 + --- a/libblkid/src/superblocks/bcache.c 148 + +++ b/libblkid/src/superblocks/bcache.c 149 + @@ -102,6 +102,15 @@ union bcachefs_sb_csum { 150 + uint8_t raw[16]; 151 + } __attribute__((packed)); 152 + 153 + +struct bcachefs_sb_layout { 154 + + uint8_t magic[16]; 155 + + uint8_t layout_type; 156 + + uint8_t sb_max_size_bits; 157 + + uint8_t nr_superblocks; 158 + + uint8_t pad[5]; 159 + + uint64_t sb_offset[61]; 160 + +} __attribute__((packed)); 161 + + 162 + struct bcachefs_super_block { 163 + union bcachefs_sb_csum csum; 164 + uint16_t version; 165 + @@ -123,7 +132,7 @@ struct bcachefs_super_block { 166 + uint64_t flags[8]; 167 + uint64_t features[2]; 168 + uint64_t compat[2]; 169 + - uint8_t layout[512]; 170 + + struct bcachefs_sb_layout layout; 171 + struct bcachefs_sb_field _start[]; 172 + } __attribute__((packed)); 173 + 174 + @@ -143,7 +152,7 @@ struct bcachefs_super_block { 175 + /* granularity of offset and length fields within superblock */ 176 + #define BCACHEFS_SECTOR_SIZE 512 177 + /* maximum superblock size */ 178 + -#define BCACHEFS_SB_MAX_SIZE 4096 179 + +#define BCACHEFS_SB_MAX_SIZE 0x100000 180 + /* fields offset within super block */ 181 + #define BCACHEFS_SB_FIELDS_OFF offsetof(struct bcachefs_super_block, _start) 182 + /* tag value for members field */ 183 + @@ -302,6 +311,9 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag) 184 + return BLKID_PROBE_NONE; 185 + 186 + sb_size = BCACHEFS_SB_FIELDS_OFF + BYTES(bcs); 187 + + if (sb_size > BCACHEFS_SECTOR_SIZE << bcs->layout.sb_max_size_bits) 188 + + return BLKID_PROBE_NONE; 189 + + 190 + if (sb_size > BCACHEFS_SB_MAX_SIZE) 191 + return BLKID_PROBE_NONE; 192 + 193 + 194 + commit acbf17ae8f8ee0f941fe98ed12f115f2b349bba8 195 + Author: Karel Zak <kzak@redhat.com> 196 + Date: Wed Aug 23 11:53:45 2023 +0200 197 + 198 + libblkid: (bcachefs) fix compiler warning [-Werror=sign-compare] 199 + 200 + Addresses: https://github.com/util-linux/util-linux/pull/2427 201 + Signed-off-by: Karel Zak <kzak@redhat.com> 202 + (cherry picked from commit 17873d38fc97913c0a31d4bd08cfbfe45c4de5be) 203 + 204 + diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c 205 + index 236877042..6ab3fe9d4 100644 206 + --- a/libblkid/src/superblocks/bcache.c 207 + +++ b/libblkid/src/superblocks/bcache.c 208 + @@ -311,7 +311,7 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag) 209 + return BLKID_PROBE_NONE; 210 + 211 + sb_size = BCACHEFS_SB_FIELDS_OFF + BYTES(bcs); 212 + - if (sb_size > BCACHEFS_SECTOR_SIZE << bcs->layout.sb_max_size_bits) 213 + + if (sb_size > ((uint64_t) BCACHEFS_SECTOR_SIZE << bcs->layout.sb_max_size_bits)) 214 + return BLKID_PROBE_NONE; 215 + 216 + if (sb_size > BCACHEFS_SB_MAX_SIZE) 217 + 218 + commit 6b9fda87c4e5d0c6f945d7565197f157b9fa3d5f 219 + Author: Thomas Weißschuh <thomas@t-8ch.de> 220 + Date: Wed Aug 23 11:58:33 2023 +0200 221 + 222 + libblkid: (bcachefs) fix size validation 223 + 224 + Avoid signed shift out-of-bounds. 225 + 226 + Also mark the constants explitly as unsigned instead of casting. 227 + 228 + Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de> 229 + (cherry picked from commit befe455f59de8c7bc66b85ed52aae8cbc95325fa) 230 + 231 + diff --git a/libblkid/src/superblocks/bcache.c b/libblkid/src/superblocks/bcache.c 232 + index 6ab3fe9d4..28ac4b52b 100644 233 + --- a/libblkid/src/superblocks/bcache.c 234 + +++ b/libblkid/src/superblocks/bcache.c 235 + @@ -142,17 +142,19 @@ struct bcachefs_super_block { 236 + /* magic string len */ 237 + #define BCACHE_SB_MAGIC_LEN (sizeof(BCACHE_SB_MAGIC) - 1) 238 + /* super block offset */ 239 + -#define BCACHE_SB_OFF 0x1000 240 + +#define BCACHE_SB_OFF 0x1000U 241 + /* supper block offset in kB */ 242 + #define BCACHE_SB_KBOFF (BCACHE_SB_OFF >> 10) 243 + /* magic string offset within super block */ 244 + #define BCACHE_SB_MAGIC_OFF offsetof(struct bcache_super_block, magic) 245 + /* start of checksummed data within superblock */ 246 + -#define BCACHE_SB_CSUMMED_START 8 247 + +#define BCACHE_SB_CSUMMED_START 8U 248 + /* granularity of offset and length fields within superblock */ 249 + -#define BCACHEFS_SECTOR_SIZE 512 250 + +#define BCACHEFS_SECTOR_SIZE 512U 251 + +/* maximum superblock size shift */ 252 + +#define BCACHEFS_SB_MAX_SIZE_SHIFT 0x10U 253 + /* maximum superblock size */ 254 + -#define BCACHEFS_SB_MAX_SIZE 0x100000 255 + +#define BCACHEFS_SB_MAX_SIZE (1U << BCACHEFS_SB_MAX_SIZE_SHIFT) 256 + /* fields offset within super block */ 257 + #define BCACHEFS_SB_FIELDS_OFF offsetof(struct bcachefs_super_block, _start) 258 + /* tag value for members field */ 259 + @@ -311,12 +313,16 @@ static int probe_bcachefs(blkid_probe pr, const struct blkid_idmag *mag) 260 + return BLKID_PROBE_NONE; 261 + 262 + sb_size = BCACHEFS_SB_FIELDS_OFF + BYTES(bcs); 263 + - if (sb_size > ((uint64_t) BCACHEFS_SECTOR_SIZE << bcs->layout.sb_max_size_bits)) 264 + - return BLKID_PROBE_NONE; 265 + 266 + if (sb_size > BCACHEFS_SB_MAX_SIZE) 267 + return BLKID_PROBE_NONE; 268 + 269 + + if (bcs->layout.sb_max_size_bits > BCACHEFS_SB_MAX_SIZE_SHIFT) 270 + + return BLKID_PROBE_NONE; 271 + + 272 + + if (sb_size > (BCACHEFS_SECTOR_SIZE << bcs->layout.sb_max_size_bits)) 273 + + return BLKID_PROBE_NONE; 274 + + 275 + sb = blkid_probe_get_sb_buffer(pr, mag, sb_size); 276 + if (!sb) 277 + return BLKID_PROBE_NONE;
+1
pkgs/os-specific/linux/util-linux/default.nix
··· 29 30 patches = [ 31 ./rtcwake-search-PATH-for-shutdown.patch 32 ]; 33 34 # We separate some of the utilities into their own outputs. This
··· 29 30 patches = [ 31 ./rtcwake-search-PATH-for-shutdown.patch 32 + ./bcachefs-patch-set.patch 33 ]; 34 35 # We separate some of the utilities into their own outputs. This
+6 -18
pkgs/tools/filesystems/bcachefs-tools/default.nix
··· 16 , fuse3 17 , cargo 18 , rustc 19 - , coreutils 20 , rustPlatform 21 , makeWrapper 22 , fuseSupport ? false 23 }: 24 - let 25 - rev = "cfa816bf3f823a3bedfedd8e214ea929c5c755fe"; 26 - in stdenv.mkDerivation { 27 pname = "bcachefs-tools"; 28 - version = "unstable-2023-06-28"; 29 30 - src = fetchFromGitHub { 31 - owner = "koverstreet"; 32 - repo = "bcachefs-tools"; 33 - inherit rev; 34 - hash = "sha256-XgXUwyZV5N8buYTuiu1Y1ZU3uHXjZ/OZ1kbZ9d6Rt5I="; 35 - }; 36 37 nativeBuildInputs = [ 38 pkg-config ··· 70 71 makeFlags = [ 72 "PREFIX=${placeholder "out"}" 73 - "VERSION=${lib.strings.substring 0 7 rev}" 74 "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools" 75 ]; 76 77 - preCheck = lib.optionalString fuseSupport '' 78 rm tests/test_fuse.py 79 ''; 80 ··· 82 smoke-test = nixosTests.bcachefs; 83 inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti; 84 }; 85 - 86 - postFixup = '' 87 - wrapProgram $out/bin/mount.bcachefs \ 88 - --prefix PATH : ${lib.makeBinPath [ coreutils ]} 89 - ''; 90 91 enableParallelBuilding = true; 92
··· 16 , fuse3 17 , cargo 18 , rustc 19 , rustPlatform 20 , makeWrapper 21 , fuseSupport ? false 22 + , version ? lib.importJSON ./version.json 23 }: 24 + stdenv.mkDerivation { 25 pname = "bcachefs-tools"; 26 + version = "unstable-${version.date}"; 27 28 + src = fetchFromGitHub (builtins.removeAttrs version ["date"]); 29 30 nativeBuildInputs = [ 31 pkg-config ··· 63 64 makeFlags = [ 65 "PREFIX=${placeholder "out"}" 66 + "VERSION=${lib.strings.substring 0 7 version.rev}" 67 "INITRAMFS_DIR=${placeholder "out"}/etc/initramfs-tools" 68 ]; 69 70 + preCheck = lib.optionalString (!fuseSupport) '' 71 rm tests/test_fuse.py 72 ''; 73 ··· 75 smoke-test = nixosTests.bcachefs; 76 inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti; 77 }; 78 79 enableParallelBuilding = true; 80
+7
pkgs/tools/filesystems/bcachefs-tools/version.json
···
··· 1 + { 2 + "owner": "koverstreet", 3 + "repo": "bcachefs-tools", 4 + "rev": "6b175a022496572416918bd38d083120c23ba5f2", 5 + "sha256": "qC6Bq2zdO8Tj+bZbIUvcVBqvuKccqDEX3HIeOXsEloQ=", 6 + "date": "2023-09-29" 7 + }
+2 -2
pkgs/top-level/linux-kernels.nix
··· 218 219 linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix { 220 # Pinned on the last version which Kent's commits can be cleany rebased up. 221 - kernel = linux_6_4; 222 - kernelPatches = linux_6_4.kernelPatches; 223 }; 224 225 linux_hardkernel_4_14 = callPackage ../os-specific/linux/kernel/linux-hardkernel-4.14.nix {
··· 218 219 linux_testing_bcachefs = callPackage ../os-specific/linux/kernel/linux-testing-bcachefs.nix { 220 # Pinned on the last version which Kent's commits can be cleany rebased up. 221 + kernel = linux_6_5; 222 + kernelPatches = linux_6_5.kernelPatches; 223 }; 224 225 linux_hardkernel_4_14 = callPackage ../os-specific/linux/kernel/linux-hardkernel-4.14.nix {