aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/inode.c13
-rw-r--r--fs/btrfs/ordered-data.c36
-rw-r--r--fs/btrfs/ordered-data.h1
-rw-r--r--fs/btrfs/transaction.c2
6 files changed, 44 insertions, 10 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index a2c2d6d82c5..1e19f2d8633 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -349,6 +349,7 @@ struct btrfs_fs_info {
349 349
350 u64 total_pinned; 350 u64 total_pinned;
351 spinlock_t delalloc_lock; 351 spinlock_t delalloc_lock;
352 spinlock_t new_trans_lock;
352 u64 delalloc_bytes; 353 u64 delalloc_bytes;
353}; 354};
354/* 355/*
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 87daed632f3..cd29922d407 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -639,6 +639,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
639 INIT_LIST_HEAD(&fs_info->hashers); 639 INIT_LIST_HEAD(&fs_info->hashers);
640 spin_lock_init(&fs_info->hash_lock); 640 spin_lock_init(&fs_info->hash_lock);
641 spin_lock_init(&fs_info->delalloc_lock); 641 spin_lock_init(&fs_info->delalloc_lock);
642 spin_lock_init(&fs_info->new_trans_lock);
642 643
643 memset(&fs_info->super_kobj, 0, sizeof(fs_info->super_kobj)); 644 memset(&fs_info->super_kobj, 0, sizeof(fs_info->super_kobj));
644 init_completion(&fs_info->kobj_unregister); 645 init_completion(&fs_info->kobj_unregister);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e53d2033164..008e3445748 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -993,20 +993,13 @@ fail:
993 993
994void btrfs_drop_inode(struct inode *inode) 994void btrfs_drop_inode(struct inode *inode)
995{ 995{
996 struct btrfs_trans_handle *trans; 996 if (!BTRFS_I(inode)->ordered_trans || inode->i_nlink) {
997 struct btrfs_root *root = BTRFS_I(inode)->root;
998
999 if (!BTRFS_I(inode)->ordered_trans) {
1000 generic_drop_inode(inode); 997 generic_drop_inode(inode);
1001 return; 998 return;
1002 } 999 }
1003 /* nasty, but it prevents a deadlock with data=ordered by preventing 1000 /* FIXME, make sure this delete actually ends up in the transaction */
1004 * a commit until after this inode is done 1001 btrfs_del_ordered_inode(inode);
1005 */
1006 trans = btrfs_start_transaction(root, 1);
1007 generic_drop_inode(inode); 1002 generic_drop_inode(inode);
1008 /* note, the inode is now untouchable */
1009 btrfs_end_transaction(trans, root);
1010} 1003}
1011 1004
1012void btrfs_delete_inode(struct inode *inode) 1005void btrfs_delete_inode(struct inode *inode)
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 411aba84d30..b56011baa17 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -219,3 +219,39 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
219 kfree(entry); 219 kfree(entry);
220 return 1; 220 return 1;
221} 221}
222
223static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree,
224 u64 root_objectid, u64 objectid)
225{
226 struct tree_entry *entry;
227 struct rb_node *node;
228 struct rb_node *prev;
229
230 write_lock(&tree->lock);
231 node = __tree_search(&tree->tree, root_objectid, objectid, &prev);
232 if (!node) {
233 write_unlock(&tree->lock);
234 return 0;
235 }
236 rb_erase(node, &tree->tree);
237 write_unlock(&tree->lock);
238 entry = rb_entry(node, struct tree_entry, rb_node);
239 kfree(entry);
240 return 1;
241}
242
243int btrfs_del_ordered_inode(struct inode *inode)
244{
245 struct btrfs_root *root = BTRFS_I(inode)->root;
246 u64 root_objectid = root->root_key.objectid;
247
248 spin_lock(&root->fs_info->new_trans_lock);
249 if (root->fs_info->running_transaction) {
250 struct btrfs_ordered_inode_tree *tree;
251 tree = &root->fs_info->running_transaction->ordered_inode_tree;
252 __btrfs_del_ordered_inode(tree, root_objectid, inode->i_ino);
253 }
254 spin_unlock(&root->fs_info->new_trans_lock);
255 return 0;
256}
257
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h
index aaf9eb14271..26b26212865 100644
--- a/fs/btrfs/ordered-data.h
+++ b/fs/btrfs/ordered-data.h
@@ -36,4 +36,5 @@ int btrfs_find_del_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
36 u64 *root_objectid, u64 *objectid); 36 u64 *root_objectid, u64 *objectid);
37int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree, 37int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
38 u64 *root_objectid, u64 *objectid); 38 u64 *root_objectid, u64 *objectid);
39int btrfs_del_ordered_inode(struct inode *inode);
39#endif 40#endif
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 614903f5c88..a3205808ab2 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -699,7 +699,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
699 BUG_ON(ret); 699 BUG_ON(ret);
700 700
701 cur_trans = root->fs_info->running_transaction; 701 cur_trans = root->fs_info->running_transaction;
702 spin_lock(&root->fs_info->new_trans_lock);
702 root->fs_info->running_transaction = NULL; 703 root->fs_info->running_transaction = NULL;
704 spin_unlock(&root->fs_info->new_trans_lock);
703 btrfs_set_super_generation(&root->fs_info->super_copy, 705 btrfs_set_super_generation(&root->fs_info->super_copy,
704 cur_trans->transid); 706 cur_trans->transid);
705 btrfs_set_super_root(&root->fs_info->super_copy, 707 btrfs_set_super_root(&root->fs_info->super_copy,