diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d3df5b52278c..9ea4c6f0352f 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -1531,12 +1531,11 @@ out_check: | |||
1531 | } | 1531 | } |
1532 | btrfs_release_path(path); | 1532 | btrfs_release_path(path); |
1533 | 1533 | ||
1534 | if (cur_offset <= end && cow_start == (u64)-1) { | 1534 | if (cur_offset <= end && cow_start == (u64)-1) |
1535 | cow_start = cur_offset; | 1535 | cow_start = cur_offset; |
1536 | cur_offset = end; | ||
1537 | } | ||
1538 | 1536 | ||
1539 | if (cow_start != (u64)-1) { | 1537 | if (cow_start != (u64)-1) { |
1538 | cur_offset = end; | ||
1540 | ret = cow_file_range(inode, locked_page, cow_start, end, end, | 1539 | ret = cow_file_range(inode, locked_page, cow_start, end, end, |
1541 | page_started, nr_written, 1, NULL); | 1540 | page_started, nr_written, 1, NULL); |
1542 | if (ret) | 1541 | if (ret) |
@@ -3570,10 +3569,11 @@ static noinline int acls_after_inode_item(struct extent_buffer *leaf, | |||
3570 | /* | 3569 | /* |
3571 | * read an inode from the btree into the in-memory inode | 3570 | * read an inode from the btree into the in-memory inode |
3572 | */ | 3571 | */ |
3573 | static int btrfs_read_locked_inode(struct inode *inode) | 3572 | static int btrfs_read_locked_inode(struct inode *inode, |
3573 | struct btrfs_path *in_path) | ||
3574 | { | 3574 | { |
3575 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | 3575 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); |
3576 | struct btrfs_path *path; | 3576 | struct btrfs_path *path = in_path; |
3577 | struct extent_buffer *leaf; | 3577 | struct extent_buffer *leaf; |
3578 | struct btrfs_inode_item *inode_item; | 3578 | struct btrfs_inode_item *inode_item; |
3579 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3579 | struct btrfs_root *root = BTRFS_I(inode)->root; |
@@ -3589,15 +3589,18 @@ static int btrfs_read_locked_inode(struct inode *inode) | |||
3589 | if (!ret) | 3589 | if (!ret) |
3590 | filled = true; | 3590 | filled = true; |
3591 | 3591 | ||
3592 | path = btrfs_alloc_path(); | 3592 | if (!path) { |
3593 | if (!path) | 3593 | path = btrfs_alloc_path(); |
3594 | return -ENOMEM; | 3594 | if (!path) |
3595 | return -ENOMEM; | ||
3596 | } | ||
3595 | 3597 | ||
3596 | memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); | 3598 | memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); |
3597 | 3599 | ||
3598 | ret = btrfs_lookup_inode(NULL, root, path, &location, 0); | 3600 | ret = btrfs_lookup_inode(NULL, root, path, &location, 0); |
3599 | if (ret) { | 3601 | if (ret) { |
3600 | btrfs_free_path(path); | 3602 | if (path != in_path) |
3603 | btrfs_free_path(path); | ||
3601 | return ret; | 3604 | return ret; |
3602 | } | 3605 | } |
3603 | 3606 | ||
@@ -3722,7 +3725,8 @@ cache_acl: | |||
3722 | btrfs_ino(BTRFS_I(inode)), | 3725 | btrfs_ino(BTRFS_I(inode)), |
3723 | root->root_key.objectid, ret); | 3726 | root->root_key.objectid, ret); |
3724 | } | 3727 | } |
3725 | btrfs_free_path(path); | 3728 | if (path != in_path) |
3729 | btrfs_free_path(path); | ||
3726 | 3730 | ||
3727 | if (!maybe_acls) | 3731 | if (!maybe_acls) |
3728 | cache_no_acl(inode); | 3732 | cache_no_acl(inode); |
@@ -5644,8 +5648,9 @@ static struct inode *btrfs_iget_locked(struct super_block *s, | |||
5644 | /* Get an inode object given its location and corresponding root. | 5648 | /* Get an inode object given its location and corresponding root. |
5645 | * Returns in *is_new if the inode was read from disk | 5649 | * Returns in *is_new if the inode was read from disk |
5646 | */ | 5650 | */ |
5647 | struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | 5651 | struct inode *btrfs_iget_path(struct super_block *s, struct btrfs_key *location, |
5648 | struct btrfs_root *root, int *new) | 5652 | struct btrfs_root *root, int *new, |
5653 | struct btrfs_path *path) | ||
5649 | { | 5654 | { |
5650 | struct inode *inode; | 5655 | struct inode *inode; |
5651 | 5656 | ||
@@ -5656,7 +5661,7 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
5656 | if (inode->i_state & I_NEW) { | 5661 | if (inode->i_state & I_NEW) { |
5657 | int ret; | 5662 | int ret; |
5658 | 5663 | ||
5659 | ret = btrfs_read_locked_inode(inode); | 5664 | ret = btrfs_read_locked_inode(inode, path); |
5660 | if (!ret) { | 5665 | if (!ret) { |
5661 | inode_tree_add(inode); | 5666 | inode_tree_add(inode); |
5662 | unlock_new_inode(inode); | 5667 | unlock_new_inode(inode); |
@@ -5678,6 +5683,12 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
5678 | return inode; | 5683 | return inode; |
5679 | } | 5684 | } |
5680 | 5685 | ||
5686 | struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | ||
5687 | struct btrfs_root *root, int *new) | ||
5688 | { | ||
5689 | return btrfs_iget_path(s, location, root, new, NULL); | ||
5690 | } | ||
5691 | |||
5681 | static struct inode *new_simple_dir(struct super_block *s, | 5692 | static struct inode *new_simple_dir(struct super_block *s, |
5682 | struct btrfs_key *key, | 5693 | struct btrfs_key *key, |
5683 | struct btrfs_root *root) | 5694 | struct btrfs_root *root) |