file-item.c (53f724b2432a9f97a941251772f2b0d195e2d282) | file-item.c (6f546216e9f9e95d6783547ce6113eb13e2daa54) |
---|---|
1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 241 unchanged lines hidden (view full) --- 250 if (BTRFS_I(inode)->root->root_key.objectid == 251 BTRFS_DATA_RELOC_TREE_OBJECTID) { 252 set_extent_bits(io_tree, offset, 253 offset + fs_info->sectorsize - 1, 254 EXTENT_NODATASUM); 255 } else { 256 btrfs_info_rl(fs_info, 257 "no csum found for inode %llu start %llu", | 1/* 2 * Copyright (C) 2007 Oracle. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 241 unchanged lines hidden (view full) --- 250 if (BTRFS_I(inode)->root->root_key.objectid == 251 BTRFS_DATA_RELOC_TREE_OBJECTID) { 252 set_extent_bits(io_tree, offset, 253 offset + fs_info->sectorsize - 1, 254 EXTENT_NODATASUM); 255 } else { 256 btrfs_info_rl(fs_info, 257 "no csum found for inode %llu start %llu", |
258 btrfs_ino(inode), offset); | 258 btrfs_ino(BTRFS_I(inode)), offset); |
259 } 260 item = NULL; 261 btrfs_release_path(path); 262 goto found; 263 } 264 btrfs_item_key_to_cpu(path->nodes[0], &found_key, 265 path->slots[0]); 266 --- 371 unchanged lines hidden (view full) --- 638 csum_end += key.offset; 639 640 /* this csum ends before we start, we're done */ 641 if (csum_end <= bytenr) 642 break; 643 644 /* delete the entire item, it is inside our range */ 645 if (key.offset >= bytenr && csum_end <= end_byte) { | 259 } 260 item = NULL; 261 btrfs_release_path(path); 262 goto found; 263 } 264 btrfs_item_key_to_cpu(path->nodes[0], &found_key, 265 path->slots[0]); 266 --- 371 unchanged lines hidden (view full) --- 638 csum_end += key.offset; 639 640 /* this csum ends before we start, we're done */ 641 if (csum_end <= bytenr) 642 break; 643 644 /* delete the entire item, it is inside our range */ 645 if (key.offset >= bytenr && csum_end <= end_byte) { |
646 ret = btrfs_del_item(trans, root, path); | 646 int del_nr = 1; 647 648 /* 649 * Check how many csum items preceding this one in this 650 * leaf correspond to our range and then delete them all 651 * at once. 652 */ 653 if (key.offset > bytenr && path->slots[0] > 0) { 654 int slot = path->slots[0] - 1; 655 656 while (slot >= 0) { 657 struct btrfs_key pk; 658 659 btrfs_item_key_to_cpu(leaf, &pk, slot); 660 if (pk.offset < bytenr || 661 pk.type != BTRFS_EXTENT_CSUM_KEY || 662 pk.objectid != 663 BTRFS_EXTENT_CSUM_OBJECTID) 664 break; 665 path->slots[0] = slot; 666 del_nr++; 667 key.offset = pk.offset; 668 slot--; 669 } 670 } 671 ret = btrfs_del_items(trans, root, path, 672 path->slots[0], del_nr); |
647 if (ret) 648 goto out; 649 if (key.offset == bytenr) 650 break; 651 } else if (key.offset < bytenr && csum_end > end_byte) { 652 unsigned long offset; 653 unsigned long shift_len; 654 unsigned long item_offset; --- 196 unchanged lines hidden (view full) --- 851 if (found_next) { 852 u64 tmp; 853 854 tmp = sums->len - total_bytes; 855 tmp >>= fs_info->sb->s_blocksize_bits; 856 tmp = min(tmp, (next_offset - file_key.offset) >> 857 fs_info->sb->s_blocksize_bits); 858 | 673 if (ret) 674 goto out; 675 if (key.offset == bytenr) 676 break; 677 } else if (key.offset < bytenr && csum_end > end_byte) { 678 unsigned long offset; 679 unsigned long shift_len; 680 unsigned long item_offset; --- 196 unchanged lines hidden (view full) --- 877 if (found_next) { 878 u64 tmp; 879 880 tmp = sums->len - total_bytes; 881 tmp >>= fs_info->sb->s_blocksize_bits; 882 tmp = min(tmp, (next_offset - file_key.offset) >> 883 fs_info->sb->s_blocksize_bits); 884 |
859 tmp = max((u64)1, tmp); 860 tmp = min(tmp, (u64)MAX_CSUM_ITEMS(fs_info, csum_size)); | 885 tmp = max_t(u64, 1, tmp); 886 tmp = min_t(u64, tmp, MAX_CSUM_ITEMS(fs_info, csum_size)); |
861 ins_size = csum_size * tmp; 862 } else { 863 ins_size = csum_size; 864 } 865 path->leave_spinning = 1; 866 ret = btrfs_insert_empty_item(trans, root, path, &file_key, 867 ins_size); 868 path->leave_spinning = 0; --- 103 unchanged lines hidden (view full) --- 972 em->block_len = (u64)-1; 973 if (!new_inline && compress_type != BTRFS_COMPRESS_NONE) { 974 set_bit(EXTENT_FLAG_COMPRESSED, &em->flags); 975 em->compress_type = compress_type; 976 } 977 } else { 978 btrfs_err(fs_info, 979 "unknown file extent item type %d, inode %llu, offset %llu, root %llu", | 887 ins_size = csum_size * tmp; 888 } else { 889 ins_size = csum_size; 890 } 891 path->leave_spinning = 1; 892 ret = btrfs_insert_empty_item(trans, root, path, &file_key, 893 ins_size); 894 path->leave_spinning = 0; --- 103 unchanged lines hidden (view full) --- 998 em->block_len = (u64)-1; 999 if (!new_inline && compress_type != BTRFS_COMPRESS_NONE) { 1000 set_bit(EXTENT_FLAG_COMPRESSED, &em->flags); 1001 em->compress_type = compress_type; 1002 } 1003 } else { 1004 btrfs_err(fs_info, 1005 "unknown file extent item type %d, inode %llu, offset %llu, root %llu", |
980 type, btrfs_ino(inode), extent_start, | 1006 type, btrfs_ino(BTRFS_I(inode)), extent_start, |
981 root->root_key.objectid); 982 } 983} | 1007 root->root_key.objectid); 1008 } 1009} |