Whamcloud - gitweb
LU-5427 lbuild: Fix compilation with MPSS 3.3
[fs/lustre-release.git] / libcfs / libcfs / winnt / winnt-proc.c
index 5c10c4f..6364371 100644 (file)
@@ -26,6 +26,8 @@
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -62,27 +64,27 @@ cfs_proc_entry_t *              cfs_proc_dev = NULL;
 
 
 /* SLAB object for cfs_proc_entry_t allocation */
-cfs_mem_cache_t *               proc_entry_cache = NULL;
+struct kmem_cache *proc_entry_cache;
 
 /* root node for sysctl table */
-cfs_sysctl_table_header_t       root_table_header;
+struct ctl_table_header       root_table_header;
 
 /* The global lock to protect all the access */
 
 #if LIBCFS_PROCFS_SPINLOCK
-cfs_spinlock_t                  proc_fs_lock;
+spinlock_t                     proc_fs_lock;
 
-#define INIT_PROCFS_LOCK()      cfs_spin_lock_init(&proc_fs_lock)
-#define LOCK_PROCFS()           cfs_spin_lock(&proc_fs_lock)
-#define UNLOCK_PROCFS()         cfs_spin_unlock(&proc_fs_lock)
+#define INIT_PROCFS_LOCK()     spin_lock_init(&proc_fs_lock)
+#define LOCK_PROCFS()          spin_lock(&proc_fs_lock)
+#define UNLOCK_PROCFS()                spin_unlock(&proc_fs_lock)
 
 #else
 
-cfs_mutex_t                     proc_fs_lock;
+struct mutex                           proc_fs_lock;
 
 #define INIT_PROCFS_LOCK()      cfs_init_mutex(&proc_fs_lock)
-#define LOCK_PROCFS()           cfs_mutex_down(&proc_fs_lock)
-#define UNLOCK_PROCFS()         cfs_mutex_up(&proc_fs_lock)
+#define LOCK_PROCFS()           mutex_lock(&proc_fs_lock)
+#define UNLOCK_PROCFS()         mutex_unlock(&proc_fs_lock)
 
 #endif
 
@@ -96,9 +98,10 @@ proc_file_read(struct file * file, const char * buf, size_t nbytes, loff_t *ppos
     char    *start;
     cfs_proc_entry_t * dp;
 
-    dp = (cfs_proc_entry_t  *) file->f_inode->i_priv;
-    if (!(page = (char*) cfs_alloc(CFS_PAGE_SIZE, 0)))
-        return -ENOMEM;
+       dp = (cfs_proc_entry_t  *) file->f_inode->i_priv;
+       page = (char *) kmalloc(PAGE_CACHE_SIZE, 0);
+       if (page == NULL)
+               return -ENOMEM;
 
     while ((nbytes > 0) && !eof) {
 
@@ -130,7 +133,7 @@ proc_file_read(struct file * file, const char * buf, size_t nbytes, loff_t *ppos
             break;
         }
         
-        n -= cfs_copy_to_user((void *)buf, start, n);
+       n -= copy_to_user((void *)buf, start, n);
         if (n == 0) {
             if (retval == 0)
                 retval = -EFAULT;
@@ -142,9 +145,9 @@ proc_file_read(struct file * file, const char * buf, size_t nbytes, loff_t *ppos
         buf += n;
         retval += n;
     }
-    cfs_free(page);
+       kfree(page);
 
-    return retval;
+       return retval;
 }
 
 static ssize_t
@@ -179,10 +182,9 @@ proc_alloc_entry()
 {
     cfs_proc_entry_t * entry = NULL;
 
-    entry = cfs_mem_cache_alloc(proc_entry_cache, 0);
-    if (!entry) {
-        return NULL;
-    }
+       entry = kmem_cache_alloc(proc_entry_cache, 0);
+       if (!entry)
+               return NULL;
 
     memset(entry, 0, sizeof(cfs_proc_entry_t));
 
@@ -197,11 +199,9 @@ proc_alloc_entry()
 
 void
 proc_free_entry(cfs_proc_entry_t * entry)
-
 {
-    ASSERT(entry->magic == CFS_PROC_ENTRY_MAGIC);
-
-    cfs_mem_cache_free(proc_entry_cache, entry);
+       ASSERT(entry->magic == CFS_PROC_ENTRY_MAGIC);
+       kmem_cache_free(proc_entry_cache, entry);
 }
 
 /* dissect the path string for a given full proc path */
@@ -411,11 +411,10 @@ proc_search_entry(
     parent = root;
     entry = NULL;
 
-    ename = cfs_alloc(0x21, CFS_ALLOC_ZERO);
+       ename = kmalloc(0x21, __GFP_ZERO);
 
-    if (ename == NULL) {
-        goto errorout;
-    }
+       if (ename == NULL)
+               goto errorout;
 
 again:
 
@@ -450,7 +449,7 @@ again:
 errorout:
 
     if (ename) {
-        cfs_free(ename);
+       kfree(ename);
     }
 
     return entry;   
@@ -492,12 +491,10 @@ again:
             entry = proc_alloc_entry();
             memcpy(entry->name, ename, flen);
 
-            if (entry) {
-                if(!proc_insert_splay(parent, entry)) {
-                    proc_free_entry(entry);
-                    entry = NULL;
-                }
-            }
+               if (entry && !proc_insert_splay(parent, entry)) {
+                       proc_free_entry(entry);
+                       entry = NULL;
+               }
         }
 
         if (!entry) {
@@ -709,17 +706,15 @@ void proc_destory_subtree(cfs_proc_entry_t *entry)
 
 void proc_destroy_fs()
 {
-    LOCK_PROCFS();
+       LOCK_PROCFS();
 
-    if (cfs_proc_root) {
-        proc_destroy_splay(cfs_proc_root);
-    }
+       if (cfs_proc_root)
+               proc_destroy_splay(cfs_proc_root);
 
-    if (proc_entry_cache) {
-        cfs_mem_cache_destroy(proc_entry_cache);
-    }
+       if (proc_entry_cache)
+               kmem_cache_destroy(proc_entry_cache);
    
-    UNLOCK_PROCFS();
+       UNLOCK_PROCFS();
 }
 
 static char proc_item_path[512];
@@ -792,15 +787,11 @@ int proc_init_fs()
     cfs_proc_entry_t * root = NULL;
 
     memset(&(root_table_header), 0, sizeof(struct ctl_table_header));
-    CFS_INIT_LIST_HEAD(&(root_table_header.ctl_entry));
+    INIT_LIST_HEAD(&(root_table_header.ctl_entry));
 
     INIT_PROCFS_LOCK();
-    proc_entry_cache = cfs_mem_cache_create(
-                            NULL,
-                            sizeof(cfs_proc_entry_t),
-                            0,
-                            0
-                            );
+    proc_entry_cache = kmem_cache_create(NULL, sizeof(cfs_proc_entry_t),
+                                        0, 0, NULL);
 
     if (!proc_entry_cache) {
         return (-ENOMEM);
@@ -908,7 +899,7 @@ struct file_operations proc_sys_file_operations = {
 
 
 /* Scan the sysctl entries in table and add them all into /proc */
-void register_proc_table(cfs_sysctl_table_t * table, cfs_proc_entry_t * root)
+void register_proc_table(struct ctl_table * table, cfs_proc_entry_t * root)
 {
     cfs_proc_entry_t * de;
     int len;
@@ -918,12 +909,12 @@ void register_proc_table(cfs_sysctl_table_t * table, cfs_proc_entry_t * root)
         /* Can't do anything without a proc name. */
         if (!table->procname)
             continue;
-        /* Maybe we can't do anything with it... */
-        if (!table->proc_handler && !table->child) {
-            printk(CFS_KERN_WARNING "SYSCTL: Can't register %s\n",
-                table->procname);
-            continue;
-        }
+       /* Maybe we can't do anything with it... */
+       if (!table->proc_handler && !table->child) {
+           printk(KERN_WARNING "SYSCTL: Can't register %s\n",
+               table->procname);
+           continue;
+       }
 
         len = strlen(table->procname);
         mode = table->mode;
@@ -959,17 +950,17 @@ void register_proc_table(cfs_sysctl_table_t * table, cfs_proc_entry_t * root)
 /*
  * Unregister a /proc sysctl table and any subdirectories.
  */
-void unregister_proc_table(cfs_sysctl_table_t * table, cfs_proc_entry_t *root)
+void unregister_proc_table(struct ctl_table * table, cfs_proc_entry_t *root)
 {
     cfs_proc_entry_t *de;
     for (; table->ctl_name; table++) {
         if (!(de = table->de))
             continue;
         if (de->mode & S_IFDIR) {
-            if (!table->child) {
-                printk (CFS_KERN_ALERT "Help- malformed sysctl tree on free\n");
-                continue;
-            }
+           if (!table->child) {
+               printk (KERN_ALERT "Help- malformed sysctl tree on free\n");
+               continue;
+           }
             unregister_proc_table(table->child, de);
 
             /* Don't unregister directories which still have entries.. */
@@ -987,7 +978,7 @@ void unregister_proc_table(cfs_sysctl_table_t * table, cfs_proc_entry_t *root)
 }
 
 /* The generic string strategy routine: */
-int sysctl_string(cfs_sysctl_table_t *table, int *name, int nlen,
+int sysctl_string(struct ctl_table *table, int *name, int nlen,
           void *oldval, size_t *oldlenp,
           void *newval, size_t newlen, void **context)
 {
@@ -997,26 +988,27 @@ int sysctl_string(cfs_sysctl_table_t *table, int *name, int nlen,
         return -ENOTDIR;
     
     if (oldval && oldlenp) {
-        if(get_user(len, oldlenp))
+       if (get_user(len, oldlenp))
             return -EFAULT;
-        if (len) {
-            l = strlen(table->data);
-            if (len > l) len = l;
-            if (len >= table->maxlen)
-                len = table->maxlen;
-            if(cfs_copy_to_user(oldval, table->data, len))
-                return -EFAULT;
-            if(put_user(0, ((char *) oldval) + len))
-                return -EFAULT;
-            if(put_user(len, oldlenp))
-                return -EFAULT;
-        }
+       if (len) {
+               l = strlen(table->data);
+               if (len > l)
+                       len = l;
+               if (len >= table->maxlen)
+                       len = table->maxlen;
+               if (copy_to_user(oldval, table->data, len))
+                       return -EFAULT;
+               if (put_user(0, ((char *) oldval) + len))
+                       return -EFAULT;
+               if (put_user(len, oldlenp))
+                       return -EFAULT;
+       }
     }
     if (newval && newlen) {
         len = newlen;
         if (len > table->maxlen)
             len = table->maxlen;
-        if(cfs_copy_from_user(table->data, newval, len))
+       if (copy_from_user(table->data, newval, len))
             return -EFAULT;
         if (len == table->maxlen)
             len--;
@@ -1063,7 +1055,7 @@ unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
 #define OP_MIN  4
 
 
-static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *filp,
+static int do_proc_dointvec(struct ctl_table *table, int write,
           void *buffer, size_t *lenp, int conv, int op)
 {
     int *i, vleft, first=1, neg, val;
@@ -1086,12 +1078,12 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
         if (write) {
             while (left) {
                 char c;
-                if(get_user(c,(char *) buffer))
-                    return -EFAULT;
+               if (get_user(c, (char *)buffer))
+                       return -EFAULT;
                 if (!isspace(c))
-                    break;
+                       break;
                 left--;
-                ((char *) buffer)++;
+               ((char *)buffer)++;
             }
             if (!left)
                 break;
@@ -1099,7 +1091,7 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
             len = left;
             if (len > TMPBUFLEN-1)
                 len = TMPBUFLEN-1;
-            if(cfs_copy_from_user(buf, buffer, len))
+           if (copy_from_user(buf, buffer, len))
                 return -EFAULT;
             buf[len] = 0;
             p = buf;
@@ -1117,17 +1109,25 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
                 val = -val;
             (char *)buffer += len;
             left -= len;
-            switch(op) {
-            case OP_SET:    *i = val; break;
-            case OP_AND:    *i &= val; break;
-            case OP_OR: *i |= val; break;
-            case OP_MAX:    if(*i < val)
-                        *i = val;
-                    break;
-            case OP_MIN:    if(*i > val)
-                        *i = val;
-                    break;
-            }
+               switch(op) {
+               case OP_SET:
+                       *i = val;
+                       break;
+               case OP_AND:
+                       *i &= val;
+                       break;
+               case OP_OR:
+                       *i |= val;
+                       break;
+               case OP_MAX:
+                       if (*i < val)
+                               *i = val;
+                       break;
+               case OP_MIN:
+                       if (*i > val)
+                               *i = val;
+                       break;
+               }
         } else {
             p = buf;
             if (!first)
@@ -1136,7 +1136,7 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
             len = strlen(buf);
             if (len > left)
                 len = left;
-            if(cfs_copy_to_user(buffer, buf, len))
+           if (copy_to_user(buffer, buf, len))
                 return -EFAULT;
             left -= len;
             (char *)buffer += len;
@@ -1144,7 +1144,7 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
     }
 
     if (!write && !first && left) {
-        if(put_user('\n', (char *) buffer))
+       if (put_user('\n', (char *) buffer))
             return -EFAULT;
         left--, ((char *)buffer)++;
     }
@@ -1152,7 +1152,7 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
         p = (char *) buffer;
         while (left) {
             char c;
-            if(get_user(c, p++))
+           if (get_user(c, p++))
                 return -EFAULT;
             if (!isspace(c))
                 break;
@@ -1162,8 +1162,6 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
     if (write && first)
         return -EINVAL;
     *lenp -= left;
-    memset(&(filp->f_pos) , 0, sizeof(loff_t));
-    filp->f_pos += (loff_t)(*lenp);
     return 0;
 }
 
@@ -1171,7 +1169,6 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
  * proc_dointvec - read a vector of integers
  * @table: the sysctl table
  * @write: %TRUE if this is a write to the sysctl file
- * @filp: the file structure
  * @buffer: the user buffer
  * @lenp: the size of the user buffer
  *
@@ -1180,10 +1177,10 @@ static int do_proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *f
  *
  * Returns 0 on success.
  */
-int proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *filp,
+int proc_dointvec(struct ctl_table *table, int write,
              void *buffer, size_t *lenp)
 {
-    return do_proc_dointvec(table,write,filp,buffer,lenp,1,OP_SET);
+    return do_proc_dointvec(table,write,buffer,lenp,1,OP_SET);
 }
 
 
@@ -1191,7 +1188,6 @@ int proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *filp,
  * proc_dostring - read a string sysctl
  * @table: the sysctl table
  * @write: %TRUE if this is a write to the sysctl file
- * @filp: the file structure
  * @buffer: the user buffer
  * @lenp: the size of the user buffer
  *
@@ -1204,14 +1200,14 @@ int proc_dointvec(cfs_sysctl_table_t *table, int write, struct file *filp,
  *
  * Returns 0 on success.
  */
-int proc_dostring(cfs_sysctl_table_t *table, int write, struct file *filp,
+int proc_dostring(struct ctl_table *table, int write,
           void *buffer, size_t *lenp)
 {
     size_t len;
     char *p, c;
     
     if (!table->data || !table->maxlen || !*lenp ||
-        (filp->f_pos && !write)) {
+       (!write)) {
         *lenp = 0;
         return 0;
     }
@@ -1220,7 +1216,7 @@ int proc_dostring(cfs_sysctl_table_t *table, int write, struct file *filp,
         len = 0;
         p = buffer;
         while (len < *lenp) {
-            if(get_user(c, p++))
+           if (get_user(c, p++))
                 return -EFAULT;
             if (c == 0 || c == '\n')
                 break;
@@ -1228,10 +1224,9 @@ int proc_dostring(cfs_sysctl_table_t *table, int write, struct file *filp,
         }
         if (len >= (size_t)table->maxlen)
             len = (size_t)table->maxlen-1;
-        if(cfs_copy_from_user(table->data, buffer, len))
+       if (copy_from_user(table->data, buffer, len))
             return -EFAULT;
         ((char *) table->data)[len] = 0;
-        filp->f_pos += *lenp;
     } else {
         len = (size_t)strlen(table->data);
         if (len > (size_t)table->maxlen)
@@ -1239,24 +1234,22 @@ int proc_dostring(cfs_sysctl_table_t *table, int write, struct file *filp,
         if (len > *lenp)
             len = *lenp;
         if (len)
-            if(cfs_copy_to_user(buffer, table->data, len))
+           if (copy_to_user(buffer, table->data, len))
                 return -EFAULT;
         if (len < *lenp) {
-            if(put_user('\n', ((char *) buffer) + len))
+           if (put_user('\n', ((char *) buffer) + len))
                 return -EFAULT;
             len++;
         }
         *lenp = len;
-        filp->f_pos += len;
     }
     return 0;
 }
 
 /* Perform the actual read/write of a sysctl table entry. */
-int do_sysctl_strategy (cfs_sysctl_table_t *table, 
-            int *name, int nlen,
-            void *oldval, size_t *oldlenp,
-            void *newval, size_t newlen, void **context)
+int do_sysctl_strategy(struct ctl_table *table, int *name, int nlen,
+                      void *oldval, size_t *oldlenp, void *newval,
+                      size_t newlen, void **context)
 {
     int op = 0, rc;
     size_t len;
@@ -1283,9 +1276,9 @@ int do_sysctl_strategy (cfs_sysctl_table_t *table,
             if (len) {
                 if (len > (size_t)table->maxlen)
                     len = (size_t)table->maxlen;
-                if(cfs_copy_to_user(oldval, table->data, len))
+               if (copy_to_user(oldval, table->data, len))
                     return -EFAULT;
-                if(put_user(len, oldlenp))
+               if (put_user(len, oldlenp))
                     return -EFAULT;
             }
         }
@@ -1293,7 +1286,7 @@ int do_sysctl_strategy (cfs_sysctl_table_t *table,
             len = newlen;
             if (len > (size_t)table->maxlen)
                 len = (size_t)table->maxlen;
-            if(cfs_copy_from_user(table->data, newval, len))
+           if (copy_from_user(table->data, newval, len))
                 return -EFAULT;
         }
     }
@@ -1301,9 +1294,9 @@ int do_sysctl_strategy (cfs_sysctl_table_t *table,
 }
 
 static int parse_table(int *name, int nlen,
-               void *oldval, size_t *oldlenp,
-               void *newval, size_t newlen,
-               cfs_sysctl_table_t *table, void **context)
+              void *oldval, size_t *oldlenp,
+              void *newval, size_t newlen,
+              struct ctl_table *table, void **context)
 {
     int n;
 
@@ -1346,7 +1339,7 @@ repeat:
 int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
            void *newval, size_t newlen)
 {
-    cfs_list_t *tmp;
+    struct list_head *tmp;
 
     if (nlen <= 0 || nlen >= CTL_MAXNAME)
         return -ENOTDIR;
@@ -1358,13 +1351,13 @@ int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
     tmp = &root_table_header.ctl_entry;
     do {
         struct ctl_table_header *head =
-            cfs_list_entry(tmp, struct ctl_table_header, ctl_entry);
+           list_entry(tmp, struct ctl_table_header, ctl_entry);
         void *context = NULL;
         int error = parse_table(name, nlen, oldval, oldlenp, 
                     newval, newlen, head->ctl_table,
                     &context);
         if (context)
-            cfs_free(context);
+           kfree(context);
         if (error != -ENOTDIR)
             return error;
         tmp = tmp->next;
@@ -1441,24 +1434,21 @@ int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
  * This routine returns %NULL on a failure to register, and a pointer
  * to the table header on success.
  */
-struct ctl_table_header *register_sysctl_table(cfs_sysctl_table_t * table, 
-                           int insert_at_head)
+struct ctl_table_header *
+register_sysctl_table(struct ctl_table *table)
 {
-    struct ctl_table_header *tmp;
-    tmp = cfs_alloc(sizeof(struct ctl_table_header), 0);
-    if (!tmp)
-        return NULL;
-    tmp->ctl_table = table;
+       struct ctl_table_header *tmp;
+       tmp = kmalloc(sizeof(struct ctl_table_header), 0);
+       if (!tmp)
+               return NULL;
+       tmp->ctl_table = table;
 
-    CFS_INIT_LIST_HEAD(&tmp->ctl_entry);
-    if (insert_at_head)
-        cfs_list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
-    else
-        cfs_list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
+       INIT_LIST_HEAD(&tmp->ctl_entry);
+       list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
 #ifdef CONFIG_PROC_FS
-    register_proc_table(table, cfs_proc_sys);
+       register_proc_table(table, cfs_proc_sys);
 #endif
-    return tmp;
+       return tmp;
 }
 
 /**
@@ -1470,15 +1460,15 @@ struct ctl_table_header *register_sysctl_table(cfs_sysctl_table_t * table,
  */
 void unregister_sysctl_table(struct ctl_table_header * header)
 {
-    cfs_list_del(&header->ctl_entry);
+    list_del(&header->ctl_entry);
 #ifdef CONFIG_PROC_FS
     unregister_proc_table(header->ctl_table, cfs_proc_sys);
 #endif
-    cfs_free(header);
+    kfree(header);
 }
 
 
-int cfs_psdev_register(cfs_psdev_t * psdev)
+int misc_register(struct miscdevice * psdev)
 {
     cfs_proc_entry_t *  entry;
 
@@ -1500,7 +1490,7 @@ int cfs_psdev_register(cfs_psdev_t * psdev)
     return 0;
 }
 
-int cfs_psdev_deregister(cfs_psdev_t * psdev)
+int misc_deregister(struct miscdevice * psdev)
 {
     cfs_proc_entry_t *  entry;
 
@@ -1645,26 +1635,24 @@ void remove_proc(void)
  *  proc process routines of kernel space
  */
 
-cfs_file_t *
-lustre_open_file(char * filename)
+struct file *
+lustre_open_file(char *filename)
 {
-    int rc = 0;
-    cfs_file_t * fh = NULL;
-    cfs_proc_entry_t * fp = NULL;
+       int rc = 0;
+       struct file *fh = NULL;
+       cfs_proc_entry_t *fp = NULL;
 
-    fp = search_proc_entry(filename, cfs_proc_root);
-    if (!fp) {
-        return NULL;
-    }
+       fp = search_proc_entry(filename, cfs_proc_root);
+       if (fp == NULL)
+               return NULL;
 
-    fh = cfs_alloc(sizeof(cfs_file_t), CFS_ALLOC_ZERO);
-    if (!fh) {
-        return NULL;
-    }
+       fh = kmalloc(sizeof(*fh), __GFP_ZERO);
+       if (fh == NULL)
+               return NULL;
 
-    fh->f_inode = cfs_alloc(sizeof(struct inode), CFS_ALLOC_ZERO);
+    fh->f_inode = kmalloc(sizeof(struct inode), __GFP_ZERO);
     if (!fh->f_inode) {
-        cfs_free(fh);
+       kfree(fh);
         return NULL;
     }
 
@@ -1678,8 +1666,8 @@ lustre_open_file(char * filename)
     }
 
     if (0 != rc) {
-        cfs_free(fh->f_inode);
-        cfs_free(fh);
+       kfree(fh->f_inode);
+       kfree(fh);
         return NULL;
     }
 
@@ -1687,10 +1675,10 @@ lustre_open_file(char * filename)
 }
 
 int
-lustre_close_file(cfs_file_t * fh)
+lustre_close_file(struct file *fh)
 {
-    int rc = 0;
-    cfs_proc_entry_t * fp = NULL;
+       int rc = 0;
+       cfs_proc_entry_t *fp = NULL;
 
     fp = (cfs_proc_entry_t *) fh->f_inode->i_priv;
     if (fh->f_op->release) {
@@ -1699,28 +1687,25 @@ lustre_close_file(cfs_file_t * fh)
         fp->nlink--;
     }
 
-    cfs_free(fh->f_inode);
-    cfs_free(fh);
+    kfree(fh->f_inode);
+    kfree(fh);
 
     return rc;
 }
 
 int
-lustre_do_ioctl( cfs_file_t * fh,
-                 unsigned long cmd,
-                 ulong_ptr_t arg )
+lustre_do_ioctl(struct file *fh, unsigned long cmd, ulong_ptr_t arg)
 {
-    int rc = 0;
+       int rc = 0;
 
-    if (fh->f_op->ioctl) {
-        rc = (fh->f_op->ioctl)(fh, cmd, arg);
-    }
+       if (fh->f_op->ioctl)
+               rc = (fh->f_op->ioctl)(fh, cmd, arg);
 
-    return rc;
+       return rc;
 }
-    
+
 int
-lustre_ioctl_file(cfs_file_t * fh, PCFS_PROC_IOCTL devctl)
+lustre_ioctl_file(struct file *fh, PCFS_PROC_IOCTL devctl)
 {
     int         rc = 0;
     ulong_ptr_t data;
@@ -1761,16 +1746,10 @@ lustre_ioctl_file(cfs_file_t * fh, PCFS_PROC_IOCTL devctl)
     rc = lustre_do_ioctl(fh, devctl->cmd, data);
 
     return rc;
-} 
-
+}
 
 size_t
-lustre_read_file(
-    cfs_file_t *    fh,
-    loff_t          off,
-    size_t          size,
-    char *          buf
-    )
+lustre_read_file(struct file *fh, loff_t off, size_t size, char *buf)
 {
     size_t  rc = 0;
     off_t   low, high;
@@ -1788,24 +1767,18 @@ lustre_read_file(
 
     return rc;
 }
 
 size_t
-lustre_write_file(
-    cfs_file_t *    fh,
-    loff_t          off,
-    size_t          size,
-    char *          buf
-    )
+lustre_write_file(struct file *fh, loff_t off, size_t size, char *buf)
 {
-    size_t rc = 0;
-    off = 0;
-    if (fh->f_op->write) {
-        rc = (fh->f_op->write)(fh, buf, size, &off);
-    }
+       size_t rc = 0;
 
-    return rc;
-}  
+       off = 0;
+       if (fh->f_op->write)
+               rc = (fh->f_op->write)(fh, buf, size, &off);
+
+       return rc;
+}
 
 
 /*
@@ -1836,7 +1809,7 @@ int seq_open(struct file *file, const struct seq_operations *op)
                file->private_data = p;
        }
        memset(p, 0, sizeof(*p));
-       cfs_mutex_init(&p->lock);
+       mutex_init(&p->lock);
        p->op = op;
 
        /*
@@ -1870,7 +1843,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
        void *p;
        int err = 0;
 
-       cfs_mutex_lock(&m->lock);
+       mutex_lock(&m->lock);
        /*
         * seq_file->op->..m_start/m_stop/m_next may do special actions
         * or optimisations based on the file->f_version, so we want to
@@ -1892,7 +1865,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
        /* if not empty - flush it first */
        if (m->count) {
                n = min(m->count, size);
-               err = cfs_copy_to_user(buf, m->buf + m->from, n);
+               err = copy_to_user(buf, m->buf + m->from, n);
                if (err)
                        goto Efault;
                m->count -= n;
@@ -1918,7 +1891,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
                if (m->count < m->size)
                        goto Fill;
                m->op->stop(m, p);
-               cfs_free(m->buf);
+               kfree(m->buf);
                m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
                if (!m->buf)
                        goto Enomem;
@@ -1947,7 +1920,7 @@ Fill:
        }
        m->op->stop(m, p);
        n = min(m->count, size);
-       err = cfs_copy_to_user(buf, m->buf, n);
+       err = copy_to_user(buf, m->buf, n);
        if (err)
                goto Efault;
        copied += n;
@@ -1963,7 +1936,7 @@ Done:
        else
                *ppos += copied;
        file->f_version = m->version;
-       cfs_mutex_unlock(&m->lock);
+       mutex_unlock(&m->lock);
        return copied;
 Enomem:
        err = -ENOMEM;
@@ -2022,8 +1995,8 @@ static int traverse(struct seq_file *m, loff_t offset)
 
 Eoverflow:
        m->op->stop(m, p);
-       cfs_free(m->buf);
-       m->buf = cfs_alloc(m->size <<= 1, GFP_KERNEL | CFS_ALLOC_ZERO);
+       kfree(m->buf);
+       m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | __GFP_ZERO);
        return !m->buf ? -ENOMEM : -EAGAIN;
 }
 
@@ -2040,7 +2013,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
        struct seq_file *m = (struct seq_file *)file->private_data;
        long long retval = -EINVAL;
 
-       cfs_mutex_lock(&m->lock);
+       mutex_lock(&m->lock);
        m->version = file->f_version;
        switch (origin) {
                case 1:
@@ -2064,7 +2037,7 @@ loff_t seq_lseek(struct file *file, loff_t offset, int origin)
                        }
        }
        file->f_version = m->version;
-       cfs_mutex_unlock(&m->lock);
+       mutex_unlock(&m->lock);
        return retval;
 }
 EXPORT_SYMBOL(seq_lseek);
@@ -2082,8 +2055,8 @@ int seq_release(struct inode *inode, struct file *file)
        struct seq_file *m = (struct seq_file *)file->private_data;
     if (m) {
         if (m->buf)
-               cfs_free(m->buf);
-           cfs_free(m);
+               kfree(m->buf);
+           kfree(m);
     }
        return 0;
 }
@@ -2210,7 +2183,7 @@ int single_open(struct file *file, int (*show)(struct seq_file *, void *),
                if (!res)
                        ((struct seq_file *)file->private_data)->private = data;
                else
-                       cfs_free(op);
+                       kfree(op);
        }
        return res;
 }
@@ -2220,7 +2193,7 @@ int single_release(struct inode *inode, struct file *file)
 {
        const struct seq_operations *op = ((struct seq_file *)file->private_data)->op;
        int res = seq_release(inode, file);
-       cfs_free((void *)op);
+       kfree((void *)op);
        return res;
 }
 EXPORT_SYMBOL(single_release);
@@ -2229,7 +2202,7 @@ int seq_release_private(struct inode *inode, struct file *file)
 {
        struct seq_file *seq = file->private_data;
 
-       cfs_free(seq->private);
+       kfree(seq->private);
        seq->private = NULL;
        return seq_release(inode, file);
 }
@@ -2242,7 +2215,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops,
        void *private;
        struct seq_file *seq;
 
-       private = cfs_alloc(psize, GFP_KERNEL | CFS_ALLOC_ZERO);
+       private = kmalloc(psize, GFP_KERNEL | __GFP_ZERO);
        if (private == NULL)
                goto out;
 
@@ -2255,7 +2228,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops,
        return private;
 
 out_free:
-       cfs_free(private);
+       kfree(private);
 out:
        return NULL;
 }
@@ -2291,11 +2264,11 @@ int seq_puts(struct seq_file *m, const char *s)
 }
 EXPORT_SYMBOL(seq_puts);
 
-cfs_list_t *seq_list_start(cfs_list_t *head, loff_t pos)
+struct list_head *seq_list_start(struct list_head *head, loff_t pos)
 {
-       cfs_list_t *lh;
+       struct list_head *lh;
 
-       cfs_list_for_each(lh, head)
+       list_for_each(lh, head)
                if (pos-- == 0)
                        return lh;
 
@@ -2304,7 +2277,7 @@ cfs_list_t *seq_list_start(cfs_list_t *head, loff_t pos)
 
 EXPORT_SYMBOL(seq_list_start);
 
-cfs_list_t *seq_list_start_head(cfs_list_t *head,
+struct list_head *seq_list_start_head(struct list_head *head,
                                 loff_t pos)
 {
        if (!pos)
@@ -2315,12 +2288,12 @@ cfs_list_t *seq_list_start_head(cfs_list_t *head,
 
 EXPORT_SYMBOL(seq_list_start_head);
 
-cfs_list_t *seq_list_next(void *v, cfs_list_t *head,
+struct list_head *seq_list_next(void *v, struct list_head *head,
                           loff_t *ppos)
 {
-       cfs_list_t *lh;
+       struct list_head *lh;
 
-       lh = ((cfs_list_t *)v)->next;
+       lh = ((struct list_head *)v)->next;
        ++*ppos;
        return lh == head ? NULL : lh;
 }