X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Flproc_ptlrpc.c;h=ee5e8c33617d5b157a028acad1511a36a757dfe0;hb=ea5df4799a3c6ca7f386303694d4440997d82d43;hp=8d081e2827b42e5d6571d4a2f59e697b13e4f113;hpb=830ce1b10f3a5d3536e5ec0a9ef87fe739a509a2;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 8d081e2..ee5e8c3 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -41,52 +41,53 @@ static struct ll_rpc_opcode { - __u32 opcode; - const char *opname; + __u32 opcode; + const char *opname; } ll_rpc_opcode_table[LUSTRE_MAX_OPCODES] = { - { OST_REPLY, "ost_reply" }, - { OST_GETATTR, "ost_getattr" }, - { OST_SETATTR, "ost_setattr" }, - { OST_READ, "ost_read" }, - { OST_WRITE, "ost_write" }, - { OST_CREATE , "ost_create" }, - { OST_DESTROY, "ost_destroy" }, - { OST_GET_INFO, "ost_get_info" }, - { OST_CONNECT, "ost_connect" }, - { OST_DISCONNECT, "ost_disconnect" }, - { OST_PUNCH, "ost_punch" }, - { OST_OPEN, "ost_open" }, - { OST_CLOSE, "ost_close" }, - { OST_STATFS, "ost_statfs" }, - { 14, NULL }, /* formerly OST_SAN_READ */ - { 15, NULL }, /* formerly OST_SAN_WRITE */ - { OST_SYNC, "ost_sync" }, - { OST_SET_INFO, "ost_set_info" }, - { OST_QUOTACHECK, "ost_quotacheck" }, - { OST_QUOTACTL, "ost_quotactl" }, - { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" }, + { OST_REPLY, "ost_reply" }, + { OST_GETATTR, "ost_getattr" }, + { OST_SETATTR, "ost_setattr" }, + { OST_READ, "ost_read" }, + { OST_WRITE, "ost_write" }, + { OST_CREATE , "ost_create" }, + { OST_DESTROY, "ost_destroy" }, + { OST_GET_INFO, "ost_get_info" }, + { OST_CONNECT, "ost_connect" }, + { OST_DISCONNECT, "ost_disconnect" }, + { OST_PUNCH, "ost_punch" }, + { OST_OPEN, "ost_open" }, + { OST_CLOSE, "ost_close" }, + { OST_STATFS, "ost_statfs" }, + { 14, NULL }, /* formerly OST_SAN_READ */ + { 15, NULL }, /* formerly OST_SAN_WRITE */ + { OST_SYNC, "ost_sync" }, + { OST_SET_INFO, "ost_set_info" }, + { OST_QUOTACHECK, "ost_quotacheck" }, + { OST_QUOTACTL, "ost_quotactl" }, + { OST_QUOTA_ADJUST_QUNIT, "ost_quota_adjust_qunit" }, { OST_LADVISE, "ost_ladvise" }, - { MDS_GETATTR, "mds_getattr" }, - { MDS_GETATTR_NAME, "mds_getattr_lock" }, - { MDS_CLOSE, "mds_close" }, - { MDS_REINT, "mds_reint" }, - { MDS_READPAGE, "mds_readpage" }, - { MDS_CONNECT, "mds_connect" }, - { MDS_DISCONNECT, "mds_disconnect" }, + { OST_FALLOCATE, "ost_fallocate"}, + { MDS_GETATTR, "mds_getattr" }, + { MDS_GETATTR_NAME, "mds_getattr_lock" }, + { MDS_CLOSE, "mds_close" }, + { MDS_REINT, "mds_reint" }, + { MDS_READPAGE, "mds_readpage" }, + { MDS_CONNECT, "mds_connect" }, + { MDS_DISCONNECT, "mds_disconnect" }, { MDS_GET_ROOT, "mds_get_root" }, - { MDS_STATFS, "mds_statfs" }, - { MDS_PIN, "mds_pin" }, - { MDS_UNPIN, "mds_unpin" }, - { MDS_SYNC, "mds_sync" }, - { MDS_DONE_WRITING, "mds_done_writing" }, - { MDS_SET_INFO, "mds_set_info" }, - { MDS_QUOTACHECK, "mds_quotacheck" }, - { MDS_QUOTACTL, "mds_quotactl" }, - { MDS_GETXATTR, "mds_getxattr" }, - { MDS_SETXATTR, "mds_setxattr" }, - { MDS_WRITEPAGE, "mds_writepage" }, - { MDS_IS_SUBDIR, "mds_is_subdir" }, - { MDS_GET_INFO, "mds_get_info" }, + { MDS_STATFS, "mds_statfs" }, + { MDS_PIN, "mds_pin" }, + { MDS_UNPIN, "mds_unpin" }, + { MDS_SYNC, "mds_sync" }, + { MDS_DONE_WRITING, "mds_done_writing" }, + { MDS_SET_INFO, "mds_set_info" }, + { MDS_QUOTACHECK, "mds_quotacheck" }, + { MDS_QUOTACTL, "mds_quotactl" }, + { MDS_GETXATTR, "mds_getxattr" }, + { MDS_SETXATTR, "mds_setxattr" }, + { MDS_WRITEPAGE, "mds_writepage" }, + { MDS_IS_SUBDIR, "mds_is_subdir" }, + { MDS_GET_INFO, "mds_get_info" }, { MDS_HSM_STATE_GET, "mds_hsm_state_get" }, { MDS_HSM_STATE_SET, "mds_hsm_state_set" }, { MDS_HSM_ACTION, "mds_hsm_action" }, @@ -95,39 +96,40 @@ static struct ll_rpc_opcode { { MDS_HSM_CT_REGISTER, "mds_hsm_ct_register" }, { MDS_HSM_CT_UNREGISTER, "mds_hsm_ct_unregister" }, { MDS_SWAP_LAYOUTS, "mds_swap_layouts" }, - { LDLM_ENQUEUE, "ldlm_enqueue" }, - { LDLM_CONVERT, "ldlm_convert" }, - { LDLM_CANCEL, "ldlm_cancel" }, - { LDLM_BL_CALLBACK, "ldlm_bl_callback" }, - { LDLM_CP_CALLBACK, "ldlm_cp_callback" }, - { LDLM_GL_CALLBACK, "ldlm_gl_callback" }, - { LDLM_SET_INFO, "ldlm_set_info" }, - { MGS_CONNECT, "mgs_connect" }, - { MGS_DISCONNECT, "mgs_disconnect" }, - { MGS_EXCEPTION, "mgs_exception" }, - { MGS_TARGET_REG, "mgs_target_reg" }, - { MGS_TARGET_DEL, "mgs_target_del" }, - { MGS_SET_INFO, "mgs_set_info" }, - { MGS_CONFIG_READ, "mgs_config_read" }, + { MDS_RMFID, "mds_rmfid" }, + { LDLM_ENQUEUE, "ldlm_enqueue" }, + { LDLM_CONVERT, "ldlm_convert" }, + { LDLM_CANCEL, "ldlm_cancel" }, + { LDLM_BL_CALLBACK, "ldlm_bl_callback" }, + { LDLM_CP_CALLBACK, "ldlm_cp_callback" }, + { LDLM_GL_CALLBACK, "ldlm_gl_callback" }, + { LDLM_SET_INFO, "ldlm_set_info" }, + { MGS_CONNECT, "mgs_connect" }, + { MGS_DISCONNECT, "mgs_disconnect" }, + { MGS_EXCEPTION, "mgs_exception" }, + { MGS_TARGET_REG, "mgs_target_reg" }, + { MGS_TARGET_DEL, "mgs_target_del" }, + { MGS_SET_INFO, "mgs_set_info" }, + { MGS_CONFIG_READ, "mgs_config_read" }, { OBD_PING, "obd_ping" }, - { 401, /* was OBD_LOG_CANCEL */ "llog_cancel" }, + { 401, /* was OBD_LOG_CANCEL */ "llog_cancel" }, { 402, /* was OBD_QC_CALLBACK */ "obd_quota_callback" }, - { OBD_IDX_READ, "dt_index_read" }, - { LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_open" }, - { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" }, - { LLOG_ORIGIN_HANDLE_READ_HEADER,"llog_origin_handle_read_header" }, - { 504, /*LLOG_ORIGIN_HANDLE_WRITE_REC*/"llog_origin_handle_write_rec" }, - { 505, /* was LLOG_ORIGIN_HANDLE_CLOSE */ "llog_origin_handle_close" }, - { 506, /* was LLOG_ORIGIN_CONNECT */ "llog_origin_connect" }, - { 507, /* was LLOG_CATINFO */ "llog_catinfo" }, - { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" }, - { LLOG_ORIGIN_HANDLE_DESTROY, "llog_origin_handle_destroy" }, - { QUOTA_DQACQ, "quota_acquire" }, - { QUOTA_DQREL, "quota_release" }, - { SEQ_QUERY, "seq_query" }, - { SEC_CTX_INIT, "sec_ctx_init" }, - { SEC_CTX_INIT_CONT,"sec_ctx_init_cont" }, - { SEC_CTX_FINI, "sec_ctx_fini" }, + { OBD_IDX_READ, "dt_index_read" }, + { LLOG_ORIGIN_HANDLE_CREATE, "llog_origin_handle_open" }, + { LLOG_ORIGIN_HANDLE_NEXT_BLOCK, "llog_origin_handle_next_block" }, + { LLOG_ORIGIN_HANDLE_READ_HEADER, "llog_origin_handle_read_header" }, + { 504, /*LLOG_ORIGIN_HANDLE_WRITE_REC*/"llog_origin_handle_write_rec" }, + { 505, /* was LLOG_ORIGIN_HANDLE_CLOSE */ "llog_origin_handle_close" }, + { 506, /* was LLOG_ORIGIN_CONNECT */ "llog_origin_connect" }, + { 507, /* was LLOG_CATINFO */ "llog_catinfo" }, + { LLOG_ORIGIN_HANDLE_PREV_BLOCK, "llog_origin_handle_prev_block" }, + { LLOG_ORIGIN_HANDLE_DESTROY, "llog_origin_handle_destroy" }, + { QUOTA_DQACQ, "quota_acquire" }, + { QUOTA_DQREL, "quota_release" }, + { SEQ_QUERY, "seq_query" }, + { SEC_CTX_INIT, "sec_ctx_init" }, + { SEC_CTX_INIT_CONT, "sec_ctx_init_cont" }, + { SEC_CTX_FINI, "sec_ctx_fini" }, { FLD_QUERY, "fld_query" }, { FLD_READ, "fld_read" }, { OUT_UPDATE, "out_update" }, @@ -136,8 +138,8 @@ static struct ll_rpc_opcode { }; static struct ll_eopcode { - __u32 opcode; - const char *opname; + __u32 opcode; + const char *opname; } ll_eopcode_table[EXTRA_LAST_OPC] = { { LDLM_GLIMPSE_ENQUEUE, "ldlm_glimpse_enqueue" }, { LDLM_PLAIN_ENQUEUE, "ldlm_plain_enqueue" }, @@ -200,10 +202,10 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, struct lprocfs_stats **stats_ret) { struct dentry *svc_debugfs_entry; - struct lprocfs_stats *svc_stats; - int i, rc; - unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | - LPROCFS_CNTR_STDDEV; + struct lprocfs_stats *svc_stats; + int i; + unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX | + LPROCFS_CNTR_STDDEV; LASSERT(!*debugfs_root_ret); LASSERT(!*stats_ret); @@ -213,15 +215,10 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, if (!svc_stats) return; - if (dir) { - svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL); - if (IS_ERR(svc_debugfs_entry)) { - lprocfs_free_stats(&svc_stats); - return; - } - } else { + if (dir) + svc_debugfs_entry = debugfs_create_dir(dir, root); + else svc_debugfs_entry = root; - } lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR, svc_counter_config, "req_waittime", "usec"); @@ -256,16 +253,12 @@ ptlrpc_ldebugfs_register(struct dentry *root, char *dir, char *name, ll_opcode2str(opcode), "usec"); } - rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats); - if (rc < 0) { - if (dir) - ldebugfs_remove(&svc_debugfs_entry); - lprocfs_free_stats(&svc_stats); - } else { - if (dir) - *debugfs_root_ret = svc_debugfs_entry; - *stats_ret = svc_stats; - } + debugfs_create_file(name, 0644, svc_debugfs_entry, svc_stats, + &lprocfs_stats_seq_fops); + + if (dir) + *debugfs_root_ret = svc_debugfs_entry; + *stats_ret = svc_stats; } static int @@ -309,6 +302,7 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, struct seq_file *m = file->private_data; struct ptlrpc_service *svc = m->private; unsigned long long val; + unsigned long long limit; int bufpages; int rc; @@ -326,8 +320,9 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, * will be upgraded */ bufpages = (roundup_pow_of_two(svc->srv_buf_size) + PAGE_SIZE - 1) >> PAGE_SHIFT; + limit = cfs_totalram_pages() / (2 * bufpages); /* do not allow history to consume more than half max number of rqbds */ - if ((svc->srv_nrqbds_max == 0 && val > totalram_pages / (2 * bufpages)) || + if ((svc->srv_nrqbds_max == 0 && val > limit) || (svc->srv_nrqbds_max != 0 && val > svc->srv_nrqbds_max / 2)) return -ERANGE; @@ -514,7 +509,7 @@ void nrs_policy_get_info_locked(struct ptlrpc_nrs_policy *policy, LASSERT(info != NULL); assert_spin_locked(&policy->pol_nrs->nrs_lock); - CLASSERT(sizeof(info->pi_arg) == sizeof(policy->pol_arg)); + BUILD_BUG_ON(sizeof(info->pi_arg) != sizeof(policy->pol_arg)); memcpy(info->pi_name, policy->pol_desc->pd_name, NRS_POL_NAME_MAX); memcpy(info->pi_arg, policy->pol_arg, sizeof(policy->pol_arg)); @@ -564,7 +559,7 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n) num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols; spin_unlock(&nrs->nrs_lock); - OBD_ALLOC(infos, num_pols * sizeof(*infos)); + OBD_ALLOC_PTR_ARRAY(infos, num_pols); if (infos == NULL) GOTO(out, rc = -ENOMEM); again: @@ -686,7 +681,7 @@ again: out: if (infos) - OBD_FREE(infos, num_pols * sizeof(*infos)); + OBD_FREE_PTR_ARRAY(infos, num_pols); mutex_unlock(&nrs_core.nrs_mutex); @@ -1026,7 +1021,6 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) req = srhi->srhi_req; - libcfs_nid2str_r(req->rq_self, nidstr, sizeof(nidstr)); arrival.tv_sec = req->rq_arrival_time.tv_sec; arrival.tv_nsec = req->rq_arrival_time.tv_nsec; sent.tv_sec = req->rq_sent; @@ -1040,8 +1034,13 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) * parser. Currently I only print stuff here I know is OK * to look at coz it was set up in request_in_callback()!!! */ - seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld.%06lld:%lld.%06llds(%+lld.0s) ", - req->rq_history_seq, nidstr, + seq_printf(s, + "%lld:%s:%s:x%llu:%d:%s:%lld.%06lld:%lld.%06llds(%+lld.0s) ", + req->rq_history_seq, + req->rq_export && req->rq_export->exp_obd ? + req->rq_export->exp_obd->obd_name : + libcfs_nid2str_r(req->rq_self, nidstr, + sizeof(nidstr)), libcfs_id2str(req->rq_peer), req->rq_xid, req->rq_reqlen, ptlrpc_rqphase2str(req), (s64)req->rq_arrival_time.tv_sec, @@ -1073,10 +1072,6 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) struct seq_file *seqf; int rc; - rc = LPROCFS_ENTRY_CHECK(inode); - if (rc < 0) - return rc; - rc = seq_open(file, &sops); if (rc) return rc; @@ -1089,12 +1084,12 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file) /* See also lprocfs_rd_timeouts */ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) { - struct ptlrpc_service *svc = m->private; - struct ptlrpc_service_part *svcpt; - time64_t worstt; - unsigned int cur; - unsigned int worst; - int i; + struct ptlrpc_service *svc = m->private; + struct ptlrpc_service_part *svcpt; + time64_t worst_timestamp; + timeout_t cur_timeout; + timeout_t worst_timeout; + int i; if (AT_OFF) { seq_printf(m, "adaptive timeouts off, using obd_timeout %u\n", @@ -1103,13 +1098,14 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) } ptlrpc_service_for_each_part(svcpt, i, svc) { - cur = at_get(&svcpt->scp_at_estimate); - worst = svcpt->scp_at_estimate.at_worst_ever; - worstt = svcpt->scp_at_estimate.at_worst_time; + cur_timeout = at_get(&svcpt->scp_at_estimate); + worst_timeout = svcpt->scp_at_estimate.at_worst_timeout_ever; + worst_timestamp = svcpt->scp_at_estimate.at_worst_timestamp; seq_printf(m, "%10s : cur %3u worst %3u (at %lld, %llds ago) ", - "service", cur, worst, (s64)worstt, - (s64)(ktime_get_real_seconds() - worstt)); + "service", cur_timeout, worst_timeout, + worst_timestamp, + ktime_get_real_seconds() - worst_timestamp); lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate); } @@ -1220,26 +1216,22 @@ void ptlrpc_ldebugfs_register_service(struct dentry *entry, .release = lprocfs_seq_release, }; - int rc; - ptlrpc_ldebugfs_register(entry, svc->srv_name, "stats", &svc->srv_debugfs_entry, &svc->srv_stats); - if (IS_ERR_OR_NULL(svc->srv_debugfs_entry)) + if (!svc->srv_debugfs_entry) return; ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL); - rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history", - 0400, &req_history_fops, svc); - if (rc) - CWARN("Error adding the req_history file\n"); + debugfs_create_file("req_history", 0400, svc->srv_debugfs_entry, svc, + &req_history_fops); } -void ptlrpc_lprocfs_register_obd(struct obd_device *obddev) +void ptlrpc_lprocfs_register_obd(struct obd_device *obd) { - ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats", - &obddev->obd_svc_debugfs_entry, - &obddev->obd_svc_stats); + ptlrpc_ldebugfs_register(obd->obd_debugfs_entry, NULL, "stats", + &obd->obd_svc_debugfs_entry, + &obd->obd_svc_stats); } EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd); @@ -1287,11 +1279,10 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw); void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc) { - if (!IS_ERR_OR_NULL(svc->srv_debugfs_entry)) - ldebugfs_remove(&svc->srv_debugfs_entry); + debugfs_remove_recursive(svc->srv_debugfs_entry); - if (svc->srv_stats) - lprocfs_free_stats(&svc->srv_stats); + if (svc->srv_stats) + lprocfs_free_stats(&svc->srv_stats); } void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) @@ -1301,26 +1292,28 @@ void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) */ lprocfs_obd_cleanup(obd); - if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry)) - ldebugfs_remove(&obd->obd_svc_debugfs_entry); + debugfs_remove_recursive(obd->obd_svc_debugfs_entry); - if (obd->obd_svc_stats) - lprocfs_free_stats(&obd->obd_svc_stats); + if (obd->obd_svc_stats) + lprocfs_free_stats(&obd->obd_svc_stats); } EXPORT_SYMBOL(ptlrpc_lprocfs_unregister_obd); -ssize_t ping_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, size_t count) +ssize_t ping_show(struct kobject *kobj, struct attribute *attr, + char *buffer) { struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); + struct obd_import *imp; struct ptlrpc_request *req; int rc; ENTRY; - LPROCFS_CLIMP_CHECK(obd); - req = ptlrpc_prep_ping(obd->u.cli.cl_import); - LPROCFS_CLIMP_EXIT(obd); + with_imp_locked(obd, imp, rc) + req = ptlrpc_prep_ping(imp); + + if (rc) + RETURN(rc); if (!req) RETURN(-ENOMEM); @@ -1329,36 +1322,19 @@ ssize_t ping_store(struct kobject *kobj, struct attribute *attr, rc = ptlrpc_queue_wait(req); ptlrpc_req_finished(req); - RETURN(rc >= 0 ? count : rc); + RETURN(rc); } -EXPORT_SYMBOL(ping_store); +EXPORT_SYMBOL(ping_show); -ssize_t -lprocfs_ping_seq_write(struct file *file, const char __user *buffer, - size_t count, loff_t *off) +/* kept for older verison of tools. */ +ssize_t ping_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct seq_file *m = file->private_data; - struct obd_device *obd = m->private; - struct ptlrpc_request *req; - int rc; - ENTRY; - - LPROCFS_CLIMP_CHECK(obd); - req = ptlrpc_prep_ping(obd->u.cli.cl_import); - LPROCFS_CLIMP_EXIT(obd); - if (req == NULL) - RETURN(-ENOMEM); + int rc = ping_show(kobj, attr, (char *)buffer); - req->rq_send_state = LUSTRE_IMP_FULL; - - rc = ptlrpc_queue_wait(req); - - ptlrpc_req_finished(req); - if (rc >= 0) - RETURN(count); - RETURN(rc); + return (rc < 0) ? rc : count; } -EXPORT_SYMBOL(lprocfs_ping_seq_write); +EXPORT_SYMBOL(ping_store); /* Write the connection UUID to this file to attempt to connect to that node. * The connection UUID is a node's primary NID. For example, @@ -1370,13 +1346,14 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer, { struct seq_file *m = file->private_data; struct obd_device *obd = m->private; - struct obd_import *imp = obd->u.cli.cl_import; + struct obd_import *imp; char *kbuf = NULL; char *uuid; char *ptr; int do_reconn = 1; const char prefix[] = "connection="; const int prefix_len = sizeof(prefix) - 1; + int rc = 0; if (count > PAGE_SIZE - 1 || count <= prefix_len) return -EINVAL; @@ -1386,57 +1363,62 @@ lprocfs_import_seq_write(struct file *file, const char __user *buffer, return -ENOMEM; if (copy_from_user(kbuf, buffer, count)) - GOTO(out, count = -EFAULT); + GOTO(out, rc = -EFAULT); kbuf[count] = 0; /* only support connection=uuid::instance now */ if (strncmp(prefix, kbuf, prefix_len) != 0) - GOTO(out, count = -EINVAL); - - uuid = kbuf + prefix_len; - ptr = strstr(uuid, "::"); - if (ptr) { - __u32 inst; - char *endptr; - - *ptr = 0; - do_reconn = 0; - ptr += 2; /* Skip :: */ - inst = simple_strtol(ptr, &endptr, 10); - if (*endptr) { - CERROR("config: wrong instance # %s\n", ptr); - } else if (inst != imp->imp_connect_data.ocd_instance) { - CDEBUG(D_INFO, "IR: %s is connecting to an obsoleted " - "target(%u/%u), reconnecting...\n", - imp->imp_obd->obd_name, - imp->imp_connect_data.ocd_instance, inst); - do_reconn = 1; - } else { - CDEBUG(D_INFO, "IR: %s has already been connecting to " - "new target(%u)\n", - imp->imp_obd->obd_name, inst); + GOTO(out, rc = -EINVAL); + + with_imp_locked(obd, imp, rc) { + uuid = kbuf + prefix_len; + ptr = strstr(uuid, "::"); + if (ptr) { + u32 inst; + int rc; + + *ptr = 0; + do_reconn = 0; + ptr += 2; /* Skip :: */ + rc = kstrtouint(ptr, 10, &inst); + if (rc) { + CERROR("config: wrong instance # %s\n", ptr); + } else if (inst != imp->imp_connect_data.ocd_instance) { + CDEBUG(D_INFO, + "IR: %s is connecting to an obsoleted target(%u/%u), reconnecting...\n", + imp->imp_obd->obd_name, + imp->imp_connect_data.ocd_instance, + inst); + do_reconn = 1; + } else { + CDEBUG(D_INFO, + "IR: %s has already been connecting to " + "new target(%u)\n", + imp->imp_obd->obd_name, inst); + } } - } - if (do_reconn) - ptlrpc_recover_import(imp, uuid, 1); + if (do_reconn) + ptlrpc_recover_import(imp, uuid, 1); + } out: OBD_FREE(kbuf, count + 1); - return count; + return rc ?: count; } EXPORT_SYMBOL(lprocfs_import_seq_write); int lprocfs_pinger_recov_seq_show(struct seq_file *m, void *n) { struct obd_device *obd = m->private; - struct obd_import *imp = obd->u.cli.cl_import; + struct obd_import *imp; + int rc; - LPROCFS_CLIMP_CHECK(obd); - seq_printf(m, "%d\n", !imp->imp_no_pinger_recover); - LPROCFS_CLIMP_EXIT(obd); - return 0; + with_imp_locked(obd, imp, rc) + seq_printf(m, "%d\n", !imp->imp_no_pinger_recover); + + return rc; } EXPORT_SYMBOL(lprocfs_pinger_recov_seq_show); @@ -1446,8 +1428,7 @@ lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, { struct seq_file *m = file->private_data; struct obd_device *obd = m->private; - struct client_obd *cli = &obd->u.cli; - struct obd_import *imp = cli->cl_import; + struct obd_import *imp; bool val; int rc; @@ -1455,11 +1436,12 @@ lprocfs_pinger_recov_seq_write(struct file *file, const char __user *buffer, if (rc < 0) return rc; - LPROCFS_CLIMP_CHECK(obd); - spin_lock(&imp->imp_lock); - imp->imp_no_pinger_recover = !val; - spin_unlock(&imp->imp_lock); - LPROCFS_CLIMP_EXIT(obd); - return count; + with_imp_locked(obd, imp, rc) { + spin_lock(&imp->imp_lock); + imp->imp_no_pinger_recover = !val; + spin_unlock(&imp->imp_lock); + } + + return rc ?: count; } EXPORT_SYMBOL(lprocfs_pinger_recov_seq_write);