-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
/*
* Copyright (c) 2009, 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/
#ifndef __PARAMS_TREE_H__
#define __PARAMS_TREE_H__
-#ifndef EXPORT_SYMTAB
-# define EXPORT_SYMTAB
-#endif
-
#include <libcfs/libcfs.h>
#undef LPROCFS
#define cfs_seq_open(file, ops, rc) (rc = seq_open(file, ops))
/* in lprocfs_stat.c, to protect the private data for proc entries */
-extern cfs_rw_semaphore_t _lprocfs_lock;
-#define LPROCFS_ENTRY() \
-do { \
- cfs_down_read(&_lprocfs_lock); \
+extern struct rw_semaphore _lprocfs_lock;
+
+/* to begin from 2.6.23, Linux defines self file_operations (proc_reg_file_ops)
+ * in procfs, the proc file_operation defined by Lustre (lprocfs_generic_fops)
+ * will be wrapped into the new defined proc_reg_file_ops, which instroduces
+ * user count in proc_dir_entrey(pde_users) to protect the proc entry from
+ * being deleted. then the protection lock (_lprocfs_lock) defined by Lustre
+ * isn't necessary anymore for lprocfs_generic_fops(e.g. lprocfs_fops_read).
+ * see bug19706 for detailed information.
+ */
+#ifndef HAVE_PROCFS_USERS
+
+#define LPROCFS_ENTRY() \
+do { \
+ down_read(&_lprocfs_lock); \
} while(0)
-#define LPROCFS_EXIT() \
-do { \
- cfs_up_read(&_lprocfs_lock); \
+
+#define LPROCFS_EXIT() \
+do { \
+ up_read(&_lprocfs_lock); \
} while(0)
+#else
+#define LPROCFS_ENTRY() do{ }while(0)
+#define LPROCFS_EXIT() do{ }while(0)
+#endif
+
#ifdef HAVE_PROCFS_DELETED
+
static inline
int LPROCFS_ENTRY_AND_CHECK(struct proc_dir_entry *dp)
{
}
return 0;
}
+#elif defined(HAVE_PROCFS_USERS) /* !HAVE_PROCFS_DELETED*/
+static inline
+int LPROCFS_ENTRY_AND_CHECK(struct proc_dir_entry *dp)
+{
+ int deleted = 0;
+
+ spin_lock(&(dp)->pde_unload_lock);
+ if (dp->proc_fops == NULL)
+ deleted = 1;
+ spin_unlock(&(dp)->pde_unload_lock);
+ if (deleted)
+ return -ENODEV;
+ return 0;
+}
#else /* !HAVE_PROCFS_DELETED*/
static inline
int LPROCFS_ENTRY_AND_CHECK(struct proc_dir_entry *dp)
return 0;
}
#endif /* HAVE_PROCFS_DELETED */
-
-#define LPROCFS_WRITE_ENTRY() \
+#define LPROCFS_SRCH_ENTRY() \
do { \
- cfs_down_write(&_lprocfs_lock); \
+ down_read(&_lprocfs_lock); \
} while(0)
-#define LPROCFS_WRITE_EXIT() \
+
+#define LPROCFS_SRCH_EXIT() \
do { \
- cfs_up_write(&_lprocfs_lock); \
+ up_read(&_lprocfs_lock); \
} while(0)
+#define LPROCFS_WRITE_ENTRY() \
+do { \
+ down_write(&_lprocfs_lock); \
+} while(0)
+
+#define LPROCFS_WRITE_EXIT() \
+do { \
+ up_write(&_lprocfs_lock); \
+} while(0)
#else /* !LPROCFS */
typedef struct cfs_params_file {
size_t count;
loff_t index;
loff_t version;
- cfs_mutex_t lock;
+ struct mutex lock;
struct cfs_seq_operations *op;
void *private;
} cfs_seq_file_t;
typedef void *cfs_poll_table_t;
typedef struct cfs_param_file_ops {
- cfs_param_module_t owner;
- int (*open) (cfs_inode_t *, cfs_file_t *);
- loff_t (*llseek)(cfs_file_t *, loff_t, int);
- int (*release) (cfs_inode_t *, cfs_param_file_t *);
- unsigned int (*poll) (cfs_file_t *, cfs_poll_table_t *);
- ssize_t (*write) (cfs_file_t *, const char *, size_t, loff_t *);
- ssize_t (*read)(cfs_file_t *, char *, size_t, loff_t *);
+ cfs_param_module_t owner;
+ int (*open) (cfs_inode_t *, struct file *);
+ loff_t (*llseek)(struct file *, loff_t, int);
+ int (*release) (cfs_inode_t *, cfs_param_file_t *);
+ unsigned int (*poll) (struct file *, cfs_poll_table_t *);
+ ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
+ ssize_t (*read)(struct file *, char *, size_t, loff_t *);
} cfs_param_file_ops_t;
typedef cfs_param_file_ops_t *cfs_lproc_filep_t;