diff options
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r-- | fs/btrfs/tree-log.c | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index b1c2921f5bef..3a72a1b6c247 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -829,7 +829,7 @@ conflict_again: | |||
829 | */ | 829 | */ |
830 | ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); | 830 | ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); |
831 | ptr_end = ptr + btrfs_item_size_nr(leaf, path->slots[0]); | 831 | ptr_end = ptr + btrfs_item_size_nr(leaf, path->slots[0]); |
832 | while(ptr < ptr_end) { | 832 | while (ptr < ptr_end) { |
833 | victim_ref = (struct btrfs_inode_ref *)ptr; | 833 | victim_ref = (struct btrfs_inode_ref *)ptr; |
834 | victim_name_len = btrfs_inode_ref_name_len(leaf, | 834 | victim_name_len = btrfs_inode_ref_name_len(leaf, |
835 | victim_ref); | 835 | victim_ref); |
@@ -938,9 +938,8 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans, | |||
938 | 938 | ||
939 | file_bytes = (item_size / csum_size) * root->sectorsize; | 939 | file_bytes = (item_size / csum_size) * root->sectorsize; |
940 | sums = kzalloc(btrfs_ordered_sum_size(root, file_bytes), GFP_NOFS); | 940 | sums = kzalloc(btrfs_ordered_sum_size(root, file_bytes), GFP_NOFS); |
941 | if (!sums) { | 941 | if (!sums) |
942 | return -ENOMEM; | 942 | return -ENOMEM; |
943 | } | ||
944 | 943 | ||
945 | INIT_LIST_HEAD(&sums->list); | 944 | INIT_LIST_HEAD(&sums->list); |
946 | sums->len = file_bytes; | 945 | sums->len = file_bytes; |
@@ -952,7 +951,7 @@ static noinline int replay_one_csum(struct btrfs_trans_handle *trans, | |||
952 | sector_sum = sums->sums; | 951 | sector_sum = sums->sums; |
953 | cur_offset = key->offset; | 952 | cur_offset = key->offset; |
954 | ptr = btrfs_item_ptr_offset(eb, slot); | 953 | ptr = btrfs_item_ptr_offset(eb, slot); |
955 | while(item_size > 0) { | 954 | while (item_size > 0) { |
956 | sector_sum->bytenr = cur_offset; | 955 | sector_sum->bytenr = cur_offset; |
957 | read_extent_buffer(eb, §or_sum->sum, ptr, csum_size); | 956 | read_extent_buffer(eb, §or_sum->sum, ptr, csum_size); |
958 | sector_sum++; | 957 | sector_sum++; |
@@ -995,7 +994,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
995 | 994 | ||
996 | path = btrfs_alloc_path(); | 995 | path = btrfs_alloc_path(); |
997 | 996 | ||
998 | while(1) { | 997 | while (1) { |
999 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); | 998 | ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); |
1000 | if (ret < 0) | 999 | if (ret < 0) |
1001 | break; | 1000 | break; |
@@ -1012,7 +1011,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
1012 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); | 1011 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); |
1013 | ptr_end = ptr + btrfs_item_size_nr(path->nodes[0], | 1012 | ptr_end = ptr + btrfs_item_size_nr(path->nodes[0], |
1014 | path->slots[0]); | 1013 | path->slots[0]); |
1015 | while(ptr < ptr_end) { | 1014 | while (ptr < ptr_end) { |
1016 | struct btrfs_inode_ref *ref; | 1015 | struct btrfs_inode_ref *ref; |
1017 | 1016 | ||
1018 | ref = (struct btrfs_inode_ref *)ptr; | 1017 | ref = (struct btrfs_inode_ref *)ptr; |
@@ -1048,7 +1047,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans, | |||
1048 | key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; | 1047 | key.objectid = BTRFS_TREE_LOG_FIXUP_OBJECTID; |
1049 | key.type = BTRFS_ORPHAN_ITEM_KEY; | 1048 | key.type = BTRFS_ORPHAN_ITEM_KEY; |
1050 | key.offset = (u64)-1; | 1049 | key.offset = (u64)-1; |
1051 | while(1) { | 1050 | while (1) { |
1052 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); | 1051 | ret = btrfs_search_slot(trans, root, &key, path, -1, 1); |
1053 | if (ret < 0) | 1052 | if (ret < 0) |
1054 | break; | 1053 | break; |
@@ -1206,8 +1205,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans, | |||
1206 | if (key->type == BTRFS_DIR_ITEM_KEY) { | 1205 | if (key->type == BTRFS_DIR_ITEM_KEY) { |
1207 | dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, | 1206 | dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, |
1208 | name, name_len, 1); | 1207 | name, name_len, 1); |
1209 | } | 1208 | } else if (key->type == BTRFS_DIR_INDEX_KEY) { |
1210 | else if (key->type == BTRFS_DIR_INDEX_KEY) { | ||
1211 | dst_di = btrfs_lookup_dir_index_item(trans, root, path, | 1209 | dst_di = btrfs_lookup_dir_index_item(trans, root, path, |
1212 | key->objectid, | 1210 | key->objectid, |
1213 | key->offset, name, | 1211 | key->offset, name, |
@@ -1282,7 +1280,7 @@ static noinline int replay_one_dir_item(struct btrfs_trans_handle *trans, | |||
1282 | 1280 | ||
1283 | ptr = btrfs_item_ptr_offset(eb, slot); | 1281 | ptr = btrfs_item_ptr_offset(eb, slot); |
1284 | ptr_end = ptr + item_size; | 1282 | ptr_end = ptr + item_size; |
1285 | while(ptr < ptr_end) { | 1283 | while (ptr < ptr_end) { |
1286 | di = (struct btrfs_dir_item *)ptr; | 1284 | di = (struct btrfs_dir_item *)ptr; |
1287 | name_len = btrfs_dir_name_len(eb, di); | 1285 | name_len = btrfs_dir_name_len(eb, di); |
1288 | ret = replay_one_name(trans, root, path, eb, di, key); | 1286 | ret = replay_one_name(trans, root, path, eb, di, key); |
@@ -1408,7 +1406,7 @@ again: | |||
1408 | item_size = btrfs_item_size_nr(eb, slot); | 1406 | item_size = btrfs_item_size_nr(eb, slot); |
1409 | ptr = btrfs_item_ptr_offset(eb, slot); | 1407 | ptr = btrfs_item_ptr_offset(eb, slot); |
1410 | ptr_end = ptr + item_size; | 1408 | ptr_end = ptr + item_size; |
1411 | while(ptr < ptr_end) { | 1409 | while (ptr < ptr_end) { |
1412 | di = (struct btrfs_dir_item *)ptr; | 1410 | di = (struct btrfs_dir_item *)ptr; |
1413 | name_len = btrfs_dir_name_len(eb, di); | 1411 | name_len = btrfs_dir_name_len(eb, di); |
1414 | name = kmalloc(name_len, GFP_NOFS); | 1412 | name = kmalloc(name_len, GFP_NOFS); |
@@ -1513,14 +1511,14 @@ static noinline int replay_dir_deletes(struct btrfs_trans_handle *trans, | |||
1513 | again: | 1511 | again: |
1514 | range_start = 0; | 1512 | range_start = 0; |
1515 | range_end = 0; | 1513 | range_end = 0; |
1516 | while(1) { | 1514 | while (1) { |
1517 | ret = find_dir_range(log, path, dirid, key_type, | 1515 | ret = find_dir_range(log, path, dirid, key_type, |
1518 | &range_start, &range_end); | 1516 | &range_start, &range_end); |
1519 | if (ret != 0) | 1517 | if (ret != 0) |
1520 | break; | 1518 | break; |
1521 | 1519 | ||
1522 | dir_key.offset = range_start; | 1520 | dir_key.offset = range_start; |
1523 | while(1) { | 1521 | while (1) { |
1524 | int nritems; | 1522 | int nritems; |
1525 | ret = btrfs_search_slot(NULL, root, &dir_key, path, | 1523 | ret = btrfs_search_slot(NULL, root, &dir_key, path, |
1526 | 0, 0); | 1524 | 0, 0); |
@@ -1676,7 +1674,7 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb, | |||
1676 | return 0; | 1674 | return 0; |
1677 | } | 1675 | } |
1678 | 1676 | ||
1679 | static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, | 1677 | static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans, |
1680 | struct btrfs_root *root, | 1678 | struct btrfs_root *root, |
1681 | struct btrfs_path *path, int *level, | 1679 | struct btrfs_path *path, int *level, |
1682 | struct walk_control *wc) | 1680 | struct walk_control *wc) |
@@ -1694,7 +1692,7 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
1694 | WARN_ON(*level < 0); | 1692 | WARN_ON(*level < 0); |
1695 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 1693 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
1696 | 1694 | ||
1697 | while(*level > 0) { | 1695 | while (*level > 0) { |
1698 | WARN_ON(*level < 0); | 1696 | WARN_ON(*level < 0); |
1699 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 1697 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
1700 | cur = path->nodes[*level]; | 1698 | cur = path->nodes[*level]; |
@@ -1753,11 +1751,11 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
1753 | WARN_ON(*level < 0); | 1751 | WARN_ON(*level < 0); |
1754 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 1752 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
1755 | 1753 | ||
1756 | if (path->nodes[*level] == root->node) { | 1754 | if (path->nodes[*level] == root->node) |
1757 | parent = path->nodes[*level]; | 1755 | parent = path->nodes[*level]; |
1758 | } else { | 1756 | else |
1759 | parent = path->nodes[*level + 1]; | 1757 | parent = path->nodes[*level + 1]; |
1760 | } | 1758 | |
1761 | bytenr = path->nodes[*level]->start; | 1759 | bytenr = path->nodes[*level]->start; |
1762 | 1760 | ||
1763 | blocksize = btrfs_level_size(root, *level); | 1761 | blocksize = btrfs_level_size(root, *level); |
@@ -1790,7 +1788,7 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans, | |||
1790 | return 0; | 1788 | return 0; |
1791 | } | 1789 | } |
1792 | 1790 | ||
1793 | static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans, | 1791 | static noinline int walk_up_log_tree(struct btrfs_trans_handle *trans, |
1794 | struct btrfs_root *root, | 1792 | struct btrfs_root *root, |
1795 | struct btrfs_path *path, int *level, | 1793 | struct btrfs_path *path, int *level, |
1796 | struct walk_control *wc) | 1794 | struct walk_control *wc) |
@@ -1801,7 +1799,7 @@ static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans, | |||
1801 | int slot; | 1799 | int slot; |
1802 | int ret; | 1800 | int ret; |
1803 | 1801 | ||
1804 | for(i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) { | 1802 | for (i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) { |
1805 | slot = path->slots[i]; | 1803 | slot = path->slots[i]; |
1806 | if (slot < btrfs_header_nritems(path->nodes[i]) - 1) { | 1804 | if (slot < btrfs_header_nritems(path->nodes[i]) - 1) { |
1807 | struct extent_buffer *node; | 1805 | struct extent_buffer *node; |
@@ -1875,7 +1873,7 @@ static int walk_log_tree(struct btrfs_trans_handle *trans, | |||
1875 | extent_buffer_get(log->node); | 1873 | extent_buffer_get(log->node); |
1876 | path->slots[level] = 0; | 1874 | path->slots[level] = 0; |
1877 | 1875 | ||
1878 | while(1) { | 1876 | while (1) { |
1879 | wret = walk_down_log_tree(trans, log, path, &level, wc); | 1877 | wret = walk_down_log_tree(trans, log, path, &level, wc); |
1880 | if (wret > 0) | 1878 | if (wret > 0) |
1881 | break; | 1879 | break; |
@@ -1941,7 +1939,7 @@ static int wait_log_commit(struct btrfs_root *log) | |||
1941 | schedule(); | 1939 | schedule(); |
1942 | finish_wait(&log->fs_info->tree_log_wait, &wait); | 1940 | finish_wait(&log->fs_info->tree_log_wait, &wait); |
1943 | mutex_lock(&log->fs_info->tree_log_mutex); | 1941 | mutex_lock(&log->fs_info->tree_log_mutex); |
1944 | } while(transid == log->fs_info->tree_log_transid && | 1942 | } while (transid == log->fs_info->tree_log_transid && |
1945 | atomic_read(&log->fs_info->tree_log_commit)); | 1943 | atomic_read(&log->fs_info->tree_log_commit)); |
1946 | return 0; | 1944 | return 0; |
1947 | } | 1945 | } |
@@ -1965,13 +1963,13 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans, | |||
1965 | } | 1963 | } |
1966 | atomic_set(&log->fs_info->tree_log_commit, 1); | 1964 | atomic_set(&log->fs_info->tree_log_commit, 1); |
1967 | 1965 | ||
1968 | while(1) { | 1966 | while (1) { |
1969 | batch = log->fs_info->tree_log_batch; | 1967 | batch = log->fs_info->tree_log_batch; |
1970 | mutex_unlock(&log->fs_info->tree_log_mutex); | 1968 | mutex_unlock(&log->fs_info->tree_log_mutex); |
1971 | schedule_timeout_uninterruptible(1); | 1969 | schedule_timeout_uninterruptible(1); |
1972 | mutex_lock(&log->fs_info->tree_log_mutex); | 1970 | mutex_lock(&log->fs_info->tree_log_mutex); |
1973 | 1971 | ||
1974 | while(atomic_read(&log->fs_info->tree_log_writers)) { | 1972 | while (atomic_read(&log->fs_info->tree_log_writers)) { |
1975 | DEFINE_WAIT(wait); | 1973 | DEFINE_WAIT(wait); |
1976 | prepare_to_wait(&log->fs_info->tree_log_wait, &wait, | 1974 | prepare_to_wait(&log->fs_info->tree_log_wait, &wait, |
1977 | TASK_UNINTERRUPTIBLE); | 1975 | TASK_UNINTERRUPTIBLE); |
@@ -2030,7 +2028,7 @@ int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root) | |||
2030 | ret = walk_log_tree(trans, log, &wc); | 2028 | ret = walk_log_tree(trans, log, &wc); |
2031 | BUG_ON(ret); | 2029 | BUG_ON(ret); |
2032 | 2030 | ||
2033 | while(1) { | 2031 | while (1) { |
2034 | ret = find_first_extent_bit(&log->dirty_log_pages, | 2032 | ret = find_first_extent_bit(&log->dirty_log_pages, |
2035 | 0, &start, &end, EXTENT_DIRTY); | 2033 | 0, &start, &end, EXTENT_DIRTY); |
2036 | if (ret) | 2034 | if (ret) |
@@ -2287,9 +2285,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2287 | struct btrfs_key tmp; | 2285 | struct btrfs_key tmp; |
2288 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, | 2286 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, |
2289 | path->slots[0]); | 2287 | path->slots[0]); |
2290 | if (key_type == tmp.type) { | 2288 | if (key_type == tmp.type) |
2291 | first_offset = max(min_offset, tmp.offset) + 1; | 2289 | first_offset = max(min_offset, tmp.offset) + 1; |
2292 | } | ||
2293 | } | 2290 | } |
2294 | goto done; | 2291 | goto done; |
2295 | } | 2292 | } |
@@ -2319,7 +2316,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2319 | * we have a block from this transaction, log every item in it | 2316 | * we have a block from this transaction, log every item in it |
2320 | * from our directory | 2317 | * from our directory |
2321 | */ | 2318 | */ |
2322 | while(1) { | 2319 | while (1) { |
2323 | struct btrfs_key tmp; | 2320 | struct btrfs_key tmp; |
2324 | src = path->nodes[0]; | 2321 | src = path->nodes[0]; |
2325 | nritems = btrfs_header_nritems(src); | 2322 | nritems = btrfs_header_nritems(src); |
@@ -2396,7 +2393,7 @@ static noinline int log_directory_changes(struct btrfs_trans_handle *trans, | |||
2396 | again: | 2393 | again: |
2397 | min_key = 0; | 2394 | min_key = 0; |
2398 | max_key = 0; | 2395 | max_key = 0; |
2399 | while(1) { | 2396 | while (1) { |
2400 | ret = log_dir_items(trans, root, inode, path, | 2397 | ret = log_dir_items(trans, root, inode, path, |
2401 | dst_path, key_type, min_key, | 2398 | dst_path, key_type, min_key, |
2402 | &max_key); | 2399 | &max_key); |
@@ -2432,7 +2429,7 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans, | |||
2432 | key.type = max_key_type; | 2429 | key.type = max_key_type; |
2433 | key.offset = (u64)-1; | 2430 | key.offset = (u64)-1; |
2434 | 2431 | ||
2435 | while(1) { | 2432 | while (1) { |
2436 | ret = btrfs_search_slot(trans, log, &key, path, -1, 1); | 2433 | ret = btrfs_search_slot(trans, log, &key, path, -1, 1); |
2437 | 2434 | ||
2438 | if (ret != 1) | 2435 | if (ret != 1) |
@@ -2481,7 +2478,7 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans, | |||
2481 | list_add_tail(&sums->list, list); | 2478 | list_add_tail(&sums->list, list); |
2482 | 2479 | ||
2483 | path = btrfs_alloc_path(); | 2480 | path = btrfs_alloc_path(); |
2484 | while(disk_bytenr < end) { | 2481 | while (disk_bytenr < end) { |
2485 | if (!item || disk_bytenr < item_start_offset || | 2482 | if (!item || disk_bytenr < item_start_offset || |
2486 | disk_bytenr >= item_last_offset) { | 2483 | disk_bytenr >= item_last_offset) { |
2487 | struct btrfs_key found_key; | 2484 | struct btrfs_key found_key; |
@@ -2496,7 +2493,8 @@ static noinline int copy_extent_csums(struct btrfs_trans_handle *trans, | |||
2496 | if (ret == -ENOENT || ret == -EFBIG) | 2493 | if (ret == -ENOENT || ret == -EFBIG) |
2497 | ret = 0; | 2494 | ret = 0; |
2498 | sum = 0; | 2495 | sum = 0; |
2499 | printk("log no csum found for byte %llu\n", | 2496 | printk(KERN_INFO "log no csum found for " |
2497 | "byte %llu\n", | ||
2500 | (unsigned long long)disk_bytenr); | 2498 | (unsigned long long)disk_bytenr); |
2501 | item = NULL; | 2499 | item = NULL; |
2502 | btrfs_release_path(root, path); | 2500 | btrfs_release_path(root, path); |
@@ -2643,7 +2641,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, | |||
2643 | * we have to do this after the loop above to avoid changing the | 2641 | * we have to do this after the loop above to avoid changing the |
2644 | * log tree while trying to change the log tree. | 2642 | * log tree while trying to change the log tree. |
2645 | */ | 2643 | */ |
2646 | while(!list_empty(&ordered_sums)) { | 2644 | while (!list_empty(&ordered_sums)) { |
2647 | struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next, | 2645 | struct btrfs_ordered_sum *sums = list_entry(ordered_sums.next, |
2648 | struct btrfs_ordered_sum, | 2646 | struct btrfs_ordered_sum, |
2649 | list); | 2647 | list); |
@@ -2736,7 +2734,7 @@ static int __btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2736 | BUG_ON(ret); | 2734 | BUG_ON(ret); |
2737 | path->keep_locks = 1; | 2735 | path->keep_locks = 1; |
2738 | 2736 | ||
2739 | while(1) { | 2737 | while (1) { |
2740 | ins_nr = 0; | 2738 | ins_nr = 0; |
2741 | ret = btrfs_search_forward(root, &min_key, &max_key, | 2739 | ret = btrfs_search_forward(root, &min_key, &max_key, |
2742 | path, 0, trans->transid); | 2740 | path, 0, trans->transid); |
@@ -2848,7 +2846,7 @@ int btrfs_log_dentry(struct btrfs_trans_handle *trans, | |||
2848 | 2846 | ||
2849 | start_log_trans(trans, root); | 2847 | start_log_trans(trans, root); |
2850 | sb = dentry->d_inode->i_sb; | 2848 | sb = dentry->d_inode->i_sb; |
2851 | while(1) { | 2849 | while (1) { |
2852 | ret = __btrfs_log_inode(trans, root, dentry->d_inode, | 2850 | ret = __btrfs_log_inode(trans, root, dentry->d_inode, |
2853 | inode_only); | 2851 | inode_only); |
2854 | BUG_ON(ret); | 2852 | BUG_ON(ret); |
@@ -2919,7 +2917,7 @@ again: | |||
2919 | key.offset = (u64)-1; | 2917 | key.offset = (u64)-1; |
2920 | btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); | 2918 | btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); |
2921 | 2919 | ||
2922 | while(1) { | 2920 | while (1) { |
2923 | ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); | 2921 | ret = btrfs_search_slot(NULL, log_root_tree, &key, path, 0, 0); |
2924 | if (ret < 0) | 2922 | if (ret < 0) |
2925 | break; | 2923 | break; |