Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128397
b: refs/heads/master
c: 39279cc
h: refs/heads/master
i:
  128395: 897a707
v: v3
  • Loading branch information
Chris Mason authored and David Woodhouse committed Jun 12, 2007
1 parent 04b61a7 commit 6a9cc34
Show file tree
Hide file tree
Showing 8 changed files with 3,121 additions and 2,929 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5276aedab0baacfb3c5483208b8be85a8416bd5f
refs/heads/master: 39279cc3d2704cfbf9c35dcb5bdd392159ae4625
4 changes: 2 additions & 2 deletions trunk/fs/btrfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ifneq ($(KERNELRELEASE),)
obj-m := btrfs.o
btrfs-y := super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
hash.o file-item.o inode-item.o inode-map.o disk-io.o \
transaction.o bit-radix.o
transaction.o bit-radix.o inode.o file.o

#btrfs-y := ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
# root-tree.o dir-item.o hash.o file-item.o inode-item.o \
Expand All @@ -16,7 +16,7 @@ else

KERNELDIR := /lib/modules/`uname -r`/build
all::
$(MAKE) C=1 -C $(KERNELDIR) M=`pwd` modules
$(MAKE) -C $(KERNELDIR) M=`pwd` modules
clean::
rm *.o btrfs.ko
endif
1 change: 1 addition & 0 deletions trunk/fs/btrfs/TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* fix printk warnings
* cleanup, add more error checking, get rid of BUG_ONs
* Fix ENOSPC handling
* Make allocator smarter
Expand Down
25 changes: 24 additions & 1 deletion trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1123,5 +1123,28 @@ struct btrfs_csum_item *btrfs_lookup_csum(struct btrfs_trans_handle *trans,
int btrfs_csum_truncate(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct btrfs_path *path,
u64 isize);
/* super.c */
/* inode.c */
void btrfs_delete_inode(struct inode *inode);
void btrfs_read_locked_inode(struct inode *inode);
int btrfs_write_inode(struct inode *inode, int wait);
void btrfs_dirty_inode(struct inode *inode);
struct inode *btrfs_alloc_inode(struct super_block *sb);
void btrfs_destroy_inode(struct inode *inode);
int btrfs_init_cachep(void);
void btrfs_destroy_cachep(void);
int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg);
long btrfs_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
struct inode *btrfs_iget_locked(struct super_block *s, u64 objectid,
struct btrfs_root *root);
int btrfs_commit_write(struct file *file, struct page *page,
unsigned from, unsigned to);
int btrfs_get_block(struct inode *inode, sector_t iblock,
struct buffer_head *result, int create);
/* file.c */
extern struct file_operations btrfs_file_operations;
int btrfs_drop_extents(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode,
u64 start, u64 end, u64 *hint_block);
#endif
46 changes: 38 additions & 8 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static int check_tree_block(struct btrfs_root *root, struct buffer_head *buf)
if (bh_blocknr(buf) != btrfs_header_blocknr(&node->header)) {
printk(KERN_CRIT "bh_blocknr(buf) is %Lu, header is %Lu\n",
bh_blocknr(buf), btrfs_header_blocknr(&node->header));
BUG();
return 1;
}
return 0;
}
Expand Down Expand Up @@ -253,7 +253,7 @@ struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr)
set_buffer_checked(bh);
}
if (check_tree_block(root, bh))
BUG();
goto fail;
return bh;
fail:
brelse(bh);
Expand Down Expand Up @@ -398,8 +398,13 @@ struct btrfs_root *open_ctree(struct super_block *sb)
struct btrfs_fs_info *fs_info = kmalloc(sizeof(*fs_info),
GFP_NOFS);
int ret;
int err = -EIO;
struct btrfs_super_block *disk_super;

if (!extent_root || !tree_root || !fs_info) {
err = -ENOMEM;
goto fail;
}
init_bit_radix(&fs_info->pinned_radix);
init_bit_radix(&fs_info->pending_del_radix);
init_bit_radix(&fs_info->extent_map_radix);
Expand Down Expand Up @@ -431,9 +436,11 @@ struct btrfs_root *open_ctree(struct super_block *sb)
mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
fs_info->hash_tfm = crypto_alloc_hash("crc32c", 0, CRYPTO_ALG_ASYNC);
spin_lock_init(&fs_info->hash_lock);

if (!fs_info->hash_tfm || IS_ERR(fs_info->hash_tfm)) {
printk("failed to allocate digest hash\n");
return NULL;
printk("btrfs: failed hash setup, modprobe cryptomgr?\n");
err = -ENOMEM;
goto fail_iput;
}
mutex_init(&fs_info->trans_mutex);
mutex_init(&fs_info->fs_mutex);
Expand All @@ -446,30 +453,53 @@ struct btrfs_root *open_ctree(struct super_block *sb)
sb->s_blocksize);

if (!fs_info->sb_buffer)
return NULL;
goto fail_iput;
disk_super = (struct btrfs_super_block *)fs_info->sb_buffer->b_data;

if (!btrfs_super_root(disk_super))
return NULL;
goto fail_sb_buffer;

i_size_write(fs_info->btree_inode,
btrfs_super_total_blocks(disk_super) <<
fs_info->btree_inode->i_blkbits);

fs_info->disk_super = disk_super;

if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC,
sizeof(disk_super->magic))) {
printk("btrfs: valid FS not found on %s\n", sb->s_id);
goto fail_sb_buffer;
}
tree_root->node = read_tree_block(tree_root,
btrfs_super_root(disk_super));
BUG_ON(!tree_root->node);
if (!tree_root->node)
goto fail_sb_buffer;

mutex_lock(&fs_info->fs_mutex);
ret = find_and_setup_root(sb->s_blocksize, tree_root, fs_info,
BTRFS_EXTENT_TREE_OBJECTID, extent_root);
BUG_ON(ret);
if (ret) {
mutex_unlock(&fs_info->fs_mutex);
goto fail_tree_root;
}

btrfs_read_block_groups(extent_root);

fs_info->generation = btrfs_super_generation(disk_super) + 1;
mutex_unlock(&fs_info->fs_mutex);
return tree_root;

fail_tree_root:
btrfs_block_release(tree_root, tree_root->node);
fail_sb_buffer:
btrfs_block_release(tree_root, fs_info->sb_buffer);
fail_iput:
iput(fs_info->btree_inode);
fail:
kfree(extent_root);
kfree(tree_root);
kfree(fs_info);
return ERR_PTR(err);
}

int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
Expand Down
Loading

0 comments on commit 6a9cc34

Please sign in to comment.