aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ordered-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r--fs/btrfs/ordered-data.c36
1 files changed, 36 insertions, 0 deletions
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