aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-15 08:40:48 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commitcee36a03e8f7c6e14aefd497d3acf01bcd3ef153 (patch)
tree14195245463be27ab4314da6eb943b146e6c8591 /fs/btrfs
parent61295eb8665e723e77af91d0a1e655a4bd28344f (diff)
Rework btrfs_drop_inode to avoid scheduling
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-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 {
u64 total_pinned;
spinlock_t delalloc_lock;
+ spinlock_t new_trans_lock;
u64 delalloc_bytes;
};
/*
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)
INIT_LIST_HEAD(&fs_info->hashers);
spin_lock_init(&fs_info->hash_lock);
spin_lock_init(&fs_info->delalloc_lock);
+ spin_lock_init(&fs_info->new_trans_lock);
memset(&fs_info->super_kobj, 0, sizeof(fs_info->super_kobj));
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:
void btrfs_drop_inode(struct inode *inode)
{
- struct btrfs_trans_handle *trans;
- struct btrfs_root *root = BTRFS_I(inode)->root;
-
- if (!BTRFS_I(inode)->ordered_trans) {
+ if (!BTRFS_I(inode)->ordered_trans || inode->i_nlink) {
generic_drop_inode(inode);
return;
}
- /* nasty, but it prevents a deadlock with data=ordered by preventing
- * a commit until after this inode is done
- */
- trans = btrfs_start_transaction(root, 1);
+ /* FIXME, make sure this delete actually ends up in the transaction */
+ btrfs_del_ordered_inode(inode);
generic_drop_inode(inode);
- /* note, the inode is now untouchable */
- btrfs_end_transaction(trans, root);
}
void 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,
kfree(entry);
return 1;
}
+
+static int __btrfs_del_ordered_inode(struct btrfs_ordered_inode_tree *tree,
+ u64 root_objectid, u64 objectid)
+{
+ struct tree_entry *entry;
+ struct rb_node *node;
+ struct rb_node *prev;
+
+ write_lock(&tree->lock);
+ node = __tree_search(&tree->tree, root_objectid, objectid, &prev);
+ if (!node) {
+ write_unlock(&tree->lock);
+ return 0;
+ }
+ rb_erase(node, &tree->tree);
+ write_unlock(&tree->lock);
+ entry = rb_entry(node, struct tree_entry, rb_node);
+ kfree(entry);
+ return 1;
+}
+
+int btrfs_del_ordered_inode(struct inode *inode)
+{
+ struct btrfs_root *root = BTRFS_I(inode)->root;
+ u64 root_objectid = root->root_key.objectid;
+
+ spin_lock(&root->fs_info->new_trans_lock);
+ if (root->fs_info->running_transaction) {
+ struct btrfs_ordered_inode_tree *tree;
+ tree = &root->fs_info->running_transaction->ordered_inode_tree;
+ __btrfs_del_ordered_inode(tree, root_objectid, inode->i_ino);
+ }
+ spin_unlock(&root->fs_info->new_trans_lock);
+ return 0;
+}
+
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,
u64 *root_objectid, u64 *objectid);
int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
u64 *root_objectid, u64 *objectid);
+int btrfs_del_ordered_inode(struct inode *inode);
#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,
BUG_ON(ret);
cur_trans = root->fs_info->running_transaction;
+ spin_lock(&root->fs_info->new_trans_lock);
root->fs_info->running_transaction = NULL;
+ spin_unlock(&root->fs_info->new_trans_lock);
btrfs_set_super_generation(&root->fs_info->super_copy,
cur_trans->transid);
btrfs_set_super_root(&root->fs_info->super_copy,