Blame SOURCES/0095-Fallback-to-old-subvol-name-scheme-to-support-old-sn.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Andrei Borzenkov <arvidjaar@gmail.com>
8631a2
Date: Tue, 21 Jun 2016 16:44:17 +0000
8631a2
Subject: [PATCH] Fallback to old subvol name scheme to support old snapshot
8631a2
 config
8631a2
8631a2
Ref: bsc#953538
8631a2
---
8631a2
 grub-core/fs/btrfs.c | 32 +++++++++++++++++++++++++++++++-
8631a2
 1 file changed, 31 insertions(+), 1 deletion(-)
8631a2
8631a2
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
8631a2
index 2e36ac47e8a..4a31d39ee74 100644
8631a2
--- a/grub-core/fs/btrfs.c
8631a2
+++ b/grub-core/fs/btrfs.c
8631a2
@@ -924,11 +924,41 @@ lookup_root_by_name(struct grub_btrfs_data *data, const char *path)
8631a2
   return GRUB_ERR_NONE;
8631a2
 }
8631a2
 
8631a2
+static grub_err_t
8631a2
+lookup_root_by_name_fallback(struct grub_btrfs_data *data, const char *path)
8631a2
+{
8631a2
+  grub_err_t err;
8631a2
+  grub_uint64_t tree = 0;
8631a2
+  grub_uint8_t type;
8631a2
+  struct grub_btrfs_key key;
8631a2
+
8631a2
+  err = find_path (data, path, &key, &tree, &type);
8631a2
+  if (err)
8631a2
+      return grub_error(GRUB_ERR_FILE_NOT_FOUND, "couldn't locate %s\n", path);
8631a2
+
8631a2
+  if (key.object_id != grub_cpu_to_le64_compile_time (GRUB_BTRFS_OBJECT_ID_CHUNK) || tree == 0)
8631a2
+    return grub_error(GRUB_ERR_BAD_FILE_TYPE, "%s: not a subvolume\n", path);
8631a2
+
8631a2
+  data->fs_tree = tree;
8631a2
+  return GRUB_ERR_NONE;
8631a2
+}
8631a2
+
8631a2
 static grub_err_t
8631a2
 btrfs_handle_subvol(struct grub_btrfs_data *data __attribute__ ((unused)))
8631a2
 {
8631a2
   if (btrfs_default_subvol)
8631a2
-    return lookup_root_by_name(data, btrfs_default_subvol);
8631a2
+    {
8631a2
+      grub_err_t err;
8631a2
+      err = lookup_root_by_name(data, btrfs_default_subvol);
8631a2
+
8631a2
+      /* Fallback to old schemes */
8631a2
+      if (err == GRUB_ERR_FILE_NOT_FOUND)
8631a2
+	{
8631a2
+	  err = GRUB_ERR_NONE;
8631a2
+	  return lookup_root_by_name_fallback(data, btrfs_default_subvol);
8631a2
+	}
8631a2
+      return err;
8631a2
+    }
8631a2
 
8631a2
   if (btrfs_default_subvolid)
8631a2
     return lookup_root_by_id(data, btrfs_default_subvolid);