Skip to contentSkip to conversation

Btrfs: create the uuid tree on remount rw

PATCH In review Josef Bacik 2 participants 2 messages Sep 21, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Btrfs: create the uuid tree on remount rw

Users have been complaining of the uuid tree stuff warning that there is no uuid root when trying to do snapshot operations. This is because if you mount -o ro we will not create the uuid tree. But then if you mount -o rw,remount we will still not create it and then any subsequent snapshot/subvol operations you try to do will fail gloriously. Fix this by creating the uuid_root on remount rw if it was not already there. Thanks,

---
 fs/btrfs/super.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
fs/btrfs/super.c +10 -0
index 6ab0df5..05cfd79 100644
@@ -1383,6 +1383,16 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
 			pr_warn("btrfs: failed to resume dev_replace\n");
 			goto restore;
 		}
+
+		if (!fs_info->uuid_root) {
+			pr_info("btrfs: creating UUID tree\n");
+			ret = btrfs_create_uuid_tree(fs_info);
+			if (ret) {
+				pr_warn("btrfs: failed to create the uuid "
+					"%d\n", ret);
+				goto restore;
+			}
+		}
 		sb->s_flags &= ~MS_RDONLY;
 	}
 out:
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 17 lines · Josef Bacik

Users have been complaining of the uuid tree stuff warning that there is no uuid root when trying to do snapshot operations. This is because if you mount -o ro we will not create the uuid tree. But then if you mount -o rw,remount we will still not create it and then any subsequent snapshot/subvol operations you try to do will fail gloriously. Fix this by creating the uuid_root on remount rw if it was not already there. Thanks,

---
  fs/btrfs/super.c | 10 ++++++++++
  1 file changed, 10 insertions(+)
fs/btrfs/super.c +0 -0
index 6ab0df5..05cfd79 100644

fs/btrfs/super.c static int btrfs_remount(struct super_block *sb, int *flags, char *data) · line 1392

Quoted 10 lines
fs/btrfs/super.c +7 -0
@@ -1383,6 +1383,16 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
  			pr_warn("btrfs: failed to resume dev_replace\n");
  			goto restore;
  		}
+
+		if (!fs_info->uuid_root) {
+			pr_info("btrfs: creating UUID tree\n");
+			ret = btrfs_create_uuid_tree(fs_info);
+			if (ret) {
+				pr_warn("btrfs: failed to create the uuid "
+					"%d\n", ret);

pr_warn("btrfs: failed to create the uuid tree "

                                          ^^^^

And I'm just wondering what would happen if you remount -o ro,remount (or umount -rf or shutdown on a busy filesystem which also causes a ro remount) while the uuid tree create/check thread is running. There is no code to stop the thread. There is only code for the regulat umount case that waits for this thread to complete. But that's not related to your patch. I'll put it on my todo list.

Quoted 7 lines
fs/btrfs/super.c +3 -0
+				goto restore;
+			}
+		}
  		sb->s_flags &= ~MS_RDONLY;
  	}
  out: