From 33512ec9ce595b7bbe4006b2fc2371e3b4d66006 Mon Sep 17 00:00:00 2001 From: shadow <shadow> Date: Thu, 8 May 2008 09:55:12 +0000 Subject: [PATCH] don't panic with use echo client. b=14949 i=johan i=deen --- lustre/include/lprocfs_status.h | 5 +++-- lustre/ldlm/ldlm_lib.c | 6 +++--- lustre/mds/handler.c | 3 +-- lustre/mds/mds_fs.c | 13 +++++++------ lustre/mds/mds_internal.h | 2 +- lustre/obdclass/lprocfs_status.c | 19 +++++++++++-------- lustre/obdfilter/filter.c | 21 +++++++-------------- 7 files changed, 33 insertions(+), 36 deletions(-) diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 5b06fcee00..8aeed92cac 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -359,7 +359,7 @@ struct nid_stat; extern int lprocfs_add_clear_entry(struct obd_device * obd, cfs_proc_dir_entry_t *entry); extern int lprocfs_exp_setup(struct obd_export *exp, - lnet_nid_t peer_nid, int *newnid); + lnet_nid_t *peer_nid, int *newnid); extern int lprocfs_exp_cleanup(struct obd_export *exp); extern int lprocfs_add_simple(struct proc_dir_entry *root, char *name, read_proc_t *read_proc, @@ -585,7 +585,8 @@ static inline void lprocfs_free_obd_stats(struct obd_device *obddev) struct obd_export; static inline int lprocfs_add_clear_entry(struct obd_export *exp) { return 0; } -static inline int lprocfs_exp_setup(struct obd_export *exp) +static inline int lprocfs_exp_setup(struct obd_export *exp, + lnet_nid_t *peer_nid, int *newnid) { return 0; } static inline int lprocfs_exp_cleanup(struct obd_export *exp) { return 0; } diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index e188385e2e..1dcc960446 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -591,7 +591,7 @@ int target_handle_connect(struct ptlrpc_request *req) int rc = 0; int initial_conn = 0; struct obd_connect_data *data, *tmpdata; - lnet_nid_t client_nid = 0; + lnet_nid_t *client_nid = NULL; ENTRY; OBD_RACE(OBD_FAIL_TGT_CONN_RACE); @@ -791,7 +791,7 @@ int target_handle_connect(struct ptlrpc_request *req) /* Tell the client if we support replayable requests */ if (target->obd_replayable) lustre_msg_add_op_flags(req->rq_repmsg, MSG_CONNECT_REPLAYABLE); - client_nid = req->rq_peer.nid; + client_nid = &req->rq_peer.nid; if (export == NULL) { if (target->obd_recovering) { @@ -810,7 +810,7 @@ int target_handle_connect(struct ptlrpc_request *req) dont_check_exports: rc = obd_connect(req->rq_svc_thread->t_env, &conn, target, &cluuid, data, - &client_nid); + client_nid); } } else { rc = obd_reconnect(req->rq_svc_thread->t_env, diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 0f3fdf2b76..228890800f 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -319,7 +319,6 @@ static int mds_connect(const struct lu_env *env, struct obd_export *exp; struct mds_export_data *med; struct mds_client_data *mcd = NULL; - lnet_nid_t *client_nid = (lnet_nid_t *)localdata; int rc; ENTRY; @@ -356,7 +355,7 @@ static int mds_connect(const struct lu_env *env, memcpy(mcd->mcd_uuid, cluuid, sizeof(mcd->mcd_uuid)); med->med_mcd = mcd; - rc = mds_client_add(obd, exp, -1, *client_nid); + rc = mds_client_add(obd, exp, -1, localdata); GOTO(out, rc); out: diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 64549a3a6b..54c577e07e 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -50,14 +50,15 @@ static int mds_export_stats_init(struct obd_device *obd, struct obd_export *exp, - lnet_nid_t client_nid) + void *localdata) { int rc, num_stats, newnid; - rc = lprocfs_exp_setup(exp, client_nid, &newnid); + + rc = lprocfs_exp_setup(exp, localdata, &newnid); if (rc) return rc; - if (client_nid && newnid) { + if (newnid) { struct nid_stat *tmp = exp->exp_nid_stats; LASSERT(tmp != NULL); num_stats = (sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) + @@ -86,7 +87,7 @@ static int mds_export_stats_init(struct obd_device *obd, * mds_init_server_data() callsite needs to be fixed. */ int mds_client_add(struct obd_device *obd, struct obd_export *exp, - int cl_idx, lnet_nid_t client_nid) + int cl_idx, void *localdata) { struct mds_obd *mds = &obd->u.mds; struct mds_export_data *med = &exp->exp_mds_data; @@ -133,7 +134,7 @@ int mds_client_add(struct obd_device *obd, struct obd_export *exp, med->med_lr_off = le32_to_cpu(mds->mds_server_data->lsd_client_start) + (cl_idx * le16_to_cpu(mds->mds_server_data->lsd_client_size)); LASSERTF(med->med_lr_off > 0, "med_lr_off = %llu\n", med->med_lr_off); - mds_export_stats_init(obd, exp, client_nid); + mds_export_stats_init(obd, exp, localdata); if (new_client) { struct lvfs_run_ctxt saved; @@ -413,7 +414,7 @@ static int mds_init_server_data(struct obd_device *obd, struct file *file) } else { med = &exp->exp_mds_data; med->med_mcd = mcd; - rc = mds_client_add(obd, exp, cl_idx, 0); + rc = mds_client_add(obd, exp, cl_idx, NULL); LASSERTF(rc == 0, "rc = %d\n", rc); /* can't fail existing */ mcd = NULL; diff --git a/lustre/mds/mds_internal.h b/lustre/mds/mds_internal.h index 4ed5035971..f480a75f37 100644 --- a/lustre/mds/mds_internal.h +++ b/lustre/mds/mds_internal.h @@ -221,7 +221,7 @@ int mds_join_file(struct mds_update_record *rec, struct ptlrpc_request *req, /* mds/mds_fs.c */ int mds_client_add(struct obd_device *obd, struct obd_export *exp, - int cl_off, lnet_nid_t client_nid); + int cl_off, void *localdata); int mds_client_free(struct obd_export *exp); int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct lov_stripe_md **ea, struct obd_trans_info *oti); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 8f0ba51470..a8b4a184c9 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -1293,7 +1293,7 @@ int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer, } 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 *newnid) { int rc = 0; struct nid_stat *tmp = NULL, *tmp1; @@ -1306,7 +1306,10 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t nid, int *newnid) !exp->exp_obd->obd_nid_stats_hash_body) RETURN(-EINVAL); - if (!nid) + /* not test against zero because eric say: + * You may only test nid against another nid, or LNET_NID_ANY. Anything else is + * nonsense.*/ + if (!nid || *nid == LNET_NID_ANY) RETURN(0); obd = exp->exp_obd; @@ -1317,26 +1320,26 @@ int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t nid, int *newnid) if (tmp == NULL) RETURN(-ENOMEM); - tmp->nid = nid; + tmp->nid = *nid; tmp->nid_obd = exp->exp_obd; tmp->nid_exp_ref_count = 1; /* need live in hash after destroy export */ - tmp1= lustre_hash_findadd_unique(obd->obd_nid_stats_hash_body, &nid, + tmp1= lustre_hash_findadd_unique(obd->obd_nid_stats_hash_body, nid, &tmp->nid_hash); CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n", - tmp1, libcfs_nid2str(nid), tmp->nid_exp_ref_count); + tmp1, libcfs_nid2str(*nid), tmp->nid_exp_ref_count); if (tmp1 != tmp) { exp->exp_nid_stats = tmp1; GOTO(destroy_new, rc = 0); } /* not found - create */ - tmp->nid_proc = proc_mkdir(libcfs_nid2str(nid), + tmp->nid_proc = proc_mkdir(libcfs_nid2str(*nid), obd->obd_proc_exports_entry); if (!tmp->nid_proc) { CERROR("Error making export directory for" - " nid %s\n", libcfs_nid2str(nid)); - lustre_hash_delitem(obd->obd_nid_stats_hash_body, &nid, + " nid %s\n", libcfs_nid2str(*nid)); + lustre_hash_delitem(obd->obd_nid_stats_hash_body, nid, &tmp->nid_hash); GOTO(destroy_new, rc = -ENOMEM); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index a1597f3f22..583390dac8 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -184,7 +184,7 @@ static int lprocfs_init_rw_stats(struct obd_device *obd, plus the procfs overhead :( */ static int filter_export_stats_init(struct obd_device *obd, struct obd_export *exp, - lnet_nid_t client_nid) + void *client_nid) { struct filter_export_data *fed = &exp->exp_filter_data; struct proc_dir_entry *brw_entry; @@ -201,7 +201,7 @@ static int filter_export_stats_init(struct obd_device *obd, if (rc) RETURN(rc); - if (client_nid && newnid) { + if (newnid) { struct nid_stat *tmp = exp->exp_nid_stats; LASSERT(tmp != NULL); @@ -237,7 +237,7 @@ static int filter_export_stats_init(struct obd_device *obd, * Otherwise, we have just read the data from the last_rcvd file and * we know its offset. */ static int filter_client_add(struct obd_device *obd, struct obd_export *exp, - int cl_idx, lnet_nid_t client_nid) + int cl_idx) { struct filter_obd *filter = &obd->u.filter; struct filter_export_data *fed = &exp->exp_filter_data; @@ -801,8 +801,8 @@ static int filter_init_server_data(struct obd_device *obd, struct file * filp) fed = &exp->exp_filter_data; fed->fed_fcd = fcd; fed->fed_group = le32_to_cpu(fcd->fcd_group); - filter_export_stats_init(obd, exp, 0); - rc = filter_client_add(obd, exp, cl_idx, 0); + filter_export_stats_init(obd, exp, NULL); + rc = filter_client_add(obd, exp, cl_idx); /* can't fail for existing client */ LASSERTF(rc == 0, "rc = %d\n", rc); @@ -2554,7 +2554,6 @@ static int filter_connect(const struct lu_env *env, struct obd_export *exp; struct filter_export_data *fed; struct filter_client_data *fcd = NULL; - lnet_nid_t client_nid; __u32 group; int rc; ENTRY; @@ -2562,12 +2561,6 @@ static int filter_connect(const struct lu_env *env, if (conn == NULL || obd == NULL || cluuid == NULL) RETURN(-EINVAL); - if (localdata != NULL) - client_nid = *(lnet_nid_t *)localdata; - else - client_nid = 0ULL; - - rc = class_connect(conn, obd, cluuid); if (rc) RETURN(rc); @@ -2580,7 +2573,7 @@ static int filter_connect(const struct lu_env *env, if (rc) GOTO(cleanup, rc); - filter_export_stats_init(obd, exp, client_nid); + filter_export_stats_init(obd, exp, localdata); group = data->ocd_group; if (obd->obd_replayable) { OBD_ALLOC(fcd, sizeof(*fcd)); @@ -2592,7 +2585,7 @@ static int filter_connect(const struct lu_env *env, memcpy(fcd->fcd_uuid, cluuid, sizeof(fcd->fcd_uuid)); fed->fed_fcd = fcd; fed->fed_fcd->fcd_group = group; - rc = filter_client_add(obd, exp, -1, client_nid); + rc = filter_client_add(obd, exp, -1); if (rc) GOTO(cleanup, rc); } -- GitLab