Commit 73bb1da6 authored by Peng Tao's avatar Peng Tao Committed by Greg Kroah-Hartman

staging/lustre: adapt proc_dir_entry change

In 3.10 merge window, proc_dir_entry is now private to proc. However,
Lustre lprocfs depends heavily on it and its now-gone read_proc_t and
write_proc_t members.

The patch largely changed the fact, and made lprocfs depend on none of
proc_dir_entry private members. All lprocfs callers are converted to
use the new seq_file scheme.

Also lprocfs_srch is removed so that we can drop lprocfs_lock. All callers
are changed to save created pde in proper place.

See https://jira.hpdd.intel.com/browse/LU-3319 for more details.
Signed-off-by: default avatarPeng Tao <tao.peng@emc.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2ac428fe
...@@ -792,8 +792,9 @@ static inline void __cfs_hash_set_theta(cfs_hash_t *hs, int min, int max) ...@@ -792,8 +792,9 @@ static inline void __cfs_hash_set_theta(cfs_hash_t *hs, int min, int max)
} }
/* Generic debug formatting routines mainly for proc handler */ /* Generic debug formatting routines mainly for proc handler */
int cfs_hash_debug_header(char *str, int size); struct seq_file;
int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size); int cfs_hash_debug_header(struct seq_file *m);
int cfs_hash_debug_str(cfs_hash_t *hs, struct seq_file *m);
/* /*
* Generic djb2 hash algorithm for character arrays. * Generic djb2 hash algorithm for character arrays.
......
...@@ -58,7 +58,6 @@ typedef module_t *cfs_param_module_t; ...@@ -58,7 +58,6 @@ typedef module_t *cfs_param_module_t;
typedef struct proc_dir_entry cfs_param_dentry_t; typedef struct proc_dir_entry cfs_param_dentry_t;
typedef struct poll_table_struct cfs_poll_table_t; typedef struct poll_table_struct cfs_poll_table_t;
#define CFS_PARAM_MODULE THIS_MODULE #define CFS_PARAM_MODULE THIS_MODULE
#define CFS_PDE(value) PDE(value)
#define cfs_file_private(file) (file->private_data) #define cfs_file_private(file) (file->private_data)
#define cfs_dentry_data(dentry) (dentry->data) #define cfs_dentry_data(dentry) (dentry->data)
#define cfs_proc_inode_pde(proc_inode) (proc_inode->pde) #define cfs_proc_inode_pde(proc_inode) (proc_inode->pde)
...@@ -75,52 +74,6 @@ typedef struct poll_table_struct cfs_poll_table_t; ...@@ -75,52 +74,6 @@ typedef struct poll_table_struct cfs_poll_table_t;
count, ppos)) count, ppos))
#define cfs_seq_open(file, ops, rc) (rc = seq_open(file, ops)) #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 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.
*/
#define LPROCFS_ENTRY() do{ }while(0)
#define LPROCFS_EXIT() do{ }while(0)
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;
}
#define LPROCFS_SRCH_ENTRY() \
do { \
down_read(&_lprocfs_lock); \
} while(0)
#define LPROCFS_SRCH_EXIT() \
do { \
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 */ #else /* !LPROCFS */
typedef struct cfs_params_file { typedef struct cfs_params_file {
...@@ -181,13 +134,7 @@ static inline cfs_proc_inode_t *FAKE_PROC_I(const cfs_inode_t *inode) ...@@ -181,13 +134,7 @@ static inline cfs_proc_inode_t *FAKE_PROC_I(const cfs_inode_t *inode)
return container_of(inode, cfs_proc_inode_t, param_inode); return container_of(inode, cfs_proc_inode_t, param_inode);
} }
static inline cfs_param_dentry_t *FAKE_PDE(cfs_inode_t *inode)
{
return FAKE_PROC_I(inode)->param_pde;
}
#define CFS_PARAM_MODULE NULL #define CFS_PARAM_MODULE NULL
#define CFS_PDE(value) FAKE_PDE(value)
#define cfs_file_private(file) (file->param_private) #define cfs_file_private(file) (file->param_private)
#define cfs_dentry_data(dentry) (dentry->param_data) #define cfs_dentry_data(dentry) (dentry->param_data)
#define cfs_proc_inode(proc_inode) (proc_inode->param_inode) #define cfs_proc_inode(proc_inode) (proc_inode->param_inode)
...@@ -212,17 +159,6 @@ do { \ ...@@ -212,17 +159,6 @@ do { \
rc = 0; \ rc = 0; \
} while(0) } while(0)
#define LPROCFS_ENTRY() do {} while(0)
#define LPROCFS_EXIT() do {} while(0)
static inline
int LPROCFS_ENTRY_AND_CHECK(cfs_param_dentry_t *dp)
{
LPROCFS_ENTRY();
return 0;
}
#define LPROCFS_WRITE_ENTRY() do {} while(0)
#define LPROCFS_WRITE_EXIT() do {} while(0)
#endif /* LPROCFS */ #endif /* LPROCFS */
/* XXX: params_tree APIs */ /* XXX: params_tree APIs */
......
...@@ -57,10 +57,8 @@ enum { ...@@ -57,10 +57,8 @@ enum {
extern struct lu_context_key seq_thread_key; extern struct lu_context_key seq_thread_key;
/* Functions used internally in module. */
int seq_client_alloc_super(struct lu_client_seq *seq, int seq_client_alloc_super(struct lu_client_seq *seq,
const struct lu_env *env); const struct lu_env *env);
/* Store API functions. */ /* Store API functions. */
int seq_store_init(struct lu_server_seq *seq, int seq_store_init(struct lu_server_seq *seq,
const struct lu_env *env, const struct lu_env *env,
......
...@@ -60,9 +60,8 @@ ...@@ -60,9 +60,8 @@
* use. * use.
*/ */
static int static int
seq_proc_write_common(struct file *file, const char *buffer, lprocfs_fid_write_common(const char *buffer, unsigned long count,
unsigned long count, void *data, struct lu_seq_range *range)
struct lu_seq_range *range)
{ {
struct lu_seq_range tmp; struct lu_seq_range tmp;
int rc; int rc;
...@@ -79,151 +78,19 @@ seq_proc_write_common(struct file *file, const char *buffer, ...@@ -79,151 +78,19 @@ seq_proc_write_common(struct file *file, const char *buffer,
RETURN(0); RETURN(0);
} }
static int
seq_proc_read_common(char *page, char **start, off_t off,
int count, int *eof, void *data,
struct lu_seq_range *range)
{
int rc;
ENTRY;
*eof = 1;
rc = snprintf(page, count, "["LPX64" - "LPX64"]:%x:%s\n",
PRANGE(range));
RETURN(rc);
}
/*
* Server side procfs stuff.
*/
static int
seq_server_proc_write_space(struct file *file, const char *buffer,
unsigned long count, void *data)
{
struct lu_server_seq *seq = (struct lu_server_seq *)data;
int rc;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lss_mutex);
rc = seq_proc_write_common(file, buffer, count,
data, &seq->lss_space);
if (rc == 0) {
CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
seq->lss_name, PRANGE(&seq->lss_space));
}
mutex_unlock(&seq->lss_mutex);
RETURN(count);
}
static int
seq_server_proc_read_space(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct lu_server_seq *seq = (struct lu_server_seq *)data;
int rc;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lss_mutex);
rc = seq_proc_read_common(page, start, off, count, eof,
data, &seq->lss_space);
mutex_unlock(&seq->lss_mutex);
RETURN(rc);
}
static int
seq_server_proc_read_server(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct lu_server_seq *seq = (struct lu_server_seq *)data;
struct client_obd *cli;
int rc;
ENTRY;
LASSERT(seq != NULL);
*eof = 1;
if (seq->lss_cli) {
if (seq->lss_cli->lcs_exp != NULL) {
cli = &seq->lss_cli->lcs_exp->exp_obd->u.cli;
rc = snprintf(page, count, "%s\n",
cli->cl_target_uuid.uuid);
} else {
rc = snprintf(page, count, "%s\n",
seq->lss_cli->lcs_srv->lss_name);
}
} else {
rc = snprintf(page, count, "<none>\n");
}
RETURN(rc);
}
static int
seq_server_proc_write_width(struct file *file, const char *buffer,
unsigned long count, void *data)
{
struct lu_server_seq *seq = (struct lu_server_seq *)data;
int rc, val;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lss_mutex);
rc = lprocfs_write_helper(buffer, count, &val);
if (rc != 0) {
CERROR("%s: invalid width.\n", seq->lss_name);
GOTO(out_unlock, rc);
}
seq->lss_width = val;
CDEBUG(D_INFO, "%s: Width: "LPU64"\n",
seq->lss_name, seq->lss_width);
out_unlock:
mutex_unlock(&seq->lss_mutex);
RETURN(count);
}
static int
seq_server_proc_read_width(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
struct lu_server_seq *seq = (struct lu_server_seq *)data;
int rc;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lss_mutex);
rc = snprintf(page, count, LPU64"\n", seq->lss_width);
mutex_unlock(&seq->lss_mutex);
RETURN(rc);
}
/* Client side procfs stuff */ /* Client side procfs stuff */
static int static ssize_t
seq_client_proc_write_space(struct file *file, const char *buffer, lprocfs_fid_space_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
int rc; int rc;
ENTRY; ENTRY;
LASSERT(seq != NULL); LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex); mutex_lock(&seq->lcs_mutex);
rc = seq_proc_write_common(file, buffer, count, rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
data, &seq->lcs_space);
if (rc == 0) { if (rc == 0) {
CDEBUG(D_INFO, "%s: Space: "DRANGE"\n", CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
...@@ -236,42 +103,37 @@ seq_client_proc_write_space(struct file *file, const char *buffer, ...@@ -236,42 +103,37 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
} }
static int static int
seq_client_proc_read_space(char *page, char **start, off_t off, lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc; int rc;
ENTRY; ENTRY;
LASSERT(seq != NULL); LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex); mutex_lock(&seq->lcs_mutex);
rc = seq_proc_read_common(page, start, off, count, eof, rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space));
data, &seq->lcs_space);
mutex_unlock(&seq->lcs_mutex); mutex_unlock(&seq->lcs_mutex);
RETURN(rc); RETURN(rc);
} }
static int static ssize_t
seq_client_proc_write_width(struct file *file, const char *buffer, lprocfs_fid_width_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = ((struct seq_file *)file->private_data)->private;
__u64 max; __u64 max;
int rc, val; int rc, val;
ENTRY; ENTRY;
LASSERT(seq != NULL); LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
rc = lprocfs_write_helper(buffer, count, &val); rc = lprocfs_write_helper(buffer, count, &val);
if (rc) { if (rc)
mutex_unlock(&seq->lcs_mutex);
RETURN(rc); RETURN(rc);
}
mutex_lock(&seq->lcs_mutex);
if (seq->lcs_type == LUSTRE_SEQ_DATA) if (seq->lcs_type == LUSTRE_SEQ_DATA)
max = LUSTRE_DATA_SEQ_MAX_WIDTH; max = LUSTRE_DATA_SEQ_MAX_WIDTH;
else else
...@@ -292,44 +154,41 @@ seq_client_proc_write_width(struct file *file, const char *buffer, ...@@ -292,44 +154,41 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
} }
static int static int
seq_client_proc_read_width(char *page, char **start, off_t off, lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc; int rc;
ENTRY; ENTRY;
LASSERT(seq != NULL); LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex); mutex_lock(&seq->lcs_mutex);
rc = snprintf(page, count, LPU64"\n", seq->lcs_width); rc = seq_printf(m, LPU64"\n", seq->lcs_width);
mutex_unlock(&seq->lcs_mutex); mutex_unlock(&seq->lcs_mutex);
RETURN(rc); RETURN(rc);
} }
static int static int
seq_client_proc_read_fid(char *page, char **start, off_t off, lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc; int rc;
ENTRY; ENTRY;
LASSERT(seq != NULL); LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex); mutex_lock(&seq->lcs_mutex);
rc = snprintf(page, count, DFID"\n", PFID(&seq->lcs_fid)); rc = seq_printf(m, DFID"\n", PFID(&seq->lcs_fid));
mutex_unlock(&seq->lcs_mutex); mutex_unlock(&seq->lcs_mutex);
RETURN(rc); RETURN(rc);
} }
static int static int
seq_client_proc_read_server(char *page, char **start, off_t off, lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_seq *seq = (struct lu_client_seq *)data; struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
struct client_obd *cli; struct client_obd *cli;
int rc; int rc;
ENTRY; ENTRY;
...@@ -338,23 +197,26 @@ seq_client_proc_read_server(char *page, char **start, off_t off, ...@@ -338,23 +197,26 @@ seq_client_proc_read_server(char *page, char **start, off_t off,
if (seq->lcs_exp != NULL) { if (seq->lcs_exp != NULL) {
cli = &seq->lcs_exp->exp_obd->u.cli; cli = &seq->lcs_exp->exp_obd->u.cli;
rc = snprintf(page, count, "%s\n", cli->cl_target_uuid.uuid); rc = seq_printf(m, "%s\n", cli->cl_target_uuid.uuid);
} else { } else {
rc = snprintf(page, count, "%s\n", seq->lcs_srv->lss_name); rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
} }
RETURN(rc); RETURN(rc);
} }
struct lprocfs_vars seq_server_proc_list[] = { struct lprocfs_vars seq_server_proc_list[] = {
{ "space", seq_server_proc_read_space, seq_server_proc_write_space, NULL }, };
{ "width", seq_server_proc_read_width, seq_server_proc_write_width, NULL },
{ "server", seq_server_proc_read_server, NULL, NULL }, LPROC_SEQ_FOPS(lprocfs_fid_space);
{ NULL }}; LPROC_SEQ_FOPS(lprocfs_fid_width);
LPROC_SEQ_FOPS_RO(lprocfs_fid_server);
LPROC_SEQ_FOPS_RO(lprocfs_fid_fid);
struct lprocfs_vars seq_client_proc_list[] = { struct lprocfs_vars seq_client_proc_list[] = {
{ "space", seq_client_proc_read_space, seq_client_proc_write_space, NULL }, { "space", &lprocfs_fid_space_fops },
{ "width", seq_client_proc_read_width, seq_client_proc_write_width, NULL }, { "width", &lprocfs_fid_width_fops },
{ "server", seq_client_proc_read_server, NULL, NULL }, { "server", &lprocfs_fid_server_fops },
{ "fid", seq_client_proc_read_fid, NULL, NULL }, { "fid", &lprocfs_fid_fid_fops },
{ NULL }}; { NULL }
};
#endif #endif
...@@ -58,12 +58,10 @@ ...@@ -58,12 +58,10 @@
#ifdef LPROCFS #ifdef LPROCFS
static int static int
fld_proc_read_targets(char *page, char **start, off_t off, fld_proc_targets_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
struct lu_fld_target *target; struct lu_fld_target *target;
int total = 0, rc;
ENTRY; ENTRY;
LASSERT(fld != NULL); LASSERT(fld != NULL);
...@@ -71,41 +69,32 @@ fld_proc_read_targets(char *page, char **start, off_t off, ...@@ -71,41 +69,32 @@ fld_proc_read_targets(char *page, char **start, off_t off,
spin_lock(&fld->lcf_lock); spin_lock(&fld->lcf_lock);
list_for_each_entry(target, list_for_each_entry(target,
&fld->lcf_targets, ft_chain) &fld->lcf_targets, ft_chain)
{ seq_printf(m, "%s\n", fld_target_name(target));
rc = snprintf(page, count, "%s\n",
fld_target_name(target));
page += rc;
count -= rc;
total += rc;
if (count == 0)
break;
}
spin_unlock(&fld->lcf_lock); spin_unlock(&fld->lcf_lock);
RETURN(total);
RETURN(0);
} }
static int static int
fld_proc_read_hash(char *page, char **start, off_t off, fld_proc_hash_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
int rc;
ENTRY; ENTRY;
LASSERT(fld != NULL); LASSERT(fld != NULL);
spin_lock(&fld->lcf_lock); spin_lock(&fld->lcf_lock);
rc = snprintf(page, count, "%s\n", fld->lcf_hash->fh_name); seq_printf(m, "%s\n", fld->lcf_hash->fh_name);
spin_unlock(&fld->lcf_lock); spin_unlock(&fld->lcf_lock);
RETURN(rc); RETURN(0);
} }
static int static ssize_t
fld_proc_write_hash(struct file *file, const char *buffer, fld_proc_hash_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_client_fld *fld = ((struct seq_file *)file->private_data)->private;
struct lu_fld_hash *hash = NULL; struct lu_fld_hash *hash = NULL;
int i; int i;
ENTRY; ENTRY;
...@@ -134,11 +123,11 @@ fld_proc_write_hash(struct file *file, const char *buffer, ...@@ -134,11 +123,11 @@ fld_proc_write_hash(struct file *file, const char *buffer,
RETURN(count); RETURN(count);
} }
static int static ssize_t
fld_proc_write_cache_flush(struct file *file, const char *buffer, fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
unsigned long count, void *data) size_t count, loff_t *pos)
{ {
struct lu_client_fld *fld = (struct lu_client_fld *)data; struct lu_client_fld *fld = file->private_data;
ENTRY; ENTRY;
LASSERT(fld != NULL); LASSERT(fld != NULL);
...@@ -150,6 +139,25 @@ fld_proc_write_cache_flush(struct file *file, const char *buffer, ...@@ -150,6 +139,25 @@ fld_proc_write_cache_flush(struct file *file, const char *buffer,
RETURN(count); RETURN(count);
} }
static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
{
file->private_data = PDE_DATA(inode);
return 0;
}
static int fld_proc_cache_flush_release(struct inode *inode, struct file *file)
{
file->private_data = NULL;
return 0;
}
struct file_operations fld_proc_cache_flush_fops = {
.owner = THIS_MODULE,
.open = fld_proc_cache_flush_open,
.write = fld_proc_cache_flush_write,
.release = fld_proc_cache_flush_release,
};
struct fld_seq_param { struct fld_seq_param {
struct lu_env fsp_env; struct lu_env fsp_env;
struct dt_it *fsp_it; struct dt_it *fsp_it;
...@@ -265,16 +273,14 @@ struct seq_operations fldb_sops = { ...@@ -265,16 +273,14 @@ struct seq_operations fldb_sops = {
static int fldb_seq_open(struct inode *inode, struct file *file) static int fldb_seq_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq; struct seq_file *seq;
struct lu_server_fld *fld = (struct lu_server_fld *)dp->data; struct lu_server_fld *fld = (struct lu_server_fld *)PDE_DATA(inode);
struct dt_object *obj; struct dt_object *obj;
const struct dt_it_ops *iops; const struct dt_it_ops *iops;
struct fld_seq_param *param = NULL; struct fld_seq_param *param = NULL;
int env_init = 0; int env_init = 0;
int rc; int rc;
LPROCFS_ENTRY_AND_CHECK(dp);
rc = seq_open(file, &fldb_sops); rc = seq_open(file, &fldb_sops);
if (rc) if (rc)
GOTO(out, rc); GOTO(out, rc);
...@@ -311,7 +317,6 @@ static int fldb_seq_open(struct inode *inode, struct file *file) ...@@ -311,7 +317,6 @@ static int fldb_seq_open(struct inode *inode, struct file *file)
lu_env_fini(&param->fsp_env); lu_env_fini(&param->fsp_env);
if (param != NULL) if (param != NULL)
OBD_FREE_PTR(param); OBD_FREE_PTR(param);
LPROCFS_EXIT();
} }
return rc; return rc;
} }
...@@ -349,10 +354,13 @@ static int fldb_seq_release(struct inode *inode, struct file *file) ...@@ -349,10 +354,13 @@ static int fldb_seq_release(struct inode *inode, struct file *file)
struct lprocfs_vars fld_server_proc_list[] = { struct lprocfs_vars fld_server_proc_list[] = {
{ NULL }}; { NULL }};
LPROC_SEQ_FOPS_RO(fld_proc_targets);
LPROC_SEQ_FOPS(fld_proc_hash);
struct lprocfs_vars fld_client_proc_list[] = { struct lprocfs_vars fld_client_proc_list[] = {
{ "targets", fld_proc_read_targets, NULL, NULL }, { "targets", &fld_proc_targets_fops },
{ "hash", fld_proc_read_hash, fld_proc_write_hash, NULL }, { "hash", &fld_proc_hash_fops },
{ "cache_flush", NULL, fld_proc_write_cache_flush, NULL }, { "cache_flush", &fld_proc_cache_flush_fops },
{ NULL }}; { NULL }};
struct file_operations fld_proc_seq_fops = { struct file_operations fld_proc_seq_fops = {
......
...@@ -2598,8 +2598,6 @@ struct cache_stats { ...@@ -2598,8 +2598,6 @@ struct cache_stats {
/** These are not exported so far */ /** These are not exported so far */
void cache_stats_init (struct cache_stats *cs, const char *name); void cache_stats_init (struct cache_stats *cs, const char *name);
int cache_stats_print(const struct cache_stats *cs,
char *page, int count, int header);
/** /**
* Client-side site. This represents particular client stack. "Global" * Client-side site. This represents particular client stack. "Global"
...@@ -2631,7 +2629,7 @@ void cl_stack_fini(const struct lu_env *env, struct cl_device *cl); ...@@ -2631,7 +2629,7 @@ void cl_stack_fini(const struct lu_env *env, struct cl_device *cl);
* Output client site statistical counters into a buffer. Suitable for * Output client site statistical counters into a buffer. Suitable for
* ll_rd_*()-style functions. * ll_rd_*()-style functions.
*/ */
int cl_site_stats_print(const struct cl_site *s, char *page, int count); int cl_site_stats_print(const struct cl_site *site, struct seq_file *m);
/** /**
* \name helpers * \name helpers
......
...@@ -1281,7 +1281,7 @@ int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags); ...@@ -1281,7 +1281,7 @@ int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags);
* Output site statistical counters into a buffer. Suitable for * Output site statistical counters into a buffer. Suitable for
* ll_rd_*()-style functions. * ll_rd_*()-style functions.
*/ */
int lu_site_stats_print(const struct lu_site *s, char *page, int count); int lu_site_stats_print(const struct lu_site *s, struct seq_file *m);
/** /**
* Common name structure to be passed around for various name related methods. * Common name structure to be passed around for various name related methods.
......
...@@ -545,6 +545,9 @@ struct ldlm_namespace { ...@@ -545,6 +545,9 @@ struct ldlm_namespace {
/** Client side original connect flags supported by server. */ /** Client side original connect flags supported by server. */
__u64 ns_orig_connect_flags; __u64 ns_orig_connect_flags;
/* namespace proc dir entry */
struct proc_dir_entry *ns_proc_dir_entry;
/** /**
* Position in global namespace list linking all namespaces on * Position in global namespace list linking all namespaces on
* the node. * the node.
......
...@@ -1060,6 +1060,7 @@ struct obd_device { ...@@ -1060,6 +1060,7 @@ struct obd_device {
struct lprocfs_stats *md_stats; struct lprocfs_stats *md_stats;
proc_dir_entry_t *obd_proc_entry; proc_dir_entry_t *obd_proc_entry;
void *obd_proc_private; /* type private PDEs */
proc_dir_entry_t *obd_proc_exports_entry; proc_dir_entry_t *obd_proc_exports_entry;
proc_dir_entry_t *obd_svc_procroot; proc_dir_entry_t *obd_svc_procroot;
struct lprocfs_stats *obd_svc_stats; struct lprocfs_stats *obd_svc_stats;
......
...@@ -199,41 +199,40 @@ enum ldlm_policy_res { ...@@ -199,41 +199,40 @@ enum ldlm_policy_res {
typedef enum ldlm_policy_res ldlm_policy_res_t; typedef enum ldlm_policy_res ldlm_policy_res_t;
#define LDLM_POOL_PROC_READER(var, type) \ #define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \
static int lprocfs_rd_##var(char *page, char **start, off_t off, \ static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \
int count, int *eof, void *data) \ { \
{ \ struct ldlm_pool *pl = m->private; \
struct ldlm_pool *pl = data; \ type tmp; \
type tmp; \
\ \
spin_lock(&pl->pl_lock); \ spin_lock(&pl->pl_lock); \
tmp = pl->pl_##var; \ tmp = pl->pl_##var; \
spin_unlock(&pl->pl_lock); \ spin_unlock(&pl->pl_lock); \
\ \
return lprocfs_rd_uint(page, start, off, count, eof, &tmp); \ return lprocfs_rd_uint(m, &tmp); \
} \ } \
struct __##var##__dummy_read {;} /* semicolon catcher */ struct __##var##__dummy_read {;} /* semicolon catcher */
#define LDLM_POOL_PROC_WRITER(var, type) \ #define LDLM_POOL_PROC_WRITER(var, type) \
int lprocfs_wr_##var(struct file *file, const char *buffer, \ int lprocfs_wr_##var(struct file *file, const char *buffer, \
unsigned long count, void *data) \ unsigned long count, void *data) \
{ \ { \
struct ldlm_pool *pl = data; \ struct ldlm_pool *pl = data; \
type tmp; \ type tmp; \
int rc; \ int rc; \
\ \
rc = lprocfs_wr_uint(file, buffer, count, &tmp); \ rc = lprocfs_wr_uint(file, buffer, count, &tmp); \
if (rc < 0) { \ if (rc < 0) { \
CERROR("Can't parse user input, rc = %d\n", rc); \ CERROR("Can't parse user input, rc = %d\n", rc); \
return rc; \ return rc; \
} \ } \
\ \
spin_lock(&pl->pl_lock); \ spin_lock(&pl->pl_lock); \
pl->pl_##var = tmp; \ pl->pl_##var = tmp; \
spin_unlock(&pl->pl_lock); \ spin_unlock(&pl->pl_lock); \
\ \
return rc; \ return rc; \
} \ } \
struct __##var##__dummy_write {;} /* semicolon catcher */ struct __##var##__dummy_write {;} /* semicolon catcher */
static inline int is_granted_or_cancelled(struct ldlm_lock *lock) static inline int is_granted_or_cancelled(struct ldlm_lock *lock)
......
...@@ -645,12 +645,11 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit) ...@@ -645,12 +645,11 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
} }
EXPORT_SYMBOL(ldlm_pool_setup); EXPORT_SYMBOL(ldlm_pool_setup);
static int lprocfs_rd_pool_state(char *page, char **start, off_t off, static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
int granted, grant_rate, cancel_rate, grant_step; int granted, grant_rate, cancel_rate, grant_step;
int nr = 0, grant_speed, grant_plan, lvf; int grant_speed, grant_plan, lvf;
struct ldlm_pool *pl = data; struct ldlm_pool *pl = m->private;
__u64 slv, clv; __u64 slv, clv;
__u32 limit; __u32 limit;
...@@ -667,35 +666,29 @@ static int lprocfs_rd_pool_state(char *page, char **start, off_t off, ...@@ -667,35 +666,29 @@ static int lprocfs_rd_pool_state(char *page, char **start, off_t off,
grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period); grant_step = ldlm_pool_t2gsp(pl->pl_recalc_period);
spin_unlock(&pl->pl_lock); spin_unlock(&pl->pl_lock);
nr += snprintf(page + nr, count - nr, "LDLM pool state (%s):\n", seq_printf(m, "LDLM pool state (%s):\n"
pl->pl_name); " SLV: "LPU64"\n"
nr += snprintf(page + nr, count - nr, " SLV: "LPU64"\n", slv); " CLV: "LPU64"\n"
nr += snprintf(page + nr, count - nr, " CLV: "LPU64"\n", clv); " LVF: %d\n",
nr += snprintf(page + nr, count - nr, " LVF: %d\n", lvf); pl->pl_name, slv, clv, lvf);
if (ns_is_server(ldlm_pl2ns(pl))) { if (ns_is_server(ldlm_pl2ns(pl))) {
nr += snprintf(page + nr, count - nr, " GSP: %d%%\n", seq_printf(m, " GSP: %d%%\n"
grant_step); " GP: %d\n",
nr += snprintf(page + nr, count - nr, " GP: %d\n", grant_step, grant_plan);
grant_plan);
} }
nr += snprintf(page + nr, count - nr, " GR: %d\n", seq_printf(m, " GR: %d\n" " CR: %d\n" " GS: %d\n"
grant_rate); " G: %d\n" " L: %d\n",
nr += snprintf(page + nr, count - nr, " CR: %d\n", grant_rate, cancel_rate, grant_speed,
cancel_rate); granted, limit);
nr += snprintf(page + nr, count - nr, " GS: %d\n",
grant_speed); return 0;
nr += snprintf(page + nr, count - nr, " G: %d\n",
granted);
nr += snprintf(page + nr, count - nr, " L: %d\n",
limit);
return nr;
} }
LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
static int lprocfs_rd_grant_speed(char *page, char **start, off_t off, static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
int count, int *eof, void *data)
{ {
struct ldlm_pool *pl = data; struct ldlm_pool *pl = m->private;
int grant_speed; int grant_speed;
spin_lock(&pl->pl_lock); spin_lock(&pl->pl_lock);
...@@ -703,12 +696,36 @@ static int lprocfs_rd_grant_speed(char *page, char **start, off_t off, ...@@ -703,12 +696,36 @@ static int lprocfs_rd_grant_speed(char *page, char **start, off_t off,
grant_speed = atomic_read(&pl->pl_grant_rate) - grant_speed = atomic_read(&pl->pl_grant_rate) -
atomic_read(&pl->pl_cancel_rate); atomic_read(&pl->pl_cancel_rate);
spin_unlock(&pl->pl_lock); spin_unlock(&pl->pl_lock);
return lprocfs_rd_uint(page, start, off, count, eof, &grant_speed); return lprocfs_rd_uint(m, &grant_speed);
} }
LDLM_POOL_PROC_READER(grant_plan, int); LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int);
LDLM_POOL_PROC_READER(recalc_period, int); LPROC_SEQ_FOPS_RO(lprocfs_grant_plan);
LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int);
LDLM_POOL_PROC_WRITER(recalc_period, int); LDLM_POOL_PROC_WRITER(recalc_period, int);
static ssize_t lprocfs_recalc_period_seq_write(struct file *file, const char *buf,
size_t len, loff_t *off)
{
struct seq_file *seq = file->private_data;
return lprocfs_wr_recalc_period(file, buf, len, seq->private);
}
LPROC_SEQ_FOPS(lprocfs_recalc_period);
LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, u64);
LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, atomic);
LPROC_SEQ_FOPS_RW_TYPE(ldlm_pool_rw, atomic);
LPROC_SEQ_FOPS_RO(lprocfs_grant_speed);
#define LDLM_POOL_ADD_VAR(name, var, ops) \
do { \
snprintf(var_name, MAX_STRING_SIZE, #name); \
pool_vars[0].data = var; \
pool_vars[0].fops = ops; \
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);\
} while (0)
static int ldlm_pool_proc_init(struct ldlm_pool *pl) static int ldlm_pool_proc_init(struct ldlm_pool *pl)
{ {
...@@ -723,8 +740,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) ...@@ -723,8 +740,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
if (!var_name) if (!var_name)
RETURN(-ENOMEM); RETURN(-ENOMEM);
parent_ns_proc = lprocfs_srch(ldlm_ns_proc_dir, parent_ns_proc = ns->ns_proc_dir_entry;
ldlm_ns_name(ns));
if (parent_ns_proc == NULL) { if (parent_ns_proc == NULL) {
CERROR("%s: proc entry is not initialized\n", CERROR("%s: proc entry is not initialized\n",
ldlm_ns_name(ns)); ldlm_ns_name(ns));
...@@ -742,58 +758,20 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl) ...@@ -742,58 +758,20 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
memset(pool_vars, 0, sizeof(pool_vars)); memset(pool_vars, 0, sizeof(pool_vars));
pool_vars[0].name = var_name; pool_vars[0].name = var_name;
snprintf(var_name, MAX_STRING_SIZE, "server_lock_volume"); LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume,
pool_vars[0].data = &pl->pl_server_lock_volume; &ldlm_pool_u64_fops);
pool_vars[0].read_fptr = lprocfs_rd_u64; LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops);
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0); LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops);
LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops);
snprintf(var_name, MAX_STRING_SIZE, "limit"); LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate,
pool_vars[0].data = &pl->pl_limit; &ldlm_pool_atomic_fops);
pool_vars[0].read_fptr = lprocfs_rd_atomic; LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate,
pool_vars[0].write_fptr = lprocfs_wr_atomic; &ldlm_pool_atomic_fops);
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0); LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops);
LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops);
snprintf(var_name, MAX_STRING_SIZE, "granted"); LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor,
pool_vars[0].data = &pl->pl_granted; &ldlm_pool_rw_atomic_fops);
pool_vars[0].read_fptr = lprocfs_rd_atomic; LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops);
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "grant_speed");
pool_vars[0].data = pl;
pool_vars[0].read_fptr = lprocfs_rd_grant_speed;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "cancel_rate");
pool_vars[0].data = &pl->pl_cancel_rate;
pool_vars[0].read_fptr = lprocfs_rd_atomic;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "grant_rate");
pool_vars[0].data = &pl->pl_grant_rate;
pool_vars[0].read_fptr = lprocfs_rd_atomic;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "grant_plan");
pool_vars[0].data = pl;
pool_vars[0].read_fptr = lprocfs_rd_grant_plan;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "recalc_period");
pool_vars[0].data = pl;
pool_vars[0].read_fptr = lprocfs_rd_recalc_period;
pool_vars[0].write_fptr = lprocfs_wr_recalc_period;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "lock_volume_factor");
pool_vars[0].data = &pl->pl_lock_volume_factor;
pool_vars[0].read_fptr = lprocfs_rd_atomic;
pool_vars[0].write_fptr = lprocfs_wr_atomic;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "state");
pool_vars[0].data = pl;
pool_vars[0].read_fptr = lprocfs_rd_pool_state;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT - pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0); LDLM_POOL_FIRST_STAT, 0);
......
...@@ -68,25 +68,27 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay; ...@@ -68,25 +68,27 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay;
unsigned int ldlm_dump_granted_max = 256; unsigned int ldlm_dump_granted_max = 256;
#ifdef LPROCFS #ifdef LPROCFS
static int ldlm_proc_dump_ns(struct file *file, const char *buffer, static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE); ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
RETURN(count); RETURN(count);
} }
LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint);
int ldlm_proc_setup(void) int ldlm_proc_setup(void)
{ {
int rc; int rc;
struct lprocfs_vars list[] = { struct lprocfs_vars list[] = {
{ "dump_namespaces", NULL, ldlm_proc_dump_ns, NULL }, { "dump_namespaces", &ldlm_dump_ns_fops, 0, 0222 },
{ "dump_granted_max", { "dump_granted_max", &ldlm_rw_uint_fops,
lprocfs_rd_uint, lprocfs_wr_uint, &ldlm_dump_granted_max },
&ldlm_dump_granted_max, NULL }, { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops,
{ "cancel_unused_locks_before_replay", &ldlm_cancel_unused_locks_before_replay },
lprocfs_rd_uint, lprocfs_wr_uint,
&ldlm_cancel_unused_locks_before_replay, NULL },
{ NULL }}; { NULL }};
ENTRY; ENTRY;
LASSERT(ldlm_ns_proc_dir == NULL); LASSERT(ldlm_ns_proc_dir == NULL);
...@@ -143,10 +145,9 @@ void ldlm_proc_cleanup(void) ...@@ -143,10 +145,9 @@ void ldlm_proc_cleanup(void)
lprocfs_remove(&ldlm_type_proc_dir); lprocfs_remove(&ldlm_type_proc_dir);
} }
static int lprocfs_rd_ns_resources(char *page, char **start, off_t off, static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = m->private;
__u64 res = 0; __u64 res = 0;
cfs_hash_bd_t bd; cfs_hash_bd_t bd;
int i; int i;
...@@ -154,35 +155,35 @@ static int lprocfs_rd_ns_resources(char *page, char **start, off_t off, ...@@ -154,35 +155,35 @@ static int lprocfs_rd_ns_resources(char *page, char **start, off_t off,
/* result is not strictly consistant */ /* result is not strictly consistant */
cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i) cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
res += cfs_hash_bd_count_get(&bd); res += cfs_hash_bd_count_get(&bd);
return lprocfs_rd_u64(page, start, off, count, eof, &res); return lprocfs_rd_u64(m, &res);
} }
LPROC_SEQ_FOPS_RO(lprocfs_ns_resources);
static int lprocfs_rd_ns_locks(char *page, char **start, off_t off, static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = m->private;
__u64 locks; __u64 locks;
locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS, locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_FIELDS_FLAGS_SUM); LPROCFS_FIELDS_FLAGS_SUM);
return lprocfs_rd_u64(page, start, off, count, eof, &locks); return lprocfs_rd_u64(m, &locks);
} }
LPROC_SEQ_FOPS_RO(lprocfs_ns_locks);
static int lprocfs_rd_lru_size(char *page, char **start, off_t off, static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = m->private;
__u32 *nr = &ns->ns_max_unused; __u32 *nr = &ns->ns_max_unused;
if (ns_connect_lru_resize(ns)) if (ns_connect_lru_resize(ns))
nr = &ns->ns_nr_unused; nr = &ns->ns_nr_unused;
return lprocfs_rd_uint(page, start, off, count, eof, nr); return lprocfs_rd_uint(m, nr);
} }
static int lprocfs_wr_lru_size(struct file *file, const char *buffer, static ssize_t lprocfs_lru_size_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
char dummy[MAX_STRING_SIZE + 1], *end; char dummy[MAX_STRING_SIZE + 1], *end;
unsigned long tmp; unsigned long tmp;
int lru_resize; int lru_resize;
...@@ -265,20 +266,20 @@ static int lprocfs_wr_lru_size(struct file *file, const char *buffer, ...@@ -265,20 +266,20 @@ static int lprocfs_wr_lru_size(struct file *file, const char *buffer,
return count; return count;
} }
LPROC_SEQ_FOPS(lprocfs_lru_size);
static int lprocfs_rd_elc(char *page, char **start, off_t off, static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = m->private;
unsigned int supp = ns_connect_cancelset(ns); unsigned int supp = ns_connect_cancelset(ns);
return lprocfs_rd_uint(page, start, off, count, eof, &supp); return lprocfs_rd_uint(m, &supp);
} }
static int lprocfs_wr_elc(struct file *file, const char *buffer, static ssize_t lprocfs_elc_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct ldlm_namespace *ns = data; struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
unsigned int supp = -1; unsigned int supp = -1;
int rc; int rc;
...@@ -292,31 +293,46 @@ static int lprocfs_wr_elc(struct file *file, const char *buffer, ...@@ -292,31 +293,46 @@ static int lprocfs_wr_elc(struct file *file, const char *buffer,
ns->ns_connect_flags |= OBD_CONNECT_CANCELSET; ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
return count; return count;
} }
LPROC_SEQ_FOPS(lprocfs_elc);
void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns) void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
{ {
struct proc_dir_entry *dir; if (ns->ns_proc_dir_entry == NULL)
dir = lprocfs_srch(ldlm_ns_proc_dir, ldlm_ns_name(ns));
if (dir == NULL) {
CERROR("dlm namespace %s has no procfs dir?\n", CERROR("dlm namespace %s has no procfs dir?\n",
ldlm_ns_name(ns)); ldlm_ns_name(ns));
} else { else
lprocfs_remove(&dir); lprocfs_remove(&ns->ns_proc_dir_entry);
}
if (ns->ns_stats != NULL) if (ns->ns_stats != NULL)
lprocfs_free_stats(&ns->ns_stats); lprocfs_free_stats(&ns->ns_stats);
} }
#define LDLM_NS_ADD_VAR(name, var, ops) \
do { \
snprintf(lock_name, MAX_STRING_SIZE, name); \
lock_vars[0].data = var; \
lock_vars[0].fops = ops; \
lprocfs_add_vars(ns_pde, lock_vars, 0); \
} while (0)
int ldlm_namespace_proc_register(struct ldlm_namespace *ns) int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
{ {
struct lprocfs_vars lock_vars[2]; struct lprocfs_vars lock_vars[2];
char lock_name[MAX_STRING_SIZE + 1]; char lock_name[MAX_STRING_SIZE + 1];
proc_dir_entry_t *ns_pde;
LASSERT(ns != NULL); LASSERT(ns != NULL);
LASSERT(ns->ns_rs_hash != NULL); LASSERT(ns->ns_rs_hash != NULL);
if (ns->ns_proc_dir_entry != NULL) {
ns_pde = ns->ns_proc_dir_entry;
} else {
ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir);
if (ns_pde == NULL)
return -ENOMEM;
ns->ns_proc_dir_entry = ns_pde;
}
ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0); ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
if (ns->ns_stats == NULL) if (ns->ns_stats == NULL)
return -ENOMEM; return -ENOMEM;
...@@ -329,86 +345,29 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) ...@@ -329,86 +345,29 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
memset(lock_vars, 0, sizeof(lock_vars)); memset(lock_vars, 0, sizeof(lock_vars));
lock_vars[0].name = lock_name; lock_vars[0].name = lock_name;
snprintf(lock_name, MAX_STRING_SIZE, "%s/resource_count", LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops);
ldlm_ns_name(ns)); LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops);
lock_vars[0].data = ns;
lock_vars[0].read_fptr = lprocfs_rd_ns_resources;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_count",
ldlm_ns_name(ns));
lock_vars[0].data = ns;
lock_vars[0].read_fptr = lprocfs_rd_ns_locks;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
if (ns_is_client(ns)) { if (ns_is_client(ns)) {
snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_unused_count", LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused,
ldlm_ns_name(ns)); &ldlm_uint_fops);
lock_vars[0].data = &ns->ns_nr_unused; LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops);
lock_vars[0].read_fptr = lprocfs_rd_uint; LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age,
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0); &ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops);
snprintf(lock_name, MAX_STRING_SIZE, "%s/lru_size",
ldlm_ns_name(ns));
lock_vars[0].data = ns;
lock_vars[0].read_fptr = lprocfs_rd_lru_size;
lock_vars[0].write_fptr = lprocfs_wr_lru_size;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/lru_max_age",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_max_age;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lock_vars[0].write_fptr = lprocfs_wr_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/early_lock_cancel",
ldlm_ns_name(ns));
lock_vars[0].data = ns;
lock_vars[0].read_fptr = lprocfs_rd_elc;
lock_vars[0].write_fptr = lprocfs_wr_elc;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
} else { } else {
snprintf(lock_name, MAX_STRING_SIZE, "%s/ctime_age_limit", LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit,
ldlm_ns_name(ns)); &ldlm_rw_uint_fops);
lock_vars[0].data = &ns->ns_ctime_age_limit; LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts,
lock_vars[0].read_fptr = lprocfs_rd_uint; &ldlm_uint_fops);
lock_vars[0].write_fptr = lprocfs_wr_uint; LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size,
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0); &ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time,
snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_timeouts", &ldlm_rw_uint_fops);
ldlm_ns_name(ns)); LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks,
lock_vars[0].data = &ns->ns_timeouts; &ldlm_rw_uint_fops);
lock_vars[0].read_fptr = lprocfs_rd_uint; LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast,
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0); &ldlm_rw_uint_fops);
snprintf(lock_name, MAX_STRING_SIZE, "%s/max_nolock_bytes",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_max_nolock_size;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lock_vars[0].write_fptr = lprocfs_wr_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/contention_seconds",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_contention_time;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lock_vars[0].write_fptr = lprocfs_wr_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/contended_locks",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_contended_locks;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lock_vars[0].write_fptr = lprocfs_wr_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
snprintf(lock_name, MAX_STRING_SIZE, "%s/max_parallel_ast",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_max_parallel_ast;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lock_vars[0].write_fptr = lprocfs_wr_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
} }
return 0; return 0;
} }
......
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
*/ */
#include <linux/libcfs/libcfs.h> #include <linux/libcfs/libcfs.h>
#include <linux/seq_file.h>
#if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1 #if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
static unsigned int warn_on_depth = 8; static unsigned int warn_on_depth = 8;
...@@ -2027,9 +2028,9 @@ void cfs_hash_rehash_key(cfs_hash_t *hs, const void *old_key, ...@@ -2027,9 +2028,9 @@ void cfs_hash_rehash_key(cfs_hash_t *hs, const void *old_key,
} }
EXPORT_SYMBOL(cfs_hash_rehash_key); EXPORT_SYMBOL(cfs_hash_rehash_key);
int cfs_hash_debug_header(char *str, int size) int cfs_hash_debug_header(struct seq_file *m)
{ {
return snprintf(str, size, "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%8s%8s%8s%s\n", return seq_printf(m, "%-*s%6s%6s%6s%6s%6s%6s%6s%7s%8s%8s%8s%s\n",
CFS_HASH_BIGNAME_LEN, CFS_HASH_BIGNAME_LEN,
"name", "cur", "min", "max", "theta", "t-min", "t-max", "name", "cur", "min", "max", "theta", "t-min", "t-max",
"flags", "rehash", "count", "maxdep", "maxdepb", "flags", "rehash", "count", "maxdep", "maxdepb",
...@@ -2061,38 +2062,28 @@ cfs_hash_full_nbkt(cfs_hash_t *hs) ...@@ -2061,38 +2062,28 @@ cfs_hash_full_nbkt(cfs_hash_t *hs)
CFS_HASH_RH_NBKT(hs) : CFS_HASH_NBKT(hs); CFS_HASH_RH_NBKT(hs) : CFS_HASH_NBKT(hs);
} }
int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size) int cfs_hash_debug_str(cfs_hash_t *hs, struct seq_file *m)
{ {
int dist[8] = { 0, }; int dist[8] = { 0, };
int maxdep = -1; int maxdep = -1;
int maxdepb = -1; int maxdepb = -1;
int total = 0; int total = 0;
int c = 0;
int theta; int theta;
int i; int i;
if (str == NULL || size == 0)
return 0;
cfs_hash_lock(hs, 0); cfs_hash_lock(hs, 0);
theta = __cfs_hash_theta(hs); theta = __cfs_hash_theta(hs);
c += snprintf(str + c, size - c, "%-*s ", seq_printf(m, "%-*s %5d %5d %5d %d.%03d %d.%03d %d.%03d 0x%02x %6d ",
CFS_HASH_BIGNAME_LEN, hs->hs_name); CFS_HASH_BIGNAME_LEN, hs->hs_name,
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_cur_bits); 1 << hs->hs_cur_bits, 1 << hs->hs_min_bits,
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_min_bits); 1 << hs->hs_max_bits,
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_max_bits); __cfs_hash_theta_int(theta), __cfs_hash_theta_frac(theta),
c += snprintf(str + c, size - c, "%d.%03d ",
__cfs_hash_theta_int(theta),
__cfs_hash_theta_frac(theta));
c += snprintf(str + c, size - c, "%d.%03d ",
__cfs_hash_theta_int(hs->hs_min_theta), __cfs_hash_theta_int(hs->hs_min_theta),
__cfs_hash_theta_frac(hs->hs_min_theta)); __cfs_hash_theta_frac(hs->hs_min_theta),
c += snprintf(str + c, size - c, "%d.%03d ",
__cfs_hash_theta_int(hs->hs_max_theta), __cfs_hash_theta_int(hs->hs_max_theta),
__cfs_hash_theta_frac(hs->hs_max_theta)); __cfs_hash_theta_frac(hs->hs_max_theta),
c += snprintf(str + c, size - c, " 0x%02x ", hs->hs_flags); hs->hs_flags, hs->hs_rehash_count);
c += snprintf(str + c, size - c, "%6d ", hs->hs_rehash_count);
/* /*
* The distribution is a summary of the chained hash depth in * The distribution is a summary of the chained hash depth in
...@@ -2121,15 +2112,12 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size) ...@@ -2121,15 +2112,12 @@ int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size)
cfs_hash_bd_unlock(hs, &bd, 0); cfs_hash_bd_unlock(hs, &bd, 0);
} }
c += snprintf(str + c, size - c, "%7d ", total); seq_printf(m, "%7d %7d %7d ", total, maxdep, maxdepb);
c += snprintf(str + c, size - c, "%7d ", maxdep);
c += snprintf(str + c, size - c, "%7d ", maxdepb);
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
c += snprintf(str + c, size - c, "%d%c", dist[i], seq_printf(m, "%d%c", dist[i], (i == 7) ? '\n' : '/');
(i == 7) ? '\n' : '/');
cfs_hash_unlock(hs, 0); cfs_hash_unlock(hs, 0);
return c; return 0;
} }
EXPORT_SYMBOL(cfs_hash_debug_str); EXPORT_SYMBOL(cfs_hash_debug_str);
...@@ -525,8 +525,7 @@ static struct seq_operations vvp_pgcache_ops = { ...@@ -525,8 +525,7 @@ static struct seq_operations vvp_pgcache_ops = {
static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp) static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp)
{ {
struct proc_dir_entry *dp = PDE(inode); struct ll_sb_info *sbi = PDE_DATA(inode);
struct ll_sb_info *sbi = dp->data;
struct seq_file *seq; struct seq_file *seq;
int result; int result;
......
...@@ -76,7 +76,7 @@ static void lmv_activate_target(struct lmv_obd *lmv, ...@@ -76,7 +76,7 @@ static void lmv_activate_target(struct lmv_obd *lmv,
static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
int activate) int activate)
{ {
struct lmv_tgt_desc *tgt; struct lmv_tgt_desc *uninitialized_var(tgt);
struct obd_device *obd; struct obd_device *obd;
int i; int i;
int rc = 0; int rc = 0;
...@@ -230,12 +230,17 @@ static int lmv_connect(const struct lu_env *env, ...@@ -230,12 +230,17 @@ static int lmv_connect(const struct lu_env *env,
if (data) if (data)
lmv->conn_data = *data; lmv->conn_data = *data;
lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry, if (obd->obd_proc_private != NULL) {
NULL, NULL); lmv_proc_dir = obd->obd_proc_private;
if (IS_ERR(lmv_proc_dir)) { } else {
CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
obd->obd_type->typ_name, obd->obd_name); NULL, NULL);
lmv_proc_dir = NULL; if (IS_ERR(lmv_proc_dir)) {
CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
obd->obd_type->typ_name, obd->obd_name);
lmv_proc_dir = NULL;
}
obd->obd_proc_private = lmv_proc_dir;
} }
/* /*
...@@ -247,9 +252,9 @@ static int lmv_connect(const struct lu_env *env, ...@@ -247,9 +252,9 @@ static int lmv_connect(const struct lu_env *env,
if (data->ocd_connect_flags & OBD_CONNECT_REAL) if (data->ocd_connect_flags & OBD_CONNECT_REAL)
rc = lmv_check_connect(obd); rc = lmv_check_connect(obd);
if (rc) { if (rc && lmv_proc_dir) {
if (lmv_proc_dir) lprocfs_remove(&lmv_proc_dir);
lprocfs_remove(&lmv_proc_dir); obd->obd_proc_private = NULL;
} }
RETURN(rc); RETURN(rc);
...@@ -408,7 +413,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -408,7 +413,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
atomic_read(&obd->obd_refcount)); atomic_read(&obd->obd_refcount));
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); lmv_proc_dir = obd->obd_proc_private;
if (lmv_proc_dir) { if (lmv_proc_dir) {
struct proc_dir_entry *mdc_symlink; struct proc_dir_entry *mdc_symlink;
...@@ -425,7 +430,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -425,7 +430,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
obd->obd_type->typ_name, obd->obd_name, obd->obd_type->typ_name, obd->obd_name,
mdc_obd->obd_name); mdc_obd->obd_name);
lprocfs_remove(&lmv_proc_dir); lprocfs_remove(&lmv_proc_dir);
lmv_proc_dir = NULL; obd->obd_proc_private = NULL;
} }
} }
RETURN(0); RETURN(0);
...@@ -626,19 +631,10 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -626,19 +631,10 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_no_recov = obd->obd_no_recov; mdc_obd->obd_no_recov = obd->obd_no_recov;
} }
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); lmv_proc_dir = obd->obd_proc_private;
if (lmv_proc_dir) { if (lmv_proc_dir)
struct proc_dir_entry *mdc_symlink; lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir);
mdc_symlink = lprocfs_srch(lmv_proc_dir, mdc_obd->obd_name);
if (mdc_symlink) {
lprocfs_remove(&mdc_symlink);
} else {
CERROR("/proc/fs/lustre/%s/%s/target_obds/%s missing\n",
obd->obd_type->typ_name, obd->obd_name,
mdc_obd->obd_name);
}
}
rc = obd_fid_fini(tgt->ltd_exp->exp_obd); rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
if (rc) if (rc)
CERROR("Can't finanize fids factory\n"); CERROR("Can't finanize fids factory\n");
...@@ -664,7 +660,6 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) ...@@ -664,7 +660,6 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
static int lmv_disconnect(struct obd_export *exp) static int lmv_disconnect(struct obd_export *exp)
{ {
struct obd_device *obd = class_exp2obd(exp); struct obd_device *obd = class_exp2obd(exp);
struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv; struct lmv_obd *lmv = &obd->u.lmv;
int rc; int rc;
int i; int i;
...@@ -687,13 +682,11 @@ static int lmv_disconnect(struct obd_export *exp) ...@@ -687,13 +682,11 @@ static int lmv_disconnect(struct obd_export *exp)
lmv_disconnect_mdc(obd, lmv->tgts[i]); lmv_disconnect_mdc(obd, lmv->tgts[i]);
} }
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); if (obd->obd_proc_private)
if (lmv_proc_dir) { lprocfs_remove((proc_dir_entry_t **)&obd->obd_proc_private);
lprocfs_remove(&lmv_proc_dir); else
} else {
CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
obd->obd_type->typ_name, obd->obd_name); obd->obd_type->typ_name, obd->obd_name);
}
out_local: out_local:
/* /*
......
...@@ -46,18 +46,16 @@ ...@@ -46,18 +46,16 @@
static struct lprocfs_vars lprocfs_module_vars[] = { {0} }; static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
static struct lprocfs_vars lprocfs_obd_vars[] = { {0} }; static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
#else #else
static int lmv_rd_numobd(char *page, char **start, off_t off, int count, static int lmv_numobd_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_desc *desc; struct lmv_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lmv.desc; desc = &dev->u.lmv.desc;
*eof = 1; return seq_printf(m, "%u\n", desc->ld_tgt_count);
return snprintf(page, count, "%u\n", desc->ld_tgt_count);
} }
LPROC_SEQ_FOPS_RO(lmv_numobd);
static const char *placement_name[] = { static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR", [PLACEMENT_CHAR_POLICY] = "CHAR",
...@@ -82,26 +80,22 @@ static const char *placement_policy2name(placement_policy_t placement) ...@@ -82,26 +80,22 @@ static const char *placement_policy2name(placement_policy_t placement)
return placement_name[placement]; return placement_name[placement];
} }
static int lmv_rd_placement(char *page, char **start, off_t off, int count, static int lmv_placement_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_obd *lmv; struct lmv_obd *lmv;
LASSERT(dev != NULL); LASSERT(dev != NULL);
lmv = &dev->u.lmv; lmv = &dev->u.lmv;
*eof = 1; return seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
return snprintf(page, count, "%s\n",
placement_policy2name(lmv->lmv_placement));
} }
#define MAX_POLICY_STRING_SIZE 64 #define MAX_POLICY_STRING_SIZE 64
static int lmv_wr_placement(struct file *file, const char *buffer, static ssize_t lmv_placement_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
char dummy[MAX_POLICY_STRING_SIZE + 1]; char dummy[MAX_POLICY_STRING_SIZE + 1];
int len = count; int len = count;
placement_policy_t policy; placement_policy_t policy;
...@@ -131,30 +125,29 @@ static int lmv_wr_placement(struct file *file, const char *buffer, ...@@ -131,30 +125,29 @@ static int lmv_wr_placement(struct file *file, const char *buffer,
} }
return count; return count;
} }
LPROC_SEQ_FOPS(lmv_placement);
static int lmv_rd_activeobd(char *page, char **start, off_t off, int count, static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_desc *desc; struct lmv_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lmv.desc; desc = &dev->u.lmv.desc;
*eof = 1; return seq_printf(m, "%u\n", desc->ld_active_tgt_count);
return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
} }
LPROC_SEQ_FOPS_RO(lmv_activeobd);
static int lmv_rd_desc_uuid(char *page, char **start, off_t off, int count, static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*) data; struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_obd *lmv; struct lmv_obd *lmv;
LASSERT(dev != NULL); LASSERT(dev != NULL);
lmv = &dev->u.lmv; lmv = &dev->u.lmv;
*eof = 1; return seq_printf(m, "%s\n", lmv->desc.ld_uuid.uuid);
return snprintf(page, count, "%s\n", lmv->desc.ld_uuid.uuid);
} }
LPROC_SEQ_FOPS_RO(lmv_desc_uuid);
static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos) static void *lmv_tgt_seq_start(struct seq_file *p, loff_t *pos)
{ {
...@@ -195,7 +188,6 @@ struct seq_operations lmv_tgt_sops = { ...@@ -195,7 +188,6 @@ struct seq_operations lmv_tgt_sops = {
static int lmv_target_seq_open(struct inode *inode, struct file *file) static int lmv_target_seq_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq; struct seq_file *seq;
int rc; int rc;
...@@ -204,22 +196,26 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) ...@@ -204,22 +196,26 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
return rc; return rc;
seq = file->private_data; seq = file->private_data;
seq->private = dp->data; seq->private = PDE_DATA(inode);
return 0; return 0;
} }
LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
struct lprocfs_vars lprocfs_lmv_obd_vars[] = { struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
{ "numobd", lmv_rd_numobd, 0, 0 }, { "numobd", &lmv_numobd_fops, 0, 0 },
{ "placement", lmv_rd_placement, lmv_wr_placement, 0 }, { "placement", &lmv_placement_fops, 0, 0 },
{ "activeobd", lmv_rd_activeobd, 0, 0 }, { "activeobd", &lmv_activeobd_fops, 0, 0 },
{ "uuid", lprocfs_rd_uuid, 0, 0 }, { "uuid", &lmv_uuid_fops, 0, 0 },
{ "desc_uuid", lmv_rd_desc_uuid, 0, 0 }, { "desc_uuid", &lmv_desc_uuid_fops, 0, 0 },
{ 0 } { 0 }
}; };
LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
static struct lprocfs_vars lprocfs_lmv_module_vars[] = { static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 }, { "num_refs", &lmv_numrefs_fops, 0, 0 },
{ 0 } { 0 }
}; };
......
...@@ -191,7 +191,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, ...@@ -191,7 +191,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index, CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); lov_proc_dir = obd->obd_proc_private;
if (lov_proc_dir) { if (lov_proc_dir) {
struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
proc_dir_entry_t *osc_symlink; proc_dir_entry_t *osc_symlink;
...@@ -211,6 +211,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, ...@@ -211,6 +211,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
obd->obd_type->typ_name, obd->obd_name, obd->obd_type->typ_name, obd->obd_name,
osc_obd->obd_name); osc_obd->obd_name);
lprocfs_remove(&lov_proc_dir); lprocfs_remove(&lov_proc_dir);
obd->obd_proc_private = NULL;
} }
} }
...@@ -290,19 +291,9 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) ...@@ -290,19 +291,9 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
tgt->ltd_exp->exp_obd->obd_inactive = 1; tgt->ltd_exp->exp_obd->obd_inactive = 1;
} }
lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds"); lov_proc_dir = obd->obd_proc_private;
if (lov_proc_dir) { if (lov_proc_dir)
proc_dir_entry_t *osc_symlink; lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
osc_symlink = lprocfs_srch(lov_proc_dir, osc_obd->obd_name);
if (osc_symlink) {
lprocfs_remove(&osc_symlink);
} else {
CERROR("/proc/fs/lustre/%s/%s/target_obds/%s missing.",
obd->obd_type->typ_name, obd->obd_name,
osc_obd->obd_name);
}
}
if (osc_obd) { if (osc_obd) {
/* Pass it on to our clients. /* Pass it on to our clients.
......
...@@ -284,7 +284,7 @@ static int pool_proc_open(struct inode *inode, struct file *file) ...@@ -284,7 +284,7 @@ static int pool_proc_open(struct inode *inode, struct file *file)
rc = seq_open(file, &pool_proc_ops); rc = seq_open(file, &pool_proc_ops);
if (!rc) { if (!rc) {
struct seq_file *s = file->private_data; struct seq_file *s = file->private_data;
s->private = PROC_I(inode)->pde->data; s->private = PDE_DATA(inode);
} }
return rc; return rc;
} }
...@@ -468,8 +468,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname) ...@@ -468,8 +468,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
/* get ref for /proc file */ /* get ref for /proc file */
lov_pool_getref(new_pool); lov_pool_getref(new_pool);
new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry, new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
poolname, NULL, NULL, poolname, new_pool,
new_pool,
&pool_proc_operations); &pool_proc_operations);
if (IS_ERR(new_pool->pool_proc_entry)) { if (IS_ERR(new_pool->pool_proc_entry)) {
CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname); CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
......
...@@ -43,22 +43,20 @@ ...@@ -43,22 +43,20 @@
#include "lov_internal.h" #include "lov_internal.h"
#ifdef LPROCFS #ifdef LPROCFS
static int lov_rd_stripesize(char *page, char **start, off_t off, int count, static int lov_stripesize_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, LPU64"\n", desc->ld_default_stripe_size);
return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
} }
static int lov_wr_stripesize(struct file *file, const char *buffer, static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc; struct lov_desc *desc;
__u64 val; __u64 val;
int rc; int rc;
...@@ -73,23 +71,22 @@ static int lov_wr_stripesize(struct file *file, const char *buffer, ...@@ -73,23 +71,22 @@ static int lov_wr_stripesize(struct file *file, const char *buffer,
desc->ld_default_stripe_size = val; desc->ld_default_stripe_size = val;
return count; return count;
} }
LPROC_SEQ_FOPS(lov_stripesize);
static int lov_rd_stripeoffset(char *page, char **start, off_t off, int count, static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, LPU64"\n", desc->ld_default_stripe_offset);
return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
} }
static int lov_wr_stripeoffset(struct file *file, const char *buffer, static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc; struct lov_desc *desc;
__u64 val; __u64 val;
int rc; int rc;
...@@ -103,23 +100,22 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer, ...@@ -103,23 +100,22 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer,
desc->ld_default_stripe_offset = val; desc->ld_default_stripe_offset = val;
return count; return count;
} }
LPROC_SEQ_FOPS(lov_stripeoffset);
static int lov_rd_stripetype(char *page, char **start, off_t off, int count, static int lov_stripetype_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device* dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, "%u\n", desc->ld_pattern);
return snprintf(page, count, "%u\n", desc->ld_pattern);
} }
static int lov_wr_stripetype(struct file *file, const char *buffer, static ssize_t lov_stripetype_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc; struct lov_desc *desc;
int val, rc; int val, rc;
...@@ -133,24 +129,23 @@ static int lov_wr_stripetype(struct file *file, const char *buffer, ...@@ -133,24 +129,23 @@ static int lov_wr_stripetype(struct file *file, const char *buffer,
desc->ld_pattern = val; desc->ld_pattern = val;
return count; return count;
} }
LPROC_SEQ_FOPS(lov_stripetype);
static int lov_rd_stripecount(char *page, char **start, off_t off, int count, static int lov_stripecount_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, "%d\n",
return snprintf(page, count, "%d\n",
(__s16)(desc->ld_default_stripe_count + 1) - 1); (__s16)(desc->ld_default_stripe_count + 1) - 1);
} }
static int lov_wr_stripecount(struct file *file, const char *buffer, static ssize_t lov_stripecount_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *dev = (struct obd_device *)data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct lov_desc *desc; struct lov_desc *desc;
int val, rc; int val, rc;
...@@ -164,43 +159,40 @@ static int lov_wr_stripecount(struct file *file, const char *buffer, ...@@ -164,43 +159,40 @@ static int lov_wr_stripecount(struct file *file, const char *buffer,
desc->ld_default_stripe_count = val; desc->ld_default_stripe_count = val;
return count; return count;
} }
LPROC_SEQ_FOPS(lov_stripecount);
static int lov_rd_numobd(char *page, char **start, off_t off, int count, static int lov_numobd_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, "%u\n", desc->ld_tgt_count);
return snprintf(page, count, "%u\n", desc->ld_tgt_count);
} }
LPROC_SEQ_FOPS_RO(lov_numobd);
static int lov_rd_activeobd(char *page, char **start, off_t off, int count, static int lov_activeobd_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device* dev = (struct obd_device*)data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc; struct lov_desc *desc;
LASSERT(dev != NULL); LASSERT(dev != NULL);
desc = &dev->u.lov.desc; desc = &dev->u.lov.desc;
*eof = 1; return seq_printf(m, "%u\n", desc->ld_active_tgt_count);
return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
} }
LPROC_SEQ_FOPS_RO(lov_activeobd);
static int lov_rd_desc_uuid(char *page, char **start, off_t off, int count, static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
struct obd_device *dev = (struct obd_device*) data; struct obd_device *dev = (struct obd_device *)m->private;
struct lov_obd *lov; struct lov_obd *lov;
LASSERT(dev != NULL); LASSERT(dev != NULL);
lov = &dev->u.lov; lov = &dev->u.lov;
*eof = 1; return seq_printf(m, "%s\n", lov->desc.ld_uuid.uuid);
return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
} }
LPROC_SEQ_FOPS_RO(lov_desc_uuid);
static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos) static void *lov_tgt_seq_start(struct seq_file *p, loff_t *pos)
{ {
...@@ -248,43 +240,49 @@ struct seq_operations lov_tgt_sops = { ...@@ -248,43 +240,49 @@ struct seq_operations lov_tgt_sops = {
static int lov_target_seq_open(struct inode *inode, struct file *file) static int lov_target_seq_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq; struct seq_file *seq;
int rc; int rc;
LPROCFS_ENTRY_AND_CHECK(dp);
rc = seq_open(file, &lov_tgt_sops); rc = seq_open(file, &lov_tgt_sops);
if (rc) { if (rc)
LPROCFS_EXIT();
return rc; return rc;
}
seq = file->private_data; seq = file->private_data;
seq->private = dp->data; seq->private = PDE_DATA(inode);
return 0; return 0;
} }
LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
struct lprocfs_vars lprocfs_lov_obd_vars[] = { struct lprocfs_vars lprocfs_lov_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 }, { "uuid", &lov_uuid_fops, 0, 0 },
{ "stripesize", lov_rd_stripesize, lov_wr_stripesize, 0 }, { "stripesize", &lov_stripesize_fops, 0 },
{ "stripeoffset", lov_rd_stripeoffset, lov_wr_stripeoffset, 0 }, { "stripeoffset", &lov_stripeoffset_fops, 0 },
{ "stripecount", lov_rd_stripecount, lov_wr_stripecount, 0 }, { "stripecount", &lov_stripecount_fops, 0 },
{ "stripetype", lov_rd_stripetype, lov_wr_stripetype, 0 }, { "stripetype", &lov_stripetype_fops, 0 },
{ "numobd", lov_rd_numobd, 0, 0 }, { "numobd", &lov_numobd_fops, 0, 0 },
{ "activeobd", lov_rd_activeobd, 0, 0 }, { "activeobd", &lov_activeobd_fops, 0, 0 },
{ "filestotal", lprocfs_rd_filestotal, 0, 0 }, { "filestotal", &lov_filestotal_fops, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 }, { "filesfree", &lov_filesfree_fops, 0, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/ /*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/
{ "blocksize", lprocfs_rd_blksize, 0, 0 }, { "blocksize", &lov_blksize_fops, 0, 0 },
{ "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 }, { "kbytestotal", &lov_kbytestotal_fops, 0, 0 },
{ "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 }, { "kbytesfree", &lov_kbytesfree_fops, 0, 0 },
{ "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 }, { "kbytesavail", &lov_kbytesavail_fops, 0, 0 },
{ "desc_uuid", lov_rd_desc_uuid, 0, 0 }, { "desc_uuid", &lov_desc_uuid_fops, 0, 0 },
{ 0 } { 0 }
}; };
LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs);
static struct lprocfs_vars lprocfs_lov_module_vars[] = { static struct lprocfs_vars lprocfs_lov_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 }, { "num_refs", &lov_numrefs_fops, 0, 0 },
{ 0 } { 0 }
}; };
......
...@@ -42,23 +42,24 @@ ...@@ -42,23 +42,24 @@
#ifdef LPROCFS #ifdef LPROCFS
static int mdc_rd_max_rpcs_in_flight(char *page, char **start, off_t off, static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
struct obd_device *dev = data; struct obd_device *dev = m->private;
struct client_obd *cli = &dev->u.cli; struct client_obd *cli = &dev->u.cli;
int rc; int rc;
client_obd_list_lock(&cli->cl_loi_list_lock); client_obd_list_lock(&cli->cl_loi_list_lock);
rc = snprintf(page, count, "%u\n", cli->cl_max_rpcs_in_flight); rc = seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
client_obd_list_unlock(&cli->cl_loi_list_lock); client_obd_list_unlock(&cli->cl_loi_list_lock);
return rc; return rc;
} }
static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer, static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
unsigned long count, void *data) const char *buffer,
size_t count,
loff_t *off)
{ {
struct obd_device *dev = data; struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
struct client_obd *cli = &dev->u.cli; struct client_obd *cli = &dev->u.cli;
int val, rc; int val, rc;
...@@ -75,12 +76,13 @@ static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer, ...@@ -75,12 +76,13 @@ static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
return count; return count;
} }
LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
/* temporary for testing */ /* temporary for testing */
static int mdc_wr_kuc(struct file *file, const char *buffer, static ssize_t mdc_wr_kuc(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
struct obd_device *obd = data; struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
struct kuc_hdr *lh; struct kuc_hdr *lh;
struct hsm_action_list *hal; struct hsm_action_list *hal;
struct hsm_action_item *hai; struct hsm_action_item *hai;
...@@ -137,41 +139,67 @@ static int mdc_wr_kuc(struct file *file, const char *buffer, ...@@ -137,41 +139,67 @@ static int mdc_wr_kuc(struct file *file, const char *buffer,
RETURN(rc); RETURN(rc);
RETURN(count); RETURN(count);
} }
struct file_operations mdc_kuc_fops = {
.write = mdc_wr_kuc,
};
LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
{
return lprocfs_obd_rd_max_pages_per_rpc(m, m->private);
}
LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
static struct lprocfs_vars lprocfs_mdc_obd_vars[] = { static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 }, { "uuid", &mdc_uuid_fops, 0, 0 },
{ "ping", 0, lprocfs_wr_ping, 0, 0, 0222 }, { "ping", &mdc_ping_fops, 0, 0222 },
{ "connect_flags", lprocfs_rd_connect_flags, 0, 0 }, { "connect_flags", &mdc_connect_flags_fops, 0, 0 },
{ "blocksize", lprocfs_rd_blksize, 0, 0 }, { "blocksize", &mdc_blksize_fops, 0, 0 },
{ "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 }, { "kbytestotal", &mdc_kbytestotal_fops, 0, 0 },
{ "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 }, { "kbytesfree", &mdc_kbytesfree_fops, 0, 0 },
{ "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 }, { "kbytesavail", &mdc_kbytesavail_fops, 0, 0 },
{ "filestotal", lprocfs_rd_filestotal, 0, 0 }, { "filestotal", &mdc_filestotal_fops, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 }, { "filesfree", &mdc_filesfree_fops, 0, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/ /*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/
{ "mds_server_uuid", lprocfs_rd_server_uuid, 0, 0 }, { "mds_server_uuid", &mdc_server_uuid_fops, 0, 0 },
{ "mds_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 }, { "mds_conn_uuid", &mdc_conn_uuid_fops, 0, 0 },
/* /*
* FIXME: below proc entry is provided, but not in used, instead * FIXME: below proc entry is provided, but not in used, instead
* sbi->sb_md_brw_size is used, the per obd variable should be used * sbi->sb_md_brw_size is used, the per obd variable should be used
* when CMD is enabled, and dir pages are managed in MDC layer. * when CMD is enabled, and dir pages are managed in MDC layer.
* Remember to enable proc write function. * Remember to enable proc write function.
*/ */
{ "max_pages_per_rpc", lprocfs_obd_rd_max_pages_per_rpc, { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, 0, 0 },
/* lprocfs_obd_wr_max_pages_per_rpc */0, 0 }, { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, 0, 0 },
{ "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight, { "timeouts", &mdc_timeouts_fops, 0, 0 },
mdc_wr_max_rpcs_in_flight, 0 }, { "import", &mdc_import_fops, 0 },
{ "timeouts", lprocfs_rd_timeouts, 0, 0 }, { "state", &mdc_state_fops, 0, 0 },
{ "import", lprocfs_rd_import, lprocfs_wr_import, 0 }, { "hsm_nl", &mdc_kuc_fops, 0, 0200 },
{ "state", lprocfs_rd_state, 0, 0 }, { "pinger_recov", &mdc_pinger_recov_fops, 0, 0 },
{ "hsm_nl", 0, mdc_wr_kuc, 0, 0, 0200 },
{ "pinger_recov", lprocfs_rd_pinger_recov,
lprocfs_wr_pinger_recov, 0, 0 },
{ 0 } { 0 }
}; };
LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs);
static struct lprocfs_vars lprocfs_mdc_module_vars[] = { static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 }, { "num_refs", &mdc_numrefs_fops, 0, 0 },
{ 0 } { 0 }
}; };
......
...@@ -43,20 +43,36 @@ ...@@ -43,20 +43,36 @@
#ifdef LPROCFS #ifdef LPROCFS
LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, import);
LPROC_SEQ_FOPS_RO_TYPE(mgc, state);
LPROC_SEQ_FOPS_WR_ONLY(mgc, ping);
static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
{
return lprocfs_mgc_rd_ir_state(m, m->private);
}
LPROC_SEQ_FOPS_RO(mgc_ir_state);
static struct lprocfs_vars lprocfs_mgc_obd_vars[] = { static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 }, { "uuid", &mgc_uuid_fops, 0, 0 },
{ "ping", 0, lprocfs_wr_ping, 0, 0, 0222 }, { "ping", &mgc_ping_fops, 0, 0222 },
{ "connect_flags", lprocfs_rd_connect_flags, 0, 0 }, { "connect_flags", &mgc_connect_flags_fops, 0, 0 },
{ "mgs_server_uuid", lprocfs_rd_server_uuid, 0, 0 }, { "mgs_server_uuid", &mgc_server_uuid_fops, 0, 0 },
{ "mgs_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 }, { "mgs_conn_uuid", &mgc_conn_uuid_fops, 0, 0 },
{ "import", lprocfs_rd_import, 0, 0 }, { "import", &mgc_import_fops, 0, 0 },
{ "state", lprocfs_rd_state, 0, 0 }, { "state", &mgc_state_fops, 0, 0 },
{ "ir_state", lprocfs_mgc_rd_ir_state, 0, 0 }, { "ir_state", &mgc_ir_state_fops, 0, 0 },
{ 0 } { 0 }
}; };
LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs);
static struct lprocfs_vars lprocfs_mgc_module_vars[] = { static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 }, { "num_refs", &mgc_numrefs_fops, 0, 0 },
{ 0 } { 0 }
}; };
......
...@@ -46,15 +46,13 @@ ...@@ -46,15 +46,13 @@
#ifdef LPROCFS #ifdef LPROCFS
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars); void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off, int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data);
int count, int *eof, void *data);
#else #else
static void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars) static void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
{ {
memset(lvars, 0, sizeof(*lvars)); memset(lvars, 0, sizeof(*lvars));
} }
static inline int lprocfs_mgc_rd_ir_state(char *page, char **start, static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
off_t off, int count, int *eof, void *data)
{ {
return 0; return 0;
} }
......
...@@ -409,32 +409,29 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg) ...@@ -409,32 +409,29 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
RETURN(rc); RETURN(rc);
} }
int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off, int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
int count, int *eof, void *data)
{ {
struct obd_device *obd = data; struct obd_device *obd = data;
struct obd_import *imp = obd->u.cli.cl_import; struct obd_import *imp = obd->u.cli.cl_import;
struct obd_connect_data *ocd = &imp->imp_connect_data; struct obd_connect_data *ocd = &imp->imp_connect_data;
struct config_llog_data *cld; struct config_llog_data *cld;
int rc = 0;
ENTRY; ENTRY;
rc = snprintf(page, count, "imperative_recovery: %s\n", seq_printf(m, "imperative_recovery: %s\n",
OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED"); OCD_HAS_FLAG(ocd, IMP_RECOV) ? "ENABLED" : "DISABLED");
rc += snprintf(page + rc, count - rc, "client_state:\n"); seq_printf(m, "client_state:\n");
spin_lock(&config_list_lock); spin_lock(&config_list_lock);
list_for_each_entry(cld, &config_llog_list, cld_list_chain) { list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
if (cld->cld_recover == NULL) if (cld->cld_recover == NULL)
continue; continue;
rc += snprintf(page + rc, count - rc, seq_printf(m, " - { client: %s, nidtbl_version: %u }\n",
" - { client: %s, nidtbl_version: %u }\n",
cld->cld_logname, cld->cld_logname,
cld->cld_recover->cld_cfg.cfg_last_idx); cld->cld_recover->cld_cfg.cfg_last_idx);
} }
spin_unlock(&config_list_lock); spin_unlock(&config_list_lock);
RETURN(rc); RETURN(0);
} }
/* reenqueue any lost locks */ /* reenqueue any lost locks */
......
...@@ -394,10 +394,8 @@ void cache_stats_init(struct cache_stats *cs, const char *name) ...@@ -394,10 +394,8 @@ void cache_stats_init(struct cache_stats *cs, const char *name)
atomic_set(&cs->cs_stats[i], 0); atomic_set(&cs->cs_stats[i], 0);
} }
int cache_stats_print(const struct cache_stats *cs, int cache_stats_print(const struct cache_stats *cs, struct seq_file *m, int h)
char *page, int count, int h)
{ {
int nob = 0;
int i; int i;
/* /*
* lookup hit total cached create * lookup hit total cached create
...@@ -406,18 +404,16 @@ int cache_stats_print(const struct cache_stats *cs, ...@@ -406,18 +404,16 @@ int cache_stats_print(const struct cache_stats *cs,
if (h) { if (h) {
const char *names[CS_NR] = CS_NAMES; const char *names[CS_NR] = CS_NAMES;
nob += snprintf(page + nob, count - nob, "%6s", " "); seq_printf(m, "%6s", " ");
for (i = 0; i < CS_NR; i++) for (i = 0; i < CS_NR; i++)
nob += snprintf(page + nob, count - nob, seq_printf(m, "%8s", names[i]);
"%8s", names[i]); seq_printf(m, "\n");
nob += snprintf(page + nob, count - nob, "\n");
} }
nob += snprintf(page + nob, count - nob, "%5.5s:", cs->cs_name); seq_printf(m, "%5.5s:", cs->cs_name);
for (i = 0; i < CS_NR; i++) for (i = 0; i < CS_NR; i++)
nob += snprintf(page + nob, count - nob, "%8u", seq_printf(m, "%8u", atomic_read(&cs->cs_stats[i]));
atomic_read(&cs->cs_stats[i])); return 0;
return nob;
} }
/** /**
...@@ -462,9 +458,8 @@ static struct cache_stats cl_env_stats = { ...@@ -462,9 +458,8 @@ static struct cache_stats cl_env_stats = {
* Outputs client site statistical counters into a buffer. Suitable for * Outputs client site statistical counters into a buffer. Suitable for
* ll_rd_*()-style functions. * ll_rd_*()-style functions.
*/ */
int cl_site_stats_print(const struct cl_site *site, char *page, int count) int cl_site_stats_print(const struct cl_site *site, struct seq_file *m)
{ {
int nob;
int i; int i;
static const char *pstate[] = { static const char *pstate[] = {
[CPS_CACHED] = "c", [CPS_CACHED] = "c",
...@@ -488,24 +483,22 @@ pages: ...... ...... ...... ...... ...... [...... ...... ...... ......] ...@@ -488,24 +483,22 @@ pages: ...... ...... ...... ...... ...... [...... ...... ...... ......]
locks: ...... ...... ...... ...... ...... [...... ...... ...... ...... ......] locks: ...... ...... ...... ...... ...... [...... ...... ...... ...... ......]
env: ...... ...... ...... ...... ...... env: ...... ...... ...... ...... ......
*/ */
nob = lu_site_stats_print(&site->cs_lu, page, count); lu_site_stats_print(&site->cs_lu, m);
nob += cache_stats_print(&site->cs_pages, page + nob, count - nob, 1); cache_stats_print(&site->cs_pages, m, 1);
nob += snprintf(page + nob, count - nob, " ["); seq_printf(m, " [");
for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i) for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i)
nob += snprintf(page + nob, count - nob, "%s: %u ", seq_printf(m, "%s: %u ", pstate[i],
pstate[i],
atomic_read(&site->cs_pages_state[i])); atomic_read(&site->cs_pages_state[i]));
nob += snprintf(page + nob, count - nob, "]\n"); seq_printf(m, "]\n");
nob += cache_stats_print(&site->cs_locks, page + nob, count - nob, 0); cache_stats_print(&site->cs_locks, m, 0);
nob += snprintf(page + nob, count - nob, " ["); seq_printf(m, " [");
for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i) for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i)
nob += snprintf(page + nob, count - nob, "%s: %u ", seq_printf(m, "%s: %u ", lstate[i],
lstate[i],
atomic_read(&site->cs_locks_state[i])); atomic_read(&site->cs_locks_state[i]));
nob += snprintf(page + nob, count - nob, "]\n"); seq_printf(m, "]\n");
nob += cache_stats_print(&cl_env_stats, page + nob, count - nob, 0); cache_stats_print(&cl_env_stats, m, 0);
nob += snprintf(page + nob, count - nob, "\n"); seq_printf(m, "\n");
return nob; return 0;
} }
EXPORT_SYMBOL(cl_site_stats_print); EXPORT_SYMBOL(cl_site_stats_print);
......
...@@ -247,11 +247,9 @@ int class_unregister_type(const char *name) ...@@ -247,11 +247,9 @@ int class_unregister_type(const char *name)
RETURN(-EBUSY); RETURN(-EBUSY);
} }
/* we do not use type->typ_procroot as for compatibility purposes if (type->typ_procroot) {
* other modules can share names (i.e. lod can use lov entry). so lprocfs_remove(&type->typ_procroot);
* we can't reference pointer as it can get invalided when another }
* module removes the entry */
lprocfs_try_remove_proc_entry(type->typ_name, proc_lustre_root);
if (type->typ_lu) if (type->typ_lu)
lu_device_type_fini(type->typ_lu); lu_device_type_fini(type->typ_lu);
......
...@@ -219,47 +219,26 @@ psdev_t obd_psdev = { ...@@ -219,47 +219,26 @@ psdev_t obd_psdev = {
#ifdef LPROCFS #ifdef LPROCFS
int obd_proc_read_version(char *page, char **start, off_t off, int count, int obd_proc_version_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
*eof = 1; return seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n",
return snprintf(page, count, "lustre: %s\nkernel: %s\nbuild: %s\n",
LUSTRE_VERSION_STRING, "patchless_client", LUSTRE_VERSION_STRING, "patchless_client",
BUILD_VERSION); BUILD_VERSION);
} }
LPROC_SEQ_FOPS_RO(obd_proc_version);
int obd_proc_read_pinger(char *page, char **start, off_t off, int count, int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
*eof = 1; return seq_printf(m, "%s\n", "on");
return snprintf(page, count, "%s\n",
"on"
);
} }
LPROC_SEQ_FOPS_RO(obd_proc_pinger);
/** static int obd_proc_health_seq_show(struct seq_file *m, void *v)
* Check all obd devices health
*
* \param page
* \param start
* \param off
* \param count
* \param eof
* \param data
* proc read function parameters, please refer to kernel
* code fs/proc/generic.c proc_file_read()
* \param data [in] unused
*
* \retval number of characters printed
*/
static int obd_proc_read_health(char *page, char **start, off_t off,
int count, int *eof, void *data)
{ {
int rc = 0, i; int rc = 0, i;
*eof = 1;
if (libcfs_catastrophe) if (libcfs_catastrophe)
rc += snprintf(page + rc, count - rc, "LBUG\n"); seq_printf(m, "LBUG\n");
read_lock(&obd_dev_lock); read_lock(&obd_dev_lock);
for (i = 0; i < class_devno_max(); i++) { for (i = 0; i < class_devno_max(); i++) {
...@@ -277,9 +256,9 @@ static int obd_proc_read_health(char *page, char **start, off_t off, ...@@ -277,9 +256,9 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
read_unlock(&obd_dev_lock); read_unlock(&obd_dev_lock);
if (obd_health_check(NULL, obd)) { if (obd_health_check(NULL, obd)) {
rc += snprintf(page + rc, count - rc, seq_printf(m, "device %s reported unhealthy\n",
"device %s reported unhealthy\n", obd->obd_name);
obd->obd_name); rc++;
} }
class_decref(obd, __FUNCTION__, current); class_decref(obd, __FUNCTION__, current);
read_lock(&obd_dev_lock); read_lock(&obd_dev_lock);
...@@ -287,20 +266,20 @@ static int obd_proc_read_health(char *page, char **start, off_t off, ...@@ -287,20 +266,20 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
read_unlock(&obd_dev_lock); read_unlock(&obd_dev_lock);
if (rc == 0) if (rc == 0)
return snprintf(page, count, "healthy\n"); return seq_printf(m, "healthy\n");
rc += snprintf(page + rc, count - rc, "NOT HEALTHY\n"); seq_printf(m, "NOT HEALTHY\n");
return rc; return 0;
} }
LPROC_SEQ_FOPS_RO(obd_proc_health);
static int obd_proc_rd_jobid_var(char *page, char **start, off_t off, static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
return snprintf(page, count, "%s\n", obd_jobid_var); return seq_printf(m, "%s\n", obd_jobid_var);
} }
static int obd_proc_wr_jobid_var(struct file *file, const char *buffer, static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, loff_t *off)
{ {
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN) if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL; return -EINVAL;
...@@ -310,17 +289,17 @@ static int obd_proc_wr_jobid_var(struct file *file, const char *buffer, ...@@ -310,17 +289,17 @@ static int obd_proc_wr_jobid_var(struct file *file, const char *buffer,
memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n')); memcpy(obd_jobid_var, buffer, count - (buffer[count - 1] == '\n'));
return count; return count;
} }
LPROC_SEQ_FOPS(obd_proc_jobid_var);
/* Root for /proc/fs/lustre */ /* Root for /proc/fs/lustre */
struct proc_dir_entry *proc_lustre_root = NULL; struct proc_dir_entry *proc_lustre_root = NULL;
EXPORT_SYMBOL(proc_lustre_root); EXPORT_SYMBOL(proc_lustre_root);
struct lprocfs_vars lprocfs_base[] = { struct lprocfs_vars lprocfs_base[] = {
{ "version", obd_proc_read_version, NULL, NULL }, { "version", &obd_proc_version_fops },
{ "pinger", obd_proc_read_pinger, NULL, NULL }, { "pinger", &obd_proc_pinger_fops },
{ "health_check", obd_proc_read_health, NULL, NULL }, { "health_check", &obd_proc_health_fops },
{ "jobid_var", obd_proc_rd_jobid_var, { "jobid_var", &obd_proc_jobid_var_fops },
obd_proc_wr_jobid_var, NULL },
{ 0 } { 0 }
}; };
#else #else
...@@ -384,7 +363,6 @@ struct seq_operations obd_device_list_sops = { ...@@ -384,7 +363,6 @@ struct seq_operations obd_device_list_sops = {
static int obd_device_list_open(struct inode *inode, struct file *file) static int obd_device_list_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq; struct seq_file *seq;
int rc = seq_open(file, &obd_device_list_sops); int rc = seq_open(file, &obd_device_list_sops);
...@@ -392,7 +370,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file) ...@@ -392,7 +370,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
return rc; return rc;
seq = file->private_data; seq = file->private_data;
seq->private = dp->data; seq->private = PDE_DATA(inode);
return 0; return 0;
} }
......
...@@ -418,20 +418,14 @@ struct seq_operations lprocfs_jobstats_seq_sops = { ...@@ -418,20 +418,14 @@ struct seq_operations lprocfs_jobstats_seq_sops = {
static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file) static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
{ {
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq; struct seq_file *seq;
int rc; int rc;
if (LPROCFS_ENTRY_AND_CHECK(dp))
return -ENOENT;
rc = seq_open(file, &lprocfs_jobstats_seq_sops); rc = seq_open(file, &lprocfs_jobstats_seq_sops);
if (rc) { if (rc)
LPROCFS_EXIT();
return rc; return rc;
}
seq = file->private_data; seq = file->private_data;
seq->private = dp->data; seq->private = PDE_DATA(inode);
return 0; return 0;
} }
...@@ -523,30 +517,23 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num, ...@@ -523,30 +517,23 @@ int lprocfs_job_stats_init(struct obd_device *obd, int cntr_num,
stats->ojs_cleanup_interval = 600; /* 10 mins by default */ stats->ojs_cleanup_interval = 600; /* 10 mins by default */
stats->ojs_last_cleanup = cfs_time_current_sec(); stats->ojs_last_cleanup = cfs_time_current_sec();
LPROCFS_WRITE_ENTRY(); entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry,
entry = create_proc_entry("job_stats", 0644, obd->obd_proc_entry); &lprocfs_jobstats_seq_fops, stats);
LPROCFS_WRITE_EXIT(); if (entry)
if (entry) {
entry->proc_fops = &lprocfs_jobstats_seq_fops;
entry->data = stats;
RETURN(0); RETURN(0);
} else { else
lprocfs_job_stats_fini(obd);
RETURN(-ENOMEM); RETURN(-ENOMEM);
}
} }
EXPORT_SYMBOL(lprocfs_job_stats_init); EXPORT_SYMBOL(lprocfs_job_stats_init);
int lprocfs_rd_job_interval(char *page, char **start, off_t off, int lprocfs_rd_job_interval(struct seq_file *m, void *data)
int count, int *eof, void *data)
{ {
struct obd_device *obd = (struct obd_device *)data; struct obd_device *obd = (struct obd_device *)data;
struct obd_job_stats *stats; struct obd_job_stats *stats;
LASSERT(obd != NULL); LASSERT(obd != NULL);
stats = &obd->u.obt.obt_jobstats; stats = &obd->u.obt.obt_jobstats;
*eof = 1; return seq_printf(m, "%d\n", stats->ojs_cleanup_interval);
return snprintf(page, count, "%d\n", stats->ojs_cleanup_interval);
} }
EXPORT_SYMBOL(lprocfs_rd_job_interval); EXPORT_SYMBOL(lprocfs_rd_job_interval);
......
...@@ -2021,14 +2021,14 @@ static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx) ...@@ -2021,14 +2021,14 @@ static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
* Output site statistical counters into a buffer. Suitable for * Output site statistical counters into a buffer. Suitable for
* lprocfs_rd_*()-style functions. * lprocfs_rd_*()-style functions.
*/ */
int lu_site_stats_print(const struct lu_site *s, char *page, int count) int lu_site_stats_print(const struct lu_site *s, struct seq_file *m)
{ {
lu_site_stats_t stats; lu_site_stats_t stats;
memset(&stats, 0, sizeof(stats)); memset(&stats, 0, sizeof(stats));
lu_site_stats_get(s->ls_obj_hash, &stats, 1); lu_site_stats_get(s->ls_obj_hash, &stats, 1);
return snprintf(page, count, "%d/%d %d/%d %d %d %d %d %d %d %d\n", return seq_printf(m, "%d/%d %d/%d %d %d %d %d %d %d %d\n",
stats.lss_busy, stats.lss_busy,
stats.lss_total, stats.lss_total,
stats.lss_populated, stats.lss_populated,
......
...@@ -1237,6 +1237,8 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, ...@@ -1237,6 +1237,8 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
struct lustre_cfg *lcfg, void *data) struct lustre_cfg *lcfg, void *data)
{ {
struct lprocfs_vars *var; struct lprocfs_vars *var;
struct file fakefile;
struct seq_file fake_seqfile;
char *key, *sval; char *key, *sval;
int i, keylen, vallen; int i, keylen, vallen;
int matched = 0, j = 0; int matched = 0, j = 0;
...@@ -1249,6 +1251,9 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, ...@@ -1249,6 +1251,9 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
RETURN(-EINVAL); RETURN(-EINVAL);
} }
/* fake a seq file so that var->fops->write can work... */
fakefile.private_data = &fake_seqfile;
fake_seqfile.private = data;
/* e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt /* e.g. tunefs.lustre --param mdt.group_upcall=foo /r/tmp/lustre-mdt
or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar
or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 */ or lctl conf_param lustre-OST0000.osc.max_dirty_mb=36 */
...@@ -1274,12 +1279,12 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars, ...@@ -1274,12 +1279,12 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
keylen == strlen(var->name)) { keylen == strlen(var->name)) {
matched++; matched++;
rc = -EROFS; rc = -EROFS;
if (var->write_fptr) { if (var->fops && var->fops->write) {
mm_segment_t oldfs; mm_segment_t oldfs;
oldfs = get_fs(); oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
rc = (var->write_fptr)(NULL, sval, rc = (var->fops->write)(&fakefile, sval,
vallen, data); vallen, NULL);
set_fs(oldfs); set_fs(oldfs);
} }
break; break;
......
...@@ -37,13 +37,15 @@ ...@@ -37,13 +37,15 @@
#include <obd_class.h> #include <obd_class.h>
#ifdef LPROCFS #ifdef LPROCFS
LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
static struct lprocfs_vars lprocfs_echo_obd_vars[] = { static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 }, { "uuid", &echo_uuid_fops, 0, 0 },
{ 0 } { 0 }
}; };
LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs);
static struct lprocfs_vars lprocfs_echo_module_vars[] = { static struct lprocfs_vars lprocfs_echo_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 }, { "num_refs", &echo_numrefs_fops, 0, 0 },
{ 0 } { 0 }
}; };
......
...@@ -94,12 +94,9 @@ void gss_stat_oos_record_svc(int phase, int replay) ...@@ -94,12 +94,9 @@ void gss_stat_oos_record_svc(int phase, int replay)
atomic_inc(&gss_stat_oos.oos_svc_pass[phase]); atomic_inc(&gss_stat_oos.oos_svc_pass[phase]);
} }
static int gss_proc_read_oos(char *page, char **start, off_t off, int count, static int gss_proc_oos_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int written; return seq_printf(m,
written = snprintf(page, count,
"seqwin: %u\n" "seqwin: %u\n"
"backwin: %u\n" "backwin: %u\n"
"client fall behind seqwin\n" "client fall behind seqwin\n"
...@@ -119,12 +116,11 @@ static int gss_proc_read_oos(char *page, char **start, off_t off, int count, ...@@ -119,12 +116,11 @@ static int gss_proc_read_oos(char *page, char **start, off_t off, int count,
atomic_read(&gss_stat_oos.oos_svc_replay[1]), atomic_read(&gss_stat_oos.oos_svc_replay[1]),
atomic_read(&gss_stat_oos.oos_svc_replay[2]), atomic_read(&gss_stat_oos.oos_svc_replay[2]),
atomic_read(&gss_stat_oos.oos_svc_pass[2])); atomic_read(&gss_stat_oos.oos_svc_pass[2]));
return written;
} }
LPROC_SEQ_FOPS_RO(gss_proc_oos);
static int gss_proc_write_secinit(struct file *file, const char *buffer, static int gss_proc_write_secinit(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, off_t *off)
{ {
int rc; int rc;
...@@ -134,12 +130,16 @@ static int gss_proc_write_secinit(struct file *file, const char *buffer, ...@@ -134,12 +130,16 @@ static int gss_proc_write_secinit(struct file *file, const char *buffer,
return rc; return rc;
} }
return ((int) count); return count;
} }
static const struct file_operations gss_proc_secinit = {
.write = gss_proc_write_secinit,
};
static struct lprocfs_vars gss_lprocfs_vars[] = { static struct lprocfs_vars gss_lprocfs_vars[] = {
{ "replays", gss_proc_read_oos, NULL }, { "replays", &gss_proc_oos_fops },
{ "init_channel", NULL, gss_proc_write_secinit, NULL, NULL, 0222 }, { "init_channel", &gss_proc_secinit, NULL, 0222 },
{ NULL } { NULL }
}; };
...@@ -150,14 +150,13 @@ static struct lprocfs_vars gss_lprocfs_vars[] = { ...@@ -150,14 +150,13 @@ static struct lprocfs_vars gss_lprocfs_vars[] = {
*/ */
static int gss_lk_debug_level = 1; static int gss_lk_debug_level = 1;
static int gss_lk_proc_read_dl(char *page, char **start, off_t off, static int gss_lk_proc_dl_seq_show(struct seq_file *m, void *v)
int count, int *eof, void *data)
{ {
return snprintf(page, count, "%u\n", gss_lk_debug_level); return seq_printf(m, "%u\n", gss_lk_debug_level);
} }
static int gss_lk_proc_write_dl(struct file *file, const char *buffer, static int gss_lk_proc_dl_seq_write(struct file *file, const char *buffer,
unsigned long count, void *data) size_t count, off_t *off)
{ {
int val, rc; int val, rc;
...@@ -171,9 +170,10 @@ static int gss_lk_proc_write_dl(struct file *file, const char *buffer, ...@@ -171,9 +170,10 @@ static int gss_lk_proc_write_dl(struct file *file, const char *buffer,
gss_lk_debug_level = val; gss_lk_debug_level = val;
return count; return count;
} }
LPROC_SEQ_FOPS(gss_lk_proc_dl);
static struct lprocfs_vars gss_lk_lprocfs_vars[] = { static struct lprocfs_vars gss_lk_lprocfs_vars[] = {
{ "debug_level", gss_lk_proc_read_dl, gss_lk_proc_write_dl, NULL }, { "debug_level", &gss_lk_proc_dl_fops },
{ NULL } { NULL }
}; };
......
...@@ -256,8 +256,7 @@ void sptlrpc_plain_fini(void); ...@@ -256,8 +256,7 @@ void sptlrpc_plain_fini(void);
/* sec_bulk.c */ /* sec_bulk.c */
int sptlrpc_enc_pool_init(void); int sptlrpc_enc_pool_init(void);
void sptlrpc_enc_pool_fini(void); void sptlrpc_enc_pool_fini(void);
int sptlrpc_proc_read_enc_pool(char *page, char **start, off_t off, int count, int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
int *eof, void *data);
/* sec_lproc.c */ /* sec_lproc.c */
int sptlrpc_lproc_init(void); int sptlrpc_lproc_init(void);
......
...@@ -130,14 +130,13 @@ static struct shrinker *pools_shrinker = NULL; ...@@ -130,14 +130,13 @@ static struct shrinker *pools_shrinker = NULL;
/* /*
* /proc/fs/lustre/sptlrpc/encrypt_page_pools * /proc/fs/lustre/sptlrpc/encrypt_page_pools
*/ */
int sptlrpc_proc_read_enc_pool(char *page, char **start, off_t off, int count, int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
int *eof, void *data)
{ {
int rc; int rc;
spin_lock(&page_pools.epp_lock); spin_lock(&page_pools.epp_lock);
rc = snprintf(page, count, rc = seq_printf(m,
"physical pages: %lu\n" "physical pages: %lu\n"
"pages per pool: %lu\n" "pages per pool: %lu\n"
"max pages: %lu\n" "max pages: %lu\n"
......
...@@ -168,8 +168,9 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) ...@@ -168,8 +168,9 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
} }
EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach); EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
static struct lprocfs_vars sptlrpc_lprocfs_vars[] = { static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
{ "encrypt_page_pools", sptlrpc_proc_read_enc_pool, NULL, NULL }, { "encrypt_page_pools", &sptlrpc_proc_enc_pool_fops },
{ NULL } { NULL }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment