Parche limpiador del btrfs que no ha logrado servir

This commit is contained in:
Sandino Araico Sanchez 2015-06-28 05:31:58 -05:00
parent 54e8d6e03c
commit a9de2403e4

View file

@ -0,0 +1,90 @@
Binary files btrfs-progs-v4.0.1.orig/.cmds-check.c.swp and btrfs-progs-v4.0.1/.cmds-check.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.ctree.c.swp and btrfs-progs-v4.0.1/.ctree.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.ctree.h.swp and btrfs-progs-v4.0.1/.ctree.h.swp differ
Binary files btrfs-progs-v4.0.1.orig/.disk-io.c.swp and btrfs-progs-v4.0.1/.disk-io.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.extent-cache.c.swp and btrfs-progs-v4.0.1/.extent-cache.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.extent-cache.h.swp and btrfs-progs-v4.0.1/.extent-cache.h.swp differ
Binary files btrfs-progs-v4.0.1.orig/.extent-tree.c.swp and btrfs-progs-v4.0.1/.extent-tree.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.extent_io.c.swp and btrfs-progs-v4.0.1/.extent_io.c.swp differ
Binary files btrfs-progs-v4.0.1.orig/.kerncompat.h.swp and btrfs-progs-v4.0.1/.kerncompat.h.swp differ
Binary files btrfs-progs-v4.0.1.orig/.list.h.swp and btrfs-progs-v4.0.1/.list.h.swp differ
Binary files btrfs-progs-v4.0.1.orig/.repair.h.swp and btrfs-progs-v4.0.1/.repair.h.swp differ
diff -uriN btrfs-progs-v4.0.1.orig/cmds-check.c btrfs-progs-v4.0.1/cmds-check.c
--- btrfs-progs-v4.0.1.orig/cmds-check.c 2015-05-20 08:12:44.000000000 -0500
+++ btrfs-progs-v4.0.1/cmds-check.c 2015-06-28 05:30:08.000000000 -0500
@@ -3222,11 +3222,14 @@
struct btrfs_path *path;
struct btrfs_corrupt_block *corrupt;
struct cache_extent *cache;
+ struct cache_tree corrupt_not_found;
struct btrfs_key key;
u64 offset;
int level;
int ret = 0;
+ cache_tree_init(&corrupt_not_found);
+
if (cache_tree_empty(corrupt_blocks))
return 0;
@@ -3276,6 +3279,15 @@
ret = btrfs_free_extent(trans, root, offset, root->nodesize,
0, root->root_key.objectid,
level - 1, 0);
+ fprintf(stderr, "btrfs_free_extent - ret = %d bytenr = %llu num_bytes = %llu parent = %d root_objectid = %llu owner = %d offset = %d\n", ret, offset, root->nodesize,
+ 0, root->root_key.objectid,
+ level - 1, 0);
+ /* Add unfound cache extents to remove list */
+ if ( ret == -EIO ) {
+ fprintf(stderr, "Extent (%llu, %llu, %llu) not found. Added to remove list.\n",
+ cache->objectid, cache->start, cache->size);
+ insert_cache_extent(&corrupt_not_found, cache);
+ }
cache = next_cache_extent(cache);
}
@@ -3293,6 +3305,17 @@
btrfs_release_path(path);
cache = next_cache_extent(cache);
}
+
+ /* Remove not found corrupt cache extents */
+ cache = first_cache_extent(&corrupt_not_found);
+ while (cache) {
+ fprintf(stderr, "Removing not found corrupt extent (%llu, %llu, %llu).\n",
+ cache->objectid, cache->start, cache->size);
+ remove_cache_extent(&corrupt_not_found, cache);
+ cache = next_cache_extent(cache);
+ }
+ free_extent_cache_tree(&corrupt_not_found);
+
out:
btrfs_commit_transaction(trans, root);
out_free_path:
diff -uriN btrfs-progs-v4.0.1.orig/ctree.c btrfs-progs-v4.0.1/ctree.c
--- btrfs-progs-v4.0.1.orig/ctree.c 2015-06-19 03:43:12.000000000 -0500
+++ btrfs-progs-v4.0.1/ctree.c 2015-06-21 05:15:35.000000000 -0500
@@ -2588,14 +2588,16 @@
int ret = 0;
nritems = btrfs_header_nritems(parent);
- if (slot != nritems -1) {
- memmove_extent_buffer(parent,
- btrfs_node_key_ptr_offset(slot),
- btrfs_node_key_ptr_offset(slot + 1),
- sizeof(struct btrfs_key_ptr) *
- (nritems - slot - 1));
+ if (nritems > 0) {
+ if (slot < nritems -1) {
+ memmove_extent_buffer(parent,
+ btrfs_node_key_ptr_offset(slot),
+ btrfs_node_key_ptr_offset(slot + 1),
+ sizeof(struct btrfs_key_ptr) *
+ (nritems - slot - 1));
+ }
+ nritems--;
}
- nritems--;
btrfs_set_header_nritems(parent, nritems);
if (nritems == 0 && parent == root->node) {
BUG_ON(btrfs_header_level(root->node) != 1);