Skip to contentSkip to conversation

btrfs-convert, ext2_copy_inodes: print inode number on error

PATCH New Dominique Martinet 1 participant 1 message Jun 28, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-convert, ext2_copy_inodes: print inode number on error

if ext2_copy_inodes fails on ext2_copy_single_inode on a specific inode, there is no message whatsoever to help identify what caused the problem.

Printing the inode number at least makes it possible to look it up (debugfs, stat <inode_num> or ncheck <inode_num>) and investigate what went wrong
---
Had an error on btrfs-convert and was a bit clueless what happened when the only error was the following:

```
ERROR: error during copy_inodes -95210]
WARNING: an error occurred during conversion, filesystem is partially created but not finalized and not mountable
```

It turns out the '210]' part of the line is leftover from the progress indicator (I was wondering what the hell is that errno?!), and it always happened on the same inode so I just had to delete it to get btrfs-convert to succeed.

Turns out that was an old ext4 cryptfs test laying around that I have no need for... Now I know that it'll be easy to make a reproducer smaller than 300GB so also possible to figure an even better error message (or interactively offer to skip?) but for now at least this simple message will help a lot!

Cheers,

 convert/source-ext2.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
convert/source-ext2.c +4 -1
index f248249f..ba65c9f9 100644
@@ -827,8 +827,11 @@ static int ext2_copy_inodes(struct btrfs_convert_context *cctx,
 		pthread_mutex_lock(&p->mutex);
 		p->cur_copy_inodes++;
 		pthread_mutex_unlock(&p->mutex);
-		if (ret)
+		if (ret) {
+			fprintf(stderr, "ext2_copy_single_inode failed on ino %u: %d\n",
+				ext2_ino, ret);
 			return ret;
+		}
 		/*
 		 * blocks_used is the number of new tree blocks allocated in
 		 * current transaction.
Signature · 1 line
2.26.2