From 44f54d6b7e25319c2bcf7ade55906ceaa90d154a Mon Sep 17 00:00:00 2001 From: tappro Date: Thu, 3 Dec 2009 15:03:45 +0000 Subject: [PATCH] Branch b1_8 b=21430 i=rread i=johann seeds PRNG with current time on server, check export is connected before request handling --- lustre/include/obd_class.h | 1 + lustre/ldlm/ldlm_lib.c | 1 + lustre/mds/handler.c | 3 +-- lustre/mgs/mgs_handler.c | 2 +- lustre/obdclass/genops.c | 14 ++++++++++++++ lustre/obdclass/lustre_handles.c | 7 +++++++ lustre/ost/ost_handler.c | 3 +-- 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index c70135f..5e812a2 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -222,6 +222,7 @@ int class_connect(struct lustre_handle *conn, struct obd_device *obd, struct obd_uuid *cluuid); int class_disconnect(struct obd_export *exp); void class_fail_export(struct obd_export *exp); +int class_connected_export(struct obd_export *exp); void class_disconnect_exports(struct obd_device *obddev); void class_set_export_delayed(struct obd_export *exp); void class_handle_stale_exports(struct obd_device *obddev); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 2a71dba..a0e8768 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -999,6 +999,7 @@ no_export: spin_unlock(&export->exp_lock); GOTO(out, rc = -EALREADY); } + LASSERT(lustre_msg_get_conn_cnt(req->rq_reqmsg) > 0); export->exp_conn_cnt = lustre_msg_get_conn_cnt(req->rq_reqmsg); export->exp_abort_active_req = 0; diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index a7e841c..68e2256 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1501,12 +1501,11 @@ int mds_handle(struct ptlrpc_request *req) RETURN(rc); } - /* XXX identical to OST */ if (lustre_msg_get_opc(req->rq_reqmsg) != MDS_CONNECT) { struct mds_export_data *med; int recovering; - if (req->rq_export == NULL) { + if (!class_connected_export(req->rq_export)) { CERROR("operation %d on unconnected MDS from %s\n", lustre_msg_get_opc(req->rq_reqmsg), libcfs_id2str(req->rq_peer)); diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 4e6630a..f8b7892 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -549,7 +549,7 @@ int mgs_handle(struct ptlrpc_request *req) LASSERT(current->journal_info == NULL); opc = lustre_msg_get_opc(req->rq_reqmsg); if (opc != MGS_CONNECT) { - if (req->rq_export == NULL) { + if (!class_connected_export(req->rq_export)) { CERROR("lustre_mgs: operation %d on unconnected MGS\n", opc); req->rq_status = -ENOTCONN; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 1f7df29..3136e66 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -985,6 +985,20 @@ no_disconn: RETURN(0); } +/* Return non-zero for a fully connected export */ +int class_connected_export(struct obd_export *exp) +{ + if (exp) { + int connected; + spin_lock(&exp->exp_lock); + connected = (exp->exp_conn_cnt > 0); + spin_unlock(&exp->exp_lock); + return connected; + } + return 0; +} +EXPORT_SYMBOL(class_connected_export); + static void class_disconnect_export_list(struct list_head *list, enum obd_option flags) { diff --git a/lustre/obdclass/lustre_handles.c b/lustre/obdclass/lustre_handles.c index d320889..28261fd 100644 --- a/lustre/obdclass/lustre_handles.c +++ b/lustre/obdclass/lustre_handles.c @@ -206,6 +206,8 @@ void class_handle_free_cb(struct rcu_head *rcu) int class_handle_init(void) { struct handle_bucket *bucket; + struct timeval tv; + int seed[2]; LASSERT(handle_hash == NULL); @@ -220,6 +222,11 @@ int class_handle_init(void) spin_lock_init(&bucket->lock); } + /** bug 21430: add randomness to the initial base */ + ll_get_random_bytes(seed, sizeof(seed)); + do_gettimeofday(&tv); + ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + ll_get_random_bytes(&handle_base, sizeof(handle_base)); LASSERT(handle_base != 0ULL); diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index 5b0fd15..b5c6a4d 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1771,11 +1771,10 @@ static int ost_handle(struct ptlrpc_request *req) ENTRY; LASSERT(current->journal_info == NULL); - /* XXX identical to MDS */ if (lustre_msg_get_opc(req->rq_reqmsg) != OST_CONNECT) { int recovering; - if (req->rq_export == NULL) { + if (!class_connected_export(req->rq_export)) { CDEBUG(D_HA,"operation %d on unconnected OST from %s\n", lustre_msg_get_opc(req->rq_reqmsg), libcfs_id2str(req->rq_peer)); -- 1.8.3.1