int level;
int should_reada = p->reada;
int lowest_unlock = 1;
+ int blocksize;
u8 lowest_level = 0;
+ u64 blocknr;
+ u64 gen;
lowest_level = p->lowest_level;
WARN_ON(lowest_level && ins_len);
reada_for_search(root, p, level, slot,
key->objectid);
- tmp = btrfs_find_tree_block(root,
- btrfs_node_blockptr(b, slot),
- btrfs_level_size(root, level - 1));
- if (tmp && btrfs_buffer_uptodate(tmp,
- btrfs_node_ptr_generation(b, slot))) {
+ blocknr = btrfs_node_blockptr(b, slot);
+ gen = btrfs_node_ptr_generation(b, slot);
+ blocksize = btrfs_level_size(root, level - 1);
+
+ tmp = btrfs_find_tree_block(root, blocknr, blocksize);
+ if (tmp && btrfs_buffer_uptodate(tmp, gen)) {
b = tmp;
} else {
/*
*/
if (level > 1) {
btrfs_release_path(NULL, p);
+ if (tmp)
+ free_extent_buffer(tmp);
+ tmp = read_tree_block(root, blocknr,
+ blocksize, gen);
if (tmp)
free_extent_buffer(tmp);
goto again;
int btrfs_release_file(struct inode * inode, struct file * filp)
{
- btrfs_del_ordered_inode(inode);
+ btrfs_del_ordered_inode(inode, 0);
if (filp->private_data)
btrfs_ioctl_trans_end(filp);
return 0;
* we don't need to worry about
* data=ordered
*/
- btrfs_del_ordered_inode(inode);
+ btrfs_del_ordered_inode(inode, 1);
}
btrfs_end_transaction(trans, root);
btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr);
- btrfs_throttle(root);
return;
no_delete_lock:
nr = trans->blocks_used;
btrfs_end_transaction(trans, root);
btrfs_btree_balance_dirty(root, nr);
- btrfs_throttle(root);
no_delete:
clear_inode(inode);
}
return;
}
-void btrfs_del_ordered_inode(struct inode *inode)
+void btrfs_del_ordered_inode(struct inode *inode, int force)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
u64 root_objectid = root->root_key.objectid;
return;
}
- if (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) ||
- mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK))
+ if (!force && (mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY) ||
+ mapping_tagged(inode->i_mapping, PAGECACHE_TAG_WRITEBACK)))
return;
spin_lock(&root->fs_info->new_trans_lock);
int btrfs_find_first_ordered_inode(struct btrfs_ordered_inode_tree *tree,
u64 *root_objectid, u64 *objectid,
struct inode **inode);
-void btrfs_del_ordered_inode(struct inode *inode);
+void btrfs_del_ordered_inode(struct inode *inode, int force);
int btrfs_ordered_throttle(struct btrfs_root *root, struct inode *inode);
#endif