aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorLi Zefan <lizf@cn.fujitsu.com>2011-04-19 22:31:50 -0400
committerLi Zefan <lizf@cn.fujitsu.com>2011-04-25 04:46:09 -0400
commit33345d01522f8152f99dc84a3e7a1a45707f387f (patch)
tree6a978702dc4421768e63501fa15bc8fedd5bff32 /fs/btrfs/inode.c
parent0414efae7989a2183fb2cc000ab285c4c2836a00 (diff)
Btrfs: Always use 64bit inode number
There's a potential problem in 32bit system when we exhaust 32bit inode numbers and start to allocate big inode numbers, because btrfs uses inode->i_ino in many places. So here we always use BTRFS_I(inode)->location.objectid, which is an u64 variable. There are 2 exceptions that BTRFS_I(inode)->location.objectid != inode->i_ino: the btree inode (0 vs 1) and empty subvol dirs (256 vs 2), and inode->i_ino will be used in those cases. Another reason to make this change is I'm going to use a special inode to save free ino cache, and the inode number must be > (u64)-256. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c197
1 files changed, 103 insertions, 94 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 77dd0a776c83..adec22884a3e 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -138,7 +138,7 @@ static noinline int insert_inline_extent(struct btrfs_trans_handle *trans,
138 path->leave_spinning = 1; 138 path->leave_spinning = 1;
139 btrfs_set_trans_block_group(trans, inode); 139 btrfs_set_trans_block_group(trans, inode);
140 140
141 key.objectid = inode->i_ino; 141 key.objectid = btrfs_ino(inode);
142 key.offset = start; 142 key.offset = start;
143 btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); 143 btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY);
144 datasize = btrfs_file_extent_calc_inline_size(cur_size); 144 datasize = btrfs_file_extent_calc_inline_size(cur_size);
@@ -1049,6 +1049,7 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1049 int nocow; 1049 int nocow;
1050 int check_prev = 1; 1050 int check_prev = 1;
1051 bool nolock = false; 1051 bool nolock = false;
1052 u64 ino = btrfs_ino(inode);
1052 1053
1053 path = btrfs_alloc_path(); 1054 path = btrfs_alloc_path();
1054 BUG_ON(!path); 1055 BUG_ON(!path);
@@ -1063,14 +1064,14 @@ static noinline int run_delalloc_nocow(struct inode *inode,
1063 cow_start = (u64)-1; 1064 cow_start = (u64)-1;
1064 cur_offset = start; 1065 cur_offset = start;
1065 while (1) { 1066 while (1) {
1066 ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, 1067 ret = btrfs_lookup_file_extent(trans, root, path, ino,
1067 cur_offset, 0); 1068 cur_offset, 0);
1068 BUG_ON(ret < 0); 1069 BUG_ON(ret < 0);
1069 if (ret > 0 && path->slots[0] > 0 && check_prev) { 1070 if (ret > 0 && path->slots[0] > 0 && check_prev) {
1070 leaf = path->nodes[0]; 1071 leaf = path->nodes[0];
1071 btrfs_item_key_to_cpu(leaf, &found_key, 1072 btrfs_item_key_to_cpu(leaf, &found_key,
1072 path->slots[0] - 1); 1073 path->slots[0] - 1);
1073 if (found_key.objectid == inode->i_ino && 1074 if (found_key.objectid == ino &&
1074 found_key.type == BTRFS_EXTENT_DATA_KEY) 1075 found_key.type == BTRFS_EXTENT_DATA_KEY)
1075 path->slots[0]--; 1076 path->slots[0]--;
1076 } 1077 }
@@ -1091,7 +1092,7 @@ next_slot:
1091 num_bytes = 0; 1092 num_bytes = 0;
1092 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 1093 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
1093 1094
1094 if (found_key.objectid > inode->i_ino || 1095 if (found_key.objectid > ino ||
1095 found_key.type > BTRFS_EXTENT_DATA_KEY || 1096 found_key.type > BTRFS_EXTENT_DATA_KEY ||
1096 found_key.offset > end) 1097 found_key.offset > end)
1097 break; 1098 break;
@@ -1126,7 +1127,7 @@ next_slot:
1126 goto out_check; 1127 goto out_check;
1127 if (btrfs_extent_readonly(root, disk_bytenr)) 1128 if (btrfs_extent_readonly(root, disk_bytenr))
1128 goto out_check; 1129 goto out_check;
1129 if (btrfs_cross_ref_exist(trans, root, inode->i_ino, 1130 if (btrfs_cross_ref_exist(trans, root, ino,
1130 found_key.offset - 1131 found_key.offset -
1131 extent_offset, disk_bytenr)) 1132 extent_offset, disk_bytenr))
1132 goto out_check; 1133 goto out_check;
@@ -1643,7 +1644,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
1643 &hint, 0); 1644 &hint, 0);
1644 BUG_ON(ret); 1645 BUG_ON(ret);
1645 1646
1646 ins.objectid = inode->i_ino; 1647 ins.objectid = btrfs_ino(inode);
1647 ins.offset = file_pos; 1648 ins.offset = file_pos;
1648 ins.type = BTRFS_EXTENT_DATA_KEY; 1649 ins.type = BTRFS_EXTENT_DATA_KEY;
1649 ret = btrfs_insert_empty_item(trans, root, path, &ins, sizeof(*fi)); 1650 ret = btrfs_insert_empty_item(trans, root, path, &ins, sizeof(*fi));
@@ -1674,7 +1675,7 @@ static int insert_reserved_file_extent(struct btrfs_trans_handle *trans,
1674 ins.type = BTRFS_EXTENT_ITEM_KEY; 1675 ins.type = BTRFS_EXTENT_ITEM_KEY;
1675 ret = btrfs_alloc_reserved_file_extent(trans, root, 1676 ret = btrfs_alloc_reserved_file_extent(trans, root,
1676 root->root_key.objectid, 1677 root->root_key.objectid,
1677 inode->i_ino, file_pos, &ins); 1678 btrfs_ino(inode), file_pos, &ins);
1678 BUG_ON(ret); 1679 BUG_ON(ret);
1679 btrfs_free_path(path); 1680 btrfs_free_path(path);
1680 1681
@@ -2004,8 +2005,9 @@ good:
2004 2005
2005zeroit: 2006zeroit:
2006 if (printk_ratelimit()) { 2007 if (printk_ratelimit()) {
2007 printk(KERN_INFO "btrfs csum failed ino %lu off %llu csum %u " 2008 printk(KERN_INFO "btrfs csum failed ino %llu off %llu csum %u "
2008 "private %llu\n", page->mapping->host->i_ino, 2009 "private %llu\n",
2010 (unsigned long long)btrfs_ino(page->mapping->host),
2009 (unsigned long long)start, csum, 2011 (unsigned long long)start, csum,
2010 (unsigned long long)private); 2012 (unsigned long long)private);
2011 } 2013 }
@@ -2243,7 +2245,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
2243 2245
2244 /* insert an orphan item to track this unlinked/truncated file */ 2246 /* insert an orphan item to track this unlinked/truncated file */
2245 if (insert >= 1) { 2247 if (insert >= 1) {
2246 ret = btrfs_insert_orphan_item(trans, root, inode->i_ino); 2248 ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
2247 BUG_ON(ret); 2249 BUG_ON(ret);
2248 } 2250 }
2249 2251
@@ -2280,7 +2282,7 @@ int btrfs_orphan_del(struct btrfs_trans_handle *trans, struct inode *inode)
2280 spin_unlock(&root->orphan_lock); 2282 spin_unlock(&root->orphan_lock);
2281 2283
2282 if (trans && delete_item) { 2284 if (trans && delete_item) {
2283 ret = btrfs_del_orphan_item(trans, root, inode->i_ino); 2285 ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode));
2284 BUG_ON(ret); 2286 BUG_ON(ret);
2285 } 2287 }
2286 2288
@@ -2542,7 +2544,8 @@ static void btrfs_read_locked_inode(struct inode *inode)
2542 * try to precache a NULL acl entry for files that don't have 2544 * try to precache a NULL acl entry for files that don't have
2543 * any xattrs or acls 2545 * any xattrs or acls
2544 */ 2546 */
2545 maybe_acls = acls_after_inode_item(leaf, path->slots[0], inode->i_ino); 2547 maybe_acls = acls_after_inode_item(leaf, path->slots[0],
2548 btrfs_ino(inode));
2546 if (!maybe_acls) 2549 if (!maybe_acls)
2547 cache_no_acl(inode); 2550 cache_no_acl(inode);
2548 2551
@@ -2688,6 +2691,8 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2688 struct btrfs_dir_item *di; 2691 struct btrfs_dir_item *di;
2689 struct btrfs_key key; 2692 struct btrfs_key key;
2690 u64 index; 2693 u64 index;
2694 u64 ino = btrfs_ino(inode);
2695 u64 dir_ino = btrfs_ino(dir);
2691 2696
2692 path = btrfs_alloc_path(); 2697 path = btrfs_alloc_path();
2693 if (!path) { 2698 if (!path) {
@@ -2696,7 +2701,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2696 } 2701 }
2697 2702
2698 path->leave_spinning = 1; 2703 path->leave_spinning = 1;
2699 di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, 2704 di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
2700 name, name_len, -1); 2705 name, name_len, -1);
2701 if (IS_ERR(di)) { 2706 if (IS_ERR(di)) {
2702 ret = PTR_ERR(di); 2707 ret = PTR_ERR(di);
@@ -2713,17 +2718,16 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2713 goto err; 2718 goto err;
2714 btrfs_release_path(root, path); 2719 btrfs_release_path(root, path);
2715 2720
2716 ret = btrfs_del_inode_ref(trans, root, name, name_len, 2721 ret = btrfs_del_inode_ref(trans, root, name, name_len, ino,
2717 inode->i_ino, 2722 dir_ino, &index);
2718 dir->i_ino, &index);
2719 if (ret) { 2723 if (ret) {
2720 printk(KERN_INFO "btrfs failed to delete reference to %.*s, " 2724 printk(KERN_INFO "btrfs failed to delete reference to %.*s, "
2721 "inode %lu parent %lu\n", name_len, name, 2725 "inode %llu parent %llu\n", name_len, name,
2722 inode->i_ino, dir->i_ino); 2726 (unsigned long long)ino, (unsigned long long)dir_ino);
2723 goto err; 2727 goto err;
2724 } 2728 }
2725 2729
2726 di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, 2730 di = btrfs_lookup_dir_index_item(trans, root, path, dir_ino,
2727 index, name, name_len, -1); 2731 index, name, name_len, -1);
2728 if (IS_ERR(di)) { 2732 if (IS_ERR(di)) {
2729 ret = PTR_ERR(di); 2733 ret = PTR_ERR(di);
@@ -2737,7 +2741,7 @@ static int __btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2737 btrfs_release_path(root, path); 2741 btrfs_release_path(root, path);
2738 2742
2739 ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len, 2743 ret = btrfs_del_inode_ref_in_log(trans, root, name, name_len,
2740 inode, dir->i_ino); 2744 inode, dir_ino);
2741 BUG_ON(ret != 0 && ret != -ENOENT); 2745 BUG_ON(ret != 0 && ret != -ENOENT);
2742 2746
2743 ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len, 2747 ret = btrfs_del_dir_entries_in_log(trans, root, name, name_len,
@@ -2815,12 +2819,14 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
2815 int check_link = 1; 2819 int check_link = 1;
2816 int err = -ENOSPC; 2820 int err = -ENOSPC;
2817 int ret; 2821 int ret;
2822 u64 ino = btrfs_ino(inode);
2823 u64 dir_ino = btrfs_ino(dir);
2818 2824
2819 trans = btrfs_start_transaction(root, 10); 2825 trans = btrfs_start_transaction(root, 10);
2820 if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) 2826 if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC)
2821 return trans; 2827 return trans;
2822 2828
2823 if (inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) 2829 if (ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
2824 return ERR_PTR(-ENOSPC); 2830 return ERR_PTR(-ENOSPC);
2825 2831
2826 /* check if there is someone else holds reference */ 2832 /* check if there is someone else holds reference */
@@ -2879,7 +2885,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
2879 2885
2880 if (ret == 0 && S_ISREG(inode->i_mode)) { 2886 if (ret == 0 && S_ISREG(inode->i_mode)) {
2881 ret = btrfs_lookup_file_extent(trans, root, path, 2887 ret = btrfs_lookup_file_extent(trans, root, path,
2882 inode->i_ino, (u64)-1, 0); 2888 ino, (u64)-1, 0);
2883 if (ret < 0) { 2889 if (ret < 0) {
2884 err = ret; 2890 err = ret;
2885 goto out; 2891 goto out;
@@ -2895,7 +2901,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
2895 goto out; 2901 goto out;
2896 } 2902 }
2897 2903
2898 di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, 2904 di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
2899 dentry->d_name.name, dentry->d_name.len, 0); 2905 dentry->d_name.name, dentry->d_name.len, 0);
2900 if (IS_ERR(di)) { 2906 if (IS_ERR(di)) {
2901 err = PTR_ERR(di); 2907 err = PTR_ERR(di);
@@ -2912,7 +2918,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
2912 2918
2913 ref = btrfs_lookup_inode_ref(trans, root, path, 2919 ref = btrfs_lookup_inode_ref(trans, root, path,
2914 dentry->d_name.name, dentry->d_name.len, 2920 dentry->d_name.name, dentry->d_name.len,
2915 inode->i_ino, dir->i_ino, 0); 2921 ino, dir_ino, 0);
2916 if (IS_ERR(ref)) { 2922 if (IS_ERR(ref)) {
2917 err = PTR_ERR(ref); 2923 err = PTR_ERR(ref);
2918 goto out; 2924 goto out;
@@ -2923,7 +2929,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir,
2923 index = btrfs_inode_ref_index(path->nodes[0], ref); 2929 index = btrfs_inode_ref_index(path->nodes[0], ref);
2924 btrfs_release_path(root, path); 2930 btrfs_release_path(root, path);
2925 2931
2926 di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, index, 2932 di = btrfs_lookup_dir_index_item(trans, root, path, dir_ino, index,
2927 dentry->d_name.name, dentry->d_name.len, 0); 2933 dentry->d_name.name, dentry->d_name.len, 0);
2928 if (IS_ERR(di)) { 2934 if (IS_ERR(di)) {
2929 err = PTR_ERR(di); 2935 err = PTR_ERR(di);
@@ -2998,12 +3004,13 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
2998 struct btrfs_key key; 3004 struct btrfs_key key;
2999 u64 index; 3005 u64 index;
3000 int ret; 3006 int ret;
3007 u64 dir_ino = btrfs_ino(dir);
3001 3008
3002 path = btrfs_alloc_path(); 3009 path = btrfs_alloc_path();
3003 if (!path) 3010 if (!path)
3004 return -ENOMEM; 3011 return -ENOMEM;
3005 3012
3006 di = btrfs_lookup_dir_item(trans, root, path, dir->i_ino, 3013 di = btrfs_lookup_dir_item(trans, root, path, dir_ino,
3007 name, name_len, -1); 3014 name, name_len, -1);
3008 BUG_ON(!di || IS_ERR(di)); 3015 BUG_ON(!di || IS_ERR(di));
3009 3016
@@ -3016,10 +3023,10 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
3016 3023
3017 ret = btrfs_del_root_ref(trans, root->fs_info->tree_root, 3024 ret = btrfs_del_root_ref(trans, root->fs_info->tree_root,
3018 objectid, root->root_key.objectid, 3025 objectid, root->root_key.objectid,
3019 dir->i_ino, &index, name, name_len); 3026 dir_ino, &index, name, name_len);
3020 if (ret < 0) { 3027 if (ret < 0) {
3021 BUG_ON(ret != -ENOENT); 3028 BUG_ON(ret != -ENOENT);
3022 di = btrfs_search_dir_index_item(root, path, dir->i_ino, 3029 di = btrfs_search_dir_index_item(root, path, dir_ino,
3023 name, name_len); 3030 name, name_len);
3024 BUG_ON(!di || IS_ERR(di)); 3031 BUG_ON(!di || IS_ERR(di));
3025 3032
@@ -3029,7 +3036,7 @@ int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
3029 index = key.offset; 3036 index = key.offset;
3030 } 3037 }
3031 3038
3032 di = btrfs_lookup_dir_index_item(trans, root, path, dir->i_ino, 3039 di = btrfs_lookup_dir_index_item(trans, root, path, dir_ino,
3033 index, name, name_len, -1); 3040 index, name, name_len, -1);
3034 BUG_ON(!di || IS_ERR(di)); 3041 BUG_ON(!di || IS_ERR(di));
3035 3042
@@ -3058,7 +3065,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
3058 unsigned long nr = 0; 3065 unsigned long nr = 0;
3059 3066
3060 if (inode->i_size > BTRFS_EMPTY_DIR_SIZE || 3067 if (inode->i_size > BTRFS_EMPTY_DIR_SIZE ||
3061 inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) 3068 btrfs_ino(inode) == BTRFS_FIRST_FREE_OBJECTID)
3062 return -ENOTEMPTY; 3069 return -ENOTEMPTY;
3063 3070
3064 trans = __unlink_start_trans(dir, dentry); 3071 trans = __unlink_start_trans(dir, dentry);
@@ -3067,7 +3074,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
3067 3074
3068 btrfs_set_trans_block_group(trans, dir); 3075 btrfs_set_trans_block_group(trans, dir);
3069 3076
3070 if (unlikely(inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 3077 if (unlikely(btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
3071 err = btrfs_unlink_subvol(trans, root, dir, 3078 err = btrfs_unlink_subvol(trans, root, dir,
3072 BTRFS_I(inode)->location.objectid, 3079 BTRFS_I(inode)->location.objectid,
3073 dentry->d_name.name, 3080 dentry->d_name.name,
@@ -3299,6 +3306,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
3299 int encoding; 3306 int encoding;
3300 int ret; 3307 int ret;
3301 int err = 0; 3308 int err = 0;
3309 u64 ino = btrfs_ino(inode);
3302 3310
3303 BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY); 3311 BUG_ON(new_size > 0 && min_type != BTRFS_EXTENT_DATA_KEY);
3304 3312
@@ -3309,7 +3317,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
3309 BUG_ON(!path); 3317 BUG_ON(!path);
3310 path->reada = -1; 3318 path->reada = -1;
3311 3319
3312 key.objectid = inode->i_ino; 3320 key.objectid = ino;
3313 key.offset = (u64)-1; 3321 key.offset = (u64)-1;
3314 key.type = (u8)-1; 3322 key.type = (u8)-1;
3315 3323
@@ -3337,7 +3345,7 @@ search_again:
3337 found_type = btrfs_key_type(&found_key); 3345 found_type = btrfs_key_type(&found_key);
3338 encoding = 0; 3346 encoding = 0;
3339 3347
3340 if (found_key.objectid != inode->i_ino) 3348 if (found_key.objectid != ino)
3341 break; 3349 break;
3342 3350
3343 if (found_type < min_type) 3351 if (found_type < min_type)
@@ -3456,7 +3464,7 @@ delete:
3456 ret = btrfs_free_extent(trans, root, extent_start, 3464 ret = btrfs_free_extent(trans, root, extent_start,
3457 extent_num_bytes, 0, 3465 extent_num_bytes, 0,
3458 btrfs_header_owner(leaf), 3466 btrfs_header_owner(leaf),
3459 inode->i_ino, extent_offset); 3467 ino, extent_offset);
3460 BUG_ON(ret); 3468 BUG_ON(ret);
3461 } 3469 }
3462 3470
@@ -3655,7 +3663,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
3655 break; 3663 break;
3656 3664
3657 err = btrfs_insert_file_extent(trans, root, 3665 err = btrfs_insert_file_extent(trans, root,
3658 inode->i_ino, cur_offset, 0, 3666 btrfs_ino(inode), cur_offset, 0,
3659 0, hole_size, 0, hole_size, 3667 0, hole_size, 0, hole_size,
3660 0, 0, 0); 3668 0, 0, 0);
3661 if (err) 3669 if (err)
@@ -3812,7 +3820,7 @@ void btrfs_evict_inode(struct inode *inode)
3812 3820
3813 if (!(root == root->fs_info->tree_root || 3821 if (!(root == root->fs_info->tree_root ||
3814 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)) 3822 root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID))
3815 btrfs_return_ino(root, inode->i_ino); 3823 btrfs_return_ino(root, btrfs_ino(inode));
3816 3824
3817 nr = trans->blocks_used; 3825 nr = trans->blocks_used;
3818 btrfs_end_transaction(trans, root); 3826 btrfs_end_transaction(trans, root);
@@ -3839,7 +3847,7 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
3839 path = btrfs_alloc_path(); 3847 path = btrfs_alloc_path();
3840 BUG_ON(!path); 3848 BUG_ON(!path);
3841 3849
3842 di = btrfs_lookup_dir_item(NULL, root, path, dir->i_ino, name, 3850 di = btrfs_lookup_dir_item(NULL, root, path, btrfs_ino(dir), name,
3843 namelen, 0); 3851 namelen, 0);
3844 if (IS_ERR(di)) 3852 if (IS_ERR(di))
3845 ret = PTR_ERR(di); 3853 ret = PTR_ERR(di);
@@ -3892,7 +3900,7 @@ static int fixup_tree_root_location(struct btrfs_root *root,
3892 3900
3893 leaf = path->nodes[0]; 3901 leaf = path->nodes[0];
3894 ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref); 3902 ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);
3895 if (btrfs_root_ref_dirid(leaf, ref) != dir->i_ino || 3903 if (btrfs_root_ref_dirid(leaf, ref) != btrfs_ino(dir) ||
3896 btrfs_root_ref_name_len(leaf, ref) != dentry->d_name.len) 3904 btrfs_root_ref_name_len(leaf, ref) != dentry->d_name.len)
3897 goto out; 3905 goto out;
3898 3906
@@ -3931,6 +3939,7 @@ static void inode_tree_add(struct inode *inode)
3931 struct btrfs_inode *entry; 3939 struct btrfs_inode *entry;
3932 struct rb_node **p; 3940 struct rb_node **p;
3933 struct rb_node *parent; 3941 struct rb_node *parent;
3942 u64 ino = btrfs_ino(inode);
3934again: 3943again:
3935 p = &root->inode_tree.rb_node; 3944 p = &root->inode_tree.rb_node;
3936 parent = NULL; 3945 parent = NULL;
@@ -3943,9 +3952,9 @@ again:
3943 parent = *p; 3952 parent = *p;
3944 entry = rb_entry(parent, struct btrfs_inode, rb_node); 3953 entry = rb_entry(parent, struct btrfs_inode, rb_node);
3945 3954
3946 if (inode->i_ino < entry->vfs_inode.i_ino) 3955 if (ino < btrfs_ino(&entry->vfs_inode))
3947 p = &parent->rb_left; 3956 p = &parent->rb_left;
3948 else if (inode->i_ino > entry->vfs_inode.i_ino) 3957 else if (ino > btrfs_ino(&entry->vfs_inode))
3949 p = &parent->rb_right; 3958 p = &parent->rb_right;
3950 else { 3959 else {
3951 WARN_ON(!(entry->vfs_inode.i_state & 3960 WARN_ON(!(entry->vfs_inode.i_state &
@@ -4009,9 +4018,9 @@ again:
4009 prev = node; 4018 prev = node;
4010 entry = rb_entry(node, struct btrfs_inode, rb_node); 4019 entry = rb_entry(node, struct btrfs_inode, rb_node);
4011 4020
4012 if (objectid < entry->vfs_inode.i_ino) 4021 if (objectid < btrfs_ino(&entry->vfs_inode))
4013 node = node->rb_left; 4022 node = node->rb_left;
4014 else if (objectid > entry->vfs_inode.i_ino) 4023 else if (objectid > btrfs_ino(&entry->vfs_inode))
4015 node = node->rb_right; 4024 node = node->rb_right;
4016 else 4025 else
4017 break; 4026 break;
@@ -4019,7 +4028,7 @@ again:
4019 if (!node) { 4028 if (!node) {
4020 while (prev) { 4029 while (prev) {
4021 entry = rb_entry(prev, struct btrfs_inode, rb_node); 4030 entry = rb_entry(prev, struct btrfs_inode, rb_node);
4022 if (objectid <= entry->vfs_inode.i_ino) { 4031 if (objectid <= btrfs_ino(&entry->vfs_inode)) {
4023 node = prev; 4032 node = prev;
4024 break; 4033 break;
4025 } 4034 }
@@ -4028,7 +4037,7 @@ again:
4028 } 4037 }
4029 while (node) { 4038 while (node) {
4030 entry = rb_entry(node, struct btrfs_inode, rb_node); 4039 entry = rb_entry(node, struct btrfs_inode, rb_node);
4031 objectid = entry->vfs_inode.i_ino + 1; 4040 objectid = btrfs_ino(&entry->vfs_inode) + 1;
4032 inode = igrab(&entry->vfs_inode); 4041 inode = igrab(&entry->vfs_inode);
4033 if (inode) { 4042 if (inode) {
4034 spin_unlock(&root->inode_lock); 4043 spin_unlock(&root->inode_lock);
@@ -4066,7 +4075,7 @@ static int btrfs_init_locked_inode(struct inode *inode, void *p)
4066static int btrfs_find_actor(struct inode *inode, void *opaque) 4075static int btrfs_find_actor(struct inode *inode, void *opaque)
4067{ 4076{
4068 struct btrfs_iget_args *args = opaque; 4077 struct btrfs_iget_args *args = opaque;
4069 return args->ino == inode->i_ino && 4078 return args->ino == btrfs_ino(inode) &&
4070 args->root == BTRFS_I(inode)->root; 4079 args->root == BTRFS_I(inode)->root;
4071} 4080}
4072 4081
@@ -4244,9 +4253,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
4244 4253
4245 /* special case for "." */ 4254 /* special case for "." */
4246 if (filp->f_pos == 0) { 4255 if (filp->f_pos == 0) {
4247 over = filldir(dirent, ".", 1, 4256 over = filldir(dirent, ".", 1, 1, btrfs_ino(inode), DT_DIR);
4248 1, inode->i_ino,
4249 DT_DIR);
4250 if (over) 4257 if (over)
4251 return 0; 4258 return 0;
4252 filp->f_pos = 1; 4259 filp->f_pos = 1;
@@ -4265,7 +4272,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
4265 4272
4266 btrfs_set_key_type(&key, key_type); 4273 btrfs_set_key_type(&key, key_type);
4267 key.offset = filp->f_pos; 4274 key.offset = filp->f_pos;
4268 key.objectid = inode->i_ino; 4275 key.objectid = btrfs_ino(inode);
4269 4276
4270 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 4277 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
4271 if (ret < 0) 4278 if (ret < 0)
@@ -4420,8 +4427,9 @@ void btrfs_dirty_inode(struct inode *inode)
4420 if (IS_ERR(trans)) { 4427 if (IS_ERR(trans)) {
4421 if (printk_ratelimit()) { 4428 if (printk_ratelimit()) {
4422 printk(KERN_ERR "btrfs: fail to " 4429 printk(KERN_ERR "btrfs: fail to "
4423 "dirty inode %lu error %ld\n", 4430 "dirty inode %llu error %ld\n",
4424 inode->i_ino, PTR_ERR(trans)); 4431 (unsigned long long)btrfs_ino(inode),
4432 PTR_ERR(trans));
4425 } 4433 }
4426 return; 4434 return;
4427 } 4435 }
@@ -4431,8 +4439,9 @@ void btrfs_dirty_inode(struct inode *inode)
4431 if (ret) { 4439 if (ret) {
4432 if (printk_ratelimit()) { 4440 if (printk_ratelimit()) {
4433 printk(KERN_ERR "btrfs: fail to " 4441 printk(KERN_ERR "btrfs: fail to "
4434 "dirty inode %lu error %d\n", 4442 "dirty inode %llu error %d\n",
4435 inode->i_ino, ret); 4443 (unsigned long long)btrfs_ino(inode),
4444 ret);
4436 } 4445 }
4437 } 4446 }
4438 } 4447 }
@@ -4452,7 +4461,7 @@ static int btrfs_set_inode_index_count(struct inode *inode)
4452 struct extent_buffer *leaf; 4461 struct extent_buffer *leaf;
4453 int ret; 4462 int ret;
4454 4463
4455 key.objectid = inode->i_ino; 4464 key.objectid = btrfs_ino(inode);
4456 btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY); 4465 btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
4457 key.offset = (u64)-1; 4466 key.offset = (u64)-1;
4458 4467
@@ -4484,7 +4493,7 @@ static int btrfs_set_inode_index_count(struct inode *inode)
4484 leaf = path->nodes[0]; 4493 leaf = path->nodes[0];
4485 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 4494 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
4486 4495
4487 if (found_key.objectid != inode->i_ino || 4496 if (found_key.objectid != btrfs_ino(inode) ||
4488 btrfs_key_type(&found_key) != BTRFS_DIR_INDEX_KEY) { 4497 btrfs_key_type(&found_key) != BTRFS_DIR_INDEX_KEY) {
4489 BTRFS_I(inode)->index_cnt = 2; 4498 BTRFS_I(inode)->index_cnt = 2;
4490 goto out; 4499 goto out;
@@ -4657,29 +4666,29 @@ int btrfs_add_link(struct btrfs_trans_handle *trans,
4657 int ret = 0; 4666 int ret = 0;
4658 struct btrfs_key key; 4667 struct btrfs_key key;
4659 struct btrfs_root *root = BTRFS_I(parent_inode)->root; 4668 struct btrfs_root *root = BTRFS_I(parent_inode)->root;
4669 u64 ino = btrfs_ino(inode);
4670 u64 parent_ino = btrfs_ino(parent_inode);
4660 4671
4661 if (unlikely(inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { 4672 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
4662 memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key)); 4673 memcpy(&key, &BTRFS_I(inode)->root->root_key, sizeof(key));
4663 } else { 4674 } else {
4664 key.objectid = inode->i_ino; 4675 key.objectid = ino;
4665 btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY); 4676 btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
4666 key.offset = 0; 4677 key.offset = 0;
4667 } 4678 }
4668 4679
4669 if (unlikely(inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { 4680 if (unlikely(ino == BTRFS_FIRST_FREE_OBJECTID)) {
4670 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, 4681 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root,
4671 key.objectid, root->root_key.objectid, 4682 key.objectid, root->root_key.objectid,
4672 parent_inode->i_ino, 4683 parent_ino, index, name, name_len);
4673 index, name, name_len);
4674 } else if (add_backref) { 4684 } else if (add_backref) {
4675 ret = btrfs_insert_inode_ref(trans, root, 4685 ret = btrfs_insert_inode_ref(trans, root, name, name_len, ino,
4676 name, name_len, inode->i_ino, 4686 parent_ino, index);
4677 parent_inode->i_ino, index);
4678 } 4687 }
4679 4688
4680 if (ret == 0) { 4689 if (ret == 0) {
4681 ret = btrfs_insert_dir_item(trans, root, name, name_len, 4690 ret = btrfs_insert_dir_item(trans, root, name, name_len,
4682 parent_inode->i_ino, &key, 4691 parent_ino, &key,
4683 btrfs_inode_type(inode), index); 4692 btrfs_inode_type(inode), index);
4684 BUG_ON(ret); 4693 BUG_ON(ret);
4685 4694
@@ -4738,7 +4747,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
4738 goto out_unlock; 4747 goto out_unlock;
4739 4748
4740 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4749 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4741 dentry->d_name.len, dir->i_ino, objectid, 4750 dentry->d_name.len, btrfs_ino(dir), objectid,
4742 BTRFS_I(dir)->block_group, mode, &index); 4751 BTRFS_I(dir)->block_group, mode, &index);
4743 err = PTR_ERR(inode); 4752 err = PTR_ERR(inode);
4744 if (IS_ERR(inode)) 4753 if (IS_ERR(inode))
@@ -4800,7 +4809,7 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
4800 goto out_unlock; 4809 goto out_unlock;
4801 4810
4802 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4811 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4803 dentry->d_name.len, dir->i_ino, objectid, 4812 dentry->d_name.len, btrfs_ino(dir), objectid,
4804 BTRFS_I(dir)->block_group, mode, &index); 4813 BTRFS_I(dir)->block_group, mode, &index);
4805 err = PTR_ERR(inode); 4814 err = PTR_ERR(inode);
4806 if (IS_ERR(inode)) 4815 if (IS_ERR(inode))
@@ -4928,7 +4937,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
4928 goto out_fail; 4937 goto out_fail;
4929 4938
4930 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 4939 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
4931 dentry->d_name.len, dir->i_ino, objectid, 4940 dentry->d_name.len, btrfs_ino(dir), objectid,
4932 BTRFS_I(dir)->block_group, S_IFDIR | mode, 4941 BTRFS_I(dir)->block_group, S_IFDIR | mode,
4933 &index); 4942 &index);
4934 if (IS_ERR(inode)) { 4943 if (IS_ERR(inode)) {
@@ -5049,7 +5058,7 @@ struct extent_map *btrfs_get_extent(struct inode *inode, struct page *page,
5049 u64 bytenr; 5058 u64 bytenr;
5050 u64 extent_start = 0; 5059 u64 extent_start = 0;
5051 u64 extent_end = 0; 5060 u64 extent_end = 0;
5052 u64 objectid = inode->i_ino; 5061 u64 objectid = btrfs_ino(inode);
5053 u32 found_type; 5062 u32 found_type;
5054 struct btrfs_path *path = NULL; 5063 struct btrfs_path *path = NULL;
5055 struct btrfs_root *root = BTRFS_I(inode)->root; 5064 struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -5557,7 +5566,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5557 if (!path) 5566 if (!path)
5558 return -ENOMEM; 5567 return -ENOMEM;
5559 5568
5560 ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, 5569 ret = btrfs_lookup_file_extent(trans, root, path, btrfs_ino(inode),
5561 offset, 0); 5570 offset, 0);
5562 if (ret < 0) 5571 if (ret < 0)
5563 goto out; 5572 goto out;
@@ -5574,7 +5583,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5574 ret = 0; 5583 ret = 0;
5575 leaf = path->nodes[0]; 5584 leaf = path->nodes[0];
5576 btrfs_item_key_to_cpu(leaf, &key, slot); 5585 btrfs_item_key_to_cpu(leaf, &key, slot);
5577 if (key.objectid != inode->i_ino || 5586 if (key.objectid != btrfs_ino(inode) ||
5578 key.type != BTRFS_EXTENT_DATA_KEY) { 5587 key.type != BTRFS_EXTENT_DATA_KEY) {
5579 /* not our file or wrong item type, must cow */ 5588 /* not our file or wrong item type, must cow */
5580 goto out; 5589 goto out;
@@ -5608,7 +5617,7 @@ static noinline int can_nocow_odirect(struct btrfs_trans_handle *trans,
5608 * look for other files referencing this extent, if we 5617 * look for other files referencing this extent, if we
5609 * find any we must cow 5618 * find any we must cow
5610 */ 5619 */
5611 if (btrfs_cross_ref_exist(trans, root, inode->i_ino, 5620 if (btrfs_cross_ref_exist(trans, root, btrfs_ino(inode),
5612 key.offset - backref_offset, disk_bytenr)) 5621 key.offset - backref_offset, disk_bytenr))
5613 goto out; 5622 goto out;
5614 5623
@@ -5798,9 +5807,10 @@ static void btrfs_endio_direct_read(struct bio *bio, int err)
5798 5807
5799 flush_dcache_page(bvec->bv_page); 5808 flush_dcache_page(bvec->bv_page);
5800 if (csum != *private) { 5809 if (csum != *private) {
5801 printk(KERN_ERR "btrfs csum failed ino %lu off" 5810 printk(KERN_ERR "btrfs csum failed ino %llu off"
5802 " %llu csum %u private %u\n", 5811 " %llu csum %u private %u\n",
5803 inode->i_ino, (unsigned long long)start, 5812 (unsigned long long)btrfs_ino(inode),
5813 (unsigned long long)start,
5804 csum, *private); 5814 csum, *private);
5805 err = -EIO; 5815 err = -EIO;
5806 } 5816 }
@@ -5947,9 +5957,9 @@ static void btrfs_end_dio_bio(struct bio *bio, int err)
5947 struct btrfs_dio_private *dip = bio->bi_private; 5957 struct btrfs_dio_private *dip = bio->bi_private;
5948 5958
5949 if (err) { 5959 if (err) {
5950 printk(KERN_ERR "btrfs direct IO failed ino %lu rw %lu " 5960 printk(KERN_ERR "btrfs direct IO failed ino %llu rw %lu "
5951 "sector %#Lx len %u err no %d\n", 5961 "sector %#Lx len %u err no %d\n",
5952 dip->inode->i_ino, bio->bi_rw, 5962 (unsigned long long)btrfs_ino(dip->inode), bio->bi_rw,
5953 (unsigned long long)bio->bi_sector, bio->bi_size, err); 5963 (unsigned long long)bio->bi_sector, bio->bi_size, err);
5954 dip->errors = 1; 5964 dip->errors = 1;
5955 5965
@@ -6859,8 +6869,8 @@ void btrfs_destroy_inode(struct inode *inode)
6859 6869
6860 spin_lock(&root->orphan_lock); 6870 spin_lock(&root->orphan_lock);
6861 if (!list_empty(&BTRFS_I(inode)->i_orphan)) { 6871 if (!list_empty(&BTRFS_I(inode)->i_orphan)) {
6862 printk(KERN_INFO "BTRFS: inode %lu still on the orphan list\n", 6872 printk(KERN_INFO "BTRFS: inode %llu still on the orphan list\n",
6863 inode->i_ino); 6873 (unsigned long long)btrfs_ino(inode));
6864 list_del_init(&BTRFS_I(inode)->i_orphan); 6874 list_del_init(&BTRFS_I(inode)->i_orphan);
6865 } 6875 }
6866 spin_unlock(&root->orphan_lock); 6876 spin_unlock(&root->orphan_lock);
@@ -6999,16 +7009,17 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
6999 u64 index = 0; 7009 u64 index = 0;
7000 u64 root_objectid; 7010 u64 root_objectid;
7001 int ret; 7011 int ret;
7012 u64 old_ino = btrfs_ino(old_inode);
7002 7013
7003 if (new_dir->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) 7014 if (btrfs_ino(new_dir) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)
7004 return -EPERM; 7015 return -EPERM;
7005 7016
7006 /* we only allow rename subvolume link between subvolumes */ 7017 /* we only allow rename subvolume link between subvolumes */
7007 if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest) 7018 if (old_ino != BTRFS_FIRST_FREE_OBJECTID && root != dest)
7008 return -EXDEV; 7019 return -EXDEV;
7009 7020
7010 if (old_inode->i_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID || 7021 if (old_ino == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID ||
7011 (new_inode && new_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) 7022 (new_inode && btrfs_ino(new_inode) == BTRFS_FIRST_FREE_OBJECTID))
7012 return -ENOTEMPTY; 7023 return -ENOTEMPTY;
7013 7024
7014 if (S_ISDIR(old_inode->i_mode) && new_inode && 7025 if (S_ISDIR(old_inode->i_mode) && new_inode &&
@@ -7024,7 +7035,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7024 filemap_flush(old_inode->i_mapping); 7035 filemap_flush(old_inode->i_mapping);
7025 7036
7026 /* close the racy window with snapshot create/destroy ioctl */ 7037 /* close the racy window with snapshot create/destroy ioctl */
7027 if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) 7038 if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
7028 down_read(&root->fs_info->subvol_sem); 7039 down_read(&root->fs_info->subvol_sem);
7029 /* 7040 /*
7030 * We want to reserve the absolute worst case amount of items. So if 7041 * We want to reserve the absolute worst case amount of items. So if
@@ -7049,15 +7060,15 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7049 if (ret) 7060 if (ret)
7050 goto out_fail; 7061 goto out_fail;
7051 7062
7052 if (unlikely(old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { 7063 if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
7053 /* force full log commit if subvolume involved. */ 7064 /* force full log commit if subvolume involved. */
7054 root->fs_info->last_trans_log_full_commit = trans->transid; 7065 root->fs_info->last_trans_log_full_commit = trans->transid;
7055 } else { 7066 } else {
7056 ret = btrfs_insert_inode_ref(trans, dest, 7067 ret = btrfs_insert_inode_ref(trans, dest,
7057 new_dentry->d_name.name, 7068 new_dentry->d_name.name,
7058 new_dentry->d_name.len, 7069 new_dentry->d_name.len,
7059 old_inode->i_ino, 7070 old_ino,
7060 new_dir->i_ino, index); 7071 btrfs_ino(new_dir), index);
7061 if (ret) 7072 if (ret)
7062 goto out_fail; 7073 goto out_fail;
7063 /* 7074 /*
@@ -7073,10 +7084,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7073 * make sure the inode gets flushed if it is replacing 7084 * make sure the inode gets flushed if it is replacing
7074 * something. 7085 * something.
7075 */ 7086 */
7076 if (new_inode && new_inode->i_size && 7087 if (new_inode && new_inode->i_size && S_ISREG(old_inode->i_mode))
7077 old_inode && S_ISREG(old_inode->i_mode)) {
7078 btrfs_add_ordered_operation(trans, root, old_inode); 7088 btrfs_add_ordered_operation(trans, root, old_inode);
7079 }
7080 7089
7081 old_dir->i_ctime = old_dir->i_mtime = ctime; 7090 old_dir->i_ctime = old_dir->i_mtime = ctime;
7082 new_dir->i_ctime = new_dir->i_mtime = ctime; 7091 new_dir->i_ctime = new_dir->i_mtime = ctime;
@@ -7085,7 +7094,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7085 if (old_dentry->d_parent != new_dentry->d_parent) 7094 if (old_dentry->d_parent != new_dentry->d_parent)
7086 btrfs_record_unlink_dir(trans, old_dir, old_inode, 1); 7095 btrfs_record_unlink_dir(trans, old_dir, old_inode, 1);
7087 7096
7088 if (unlikely(old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID)) { 7097 if (unlikely(old_ino == BTRFS_FIRST_FREE_OBJECTID)) {
7089 root_objectid = BTRFS_I(old_inode)->root->root_key.objectid; 7098 root_objectid = BTRFS_I(old_inode)->root->root_key.objectid;
7090 ret = btrfs_unlink_subvol(trans, root, old_dir, root_objectid, 7099 ret = btrfs_unlink_subvol(trans, root, old_dir, root_objectid,
7091 old_dentry->d_name.name, 7100 old_dentry->d_name.name,
@@ -7102,7 +7111,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7102 7111
7103 if (new_inode) { 7112 if (new_inode) {
7104 new_inode->i_ctime = CURRENT_TIME; 7113 new_inode->i_ctime = CURRENT_TIME;
7105 if (unlikely(new_inode->i_ino == 7114 if (unlikely(btrfs_ino(new_inode) ==
7106 BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) { 7115 BTRFS_EMPTY_SUBVOL_DIR_OBJECTID)) {
7107 root_objectid = BTRFS_I(new_inode)->location.objectid; 7116 root_objectid = BTRFS_I(new_inode)->location.objectid;
7108 ret = btrfs_unlink_subvol(trans, dest, new_dir, 7117 ret = btrfs_unlink_subvol(trans, dest, new_dir,
@@ -7130,7 +7139,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7130 new_dentry->d_name.len, 0, index); 7139 new_dentry->d_name.len, 0, index);
7131 BUG_ON(ret); 7140 BUG_ON(ret);
7132 7141
7133 if (old_inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { 7142 if (old_ino != BTRFS_FIRST_FREE_OBJECTID) {
7134 struct dentry *parent = dget_parent(new_dentry); 7143 struct dentry *parent = dget_parent(new_dentry);
7135 btrfs_log_new_name(trans, old_inode, old_dir, parent); 7144 btrfs_log_new_name(trans, old_inode, old_dir, parent);
7136 dput(parent); 7145 dput(parent);
@@ -7139,7 +7148,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
7139out_fail: 7148out_fail:
7140 btrfs_end_transaction_throttle(trans, root); 7149 btrfs_end_transaction_throttle(trans, root);
7141out_notrans: 7150out_notrans:
7142 if (old_inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) 7151 if (old_ino == BTRFS_FIRST_FREE_OBJECTID)
7143 up_read(&root->fs_info->subvol_sem); 7152 up_read(&root->fs_info->subvol_sem);
7144 7153
7145 return ret; 7154 return ret;
@@ -7284,7 +7293,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
7284 goto out_unlock; 7293 goto out_unlock;
7285 7294
7286 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name, 7295 inode = btrfs_new_inode(trans, root, dir, dentry->d_name.name,
7287 dentry->d_name.len, dir->i_ino, objectid, 7296 dentry->d_name.len, btrfs_ino(dir), objectid,
7288 BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO, 7297 BTRFS_I(dir)->block_group, S_IFLNK|S_IRWXUGO,
7289 &index); 7298 &index);
7290 err = PTR_ERR(inode); 7299 err = PTR_ERR(inode);
@@ -7315,7 +7324,7 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
7315 7324
7316 path = btrfs_alloc_path(); 7325 path = btrfs_alloc_path();
7317 BUG_ON(!path); 7326 BUG_ON(!path);
7318 key.objectid = inode->i_ino; 7327 key.objectid = btrfs_ino(inode);
7319 key.offset = 0; 7328 key.offset = 0;
7320 btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY); 7329 btrfs_set_key_type(&key, BTRFS_EXTENT_DATA_KEY);
7321 datasize = btrfs_file_extent_calc_inline_size(name_len); 7330 datasize = btrfs_file_extent_calc_inline_size(name_len);