patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / fs / cifs / cifsfs.c
index 17458b7..1fe2654 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/list.h>
 #include <linux/seq_file.h>
 #include <linux/vfs.h>
+#include <linux/mempool.h>
 #include "cifsfs.h"
 #include "cifspdu.h"
 #define DECLARE_GLOBALS_HERE
 #include "cifs_debug.h"
 #include "cifs_fs_sb.h"
 #include <linux/mm.h>
-#define CIFS_MAGIC_NUMBER 0xFF534D42   /* the first four bytes of all SMB PDUs */
+#define CIFS_MAGIC_NUMBER 0xFF534D42   /* the first four bytes of SMB PDUs */
+/* BB when mempool_resize is added back in, we will resize pool on new mount */
+#define CIFS_MIN_RCV_POOL 11 /* enough for progress to five servers */
 
-#ifdef CIFS_QUOTA
+#ifdef CONFIG_CIFS_QUOTA
 static struct quotactl_ops cifs_quotactl_ops;
 #endif
 
@@ -100,7 +103,7 @@ cifs_read_super(struct super_block *sb, void *data,
        sb->s_op = &cifs_super_ops;
 /*     if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
            sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
-#ifdef CIFS_QUOTA
+#ifdef CONFIG_CIFS_QUOTA
        sb->s_qcop = &cifs_quotactl_ops;
 #endif
        sb->s_blocksize = CIFS_MAX_MSGSIZE;
@@ -209,9 +212,11 @@ static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
 }
 
 static kmem_cache_t *cifs_inode_cachep;
-kmem_cache_t *cifs_req_cachep;
-kmem_cache_t *cifs_mid_cachep;
+static kmem_cache_t *cifs_req_cachep;
+static kmem_cache_t *cifs_mid_cachep;
 kmem_cache_t *cifs_oplock_cachep;
+mempool_t *cifs_req_poolp;
+mempool_t *cifs_mid_poolp;
 
 static struct inode *
 cifs_alloc_inode(struct super_block *sb)
@@ -271,7 +276,7 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
        return 0;
 }
 
-#ifdef CIFS_QUOTA
+#ifdef CONFIG_CIFS_QUOTA
 int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
                struct fs_disk_quota * pdquota)
 {
@@ -421,7 +426,7 @@ cifs_get_sb(struct file_system_type *fs_type,
 }
 
 static ssize_t
-cifs_read_wrapper(struct file * file, char *read_data, size_t read_size,
+cifs_read_wrapper(struct file * file, char __user *read_data, size_t read_size,
           loff_t * poffset)
 {
        if(file == NULL)
@@ -450,7 +455,7 @@ cifs_read_wrapper(struct file * file, char *read_data, size_t read_size,
 }
 
 static ssize_t
-cifs_write_wrapper(struct file * file, const char *write_data,
+cifs_write_wrapper(struct file * file, const char __user *write_data,
            size_t write_size, loff_t * poffset) 
 {
        ssize_t written;
@@ -504,7 +509,7 @@ struct inode_operations cifs_file_inode_ops = {
        .getattr = cifs_getattr, /* do we need this anymore? */
        .rename = cifs_rename,
        .permission = cifs_permission,
-#ifdef CIFS_XATTR
+#ifdef CONFIG_CIFS_XATTR
        .setxattr = cifs_setxattr,
        .getxattr = cifs_getxattr,
        .listxattr = cifs_listxattr,
@@ -519,7 +524,7 @@ struct inode_operations cifs_symlink_inode_ops = {
        /* BB add the following two eventually */
        /* revalidate: cifs_revalidate,
           setattr:    cifs_notify_change, *//* BB do we need notify change */
-#ifdef CIFS_XATTR
+#ifdef CONFIG_CIFS_XATTR
        .setxattr = cifs_setxattr,
        .getxattr = cifs_getxattr,
        .listxattr = cifs_listxattr,
@@ -537,7 +542,7 @@ struct file_operations cifs_file_ops = {
        .flush = cifs_flush,
        .mmap  = cifs_file_mmap,
        .sendfile = generic_file_sendfile,
-#ifdef CIFS_FCNTL
+#ifdef CONFIG_CIFS_FCNTL
        .fcntl = cifs_fcntl,
 #endif
 };
@@ -546,7 +551,7 @@ struct file_operations cifs_dir_ops = {
        .readdir = cifs_readdir,
        .release = cifs_closedir,
        .read    = generic_read_dir,
-#ifdef CIFS_FCNTL
+#ifdef CONFIG_CIFS_FCNTL
        .fcntl   = cifs_fcntl,
 #endif
 };
@@ -593,12 +598,23 @@ cifs_init_request_bufs(void)
        if (cifs_req_cachep == NULL)
                return -ENOMEM;
 
+       cifs_req_poolp = mempool_create(CIFS_MIN_RCV_POOL,
+                                       mempool_alloc_slab,
+                                       mempool_free_slab,
+                                       cifs_req_cachep);
+
+       if(cifs_req_poolp == NULL) {
+               kmem_cache_destroy(cifs_req_cachep);
+               return -ENOMEM;
+       }
+
        return 0;
 }
 
 static void
 cifs_destroy_request_bufs(void)
 {
+       mempool_destroy(cifs_req_poolp);
        if (kmem_cache_destroy(cifs_req_cachep))
                printk(KERN_WARNING
                       "cifs_destroy_request_cache: error not all structures were freed\n");
@@ -612,11 +628,22 @@ cifs_init_mids(void)
                                SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (cifs_mid_cachep == NULL)
                return -ENOMEM;
+
+       cifs_mid_poolp = mempool_create(3 /* a reasonable min simultan opers */,
+                                       mempool_alloc_slab,
+                                       mempool_free_slab,
+                                       cifs_mid_cachep);
+       if(cifs_mid_poolp == NULL) {
+               kmem_cache_destroy(cifs_mid_cachep);
+               return -ENOMEM;
+       }
+
        cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
                                sizeof (struct oplock_q_entry), 0,
                                SLAB_HWCACHE_ALIGN, NULL, NULL);
        if (cifs_oplock_cachep == NULL) {
                kmem_cache_destroy(cifs_mid_cachep);
+               mempool_destroy(cifs_mid_poolp);
                return -ENOMEM;
        }
 
@@ -626,9 +653,11 @@ cifs_init_mids(void)
 static void
 cifs_destroy_mids(void)
 {
+       mempool_destroy(cifs_mid_poolp);
        if (kmem_cache_destroy(cifs_mid_cachep))
                printk(KERN_WARNING
                       "cifs_destroy_mids: error not all structures were freed\n");
+
        if (kmem_cache_destroy(cifs_oplock_cachep))
                printk(KERN_WARNING
                       "error not all oplock structures were freed\n");