]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/hfs/btree.c
autofs4: deadlock during create
[linux-2.6-omap-h63xx.git] / fs / hfs / btree.c
index 7bb11edd148891694586da25a7e7926b21973a1b..8a3a650abc87a9ed4520318a811fb76619933a7e 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <linux/pagemap.h>
+#include <linux/log2.h>
 
 #include "btree.h"
 
@@ -21,10 +22,9 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        struct page *page;
        unsigned int size;
 
-       tree = kmalloc(sizeof(*tree), GFP_KERNEL);
+       tree = kzalloc(sizeof(*tree), GFP_KERNEL);
        if (!tree)
                return NULL;
-       memset(tree, 0, sizeof(*tree));
 
        init_MUTEX(&tree->tree_lock);
        spin_lock_init(&tree->hash_lock);
@@ -36,8 +36,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        tree->inode = iget_locked(sb, id);
        if (!tree->inode)
                goto free_tree;
-       if (!(tree->inode->i_state & I_NEW))
-               BUG();
+       BUG_ON(!(tree->inode->i_state & I_NEW));
        {
        struct hfs_mdb *mdb = HFS_SB(sb)->mdb;
        HFS_I(tree->inode)->flags = 0;
@@ -60,7 +59,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        unlock_new_inode(tree->inode);
 
        mapping = tree->inode->i_mapping;
-       page = read_cache_page(mapping, 0, (filler_t *)mapping->a_ops->readpage, NULL);
+       page = read_mapping_page(mapping, 0, NULL);
        if (IS_ERR(page))
                goto free_tree;
 
@@ -78,7 +77,7 @@ struct hfs_btree *hfs_btree_open(struct super_block *sb, u32 id, btree_keycmp ke
        tree->depth = be16_to_cpu(head->depth);
 
        size = tree->node_size;
-       if (!size || size & (size - 1))
+       if (!is_power_of_2(size))
                goto fail_page;
        if (!tree->node_count)
                goto fail_page;