vserver 1.9.5.x5
[linux-2.6.git] / fs / hfs / btree.c
index 3e620ef..394725e 100644 (file)
@@ -19,7 +19,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        struct hfs_btree_header_rec *head;
        struct address_space *mapping;
        struct page *page;
-       unsigned int shift, size;
+       unsigned int size;
 
        tree = kmalloc(sizeof(*tree), GFP_KERNEL);
        if (!tree)
@@ -82,10 +82,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
                goto fail_page;
        if (!tree->node_count)
                goto fail_page;
-       for (shift = 0; size >>= 1; shift += 1)
-               ;
-       tree->node_size_shift = shift;
-
+       tree->node_size_shift = ffs(size) - 1;
        tree->pages_per_bnode = (tree->node_size + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 
        kunmap(page);
@@ -157,7 +154,7 @@ static struct hfs_bnode *hfs_bmap_new_bmap(struct hfs_bnode *prev, u32 idx)
        struct hfs_btree *tree = prev->tree;
        struct hfs_bnode *node;
        struct hfs_bnode_desc desc;
-       u32 cnid;
+       __be32 cnid;
 
        node = hfs_bnode_create(tree, idx);
        if (IS_ERR(node))
@@ -204,10 +201,12 @@ struct hfs_bnode *hfs_bmap_alloc(struct hfs_btree *tree)
                res = hfs_extend_file(inode);
                if (res)
                        return ERR_PTR(res);
-               inode->i_blocks = HFS_I(inode)->alloc_blocks *
-                                 HFS_SB(tree->sb)->fs_div;
                HFS_I(inode)->phys_size = inode->i_size =
-                       (loff_t)inode->i_blocks << tree->sb->s_blocksize_bits;
+                               (loff_t)HFS_I(inode)->alloc_blocks *
+                               HFS_SB(tree->sb)->alloc_blksz;
+               HFS_I(inode)->fs_blocks = inode->i_size >>
+                                         tree->sb->s_blocksize_bits;
+               inode_set_bytes(inode, inode->i_size);
                count = inode->i_size >> tree->node_size_shift;
                tree->free_nodes = count - tree->node_count;
                tree->node_count = count;