Revision 613866383839 () - Diff

Link to this snippet: https://friendpaste.com/6XrGXb5p0RSJGixUFYouHg
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 64ea749c1ba4..22616c060722 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3569,10 +3569,9 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf,
* read an inode from the btree into the in-memory inode
*/
static int btrfs_read_locked_inode(struct inode *inode,
- struct btrfs_path *in_path)
+ struct btrfs_path *path)
{
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
- struct btrfs_path *path = in_path;
struct extent_buffer *leaf;
struct btrfs_inode_item *inode_item;
struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -3588,20 +3587,11 @@ static int btrfs_read_locked_inode(struct inode *inode,
if (!ret)
filled = true;
- if (!path) {
- path = btrfs_alloc_path();
- if (!path)
- return -ENOMEM;
- }
-
memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
- if (ret) {
- if (path != in_path)
- btrfs_free_path(path);
+ if (ret)
return ret;
- }
leaf = path->nodes[0];
@@ -3724,8 +3714,7 @@ static int btrfs_read_locked_inode(struct inode *inode,
btrfs_ino(BTRFS_I(inode)),
root->root_key.objectid, ret);
}
- if (path != in_path)
- btrfs_free_path(path);
+ btrfs_release_path(path);
if (!maybe_acls)
cache_no_acl(inode);
@@ -5669,7 +5658,7 @@ static struct inode *btrfs_iget_locked(struct super_block *s,
*/
struct inode *btrfs_iget_path(struct super_block *s, struct btrfs_key *location,
struct btrfs_root *root, int *new,
- struct btrfs_path *path)
+ struct btrfs_path *in_path)
{
struct inode *inode;
@@ -5679,8 +5668,17 @@ struct inode *btrfs_iget_path(struct super_block *s, struct btrfs_key *location,
if (inode->i_state & I_NEW) {
int ret;
+ struct btrfs_path *path = in_path;
+
+ if (!path) {
+ path = btrfs_alloc_path();
+ if (!path)
+ return ERR_PTR(-ENOMEM);
+ }
ret = btrfs_read_locked_inode(inode, path);
+ if (path != in_path)
+ btrfs_free_path(path);
if (!ret) {
inode_tree_add(inode);
unlock_new_inode(inode);