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)
}
/* Generic debug formatting routines mainly for proc handler */
int cfs_hash_debug_header(char *str, int size);
int cfs_hash_debug_str(cfs_hash_t *hs, char *str, int size);
struct seq_file;
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.
......
......@@ -58,7 +58,6 @@ typedef module_t *cfs_param_module_t;
typedef struct proc_dir_entry cfs_param_dentry_t;
typedef struct poll_table_struct cfs_poll_table_t;
#define CFS_PARAM_MODULE THIS_MODULE
#define CFS_PDE(value) PDE(value)
#define cfs_file_private(file) (file->private_data)
#define cfs_dentry_data(dentry) (dentry->data)
#define cfs_proc_inode_pde(proc_inode) (proc_inode->pde)
......@@ -75,52 +74,6 @@ typedef struct poll_table_struct cfs_poll_table_t;
count, ppos))
#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 */
typedef struct cfs_params_file {
......@@ -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);
}
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_PDE(value) FAKE_PDE(value)
#define cfs_file_private(file) (file->param_private)
#define cfs_dentry_data(dentry) (dentry->param_data)
#define cfs_proc_inode(proc_inode) (proc_inode->param_inode)
......@@ -212,17 +159,6 @@ do { \
rc = 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 */
/* XXX: params_tree APIs */
......
......@@ -57,10 +57,8 @@ enum {
extern struct lu_context_key seq_thread_key;
/* Functions used internally in module. */
int seq_client_alloc_super(struct lu_client_seq *seq,
const struct lu_env *env);
/* Store API functions. */
int seq_store_init(struct lu_server_seq *seq,
const struct lu_env *env,
......
......@@ -60,9 +60,8 @@
* use.
*/
static int
seq_proc_write_common(struct file *file, const char *buffer,
unsigned long count, void *data,
struct lu_seq_range *range)
lprocfs_fid_write_common(const char *buffer, unsigned long count,
struct lu_seq_range *range)
{
struct lu_seq_range tmp;
int rc;
......@@ -79,151 +78,19 @@ seq_proc_write_common(struct file *file, const char *buffer,
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 */
static int
seq_client_proc_write_space(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t
lprocfs_fid_space_seq_write(struct file *file, const char *buffer,
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;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
rc = seq_proc_write_common(file, buffer, count,
data, &seq->lcs_space);
rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
if (rc == 0) {
CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
......@@ -236,42 +103,37 @@ seq_client_proc_write_space(struct file *file, const char *buffer,
}
static int
seq_client_proc_read_space(char *page, char **start, off_t off,
int count, int *eof, void *data)
lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)data;
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
rc = seq_proc_read_common(page, start, off, count, eof,
data, &seq->lcs_space);
rc = seq_printf(m, "["LPX64" - "LPX64"]:%x:%s\n", PRANGE(&seq->lcs_space));
mutex_unlock(&seq->lcs_mutex);
RETURN(rc);
}
static int
seq_client_proc_write_width(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t
lprocfs_fid_width_seq_write(struct file *file, const char *buffer,
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;
int rc, val;
ENTRY;
LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
rc = lprocfs_write_helper(buffer, count, &val);
if (rc) {
mutex_unlock(&seq->lcs_mutex);
if (rc)
RETURN(rc);
}
mutex_lock(&seq->lcs_mutex);
if (seq->lcs_type == LUSTRE_SEQ_DATA)
max = LUSTRE_DATA_SEQ_MAX_WIDTH;
else
......@@ -292,44 +154,41 @@ seq_client_proc_write_width(struct file *file, const char *buffer,
}
static int
seq_client_proc_read_width(char *page, char **start, off_t off,
int count, int *eof, void *data)
lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)data;
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc;
ENTRY;
LASSERT(seq != NULL);
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);
RETURN(rc);
}
static int
seq_client_proc_read_fid(char *page, char **start, off_t off,
int count, int *eof, void *data)
lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)data;
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
int rc;
ENTRY;
LASSERT(seq != NULL);
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);
RETURN(rc);
}
static int
seq_client_proc_read_server(char *page, char **start, off_t off,
int count, int *eof, void *data)
lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
{
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;
int rc;
ENTRY;
......@@ -338,23 +197,26 @@ seq_client_proc_read_server(char *page, char **start, off_t off,
if (seq->lcs_exp != NULL) {
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 {
rc = snprintf(page, count, "%s\n", seq->lcs_srv->lss_name);
rc = seq_printf(m, "%s\n", seq->lcs_srv->lss_name);
}
RETURN(rc);
}
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 },
{ NULL }};
};
LPROC_SEQ_FOPS(lprocfs_fid_space);
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[] = {
{ "space", seq_client_proc_read_space, seq_client_proc_write_space, NULL },
{ "width", seq_client_proc_read_width, seq_client_proc_write_width, NULL },
{ "server", seq_client_proc_read_server, NULL, NULL },
{ "fid", seq_client_proc_read_fid, NULL, NULL },
{ NULL }};
{ "space", &lprocfs_fid_space_fops },
{ "width", &lprocfs_fid_width_fops },
{ "server", &lprocfs_fid_server_fops },
{ "fid", &lprocfs_fid_fid_fops },
{ NULL }
};
#endif
......@@ -58,12 +58,10 @@
#ifdef LPROCFS
static int
fld_proc_read_targets(char *page, char **start, off_t off,
int count, int *eof, void *data)
fld_proc_targets_seq_show(struct seq_file *m, void *unused)
{
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;
int total = 0, rc;
ENTRY;
LASSERT(fld != NULL);
......@@ -71,41 +69,32 @@ fld_proc_read_targets(char *page, char **start, off_t off,
spin_lock(&fld->lcf_lock);
list_for_each_entry(target,
&fld->lcf_targets, ft_chain)
{
rc = snprintf(page, count, "%s\n",
fld_target_name(target));
page += rc;
count -= rc;
total += rc;
if (count == 0)
break;
}
seq_printf(m, "%s\n", fld_target_name(target));
spin_unlock(&fld->lcf_lock);
RETURN(total);
RETURN(0);
}
static int
fld_proc_read_hash(char *page, char **start, off_t off,
int count, int *eof, void *data)
fld_proc_hash_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)data;
int rc;
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
ENTRY;
LASSERT(fld != NULL);
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);
RETURN(rc);
RETURN(0);
}
static int
fld_proc_write_hash(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t
fld_proc_hash_seq_write(struct file *file, const char *buffer,
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;
int i;
ENTRY;
......@@ -134,11 +123,11 @@ fld_proc_write_hash(struct file *file, const char *buffer,
RETURN(count);
}
static int
fld_proc_write_cache_flush(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t
fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
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;
LASSERT(fld != NULL);
......@@ -150,6 +139,25 @@ fld_proc_write_cache_flush(struct file *file, const char *buffer,
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 lu_env fsp_env;
struct dt_it *fsp_it;
......@@ -265,16 +273,14 @@ struct seq_operations fldb_sops = {
static int fldb_seq_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *dp = PDE(inode);
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;
const struct dt_it_ops *iops;
struct fld_seq_param *param = NULL;
int env_init = 0;
int rc;
LPROCFS_ENTRY_AND_CHECK(dp);
rc = seq_open(file, &fldb_sops);
if (rc)
GOTO(out, rc);
......@@ -311,7 +317,6 @@ static int fldb_seq_open(struct inode *inode, struct file *file)
lu_env_fini(&param->fsp_env);
if (param != NULL)
OBD_FREE_PTR(param);
LPROCFS_EXIT();
}
return rc;
}
......@@ -349,10 +354,13 @@ static int fldb_seq_release(struct inode *inode, struct file *file)
struct lprocfs_vars fld_server_proc_list[] = {
{ NULL }};
LPROC_SEQ_FOPS_RO(fld_proc_targets);
LPROC_SEQ_FOPS(fld_proc_hash);
struct lprocfs_vars fld_client_proc_list[] = {
{ "targets", fld_proc_read_targets, NULL, NULL },
{ "hash", fld_proc_read_hash, fld_proc_write_hash, NULL },
{ "cache_flush", NULL, fld_proc_write_cache_flush, NULL },
{ "targets", &fld_proc_targets_fops },
{ "hash", &fld_proc_hash_fops },
{ "cache_flush", &fld_proc_cache_flush_fops },
{ NULL }};
struct file_operations fld_proc_seq_fops = {
......
......@@ -2598,8 +2598,6 @@ struct cache_stats {
/** These are not exported so far */
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"
......@@ -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
* 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
......
......@@ -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
* 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.
......
......@@ -545,6 +545,9 @@ struct ldlm_namespace {
/** Client side original connect flags supported by server. */
__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
* the node.
......
......@@ -1060,6 +1060,7 @@ struct obd_device {
struct lprocfs_stats *md_stats;
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_svc_procroot;
struct lprocfs_stats *obd_svc_stats;
......
......@@ -199,41 +199,40 @@ enum ldlm_policy_res {
typedef enum ldlm_policy_res ldlm_policy_res_t;
#define LDLM_POOL_PROC_READER(var, type) \
static int lprocfs_rd_##var(char *page, char **start, off_t off, \
int count, int *eof, void *data) \
{ \
struct ldlm_pool *pl = data; \
type tmp; \
#define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \
static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \
{ \
struct ldlm_pool *pl = m->private; \
type tmp; \
\
spin_lock(&pl->pl_lock); \
tmp = pl->pl_##var; \
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 */
#define LDLM_POOL_PROC_WRITER(var, type) \
int lprocfs_wr_##var(struct file *file, const char *buffer, \
unsigned long count, void *data) \
{ \
struct ldlm_pool *pl = data; \
type tmp; \
int rc; \
int lprocfs_wr_##var(struct file *file, const char *buffer, \
unsigned long count, void *data) \
{ \
struct ldlm_pool *pl = data; \
type tmp; \
int rc; \
\
rc = lprocfs_wr_uint(file, buffer, count, &tmp); \
if (rc < 0) { \
if (rc < 0) { \
CERROR("Can't parse user input, rc = %d\n", rc); \
return rc; \
} \
return rc; \
} \
\
spin_lock(&pl->pl_lock); \
pl->pl_##var = tmp; \
spin_unlock(&pl->pl_lock); \
\
return rc; \
} \
return rc; \
} \
struct __##var##__dummy_write {;} /* semicolon catcher */
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)
}
EXPORT_SYMBOL(ldlm_pool_setup);
static int lprocfs_rd_pool_state(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
{
int granted, grant_rate, cancel_rate, grant_step;
int nr = 0, grant_speed, grant_plan, lvf;
struct ldlm_pool *pl = data;
int grant_speed, grant_plan, lvf;
struct ldlm_pool *pl = m->private;
__u64 slv, clv;
__u32 limit;
......@@ -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);
spin_unlock(&pl->pl_lock);
nr += snprintf(page + nr, count - nr, "LDLM pool state (%s):\n",
pl->pl_name);
nr += snprintf(page + nr, count - nr, " SLV: "LPU64"\n", slv);
nr += snprintf(page + nr, count - nr, " CLV: "LPU64"\n", clv);
nr += snprintf(page + nr, count - nr, " LVF: %d\n", lvf);
seq_printf(m, "LDLM pool state (%s):\n"
" SLV: "LPU64"\n"
" CLV: "LPU64"\n"
" LVF: %d\n",
pl->pl_name, slv, clv, lvf);
if (ns_is_server(ldlm_pl2ns(pl))) {
nr += snprintf(page + nr, count - nr, " GSP: %d%%\n",
grant_step);
nr += snprintf(page + nr, count - nr, " GP: %d\n",
grant_plan);
seq_printf(m, " GSP: %d%%\n"
" GP: %d\n",
grant_step, grant_plan);
}
nr += snprintf(page + nr, count - nr, " GR: %d\n",
grant_rate);
nr += snprintf(page + nr, count - nr, " CR: %d\n",
cancel_rate);
nr += snprintf(page + nr, count - nr, " GS: %d\n",
grant_speed);
nr += snprintf(page + nr, count - nr, " G: %d\n",
granted);
nr += snprintf(page + nr, count - nr, " L: %d\n",
limit);
return nr;
seq_printf(m, " GR: %d\n" " CR: %d\n" " GS: %d\n"
" G: %d\n" " L: %d\n",
grant_rate, cancel_rate, grant_speed,
granted, limit);
return 0;
}
LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
static int lprocfs_rd_grant_speed(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
{
struct ldlm_pool *pl = data;
struct ldlm_pool *pl = m->private;
int grant_speed;
spin_lock(&pl->pl_lock);
......@@ -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) -
atomic_read(&pl->pl_cancel_rate);
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(recalc_period, int);
LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int);
LPROC_SEQ_FOPS_RO(lprocfs_grant_plan);
LDLM_POOL_PROC_READER_SEQ_SHOW(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)
{
......@@ -723,8 +740,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
if (!var_name)
RETURN(-ENOMEM);
parent_ns_proc = lprocfs_srch(ldlm_ns_proc_dir,
ldlm_ns_name(ns));
parent_ns_proc = ns->ns_proc_dir_entry;
if (parent_ns_proc == NULL) {
CERROR("%s: proc entry is not initialized\n",
ldlm_ns_name(ns));
......@@ -742,58 +758,20 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
memset(pool_vars, 0, sizeof(pool_vars));
pool_vars[0].name = var_name;
snprintf(var_name, MAX_STRING_SIZE, "server_lock_volume");
pool_vars[0].data = &pl->pl_server_lock_volume;
pool_vars[0].read_fptr = lprocfs_rd_u64;
lprocfs_add_vars(pl->pl_proc_dir, pool_vars, 0);
snprintf(var_name, MAX_STRING_SIZE, "limit");
pool_vars[0].data = &pl->pl_limit;
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, "granted");
pool_vars[0].data = &pl->pl_granted;
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_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);
LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume,
&ldlm_pool_u64_fops);
LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops);
LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops);
LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops);
LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate,
&ldlm_pool_atomic_fops);
LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate,
&ldlm_pool_atomic_fops);
LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops);
LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops);
LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor,
&ldlm_pool_rw_atomic_fops);
LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops);
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
......
......@@ -68,25 +68,27 @@ extern unsigned int ldlm_cancel_unused_locks_before_replay;
unsigned int ldlm_dump_granted_max = 256;
#ifdef LPROCFS
static int ldlm_proc_dump_ns(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lprocfs_wr_dump_ns(struct file *file, const char *buffer,
size_t count, loff_t *off)
{
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
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 rc;
struct lprocfs_vars list[] = {
{ "dump_namespaces", NULL, ldlm_proc_dump_ns, NULL },
{ "dump_granted_max",
lprocfs_rd_uint, lprocfs_wr_uint,
&ldlm_dump_granted_max, NULL },
{ "cancel_unused_locks_before_replay",
lprocfs_rd_uint, lprocfs_wr_uint,
&ldlm_cancel_unused_locks_before_replay, NULL },
{ "dump_namespaces", &ldlm_dump_ns_fops, 0, 0222 },
{ "dump_granted_max", &ldlm_rw_uint_fops,
&ldlm_dump_granted_max },
{ "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops,
&ldlm_cancel_unused_locks_before_replay },
{ NULL }};
ENTRY;
LASSERT(ldlm_ns_proc_dir == NULL);
......@@ -143,10 +145,9 @@ void ldlm_proc_cleanup(void)
lprocfs_remove(&ldlm_type_proc_dir);
}
static int lprocfs_rd_ns_resources(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
{
struct ldlm_namespace *ns = data;
struct ldlm_namespace *ns = m->private;
__u64 res = 0;
cfs_hash_bd_t bd;
int i;
......@@ -154,35 +155,35 @@ static int lprocfs_rd_ns_resources(char *page, char **start, off_t off,
/* result is not strictly consistant */
cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
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,
int count, int *eof, void *data)
static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
{
struct ldlm_namespace *ns = data;
struct ldlm_namespace *ns = m->private;
__u64 locks;
locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
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,
int count, int *eof, void *data)
static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
{
struct ldlm_namespace *ns = data;
struct ldlm_namespace *ns = m->private;
__u32 *nr = &ns->ns_max_unused;
if (ns_connect_lru_resize(ns))
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,
unsigned long count, void *data)
static ssize_t lprocfs_lru_size_seq_write(struct file *file, const char *buffer,
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;
unsigned long tmp;
int lru_resize;
......@@ -265,20 +266,20 @@ static int lprocfs_wr_lru_size(struct file *file, const char *buffer,
return count;
}
LPROC_SEQ_FOPS(lprocfs_lru_size);
static int lprocfs_rd_elc(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
{
struct ldlm_namespace *ns = data;
struct ldlm_namespace *ns = m->private;
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,
unsigned long count, void *data)
static ssize_t lprocfs_elc_seq_write(struct file *file, const char *buffer,
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;
int rc;
......@@ -292,31 +293,46 @@ static int lprocfs_wr_elc(struct file *file, const char *buffer,
ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
return count;
}
LPROC_SEQ_FOPS(lprocfs_elc);
void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
{
struct proc_dir_entry *dir;
dir = lprocfs_srch(ldlm_ns_proc_dir, ldlm_ns_name(ns));
if (dir == NULL) {
if (ns->ns_proc_dir_entry == NULL)
CERROR("dlm namespace %s has no procfs dir?\n",
ldlm_ns_name(ns));
} else {
lprocfs_remove(&dir);
}
else
lprocfs_remove(&ns->ns_proc_dir_entry);
if (ns->ns_stats != NULL)
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)
{
struct lprocfs_vars lock_vars[2];
char lock_name[MAX_STRING_SIZE + 1];
proc_dir_entry_t *ns_pde;
LASSERT(ns != 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);
if (ns->ns_stats == NULL)
return -ENOMEM;
......@@ -329,86 +345,29 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
memset(lock_vars, 0, sizeof(lock_vars));
lock_vars[0].name = lock_name;
snprintf(lock_name, MAX_STRING_SIZE, "%s/resource_count",
ldlm_ns_name(ns));
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);
LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops);
LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops);
if (ns_is_client(ns)) {
snprintf(lock_name, MAX_STRING_SIZE, "%s/lock_unused_count",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_nr_unused;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
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);
LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused,
&ldlm_uint_fops);
LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops);
LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age,
&ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops);
} else {
snprintf(lock_name, MAX_STRING_SIZE, "%s/ctime_age_limit",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_ctime_age_limit;
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/lock_timeouts",
ldlm_ns_name(ns));
lock_vars[0].data = &ns->ns_timeouts;
lock_vars[0].read_fptr = lprocfs_rd_uint;
lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
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);
LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit,
&ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts,
&ldlm_uint_fops);
LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size,
&ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time,
&ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks,
&ldlm_rw_uint_fops);
LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast,
&ldlm_rw_uint_fops);
}
return 0;
}
......
......@@ -108,6 +108,7 @@
*/
#include <linux/libcfs/libcfs.h>
#include <linux/seq_file.h>
#if CFS_HASH_DEBUG_LEVEL >= CFS_HASH_DEBUG_1
static unsigned int warn_on_depth = 8;
......@@ -2027,9 +2028,9 @@ void cfs_hash_rehash_key(cfs_hash_t *hs, const void *old_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,
"name", "cur", "min", "max", "theta", "t-min", "t-max",
"flags", "rehash", "count", "maxdep", "maxdepb",
......@@ -2061,38 +2062,28 @@ cfs_hash_full_nbkt(cfs_hash_t *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 maxdep = -1;
int maxdepb = -1;
int total = 0;
int c = 0;
int theta;
int i;
if (str == NULL || size == 0)
return 0;
cfs_hash_lock(hs, 0);
theta = __cfs_hash_theta(hs);
c += snprintf(str + c, size - c, "%-*s ",
CFS_HASH_BIGNAME_LEN, hs->hs_name);
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_cur_bits);
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_min_bits);
c += snprintf(str + c, size - c, "%5d ", 1 << hs->hs_max_bits);
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 ",
seq_printf(m, "%-*s %5d %5d %5d %d.%03d %d.%03d %d.%03d 0x%02x %6d ",
CFS_HASH_BIGNAME_LEN, hs->hs_name,
1 << hs->hs_cur_bits, 1 << hs->hs_min_bits,
1 << hs->hs_max_bits,
__cfs_hash_theta_int(theta), __cfs_hash_theta_frac(theta),
__cfs_hash_theta_int(hs->hs_min_theta),
__cfs_hash_theta_frac(hs->hs_min_theta));
c += snprintf(str + c, size - c, "%d.%03d ",
__cfs_hash_theta_frac(hs->hs_min_theta),
__cfs_hash_theta_int(hs->hs_max_theta),
__cfs_hash_theta_frac(hs->hs_max_theta));
c += snprintf(str + c, size - c, " 0x%02x ", hs->hs_flags);
c += snprintf(str + c, size - c, "%6d ", hs->hs_rehash_count);
__cfs_hash_theta_frac(hs->hs_max_theta),
hs->hs_flags, hs->hs_rehash_count);
/*
* 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)
cfs_hash_bd_unlock(hs, &bd, 0);
}
c += snprintf(str + c, size - c, "%7d ", total);
c += snprintf(str + c, size - c, "%7d ", maxdep);
c += snprintf(str + c, size - c, "%7d ", maxdepb);
seq_printf(m, "%7d %7d %7d ", total, maxdep, maxdepb);
for (i = 0; i < 8; i++)
c += snprintf(str + c, size - c, "%d%c", dist[i],
(i == 7) ? '\n' : '/');
seq_printf(m, "%d%c", dist[i], (i == 7) ? '\n' : '/');
cfs_hash_unlock(hs, 0);
return c;
return 0;
}
EXPORT_SYMBOL(cfs_hash_debug_str);
......@@ -525,8 +525,7 @@ static struct seq_operations vvp_pgcache_ops = {
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 = dp->data;
struct ll_sb_info *sbi = PDE_DATA(inode);
struct seq_file *seq;
int result;
......
......@@ -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,
int activate)
{
struct lmv_tgt_desc *tgt;
struct lmv_tgt_desc *uninitialized_var(tgt);
struct obd_device *obd;
int i;
int rc = 0;
......@@ -230,12 +230,17 @@ static int lmv_connect(const struct lu_env *env,
if (data)
lmv->conn_data = *data;
lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
NULL, 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;
if (obd->obd_proc_private != NULL) {
lmv_proc_dir = obd->obd_proc_private;
} else {
lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
NULL, 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,
if (data->ocd_connect_flags & OBD_CONNECT_REAL)
rc = lmv_check_connect(obd);
if (rc) {
if (lmv_proc_dir)
lprocfs_remove(&lmv_proc_dir);
if (rc && lmv_proc_dir) {
lprocfs_remove(&lmv_proc_dir);
obd->obd_proc_private = NULL;
}
RETURN(rc);
......@@ -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,
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) {
struct proc_dir_entry *mdc_symlink;
......@@ -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,
mdc_obd->obd_name);
lprocfs_remove(&lmv_proc_dir);
lmv_proc_dir = NULL;
obd->obd_proc_private = NULL;
}
}
RETURN(0);
......@@ -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;
}
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
if (lmv_proc_dir) {
struct proc_dir_entry *mdc_symlink;
lmv_proc_dir = obd->obd_proc_private;
if (lmv_proc_dir)
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);
if (rc)
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)
static int lmv_disconnect(struct obd_export *exp)
{
struct obd_device *obd = class_exp2obd(exp);
struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
int rc;
int i;
......@@ -687,13 +682,11 @@ static int lmv_disconnect(struct obd_export *exp)
lmv_disconnect_mdc(obd, lmv->tgts[i]);
}
lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
if (lmv_proc_dir) {
lprocfs_remove(&lmv_proc_dir);
} else {
if (obd->obd_proc_private)
lprocfs_remove((proc_dir_entry_t **)&obd->obd_proc_private);
else
CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
obd->obd_type->typ_name, obd->obd_name);
}
out_local:
/*
......
......@@ -46,18 +46,16 @@
static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
#else
static int lmv_rd_numobd(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lmv_numobd_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
*eof = 1;
return snprintf(page, count, "%u\n", desc->ld_tgt_count);
return seq_printf(m, "%u\n", desc->ld_tgt_count);
}
LPROC_SEQ_FOPS_RO(lmv_numobd);
static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR",
......@@ -82,26 +80,22 @@ static const char *placement_policy2name(placement_policy_t placement)
return placement_name[placement];
}
static int lmv_rd_placement(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lmv_placement_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_obd *lmv;
LASSERT(dev != NULL);
lmv = &dev->u.lmv;
*eof = 1;
return snprintf(page, count, "%s\n",
placement_policy2name(lmv->lmv_placement));
return seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
}
#define MAX_POLICY_STRING_SIZE 64
static int lmv_wr_placement(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lmv_placement_seq_write(struct file *file, const char *buffer,
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];
int len = count;
placement_policy_t policy;
......@@ -131,30 +125,29 @@ static int lmv_wr_placement(struct file *file, const char *buffer,
}
return count;
}
LPROC_SEQ_FOPS(lmv_placement);
static int lmv_rd_activeobd(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
*eof = 1;
return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
return seq_printf(m, "%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,
int *eof, void *data)
static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*) data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lmv_obd *lmv;
LASSERT(dev != NULL);
lmv = &dev->u.lmv;
*eof = 1;
return snprintf(page, count, "%s\n", lmv->desc.ld_uuid.uuid);
return seq_printf(m, "%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)
{
......@@ -195,7 +188,6 @@ struct seq_operations lmv_tgt_sops = {
static int lmv_target_seq_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq;
int rc;
......@@ -204,22 +196,26 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
seq->private = dp->data;
seq->private = PDE_DATA(inode);
return 0;
}
LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
{ "numobd", lmv_rd_numobd, 0, 0 },
{ "placement", lmv_rd_placement, lmv_wr_placement, 0 },
{ "activeobd", lmv_rd_activeobd, 0, 0 },
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "desc_uuid", lmv_rd_desc_uuid, 0, 0 },
{ "numobd", &lmv_numobd_fops, 0, 0 },
{ "placement", &lmv_placement_fops, 0, 0 },
{ "activeobd", &lmv_activeobd_fops, 0, 0 },
{ "uuid", &lmv_uuid_fops, 0, 0 },
{ "desc_uuid", &lmv_desc_uuid_fops, 0, 0 },
{ 0 }
};
LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ "num_refs", &lmv_numrefs_fops, 0, 0 },
{ 0 }
};
......
......@@ -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,
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) {
struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
proc_dir_entry_t *osc_symlink;
......@@ -211,6 +211,7 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
obd->obd_type->typ_name, obd->obd_name,
osc_obd->obd_name);
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)
tgt->ltd_exp->exp_obd->obd_inactive = 1;
}
lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
if (lov_proc_dir) {
proc_dir_entry_t *osc_symlink;
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);
}
}
lov_proc_dir = obd->obd_proc_private;
if (lov_proc_dir)
lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
if (osc_obd) {
/* Pass it on to our clients.
......
......@@ -284,7 +284,7 @@ static int pool_proc_open(struct inode *inode, struct file *file)
rc = seq_open(file, &pool_proc_ops);
if (!rc) {
struct seq_file *s = file->private_data;
s->private = PROC_I(inode)->pde->data;
s->private = PDE_DATA(inode);
}
return rc;
}
......@@ -468,8 +468,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
/* get ref for /proc file */
lov_pool_getref(new_pool);
new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
poolname, NULL, NULL,
new_pool,
poolname, new_pool,
&pool_proc_operations);
if (IS_ERR(new_pool->pool_proc_entry)) {
CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
......
......@@ -43,22 +43,20 @@
#include "lov_internal.h"
#ifdef LPROCFS
static int lov_rd_stripesize(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lov_stripesize_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device *)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_size);
return seq_printf(m, LPU64"\n", desc->ld_default_stripe_size);
}
static int lov_wr_stripesize(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lov_stripesize_seq_write(struct file *file, const char *buffer,
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;
__u64 val;
int rc;
......@@ -73,23 +71,22 @@ static int lov_wr_stripesize(struct file *file, const char *buffer,
desc->ld_default_stripe_size = val;
return count;
}
LPROC_SEQ_FOPS(lov_stripesize);
static int lov_rd_stripeoffset(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lov_stripeoffset_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device *)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, LPU64"\n", desc->ld_default_stripe_offset);
return seq_printf(m, LPU64"\n", desc->ld_default_stripe_offset);
}
static int lov_wr_stripeoffset(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lov_stripeoffset_seq_write(struct file *file, const char *buffer,
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;
__u64 val;
int rc;
......@@ -103,23 +100,22 @@ static int lov_wr_stripeoffset(struct file *file, const char *buffer,
desc->ld_default_stripe_offset = val;
return count;
}
LPROC_SEQ_FOPS(lov_stripeoffset);
static int lov_rd_stripetype(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lov_stripetype_seq_show(struct seq_file *m, void *v)
{
struct obd_device* dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, "%u\n", desc->ld_pattern);
return seq_printf(m, "%u\n", desc->ld_pattern);
}
static int lov_wr_stripetype(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lov_stripetype_seq_write(struct file *file, const char *buffer,
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;
int val, rc;
......@@ -133,24 +129,23 @@ static int lov_wr_stripetype(struct file *file, const char *buffer,
desc->ld_pattern = val;
return count;
}
LPROC_SEQ_FOPS(lov_stripetype);
static int lov_rd_stripecount(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lov_stripecount_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device *)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, "%d\n",
return seq_printf(m, "%d\n",
(__s16)(desc->ld_default_stripe_count + 1) - 1);
}
static int lov_wr_stripecount(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t lov_stripecount_seq_write(struct file *file, const char *buffer,
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;
int val, rc;
......@@ -164,43 +159,40 @@ static int lov_wr_stripecount(struct file *file, const char *buffer,
desc->ld_default_stripe_count = val;
return count;
}
LPROC_SEQ_FOPS(lov_stripecount);
static int lov_rd_numobd(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int lov_numobd_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, "%u\n", desc->ld_tgt_count);
return seq_printf(m, "%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,
int *eof, void *data)
static int lov_activeobd_seq_show(struct seq_file *m, void *v)
{
struct obd_device* dev = (struct obd_device*)data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_desc *desc;
LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
*eof = 1;
return snprintf(page, count, "%u\n", desc->ld_active_tgt_count);
return seq_printf(m, "%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,
int *eof, void *data)
static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = (struct obd_device*) data;
struct obd_device *dev = (struct obd_device *)m->private;
struct lov_obd *lov;
LASSERT(dev != NULL);
lov = &dev->u.lov;
*eof = 1;
return snprintf(page, count, "%s\n", lov->desc.ld_uuid.uuid);
return seq_printf(m, "%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)
{
......@@ -248,43 +240,49 @@ struct seq_operations lov_tgt_sops = {
static int lov_target_seq_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq;
int rc;
LPROCFS_ENTRY_AND_CHECK(dp);
rc = seq_open(file, &lov_tgt_sops);
if (rc) {
LPROCFS_EXIT();
if (rc)
return rc;
}
seq = file->private_data;
seq->private = dp->data;
seq->private = PDE_DATA(inode);
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[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "stripesize", lov_rd_stripesize, lov_wr_stripesize, 0 },
{ "stripeoffset", lov_rd_stripeoffset, lov_wr_stripeoffset, 0 },
{ "stripecount", lov_rd_stripecount, lov_wr_stripecount, 0 },
{ "stripetype", lov_rd_stripetype, lov_wr_stripetype, 0 },
{ "numobd", lov_rd_numobd, 0, 0 },
{ "activeobd", lov_rd_activeobd, 0, 0 },
{ "filestotal", lprocfs_rd_filestotal, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 },
{ "uuid", &lov_uuid_fops, 0, 0 },
{ "stripesize", &lov_stripesize_fops, 0 },
{ "stripeoffset", &lov_stripeoffset_fops, 0 },
{ "stripecount", &lov_stripecount_fops, 0 },
{ "stripetype", &lov_stripetype_fops, 0 },
{ "numobd", &lov_numobd_fops, 0, 0 },
{ "activeobd", &lov_activeobd_fops, 0, 0 },
{ "filestotal", &lov_filestotal_fops, 0, 0 },
{ "filesfree", &lov_filesfree_fops, 0, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/
{ "blocksize", lprocfs_rd_blksize, 0, 0 },
{ "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
{ "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
{ "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
{ "desc_uuid", lov_rd_desc_uuid, 0, 0 },
{ "blocksize", &lov_blksize_fops, 0, 0 },
{ "kbytestotal", &lov_kbytestotal_fops, 0, 0 },
{ "kbytesfree", &lov_kbytesfree_fops, 0, 0 },
{ "kbytesavail", &lov_kbytesavail_fops, 0, 0 },
{ "desc_uuid", &lov_desc_uuid_fops, 0, 0 },
{ 0 }
};
LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs);
static struct lprocfs_vars lprocfs_lov_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ "num_refs", &lov_numrefs_fops, 0, 0 },
{ 0 }
};
......
......@@ -42,23 +42,24 @@
#ifdef LPROCFS
static int mdc_rd_max_rpcs_in_flight(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
{
struct obd_device *dev = data;
struct obd_device *dev = m->private;
struct client_obd *cli = &dev->u.cli;
int rc;
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);
return rc;
}
static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
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;
int val, rc;
......@@ -75,12 +76,13 @@ static int mdc_wr_max_rpcs_in_flight(struct file *file, const char *buffer,
return count;
}
LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
/* temporary for testing */
static int mdc_wr_kuc(struct file *file, const char *buffer,
unsigned long count, void *data)
static ssize_t mdc_wr_kuc(struct file *file, const char *buffer,
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 hsm_action_list *hal;
struct hsm_action_item *hai;
......@@ -137,41 +139,67 @@ static int mdc_wr_kuc(struct file *file, const char *buffer,
RETURN(rc);
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[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "ping", 0, lprocfs_wr_ping, 0, 0, 0222 },
{ "connect_flags", lprocfs_rd_connect_flags, 0, 0 },
{ "blocksize", lprocfs_rd_blksize, 0, 0 },
{ "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
{ "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
{ "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 },
{ "filestotal", lprocfs_rd_filestotal, 0, 0 },
{ "filesfree", lprocfs_rd_filesfree, 0, 0 },
{ "uuid", &mdc_uuid_fops, 0, 0 },
{ "ping", &mdc_ping_fops, 0, 0222 },
{ "connect_flags", &mdc_connect_flags_fops, 0, 0 },
{ "blocksize", &mdc_blksize_fops, 0, 0 },
{ "kbytestotal", &mdc_kbytestotal_fops, 0, 0 },
{ "kbytesfree", &mdc_kbytesfree_fops, 0, 0 },
{ "kbytesavail", &mdc_kbytesavail_fops, 0, 0 },
{ "filestotal", &mdc_filestotal_fops, 0, 0 },
{ "filesfree", &mdc_filesfree_fops, 0, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, 0, 0 },*/
{ "mds_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
{ "mds_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 },
{ "mds_server_uuid", &mdc_server_uuid_fops, 0, 0 },
{ "mds_conn_uuid", &mdc_conn_uuid_fops, 0, 0 },
/*
* 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
* when CMD is enabled, and dir pages are managed in MDC layer.
* Remember to enable proc write function.
*/
{ "max_pages_per_rpc", lprocfs_obd_rd_max_pages_per_rpc,
/* lprocfs_obd_wr_max_pages_per_rpc */0, 0 },
{ "max_rpcs_in_flight", mdc_rd_max_rpcs_in_flight,
mdc_wr_max_rpcs_in_flight, 0 },
{ "timeouts", lprocfs_rd_timeouts, 0, 0 },
{ "import", lprocfs_rd_import, lprocfs_wr_import, 0 },
{ "state", lprocfs_rd_state, 0, 0 },
{ "hsm_nl", 0, mdc_wr_kuc, 0, 0, 0200 },
{ "pinger_recov", lprocfs_rd_pinger_recov,
lprocfs_wr_pinger_recov, 0, 0 },
{ "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, 0, 0 },
{ "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, 0, 0 },
{ "timeouts", &mdc_timeouts_fops, 0, 0 },
{ "import", &mdc_import_fops, 0 },
{ "state", &mdc_state_fops, 0, 0 },
{ "hsm_nl", &mdc_kuc_fops, 0, 0200 },
{ "pinger_recov", &mdc_pinger_recov_fops, 0, 0 },
{ 0 }
};
LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs);
static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ "num_refs", &mdc_numrefs_fops, 0, 0 },
{ 0 }
};
......
......@@ -43,20 +43,36 @@
#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[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "ping", 0, lprocfs_wr_ping, 0, 0, 0222 },
{ "connect_flags", lprocfs_rd_connect_flags, 0, 0 },
{ "mgs_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
{ "mgs_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 },
{ "import", lprocfs_rd_import, 0, 0 },
{ "state", lprocfs_rd_state, 0, 0 },
{ "ir_state", lprocfs_mgc_rd_ir_state, 0, 0 },
{ "uuid", &mgc_uuid_fops, 0, 0 },
{ "ping", &mgc_ping_fops, 0, 0222 },
{ "connect_flags", &mgc_connect_flags_fops, 0, 0 },
{ "mgs_server_uuid", &mgc_server_uuid_fops, 0, 0 },
{ "mgs_conn_uuid", &mgc_conn_uuid_fops, 0, 0 },
{ "import", &mgc_import_fops, 0, 0 },
{ "state", &mgc_state_fops, 0, 0 },
{ "ir_state", &mgc_ir_state_fops, 0, 0 },
{ 0 }
};
LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs);
static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ "num_refs", &mgc_numrefs_fops, 0, 0 },
{ 0 }
};
......
......@@ -46,15 +46,13 @@
#ifdef LPROCFS
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off,
int count, int *eof, void *data);
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data);
#else
static void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
{
memset(lvars, 0, sizeof(*lvars));
}
static inline int lprocfs_mgc_rd_ir_state(char *page, char **start,
off_t off, int count, int *eof, void *data)
static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
{
return 0;
}
......
......@@ -409,32 +409,29 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
RETURN(rc);
}
int lprocfs_mgc_rd_ir_state(char *page, char **start, off_t off,
int count, int *eof, void *data)
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
struct obd_import *imp = obd->u.cli.cl_import;
struct obd_connect_data *ocd = &imp->imp_connect_data;
struct config_llog_data *cld;
int rc = 0;
ENTRY;
rc = snprintf(page, count, "imperative_recovery: %s\n",
seq_printf(m, "imperative_recovery: %s\n",
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);
list_for_each_entry(cld, &config_llog_list, cld_list_chain) {
if (cld->cld_recover == NULL)
continue;
rc += snprintf(page + rc, count - rc,
" - { client: %s, nidtbl_version: %u }\n",
seq_printf(m, " - { client: %s, nidtbl_version: %u }\n",
cld->cld_logname,
cld->cld_recover->cld_cfg.cfg_last_idx);
}
spin_unlock(&config_list_lock);
RETURN(rc);
RETURN(0);
}
/* reenqueue any lost locks */
......
......@@ -394,10 +394,8 @@ void cache_stats_init(struct cache_stats *cs, const char *name)
atomic_set(&cs->cs_stats[i], 0);
}
int cache_stats_print(const struct cache_stats *cs,
char *page, int count, int h)
int cache_stats_print(const struct cache_stats *cs, struct seq_file *m, int h)
{
int nob = 0;
int i;
/*
* lookup hit total cached create
......@@ -406,18 +404,16 @@ int cache_stats_print(const struct cache_stats *cs,
if (h) {
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++)
nob += snprintf(page + nob, count - nob,
"%8s", names[i]);
nob += snprintf(page + nob, count - nob, "\n");
seq_printf(m, "%8s", names[i]);
seq_printf(m, "\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++)
nob += snprintf(page + nob, count - nob, "%8u",
atomic_read(&cs->cs_stats[i]));
return nob;
seq_printf(m, "%8u", atomic_read(&cs->cs_stats[i]));
return 0;
}
/**
......@@ -462,9 +458,8 @@ static struct cache_stats cl_env_stats = {
* Outputs client site statistical counters into a buffer. Suitable for
* 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;
static const char *pstate[] = {
[CPS_CACHED] = "c",
......@@ -488,24 +483,22 @@ pages: ...... ...... ...... ...... ...... [...... ...... ...... ......]
locks: ...... ...... ...... ...... ...... [...... ...... ...... ...... ......]
env: ...... ...... ...... ...... ......
*/
nob = lu_site_stats_print(&site->cs_lu, page, count);
nob += cache_stats_print(&site->cs_pages, page + nob, count - nob, 1);
nob += snprintf(page + nob, count - nob, " [");
lu_site_stats_print(&site->cs_lu, m);
cache_stats_print(&site->cs_pages, m, 1);
seq_printf(m, " [");
for (i = 0; i < ARRAY_SIZE(site->cs_pages_state); ++i)
nob += snprintf(page + nob, count - nob, "%s: %u ",
pstate[i],
seq_printf(m, "%s: %u ", pstate[i],
atomic_read(&site->cs_pages_state[i]));
nob += snprintf(page + nob, count - nob, "]\n");
nob += cache_stats_print(&site->cs_locks, page + nob, count - nob, 0);
nob += snprintf(page + nob, count - nob, " [");
seq_printf(m, "]\n");
cache_stats_print(&site->cs_locks, m, 0);
seq_printf(m, " [");
for (i = 0; i < ARRAY_SIZE(site->cs_locks_state); ++i)
nob += snprintf(page + nob, count - nob, "%s: %u ",
lstate[i],
seq_printf(m, "%s: %u ", lstate[i],
atomic_read(&site->cs_locks_state[i]));
nob += snprintf(page + nob, count - nob, "]\n");
nob += cache_stats_print(&cl_env_stats, page + nob, count - nob, 0);
nob += snprintf(page + nob, count - nob, "\n");
return nob;
seq_printf(m, "]\n");
cache_stats_print(&cl_env_stats, m, 0);
seq_printf(m, "\n");
return 0;
}
EXPORT_SYMBOL(cl_site_stats_print);
......
......@@ -247,11 +247,9 @@ int class_unregister_type(const char *name)
RETURN(-EBUSY);
}
/* we do not use type->typ_procroot as for compatibility purposes
* other modules can share names (i.e. lod can use lov entry). so
* 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_procroot) {
lprocfs_remove(&type->typ_procroot);
}
if (type->typ_lu)
lu_device_type_fini(type->typ_lu);
......
......@@ -219,47 +219,26 @@ psdev_t obd_psdev = {
#ifdef LPROCFS
int obd_proc_read_version(char *page, char **start, off_t off, int count,
int *eof, void *data)
int obd_proc_version_seq_show(struct seq_file *m, void *v)
{
*eof = 1;
return snprintf(page, count, "lustre: %s\nkernel: %s\nbuild: %s\n",
return seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n",
LUSTRE_VERSION_STRING, "patchless_client",
BUILD_VERSION);
}
LPROC_SEQ_FOPS_RO(obd_proc_version);
int obd_proc_read_pinger(char *page, char **start, off_t off, int count,
int *eof, void *data)
int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
{
*eof = 1;
return snprintf(page, count, "%s\n",
"on"
);
return seq_printf(m, "%s\n", "on");
}
LPROC_SEQ_FOPS_RO(obd_proc_pinger);
/**
* 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)
static int obd_proc_health_seq_show(struct seq_file *m, void *v)
{
int rc = 0, i;
*eof = 1;
if (libcfs_catastrophe)
rc += snprintf(page + rc, count - rc, "LBUG\n");
seq_printf(m, "LBUG\n");
read_lock(&obd_dev_lock);
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,
read_unlock(&obd_dev_lock);
if (obd_health_check(NULL, obd)) {
rc += snprintf(page + rc, count - rc,
"device %s reported unhealthy\n",
obd->obd_name);
seq_printf(m, "device %s reported unhealthy\n",
obd->obd_name);
rc++;
}
class_decref(obd, __FUNCTION__, current);
read_lock(&obd_dev_lock);
......@@ -287,20 +266,20 @@ static int obd_proc_read_health(char *page, char **start, off_t off,
read_unlock(&obd_dev_lock);
if (rc == 0)
return snprintf(page, count, "healthy\n");
return seq_printf(m, "healthy\n");
rc += snprintf(page + rc, count - rc, "NOT HEALTHY\n");
return rc;
seq_printf(m, "NOT HEALTHY\n");
return 0;
}
LPROC_SEQ_FOPS_RO(obd_proc_health);
static int obd_proc_rd_jobid_var(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
{
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,
unsigned long count, void *data)
static ssize_t obd_proc_jobid_var_seq_write(struct file *file, const char *buffer,
size_t count, loff_t *off)
{
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL;
......@@ -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'));
return count;
}
LPROC_SEQ_FOPS(obd_proc_jobid_var);
/* Root for /proc/fs/lustre */
struct proc_dir_entry *proc_lustre_root = NULL;
EXPORT_SYMBOL(proc_lustre_root);
struct lprocfs_vars lprocfs_base[] = {
{ "version", obd_proc_read_version, NULL, NULL },
{ "pinger", obd_proc_read_pinger, NULL, NULL },
{ "health_check", obd_proc_read_health, NULL, NULL },
{ "jobid_var", obd_proc_rd_jobid_var,
obd_proc_wr_jobid_var, NULL },
{ "version", &obd_proc_version_fops },
{ "pinger", &obd_proc_pinger_fops },
{ "health_check", &obd_proc_health_fops },
{ "jobid_var", &obd_proc_jobid_var_fops },
{ 0 }
};
#else
......@@ -384,7 +363,6 @@ struct seq_operations obd_device_list_sops = {
static int obd_device_list_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq;
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)
return rc;
seq = file->private_data;
seq->private = dp->data;
seq->private = PDE_DATA(inode);
return 0;
}
......
......@@ -418,20 +418,14 @@ struct seq_operations lprocfs_jobstats_seq_sops = {
static int lprocfs_jobstats_seq_open(struct inode *inode, struct file *file)
{
struct proc_dir_entry *dp = PDE(inode);
struct seq_file *seq;
int rc;
if (LPROCFS_ENTRY_AND_CHECK(dp))
return -ENOENT;
rc = seq_open(file, &lprocfs_jobstats_seq_sops);
if (rc) {
LPROCFS_EXIT();
if (rc)
return rc;
}
seq = file->private_data;
seq->private = dp->data;
seq->private = PDE_DATA(inode);
return 0;
}
......@@ -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_last_cleanup = cfs_time_current_sec();
LPROCFS_WRITE_ENTRY();
entry = create_proc_entry("job_stats", 0644, obd->obd_proc_entry);
LPROCFS_WRITE_EXIT();
if (entry) {
entry->proc_fops = &lprocfs_jobstats_seq_fops;
entry->data = stats;
entry = proc_create_data("job_stats", 0644, obd->obd_proc_entry,
&lprocfs_jobstats_seq_fops, stats);
if (entry)
RETURN(0);
} else {
lprocfs_job_stats_fini(obd);
else
RETURN(-ENOMEM);
}
}
EXPORT_SYMBOL(lprocfs_job_stats_init);
int lprocfs_rd_job_interval(char *page, char **start, off_t off,
int count, int *eof, void *data)
int lprocfs_rd_job_interval(struct seq_file *m, void *data)
{
struct obd_device *obd = (struct obd_device *)data;
struct obd_job_stats *stats;
LASSERT(obd != NULL);
stats = &obd->u.obt.obt_jobstats;
*eof = 1;
return snprintf(page, count, "%d\n", stats->ojs_cleanup_interval);
return seq_printf(m, "%d\n", stats->ojs_cleanup_interval);
}
EXPORT_SYMBOL(lprocfs_rd_job_interval);
......
......@@ -2021,14 +2021,14 @@ static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
* Output site statistical counters into a buffer. Suitable for
* 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;
memset(&stats, 0, sizeof(stats));
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_total,
stats.lss_populated,
......
......@@ -1237,6 +1237,8 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
struct lustre_cfg *lcfg, void *data)
{
struct lprocfs_vars *var;
struct file fakefile;
struct seq_file fake_seqfile;
char *key, *sval;
int i, keylen, vallen;
int matched = 0, j = 0;
......@@ -1249,6 +1251,9 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
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
or lctl conf_param lustre-MDT0000.mdt.group_upcall=bar
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,
keylen == strlen(var->name)) {
matched++;
rc = -EROFS;
if (var->write_fptr) {
if (var->fops && var->fops->write) {
mm_segment_t oldfs;
oldfs = get_fs();
set_fs(KERNEL_DS);
rc = (var->write_fptr)(NULL, sval,
vallen, data);
rc = (var->fops->write)(&fakefile, sval,
vallen, NULL);
set_fs(oldfs);
}
break;
......
......@@ -37,13 +37,15 @@
#include <obd_class.h>
#ifdef LPROCFS
LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
{ "uuid", lprocfs_rd_uuid, 0, 0 },
{ "uuid", &echo_uuid_fops, 0, 0 },
{ 0 }
};
LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs);
static struct lprocfs_vars lprocfs_echo_module_vars[] = {
{ "num_refs", lprocfs_rd_numrefs, 0, 0 },
{ "num_refs", &echo_numrefs_fops, 0, 0 },
{ 0 }
};
......
......@@ -94,12 +94,9 @@ void gss_stat_oos_record_svc(int phase, int replay)
atomic_inc(&gss_stat_oos.oos_svc_pass[phase]);
}
static int gss_proc_read_oos(char *page, char **start, off_t off, int count,
int *eof, void *data)
static int gss_proc_oos_seq_show(struct seq_file *m, void *v)
{
int written;
written = snprintf(page, count,
return seq_printf(m,
"seqwin: %u\n"
"backwin: %u\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,
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_pass[2]));
return written;
}
LPROC_SEQ_FOPS_RO(gss_proc_oos);
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;
......@@ -134,12 +130,16 @@ static int gss_proc_write_secinit(struct file *file, const char *buffer,
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[] = {
{ "replays", gss_proc_read_oos, NULL },
{ "init_channel", NULL, gss_proc_write_secinit, NULL, NULL, 0222 },
{ "replays", &gss_proc_oos_fops },
{ "init_channel", &gss_proc_secinit, NULL, 0222 },
{ NULL }
};
......@@ -150,14 +150,13 @@ static struct lprocfs_vars gss_lprocfs_vars[] = {
*/
static int gss_lk_debug_level = 1;
static int gss_lk_proc_read_dl(char *page, char **start, off_t off,
int count, int *eof, void *data)
static int gss_lk_proc_dl_seq_show(struct seq_file *m, void *v)
{
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,
unsigned long count, void *data)
static int gss_lk_proc_dl_seq_write(struct file *file, const char *buffer,
size_t count, off_t *off)
{
int val, rc;
......@@ -171,9 +170,10 @@ static int gss_lk_proc_write_dl(struct file *file, const char *buffer,
gss_lk_debug_level = val;
return count;
}
LPROC_SEQ_FOPS(gss_lk_proc_dl);
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 }
};
......
......@@ -256,8 +256,7 @@ void sptlrpc_plain_fini(void);
/* sec_bulk.c */
int sptlrpc_enc_pool_init(void);
void sptlrpc_enc_pool_fini(void);
int sptlrpc_proc_read_enc_pool(char *page, char **start, off_t off, int count,
int *eof, void *data);
int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
/* sec_lproc.c */
int sptlrpc_lproc_init(void);
......
......@@ -130,14 +130,13 @@ static struct shrinker *pools_shrinker = NULL;
/*
* /proc/fs/lustre/sptlrpc/encrypt_page_pools
*/
int sptlrpc_proc_read_enc_pool(char *page, char **start, off_t off, int count,
int *eof, void *data)
int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v)
{
int rc;
spin_lock(&page_pools.epp_lock);
rc = snprintf(page, count,
rc = seq_printf(m,
"physical pages: %lu\n"
"pages per pool: %lu\n"
"max pages: %lu\n"
......
......@@ -168,8 +168,9 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
}
EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
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 }
};
......
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