* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
}
EXPORT_SYMBOL(lprocfs_seq_release);
-struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
- const char *name)
+static struct proc_dir_entry *__lprocfs_srch(struct proc_dir_entry *head,
+ const char *name)
{
struct proc_dir_entry *temp;
if (head == NULL)
return NULL;
- LPROCFS_ENTRY();
temp = head->subdir;
while (temp != NULL) {
if (strcmp(temp->name, name) == 0) {
- LPROCFS_EXIT();
return temp;
}
temp = temp->next;
}
- LPROCFS_EXIT();
return NULL;
}
+struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
+ const char *name)
+{
+ struct proc_dir_entry *temp;
+
+ LPROCFS_ENTRY();
+ temp = __lprocfs_srch(head, name);
+ LPROCFS_EXIT();
+ return temp;
+}
+
/* lprocfs API calls */
/* Function that emulates snprintf but also has the side effect of advancing
mode |= 0200;
if (fops)
mode = 0644;
+ LPROCFS_WRITE_ENTRY();
proc = create_proc_entry(name, mode, root);
if (!proc) {
CERROR("LprocFS: No memory to create /proc entry %s", name);
+ LPROCFS_WRITE_EXIT();
return ERR_PTR(-ENOMEM);
}
proc->read_proc = read_proc;
proc->data = data;
if (fops)
proc->proc_fops = fops;
+ LPROCFS_WRITE_EXIT();
return proc;
}
if (page == NULL)
return -ENOMEM;
- if (LPROCFS_ENTRY_AND_CHECK(dp))
- return -ENOENT;
+ if (LPROCFS_ENTRY_AND_CHECK(dp)) {
+ rc = -ENOENT;
+ goto out;
+ }
OBD_FAIL_TIMEOUT(OBD_FAIL_LPROC_REMOVE, 10);
if (dp->read_proc)
int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
void *data)
{
+ int rc = 0;
+
if (root == NULL || list == NULL)
return -EINVAL;
+ LPROCFS_WRITE_ENTRY();
while (list->name != NULL) {
struct proc_dir_entry *cur_root, *proc;
char *pathcopy, *cur, *next, pathbuf[64];
if (strlen(list->name) > sizeof(pathbuf) - 1) {
OBD_ALLOC(pathcopy, pathsize);
if (pathcopy == NULL)
- return -ENOMEM;
+ GOTO(out, rc = -ENOMEM);
} else {
pathcopy = pathbuf;
}
if (*cur =='\0') /* skip double/trailing "/" */
continue;
- proc = lprocfs_srch(cur_root, cur);
+ proc = __lprocfs_srch(cur_root, cur);
CDEBUG(D_OTHER, "cur_root=%s, cur=%s, next=%s, (%s)\n",
cur_root->name, cur, next,
(proc ? "exists" : "new"));
if (cur_root == NULL || proc == NULL) {
CERROR("LprocFS: No memory to create /proc entry %s",
list->name);
- return -ENOMEM;
+ GOTO(out, rc = -ENOMEM);
}
if (list->fops)
proc->data = (list->data ? list->data : data);
list++;
}
- return 0;
+out:
+ LPROCFS_WRITE_EXIT();
+ return rc;
}
void lprocfs_remove(struct proc_dir_entry **rooth)
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
*eof = 1;
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
__u32 blk_size = osfs.os_bsize >> 10;
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
*eof = 1;
int *eof, void *data)
{
struct obd_statfs osfs;
- int rc = obd_statfs(data, &osfs, cfs_time_current_64() - CFS_HZ,
+ int rc = obd_statfs(data, &osfs,
+ cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
*eof = 1;
flag2str(deactive);
flag2str(replayable);
flag2str(pingable);
- flag2str(recon_bk);
- flag2str(last_recon);
return len;
}
#undef flags2str
"pools",
"grant_shrink",
"skip_orphan",
+ "large_ea",
+ "full20",
+ "layout_lock",
NULL
};
struct lprocfs_counter ret;
struct obd_device *obd = (struct obd_device *)data;
struct obd_import *imp;
+ struct obd_import_conn *conn;
int i, j, k, rw = 0;
LASSERT(obd != NULL);
"import:\n"
" name: %s\n"
" target: %s\n"
- " current_connection: %s\n"
" state: %s\n"
" connect_flags: [",
obd->obd_name,
obd2cli_tgt(obd),
- imp->imp_connection->c_remote_uuid.uuid,
ptlrpc_import_state_name(imp->imp_state));
i += obd_connect_flags2str(page + i, count - i,
imp->imp_connect_data.ocd_connect_flags,
i += snprintf(page + i, count - i,
"]\n"
" connection:\n"
+ " failover_nids: [");
+ cfs_spin_lock(&imp->imp_lock);
+ j = 0;
+ cfs_list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
+ i += snprintf(page + i, count - i, "%s%s", j ? ", " : "",
+ libcfs_nid2str(conn->oic_conn->c_peer.nid));
+ j++;
+ }
+ cfs_spin_unlock(&imp->imp_lock);
+ i += snprintf(page + i, count - i,
+ "]\n"
+ " current_connection: %s\n"
" connection_attempts: %u\n"
" generation: %u\n"
" in-progress_invalidations: %u\n",
+ libcfs_nid2str(imp->imp_connection->c_peer.nid),
imp->imp_conn_cnt,
imp->imp_generation,
cfs_atomic_read(&imp->imp_inval_count));
lprocfs_stats_collect(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, &ret);
- if (ret.lc_count != 0)
- do_div(ret.lc_sum, ret.lc_count);
- else
+ if (ret.lc_count != 0) {
+ /* first argument to do_div MUST be __u64 */
+ __u64 sum = ret.lc_sum;
+ do_div(sum, ret.lc_count);
+ ret.lc_sum = sum;
+ } else
ret.lc_sum = 0;
i += snprintf(page + i, count - i,
" rpcs:\n"
PTLRPC_LAST_CNTR + BRW_READ_BYTES + rw,
&ret);
if (ret.lc_sum > 0 && ret.lc_count > 0) {
- do_div(ret.lc_sum, ret.lc_count);
+ /* first argument to do_div MUST be __u64 */
+ __u64 sum = ret.lc_sum;
+ do_div(sum, ret.lc_count);
+ ret.lc_sum = sum;
i += snprintf(page + i, count - i,
" %s_data_averages:\n"
" bytes_per_rpc: "LPU64"\n",
j = opcode_offset(OST_READ + rw) + EXTRA_MAX_OPCODES;
lprocfs_stats_collect(obd->obd_svc_stats, j, &ret);
if (ret.lc_sum > 0 && ret.lc_count != 0) {
- do_div(ret.lc_sum, ret.lc_count);
+ /* first argument to do_div MUST be __u64 */
+ __u64 sum = ret.lc_sum;
+ do_div(sum, ret.lc_count);
+ ret.lc_sum = sum;
i += snprintf(page + i, count - i,
" %s_per_rpc: "LPU64"\n",
ret.lc_units, ret.lc_sum);
struct proc_dir_entry *entry;
LASSERT(root != NULL);
+ LPROCFS_WRITE_ENTRY();
entry = create_proc_entry(name, 0644, root);
+ if (entry) {
+ entry->proc_fops = &lprocfs_stats_seq_fops;
+ entry->data = stats;
+ }
+
+ LPROCFS_WRITE_EXIT();
+
if (entry == NULL)
return -ENOMEM;
- entry->proc_fops = &lprocfs_stats_seq_fops;
- entry->data = stats;
+
return 0;
}
lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \
} while (0)
-int lprocfs_alloc_md_stats(struct obd_device *obd,
- unsigned num_private_stats)
+void lprocfs_init_mps_stats(int num_private_stats, struct lprocfs_stats *stats)
{
- struct lprocfs_stats *stats;
- unsigned int num_stats;
- int rc, i;
-
- LASSERT(obd->md_stats == NULL);
- LASSERT(obd->obd_proc_entry != NULL);
- LASSERT(obd->md_cntr_base == 0);
-
- num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) +
- num_private_stats;
- stats = lprocfs_alloc_stats(num_stats, 0);
- if (stats == NULL)
- return -ENOMEM;
-
LPROCFS_MD_OP_INIT(num_private_stats, stats, getstatus);
LPROCFS_MD_OP_INIT(num_private_stats, stats, change_cbdata);
LPROCFS_MD_OP_INIT(num_private_stats, stats, find_cbdata);
LPROCFS_MD_OP_INIT(num_private_stats, stats, get_remote_perm);
LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_getattr_async);
LPROCFS_MD_OP_INIT(num_private_stats, stats, revalidate_lock);
+}
+
+int lprocfs_alloc_md_stats(struct obd_device *obd,
+ unsigned num_private_stats)
+{
+ struct lprocfs_stats *stats;
+ unsigned int num_stats;
+ int rc, i;
+
+ LASSERT(obd->md_stats == NULL);
+ LASSERT(obd->obd_proc_entry != NULL);
+ LASSERT(obd->md_cntr_base == 0);
+
+ num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) +
+ num_private_stats;
+ stats = lprocfs_alloc_stats(num_stats, 0);
+ if (stats == NULL)
+ return -ENOMEM;
+
+ lprocfs_init_mps_stats(num_private_stats, stats);
for (i = num_private_stats; i < num_stats; i++) {
if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) {
cb_data->len = len;
}
-void lprocfs_exp_print_uuid(void *obj, void *cb_data)
+int lprocfs_exp_print_uuid(cfs_hash_t *hs, cfs_hash_bd_t *bd,
+ cfs_hlist_node_t *hnode, void *cb_data)
+
{
- struct obd_export *exp = (struct obd_export *)obj;
+ struct obd_export *exp = cfs_hash_object(hs, hnode);
struct exp_uuid_cb_data *data = (struct exp_uuid_cb_data *)cb_data;
if (exp->exp_nid_stats)
*data->len += snprintf((data->page + *data->len),
data->count, "%s\n",
obd_uuid2str(&exp->exp_client_uuid));
+ return 0;
}
int lprocfs_exp_rd_uuid(char *page, char **start, off_t off, int count,
return (*cb_data.len);
}
-void lprocfs_exp_print_hash(void *obj, void *cb_data)
+int lprocfs_exp_print_hash(cfs_hash_t *hs, cfs_hash_bd_t *bd,
+ cfs_hlist_node_t *hnode, void *cb_data)
+
{
struct exp_uuid_cb_data *data = cb_data;
- struct obd_export *exp = obj;
- cfs_hash_t *hs;
+ struct obd_export *exp = cfs_hash_object(hs, hnode);
- hs = exp->exp_lock_hash;
- if (hs) {
- if (!*data->len)
+ if (exp->exp_lock_hash != NULL) {
+ if (!*data->len) {
*data->len += cfs_hash_debug_header(data->page,
data->count);
-
+ }
*data->len += cfs_hash_debug_str(hs, data->page + *data->len,
data->count);
}
+
+ return 0;
}
int lprocfs_exp_rd_hash(char *page, char **start, off_t off, int count,
}
EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
-void lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
+int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
{
struct nid_stat *stat = obj;
int i;
ENTRY;
- /* object has only hash + iterate_all references.
- * add/delete blocked by hash bucket lock */
+
CDEBUG(D_INFO,"refcnt %d\n", cfs_atomic_read(&stat->nid_exp_ref_count));
- if (cfs_atomic_read(&stat->nid_exp_ref_count) == 2) {
- cfs_hlist_del_init(&stat->nid_hash);
- nidstat_putref(stat);
+ if (cfs_atomic_read(&stat->nid_exp_ref_count) == 1) {
+ /* object has only hash references. */
cfs_spin_lock(&stat->nid_obd->obd_nid_lock);
cfs_list_move(&stat->nid_list, data);
cfs_spin_unlock(&stat->nid_obd->obd_nid_lock);
- EXIT;
- return;
+ RETURN(1);
}
/* we has reference to object - only clear data*/
if (stat->nid_stats)
for (i = 0; i < BRW_LAST; i++)
lprocfs_oh_clear(&stat->nid_brw_stats->hist[i]);
}
- EXIT;
- return;
+ RETURN(0);
}
int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
+ unsigned long count, void *data)
{
struct obd_device *obd = (struct obd_device *)data;
struct nid_stat *client_stat;
CFS_LIST_HEAD(free_list);
- cfs_hash_for_each(obd->obd_nid_stats_hash,
+ cfs_hash_cond_del(obd->obd_nid_stats_hash,
lprocfs_nid_stats_clear_write_cb, &free_list);
while (!cfs_list_empty(&free_list)) {
}
EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
-int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
+int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int reconnect,
+ int *newnid)
{
struct nid_stat *new_stat, *old_stat;
struct obd_device *obd = NULL;
new_stat->nid = *nid;
new_stat->nid_obd = exp->exp_obd;
- cfs_atomic_set(&new_stat->nid_exp_ref_count, 0);
+ /* we need set default refcount to 1 to balance obd_disconnect */
+ cfs_atomic_set(&new_stat->nid_exp_ref_count, 1);
old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
nid, &new_stat->nid_hash);
/* Return -EALREADY here so that we know that the /proc
* entry already has been created */
if (old_stat != new_stat) {
- cfs_spin_lock(&obd->obd_nid_lock);
- if (exp->exp_nid_stats != old_stat) {
- if (exp->exp_nid_stats)
- nidstat_putref(exp->exp_nid_stats);
- exp->exp_nid_stats = old_stat;
- } else {
- /* cfs_hash_findadd_unique() has added
- * old_stat's refcount */
+ /* if this connects to the existing export of same nid,
+ * we need to release old stats for obd_disconnect won't
+ * balance the reference gotten in "cfs_hash_findadd_uinque" */
+ if (reconnect && exp->exp_nid_stats)
nidstat_putref(old_stat);
- }
-
- cfs_spin_unlock(&obd->obd_nid_lock);
+ exp->exp_nid_stats = old_stat;
GOTO(destroy_new, rc = -EALREADY);
}
/* not found - create */
GOTO(destroy_new, rc = -ENOMEM);
memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE);
- new_stat->nid_proc = lprocfs_register(buffer,
+ new_stat->nid_proc = lprocfs_register(buffer,
obd->obd_proc_exports_entry,
NULL, NULL);
OBD_FREE(buffer, LNET_NIDSTR_SIZE);
GOTO(destroy_new_ns, rc);
}
- if (exp->exp_nid_stats)
- nidstat_putref(exp->exp_nid_stats);
- nidstat_getref(new_stat);
exp->exp_nid_stats = new_stat;
*newnid = 1;
/* protect competitive add to list, not need locking on destroy */
cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
destroy_new:
+ nidstat_putref(new_stat);
OBD_FREE_PTR(new_stat);
RETURN(rc);
}
struct proc_dir_entry *entry;
ENTRY;
+ LPROCFS_WRITE_ENTRY();
entry = create_proc_entry(name, mode, parent);
+ if (entry) {
+ entry->proc_fops = seq_fops;
+ entry->data = data;
+ }
+ LPROCFS_WRITE_EXIT();
+
if (entry == NULL)
RETURN(-ENOMEM);
- entry->proc_fops = seq_fops;
- entry->data = data;
RETURN(0);
}
c += cfs_hash_debug_str(obd->obd_uuid_hash, page + c, count - c);
c += cfs_hash_debug_str(obd->obd_nid_hash, page + c, count - c);
c += cfs_hash_debug_str(obd->obd_nid_stats_hash, page+c, count-c);
+#ifdef HAVE_QUOTA_SUPPORT
+ if (obd->u.obt.obt_qctxt.lqc_lqs_hash)
+ c += cfs_hash_debug_str(obd->u.obt.obt_qctxt.lqc_lqs_hash,
+ page + c, count - c);
+#endif
return c;
}
}
EXPORT_SYMBOL(lprocfs_obd_wr_recovery_time_hard);
+int lprocfs_obd_rd_mntdev(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
+{
+ struct obd_device *obd = (struct obd_device *)data;
+
+ LASSERT(obd != NULL);
+ LASSERT(obd->u.obt.obt_vfsmnt->mnt_devname);
+ *eof = 1;
+ return snprintf(page, count, "%s\n",
+ obd->u.obt.obt_vfsmnt->mnt_devname);
+}
+EXPORT_SYMBOL(lprocfs_obd_rd_mntdev);
+
EXPORT_SYMBOL(lprocfs_register);
EXPORT_SYMBOL(lprocfs_srch);
EXPORT_SYMBOL(lprocfs_remove);
EXPORT_SYMBOL(lprocfs_clear_stats);
EXPORT_SYMBOL(lprocfs_register_stats);
EXPORT_SYMBOL(lprocfs_init_ops_stats);
+EXPORT_SYMBOL(lprocfs_init_mps_stats);
EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
EXPORT_SYMBOL(lprocfs_alloc_obd_stats);
EXPORT_SYMBOL(lprocfs_alloc_md_stats);