# f73a1c7d117d07a96d89475066188a2b79e53c48
#
AC_DEFUN([LC_HAVE_BIO_END_SECTOR], [
-LB_CHECK_COMPILE([if 'bio_end_sector is defined],
+LB_CHECK_COMPILE([if 'bio_end_sector' is defined],
bio_end_sector, [
#include <linux/bio.h>
],[
]) # LC_HAVE_BIO_END_SECTOR
#
-# LC_HAVE_ONLY_PROCFS_SEQ
+# LC_HAVE_REMOVE_PROC_SUBTREE
#
-# 3.10+ only supports procfs seq_files handling
+# 3.10 introduced remove_proc_subtree
#
-AC_DEFUN([LC_HAVE_ONLY_PROCFS_SEQ], [
-LB_CHECK_COMPILE([if procfs only supports using 'seq_files'],
-only_procfs_seq_files, [
+AC_DEFUN([LC_HAVE_REMOVE_PROC_SUBTREE], [
+LB_CHECK_COMPILE([if 'remove_proc_subtree' is defined],
+remove_proc_subtree, [
#include <linux/proc_fs.h>
],[
- ((struct proc_dir_entry *)0)->write_proc(NULL, NULL, 0, NULL);
-], [], [
- AC_DEFINE(HAVE_ONLY_PROCFS_SEQ, 1,
- [only seq_files supported])
+ remove_proc_subtree(NULL, NULL);
+], [
+ AC_DEFINE(HAVE_REMOVE_PROC_SUBTREE, 1,
+ [remove_proc_subtree is defined])
+])
+]) # LC_HAVE_REMOVE_PROC_SUBTREE
+
+#
+# LC_HAVE_PROC_REMOVE
+#
+# 3.10 introduced proc_remove
+#
+AC_DEFUN([LC_HAVE_PROC_REMOVE], [
+LB_CHECK_COMPILE([if 'proc_remove' is defined],
+proc_remove, [
+ #include <linux/proc_fs.h>
+],[
+ proc_remove(NULL);
+], [
+ AC_DEFINE(HAVE_PROC_REMOVE, 1,
+ [proc_remove is defined])
])
-]) # LC_HAVE_ONLY_PROCFS_SEQ
+]) # LC_HAVE_PROC_REMOVE
#
# LC_BLKDEV_RELEASE_RETURN_INT
LC_HAVE_BIO_END_SECTOR
# 3.10
- LC_HAVE_ONLY_PROCFS_SEQ
LC_BLKDEV_RELEASE_RETURN_INT
+ LC_HAVE_REMOVE_PROC_SUBTREE
+ LC_HAVE_PROC_REMOVE
# 3.11
LC_INVALIDATE_RANGE
*
* lustre/include/lprocfs_status.h
*
- * Top level header file for LProc SNMP
+ * Top level header file for LProc
*
* Author: Hariharan Thantry thantry@users.sourceforge.net
*/
-#ifndef _LPROCFS_SNMP_H
-#define _LPROCFS_SNMP_H
+#ifndef _LPROCFS_STATUS_H
+#define _LPROCFS_STATUS_H
#include <linux/fs.h>
#include <linux/proc_fs.h>
#include <lustre/lustre_idl.h>
-#ifndef HAVE_ONLY_PROCFS_SEQ
-struct lprocfs_vars {
- const char *name;
- read_proc_t *read_fptr;
- write_proc_t *write_fptr;
- void *data;
- const struct file_operations *fops;
- /**
- * /proc file mode.
- */
- mode_t proc_mode;
-};
-
-struct lprocfs_static_vars {
- struct lprocfs_vars *module_vars;
- struct lprocfs_vars *obd_vars;
-};
-
-#endif
-
struct lprocfs_seq_vars {
const char *name;
const struct file_operations *fops;
struct lprocfs_stats *stats);
/* lprocfs_status.c */
-#ifndef HAVE_ONLY_PROCFS_SEQ
-extern int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data);
-
-extern struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list,
- void *data);
-#endif
extern int lprocfs_seq_add_vars(struct proc_dir_entry *root,
struct lprocfs_seq_vars *var,
void *data);
extern void lprocfs_remove(struct proc_dir_entry **root);
extern void lprocfs_remove_proc_entry(const char *name,
struct proc_dir_entry *parent);
-#ifndef HAVE_ONLY_PROCFS_SEQ
-extern void lprocfs_try_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent);
-
-extern struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *root,
- const char *name);
-
+#ifndef HAVE_REMOVE_PROC_SUBTREE
+extern int remove_proc_subtree(const char *name,
+ struct proc_dir_entry *parent);
#define PDE_DATA(inode) (PDE(inode)->data)
static inline int LPROCFS_ENTRY_CHECK(struct inode *inode)
lprocfs_timeouts_seq_write(struct file *file, const char *buffer,
size_t count, loff_t *off);
#ifdef HAVE_SERVER_SUPPORT
-#ifndef HAVE_ONLY_PROCFS_SEQ
-extern ssize_t lprocfs_fops_read(struct file *f, char __user *buf,
- size_t size, loff_t *ppos);
-extern ssize_t lprocfs_fops_write(struct file *f, const char __user *buf,
- size_t size, loff_t *ppos);
-#endif
extern ssize_t
lprocfs_evict_client_seq_write(struct file *file, const char *buffer,
size_t count, loff_t *off);
lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
const char *format, ...)
{return NULL; }
-#ifndef HAVE_ONLY_PROCFS_SEQ
-static inline struct proc_dir_entry *
-lprocfs_register(const char *name, struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
-{ return NULL; }
-static inline int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data)
-{ return 0; }
-#endif
static inline int lprocfs_seq_add_vars(struct proc_dir_entry *root,
struct lprocfs_seq_vars *var,
void *data)
static inline void lprocfs_remove_proc_entry(const char *name,
struct proc_dir_entry *parent)
{ return; }
-#ifndef HAVE_ONLY_PROCFS_SEQ
-static inline void lprocfs_try_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent)
-{ return; }
-static inline struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
- const char *name)
-{ return 0; }
-#endif
static inline int lprocfs_obd_setup(struct obd_device *dev)
{ return 0; }
static inline int lprocfs_obd_cleanup(struct obd_device *dev)
#endif /* CONFIG_PROC_FS */
-#endif /* LPROCFS_SNMP_H */
+#endif /* LPROCFS_STATUS_H */
#define DEBUG_SUBSYSTEM S_CLASS
-
#include <obd_class.h>
#include <lprocfs_status.h>
#include <lustre/lustre_idl.h>
}
EXPORT_SYMBOL(lprocfs_add_symlink);
-#ifdef HAVE_ONLY_PROCFS_SEQ
static const struct file_operations lprocfs_generic_fops = { };
-#else
-
-ssize_t
-lprocfs_fops_read(struct file *f, char __user *buf, size_t size, loff_t *ppos)
-{
- 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;
-
- page = (char *)__get_free_page(GFP_KERNEL);
- if (page == NULL)
- return -ENOMEM;
-
- rc = LPROCFS_ENTRY_CHECK(inode);
- if (rc < 0)
- goto out;
-
- 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);
- else
- rc = 0;
-
- if (rc <= 0)
- goto out;
-
- /* for lustre proc read, the read count must be less than PAGE_SIZE */
- LASSERT(eof == 1);
-
- if (start == NULL) {
- rc -= *ppos;
- if (rc < 0)
- rc = 0;
- if (rc == 0)
- goto out;
- start = page + *ppos;
- } else if (start < page) {
- start = page;
- }
-
- count = (rc < size) ? rc : size;
- if (copy_to_user(buf, start, count)) {
- rc = -EFAULT;
- goto out;
- }
- *ppos += count;
-
-out:
- free_page((unsigned long)page);
- return rc;
-}
-
-ssize_t
-lprocfs_fops_write(struct file *f, const char __user *buf, size_t size,
- loff_t *ppos)
-{
- struct inode *inode = f->f_dentry->d_inode;
- struct proc_dir_entry *dp = PDE(inode);
- int 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 = {
- .owner = THIS_MODULE,
- .read = lprocfs_fops_read,
- .write = lprocfs_fops_write,
-};
-
-/* for b=10866, global variable */
-DECLARE_RWSEM(_lprocfs_lock);
-EXPORT_SYMBOL(_lprocfs_lock);
-
-static struct proc_dir_entry *__lprocfs_srch(struct proc_dir_entry *head,
- const char *name)
-{
- struct proc_dir_entry *temp;
-
- if (head == NULL)
- return NULL;
-
- temp = head->subdir;
- while (temp != NULL) {
- if (strcmp(temp->name, name) == 0)
- return temp;
- temp = temp->next;
- }
- return NULL;
-}
-
-struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
- const char *name)
-{
- struct proc_dir_entry *temp;
-
- down_read(&_lprocfs_lock);
- temp = __lprocfs_srch(head, name);
- up_read(&_lprocfs_lock);
- return temp;
-}
-EXPORT_SYMBOL(lprocfs_srch);
-
-static int __lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *list,
- void *data)
-{
- int rc = 0;
-
- if (root == NULL || list == NULL)
- return -EINVAL;
-
- while (list->name != NULL) {
- struct proc_dir_entry *cur_root, *proc;
- char *pathcopy, *cur, *next, pathbuf[64];
- int pathsize = strlen(list->name) + 1;
-
- proc = NULL;
- cur_root = root;
-
- /* need copy of path for strsep */
- if (strlen(list->name) > sizeof(pathbuf) - 1) {
- OBD_ALLOC(pathcopy, pathsize);
- if (pathcopy == NULL)
- GOTO(out, rc = -ENOMEM);
- } else {
- pathcopy = pathbuf;
- }
-
- next = pathcopy;
- strcpy(pathcopy, list->name);
-
- while (cur_root != NULL && (cur = strsep(&next, "/"))) {
- if (*cur =='\0') /* skip double/trailing "/" */
- continue;
-
- proc = __lprocfs_srch(cur_root, cur);
- CDEBUG(D_OTHER, "cur_root=%s, cur=%s, next=%s, (%s)\n",
- cur_root->name, cur, next,
- (proc ? "exists" : "new"));
- if (next != NULL) {
- cur_root = (proc ? proc :
- proc_mkdir(cur, cur_root));
- } else if (proc == NULL) {
- mode_t mode = 0;
- if (list->proc_mode != 0000) {
- mode = list->proc_mode;
- } else {
- if (list->read_fptr)
- mode = 0444;
- if (list->write_fptr)
- mode |= 0200;
- }
- proc = create_proc_entry(cur, mode, cur_root);
- }
- }
-
- if (pathcopy != pathbuf)
- OBD_FREE(pathcopy, pathsize);
-
- if (cur_root == NULL || proc == NULL) {
- CERROR("LprocFS: No memory to create /proc entry %s\n",
- list->name);
- GOTO(out, rc = -ENOMEM);
- }
-
- if (list->fops)
- proc->proc_fops = list->fops;
- else
- proc->proc_fops = &lprocfs_generic_fops;
- proc->read_proc = list->read_fptr;
- proc->write_proc = list->write_fptr;
- proc->data = (list->data ? list->data : data);
- list++;
- }
-out:
- return rc;
-}
-
-int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
- void *data)
-{
- int rc = 0;
-
- down_write(&_lprocfs_lock);
- rc = __lprocfs_add_vars(root, list, data);
- up_write(&_lprocfs_lock);
-
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_add_vars);
-#endif
/**
* Add /proc entries.
}
EXPORT_SYMBOL(lprocfs_seq_add_vars);
-#ifndef HAVE_ONLY_PROCFS_SEQ
+#ifndef HAVE_REMOVE_PROC_SUBTREE
+/* for b=10866, global variable */
+DECLARE_RWSEM(_lprocfs_lock);
+EXPORT_SYMBOL(_lprocfs_lock);
+
static void lprocfs_remove_nolock(struct proc_dir_entry **proot)
{
struct proc_dir_entry *root = *proot;
break;
}
}
-#endif
-
-void lprocfs_remove(struct proc_dir_entry **rooth)
-{
-#ifndef HAVE_ONLY_PROCFS_SEQ
- down_write(&_lprocfs_lock); /* search vs remove race */
- lprocfs_remove_nolock(rooth);
- up_write(&_lprocfs_lock);
-#else
- proc_remove(*rooth);
- *rooth = NULL;
-#endif
-}
-EXPORT_SYMBOL(lprocfs_remove);
-void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
-{
- LASSERT(parent != NULL);
- remove_proc_entry(name, parent);
-}
-EXPORT_SYMBOL(lprocfs_remove_proc_entry);
-
-#ifndef HAVE_ONLY_PROCFS_SEQ
-void lprocfs_try_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent)
+int remove_proc_subtree(const char *name, struct proc_dir_entry *parent)
{
struct proc_dir_entry *t = NULL;
struct proc_dir_entry **p;
lprocfs_remove_nolock(&t);
up_write(&_lprocfs_lock);
- return;
+ return 0;
}
-EXPORT_SYMBOL(lprocfs_try_remove_proc_entry);
+EXPORT_SYMBOL(remove_proc_subtree);
+#endif /* !HAVE_REMOVE_PROC_SUBTREE */
-struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
+#ifndef HAVE_PROC_REMOVE
+void proc_remove(struct proc_dir_entry *de)
{
- struct proc_dir_entry *entry;
- int rc;
-
- down_write(&_lprocfs_lock);
- entry = __lprocfs_srch(parent, name);
- if (entry != NULL) {
- CERROR("entry '%s' already registered\n", name);
- GOTO(out, entry = ERR_PTR(-EALREADY));
- }
-
- entry = proc_mkdir(name, parent);
- if (entry == NULL)
- GOTO(out, entry = ERR_PTR(-ENOMEM));
-
- if (list != NULL) {
- rc = __lprocfs_add_vars(entry, list, data);
- if (rc != 0) {
- lprocfs_remove_nolock(&entry);
- GOTO(out, entry = ERR_PTR(rc));
- }
- }
-out:
+#ifndef HAVE_REMOVE_PROC_SUBTREE
+ down_write(&_lprocfs_lock); /* search vs remove race */
+ lprocfs_remove_nolock(&de);
up_write(&_lprocfs_lock);
- return entry;
+#else
+ if (de)
+ remove_proc_subtree(de->name, de->parent);
+#endif
}
-EXPORT_SYMBOL(lprocfs_register);
#endif
+void lprocfs_remove(struct proc_dir_entry **rooth)
+{
+ proc_remove(*rooth);
+ *rooth = NULL;
+}
+EXPORT_SYMBOL(lprocfs_remove);
+
+void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
+{
+ LASSERT(parent != NULL);
+ remove_proc_entry(name, parent);
+}
+EXPORT_SYMBOL(lprocfs_remove_proc_entry);
+
struct proc_dir_entry *
lprocfs_seq_register(const char *name, struct proc_dir_entry *parent,
struct lprocfs_seq_vars *list, void *data)