Skip to contentSkip to conversation

full btrfs partition, became unmountable (+ a solution that thankfully worked for me)

PATCH Cyrille Chépélov 2 participants 5 messages Jan 25, 2011 – Jan 27, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hello all,

Last Friday, the /var and /home partition on one of my appliances became full. This should normally not be much of a problem, except that after the incident, I had been unable to mount the partition back again.

The appliance runs 2.6.32 as provided by Debian during the last two months.
The rescue computer runs 2.6.37; both exhibited the same behaviour at
mount: an infinite loop-and-abort cycle (I unfortunately did not write down the exact messages, but in a nutshell, there was not enough free space to replay the log, so it aborted).

After pulling the SD card (yes) to break the loop, I ended up with a corrupt file system. Any attempt to mount, debug or fsck (using btrfs-tools 0.19+20100601 as shipped by Debian, or compiled from git 1b444cd2e6ab8dcafdd) aborted with the following message:

    btrfs-debug-tree: disk-io.c:741: open_ctree_fd: Assertion `!(!

tree_root->node)' failed.

After much scavenging on the disk image, I finally managed to recover, using the (dirty) patch attached here. Since apparently other people had similar issues, I'm posting it in the hope it might be useful.

-- Cyrille

PS: Chris, if btrfs-images of "before" and "after" my butcher fix would be useful to you, just let me know.

btrfsck.c +33 -1
index 63e44d1..1e6bc32 100644
@@ -2823,13 +2823,17 @@ int main(int ac, char **av)
 	u64 bytenr = 0;
 	int ret;
 	int num;
+	int emergency_super = 0;
 
 	while(1) {
 		int c;
-		c = getopt(ac, av, "s:");
+		c = getopt(ac, av, "es:");
 		if (c < 0)
 			break;
 		switch(c) {
+			case 'e':
+				emergency_super = 1;
+				break;
 			case 's':
 				num = atol(optarg);
 				bytenr = btrfs_sb_offset(num);
@@ -2861,6 +2865,12 @@ int main(int ac, char **av)
 	if (root == NULL)
 		return 1;
 
+	if (root->fs_info->emergency_root_tree && (!emergency_super)) {
+		printf("DANGEROUS: had to use a synthetic super. Please run with '-e' flag if you know why you do it.\n");
+		printf("      ... and have perfect backups.\n");
+		return 1;
+	}
+
 	ret = check_extents(root);
 	if (ret)
 		goto out;
@@ -2869,6 +2879,27 @@ int main(int ac, char **av)
 		goto out;
 
 	ret = check_root_refs(root, &root_cache);
+	if (ret)
+		goto out;
+
+
+	if (root->fs_info->emergency_root_tree) {
+		printf("DANGEROUS: had to use a scavenged root. Apparently could figure out the primary trees ?\n" 
+		       "   Now writing supers, knock wood.\n");
+		free_root_recs(&root_cache);
+		close_ctree(root);
+		
+		cache_tree_init(&root_cache);
+		root = open_ctree(av[optind], bytenr, 1 /* WRITES! */);
+
+		ret = write_all_supers(root);
+		if (ret) {
+			printf("Error writing superblocks.\n");		
+			goto out;			
+		}
+		printf("Wrote back superblocks.\n");
+	}
+
 out:
 	free_root_recs(&root_cache);
 	close_ctree(root);
@@ -2897,6 +2928,7 @@ out:
 	printf("file data blocks allocated: %llu\n referenced %llu\n",
 		(unsigned long long)data_bytes_allocated,
 		(unsigned long long)data_bytes_referenced);
+
 	printf("%s\n", BTRFS_BUILD_VERSION);
 	return ret;
 }
ctree.h +1 -0
index b79e238..7439d87 100644
@@ -728,6 +728,7 @@ struct btrfs_fs_info {
 	struct list_head space_info;
 	int system_allocs;
 	int readonly;
+	int emergency_root_tree;
 };
 
 /*
disk-io.c +192 -17

279 lines not on this page · raw message

disk-io.h +1 -0
index 49e5692..0af98b4 100644
@@ -64,6 +64,7 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid);
 int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
 int wait_on_tree_block_writeback(struct btrfs_root *root,
 				 struct extent_buffer *buf);
+int write_all_supers(struct btrfs_root *root);
 u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len);
 void btrfs_csum_final(u32 crc, char *result);
 
#1 lore raw

Not sure where you pulled your source from but a fresh checkout of eith= er master or next of git.kernel.org/pub/scm/linux/kernel/git/mason/btrf= s-progs-unstable.git does not compile properly.
They both fail with=20

cc1: warnings being treated as errors
disk-io.c: In function =91btrfs_read_dev_super=92:
disk-io.c:937: error: format =91%lu=92 expects type =91long unsigned in= t=92, but argument 4 has type =91unsigned int=92 disk-io.c:957: error: implicit declaration of function =91uuid_unparse=92

am I patching/compiling from the wrong source or is there something I a= m missing?

Quoted 3 lines · On Jan 25, 2011, at 1:46 PM, Cyrille Ch=E9p=E9lov wrote:

Hello all,
=20
Last Friday, the /var and /home partition on one of my appliances bec=

ame

Quoted 1 line

full. This should normally not be much of a problem, except that afte=

r

Quoted 6 lines

the incident, I had been unable to mount the partition back again. =20
The appliance runs 2.6.32 as provided by Debian during the last two months.=20
The rescue computer runs 2.6.37; both exhibited the same behaviour at
mount: an infinite loop-and-abort cycle (I unfortunately did not writ=

e

Quoted 11 lines

down the exact messages, but in a nutshell, there was not enough free space to replay the log, so it aborted).
=20
After pulling the SD card (yes) to break the loop, I ended up with a corrupt file system. Any attempt to mount, debug or fsck (using btrfs-tools 0.19+20100601 as shipped by Debian, or compiled from git 1b444cd2e6ab8dcafdd) aborted with the following message:

   btrfs-debug-tree: disk-io.c:741: open_ctree_fd: Assertion `!(!

tree_root->node)' failed.
=20
After much scavenging on the disk image, I finally managed to recover=

,

Quoted 1 line

using the (dirty) patch attached here. Since apparently other people =

had

Quoted 5 lines

similar issues, I'm posting it in the hope it might be useful. =20
-- Cyrille
=20
PS: Chris, if btrfs-images of "before" and "after" my butcher fix wou=

ld

Quoted 2 lines

be useful to you, just let me know.=20
<scavenge.patch>

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 9 lines · Shawn Stricker

Not sure where you pulled your source from but a fresh checkout of either master or next of git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git does not compile properly. They both fail with

cc1: warnings being treated as errors
disk-io.c: In function ‘btrfs_read_dev_super’:
disk-io.c:937: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ disk-io.c:957: error: implicit declaration of function ‘uuid_unparse’

am I patching/compiling from the wrong source or is there something I am missing?

uh, I had been compiling with CFLAGS=-g, where the makefile specifies "-O2 -Werror"

-Werror causes warnings to be treated as errors, which is a good thing in a way (makes sure stuff as this gets caught :) )

fixes are:
* line 937 (patched), should be %llu instead of %lu
* line 957, there should be a prototype for uuid_unparse(), most
certainly by including <uuid/uuid.h>

please try this patch instead.

Thanks for the feedback!

-- Cyrille

Quoted 26 lines · Cyrille Chépélov
Quoted 25 lines

Hello all,

Last Friday, the /var and /home partition on one of my appliances became full. This should normally not be much of a problem, except that after the incident, I had been unable to mount the partition back again.

The appliance runs 2.6.32 as provided by Debian during the last two months.
The rescue computer runs 2.6.37; both exhibited the same behaviour at
mount: an infinite loop-and-abort cycle (I unfortunately did not write down the exact messages, but in a nutshell, there was not enough free space to replay the log, so it aborted).

After pulling the SD card (yes) to break the loop, I ended up with a corrupt file system. Any attempt to mount, debug or fsck (using btrfs-tools 0.19+20100601 as shipped by Debian, or compiled from git 1b444cd2e6ab8dcafdd) aborted with the following message:

   btrfs-debug-tree: disk-io.c:741: open_ctree_fd: Assertion `!(!

tree_root->node)' failed.

After much scavenging on the disk image, I finally managed to recover, using the (dirty) patch attached here. Since apparently other people had similar issues, I'm posting it in the hope it might be useful.

Quoted 6 lines
Quoted 5 lines

-- Cyrille

PS: Chris, if btrfs-images of "before" and "after" my butcher fix would be useful to you, just let me know.
<scavenge.patch>

btrfsck.c +33 -1
index 63e44d1..1e6bc32 100644
@@ -2823,13 +2823,17 @@ int main(int ac, char **av)
 	u64 bytenr = 0;
 	int ret;
 	int num;
+	int emergency_super = 0;
 
 	while(1) {
 		int c;
-		c = getopt(ac, av, "s:");
+		c = getopt(ac, av, "es:");
 		if (c < 0)
 			break;
 		switch(c) {
+			case 'e':
+				emergency_super = 1;
+				break;
 			case 's':
 				num = atol(optarg);
 				bytenr = btrfs_sb_offset(num);
@@ -2861,6 +2865,12 @@ int main(int ac, char **av)
 	if (root == NULL)
 		return 1;
 
+	if (root->fs_info->emergency_root_tree && (!emergency_super)) {
+		printf("DANGEROUS: had to use a synthetic super. Please run with '-e' flag if you know why you do it.\n");
+		printf("      ... and have perfect backups.\n");
+		return 1;
+	}
+
 	ret = check_extents(root);
 	if (ret)
 		goto out;
@@ -2869,6 +2879,27 @@ int main(int ac, char **av)
 		goto out;
 
 	ret = check_root_refs(root, &root_cache);
+	if (ret)
+		goto out;
+
+
+	if (root->fs_info->emergency_root_tree) {
+		printf("DANGEROUS: had to use a scavenged root. Apparently could figure out the primary trees ?\n" 
+		       "   Now writing supers, knock wood.\n");
+		free_root_recs(&root_cache);
+		close_ctree(root);
+		
+		cache_tree_init(&root_cache);
+		root = open_ctree(av[optind], bytenr, 1 /* WRITES! */);
+
+		ret = write_all_supers(root);
+		if (ret) {
+			printf("Error writing superblocks.\n");		
+			goto out;			
+		}
+		printf("Wrote back superblocks.\n");
+	}
+
 out:
 	free_root_recs(&root_cache);
 	close_ctree(root);
@@ -2897,6 +2928,7 @@ out:
 	printf("file data blocks allocated: %llu\n referenced %llu\n",
 		(unsigned long long)data_bytes_allocated,
 		(unsigned long long)data_bytes_referenced);
+
 	printf("%s\n", BTRFS_BUILD_VERSION);
 	return ret;
 }
ctree.h +1 -0
index b79e238..7439d87 100644
@@ -728,6 +728,7 @@ struct btrfs_fs_info {
 	struct list_head space_info;
 	int system_allocs;
 	int readonly;
+	int emergency_root_tree;
 };
 
 /*
disk-io.c +193 -17

286 lines not on this page · raw message

disk-io.h +1 -0
index 49e5692..0af98b4 100644
@@ -64,6 +64,7 @@ int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid);
 int btrfs_set_buffer_uptodate(struct extent_buffer *buf);
 int wait_on_tree_block_writeback(struct btrfs_root *root,
 				 struct extent_buffer *buf);
+int write_all_supers(struct btrfs_root *root);
 u32 btrfs_csum_data(struct btrfs_root *root, char *data, u32 seed, size_t len);
 void btrfs_csum_final(u32 crc, char *result);
 
#3 lore raw

any chance of getting a little more informative output?
I started the command at about 2250 Eastern and now at 0117 Eastern the command is still running and all of the attached output happened in the first few minutes (under 5).

btrfsck /dev/sde
trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 8679965255889070385
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 11385464139938791651
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9270412280288921994
trying potential super #0 at bytenr 65536 
super #0 at bytenr 65536 has better generation 2155 than 0, using that
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 7739426643357674384
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 15592201610856999042

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 13794433748072589868
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 6338804170709571794
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 1827607198315921929
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 1254821329273892037
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 5355923006792833603
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 15445565961457297964
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 3079817357236378973
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 2007935378006179730
trying potential super #0 at bytenr 65536 
    invalid magic
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 5729257636792198197
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9602773462471183673

trying potential super #0 at bytenr 65536
misplaced block thinks it's at 327680
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944

    misplaced block thinks it's at 18446744073709551615

trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944

    misplaced block thinks it's at 4313900536667142911

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 1142399309793345613
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 6887355887353813266
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 10874904992214108498
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 8679965255889070385
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 16378195527537296748
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9378314511156802577

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 129195 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 129195 than 129195, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 129195 than 129195, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 18202071404685
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 3859474551985562464
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 1690337285292802040
failed to read /dev/sr0
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 58309515406157858
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 14974415773995368456

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864

    misplaced block thinks it's at 7579404676876747853

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864

    misplaced block thinks it's at 4478649175259584457

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 8679965255889070385
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 11385464139938791651
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9270412280288921994
trying potential super #0 at bytenr 65536 
super #0 at bytenr 65536 has better generation 2155 than 0, using that
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 7739426643357674384
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 15592201610856999042

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 13794433748072589868
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 6338804170709571794
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 1827607198315921929
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 1254821329273892037
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 5355923006792833603
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 15445565961457297964
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 3079817357236378973
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 2007935378006179730
trying potential super #0 at bytenr 65536 
    invalid magic
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 5729257636792198197
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9602773462471183673

trying potential super #0 at bytenr 65536
misplaced block thinks it's at 327680
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944

    misplaced block thinks it's at 18446744073709551615

trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
misplaced block thinks it's at 0
trying potential super #2 at bytenr 274877906944

    misplaced block thinks it's at 4313900536667142911

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 1142399309793345613
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 6887355887353813266
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 10874904992214108498
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 8679965255889070385
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 16378195527537296748
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 9378314511156802577

trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 129195 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 129195 than 129195, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 129195 than 129195, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
trying potential super #0 at bytenr 65536

    misplaced block thinks it's at 18202071404685
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 3859474551985562464
trying potential super #2 at bytenr 274877906944 
    misplaced block thinks it's at 1690337285292802040
failed to read /dev/sr0
trying potential super #0 at bytenr 65536 
    misplaced block thinks it's at 58309515406157858
trying potential super #1 at bytenr 67108864 
    misplaced block thinks it's at 14974415773995368456

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864

    misplaced block thinks it's at 7579404676876747853

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864

    misplaced block thinks it's at 4478649175259584457

trying potential super #2 at bytenr 274877906944
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
misplaced block thinks it's at 0
trying potential super #1 at bytenr 67108864
got only 0 bytes instead of 2859
trying potential super #0 at bytenr 65536
super #0 at bytenr 65536 has better generation 134838 than 0, using that trying potential super #1 at bytenr 67108864
super #1 at bytenr 67108864 has same generation 134838 than 134838, skipping
warning: super #1 at bytenr 67108864 has different contents!
trying potential super #2 at bytenr 274877906944
super #2 at bytenr 274877906944 has same generation 134838 than 134838, skipping
warning: super #2 at bytenr 274877906944 has different contents!
parent transid verify failed on 12608758878208 wanted 134838 found 134835 parent transid verify failed on 12608758878208 wanted 134838 found 134835 *** did not find a root, about to abort ***
*** will attempt to find useful trees before bailing out anyway: ***

     found valid header at 131072(+65536) -- gen=134834 owner=3 nritems=33 level=1  ... new best gen for ObjectID 3  at 131072
     found valid header at 1118208(+835584) -- gen=1 owner=1 nritems=4 level=0  ... new best gen for ObjectID 1  at 1118208
     found valid header at 1122304(+4096) -- gen=1 owner=2 nritems=12 level=0  ... new best gen for ObjectID 2  at 1122304
     found valid header at 1130496(+4096) -- gen=1 owner=4 nritems=1 level=0  ... new best gen for ObjectID 4  at 1130496
     found valid header at 1134592(+4096) -- gen=1 owner=5 nritems=0 level=0  ... new best gen for ObjectID 5  at 1134592
     found valid header at 1138688(+4096) -- gen=1 owner=7 nritems=0 level=0  ... new best gen for ObjectID 7  at 1138688
Quoted 62 lines · Cyrille Chépélov
Quoted 9 lines · Shawn Stricker

Not sure where you pulled your source from but a fresh checkout of either master or next of git.kernel.org/pub/scm/linux/kernel/git/mason/btrfs-progs-unstable.git does not compile properly. They both fail with

cc1: warnings being treated as errors
disk-io.c: In function ‘btrfs_read_dev_super’:
disk-io.c:937: error: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ disk-io.c:957: error: implicit declaration of function ‘uuid_unparse’

am I patching/compiling from the wrong source or is there something I am missing?

uh, I had been compiling with CFLAGS=-g, where the makefile specifies "-O2 -Werror"

-Werror causes warnings to be treated as errors, which is a good thing in a way (makes sure stuff as this gets caught :) )

fixes are:
* line 937 (patched), should be %llu instead of %lu
* line 957, there should be a prototype for uuid_unparse(), most
certainly by including <uuid/uuid.h>

please try this patch instead.

Thanks for the feedback!

-- Cyrille

Quoted 26 lines · Cyrille Chépélov
Quoted 25 lines

Hello all,

Last Friday, the /var and /home partition on one of my appliances became full. This should normally not be much of a problem, except that after the incident, I had been unable to mount the partition back again.

The appliance runs 2.6.32 as provided by Debian during the last two months.
The rescue computer runs 2.6.37; both exhibited the same behaviour at
mount: an infinite loop-and-abort cycle (I unfortunately did not write down the exact messages, but in a nutshell, there was not enough free space to replay the log, so it aborted).

After pulling the SD card (yes) to break the loop, I ended up with a corrupt file system. Any attempt to mount, debug or fsck (using btrfs-tools 0.19+20100601 as shipped by Debian, or compiled from git 1b444cd2e6ab8dcafdd) aborted with the following message:
btrfs-debug-tree: disk-io.c:741: open_ctree_fd: Assertion `!(!
tree_root->node)' failed.

After much scavenging on the disk image, I finally managed to recover, using the (dirty) patch attached here. Since apparently other people had similar issues, I'm posting it in the hope it might be useful.

Quoted 6 lines
Quoted 5 lines

-- Cyrille

PS: Chris, if btrfs-images of "before" and "after" my butcher fix would be useful to you, just let me know.
<scavenge.patch>

<scavenge-2.patch>

#4 lore raw

Hello Shawn,

it's now performing a sequential read of the volume, which will probabl= y
take significantly more time for you than for me (where I was dealing with an image of a 16GB SD card, stored on a recent mechanical SATA disk).

I'm a bit confused by what happens while reading the "potential supers"= =2E
At first the blocks appear valid, then they are all "misplaced" (meanin= g
the bytenr field !=3D the bytenr from which the block has been read, IO= W
the block is most probably not part of btrfs structures, from what I understand). From the output before the "will attempt to find useful trees" messages, it seems btrfsck is now doing a sequential read not just of /dev/sde, but also every single block device ?

disk-io.c: try_emergency_tree_fixup() is probably now a bit too silent for your use case at the moment. You might want to uncomment the commented out fprintf there; this will make it very verbose (an extra line per structure block) but will provide clues as to where on disk is it working.

-- Cyrille

Le jeudi 27 janvier 2011 =C3=A0 01:18 -0500, Shawn Stricker a =C3=A9cri= t :

Quoted 2 lines

any chance of getting a little more informative output?
I started the command at about 2250 Eastern and now at 0117 Eastern t=

he command is still running and all of the attached output happened in = the first few minutes (under 5).

Quoted 3 lines · On Jan 26, 2011, at 2:46 AM, Cyrille Ch=C3=A9p=C3=A9lov wrote:

=20

Quoted 1 line

Le mardi 25 janvier 2011 =C3=A0 23:38 -0500, Shawn Stricker a =C3=A9=

crit :

Quoted 1 line
Quoted 1 line
Quoted 1 line

Not sure where you pulled your source from but a fresh checkout of=

either master or next of git.kernel.org/pub/scm/linux/kernel/git/mason=
/btrfs-progs-unstable.git does not compile properly.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

They both fail with=20
=20
cc1: warnings being treated as errors
disk-io.c: In function =E2=80=98btrfs_read_dev_super=E2=80=99:
disk-io.c:937: error: format =E2=80=98%lu=E2=80=99 expects type =E2=

=80=98long unsigned int=E2=80=99, but argument 4 has type =E2=80=98unsi= gned int=E2=80=99

Quoted 1 line
Quoted 1 line
Quoted 1 line

disk-io.c:957: error: implicit declaration of function =E2=80=98uu=

id_unparse=E2=80=99

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

=20
am I patching/compiling from the wrong source or is there somethin=

g I am missing?

Quoted 2 lines
Quoted 2 lines

=20
uh, I had been compiling with CFLAGS=3D-g, where the makefile speci=

fies

Quoted 3 lines
Quoted 3 lines

"-O2 -Werror"
=20
-Werror causes warnings to be treated as errors, which is a good th=

ing

Quoted 13 lines
Quoted 13 lines

in a way (makes sure stuff as this gets caught :) )
=20
fixes are:
* line 937 (patched), should be %llu instead of %lu
* line 957, there should be a prototype for uuid_unparse(), most
certainly by including <uuid/uuid.h>
=20
please try this patch instead.
=20
Thanks for the feedback!
=20
-- Cyrille
=20

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines · On Jan 25, 2011, at 1:46 PM, Cyrille Ch=C3=A9p=C3=A9lov wrote:

=20

Quoted 3 lines

Hello all,
=20
Last Friday, the /var and /home partition on one of my appliances=

became

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

full. This should normally not be much of a problem, except that =

after

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the incident, I had been unable to mount the partition back again=

=2E

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

=20
The appliance runs 2.6.32 as provided by Debian during the last t=

wo

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

months.=20
The rescue computer runs 2.6.37; both exhibited the same behaviou=

r at

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

mount: an infinite loop-and-abort cycle (I unfortunately did not =

write

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

down the exact messages, but in a nutshell, there was not enough =

free

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

space to replay the log, so it aborted).
=20
After pulling the SD card (yes) to break the loop, I ended up wit=

h a

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

corrupt file system. Any attempt to mount, debug or fsck (using btrfs-tools 0.19+20100601 as shipped by Debian, or compiled from =

git

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

1b444cd2e6ab8dcafdd) aborted with the following message:
btrfs-debug-tree: disk-io.c:741: open_ctree_fd: Assertion `!(!
tree_root->node)' failed.
=20
After much scavenging on the disk image, I finally managed to rec=

over,

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

using the (dirty) patch attached here. Since apparently other peo=

ple had

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

similar issues, I'm posting it in the hope it might be useful. =20
-- Cyrille
=20
PS: Chris, if btrfs-images of "before" and "after" my butcher fix=

would

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

be useful to you, just let me know.=20
<scavenge.patch>

=20

=20
<scavenge-2.patch>

=20

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html