if (!bits)
return 0;
clear_bit(bit_slot, bits + 1);
-#if 0
for (i = 1; i < BIT_ARRAY_BYTES / sizeof(unsigned long); i++) {
if (bits[i]) {
empty = 0;
BUG_ON(!bits);
kmem_cache_free(btrfs_bit_radix_cachep, bits);
}
-#endif
return 0;
}
struct buffer_head *btrfs_find_tree_block(struct btrfs_root *root, u64 blocknr)
{
- return sb_find_get_block(root->fs_info->sb, blocknr);
-#if 0
struct address_space *mapping = root->fs_info->btree_inode->i_mapping;
int blockbits = root->fs_info->sb->s_blocksize_bits;
unsigned long index = blocknr >> (PAGE_CACHE_SHIFT - blockbits);
}
page_cache_release(page);
return ret;
-#endif
}
struct buffer_head *btrfs_find_create_tree_block(struct btrfs_root *root,
u64 blocknr)
{
- return sb_getblk(root->fs_info->sb, blocknr);
-#if 0
struct address_space *mapping = root->fs_info->btree_inode->i_mapping;
int blockbits = root->fs_info->sb->s_blocksize_bits;
unsigned long index = blocknr >> (PAGE_CACHE_SHIFT - blockbits);
touch_buffer(ret);
page_cache_release(page);
return ret;
-#endif
}
static sector_t max_block(struct block_device *bdev)
static int btree_writepage(struct page *page, struct writeback_control *wbc)
{
-#if 0
struct buffer_head *bh;
struct btrfs_root *root = btrfs_sb(page->mapping->host->i_sb);
struct buffer_head *head;
csum_tree_block(root, bh, 0);
bh = bh->b_this_page;
} while (bh != head);
-#endif
return block_write_full_page(page, btree_get_block, wbc);
}
struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr)
{
- return sb_bread(root->fs_info->sb, blocknr);
-#if 0
struct buffer_head *bh = NULL;
bh = btrfs_find_create_tree_block(root, blocknr);
fail:
brelse(bh);
return NULL;
-
-#endif
}
int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
fs_info->last_inode_alloc = 0;
fs_info->last_inode_alloc_dirid = 0;
fs_info->sb = sb;
- fs_info->btree_inode = NULL;
-#if 0
fs_info->btree_inode = new_inode(sb);
fs_info->btree_inode->i_ino = 1;
fs_info->btree_inode->i_nlink = 1;
fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
insert_inode_hash(fs_info->btree_inode);
mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
-#endif
fs_info->hash_tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
spin_lock_init(&fs_info->hash_lock);
if (!fs_info->hash_tfm || IS_ERR(fs_info->hash_tfm)) {
btrfs_block_release(root, root->commit_root);
btrfs_block_release(root, root->fs_info->sb_buffer);
crypto_free_hash(root->fs_info->hash_tfm);
- // truncate_inode_pages(root->fs_info->btree_inode->i_mapping, 0);
- // iput(root->fs_info->btree_inode);
+ truncate_inode_pages(root->fs_info->btree_inode->i_mapping, 0);
+ iput(root->fs_info->btree_inode);
kfree(root->fs_info->extent_root);
kfree(root->fs_info->inode_root);
kfree(root->fs_info->tree_root);
void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf)
{
- // brelse(buf);
+ brelse(buf);
}
struct btrfs_root *fs_root,
u64 dirid, u64 *objectid)
{
- struct btrfs_path path;
+ struct btrfs_path *path;
struct btrfs_key key;
int ret;
u64 hole_size = 0;
btrfs_set_key_type(&search_key, BTRFS_INODE_MAP_ITEM_KEY);
search_key.offset = 0;
- btrfs_init_path(&path);
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ btrfs_init_path(path);
start_found = 0;
- ret = btrfs_search_slot(trans, root, &search_key, &path, 0, 0);
+ ret = btrfs_search_slot(trans, root, &search_key, path, 0, 0);
if (ret < 0)
goto error;
- if (path.slots[0] > 0)
- path.slots[0]--;
+ if (path->slots[0] > 0)
+ path->slots[0]--;
while (1) {
- l = btrfs_buffer_leaf(path.nodes[0]);
- slot = path.slots[0];
+ l = btrfs_buffer_leaf(path->nodes[0]);
+ slot = path->slots[0];
if (slot >= btrfs_header_nritems(&l->header)) {
- ret = btrfs_next_leaf(root, &path);
+ ret = btrfs_next_leaf(root, path);
if (ret == 0)
continue;
if (ret < 0)
}
start_found = 1;
last_ino = key.objectid + 1;
- path.slots[0]++;
+ path->slots[0]++;
}
// FIXME -ENOSPC
found:
root->fs_info->last_inode_alloc = *objectid;
root->fs_info->last_inode_alloc_dirid = dirid;
- btrfs_release_path(root, &path);
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
BUG_ON(*objectid < search_start);
return 0;
error:
- btrfs_release_path(root, &path);
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
return ret;
}
u64 objectid, struct btrfs_key *location)
{
int ret = 0;
- struct btrfs_path path;
+ struct btrfs_path *path;
struct btrfs_inode_map_item *inode_item;
struct btrfs_key key;
struct btrfs_root *inode_root = fs_root->fs_info->inode_root;
key.flags = 0;
btrfs_set_key_type(&key, BTRFS_INODE_MAP_ITEM_KEY);
key.offset = 0;
- btrfs_init_path(&path);
- ret = btrfs_insert_empty_item(trans, inode_root, &path, &key,
+ path = btrfs_alloc_path();
+ BUG_ON(!path);
+ btrfs_init_path(path);
+ ret = btrfs_insert_empty_item(trans, inode_root, path, &key,
sizeof(struct btrfs_inode_map_item));
if (ret)
goto out;
- inode_item = btrfs_item_ptr(btrfs_buffer_leaf(path.nodes[0]),
- path.slots[0], struct btrfs_inode_map_item);
+ inode_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]),
+ path->slots[0], struct btrfs_inode_map_item);
btrfs_cpu_key_to_disk(&inode_item->key, location);
- btrfs_mark_buffer_dirty(path.nodes[0]);
+ btrfs_mark_buffer_dirty(path->nodes[0]);
out:
- btrfs_release_path(inode_root, &path);
+ btrfs_release_path(inode_root, path);
+ btrfs_free_path(path);
return ret;
}
ret = btrfs_lookup_inode(NULL, root, path, inode->i_ino, 0);
if (ret) {
btrfs_release_path(root, path);
+ btrfs_free_path(path);
mutex_unlock(&root->fs_info->fs_mutex);
make_bad_inode(inode);
return;
goto out;
}
btrfs_release_path(root, path);
- btrfs_free_path(path);
/* now the directory is empty */
err = btrfs_unlink_trans(trans, root, dir, dentry);
inode->i_size = 0;
}
out:
+ btrfs_release_path(root, path);
+ btrfs_free_path(path);
mutex_unlock(&root->fs_info->fs_mutex);
ret = btrfs_end_transaction(trans, root);
if (ret && !err)
sb->s_dirt = 0;
if (!wait) {
- // filemap_flush(root->fs_info->btree_inode->i_mapping);
- filemap_flush(root->fs_info->sb->s_bdev->bd_inode->i_mapping);
+ filemap_flush(root->fs_info->btree_inode->i_mapping);
return 0;
}
- filemap_write_and_wait(root->fs_info->sb->s_bdev->bd_inode->i_mapping);
+ filemap_write_and_wait(root->fs_info->btree_inode->i_mapping);
mutex_lock(&root->fs_info->fs_mutex);
trans = btrfs_start_transaction(root, 1);
ret = btrfs_commit_transaction(trans, root);
int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans,
struct btrfs_root *root)
{
- filemap_write_and_wait(root->fs_info->sb->s_bdev->bd_inode->i_mapping);
+ filemap_write_and_wait(root->fs_info->btree_inode->i_mapping);
return 0;
}