X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ffld%2Ffld_handler.c;h=9d6d1380aaee642c3697c2740dc81226e5b22072;hp=0ee6852c9365168fac6922d3d22500a351047d2b;hb=c50a9e2ae39df781598696dae4f33d60199a84dd;hpb=b36763df4f2b3695766e90598f9435a814cc10d0 diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 0ee6852..9d6d138 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -44,63 +44,38 @@ #define DEBUG_SUBSYSTEM S_FLD -#ifdef __KERNEL__ -# include -# include -# include -# include -#else /* __KERNEL__ */ -# include -# include -#endif +#include +#include #include -#include -#include #include -#include - -#include #include +#include +#include /* err_serious() */ #include +#include #include "fld_internal.h" -#include - -#ifdef __KERNEL__ /* context key constructor/destructor: fld_key_init, fld_key_fini */ LU_KEY_INIT_FINI(fld, struct fld_thread_info); /* context key: fld_thread_key */ -LU_CONTEXT_KEY_DEFINE(fld, LCT_MD_THREAD|LCT_DT_THREAD); - -cfs_proc_dir_entry_t *fld_type_proc_dir = NULL; +LU_CONTEXT_KEY_DEFINE(fld, LCT_MD_THREAD | LCT_DT_THREAD | LCT_MG_THREAD); -static int __init fld_mod_init(void) +int fld_server_mod_init(void) { - fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME, - proc_lustre_root, - NULL, NULL); - if (IS_ERR(fld_type_proc_dir)) - return PTR_ERR(fld_type_proc_dir); - - LU_CONTEXT_KEY_INIT(&fld_thread_key); - lu_context_key_register(&fld_thread_key); - return 0; + LU_CONTEXT_KEY_INIT(&fld_thread_key); + return lu_context_key_register(&fld_thread_key); } -static void __exit fld_mod_exit(void) +void fld_server_mod_exit(void) { - lu_context_key_degister(&fld_thread_key); - if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) { - lprocfs_remove(&fld_type_proc_dir); - fld_type_proc_dir = NULL; - } + lu_context_key_degister(&fld_thread_key); } int fld_declare_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *range, + const struct lu_seq_range *range, struct thandle *th) { int rc; @@ -117,7 +92,7 @@ EXPORT_SYMBOL(fld_declare_server_create); * is granted to a server. */ int fld_server_create(const struct lu_env *env, struct lu_server_fld *fld, - struct lu_seq_range *range, struct thandle *th) + const struct lu_seq_range *range, struct thandle *th) { int rc; @@ -136,37 +111,37 @@ EXPORT_SYMBOL(fld_server_create); * sequence controller node (MDT0). All other MDT[1...N] and client * cache fld entries, but this cache is not persistent. */ - int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld, seqno_t seq, struct lu_seq_range *range) { - struct lu_seq_range *erange; - struct fld_thread_info *info; - int rc; - ENTRY; + struct lu_seq_range *erange; + struct fld_thread_info *info; + int rc; + ENTRY; - info = lu_context_key_get(&env->le_ctx, &fld_thread_key); - erange = &info->fti_lrange; - - /* Lookup it in the cache. */ - rc = fld_cache_lookup(fld->lsf_cache, seq, erange); - if (rc == 0) { - if (unlikely(erange->lsr_flags != range->lsr_flags) && - range->lsr_flags != -1) { - CERROR("FLD cache found a range "DRANGE" doesn't " - "match the requested flag %x\n", - PRANGE(erange), range->lsr_flags); - RETURN(-EIO); - } - *range = *erange; - RETURN(0); - } + info = lu_context_key_get(&env->le_ctx, &fld_thread_key); + LASSERT(info != NULL); + erange = &info->fti_lrange; + + /* Lookup it in the cache. */ + rc = fld_cache_lookup(fld->lsf_cache, seq, erange); + if (rc == 0) { + if (unlikely(fld_range_type(erange) != fld_range_type(range) && + !fld_range_is_any(range))) { + CERROR("%s: FLD cache range "DRANGE" does not match" + "requested flag %x: rc = %d\n", fld->lsf_name, + PRANGE(erange), range->lsr_flags, -EIO); + RETURN(-EIO); + } + *range = *erange; + RETURN(0); + } if (fld->lsf_obj) { /* On server side, all entries should be in cache. * If we can not find it in cache, just return error */ - CERROR("%s: Can not found the seq "LPX64"\n", - fld->lsf_name, seq); + CERROR("%s: Cannot find sequence "LPX64": rc = %d\n", + fld->lsf_name, seq, -EIO); RETURN(-EIO); } else { LASSERT(fld->lsf_control_exp); @@ -239,22 +214,21 @@ static int fld_req_handle(struct ptlrpc_request *req, *out = *in; /* For old 2.0 client, the 'lsr_flags' is uninitialized. - * Set it as 'LU_SEQ_RANGE_MDT' by default. - * Old 2.0 liblustre client cannot talk with new 2.1 server. */ - if (!(exp->exp_connect_flags & OBD_CONNECT_64BITHASH) && - !((exp->exp_connect_flags & OBD_CONNECT_MDS) && - (exp->exp_connect_flags & OBD_CONNECT_FID)) && - !(exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) && + * Set it as 'LU_SEQ_RANGE_MDT' by default. */ + if (!(exp_connect_flags(exp) & OBD_CONNECT_64BITHASH) && + !(exp_connect_flags(exp) & OBD_CONNECT_MDS_MDS) && + !(exp_connect_flags(exp) & OBD_CONNECT_LIGHTWEIGHT) && !exp->exp_libclient) - out->lsr_flags = LU_SEQ_RANGE_MDT; + fld_range_set_mdt(out); rc = fld_server_handle(lu_site2seq(site)->ss_server_fld, req->rq_svc_thread->t_env, *opc, out, info); - } else + } else { rc = err_serious(-EPROTO); + } - RETURN(rc); + RETURN(rc); } static void fld_thread_info_init(struct ptlrpc_request *req, @@ -383,12 +357,11 @@ static void fld_server_proc_fini(struct lu_server_fld *fld) int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, struct dt_device *dt, const char *prefix, int mds_node_id, - __u32 lsr_flags) + int type) { - int cache_size, cache_threshold; - struct lu_seq_range range; - int rc; - ENTRY; + int cache_size, cache_threshold; + int rc; + ENTRY; snprintf(fld->lsf_name, sizeof(fld->lsf_name), "srv-%s", prefix); @@ -408,12 +381,13 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, GOTO(out, rc); } - if (!mds_node_id && lsr_flags == LU_SEQ_RANGE_MDT) { + if (!mds_node_id && type == LU_SEQ_RANGE_MDT) { rc = fld_index_init(env, fld, dt); if (rc) GOTO(out, rc); - } else + } else { fld->lsf_obj = NULL; + } rc = fld_server_proc_init(fld); if (rc) @@ -421,15 +395,8 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld, fld->lsf_control_exp = NULL; - /* Insert reserved sequence number of ".lustre" into fld cache. */ - if (lsr_flags == LU_SEQ_RANGE_MDT) { - range.lsr_start = FID_SEQ_DOT_LUSTRE; - range.lsr_end = FID_SEQ_DOT_LUSTRE + 1; - range.lsr_index = 0; - range.lsr_flags = lsr_flags; - fld_cache_insert(fld->lsf_cache, &range); - } - EXIT; + GOTO(out, rc); + out: if (rc) fld_server_fini(env, fld); @@ -453,10 +420,3 @@ void fld_server_fini(const struct lu_env *env, struct lu_server_fld *fld) EXIT; } EXPORT_SYMBOL(fld_server_fini); - -MODULE_AUTHOR("Sun Microsystems, Inc. "); -MODULE_DESCRIPTION("Lustre FLD"); -MODULE_LICENSE("GPL"); - -cfs_module(mdd, "0.1.0", fld_mod_init, fld_mod_exit); -#endif