Whamcloud - gitweb
LU-5275 lprocfs: reduce scope of params_tree.h
[fs/lustre-release.git] / lustre / obdclass / lprocfs_status.c
index e38c39d..259b79c 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -124,26 +124,29 @@ static const struct file_operations lprocfs_generic_fops = { };
 ssize_t
 lprocfs_fops_read(struct file *f, char __user *buf, size_t size, loff_t *ppos)
 {
-        struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
-        char *page, *start = NULL;
-        int rc = 0, eof = 1, count;
+       struct inode *inode = f->f_dentry->d_inode;
+       struct proc_dir_entry *dp = PDE(inode);
+       char *page, *start = NULL;
+       int rc, eof = 1, count;
 
        if (*ppos >= PAGE_CACHE_SIZE)
-                return 0;
+               return 0;
 
-        page = (char *)__get_free_page(GFP_KERNEL);
-        if (page == NULL)
-                return -ENOMEM;
+       page = (char *)__get_free_page(GFP_KERNEL);
+       if (page == NULL)
+               return -ENOMEM;
 
-       if (LPROCFS_ENTRY_CHECK(dp)) {
-                rc = -ENOENT;
-                goto out;
-        }
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               goto out;
 
-        OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
-        if (dp->read_proc)
+       OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
+       if (dp->read_proc != NULL)
                rc = dp->read_proc(page, &start, *ppos, PAGE_CACHE_SIZE,
-                                   &eof, dp->data);
+                                  &eof, dp->data);
+       else
+               rc = 0;
+
         if (rc <= 0)
                 goto out;
 
@@ -177,14 +180,20 @@ ssize_t
 lprocfs_fops_write(struct file *f, const char __user *buf, size_t size,
                   loff_t *ppos)
 {
-        struct proc_dir_entry *dp = PDE(f->f_dentry->d_inode);
-        int rc = -EIO;
+       struct inode *inode = f->f_dentry->d_inode;
+       struct proc_dir_entry *dp = PDE(inode);
+       int rc;
 
-       if (LPROCFS_ENTRY_CHECK(dp))
-                return -ENOENT;
-        if (dp->write_proc)
-                rc = dp->write_proc(f, buf, size, dp->data);
-        return rc;
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
+
+       if (dp->write_proc != NULL)
+               rc = dp->write_proc(f, buf, size, dp->data);
+       else
+               rc = -EIO;
+
+       return rc;
 }
 
 static struct file_operations lprocfs_generic_fops = {
@@ -358,7 +367,7 @@ lprocfs_seq_add_vars(struct proc_dir_entry *root, struct lprocfs_seq_vars *list,
 EXPORT_SYMBOL(lprocfs_seq_add_vars);
 
 #ifndef HAVE_ONLY_PROCFS_SEQ
-void lprocfs_remove_nolock(struct proc_dir_entry **proot)
+static void lprocfs_remove_nolock(struct proc_dir_entry **proot)
 {
        struct proc_dir_entry *root = *proot;
        struct proc_dir_entry *temp = root;
@@ -519,7 +528,7 @@ int lprocfs_uint_seq_show(struct seq_file *m, void *data)
 }
 EXPORT_SYMBOL(lprocfs_uint_seq_show);
 
-int lprocfs_wr_uint(struct file *file, const char *buffer,
+int lprocfs_wr_uint(struct file *file, const char __user *buffer,
                     unsigned long count, void *data)
 {
         unsigned *p = data;
@@ -539,7 +548,7 @@ int lprocfs_wr_uint(struct file *file, const char *buffer,
 }
 EXPORT_SYMBOL(lprocfs_wr_uint);
 
-ssize_t lprocfs_uint_seq_write(struct file *file, const char *buffer,
+ssize_t lprocfs_uint_seq_write(struct file *file, const char __user *buffer,
                               size_t count, loff_t *off)
 {
        int *data = ((struct seq_file *)file->private_data)->private;
@@ -569,7 +578,7 @@ int lprocfs_atomic_seq_show(struct seq_file *m, void *data)
 EXPORT_SYMBOL(lprocfs_atomic_seq_show);
 
 ssize_t
-lprocfs_atomic_seq_write(struct file *file, const char *buffer,
+lprocfs_atomic_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
        atomic_t *atm = ((struct seq_file *)file->private_data)->private;
@@ -1391,8 +1400,9 @@ void lprocfs_clear_stats(struct lprocfs_stats *stats)
 }
 EXPORT_SYMBOL(lprocfs_clear_stats);
 
-static ssize_t lprocfs_stats_seq_write(struct file *file, const char *buf,
-                                       size_t len, loff_t *off)
+static ssize_t lprocfs_stats_seq_write(struct file *file,
+                                      const char __user *buf,
+                                      size_t len, loff_t *off)
 {
         struct seq_file *seq = file->private_data;
         struct lprocfs_stats *stats = seq->private;
@@ -1465,7 +1475,7 @@ out:
        return (rc < 0) ? rc : 0;
 }
 
-struct seq_operations lprocfs_stats_seq_sops = {
+static const struct seq_operations lprocfs_stats_seq_sops = {
        .start  = lprocfs_stats_seq_start,
        .stop   = lprocfs_stats_seq_stop,
        .next   = lprocfs_stats_seq_next,
@@ -1477,10 +1487,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
        struct seq_file *seq;
        int rc;
 
-#ifndef HAVE_ONLY_PROCFS_SEQ
-       if (LPROCFS_ENTRY_CHECK(PDE(inode)))
-               return -ENOENT;
-#endif
+       rc = LPROCFS_ENTRY_CHECK(inode);
+       if (rc < 0)
+               return rc;
+
        rc = seq_open(file, &lprocfs_stats_seq_sops);
        if (rc)
                return rc;
@@ -1489,7 +1499,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
        return 0;
 }
 
-struct file_operations lprocfs_stats_seq_fops = {
+static const struct file_operations lprocfs_stats_seq_fops = {
         .owner   = THIS_MODULE,
         .open    = lprocfs_stats_seq_open,
         .read    = seq_read,
@@ -1726,14 +1736,14 @@ __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
 }
 EXPORT_SYMBOL(lprocfs_read_helper);
 
-int lprocfs_write_helper(const char *buffer, unsigned long count,
+int lprocfs_write_helper(const char __user *buffer, unsigned long count,
                          int *val)
 {
         return lprocfs_write_frac_helper(buffer, count, val, 1);
 }
 EXPORT_SYMBOL(lprocfs_write_helper);
 
-int lprocfs_write_frac_helper(const char *buffer, unsigned long count,
+int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count,
                               int *val, int mult)
 {
         char kernbuf[20], *end, *pbuf;
@@ -1856,14 +1866,16 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
 }
 EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);
 
-int lprocfs_write_u64_helper(const char *buffer, unsigned long count,__u64 *val)
+int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
+                            __u64 *val)
 {
         return lprocfs_write_frac_u64_helper(buffer, count, val, 1);
 }
 EXPORT_SYMBOL(lprocfs_write_u64_helper);
 
-int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
-                              __u64 *val, int mult)
+int lprocfs_write_frac_u64_helper(const char __user *buffer,
+                                 unsigned long count,
+                                 __u64 *val, int mult)
 {
         char kernbuf[22], *end, *pbuf;
         __u64 whole, frac = 0, units;
@@ -2046,16 +2058,17 @@ void lprocfs_oh_clear(struct obd_histogram *oh)
 EXPORT_SYMBOL(lprocfs_oh_clear);
 
 int lprocfs_obd_rd_max_pages_per_rpc(char *page, char **start, off_t off,
-                                     int count, int *eof, void *data)
+                                    int count, int *eof, void *data)
 {
-        struct obd_device *dev = data;
-        struct client_obd *cli = &dev->u.cli;
-        int rc;
+       struct obd_device *dev = data;
+       struct client_obd *cli = &dev->u.cli;
+       int rc;
 
-        client_obd_list_lock(&cli->cl_loi_list_lock);
-        rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);
-        client_obd_list_unlock(&cli->cl_loi_list_lock);
-        return rc;
+       spin_lock(&cli->cl_loi_list_lock);
+       rc = snprintf(page, count, "%d\n", cli->cl_max_pages_per_rpc);
+       spin_unlock(&cli->cl_loi_list_lock);
+
+       return rc;
 }
 EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc);
 
@@ -2065,9 +2078,9 @@ int lprocfs_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *data)
        struct client_obd *cli = &dev->u.cli;
        int rc;
 
-       client_obd_list_lock(&cli->cl_loi_list_lock);
+       spin_lock(&cli->cl_loi_list_lock);
        rc = seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
-       client_obd_list_unlock(&cli->cl_loi_list_lock);
+       spin_unlock(&cli->cl_loi_list_lock);
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_obd_max_pages_per_rpc_seq_show);