summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2018-06-18 18:15:12 +0200
committerDavid Sterba <dsterba@suse.com>2018-08-07 11:18:54 +0200
commita8985f549cb897e28999bf3d8cdac78cc2d1555e (patch)
treeb2379f578e535c120a78bfe88754fa140e3df890
parent7faaca0d9f78f7162ae603231f693dd8e1af2a41 (diff)
btrfs-progs: btrfstune: allow to continue uuid change
When the 'btrfsune -u' command is interrupted, the final filesystem fsid is not written to the superblock and it cannot be mounted. Too bad that 'btrfstune' cannot continue to finish the UUID change as it should. This patch fixes that and passes the relaxed flags for superblock and only warns when it detects the fsid mismatch. As this is something that should be noted in case it would be needed for further debugging, it's not just silent. Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--btrfstune.c9
-rw-r--r--disk-io.c11
2 files changed, 13 insertions, 7 deletions
diff --git a/btrfstune.c b/btrfstune.c
index 889b931c..eb13b7be 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -474,7 +474,8 @@ int main(int argc, char *argv[])
return 1;
}
- ret = check_mounted_where(fd, device, NULL, 0, NULL, SBREAD_DEFAULT);
+ ret = check_mounted_where(fd, device, NULL, 0, NULL,
+ SBREAD_IGNORE_FSID_MISMATCH);
if (ret < 0) {
error("could not check mount status of %s: %s", device,
strerror(-ret));
@@ -521,9 +522,9 @@ int main(int argc, char *argv[])
if (random_fsid || new_fsid_str) {
if (!force) {
warning(
- "it's highly recommended to run 'btrfs check' before this operation");
- warning(
- "also canceling running UUID change progress may cause corruption");
+"it's recommended to run 'btrfs check --readonly' before this operation.\n"
+"\tThe whole operation must finish before the filesystem can be mounted again.\n"
+"\tIf cancelled or interrupted, run 'btrfstune -u' to restart.");
ret = ask_user("We are going to change UUID, are your sure?");
if (!ret) {
fprintf(stderr, "UUID change canceled\n");
diff --git a/disk-io.c b/disk-io.c
index 26e4f6e9..ca2fc383 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1383,9 +1383,14 @@ static int check_super(struct btrfs_super_block *sb, unsigned sbflags)
uuid_unparse(sb->fsid, fsid);
uuid_unparse(sb->dev_item.fsid, dev_fsid);
- error("dev_item UUID does not match fsid: %s != %s",
- dev_fsid, fsid);
- goto error_out;
+ if (sbflags & SBREAD_IGNORE_FSID_MISMATCH) {
+ warning("ignored: dev_item fsid mismatch: %s != %s",
+ dev_fsid, fsid);
+ } else {
+ error("dev_item UUID does not match fsid: %s != %s",
+ dev_fsid, fsid);
+ goto error_out;
+ }
}
/*