diff mbox

btrfs-progs: convert: Print different error message if convert partly failed.

Message ID 1433836660-1163-1-git-send-email-quwenruo@cn.fujitsu.com (mailing list archive)
State Accepted
Headers show

Commit Message

Qu Wenruo June 9, 2015, 7:57 a.m. UTC
When testing under libguestfs, btrfs-convert will never succeed to fix
chunk map, and always fails.

But in that case, it's already a mountable btrfs.
So better to info user with different error message for that case.

The root cause of it is still under investigation.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 btrfs-convert.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

David Sterba Sept. 25, 2015, 5:57 p.m. UTC | #1
On Tue, Jun 09, 2015 at 03:57:40PM +0800, Qu Wenruo wrote:
> When testing under libguestfs, btrfs-convert will never succeed to fix
> chunk map, and always fails.
> 
> But in that case, it's already a mountable btrfs.
> So better to info user with different error message for that case.
> 
> The root cause of it is still under investigation.
> 
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>

I've adjusted wording of the error message and applied, thanks. What are
the consequences of the unfinished conversion process when such
filesystem is mounted?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Qu Wenruo Sept. 26, 2015, 8:03 a.m. UTC | #2
? 2015?09?26? 01:57, David Sterba ??:
> On Tue, Jun 09, 2015 at 03:57:40PM +0800, Qu Wenruo wrote:
>> When testing under libguestfs, btrfs-convert will never succeed to fix
>> chunk map, and always fails.
>>
>> But in that case, it's already a mountable btrfs.
>> So better to info user with different error message for that case.
>>
>> The root cause of it is still under investigation.
>>
>> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
>
> I've adjusted wording of the error message and applied, thanks. What are
> the consequences of the unfinished conversion process when such
> filesystem is mounted?

The whole chunk tree will not be in system chunk but metadata chunk, 
until COW happens.

But the funny thing is, even the system chunk is empty after the 
convert, with empty bg auto remove in recent kernels, it will try to 
remove empty system chunk, and cause COW...
And magically, things will become normal again(If chunk tree only has leaf).

Quite tricky to debug why open_ctree() will fail, as libguestfs is such 
a strange environment, not good method to debug and even no way to use 
gdb...

Thanks,
Qu
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/btrfs-convert.c b/btrfs-convert.c
index 9a9d619..5606156 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2286,6 +2286,7 @@  static int do_convert(const char *devname, int datacsum, int packing, int noxatt
 {
 	int i, ret, blocks_per_node;
 	int fd = -1;
+	int is_btrfs = 0;
 	u32 blocksize;
 	u64 blocks[7];
 	u64 total_bytes;
@@ -2435,6 +2436,7 @@  static int do_convert(const char *devname, int datacsum, int packing, int noxatt
 		fprintf(stderr, "unable to migrate super block\n");
 		goto fail;
 	}
+	is_btrfs = 1;
 
 	root = open_ctree_fd(fd, devname, 0, OPEN_CTREE_WRITES);
 	if (!root) {
@@ -2455,7 +2457,11 @@  static int do_convert(const char *devname, int datacsum, int packing, int noxatt
 fail:
 	if (fd != -1)
 		close(fd);
-	fprintf(stderr, "conversion aborted.\n");
+	if (is_btrfs)
+		fprintf(stderr,
+			"some error happened, but still converted to btrfs\n");
+	else
+		fprintf(stderr, "conversion aborted\n");
 	return -1;
 }