* 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/
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;
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 = {
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;
}
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;
}
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;
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;
}
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;
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,
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;
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,
}
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;
}
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;
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);
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);