diff options
author | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-19 22:31:50 -0400 |
---|---|---|
committer | Li Zefan <lizf@cn.fujitsu.com> | 2011-04-25 04:46:09 -0400 |
commit | 33345d01522f8152f99dc84a3e7a1a45707f387f (patch) | |
tree | 6a978702dc4421768e63501fa15bc8fedd5bff32 | |
parent | 0414efae7989a2183fb2cc000ab285c4c2836a00 (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>
-rw-r--r-- | fs/btrfs/btrfs_inode.h | 9 | ||||
-rw-r--r-- | fs/btrfs/compression.c | 5 | ||||
-rw-r--r-- | fs/btrfs/export.c | 25 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 10 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 4 | ||||
-rw-r--r-- | fs/btrfs/file-item.c | 5 | ||||
-rw-r--r-- | fs/btrfs/file.c | 27 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 197 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 18 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 24 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 4 | ||||
-rw-r--r-- | fs/btrfs/tree-log.c | 54 | ||||
-rw-r--r-- | fs/btrfs/xattr.c | 8 |
13 files changed, 208 insertions, 182 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h index 57c3bb2884ce..8842a4195f91 100644 --- a/fs/btrfs/btrfs_inode.h +++ b/fs/btrfs/btrfs_inode.h | |||
@@ -166,6 +166,15 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode) | |||
166 | return container_of(inode, struct btrfs_inode, vfs_inode); | 166 | return container_of(inode, struct btrfs_inode, vfs_inode); |
167 | } | 167 | } |
168 | 168 | ||
169 | static inline u64 btrfs_ino(struct inode *inode) | ||
170 | { | ||
171 | u64 ino = BTRFS_I(inode)->location.objectid; | ||
172 | |||
173 | if (ino <= BTRFS_FIRST_FREE_OBJECTID) | ||
174 | ino = inode->i_ino; | ||
175 | return ino; | ||
176 | } | ||
177 | |||
169 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) | 178 | static inline void btrfs_i_size_write(struct inode *inode, u64 size) |
170 | { | 179 | { |
171 | i_size_write(inode, size); | 180 | i_size_write(inode, size); |
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index 41d1d7c70e29..369d5068ac7a 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -125,9 +125,10 @@ static int check_compressed_csum(struct inode *inode, | |||
125 | kunmap_atomic(kaddr, KM_USER0); | 125 | kunmap_atomic(kaddr, KM_USER0); |
126 | 126 | ||
127 | if (csum != *cb_sum) { | 127 | if (csum != *cb_sum) { |
128 | printk(KERN_INFO "btrfs csum failed ino %lu " | 128 | printk(KERN_INFO "btrfs csum failed ino %llu " |
129 | "extent %llu csum %u " | 129 | "extent %llu csum %u " |
130 | "wanted %u mirror %d\n", inode->i_ino, | 130 | "wanted %u mirror %d\n", |
131 | (unsigned long long)btrfs_ino(inode), | ||
131 | (unsigned long long)disk_start, | 132 | (unsigned long long)disk_start, |
132 | csum, *cb_sum, cb->mirror_num); | 133 | csum, *cb_sum, cb->mirror_num); |
133 | ret = -EIO; | 134 | ret = -EIO; |
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index ff27d7a477b2..7fa283e7d306 100644 --- a/fs/btrfs/export.c +++ b/fs/btrfs/export.c | |||
@@ -28,7 +28,7 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, | |||
28 | len = BTRFS_FID_SIZE_NON_CONNECTABLE; | 28 | len = BTRFS_FID_SIZE_NON_CONNECTABLE; |
29 | type = FILEID_BTRFS_WITHOUT_PARENT; | 29 | type = FILEID_BTRFS_WITHOUT_PARENT; |
30 | 30 | ||
31 | fid->objectid = inode->i_ino; | 31 | fid->objectid = btrfs_ino(inode); |
32 | fid->root_objectid = BTRFS_I(inode)->root->objectid; | 32 | fid->root_objectid = BTRFS_I(inode)->root->objectid; |
33 | fid->gen = inode->i_generation; | 33 | fid->gen = inode->i_generation; |
34 | 34 | ||
@@ -174,13 +174,13 @@ static struct dentry *btrfs_get_parent(struct dentry *child) | |||
174 | if (!path) | 174 | if (!path) |
175 | return ERR_PTR(-ENOMEM); | 175 | return ERR_PTR(-ENOMEM); |
176 | 176 | ||
177 | if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 177 | if (btrfs_ino(dir) == BTRFS_FIRST_FREE_OBJECTID) { |
178 | key.objectid = root->root_key.objectid; | 178 | key.objectid = root->root_key.objectid; |
179 | key.type = BTRFS_ROOT_BACKREF_KEY; | 179 | key.type = BTRFS_ROOT_BACKREF_KEY; |
180 | key.offset = (u64)-1; | 180 | key.offset = (u64)-1; |
181 | root = root->fs_info->tree_root; | 181 | root = root->fs_info->tree_root; |
182 | } else { | 182 | } else { |
183 | key.objectid = dir->i_ino; | 183 | key.objectid = btrfs_ino(dir); |
184 | key.type = BTRFS_INODE_REF_KEY; | 184 | key.type = BTRFS_INODE_REF_KEY; |
185 | key.offset = (u64)-1; | 185 | key.offset = (u64)-1; |
186 | } | 186 | } |
@@ -240,6 +240,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
240 | struct btrfs_key key; | 240 | struct btrfs_key key; |
241 | int name_len; | 241 | int name_len; |
242 | int ret; | 242 | int ret; |
243 | u64 ino; | ||
243 | 244 | ||
244 | if (!dir || !inode) | 245 | if (!dir || !inode) |
245 | return -EINVAL; | 246 | return -EINVAL; |
@@ -247,19 +248,21 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
247 | if (!S_ISDIR(dir->i_mode)) | 248 | if (!S_ISDIR(dir->i_mode)) |
248 | return -EINVAL; | 249 | return -EINVAL; |
249 | 250 | ||
251 | ino = btrfs_ino(inode); | ||
252 | |||
250 | path = btrfs_alloc_path(); | 253 | path = btrfs_alloc_path(); |
251 | if (!path) | 254 | if (!path) |
252 | return -ENOMEM; | 255 | return -ENOMEM; |
253 | path->leave_spinning = 1; | 256 | path->leave_spinning = 1; |
254 | 257 | ||
255 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 258 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
256 | key.objectid = BTRFS_I(inode)->root->root_key.objectid; | 259 | key.objectid = BTRFS_I(inode)->root->root_key.objectid; |
257 | key.type = BTRFS_ROOT_BACKREF_KEY; | 260 | key.type = BTRFS_ROOT_BACKREF_KEY; |
258 | key.offset = (u64)-1; | 261 | key.offset = (u64)-1; |
259 | root = root->fs_info->tree_root; | 262 | root = root->fs_info->tree_root; |
260 | } else { | 263 | } else { |
261 | key.objectid = inode->i_ino; | 264 | key.objectid = ino; |
262 | key.offset = dir->i_ino; | 265 | key.offset = btrfs_ino(dir); |
263 | key.type = BTRFS_INODE_REF_KEY; | 266 | key.type = BTRFS_INODE_REF_KEY; |
264 | } | 267 | } |
265 | 268 | ||
@@ -268,7 +271,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
268 | btrfs_free_path(path); | 271 | btrfs_free_path(path); |
269 | return ret; | 272 | return ret; |
270 | } else if (ret > 0) { | 273 | } else if (ret > 0) { |
271 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 274 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
272 | path->slots[0]--; | 275 | path->slots[0]--; |
273 | } else { | 276 | } else { |
274 | btrfs_free_path(path); | 277 | btrfs_free_path(path); |
@@ -277,11 +280,11 @@ static int btrfs_get_name(struct dentry *parent, char *name, | |||
277 | } | 280 | } |
278 | leaf = path->nodes[0]; | 281 | leaf = path->nodes[0]; |
279 | 282 | ||
280 | if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { | 283 | if (ino == BTRFS_FIRST_FREE_OBJECTID) { |
281 | rref = btrfs_item_ptr(leaf, path->slots[0], | 284 | rref = btrfs_item_ptr(leaf, path->slots[0], |
282 | struct btrfs_root_ref); | 285 | struct btrfs_root_ref); |
283 | name_ptr = (unsigned long)(rref + 1); | 286 | name_ptr = (unsigned long)(rref + 1); |
284 | name_len = btrfs_root_ref_name_len(leaf, rref); | 287 | name_len = btrfs_root_ref_name_len(leaf, rref); |
285 | } else { | 288 | } else { |
286 | iref = btrfs_item_ptr(leaf, path->slots[0], | 289 | iref = btrfs_item_ptr(leaf, path->slots[0], |
287 | struct btrfs_inode_ref); | 290 | struct btrfs_inode_ref); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 904eae10ec65..a0e818cb0401 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -7009,8 +7009,8 @@ static noinline int get_new_locations(struct inode *reloc_inode, | |||
7009 | 7009 | ||
7010 | cur_pos = extent_key->objectid - offset; | 7010 | cur_pos = extent_key->objectid - offset; |
7011 | last_byte = extent_key->objectid + extent_key->offset; | 7011 | last_byte = extent_key->objectid + extent_key->offset; |
7012 | ret = btrfs_lookup_file_extent(NULL, root, path, reloc_inode->i_ino, | 7012 | ret = btrfs_lookup_file_extent(NULL, root, path, |
7013 | cur_pos, 0); | 7013 | btrfs_ino(reloc_inode), cur_pos, 0); |
7014 | if (ret < 0) | 7014 | if (ret < 0) |
7015 | goto out; | 7015 | goto out; |
7016 | if (ret > 0) { | 7016 | if (ret > 0) { |
@@ -7033,7 +7033,7 @@ static noinline int get_new_locations(struct inode *reloc_inode, | |||
7033 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); | 7033 | btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); |
7034 | if (found_key.offset != cur_pos || | 7034 | if (found_key.offset != cur_pos || |
7035 | found_key.type != BTRFS_EXTENT_DATA_KEY || | 7035 | found_key.type != BTRFS_EXTENT_DATA_KEY || |
7036 | found_key.objectid != reloc_inode->i_ino) | 7036 | found_key.objectid != btrfs_ino(reloc_inode)) |
7037 | break; | 7037 | break; |
7038 | 7038 | ||
7039 | fi = btrfs_item_ptr(leaf, path->slots[0], | 7039 | fi = btrfs_item_ptr(leaf, path->slots[0], |
@@ -7179,7 +7179,7 @@ next: | |||
7179 | break; | 7179 | break; |
7180 | } | 7180 | } |
7181 | 7181 | ||
7182 | if (inode && key.objectid != inode->i_ino) { | 7182 | if (inode && key.objectid != btrfs_ino(inode)) { |
7183 | BUG_ON(extent_locked); | 7183 | BUG_ON(extent_locked); |
7184 | btrfs_release_path(root, path); | 7184 | btrfs_release_path(root, path); |
7185 | mutex_unlock(&inode->i_mutex); | 7185 | mutex_unlock(&inode->i_mutex); |
@@ -7488,7 +7488,7 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root, | |||
7488 | continue; | 7488 | continue; |
7489 | if (btrfs_file_extent_disk_bytenr(leaf, fi) == 0) | 7489 | if (btrfs_file_extent_disk_bytenr(leaf, fi) == 0) |
7490 | continue; | 7490 | continue; |
7491 | if (!inode || inode->i_ino != key.objectid) { | 7491 | if (!inode || btrfs_ino(inode) != key.objectid) { |
7492 | iput(inode); | 7492 | iput(inode); |
7493 | inode = btrfs_ilookup(target_root->fs_info->sb, | 7493 | inode = btrfs_ilookup(target_root->fs_info->sb, |
7494 | key.objectid, target_root, 1); | 7494 | key.objectid, target_root, 1); |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5ae0bffaa4d8..41d313a0d098 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -3030,7 +3030,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
3030 | * because there might be preallocation past i_size | 3030 | * because there might be preallocation past i_size |
3031 | */ | 3031 | */ |
3032 | ret = btrfs_lookup_file_extent(NULL, BTRFS_I(inode)->root, | 3032 | ret = btrfs_lookup_file_extent(NULL, BTRFS_I(inode)->root, |
3033 | path, inode->i_ino, -1, 0); | 3033 | path, btrfs_ino(inode), -1, 0); |
3034 | if (ret < 0) { | 3034 | if (ret < 0) { |
3035 | btrfs_free_path(path); | 3035 | btrfs_free_path(path); |
3036 | return ret; | 3036 | return ret; |
@@ -3043,7 +3043,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | |||
3043 | found_type = btrfs_key_type(&found_key); | 3043 | found_type = btrfs_key_type(&found_key); |
3044 | 3044 | ||
3045 | /* No extents, but there might be delalloc bits */ | 3045 | /* No extents, but there might be delalloc bits */ |
3046 | if (found_key.objectid != inode->i_ino || | 3046 | if (found_key.objectid != btrfs_ino(inode) || |
3047 | found_type != BTRFS_EXTENT_DATA_KEY) { | 3047 | found_type != BTRFS_EXTENT_DATA_KEY) { |
3048 | /* have to trust i_size as the end */ | 3048 | /* have to trust i_size as the end */ |
3049 | last = (u64)-1; | 3049 | last = (u64)-1; |
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index a6a9d4e8b491..1d9410e39212 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c | |||
@@ -208,8 +208,9 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root, | |||
208 | EXTENT_NODATASUM, GFP_NOFS); | 208 | EXTENT_NODATASUM, GFP_NOFS); |
209 | } else { | 209 | } else { |
210 | printk(KERN_INFO "btrfs no csum found " | 210 | printk(KERN_INFO "btrfs no csum found " |
211 | "for inode %lu start %llu\n", | 211 | "for inode %llu start %llu\n", |
212 | inode->i_ino, | 212 | (unsigned long long) |
213 | btrfs_ino(inode), | ||
213 | (unsigned long long)offset); | 214 | (unsigned long long)offset); |
214 | } | 215 | } |
215 | item = NULL; | 216 | item = NULL; |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 75899a01dded..bef020451525 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -298,6 +298,7 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, | |||
298 | struct btrfs_path *path; | 298 | struct btrfs_path *path; |
299 | struct btrfs_key key; | 299 | struct btrfs_key key; |
300 | struct btrfs_key new_key; | 300 | struct btrfs_key new_key; |
301 | u64 ino = btrfs_ino(inode); | ||
301 | u64 search_start = start; | 302 | u64 search_start = start; |
302 | u64 disk_bytenr = 0; | 303 | u64 disk_bytenr = 0; |
303 | u64 num_bytes = 0; | 304 | u64 num_bytes = 0; |
@@ -318,14 +319,14 @@ int btrfs_drop_extents(struct btrfs_trans_handle *trans, struct inode *inode, | |||
318 | 319 | ||
319 | while (1) { | 320 | while (1) { |
320 | recow = 0; | 321 | recow = 0; |
321 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 322 | ret = btrfs_lookup_file_extent(trans, root, path, ino, |
322 | search_start, -1); | 323 | search_start, -1); |
323 | if (ret < 0) | 324 | if (ret < 0) |
324 | break; | 325 | break; |
325 | if (ret > 0 && path->slots[0] > 0 && search_start == start) { | 326 | if (ret > 0 && path->slots[0] > 0 && search_start == start) { |
326 | leaf = path->nodes[0]; | 327 | leaf = path->nodes[0]; |
327 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1); | 328 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0] - 1); |
328 | if (key.objectid == inode->i_ino && | 329 | if (key.objectid == ino && |
329 | key.type == BTRFS_EXTENT_DATA_KEY) | 330 | key.type == BTRFS_EXTENT_DATA_KEY) |
330 | path->slots[0]--; | 331 | path->slots[0]--; |
331 | } | 332 | } |
@@ -346,7 +347,7 @@ next_slot: | |||
346 | } | 347 | } |
347 | 348 | ||
348 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); | 349 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
349 | if (key.objectid > inode->i_ino || | 350 | if (key.objectid > ino || |
350 | key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end) | 351 | key.type > BTRFS_EXTENT_DATA_KEY || key.offset >= end) |
351 | break; | 352 | break; |
352 | 353 | ||
@@ -592,6 +593,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | |||
592 | int del_slot = 0; | 593 | int del_slot = 0; |
593 | int recow; | 594 | int recow; |
594 | int ret; | 595 | int ret; |
596 | u64 ino = btrfs_ino(inode); | ||
595 | 597 | ||
596 | btrfs_drop_extent_cache(inode, start, end - 1, 0); | 598 | btrfs_drop_extent_cache(inode, start, end - 1, 0); |
597 | 599 | ||
@@ -600,7 +602,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, | |||
600 | again: | 602 | again: |
601 | recow = 0; | 603 | recow = 0; |
602 | split = start; | 604 | split = start; |
603 | key.objectid = inode->i_ino; | 605 | key.objectid = ino; |
604 | key.type = BTRFS_EXTENT_DATA_KEY; | 606 | key.type = BTRFS_EXTENT_DATA_KEY; |
605 | key.offset = split; | 607 | key.offset = split; |
606 | 608 | ||
@@ -612,8 +614,7 @@ again: | |||
612 | 614 | ||
613 | leaf = path->nodes[0]; | 615 | leaf = path->nodes[0]; |
614 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); | 616 | btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); |
615 | BUG_ON(key.objectid != inode->i_ino || | 617 | BUG_ON(key.objectid != ino || key.type != BTRFS_EXTENT_DATA_KEY); |
616 | key.type != BTRFS_EXTENT_DATA_KEY); | ||
617 | fi = btrfs_item_ptr(leaf, path->slots[0], | 618 | fi = btrfs_item_ptr(leaf, path->slots[0], |
618 | struct btrfs_file_extent_item); | 619 | struct btrfs_file_extent_item); |
619 | BUG_ON(btrfs_file_extent_type(leaf, fi) != | 620 | BUG_ON(btrfs_file_extent_type(leaf, fi) != |
@@ -630,7 +631,7 @@ again: | |||
630 | other_start = 0; | 631 | other_start = 0; |
631 | other_end = start; | 632 | other_end = start; |
632 | if (extent_mergeable(leaf, path->slots[0] - 1, | 633 | if (extent_mergeable(leaf, path->slots[0] - 1, |
633 | inode->i_ino, bytenr, orig_offset, | 634 | ino, bytenr, orig_offset, |
634 | &other_start, &other_end)) { | 635 | &other_start, &other_end)) { |
635 | new_key.offset = end; | 636 | new_key.offset = end; |
636 | btrfs_set_item_key_safe(trans, root, path, &new_key); | 637 | btrfs_set_item_key_safe(trans, root, path, &new_key); |
@@ -653,7 +654,7 @@ again: | |||
653 | other_start = end; | 654 | other_start = end; |
654 | other_end = 0; | 655 | other_end = 0; |
655 | if (extent_mergeable(leaf, path->slots[0] + 1, | 656 | if (extent_mergeable(leaf, path->slots[0] + 1, |
656 | inode->i_ino, bytenr, orig_offset, | 657 | ino, bytenr, orig_offset, |
657 | &other_start, &other_end)) { | 658 | &other_start, &other_end)) { |
658 | fi = btrfs_item_ptr(leaf, path->slots[0], | 659 | fi = btrfs_item_ptr(leaf, path->slots[0], |
659 | struct btrfs_file_extent_item); | 660 | struct btrfs_file_extent_item); |
@@ -702,7 +703,7 @@ again: | |||
702 | 703 | ||
703 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, | 704 | ret = btrfs_inc_extent_ref(trans, root, bytenr, num_bytes, 0, |
704 | root->root_key.objectid, | 705 | root->root_key.objectid, |
705 | inode->i_ino, orig_offset); | 706 | ino, orig_offset); |
706 | BUG_ON(ret); | 707 | BUG_ON(ret); |
707 | 708 | ||
708 | if (split == start) { | 709 | if (split == start) { |
@@ -718,7 +719,7 @@ again: | |||
718 | other_start = end; | 719 | other_start = end; |
719 | other_end = 0; | 720 | other_end = 0; |
720 | if (extent_mergeable(leaf, path->slots[0] + 1, | 721 | if (extent_mergeable(leaf, path->slots[0] + 1, |
721 | inode->i_ino, bytenr, orig_offset, | 722 | ino, bytenr, orig_offset, |
722 | &other_start, &other_end)) { | 723 | &other_start, &other_end)) { |
723 | if (recow) { | 724 | if (recow) { |
724 | btrfs_release_path(root, path); | 725 | btrfs_release_path(root, path); |
@@ -729,13 +730,13 @@ again: | |||
729 | del_nr++; | 730 | del_nr++; |
730 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | 731 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, |
731 | 0, root->root_key.objectid, | 732 | 0, root->root_key.objectid, |
732 | inode->i_ino, orig_offset); | 733 | ino, orig_offset); |
733 | BUG_ON(ret); | 734 | BUG_ON(ret); |
734 | } | 735 | } |
735 | other_start = 0; | 736 | other_start = 0; |
736 | other_end = start; | 737 | other_end = start; |
737 | if (extent_mergeable(leaf, path->slots[0] - 1, | 738 | if (extent_mergeable(leaf, path->slots[0] - 1, |
738 | inode->i_ino, bytenr, orig_offset, | 739 | ino, bytenr, orig_offset, |
739 | &other_start, &other_end)) { | 740 | &other_start, &other_end)) { |
740 | if (recow) { | 741 | if (recow) { |
741 | btrfs_release_path(root, path); | 742 | btrfs_release_path(root, path); |
@@ -746,7 +747,7 @@ again: | |||
746 | del_nr++; | 747 | del_nr++; |
747 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, | 748 | ret = btrfs_free_extent(trans, root, bytenr, num_bytes, |
748 | 0, root->root_key.objectid, | 749 | 0, root->root_key.objectid, |
749 | inode->i_ino, orig_offset); | 750 | ino, orig_offset); |
750 | BUG_ON(ret); | 751 | BUG_ON(ret); |
751 | } | 752 | } |
752 | if (del_nr == 0) { | 753 | if (del_nr == 0) { |
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 | ||
2005 | zeroit: | 2006 | zeroit: |
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); | ||
3934 | again: | 3943 | again: |
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) | |||
4066 | static int btrfs_find_actor(struct inode *inode, void *opaque) | 4075 | static 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, | |||
7139 | out_fail: | 7148 | out_fail: |
7140 | btrfs_end_transaction_throttle(trans, root); | 7149 | btrfs_end_transaction_throttle(trans, root); |
7141 | out_notrans: | 7150 | out_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); |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e1835f8eec93..01dccb4a70bb 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -416,7 +416,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
416 | BUG_ON(ret); | 416 | BUG_ON(ret); |
417 | 417 | ||
418 | ret = btrfs_insert_dir_item(trans, root, | 418 | ret = btrfs_insert_dir_item(trans, root, |
419 | name, namelen, dir->i_ino, &key, | 419 | name, namelen, btrfs_ino(dir), &key, |
420 | BTRFS_FT_DIR, index); | 420 | BTRFS_FT_DIR, index); |
421 | if (ret) | 421 | if (ret) |
422 | goto fail; | 422 | goto fail; |
@@ -427,7 +427,7 @@ static noinline int create_subvol(struct btrfs_root *root, | |||
427 | 427 | ||
428 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, | 428 | ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, |
429 | objectid, root->root_key.objectid, | 429 | objectid, root->root_key.objectid, |
430 | dir->i_ino, index, name, namelen); | 430 | btrfs_ino(dir), index, name, namelen); |
431 | 431 | ||
432 | BUG_ON(ret); | 432 | BUG_ON(ret); |
433 | 433 | ||
@@ -1123,7 +1123,7 @@ static noinline int btrfs_ioctl_subvol_getflags(struct file *file, | |||
1123 | int ret = 0; | 1123 | int ret = 0; |
1124 | u64 flags = 0; | 1124 | u64 flags = 0; |
1125 | 1125 | ||
1126 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) | 1126 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) |
1127 | return -EINVAL; | 1127 | return -EINVAL; |
1128 | 1128 | ||
1129 | down_read(&root->fs_info->subvol_sem); | 1129 | down_read(&root->fs_info->subvol_sem); |
@@ -1150,7 +1150,7 @@ static noinline int btrfs_ioctl_subvol_setflags(struct file *file, | |||
1150 | if (root->fs_info->sb->s_flags & MS_RDONLY) | 1150 | if (root->fs_info->sb->s_flags & MS_RDONLY) |
1151 | return -EROFS; | 1151 | return -EROFS; |
1152 | 1152 | ||
1153 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) | 1153 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) |
1154 | return -EINVAL; | 1154 | return -EINVAL; |
1155 | 1155 | ||
1156 | if (copy_from_user(&flags, arg, sizeof(flags))) | 1156 | if (copy_from_user(&flags, arg, sizeof(flags))) |
@@ -1633,7 +1633,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, | |||
1633 | goto out_dput; | 1633 | goto out_dput; |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | if (inode->i_ino != BTRFS_FIRST_FREE_OBJECTID) { | 1636 | if (btrfs_ino(inode) != BTRFS_FIRST_FREE_OBJECTID) { |
1637 | err = -EINVAL; | 1637 | err = -EINVAL; |
1638 | goto out_dput; | 1638 | goto out_dput; |
1639 | } | 1639 | } |
@@ -1919,7 +1919,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1919 | } | 1919 | } |
1920 | 1920 | ||
1921 | /* clone data */ | 1921 | /* clone data */ |
1922 | key.objectid = src->i_ino; | 1922 | key.objectid = btrfs_ino(src); |
1923 | key.type = BTRFS_EXTENT_DATA_KEY; | 1923 | key.type = BTRFS_EXTENT_DATA_KEY; |
1924 | key.offset = 0; | 1924 | key.offset = 0; |
1925 | 1925 | ||
@@ -1946,7 +1946,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1946 | 1946 | ||
1947 | btrfs_item_key_to_cpu(leaf, &key, slot); | 1947 | btrfs_item_key_to_cpu(leaf, &key, slot); |
1948 | if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || | 1948 | if (btrfs_key_type(&key) > BTRFS_EXTENT_DATA_KEY || |
1949 | key.objectid != src->i_ino) | 1949 | key.objectid != btrfs_ino(src)) |
1950 | break; | 1950 | break; |
1951 | 1951 | ||
1952 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { | 1952 | if (btrfs_key_type(&key) == BTRFS_EXTENT_DATA_KEY) { |
@@ -1989,7 +1989,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
1989 | goto next; | 1989 | goto next; |
1990 | 1990 | ||
1991 | memcpy(&new_key, &key, sizeof(new_key)); | 1991 | memcpy(&new_key, &key, sizeof(new_key)); |
1992 | new_key.objectid = inode->i_ino; | 1992 | new_key.objectid = btrfs_ino(inode); |
1993 | if (off <= key.offset) | 1993 | if (off <= key.offset) |
1994 | new_key.offset = key.offset + destoff - off; | 1994 | new_key.offset = key.offset + destoff - off; |
1995 | else | 1995 | else |
@@ -2043,7 +2043,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
2043 | ret = btrfs_inc_extent_ref(trans, root, | 2043 | ret = btrfs_inc_extent_ref(trans, root, |
2044 | disko, diskl, 0, | 2044 | disko, diskl, 0, |
2045 | root->root_key.objectid, | 2045 | root->root_key.objectid, |
2046 | inode->i_ino, | 2046 | btrfs_ino(inode), |
2047 | new_key.offset - datao); | 2047 | new_key.offset - datao); |
2048 | BUG_ON(ret); | 2048 | BUG_ON(ret); |
2049 | } | 2049 | } |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index e6cb89357256..7b75e0c8ef8d 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -1410,9 +1410,9 @@ again: | |||
1410 | prev = node; | 1410 | prev = node; |
1411 | entry = rb_entry(node, struct btrfs_inode, rb_node); | 1411 | entry = rb_entry(node, struct btrfs_inode, rb_node); |
1412 | 1412 | ||
1413 | if (objectid < entry->vfs_inode.i_ino) | 1413 | if (objectid < btrfs_ino(&entry->vfs_inode)) |
1414 | node = node->rb_left; | 1414 | node = node->rb_left; |
1415 | else if (objectid > entry->vfs_inode.i_ino) | 1415 | else if (objectid > btrfs_ino(&entry->vfs_inode)) |
1416 | node = node->rb_right; | 1416 | node = node->rb_right; |
1417 | else | 1417 | else |
1418 | break; | 1418 | break; |
@@ -1420,7 +1420,7 @@ again: | |||
1420 | if (!node) { | 1420 | if (!node) { |
1421 | while (prev) { | 1421 | while (prev) { |
1422 | entry = rb_entry(prev, struct btrfs_inode, rb_node); | 1422 | entry = rb_entry(prev, struct btrfs_inode, rb_node); |
1423 | if (objectid <= entry->vfs_inode.i_ino) { | 1423 | if (objectid <= btrfs_ino(&entry->vfs_inode)) { |
1424 | node = prev; | 1424 | node = prev; |
1425 | break; | 1425 | break; |
1426 | } | 1426 | } |
@@ -1435,7 +1435,7 @@ again: | |||
1435 | return inode; | 1435 | return inode; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | objectid = entry->vfs_inode.i_ino + 1; | 1438 | objectid = btrfs_ino(&entry->vfs_inode) + 1; |
1439 | if (cond_resched_lock(&root->inode_lock)) | 1439 | if (cond_resched_lock(&root->inode_lock)) |
1440 | goto again; | 1440 | goto again; |
1441 | 1441 | ||
@@ -1471,7 +1471,7 @@ static int get_new_location(struct inode *reloc_inode, u64 *new_bytenr, | |||
1471 | return -ENOMEM; | 1471 | return -ENOMEM; |
1472 | 1472 | ||
1473 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; | 1473 | bytenr -= BTRFS_I(reloc_inode)->index_cnt; |
1474 | ret = btrfs_lookup_file_extent(NULL, root, path, reloc_inode->i_ino, | 1474 | ret = btrfs_lookup_file_extent(NULL, root, path, btrfs_ino(reloc_inode), |
1475 | bytenr, 0); | 1475 | bytenr, 0); |
1476 | if (ret < 0) | 1476 | if (ret < 0) |
1477 | goto out; | 1477 | goto out; |
@@ -1559,11 +1559,11 @@ int replace_file_extents(struct btrfs_trans_handle *trans, | |||
1559 | if (first) { | 1559 | if (first) { |
1560 | inode = find_next_inode(root, key.objectid); | 1560 | inode = find_next_inode(root, key.objectid); |
1561 | first = 0; | 1561 | first = 0; |
1562 | } else if (inode && inode->i_ino < key.objectid) { | 1562 | } else if (inode && btrfs_ino(inode) < key.objectid) { |
1563 | btrfs_add_delayed_iput(inode); | 1563 | btrfs_add_delayed_iput(inode); |
1564 | inode = find_next_inode(root, key.objectid); | 1564 | inode = find_next_inode(root, key.objectid); |
1565 | } | 1565 | } |
1566 | if (inode && inode->i_ino == key.objectid) { | 1566 | if (inode && btrfs_ino(inode) == key.objectid) { |
1567 | end = key.offset + | 1567 | end = key.offset + |
1568 | btrfs_file_extent_num_bytes(leaf, fi); | 1568 | btrfs_file_extent_num_bytes(leaf, fi); |
1569 | WARN_ON(!IS_ALIGNED(key.offset, | 1569 | WARN_ON(!IS_ALIGNED(key.offset, |
@@ -1894,6 +1894,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1894 | struct inode *inode = NULL; | 1894 | struct inode *inode = NULL; |
1895 | u64 objectid; | 1895 | u64 objectid; |
1896 | u64 start, end; | 1896 | u64 start, end; |
1897 | u64 ino; | ||
1897 | 1898 | ||
1898 | objectid = min_key->objectid; | 1899 | objectid = min_key->objectid; |
1899 | while (1) { | 1900 | while (1) { |
@@ -1906,17 +1907,18 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1906 | inode = find_next_inode(root, objectid); | 1907 | inode = find_next_inode(root, objectid); |
1907 | if (!inode) | 1908 | if (!inode) |
1908 | break; | 1909 | break; |
1910 | ino = btrfs_ino(inode); | ||
1909 | 1911 | ||
1910 | if (inode->i_ino > max_key->objectid) { | 1912 | if (ino > max_key->objectid) { |
1911 | iput(inode); | 1913 | iput(inode); |
1912 | break; | 1914 | break; |
1913 | } | 1915 | } |
1914 | 1916 | ||
1915 | objectid = inode->i_ino + 1; | 1917 | objectid = ino + 1; |
1916 | if (!S_ISREG(inode->i_mode)) | 1918 | if (!S_ISREG(inode->i_mode)) |
1917 | continue; | 1919 | continue; |
1918 | 1920 | ||
1919 | if (unlikely(min_key->objectid == inode->i_ino)) { | 1921 | if (unlikely(min_key->objectid == ino)) { |
1920 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) | 1922 | if (min_key->type > BTRFS_EXTENT_DATA_KEY) |
1921 | continue; | 1923 | continue; |
1922 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) | 1924 | if (min_key->type < BTRFS_EXTENT_DATA_KEY) |
@@ -1929,7 +1931,7 @@ static int invalidate_extent_cache(struct btrfs_root *root, | |||
1929 | start = 0; | 1931 | start = 0; |
1930 | } | 1932 | } |
1931 | 1933 | ||
1932 | if (unlikely(max_key->objectid == inode->i_ino)) { | 1934 | if (unlikely(max_key->objectid == ino)) { |
1933 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) | 1935 | if (max_key->type < BTRFS_EXTENT_DATA_KEY) |
1934 | continue; | 1936 | continue; |
1935 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { | 1937 | if (max_key->type > BTRFS_EXTENT_DATA_KEY) { |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index aef6c81e7101..f4c1184b7f1a 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -972,7 +972,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
972 | BUG_ON(ret); | 972 | BUG_ON(ret); |
973 | ret = btrfs_insert_dir_item(trans, parent_root, | 973 | ret = btrfs_insert_dir_item(trans, parent_root, |
974 | dentry->d_name.name, dentry->d_name.len, | 974 | dentry->d_name.name, dentry->d_name.len, |
975 | parent_inode->i_ino, &key, | 975 | btrfs_ino(parent_inode), &key, |
976 | BTRFS_FT_DIR, index); | 976 | BTRFS_FT_DIR, index); |
977 | BUG_ON(ret); | 977 | BUG_ON(ret); |
978 | 978 | ||
@@ -1014,7 +1014,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans, | |||
1014 | */ | 1014 | */ |
1015 | ret = btrfs_add_root_ref(trans, tree_root, objectid, | 1015 | ret = btrfs_add_root_ref(trans, tree_root, objectid, |
1016 | parent_root->root_key.objectid, | 1016 | parent_root->root_key.objectid, |
1017 | parent_inode->i_ino, index, | 1017 | btrfs_ino(parent_inode), index, |
1018 | dentry->d_name.name, dentry->d_name.len); | 1018 | dentry->d_name.name, dentry->d_name.len); |
1019 | BUG_ON(ret); | 1019 | BUG_ON(ret); |
1020 | dput(parent); | 1020 | dput(parent); |
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index c50271ad3157..4323dc68d6cd 100644 --- a/fs/btrfs/tree-log.c +++ b/fs/btrfs/tree-log.c | |||
@@ -519,7 +519,7 @@ static noinline int replay_one_extent(struct btrfs_trans_handle *trans, | |||
519 | * file. This must be done before the btrfs_drop_extents run | 519 | * file. This must be done before the btrfs_drop_extents run |
520 | * so we don't try to drop this extent. | 520 | * so we don't try to drop this extent. |
521 | */ | 521 | */ |
522 | ret = btrfs_lookup_file_extent(trans, root, path, inode->i_ino, | 522 | ret = btrfs_lookup_file_extent(trans, root, path, btrfs_ino(inode), |
523 | start, 0); | 523 | start, 0); |
524 | 524 | ||
525 | if (ret == 0 && | 525 | if (ret == 0 && |
@@ -832,7 +832,7 @@ again: | |||
832 | read_extent_buffer(eb, name, (unsigned long)(ref + 1), namelen); | 832 | read_extent_buffer(eb, name, (unsigned long)(ref + 1), namelen); |
833 | 833 | ||
834 | /* if we already have a perfect match, we're done */ | 834 | /* if we already have a perfect match, we're done */ |
835 | if (inode_in_dir(root, path, dir->i_ino, inode->i_ino, | 835 | if (inode_in_dir(root, path, btrfs_ino(dir), btrfs_ino(inode), |
836 | btrfs_inode_ref_index(eb, ref), | 836 | btrfs_inode_ref_index(eb, ref), |
837 | name, namelen)) { | 837 | name, namelen)) { |
838 | goto out; | 838 | goto out; |
@@ -960,8 +960,9 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
960 | unsigned long ptr; | 960 | unsigned long ptr; |
961 | unsigned long ptr_end; | 961 | unsigned long ptr_end; |
962 | int name_len; | 962 | int name_len; |
963 | u64 ino = btrfs_ino(inode); | ||
963 | 964 | ||
964 | key.objectid = inode->i_ino; | 965 | key.objectid = ino; |
965 | key.type = BTRFS_INODE_REF_KEY; | 966 | key.type = BTRFS_INODE_REF_KEY; |
966 | key.offset = (u64)-1; | 967 | key.offset = (u64)-1; |
967 | 968 | ||
@@ -980,7 +981,7 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
980 | } | 981 | } |
981 | btrfs_item_key_to_cpu(path->nodes[0], &key, | 982 | btrfs_item_key_to_cpu(path->nodes[0], &key, |
982 | path->slots[0]); | 983 | path->slots[0]); |
983 | if (key.objectid != inode->i_ino || | 984 | if (key.objectid != ino || |
984 | key.type != BTRFS_INODE_REF_KEY) | 985 | key.type != BTRFS_INODE_REF_KEY) |
985 | break; | 986 | break; |
986 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); | 987 | ptr = btrfs_item_ptr_offset(path->nodes[0], path->slots[0]); |
@@ -1011,10 +1012,10 @@ static noinline int fixup_inode_link_count(struct btrfs_trans_handle *trans, | |||
1011 | if (inode->i_nlink == 0) { | 1012 | if (inode->i_nlink == 0) { |
1012 | if (S_ISDIR(inode->i_mode)) { | 1013 | if (S_ISDIR(inode->i_mode)) { |
1013 | ret = replay_dir_deletes(trans, root, NULL, path, | 1014 | ret = replay_dir_deletes(trans, root, NULL, path, |
1014 | inode->i_ino, 1); | 1015 | ino, 1); |
1015 | BUG_ON(ret); | 1016 | BUG_ON(ret); |
1016 | } | 1017 | } |
1017 | ret = insert_orphan_item(trans, root, inode->i_ino); | 1018 | ret = insert_orphan_item(trans, root, ino); |
1018 | BUG_ON(ret); | 1019 | BUG_ON(ret); |
1019 | } | 1020 | } |
1020 | btrfs_free_path(path); | 1021 | btrfs_free_path(path); |
@@ -2197,6 +2198,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2197 | int ret; | 2198 | int ret; |
2198 | int err = 0; | 2199 | int err = 0; |
2199 | int bytes_del = 0; | 2200 | int bytes_del = 0; |
2201 | u64 dir_ino = btrfs_ino(dir); | ||
2200 | 2202 | ||
2201 | if (BTRFS_I(dir)->logged_trans < trans->transid) | 2203 | if (BTRFS_I(dir)->logged_trans < trans->transid) |
2202 | return 0; | 2204 | return 0; |
@@ -2212,7 +2214,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2212 | if (!path) | 2214 | if (!path) |
2213 | return -ENOMEM; | 2215 | return -ENOMEM; |
2214 | 2216 | ||
2215 | di = btrfs_lookup_dir_item(trans, log, path, dir->i_ino, | 2217 | di = btrfs_lookup_dir_item(trans, log, path, dir_ino, |
2216 | name, name_len, -1); | 2218 | name, name_len, -1); |
2217 | if (IS_ERR(di)) { | 2219 | if (IS_ERR(di)) { |
2218 | err = PTR_ERR(di); | 2220 | err = PTR_ERR(di); |
@@ -2224,7 +2226,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2224 | BUG_ON(ret); | 2226 | BUG_ON(ret); |
2225 | } | 2227 | } |
2226 | btrfs_release_path(log, path); | 2228 | btrfs_release_path(log, path); |
2227 | di = btrfs_lookup_dir_index_item(trans, log, path, dir->i_ino, | 2229 | di = btrfs_lookup_dir_index_item(trans, log, path, dir_ino, |
2228 | index, name, name_len, -1); | 2230 | index, name, name_len, -1); |
2229 | if (IS_ERR(di)) { | 2231 | if (IS_ERR(di)) { |
2230 | err = PTR_ERR(di); | 2232 | err = PTR_ERR(di); |
@@ -2242,7 +2244,7 @@ int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans, | |||
2242 | if (bytes_del) { | 2244 | if (bytes_del) { |
2243 | struct btrfs_key key; | 2245 | struct btrfs_key key; |
2244 | 2246 | ||
2245 | key.objectid = dir->i_ino; | 2247 | key.objectid = dir_ino; |
2246 | key.offset = 0; | 2248 | key.offset = 0; |
2247 | key.type = BTRFS_INODE_ITEM_KEY; | 2249 | key.type = BTRFS_INODE_ITEM_KEY; |
2248 | btrfs_release_path(log, path); | 2250 | btrfs_release_path(log, path); |
@@ -2300,7 +2302,7 @@ int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans, | |||
2300 | log = root->log_root; | 2302 | log = root->log_root; |
2301 | mutex_lock(&BTRFS_I(inode)->log_mutex); | 2303 | mutex_lock(&BTRFS_I(inode)->log_mutex); |
2302 | 2304 | ||
2303 | ret = btrfs_del_inode_ref(trans, log, name, name_len, inode->i_ino, | 2305 | ret = btrfs_del_inode_ref(trans, log, name, name_len, btrfs_ino(inode), |
2304 | dirid, &index); | 2306 | dirid, &index); |
2305 | mutex_unlock(&BTRFS_I(inode)->log_mutex); | 2307 | mutex_unlock(&BTRFS_I(inode)->log_mutex); |
2306 | if (ret == -ENOSPC) { | 2308 | if (ret == -ENOSPC) { |
@@ -2366,13 +2368,14 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2366 | int nritems; | 2368 | int nritems; |
2367 | u64 first_offset = min_offset; | 2369 | u64 first_offset = min_offset; |
2368 | u64 last_offset = (u64)-1; | 2370 | u64 last_offset = (u64)-1; |
2371 | u64 ino = btrfs_ino(inode); | ||
2369 | 2372 | ||
2370 | log = root->log_root; | 2373 | log = root->log_root; |
2371 | max_key.objectid = inode->i_ino; | 2374 | max_key.objectid = ino; |
2372 | max_key.offset = (u64)-1; | 2375 | max_key.offset = (u64)-1; |
2373 | max_key.type = key_type; | 2376 | max_key.type = key_type; |
2374 | 2377 | ||
2375 | min_key.objectid = inode->i_ino; | 2378 | min_key.objectid = ino; |
2376 | min_key.type = key_type; | 2379 | min_key.type = key_type; |
2377 | min_key.offset = min_offset; | 2380 | min_key.offset = min_offset; |
2378 | 2381 | ||
@@ -2385,9 +2388,8 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2385 | * we didn't find anything from this transaction, see if there | 2388 | * we didn't find anything from this transaction, see if there |
2386 | * is anything at all | 2389 | * is anything at all |
2387 | */ | 2390 | */ |
2388 | if (ret != 0 || min_key.objectid != inode->i_ino || | 2391 | if (ret != 0 || min_key.objectid != ino || min_key.type != key_type) { |
2389 | min_key.type != key_type) { | 2392 | min_key.objectid = ino; |
2390 | min_key.objectid = inode->i_ino; | ||
2391 | min_key.type = key_type; | 2393 | min_key.type = key_type; |
2392 | min_key.offset = (u64)-1; | 2394 | min_key.offset = (u64)-1; |
2393 | btrfs_release_path(root, path); | 2395 | btrfs_release_path(root, path); |
@@ -2396,7 +2398,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2396 | btrfs_release_path(root, path); | 2398 | btrfs_release_path(root, path); |
2397 | return ret; | 2399 | return ret; |
2398 | } | 2400 | } |
2399 | ret = btrfs_previous_item(root, path, inode->i_ino, key_type); | 2401 | ret = btrfs_previous_item(root, path, ino, key_type); |
2400 | 2402 | ||
2401 | /* if ret == 0 there are items for this type, | 2403 | /* if ret == 0 there are items for this type, |
2402 | * create a range to tell us the last key of this type. | 2404 | * create a range to tell us the last key of this type. |
@@ -2414,7 +2416,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2414 | } | 2416 | } |
2415 | 2417 | ||
2416 | /* go backward to find any previous key */ | 2418 | /* go backward to find any previous key */ |
2417 | ret = btrfs_previous_item(root, path, inode->i_ino, key_type); | 2419 | ret = btrfs_previous_item(root, path, ino, key_type); |
2418 | if (ret == 0) { | 2420 | if (ret == 0) { |
2419 | struct btrfs_key tmp; | 2421 | struct btrfs_key tmp; |
2420 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); | 2422 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); |
@@ -2449,8 +2451,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2449 | for (i = path->slots[0]; i < nritems; i++) { | 2451 | for (i = path->slots[0]; i < nritems; i++) { |
2450 | btrfs_item_key_to_cpu(src, &min_key, i); | 2452 | btrfs_item_key_to_cpu(src, &min_key, i); |
2451 | 2453 | ||
2452 | if (min_key.objectid != inode->i_ino || | 2454 | if (min_key.objectid != ino || min_key.type != key_type) |
2453 | min_key.type != key_type) | ||
2454 | goto done; | 2455 | goto done; |
2455 | ret = overwrite_item(trans, log, dst_path, src, i, | 2456 | ret = overwrite_item(trans, log, dst_path, src, i, |
2456 | &min_key); | 2457 | &min_key); |
@@ -2471,7 +2472,7 @@ static noinline int log_dir_items(struct btrfs_trans_handle *trans, | |||
2471 | goto done; | 2472 | goto done; |
2472 | } | 2473 | } |
2473 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); | 2474 | btrfs_item_key_to_cpu(path->nodes[0], &tmp, path->slots[0]); |
2474 | if (tmp.objectid != inode->i_ino || tmp.type != key_type) { | 2475 | if (tmp.objectid != ino || tmp.type != key_type) { |
2475 | last_offset = (u64)-1; | 2476 | last_offset = (u64)-1; |
2476 | goto done; | 2477 | goto done; |
2477 | } | 2478 | } |
@@ -2497,8 +2498,7 @@ done: | |||
2497 | * is valid | 2498 | * is valid |
2498 | */ | 2499 | */ |
2499 | ret = insert_dir_log_key(trans, log, path, key_type, | 2500 | ret = insert_dir_log_key(trans, log, path, key_type, |
2500 | inode->i_ino, first_offset, | 2501 | ino, first_offset, last_offset); |
2501 | last_offset); | ||
2502 | if (ret) | 2502 | if (ret) |
2503 | err = ret; | 2503 | err = ret; |
2504 | } | 2504 | } |
@@ -2742,6 +2742,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2742 | int nritems; | 2742 | int nritems; |
2743 | int ins_start_slot = 0; | 2743 | int ins_start_slot = 0; |
2744 | int ins_nr; | 2744 | int ins_nr; |
2745 | u64 ino = btrfs_ino(inode); | ||
2745 | 2746 | ||
2746 | log = root->log_root; | 2747 | log = root->log_root; |
2747 | 2748 | ||
@@ -2754,11 +2755,11 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2754 | return -ENOMEM; | 2755 | return -ENOMEM; |
2755 | } | 2756 | } |
2756 | 2757 | ||
2757 | min_key.objectid = inode->i_ino; | 2758 | min_key.objectid = ino; |
2758 | min_key.type = BTRFS_INODE_ITEM_KEY; | 2759 | min_key.type = BTRFS_INODE_ITEM_KEY; |
2759 | min_key.offset = 0; | 2760 | min_key.offset = 0; |
2760 | 2761 | ||
2761 | max_key.objectid = inode->i_ino; | 2762 | max_key.objectid = ino; |
2762 | 2763 | ||
2763 | /* today the code can only do partial logging of directories */ | 2764 | /* today the code can only do partial logging of directories */ |
2764 | if (!S_ISDIR(inode->i_mode)) | 2765 | if (!S_ISDIR(inode->i_mode)) |
@@ -2781,8 +2782,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2781 | 2782 | ||
2782 | if (inode_only == LOG_INODE_EXISTS) | 2783 | if (inode_only == LOG_INODE_EXISTS) |
2783 | max_key_type = BTRFS_XATTR_ITEM_KEY; | 2784 | max_key_type = BTRFS_XATTR_ITEM_KEY; |
2784 | ret = drop_objectid_items(trans, log, path, | 2785 | ret = drop_objectid_items(trans, log, path, ino, max_key_type); |
2785 | inode->i_ino, max_key_type); | ||
2786 | } else { | 2786 | } else { |
2787 | ret = btrfs_truncate_inode_items(trans, log, inode, 0, 0); | 2787 | ret = btrfs_truncate_inode_items(trans, log, inode, 0, 0); |
2788 | } | 2788 | } |
@@ -2800,7 +2800,7 @@ static int btrfs_log_inode(struct btrfs_trans_handle *trans, | |||
2800 | break; | 2800 | break; |
2801 | again: | 2801 | again: |
2802 | /* note, ins_nr might be > 0 here, cleanup outside the loop */ | 2802 | /* note, ins_nr might be > 0 here, cleanup outside the loop */ |
2803 | if (min_key.objectid != inode->i_ino) | 2803 | if (min_key.objectid != ino) |
2804 | break; | 2804 | break; |
2805 | if (min_key.type > max_key.type) | 2805 | if (min_key.type > max_key.type) |
2806 | break; | 2806 | break; |
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 07b9bc350d5d..a8af771fc60c 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c | |||
@@ -44,7 +44,7 @@ ssize_t __btrfs_getxattr(struct inode *inode, const char *name, | |||
44 | return -ENOMEM; | 44 | return -ENOMEM; |
45 | 45 | ||
46 | /* lookup the xattr by name */ | 46 | /* lookup the xattr by name */ |
47 | di = btrfs_lookup_xattr(NULL, root, path, inode->i_ino, name, | 47 | di = btrfs_lookup_xattr(NULL, root, path, btrfs_ino(inode), name, |
48 | strlen(name), 0); | 48 | strlen(name), 0); |
49 | if (!di) { | 49 | if (!di) { |
50 | ret = -ENODATA; | 50 | ret = -ENODATA; |
@@ -103,7 +103,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
103 | return -ENOMEM; | 103 | return -ENOMEM; |
104 | 104 | ||
105 | /* first lets see if we already have this xattr */ | 105 | /* first lets see if we already have this xattr */ |
106 | di = btrfs_lookup_xattr(trans, root, path, inode->i_ino, name, | 106 | di = btrfs_lookup_xattr(trans, root, path, btrfs_ino(inode), name, |
107 | strlen(name), -1); | 107 | strlen(name), -1); |
108 | if (IS_ERR(di)) { | 108 | if (IS_ERR(di)) { |
109 | ret = PTR_ERR(di); | 109 | ret = PTR_ERR(di); |
@@ -136,7 +136,7 @@ static int do_setxattr(struct btrfs_trans_handle *trans, | |||
136 | } | 136 | } |
137 | 137 | ||
138 | /* ok we have to create a completely new xattr */ | 138 | /* ok we have to create a completely new xattr */ |
139 | ret = btrfs_insert_xattr_item(trans, root, path, inode->i_ino, | 139 | ret = btrfs_insert_xattr_item(trans, root, path, btrfs_ino(inode), |
140 | name, name_len, value, size); | 140 | name, name_len, value, size); |
141 | BUG_ON(ret); | 141 | BUG_ON(ret); |
142 | out: | 142 | out: |
@@ -190,7 +190,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size) | |||
190 | * NOTE: we set key.offset = 0; because we want to start with the | 190 | * NOTE: we set key.offset = 0; because we want to start with the |
191 | * first xattr that we find and walk forward | 191 | * first xattr that we find and walk forward |
192 | */ | 192 | */ |
193 | key.objectid = inode->i_ino; | 193 | key.objectid = btrfs_ino(inode); |
194 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); | 194 | btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY); |
195 | key.offset = 0; | 195 | key.offset = 0; |
196 | 196 | ||