Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Chris Mason 2007-04-02 14:53:59 -04:00 коммит произвёл David Woodhouse
Родитель 5caf2a0029
Коммит 7cfcc17e7f
5 изменённых файлов: 34 добавлений и 43 удалений

Просмотреть файл

@ -62,7 +62,6 @@ int clear_radix_bit(struct radix_tree_root *radix, unsigned long bit)
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;
@ -74,7 +73,6 @@ int clear_radix_bit(struct radix_tree_root *radix, unsigned long bit)
BUG_ON(!bits);
kmem_cache_free(btrfs_bit_radix_cachep, bits);
}
#endif
return 0;
}

Просмотреть файл

@ -23,8 +23,6 @@ static int check_tree_block(struct btrfs_root *root, struct buffer_head *buf)
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);
@ -58,14 +56,11 @@ out_unlock:
}
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);
@ -103,7 +98,6 @@ out_unlock:
touch_buffer(ret);
page_cache_release(page);
return ret;
#endif
}
static sector_t max_block(struct block_device *bdev)
@ -186,7 +180,6 @@ static int csum_tree_block(struct btrfs_root *root, struct buffer_head *bh,
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;
@ -201,7 +194,6 @@ static int btree_writepage(struct page *page, struct writeback_control *wbc)
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);
}
@ -218,8 +210,6 @@ static struct address_space_operations btree_aops = {
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);
@ -243,8 +233,6 @@ struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr)
fail:
brelse(bh);
return NULL;
#endif
}
int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
@ -323,8 +311,6 @@ struct btrfs_root *open_ctree(struct super_block *sb)
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;
@ -332,7 +318,6 @@ struct btrfs_root *open_ctree(struct super_block *sb)
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)) {
@ -435,8 +420,8 @@ int close_ctree(struct btrfs_root *root)
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);
@ -447,6 +432,6 @@ int close_ctree(struct btrfs_root *root)
void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf)
{
// brelse(buf);
brelse(buf);
}

Просмотреть файл

@ -10,7 +10,7 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
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;
@ -31,20 +31,22 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
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)
@ -72,17 +74,19 @@ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
}
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;
}
@ -91,7 +95,7 @@ int btrfs_insert_inode_map(struct btrfs_trans_handle *trans,
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;
@ -100,18 +104,21 @@ int btrfs_insert_inode_map(struct btrfs_trans_handle *trans,
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;
}

Просмотреть файл

@ -49,6 +49,7 @@ static void btrfs_read_locked_inode(struct inode *inode)
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;
@ -215,7 +216,6 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
goto out;
}
btrfs_release_path(root, path);
btrfs_free_path(path);
/* now the directory is empty */
err = btrfs_unlink_trans(trans, root, dir, dentry);
@ -223,6 +223,8 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *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)
@ -800,11 +802,10 @@ static int btrfs_sync_fs(struct super_block *sb, int wait)
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);

Просмотреть файл

@ -88,7 +88,7 @@ int btrfs_end_transaction(struct btrfs_trans_handle *trans,
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;
}