diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 7ffa3d34ea19..59cba180fe83 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include <linux/time.h> | 26 | #include <linux/time.h> |
27 | #include <linux/init.h> | 27 | #include <linux/init.h> |
28 | #include <linux/string.h> | 28 | #include <linux/string.h> |
29 | #include <linux/smp_lock.h> | ||
30 | #include <linux/backing-dev.h> | 29 | #include <linux/backing-dev.h> |
31 | #include <linux/mpage.h> | 30 | #include <linux/mpage.h> |
32 | #include <linux/swap.h> | 31 | #include <linux/swap.h> |
@@ -2604,8 +2603,8 @@ noinline int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, | |||
2604 | if (root->ref_cows) | 2603 | if (root->ref_cows) |
2605 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); | 2604 | btrfs_drop_extent_cache(inode, new_size & (~mask), (u64)-1, 0); |
2606 | path = btrfs_alloc_path(); | 2605 | path = btrfs_alloc_path(); |
2607 | path->reada = -1; | ||
2608 | BUG_ON(!path); | 2606 | BUG_ON(!path); |
2607 | path->reada = -1; | ||
2609 | 2608 | ||
2610 | /* FIXME, add redo link to tree so we don't leak on crash */ | 2609 | /* FIXME, add redo link to tree so we don't leak on crash */ |
2611 | key.objectid = inode->i_ino; | 2610 | key.objectid = inode->i_ino; |
@@ -3100,8 +3099,12 @@ static void inode_tree_add(struct inode *inode) | |||
3100 | { | 3099 | { |
3101 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3100 | struct btrfs_root *root = BTRFS_I(inode)->root; |
3102 | struct btrfs_inode *entry; | 3101 | struct btrfs_inode *entry; |
3103 | struct rb_node **p = &root->inode_tree.rb_node; | 3102 | struct rb_node **p; |
3104 | struct rb_node *parent = NULL; | 3103 | struct rb_node *parent; |
3104 | |||
3105 | again: | ||
3106 | p = &root->inode_tree.rb_node; | ||
3107 | parent = NULL; | ||
3105 | 3108 | ||
3106 | spin_lock(&root->inode_lock); | 3109 | spin_lock(&root->inode_lock); |
3107 | while (*p) { | 3110 | while (*p) { |
@@ -3109,13 +3112,16 @@ static void inode_tree_add(struct inode *inode) | |||
3109 | entry = rb_entry(parent, struct btrfs_inode, rb_node); | 3112 | entry = rb_entry(parent, struct btrfs_inode, rb_node); |
3110 | 3113 | ||
3111 | if (inode->i_ino < entry->vfs_inode.i_ino) | 3114 | if (inode->i_ino < entry->vfs_inode.i_ino) |
3112 | p = &(*p)->rb_left; | 3115 | p = &parent->rb_left; |
3113 | else if (inode->i_ino > entry->vfs_inode.i_ino) | 3116 | else if (inode->i_ino > entry->vfs_inode.i_ino) |
3114 | p = &(*p)->rb_right; | 3117 | p = &parent->rb_right; |
3115 | else { | 3118 | else { |
3116 | WARN_ON(!(entry->vfs_inode.i_state & | 3119 | WARN_ON(!(entry->vfs_inode.i_state & |
3117 | (I_WILL_FREE | I_FREEING | I_CLEAR))); | 3120 | (I_WILL_FREE | I_FREEING | I_CLEAR))); |
3118 | break; | 3121 | rb_erase(parent, &root->inode_tree); |
3122 | RB_CLEAR_NODE(parent); | ||
3123 | spin_unlock(&root->inode_lock); | ||
3124 | goto again; | ||
3119 | } | 3125 | } |
3120 | } | 3126 | } |
3121 | rb_link_node(&BTRFS_I(inode)->rb_node, parent, p); | 3127 | rb_link_node(&BTRFS_I(inode)->rb_node, parent, p); |
@@ -3127,12 +3133,12 @@ static void inode_tree_del(struct inode *inode) | |||
3127 | { | 3133 | { |
3128 | struct btrfs_root *root = BTRFS_I(inode)->root; | 3134 | struct btrfs_root *root = BTRFS_I(inode)->root; |
3129 | 3135 | ||
3136 | spin_lock(&root->inode_lock); | ||
3130 | if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) { | 3137 | if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) { |
3131 | spin_lock(&root->inode_lock); | ||
3132 | rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree); | 3138 | rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree); |
3133 | spin_unlock(&root->inode_lock); | ||
3134 | RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); | 3139 | RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); |
3135 | } | 3140 | } |
3141 | spin_unlock(&root->inode_lock); | ||
3136 | } | 3142 | } |
3137 | 3143 | ||
3138 | static noinline void init_btrfs_i(struct inode *inode) | 3144 | static noinline void init_btrfs_i(struct inode *inode) |
@@ -4786,8 +4792,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
4786 | * and the replacement file is large. Start IO on it now so | 4792 | * and the replacement file is large. Start IO on it now so |
4787 | * we don't add too much work to the end of the transaction | 4793 | * we don't add too much work to the end of the transaction |
4788 | */ | 4794 | */ |
4789 | if (new_inode && old_inode && S_ISREG(old_inode->i_mode) && | 4795 | if (new_inode && S_ISREG(old_inode->i_mode) && new_inode->i_size && |
4790 | new_inode->i_size && | ||
4791 | old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) | 4796 | old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) |
4792 | filemap_flush(old_inode->i_mapping); | 4797 | filemap_flush(old_inode->i_mapping); |
4793 | 4798 | ||