lprocfs_status.c
来自「lustre 1.6.5 source code」· C语言 代码 · 共 1,933 行 · 第 1/5 页
C
1,933 行
{ atomic_t *atom = (atomic_t *)data; LASSERT(atom != NULL); *eof = 1; return snprintf(page, count, "%d\n", atomic_read(atom));}int lprocfs_wr_atomic(struct file *file, const char *buffer, unsigned long count, void *data){ atomic_t *atm = data; int val = 0; int rc; rc = lprocfs_write_helper(buffer, count, &val); if (rc < 0) return rc; if (val <= 0) return -ERANGE; atomic_set(atm, val); return count;}int lprocfs_rd_uuid(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = (struct obd_device*)data; LASSERT(obd != NULL); *eof = 1; return snprintf(page, count, "%s\n", obd->obd_uuid.uuid);}int lprocfs_rd_name(char *page, char **start, off_t off, int count, int *eof, void* data){ struct obd_device *dev = (struct obd_device *)data; LASSERT(dev != NULL); LASSERT(dev->obd_name != NULL); *eof = 1; return snprintf(page, count, "%s\n", dev->obd_name);}int lprocfs_rd_fstype(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->obd_fsops != NULL); LASSERT(obd->obd_fsops->fs_type != NULL); return snprintf(page, count, "%s\n", obd->obd_fsops->fs_type);}int lprocfs_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, "%u\n", osfs.os_bsize); } return rc;}int lprocfs_rd_kbytestotal(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_blocks; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}int lprocfs_rd_kbytesfree(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bfree; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}int lprocfs_rd_kbytesavail(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; __u64 result = osfs.os_bavail; while (blk_size >>= 1) result <<= 1; *eof = 1; rc = snprintf(page, count, LPU64"\n", result); } return rc;}int lprocfs_rd_filestotal(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_files); } return rc;}int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_statfs osfs; int rc = obd_statfs(data, &osfs, cfs_time_current_64() - HZ, OBD_STATFS_NODELAY); if (!rc) { *eof = 1; rc = snprintf(page, count, LPU64"\n", osfs.os_ffree); } return rc;}int lprocfs_rd_server_uuid(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = (struct obd_device *)data; struct obd_import *imp; char *imp_state_name = NULL; int rc = 0; LASSERT(obd != NULL); LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import; imp_state_name = ptlrpc_import_state_name(imp->imp_state); *eof = 1; rc = snprintf(page, count, "%s\t%s%s\n", obd2cli_tgt(obd), imp_state_name, imp->imp_deactive ? "\tDEACTIVATED" : ""); LPROCFS_CLIMP_EXIT(obd); return rc;}int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = (struct obd_device*)data; struct ptlrpc_connection *conn; int rc = 0; LASSERT(obd != NULL); LPROCFS_CLIMP_CHECK(obd); conn = obd->u.cli.cl_import->imp_connection; LASSERT(conn != NULL); *eof = 1; rc = snprintf(page, count, "%s\n", conn->c_remote_uuid.uuid); LPROCFS_CLIMP_EXIT(obd); return rc;}int lprocfs_at_hist_helper(char *page, int count, int rc, struct adaptive_timeout *at){ int i; for (i = 0; i < AT_BINS; i++) rc += snprintf(page + rc, count - rc, "%3u ", at->at_hist[i]); rc += snprintf(page + rc, count - rc, "\n"); return rc;}/* See also ptlrpc_lprocfs_rd_timeouts */int lprocfs_rd_timeouts(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = (struct obd_device *)data; struct obd_import *imp; unsigned int cur, worst; time_t now, worstt; struct dhms ts; int i, rc = 0; LASSERT(obd != NULL); LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import; *eof = 1; now = cfs_time_current_sec(); /* Some network health info for kicks */ s2dhms(&ts, now - imp->imp_last_reply_time); rc += snprintf(page + rc, count - rc, "%-10s : %ld, "DHMS_FMT" ago\n", "last reply", imp->imp_last_reply_time, DHMS_VARS(&ts)); cur = at_get(&imp->imp_at.iat_net_latency); worst = imp->imp_at.iat_net_latency.at_worst_ever; worstt = imp->imp_at.iat_net_latency.at_worst_time; s2dhms(&ts, now - worstt); rc += snprintf(page + rc, count - rc, "%-10s : cur %3u worst %3u (at %ld, "DHMS_FMT" ago) ", "network", cur, worst, worstt, DHMS_VARS(&ts)); rc = lprocfs_at_hist_helper(page, count, rc, &imp->imp_at.iat_net_latency); for(i = 0; i < IMP_AT_MAX_PORTALS; i++) { if (imp->imp_at.iat_portal[i] == 0) break; cur = at_get(&imp->imp_at.iat_service_estimate[i]); worst = imp->imp_at.iat_service_estimate[i].at_worst_ever; worstt = imp->imp_at.iat_service_estimate[i].at_worst_time; s2dhms(&ts, now - worstt); rc += snprintf(page + rc, count - rc, "portal %-2d : cur %3u worst %3u (at %ld, " DHMS_FMT" ago) ", imp->imp_at.iat_portal[i], cur, worst, worstt, DHMS_VARS(&ts)); rc = lprocfs_at_hist_helper(page, count, rc, &imp->imp_at.iat_service_estimate[i]); } LPROCFS_CLIMP_EXIT(obd); return rc;}static const char *obd_connect_names[] = { "read_only", "lov_index", "unused", "write_grant", "server_lock", "version", "request_portal", "acl", "xattr", "create_on_write", "truncate_lock", "initial_transno", "inode_bit_locks", "join_file", "getattr_by_fid", "no_oh_for_devices", "local_1.8_client", "remote_1.8_client", "max_byte_per_rpc", "64bit_qdata", "fid_capability", "oss_capability", "early_lock_cancel", "size_on_mds", "adaptive_timeout", "lru_resize", "mds_mds_connection", "real_conn", "change_qunit_size", "alt_checksum_algorithm", "fid_is_enabled", NULL};int lprocfs_rd_connect_flags(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = data; __u64 mask = 1, flags; int i, ret = 0; LPROCFS_CLIMP_CHECK(obd); flags = obd->u.cli.cl_import->imp_connect_data.ocd_connect_flags; ret = snprintf(page, count, "flags="LPX64"\n", flags); for (i = 0; obd_connect_names[i] != NULL; i++, mask <<= 1) { if (flags & mask) ret += snprintf(page + ret, count - ret, "%s\n", obd_connect_names[i]); } if (flags & ~(mask - 1)) ret += snprintf(page + ret, count - ret, "unknown flags "LPX64"\n", flags & ~(mask - 1)); LPROCFS_CLIMP_EXIT(obd); return ret;}EXPORT_SYMBOL(lprocfs_rd_connect_flags);int lprocfs_rd_num_exports(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_device *obd = (struct obd_device*)data; LASSERT(obd != NULL); *eof = 1; return snprintf(page, count, "%u\n", obd->obd_num_exports);}int lprocfs_rd_numrefs(char *page, char **start, off_t off, int count, int *eof, void *data){ struct obd_type *class = (struct obd_type*) data; LASSERT(class != NULL); *eof = 1; return snprintf(page, count, "%d\n", class->typ_refcnt);}int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list){ int rc = 0; LASSERT(obd != NULL); LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); LASSERT(obd->obd_type->typ_procroot != NULL); obd->obd_proc_entry = lprocfs_register(obd->obd_name, obd->obd_type->typ_procroot, list, obd); if (IS_ERR(obd->obd_proc_entry)) { rc = PTR_ERR(obd->obd_proc_entry); CERROR("error %d setting up lprocfs for %s\n",rc,obd->obd_name); obd->obd_proc_entry = NULL; } return rc;}int lprocfs_obd_cleanup(struct obd_device *obd){ if (!obd) return -EINVAL; if (obd->obd_proc_exports_entry) { /* Should be no exports left */ LASSERT(obd->obd_proc_exports_entry->subdir == NULL); lprocfs_remove(&obd->obd_proc_exports_entry); } lprocfs_remove(&obd->obd_proc_entry); return 0;}void lprocfs_free_client_stats(void *obj, void *data){ struct nid_stat *client_stat = obj; CDEBUG(D_CONFIG, "stat %p - data %p/%p/%p\n", client_stat, client_stat->nid_proc, client_stat->nid_stats, client_stat->nid_brw_stats); LASSERTF(client_stat->nid_exp_ref_count == 0, "count %d\n", client_stat->nid_exp_ref_count); hlist_del_init(&client_stat->nid_hash); list_del(&client_stat->nid_list); if (client_stat->nid_proc) lprocfs_remove(&client_stat->nid_proc); if (client_stat->nid_stats) lprocfs_free_stats(&client_stat->nid_stats);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?