From 61f9847a812f95d5140edee1fb25bfbe6cb70bb7 Mon Sep 17 00:00:00 2001 From: Liang Zhen Date: Fri, 5 Dec 2014 22:06:52 +0800 Subject: [PATCH] LU-6032 obdclass: new wrapper to convert NID to string This patch includes a couple of changes: - add new wrapper function obd_import_nid2str - use obd_import_nid2str and obd_export_nid2str to replace all libcfs_nid2str conversions for NID of export/import connection Signed-off-by: Liang Zhen Change-Id: I57d08e6ef902c6a34c705663de0ed73bb3dc76f2 Reviewed-on: https://review.whamcloud.com/12956 Reviewed-by: Dmitry Eremin Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Amir Shehata Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/include/obd_class.h | 12 +++++++++++- lustre/ldlm/ldlm_lock.c | 4 ++-- lustre/mdt/mdt_open.c | 3 +-- lustre/mdt/mdt_recovery.c | 2 +- lustre/obdclass/genops.c | 22 ++++++---------------- lustre/ptlrpc/client.c | 5 ++--- lustre/ptlrpc/import.c | 21 ++++++++++----------- 7 files changed, 33 insertions(+), 36 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index f9c02dd..e65f9ce 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -91,7 +91,17 @@ int get_devices_count(void); int class_notify_sptlrpc_conf(const char *fsname, int namelen); -char *obd_export_nid2str(struct obd_export *exp); +static inline char *obd_export_nid2str(struct obd_export *exp) +{ + return exp->exp_connection == NULL ? + "" : libcfs_nid2str(exp->exp_connection->c_peer.nid); +} + +static inline char *obd_import_nid2str(struct obd_import *imp) +{ + return imp->imp_connection == NULL ? + "" : libcfs_nid2str(imp->imp_connection->c_peer.nid); +} int obd_export_evict_by_nid(struct obd_device *obd, const char *nid); int obd_export_evict_by_uuid(struct obd_device *obd, const char *uuid); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 61324cc..01d9837 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -2606,10 +2606,10 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, va_start(args, fmt); if (exp && exp->exp_connection) { - nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); + nid = obd_export_nid2str(exp); } else if (exp && exp->exp_obd != NULL) { struct obd_import *imp = exp->exp_obd->u.cli.cl_import; - nid = libcfs_nid2str(imp->imp_connection->c_peer.nid); + nid = obd_import_nid2str(imp); } if (resource == NULL) { diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index 0d35f29..cb7e236 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -226,8 +226,7 @@ static void mdt_empty_transno(struct mdt_thread_info *info, int rc) CERROR("%s: replay trans %llu NID %s: rc = %d\n", mdt_obd_name(mdt), info->mti_transno, - libcfs_nid2str(exp->exp_connection->c_peer.nid), - rc); + obd_export_nid2str(exp), rc); spin_unlock(&mdt->mdt_lut.lut_translock); RETURN_EXIT; } diff --git a/lustre/mdt/mdt_recovery.c b/lustre/mdt/mdt_recovery.c index 57fa1c8..8a67985 100644 --- a/lustre/mdt/mdt_recovery.c +++ b/lustre/mdt/mdt_recovery.c @@ -152,7 +152,7 @@ static void mdt_steal_ack_locks(struct ptlrpc_request *req) " o%d NID %s\n", rs->rs_nlocks, rs, rs->rs_xid, rs->rs_transno, rs->rs_opc, - libcfs_nid2str(exp->exp_connection->c_peer.nid)); + obd_export_nid2str(exp)); spin_lock(&svcpt->scp_rep_lock); list_del_init(&rs->rs_exp_list); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 567e602..393e848 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -1671,13 +1671,12 @@ void class_disconnect_stale_exports(struct obd_device *obd, spin_unlock(&exp->exp_lock); list_move(&exp->exp_obd_chain, &work_list); - evicted++; - CDEBUG(D_HA, "%s: disconnect stale client %s@%s\n", - obd->obd_name, exp->exp_client_uuid.uuid, - exp->exp_connection == NULL ? "" : - libcfs_nid2str(exp->exp_connection->c_peer.nid)); - print_export_data(exp, "EVICTING", 0, D_HA); - } + evicted++; + CDEBUG(D_HA, "%s: disconnect stale client %s@%s\n", + obd->obd_name, exp->exp_client_uuid.uuid, + obd_export_nid2str(exp)); + print_export_data(exp, "EVICTING", 0, D_HA); + } spin_unlock(&obd->obd_dev_lock); if (evicted) @@ -1728,15 +1727,6 @@ void class_fail_export(struct obd_export *exp) } EXPORT_SYMBOL(class_fail_export); -char *obd_export_nid2str(struct obd_export *exp) -{ - if (exp->exp_connection != NULL) - return libcfs_nid2str(exp->exp_connection->c_peer.nid); - - return "(no nid)"; -} -EXPORT_SYMBOL(obd_export_nid2str); - int obd_export_evict_by_nid(struct obd_device *obd, const char *nid) { struct cfs_hash *nid_hash; diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 95fd6ec..038ff31 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -1598,8 +1598,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) " %s:%s:%d:%llu:%s:%d\n", current_comm(), imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, - libcfs_nid2str(imp->imp_connection->c_peer.nid), - lustre_msg_get_opc(req->rq_reqmsg)); + obd_import_nid2str(imp), lustre_msg_get_opc(req->rq_reqmsg)); rc = ptl_send_rpc(req, 0); if (rc == -ENOMEM) { @@ -2023,7 +2022,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set) imp->imp_obd->obd_uuid.uuid, lustre_msg_get_status(req->rq_reqmsg), req->rq_xid, - libcfs_nid2str(imp->imp_connection->c_peer.nid), + obd_import_nid2str(imp), lustre_msg_get_opc(req->rq_reqmsg)); spin_lock(&imp->imp_lock); diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index dcd42f0..a1e1d25 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -175,16 +175,15 @@ int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt) "lost; in progress operations using this " "service will wait for recovery to complete\n", imp->imp_obd->obd_name, target_len, target_start, - libcfs_nid2str(imp->imp_connection->c_peer.nid)); - } else { - LCONSOLE_ERROR_MSG(0x166, "%s: Connection to " - "%.*s (at %s) was lost; in progress " - "operations using this service will fail\n", - imp->imp_obd->obd_name, - target_len, target_start, - libcfs_nid2str(imp->imp_connection->c_peer.nid)); - } - IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON); + obd_import_nid2str(imp)); + } else { + LCONSOLE_ERROR_MSG(0x166, "%s: Connection to " + "%.*s (at %s) was lost; in progress " + "operations using this service will fail\n", + imp->imp_obd->obd_name, target_len, target_start, + obd_import_nid2str(imp)); + } + IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON); spin_unlock(&imp->imp_lock); if (obd_dump_on_timeout) @@ -1535,7 +1534,7 @@ int ptlrpc_import_recovery_state_machine(struct obd_import *imp) LCONSOLE_INFO("%s: Connection restored to %s (at %s)\n", imp->imp_obd->obd_name, obd_uuid2str(&conn->c_remote_uuid), - libcfs_nid2str(imp->imp_connection->c_peer.nid)); + obd_import_nid2str(imp)); } if (imp->imp_state == LUSTRE_IMP_FULL) { -- 1.8.3.1