nfsd4: rename sessionid_lock to client_lock
[safe/jmp/linux-2.6] / fs / logfs / dir.c
index 89104e6..2396a85 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 2005-2008 Joern Engel <joern@logfs.org>
  */
 #include "logfs.h"
-
+#include <linux/slab.h>
 
 /*
  * Atomic dir operations
@@ -133,17 +133,22 @@ static u32 hash_32(const char *s, int len, u32 seed)
  */
 static pgoff_t hash_index(u32 hash, int round)
 {
+       u32 i0_blocks = I0_BLOCKS;
+       u32 i1_blocks = I1_BLOCKS;
+       u32 i2_blocks = I2_BLOCKS;
+       u32 i3_blocks = I3_BLOCKS;
+
        switch (round) {
        case 0:
-               return hash % I0_BLOCKS;
+               return hash % i0_blocks;
        case 1:
-               return I0_BLOCKS + hash % (I1_BLOCKS - I0_BLOCKS);
+               return i0_blocks + hash % (i1_blocks - i0_blocks);
        case 2:
-               return I1_BLOCKS + hash % (I2_BLOCKS - I1_BLOCKS);
+               return i1_blocks + hash % (i2_blocks - i1_blocks);
        case 3:
-               return I2_BLOCKS + hash % (I3_BLOCKS - I2_BLOCKS);
+               return i2_blocks + hash % (i3_blocks - i2_blocks);
        case 4 ... 19:
-               return I3_BLOCKS + 16 * (hash % (((1<<31) - I3_BLOCKS) / 16))
+               return i3_blocks + 16 * (hash % (((1<<31) - i3_blocks) / 16))
                        + round - 4;
        }
        BUG();
@@ -224,10 +229,14 @@ static int logfs_unlink(struct inode *dir, struct dentry *dentry)
        inode->i_ctime = dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 
        page = logfs_get_dd_page(dir, dentry);
-       if (!page)
+       if (!page) {
+               kfree(ta);
                return -ENOENT;
-       if (IS_ERR(page))
+       }
+       if (IS_ERR(page)) {
+               kfree(ta);
                return PTR_ERR(page);
+       }
        index = page->index;
        page_cache_release(page);
 
@@ -294,12 +303,12 @@ static int __logfs_readdir(struct file *file, void *buf, filldir_t filldir)
                                (filler_t *)logfs_readpage, NULL);
                if (IS_ERR(page))
                        return PTR_ERR(page);
-               dd = kmap_atomic(page, KM_USER0);
+               dd = kmap(page);
                BUG_ON(dd->namelen == 0);
 
                full = filldir(buf, (char *)dd->name, be16_to_cpu(dd->namelen),
                                pos, be64_to_cpu(dd->ino), dd->type);
-               kunmap_atomic(dd, KM_USER0);
+               kunmap(page);
                page_cache_release(page);
                if (full)
                        break;