diff --git a/0001-Unify-the-check-to-enable-btrfs-relative-path.patch b/0001-Unify-the-check-to-enable-btrfs-relative-path.patch index a201875..32f051f 100644 --- a/0001-Unify-the-check-to-enable-btrfs-relative-path.patch +++ b/0001-Unify-the-check-to-enable-btrfs-relative-path.patch @@ -98,7 +98,7 @@ Signed-off-by: Michael Chang { if (!load_cfg_f) load_cfg_f = grub_util_fopen (load_cfg, "wb"); -@@ -1670,21 +1708,13 @@ +@@ -1670,22 +1708,14 @@ #ifdef __linux__ @@ -108,6 +108,7 @@ Signed-off-by: Michael Chang { char *subvol = NULL; char *mount_path = NULL; + grub_uint64_t subvolid = 0; - char **rootdir_devices = NULL; - char *t = grub_util_path_concat (2, "/", rootdir); - char *rootdir_path = grub_canonicalize_file_name (t); @@ -117,10 +118,10 @@ Signed-off-by: Michael Chang - - if (rootdir_devices && rootdir_devices[0]) - if (grub_strcmp (rootdir_devices[0], grub_devices[0]) == 0) -- subvol = grub_util_get_btrfs_subvol (platdir, &mount_path); +- subvol = grub_util_get_btrfs_subvol (platdir, &mount_path, &subvolid); + + if (grub_strcmp (rootdir_devices[0], grub_devices[0]) == 0) -+ subvol = grub_util_get_btrfs_subvol (platdir, &mount_path); ++ subvol = grub_util_get_btrfs_subvol (platdir, &mount_path, &subvolid); if (subvol && mount_path) { diff --git a/grub2-btrfs-06-subvol-mount.patch b/grub2-btrfs-06-subvol-mount.patch index eabffd3..2be6c80 100644 --- a/grub2-btrfs-06-subvol-mount.patch +++ b/grub2-btrfs-06-subvol-mount.patch @@ -7,6 +7,10 @@ v3: * Fix executable stack on which function trampoline is constructed to support closure (nested function). The closure sematic is replaced. +v4: +* Fix btrfs subvolume for platform modules not mounting at runtime when the + default subvolume is the topmost root tree (bsc#1228124) + --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -44,6 +44,7 @@ @@ -57,7 +61,7 @@ v3: if (err) return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path); -@@ -2321,11 +2345,20 @@ +@@ -2323,11 +2347,20 @@ grub_uint64_t tree; grub_uint8_t type; grub_size_t est_size = 0; @@ -79,7 +83,7 @@ v3: if (err) { grub_btrfs_unmount (data); -@@ -2452,11 +2485,21 @@ +@@ -2454,11 +2487,21 @@ struct grub_btrfs_inode inode; grub_uint8_t type; struct grub_btrfs_key key_in; @@ -102,7 +106,7 @@ v3: if (err) { grub_btrfs_unmount (data); -@@ -2691,6 +2734,150 @@ +@@ -2693,6 +2736,150 @@ return 0; } @@ -253,7 +257,7 @@ v3: static grub_err_t get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree, grub_uint64_t objectid, grub_uint64_t offset, -@@ -2903,6 +3090,7 @@ +@@ -2905,6 +3092,7 @@ }; static grub_command_t cmd_info; @@ -261,7 +265,7 @@ v3: static grub_extcmd_t cmd_list_subvols; static char * -@@ -2966,6 +3154,9 @@ +@@ -2968,6 +3156,9 @@ cmd_info = grub_register_command("btrfs-info", grub_cmd_btrfs_info, "DEVICE", "Print BtrFS info about DEVICE."); @@ -288,18 +292,22 @@ v3: struct btrfs_ioctl_search_args { struct btrfs_ioctl_search_key key; grub_uint64_t buf[(4096 - sizeof(struct btrfs_ioctl_search_key)) -@@ -375,6 +383,109 @@ +@@ -375,6 +383,117 @@ int use_relative_path_on_btrfs = 0; +static char * -+get_btrfs_subvol (const char *path) ++get_btrfs_subvol (const char *path, grub_uint64_t *subvolid) +{ + struct btrfs_ioctl_ino_lookup_args args; + grub_uint64_t tree_id; ++ grub_uint64_t ret_id; + int fd = -1; + char *ret = NULL; + ++ if (subvolid) ++ *subvolid = 0; ++ + fd = open (path, O_RDONLY); + + if (fd < 0) @@ -312,6 +320,7 @@ v3: + goto error; + + tree_id = args.treeid; ++ ret_id = args.treeid; + + while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID) + { @@ -380,6 +389,9 @@ v3: + } + } + ++ if (subvolid) ++ *subvolid = ret_id; ++ + close (fd); + return ret; + @@ -398,7 +410,7 @@ v3: char ** grub_find_root_devices_from_mountinfo (const char *dir, char **relroot) { -@@ -516,12 +627,17 @@ +@@ -516,12 +635,17 @@ else if (grub_strcmp (entries[i].fstype, "btrfs") == 0) { ret = grub_find_root_devices_from_btrfs (dir); @@ -419,13 +431,13 @@ v3: } } else if (!retry && grub_strcmp (entries[i].fstype, "autofs") == 0) -@@ -1202,6 +1318,24 @@ +@@ -1202,6 +1326,24 @@ return grub_dev; } + +char * -+grub_util_get_btrfs_subvol (const char *path, char **mount_path) ++grub_util_get_btrfs_subvol (const char *path, char **mount_path, grub_uint64_t *subvolid) +{ + if (mount_path) + *mount_path = NULL; @@ -438,7 +450,7 @@ v3: + if (mount_path) + *mount_path = grub_strdup (grub_btrfs_mount_path); + -+ return get_btrfs_subvol (grub_btrfs_mount_path); ++ return get_btrfs_subvol (grub_btrfs_mount_path, subvolid); +} + char * @@ -446,7 +458,7 @@ v3: { --- a/util/grub-install.c +++ b/util/grub-install.c -@@ -1645,6 +1645,58 @@ +@@ -1646,6 +1646,58 @@ prefix_drive = xasprintf ("(%s)", grub_drives[0]); } @@ -457,6 +469,7 @@ v3: + { + char *subvol = NULL; + char *mount_path = NULL; ++ grub_uint64_t subvolid = 0; + char **rootdir_devices = NULL; + char *t = grub_util_path_concat (2, "/", rootdir); + char *rootdir_path = grub_canonicalize_file_name (t); @@ -466,15 +479,15 @@ v3: + + if (rootdir_devices && rootdir_devices[0]) + if (grub_strcmp (rootdir_devices[0], grub_devices[0]) == 0) -+ subvol = grub_util_get_btrfs_subvol (platdir, &mount_path); ++ subvol = grub_util_get_btrfs_subvol (platdir, &mount_path, &subvolid); + + if (subvol && mount_path) + { -+ char *def_subvol; ++ grub_uint64_t def_subvolid = 0; + -+ def_subvol = grub_util_get_btrfs_subvol (rootdir_path, NULL); ++ grub_free (grub_util_get_btrfs_subvol (rootdir_path, NULL, &def_subvolid)); + -+ if (def_subvol) ++ if (def_subvolid) + { + char *rootdir_mount_path = NULL; + if (!load_cfg_f) @@ -484,10 +497,9 @@ v3: + if (grub_strncmp (rootdir_path, mount_path, grub_strlen (rootdir_path)) == 0) + rootdir_mount_path = grub_util_path_concat (2, "/", mount_path + grub_strlen (rootdir_path)); + -+ if (grub_strcmp (subvol, def_subvol) != 0 && rootdir_mount_path) ++ if (subvolid != def_subvolid && rootdir_mount_path) + fprintf (load_cfg_f, "btrfs-mount-subvol ($root) %s %s\n", rootdir_mount_path, subvol); + free (rootdir_mount_path); -+ free (def_subvol); + } + } + @@ -513,7 +525,7 @@ v3: +#ifdef __linux__ +char * -+grub_util_get_btrfs_subvol (const char *path, char **mount_path); ++grub_util_get_btrfs_subvol (const char *path, char **mount_path, grub_uint64_t *subvolid); +#endif + /* Devmapper functions provided by getroot_devmapper.c. */ diff --git a/grub2-s390x-set-hostonly.patch b/grub2-s390x-set-hostonly.patch new file mode 100644 index 0000000..63b5679 --- /dev/null +++ b/grub2-s390x-set-hostonly.patch @@ -0,0 +1,52 @@ +diff --git a/util/s390x/zipl2grub.pl.in b/util/s390x/zipl2grub.pl.in +index f4f997100..46b902209 100644 +--- a/util/s390x/zipl2grub.pl.in ++++ b/util/s390x/zipl2grub.pl.in +@@ -15,6 +15,7 @@ my $zipldir = ""; + my $running = ""; + my $refresh = 1; # needs to default to "on" until most bugs are shaken out! + my $force = 0; ++my $hostonly = 1; + my $verbose = 0; + my $debug = 0; + my $miss = 0; +@@ -114,8 +115,13 @@ sub BootCopy($$$$) { + } + sub MkInitrd($$$) { + my( $initrd, $dir, $version) = @_; +- my @C = ( "dracut", "--hostonly", "--force"); ++ my @C = ( "dracut", "--force"); + my $uuid; ++ if ($hostonly) { ++ push @C, "--hostonly"; ++ } else { ++ push @C, "--no-hostonly"; ++ } + push @C, "--quiet" unless ($verbose > 1); + if ( exists( $fsdev{"/boot"}) ) { + chomp( $uuid = qx{grub2-probe --target=fs_uuid /boot}); +@@ -368,6 +374,24 @@ foreach ("GRUB_EMU_CONMODE", "GRUB_CONMODE") { + $C{$_} = "conmode=" . $C{$_}; + } + ++if ( !exists( $C{SUSE_S390_DRACUT_HOSTONLY}) || $C{SUSE_S390_DRACUT_HOSTONLY} eq "auto" ) { ++ # Auto-detection mode ++ # ++ # Check if the root block device of the root partition is a loop device. ++ # If yes, it is the image building system, e.g. kiwi. Then, set 'hostonly' to 0. ++ my ( $dev, $lsblk ); ++ ++ chomp( $dev = qx{grub2-probe -t device /}); ++ if ($dev) { ++ chomp( $lsblk = qx{lsblk -snrp -o NAME $dev}); ++ $hostonly = 0 if ( $lsblk =~ m{\/loop} ); ++ } ++} elsif ( $C{SUSE_S390_DRACUT_HOSTONLY} =~ m{^(no|false|0)$} ) { ++ $hostonly = 0; ++} else { ++ $hostonly = 1; ++} ++ + if ( $debug && $verbose > 2 ) { + foreach ( sort( keys( %C)) ) { + printf( "%s=\"%s\"\n", $_, $C{$_}); diff --git a/grub2.changes b/grub2.changes index add8e79..97361ea 100644 --- a/grub2.changes +++ b/grub2.changes @@ -1,3 +1,20 @@ +------------------------------------------------------------------- +Fri Aug 2 08:44:40 UTC 2024 - Michael Chang + +- Fix btrfs subvolume for platform modules not mounting at runtime when the + default subvolume is the topmost root tree (bsc#1228124) + * grub2-btrfs-06-subvol-mount.patch +- Rediff + * 0001-Unify-the-check-to-enable-btrfs-relative-path.patch + +------------------------------------------------------------------- +Fri Aug 2 02:22:21 UTC 2024 - Gary Ching-Pang Lin + +- Switch to '--no-hostonly' when creating the ZIPL initrd in the + KIWI build environment to avoid some potential issues due to the + missing modules + * grub2-s390x-set-hostonly.patch + ------------------------------------------------------------------- Fri Jul 19 09:59:15 UTC 2024 - Michael Chang diff --git a/grub2.spec b/grub2.spec index 5e9adbf..2ca9eaf 100644 --- a/grub2.spec +++ b/grub2.spec @@ -405,6 +405,7 @@ Patch214: 0007-grub-switch-to-blscfg-adapt-to-openSUSE.patch Patch215: 0008-blscfg-reading-bls-fragments-if-boot-present.patch Patch216: 0009-10_linux-Some-refinement-for-BLS.patch Patch217: 0001-net-drivers-ieee1275-ofnet-Remove-200-ms-timeout-in-.patch +Patch218: grub2-s390x-set-hostonly.patch Requires: gettext-runtime %if 0%{?suse_version} >= 1140