aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 183913bac14..a794b9f6013 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -333,13 +333,13 @@ static noinline int overwrite_item(struct btrfs_trans_handle *trans,
333 goto insert; 333 goto insert;
334 334
335 if (item_size == 0) { 335 if (item_size == 0) {
336 btrfs_release_path(root, path); 336 btrfs_release_path(path);
337 return 0; 337 return 0;
338 } 338 }
339 dst_copy = kmalloc(item_size, GFP_NOFS); 339 dst_copy = kmalloc(item_size, GFP_NOFS);
340 src_copy = kmalloc(item_size, GFP_NOFS); 340 src_copy = kmalloc(item_size, GFP_NOFS);
341 if (!dst_copy || !src_copy) { 341 if (!dst_copy || !src_copy) {
342 btrfs_release_path(root, path); 342 btrfs_release_path(path);
343 kfree(dst_copy); 343 kfree(dst_copy);
344 kfree(src_copy); 344 kfree(src_copy);
345 return -ENOMEM; 345 return -ENOMEM;
@@ -361,13 +361,13 @@ static noinline int overwrite_item(struct btrfs_trans_handle *trans,
361 * sync 361 * sync
362 */ 362 */
363 if (ret == 0) { 363 if (ret == 0) {
364 btrfs_release_path(root, path); 364 btrfs_release_path(path);
365 return 0; 365 return 0;
366 } 366 }
367 367
368 } 368 }
369insert: 369insert:
370 btrfs_release_path(root, path); 370 btrfs_release_path(path);
371 /* try to insert the key into the destination tree */ 371 /* try to insert the key into the destination tree */
372 ret = btrfs_insert_empty_item(trans, root, path, 372 ret = btrfs_insert_empty_item(trans, root, path,
373 key, item_size); 373 key, item_size);
@@ -438,7 +438,7 @@ insert:
438 } 438 }
439no_copy: 439no_copy:
440 btrfs_mark_buffer_dirty(path->nodes[0]); 440 btrfs_mark_buffer_dirty(path->nodes[0]);
441 btrfs_release_path(root, path); 441 btrfs_release_path(path);
442 return 0; 442 return 0;
443} 443}
444 444
@@ -544,11 +544,11 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
544 * we don't have to do anything 544 * we don't have to do anything
545 */ 545 */
546 if (memcmp(&cmp1, &cmp2, sizeof(cmp1)) == 0) { 546 if (memcmp(&cmp1, &cmp2, sizeof(cmp1)) == 0) {
547 btrfs_release_path(root, path); 547 btrfs_release_path(path);
548 goto out; 548 goto out;
549 } 549 }
550 } 550 }
551 btrfs_release_path(root, path); 551 btrfs_release_path(path);
552 552
553 saved_nbytes = inode_get_bytes(inode); 553 saved_nbytes = inode_get_bytes(inode);
554 /* drop any overlapping extents */ 554 /* drop any overlapping extents */
@@ -600,7 +600,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
600 key->objectid, offset, &ins); 600 key->objectid, offset, &ins);
601 BUG_ON(ret); 601 BUG_ON(ret);
602 } 602 }
603 btrfs_release_path(root, path); 603 btrfs_release_path(path);
604 604
605 if (btrfs_file_extent_compression(eb, item)) { 605 if (btrfs_file_extent_compression(eb, item)) {
606 csum_start = ins.objectid; 606 csum_start = ins.objectid;
@@ -629,7 +629,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans,
629 kfree(sums); 629 kfree(sums);
630 } 630 }
631 } else { 631 } else {
632 btrfs_release_path(root, path); 632 btrfs_release_path(path);
633 } 633 }
634 } else if (found_type == BTRFS_FILE_EXTENT_INLINE) { 634 } else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
635 /* inline extents are easy, we just overwrite them */ 635 /* inline extents are easy, we just overwrite them */
@@ -675,7 +675,7 @@ static noinline int drop_one_dir_item(struct btrfs_trans_handle *trans,
675 return -ENOMEM; 675 return -ENOMEM;
676 676
677 read_extent_buffer(leaf, name, (unsigned long)(di + 1), name_len); 677 read_extent_buffer(leaf, name, (unsigned long)(di + 1), name_len);
678 btrfs_release_path(root, path); 678 btrfs_release_path(path);
679 679
680 inode = read_one_inode(root, location.objectid); 680 inode = read_one_inode(root, location.objectid);
681 BUG_ON(!inode); 681 BUG_ON(!inode);
@@ -713,7 +713,7 @@ static noinline int inode_in_dir(struct btrfs_root *root,
713 goto out; 713 goto out;
714 } else 714 } else
715 goto out; 715 goto out;
716 btrfs_release_path(root, path); 716 btrfs_release_path(path);
717 717
718 di = btrfs_lookup_dir_item(NULL, root, path, dirid, name, name_len, 0); 718 di = btrfs_lookup_dir_item(NULL, root, path, dirid, name, name_len, 0);
719 if (di && !IS_ERR(di)) { 719 if (di && !IS_ERR(di)) {
@@ -724,7 +724,7 @@ static noinline int inode_in_dir(struct btrfs_root *root,
724 goto out; 724 goto out;
725 match = 1; 725 match = 1;
726out: 726out:
727 btrfs_release_path(root, path); 727 btrfs_release_path(path);
728 return match; 728 return match;
729} 729}
730 730
@@ -884,7 +884,7 @@ again:
884 if (!backref_in_log(log, key, victim_name, 884 if (!backref_in_log(log, key, victim_name,
885 victim_name_len)) { 885 victim_name_len)) {
886 btrfs_inc_nlink(inode); 886 btrfs_inc_nlink(inode);
887 btrfs_release_path(root, path); 887 btrfs_release_path(path);
888 888
889 ret = btrfs_unlink_inode(trans, root, dir, 889 ret = btrfs_unlink_inode(trans, root, dir,
890 inode, victim_name, 890 inode, victim_name,
@@ -901,7 +901,7 @@ again:
901 */ 901 */
902 search_done = 1; 902 search_done = 1;
903 } 903 }
904 btrfs_release_path(root, path); 904 btrfs_release_path(path);
905 905
906insert: 906insert:
907 /* insert our name */ 907 /* insert our name */
@@ -922,7 +922,7 @@ out:
922 BUG_ON(ret); 922 BUG_ON(ret);
923 923
924out_nowrite: 924out_nowrite:
925 btrfs_release_path(root, path); 925 btrfs_release_path(path);
926 iput(dir); 926 iput(dir);
927 iput(inode); 927 iput(inode);
928 return 0; 928 return 0;
@@ -1000,9 +1000,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans,
1000 if (key.offset == 0) 1000 if (key.offset == 0)
1001 break; 1001 break;
1002 key.offset--; 1002 key.offset--;
1003 btrfs_release_path(root, path); 1003 btrfs_release_path(path);
1004 } 1004 }
1005 btrfs_release_path(root, path); 1005 btrfs_release_path(path);
1006 if (nlink != inode->i_nlink) { 1006 if (nlink != inode->i_nlink) {
1007 inode->i_nlink = nlink; 1007 inode->i_nlink = nlink;
1008 btrfs_update_inode(trans, root, inode); 1008 btrfs_update_inode(trans, root, inode);
@@ -1053,7 +1053,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1053 ret = btrfs_del_item(trans, root, path); 1053 ret = btrfs_del_item(trans, root, path);
1054 BUG_ON(ret); 1054 BUG_ON(ret);
1055 1055
1056 btrfs_release_path(root, path); 1056 btrfs_release_path(path);
1057 inode = read_one_inode(root, key.offset); 1057 inode = read_one_inode(root, key.offset);
1058 BUG_ON(!inode); 1058 BUG_ON(!inode);
1059 1059
@@ -1069,7 +1069,7 @@ static noinline int fixup_inode_link_counts(struct btrfs_trans_handle *trans,
1069 */ 1069 */
1070 key.offset = (u64)-1; 1070 key.offset = (u64)-1;
1071 } 1071 }
1072 btrfs_release_path(root, path); 1072 btrfs_release_path(path);
1073 return 0; 1073 return 0;
1074} 1074}
1075 1075
@@ -1097,7 +1097,7 @@ static noinline int link_to_fixup_dir(struct btrfs_trans_handle *trans,
1097 1097
1098 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); 1098 ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
1099 1099
1100 btrfs_release_path(root, path); 1100 btrfs_release_path(path);
1101 if (ret == 0) { 1101 if (ret == 0) {
1102 btrfs_inc_nlink(inode); 1102 btrfs_inc_nlink(inode);
1103 btrfs_update_inode(trans, root, inode); 1103 btrfs_update_inode(trans, root, inode);
@@ -1193,7 +1193,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1193 exists = 1; 1193 exists = 1;
1194 else 1194 else
1195 exists = 0; 1195 exists = 0;
1196 btrfs_release_path(root, path); 1196 btrfs_release_path(path);
1197 1197
1198 if (key->type == BTRFS_DIR_ITEM_KEY) { 1198 if (key->type == BTRFS_DIR_ITEM_KEY) {
1199 dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid, 1199 dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,
@@ -1206,7 +1206,7 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1206 } else { 1206 } else {
1207 BUG(); 1207 BUG();
1208 } 1208 }
1209 if (!dst_di || IS_ERR(dst_di)) { 1209 if (IS_ERR_OR_NULL(dst_di)) {
1210 /* we need a sequence number to insert, so we only 1210 /* we need a sequence number to insert, so we only
1211 * do inserts for the BTRFS_DIR_INDEX_KEY types 1211 * do inserts for the BTRFS_DIR_INDEX_KEY types
1212 */ 1212 */
@@ -1237,13 +1237,13 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
1237 if (key->type == BTRFS_DIR_INDEX_KEY) 1237 if (key->type == BTRFS_DIR_INDEX_KEY)
1238 goto insert; 1238 goto insert;
1239out: 1239out:
1240 btrfs_release_path(root, path); 1240 btrfs_release_path(path);
1241 kfree(name); 1241 kfree(name);
1242 iput(dir); 1242 iput(dir);
1243 return 0; 1243 return 0;
1244 1244
1245insert: 1245insert:
1246 btrfs_release_path(root, path); 1246 btrfs_release_path(path);
1247 ret = insert_one_name(trans, root, path, key->objectid, key->offset, 1247 ret = insert_one_name(trans, root, path, key->objectid, key->offset,
1248 name, name_len, log_type, &log_key); 1248 name, name_len, log_type, &log_key);
1249 1249
@@ -1364,7 +1364,7 @@ next:
1364 *end_ret = found_end; 1364 *end_ret = found_end;
1365 ret = 0; 1365 ret = 0;
1366out: 1366out:
1367 btrfs_release_path(root, path); 1367 btrfs_release_path(path);
1368 return ret; 1368 return ret;
1369} 1369}
1370 1370
@@ -1427,10 +1427,10 @@ again:
1427 dir_key->offset, 1427 dir_key->offset,
1428 name, name_len, 0); 1428 name, name_len, 0);
1429 } 1429 }
1430 if (!log_di || IS_ERR(log_di)) { 1430 if (IS_ERR_OR_NULL(log_di)) {
1431 btrfs_dir_item_key_to_cpu(eb, di, &location); 1431 btrfs_dir_item_key_to_cpu(eb, di, &location);
1432 btrfs_release_path(root, path); 1432 btrfs_release_path(path);
1433 btrfs_release_path(log, log_path); 1433 btrfs_release_path(log_path);
1434 inode = read_one_inode(root, location.objectid); 1434 inode = read_one_inode(root, location.objectid);
1435 BUG_ON(!inode); 1435 BUG_ON(!inode);
1436 1436
@@ -1454,7 +1454,7 @@ again:
1454 ret = 0; 1454 ret = 0;
1455 goto out; 1455 goto out;
1456 } 1456 }
1457 btrfs_release_path(log, log_path); 1457 btrfs_release_path(log_path);
1458 kfree(name); 1458 kfree(name);
1459 1459
1460 ptr = (unsigned long)(di + 1); 1460 ptr = (unsigned long)(di + 1);
@@ -1462,8 +1462,8 @@ again:
1462 } 1462 }
1463 ret = 0; 1463 ret = 0;
1464out: 1464out:
1465 btrfs_release_path(root, path); 1465 btrfs_release_path(path);
1466 btrfs_release_path(log, log_path); 1466 btrfs_release_path(log_path);
1467 return ret; 1467 return ret;
1468} 1468}
1469 1469
@@ -1551,7 +1551,7 @@ again:
1551 break; 1551 break;
1552 dir_key.offset = found_key.offset + 1; 1552 dir_key.offset = found_key.offset + 1;
1553 } 1553 }
1554 btrfs_release_path(root, path); 1554 btrfs_release_path(path);
1555 if (range_end == (u64)-1) 1555 if (range_end == (u64)-1)
1556 break; 1556 break;
1557 range_start = range_end + 1; 1557 range_start = range_end + 1;
@@ -1562,11 +1562,11 @@ next_type:
1562 if (key_type == BTRFS_DIR_LOG_ITEM_KEY) { 1562 if (key_type == BTRFS_DIR_LOG_ITEM_KEY) {
1563 key_type = BTRFS_DIR_LOG_INDEX_KEY; 1563 key_type = BTRFS_DIR_LOG_INDEX_KEY;
1564 dir_key.type = BTRFS_DIR_INDEX_KEY; 1564 dir_key.type = BTRFS_DIR_INDEX_KEY;
1565 btrfs_release_path(root, path); 1565 btrfs_release_path(path);
1566 goto again; 1566 goto again;
1567 } 1567 }
1568out: 1568out:
1569 btrfs_release_path(root, path); 1569 btrfs_release_path(path);
1570 btrfs_free_path(log_path); 1570 btrfs_free_path(log_path);
1571 iput(dir); 1571 iput(dir);
1572 return ret; 1572 return ret;
@@ -2227,7 +2227,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
2227 bytes_del += name_len; 2227 bytes_del += name_len;
2228 BUG_ON(ret); 2228 BUG_ON(ret);
2229 } 2229 }
2230 btrfs_release_path(log, path); 2230 btrfs_release_path(path);
2231 di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino, 2231 di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino,
2232 index, name, name_len, -1); 2232 index, name, name_len, -1);
2233 if (IS_ERR(di)) { 2233 if (IS_ERR(di)) {
@@ -2249,7 +2249,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
2249 key.objectid = dir_ino; 2249 key.objectid = dir_ino;
2250 key.offset = 0; 2250 key.offset = 0;
2251 key.type = BTRFS_INODE_ITEM_KEY; 2251 key.type = BTRFS_INODE_ITEM_KEY;
2252 btrfs_release_path(log, path); 2252 btrfs_release_path(path);
2253 2253
2254 ret = btrfs_search_slot(trans, log, &key, path, 0, 1); 2254 ret = btrfs_search_slot(trans, log, &key, path, 0, 1);
2255 if (ret < 0) { 2255 if (ret < 0) {
@@ -2271,7 +2271,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
2271 btrfs_mark_buffer_dirty(path->nodes[0]); 2271 btrfs_mark_buffer_dirty(path->nodes[0]);
2272 } else 2272 } else
2273 ret = 0; 2273 ret = 0;
2274 btrfs_release_path(log, path); 2274 btrfs_release_path(path);
2275 } 2275 }
2276fail: 2276fail:
2277 btrfs_free_path(path); 2277 btrfs_free_path(path);
@@ -2346,7 +2346,7 @@ static noinline int insert_dir_log_key(struct btrfs_trans_handle *trans,
2346 struct btrfs_dir_log_item); 2346 struct btrfs_dir_log_item);
2347 btrfs_set_dir_log_end(path->nodes[0], item, last_offset); 2347 btrfs_set_dir_log_end(path->nodes[0], item, last_offset);
2348 btrfs_mark_buffer_dirty(path->nodes[0]); 2348 btrfs_mark_buffer_dirty(path->nodes[0]);
2349 btrfs_release_path(log, path); 2349 btrfs_release_path(path);
2350 return 0; 2350 return 0;
2351} 2351}
2352 2352
@@ -2395,10 +2395,10 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2395 min_key.objectid = ino; 2395 min_key.objectid = ino;
2396 min_key.type = key_type; 2396 min_key.type = key_type;
2397 min_key.offset = (u64)-1; 2397 min_key.offset = (u64)-1;
2398 btrfs_release_path(root, path); 2398 btrfs_release_path(path);
2399 ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); 2399 ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
2400 if (ret < 0) { 2400 if (ret < 0) {
2401 btrfs_release_path(root, path); 2401 btrfs_release_path(path);
2402 return ret; 2402 return ret;
2403 } 2403 }
2404 ret = btrfs_previous_item(root, path, ino, key_type); 2404 ret = btrfs_previous_item(root, path, ino, key_type);
@@ -2434,7 +2434,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2434 } 2434 }
2435 } 2435 }
2436 } 2436 }
2437 btrfs_release_path(root, path); 2437 btrfs_release_path(path);
2438 2438
2439 /* find the first key from this transaction again */ 2439 /* find the first key from this transaction again */
2440 ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0); 2440 ret = btrfs_search_slot(NULL, root, &min_key, path, 0, 0);
@@ -2491,8 +2491,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans,
2491 } 2491 }
2492 } 2492 }
2493done: 2493done:
2494 btrfs_release_path(root, path); 2494 btrfs_release_path(path);
2495 btrfs_release_path(log, dst_path); 2495 btrfs_release_path(dst_path);
2496 2496
2497 if (err == 0) { 2497 if (err == 0) {
2498 *last_offset_ret = last_offset; 2498 *last_offset_ret = last_offset;
@@ -2588,9 +2588,9 @@ static int drop_objectid_items(struct btrfs_trans_handle *trans,
2588 2588
2589 ret = btrfs_del_item(trans, log, path); 2589 ret = btrfs_del_item(trans, log, path);
2590 BUG_ON(ret); 2590 BUG_ON(ret);
2591 btrfs_release_path(log, path); 2591 btrfs_release_path(path);
2592 } 2592 }
2593 btrfs_release_path(log, path); 2593 btrfs_release_path(path);
2594 return ret; 2594 return ret;
2595} 2595}
2596 2596
@@ -2696,7 +2696,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
2696 } 2696 }
2697 2697
2698 btrfs_mark_buffer_dirty(dst_path->nodes[0]); 2698 btrfs_mark_buffer_dirty(dst_path->nodes[0]);
2699 btrfs_release_path(log, dst_path); 2699 btrfs_release_path(dst_path);
2700 kfree(ins_data); 2700 kfree(ins_data);
2701 2701
2702 /* 2702 /*
@@ -2852,7 +2852,7 @@ next_slot:
2852 } 2852 }
2853 ins_nr = 0; 2853 ins_nr = 0;
2854 } 2854 }
2855 btrfs_release_path(root, path); 2855 btrfs_release_path(path);
2856 2856
2857 if (min_key.offset < (u64)-1) 2857 if (min_key.offset < (u64)-1)
2858 min_key.offset++; 2858 min_key.offset++;
@@ -2875,8 +2875,8 @@ next_slot:
2875 } 2875 }
2876 WARN_ON(ins_nr); 2876 WARN_ON(ins_nr);
2877 if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) { 2877 if (inode_only == LOG_INODE_ALL && S_ISDIR(inode->i_mode)) {
2878 btrfs_release_path(root, path); 2878 btrfs_release_path(path);
2879 btrfs_release_path(log, dst_path); 2879 btrfs_release_path(dst_path);
2880 ret = log_directory_changes(trans, root, inode, path, dst_path); 2880 ret = log_directory_changes(trans, root, inode, path, dst_path);
2881 if (ret) { 2881 if (ret) {
2882 err = ret; 2882 err = ret;
@@ -3143,7 +3143,7 @@ again:
3143 } 3143 }
3144 btrfs_item_key_to_cpu(path->nodes[0], &found_key, 3144 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
3145 path->slots[0]); 3145 path->slots[0]);
3146 btrfs_release_path(log_root_tree, path); 3146 btrfs_release_path(path);
3147 if (found_key.objectid != BTRFS_TREE_LOG_OBJECTID) 3147 if (found_key.objectid != BTRFS_TREE_LOG_OBJECTID)
3148 break; 3148 break;
3149 3149
@@ -3178,7 +3178,7 @@ again:
3178 if (found_key.offset == 0) 3178 if (found_key.offset == 0)
3179 break; 3179 break;
3180 } 3180 }
3181 btrfs_release_path(log_root_tree, path); 3181 btrfs_release_path(path);
3182 3182
3183 /* step one is to pin it all, step two is to replay just inodes */ 3183 /* step one is to pin it all, step two is to replay just inodes */
3184 if (wc.pin) { 3184 if (wc.pin) {