From: yury Date: Mon, 12 Jun 2006 18:59:46 +0000 (+0000) Subject: - cleanups in FLD, added client API and server API X-Git-Tag: v1_8_0_110~486^2~1640 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=b59acca8c981e4bfed5ceccf994a0b58f577afc3;p=fs%2Flustre-release.git - cleanups in FLD, added client API and server API --- diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index 4c1aa6d..cec62e5 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -99,9 +99,9 @@ seq_client_alloc_super(struct lu_client_seq *seq) rc = seq_client_alloc_common(seq, &seq->seq_cl_range, SEQ_ALLOC_SUPER); if (rc == 0) { - CWARN("SEQ-MGR(cli): allocated super-sequence " - "["LPX64"-"LPX64"]\n", seq->seq_cl_range.lr_start, - seq->seq_cl_range.lr_end); + CDEBUG(D_INFO, "SEQ-MGR(cli): allocated super-sequence " + "["LPX64"-"LPX64"]\n", seq->seq_cl_range.lr_start, + seq->seq_cl_range.lr_end); } RETURN(rc); } @@ -118,9 +118,9 @@ seq_client_alloc_meta(struct lu_client_seq *seq) rc = seq_client_alloc_common(seq, &seq->seq_cl_range, SEQ_ALLOC_META); if (rc == 0) { - CWARN("SEQ-MGR(cli): allocated meta-sequence " - "["LPX64"-"LPX64"]\n", seq->seq_cl_range.lr_start, - seq->seq_cl_range.lr_end); + CDEBUG(D_INFO, "SEQ-MGR(cli): allocated meta-sequence " + "["LPX64"-"LPX64"]\n", seq->seq_cl_range.lr_start, + seq->seq_cl_range.lr_end); } RETURN(rc); } @@ -159,8 +159,8 @@ seq_client_alloc_seq(struct lu_client_seq *seq, __u64 *seqnr) up(&seq->seq_sem); if (rc == 0) { - CWARN("SEQ-MGR(cli): allocated sequence " - "["LPX64"]\n", *seqnr); + CDEBUG(D_INFO, "SEQ-MGR(cli): allocated sequence " + "["LPX64"]\n", *seqnr); } RETURN(rc); } @@ -200,8 +200,8 @@ seq_client_alloc_fid(struct lu_client_seq *seq, struct lu_fid *fid) } LASSERT(fid_is_sane(fid)); - CWARN("SEQ-MGR(cli): allocated FID "DFID3"\n", - PFID3(fid)); + CDEBUG(D_INFO, "SEQ-MGR(cli): allocated FID "DFID3"\n", + PFID3(fid)); EXIT; out: @@ -264,7 +264,7 @@ out: if (rc) seq_client_fini(seq); else - CWARN("Client Sequence Manager initialized\n"); + CDEBUG(D_INFO, "Client Sequence Manager initialized\n"); return rc; } EXPORT_SYMBOL(seq_client_init); @@ -276,7 +276,7 @@ void seq_client_fini(struct lu_client_seq *seq) class_export_put(seq->seq_exp); seq->seq_exp = NULL; } - CWARN("Client Sequence Manager finalized\n"); + CDEBUG(D_INFO, "Client Sequence Manager finalized\n"); EXIT; } EXPORT_SYMBOL(seq_client_fini); @@ -345,9 +345,9 @@ seq_server_alloc_super(struct lu_server_seq *seq, } if (rc == 0) { - CWARN("SEQ-MGR(srv): allocated super-sequence " - "["LPX64"-"LPX64"]\n", range->lr_start, - range->lr_end); + CDEBUG(D_INFO, "SEQ-MGR(srv): allocated super-sequence " + "["LPX64"-"LPX64"]\n", range->lr_start, + range->lr_end); } RETURN(rc); @@ -394,9 +394,9 @@ seq_server_alloc_meta(struct lu_server_seq *seq, range->lr_end = ms_range->lr_start; if (rc == 0) { - CWARN("SEQ-MGR(srv): allocated meta-sequence " - "["LPX64"-"LPX64"]\n", range->lr_start, - range->lr_end); + CDEBUG(D_INFO, "SEQ-MGR(srv): allocated meta-sequence " + "["LPX64"-"LPX64"]\n", range->lr_start, + range->lr_end); } RETURN(rc); @@ -602,7 +602,7 @@ out: if (rc) seq_server_fini(seq, ctx); else - CWARN("Server Sequence Manager initialized\n"); + CDEBUG(D_INFO, "Server Sequence Manager initialized\n"); return rc; } EXPORT_SYMBOL(seq_server_init); @@ -628,14 +628,14 @@ seq_server_fini(struct lu_server_seq *seq, seq->seq_dev = NULL; } - CWARN("Server Sequence Manager finalized\n"); + CDEBUG(D_INFO, "Server Sequence Manager finalized\n"); } EXPORT_SYMBOL(seq_server_fini); static int fid_init(void) { ENTRY; - CWARN("Lustre Sequence Manager\n"); + CDEBUG(D_INFO, "Lustre Sequence Manager\n"); RETURN(0); } diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index 3a3dbe8..fb4c35c 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -50,28 +50,7 @@ #include #include "fld_internal.h" -static int dht_mdt_hash(__u64 seq) -{ - return 0; -} - -struct obd_export * -get_fld_exp(struct obd_export *exp, __u64 seq) -{ - int seq_mds; - - seq_mds = dht_mdt_hash(seq); - CDEBUG(D_INFO, "mds number %d\n", seq_mds); - - /* get exp according to lu_seq */ - return exp; -} - #ifdef __KERNEL__ -static int fld_handle(const struct lu_context *ctx, - struct lu_fld *fld, __u32 opts, - struct md_fld *mf); - /* XXX: maybe these 2 items should go to sbi */ struct fld_cache_info *fld_cache = NULL; @@ -170,7 +149,50 @@ fld_cache_delete(struct fld_cache_info *fld_cache, __u64 lu_seq) } #endif -static int fld_rpc(struct obd_export *exp, struct md_fld *mf, __u32 fld_op) +static int dht_mdt_hash(__u64 seq) +{ + return 0; +} + +static struct obd_export * +fld_client_get_exp(struct lu_client_fld *fld, __u64 seq) +{ + int seq_mds; + + seq_mds = dht_mdt_hash(seq); + CDEBUG(D_INFO, "mds number %d\n", seq_mds); + + /* XXX: get exp according to lu_seq */ + return fld->fld_exp; +} + +int fld_client_init(struct lu_client_fld *fld, + struct obd_export *exp) +{ + int rc = 0; + ENTRY; + + LASSERT(exp != NULL); + fld->fld_exp = class_export_get(exp); + CDEBUG(D_INFO, "Client FLD initialized\n"); + + RETURN(rc); +} + +void fld_client_fini(struct lu_client_fld *fld) +{ + ENTRY; + if (fld->fld_exp != NULL) { + class_export_put(fld->fld_exp); + fld->fld_exp = NULL; + } + CDEBUG(D_INFO, "Client FLD finalized\n"); + EXIT; +} + +static int +fld_client_rpc(struct obd_export *exp, + struct md_fld *mf, __u32 fld_op) { struct ptlrpc_request *req; struct md_fld *pmf; @@ -179,8 +201,9 @@ static int fld_rpc(struct obd_export *exp, struct md_fld *mf, __u32 fld_op) int size[2] = {sizeof(*op), mf_size}, rc; ENTRY; - req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION, - FLD_QUERY, 2, size, NULL); + req = ptlrpc_prep_req(class_exp2cliimp(exp), + LUSTRE_MDS_VERSION, FLD_QUERY, + 2, size, NULL); if (req == NULL) RETURN(-ENOMEM); @@ -196,7 +219,8 @@ static int fld_rpc(struct obd_export *exp, struct md_fld *mf, __u32 fld_op) if (rc) GOTO(out_req, rc); - pmf = lustre_swab_repbuf(req, 0, sizeof(*pmf), lustre_swab_md_fld); + pmf = lustre_swab_repbuf(req, 0, sizeof(*pmf), + lustre_swab_md_fld); *mf = *pmf; out_req: ptlrpc_req_finished(req); @@ -204,21 +228,22 @@ out_req: } int -fld_create(struct obd_export *exp, __u64 seq, __u64 mds_num) +fld_client_create(struct lu_client_fld *fld, + __u64 seq, __u64 mds_num) { struct obd_export *fld_exp; struct md_fld md_fld; __u32 rc; ENTRY; - fld_exp = get_fld_exp(exp, seq); + fld_exp = fld_client_get_exp(fld, seq); if (!fld_exp) RETURN(-EINVAL); md_fld.mf_seq = seq; md_fld.mf_mds = mds_num; - rc = fld_rpc(fld_exp, &md_fld, FLD_CREATE); + rc = fld_client_rpc(fld_exp, &md_fld, FLD_CREATE); #ifdef __KERNEL__ fld_cache_insert(fld_cache, seq, mds_num); @@ -228,7 +253,8 @@ fld_create(struct obd_export *exp, __u64 seq, __u64 mds_num) } int -fld_delete(struct obd_export *exp, __u64 seq, __u64 mds_num) +fld_client_delete(struct lu_client_fld *fld, + __u64 seq, __u64 mds_num) { struct obd_export *fld_exp; struct md_fld md_fld; @@ -238,32 +264,33 @@ fld_delete(struct obd_export *exp, __u64 seq, __u64 mds_num) fld_cache_delete(fld_cache, seq); #endif - fld_exp = get_fld_exp(exp, seq); + fld_exp = fld_client_get_exp(fld, seq); if (!fld_exp) RETURN(-EINVAL); md_fld.mf_seq = seq; md_fld.mf_mds = mds_num; - rc = fld_rpc(fld_exp, &md_fld, FLD_DELETE); + rc = fld_client_rpc(fld_exp, &md_fld, FLD_DELETE); RETURN(rc); } int -fld_get(struct obd_export *exp, __u64 lu_seq, __u64 *mds_num) +fld_client_get(struct lu_client_fld *fld, + __u64 lu_seq, __u64 *mds_num) { struct obd_export *fld_exp; struct md_fld md_fld; int vallen, rc; - fld_exp = get_fld_exp(exp, lu_seq); + fld_exp = fld_client_get_exp(fld, lu_seq); if (!fld_exp); RETURN(-EINVAL); md_fld.mf_seq = lu_seq; vallen = sizeof(struct md_fld); - rc = fld_rpc(fld_exp, &md_fld, FLD_GET); + rc = fld_client_rpc(fld_exp, &md_fld, FLD_GET); if (rc == 0) *mds_num = md_fld.mf_mds; @@ -272,23 +299,24 @@ fld_get(struct obd_export *exp, __u64 lu_seq, __u64 *mds_num) /* lookup fid in the namespace of pfid according to the name */ int -fld_lookup(struct obd_export *exp, __u64 lu_seq, __u64 *mds_num) +fld_client_lookup(struct lu_client_fld *fld, + __u64 lu_seq, __u64 *mds_num) { - struct fld_cache *fld; + struct fld_cache *fld_entry; int rc; ENTRY; #ifdef __KERNEL__ /* lookup it in the cache */ - fld = fld_cache_lookup(fld_cache, lu_seq); - if (fld != NULL) { - *mds_num = fld->fld_mds; + fld_entry = fld_cache_lookup(fld_cache, lu_seq); + if (fld_entry != NULL) { + *mds_num = fld_entry->fld_mds; RETURN(0); } #endif /* can not find it in the cache */ - rc = fld_get(exp, lu_seq, mds_num); + rc = fld_client_get(fld, lu_seq, mds_num); if (rc) RETURN(rc); @@ -343,8 +371,35 @@ static void __exit fld_mod_exit(void) static struct fld_list fld_list_head; static int +fld_server_handle(struct lu_server_fld *fld, + const struct lu_context *ctx, + __u32 opts, struct md_fld *mf) +{ + int rc; + ENTRY; + + switch (opts) { + case FLD_CREATE: + rc = fld_handle_insert(fld, ctx, mf->mf_seq, mf->mf_mds); + break; + case FLD_DELETE: + rc = fld_handle_delete(fld, ctx, mf->mf_seq); + break; + case FLD_GET: + rc = fld_handle_lookup(fld, ctx, mf->mf_seq, &mf->mf_mds); + break; + default: + rc = -EINVAL; + break; + } + RETURN(rc); + +} + +static int fld_req_handle0(const struct lu_context *ctx, - struct lu_fld *fld, struct ptlrpc_request *req) + struct lu_server_fld *fld, + struct ptlrpc_request *req) { struct md_fld *in; struct md_fld *out; @@ -367,7 +422,7 @@ fld_req_handle0(const struct lu_context *ctx, LASSERT(out != NULL); *out = *in; - rc = fld_handle(ctx, fld, *opt, out); + rc = fld_server_handle(fld, ctx, *opt, out); } else { CERROR("Cannot unpack mf\n"); } @@ -416,8 +471,8 @@ out: } int -fld_server_init(const struct lu_context *ctx, - struct lu_fld *fld, +fld_server_init(struct lu_server_fld *fld, + const struct lu_context *ctx, struct dt_device *dt) { int result; @@ -437,7 +492,7 @@ fld_server_init(const struct lu_context *ctx, INIT_LIST_HEAD(&fld_list_head.fld_list); spin_lock_init(&fld_list_head.fld_lock); - result = fld_iam_init(ctx, fld); + result = fld_iam_init(fld, ctx); if (result == 0) { fld->fld_service = @@ -452,14 +507,16 @@ fld_server_init(const struct lu_context *ctx, } if (result != 0) - fld_server_fini(ctx, fld); + fld_server_fini(fld, ctx); + else + CDEBUG(D_INFO, "Server FLD initialized\n"); return result; } EXPORT_SYMBOL(fld_server_init); void -fld_server_fini(const struct lu_context *ctx, - struct lu_fld *fld) +fld_server_fini(struct lu_server_fld *fld, + const struct lu_context *ctx) { struct list_head *pos, *n; @@ -478,40 +535,16 @@ fld_server_fini(const struct lu_context *ctx, spin_unlock(&fld_list_head.fld_lock); if (fld->fld_dt != NULL) { lu_device_put(&fld->fld_dt->dd_lu_dev); - fld_iam_fini(ctx, fld); + fld_iam_fini(fld, ctx); fld->fld_dt = NULL; } + CDEBUG(D_INFO, "Server FLD finalized\n"); } EXPORT_SYMBOL(fld_server_fini); -static int -fld_handle(const struct lu_context *ctx, - struct lu_fld *fld, __u32 opts, struct md_fld *mf) -{ - int rc; - ENTRY; - - switch (opts) { - case FLD_CREATE: - rc = fld_handle_insert(ctx, fld, mf->mf_seq, mf->mf_mds); - break; - case FLD_DELETE: - rc = fld_handle_delete(ctx, fld, mf->mf_seq); - break; - case FLD_GET: - rc = fld_handle_lookup(ctx, fld, mf->mf_seq, &mf->mf_mds); - break; - default: - rc = -EINVAL; - break; - } - RETURN(rc); - -} - MODULE_AUTHOR("Cluster File Systems, Inc. "); -MODULE_DESCRIPTION("Lustre fld Prototype"); +MODULE_DESCRIPTION("Lustre FLD"); MODULE_LICENSE("GPL"); -cfs_module(mdd, "0.0.3", fld_mod_init, fld_mod_exit); +cfs_module(mdd, "0.0.4", fld_mod_init, fld_mod_exit); #endif diff --git a/lustre/fld/fld_iam.c b/lustre/fld/fld_iam.c index 3f9186d..50d9b53 100644 --- a/lustre/fld/fld_iam.c +++ b/lustre/fld/fld_iam.c @@ -118,7 +118,8 @@ static struct dt_rec *fld_rec(const struct lu_context *ctx, return (void *)&info->fti_rec; } -int fld_handle_insert(const struct lu_context *ctx, struct lu_fld *fld, +int fld_handle_insert(struct lu_server_fld *fld, + const struct lu_context *ctx, fidseq_t seq_num, mdsno_t mds_num) { struct dt_device *dt = fld->fld_dt; @@ -141,7 +142,8 @@ int fld_handle_insert(const struct lu_context *ctx, struct lu_fld *fld, RETURN(rc); } -int fld_handle_delete(const struct lu_context *ctx, struct lu_fld *fld, +int fld_handle_delete(struct lu_server_fld *fld, + const struct lu_context *ctx, fidseq_t seq_num) { struct dt_device *dt = fld->fld_dt; @@ -160,8 +162,9 @@ int fld_handle_delete(const struct lu_context *ctx, struct lu_fld *fld, RETURN(rc); } -int fld_handle_lookup(const struct lu_context *ctx, - struct lu_fld *fld, fidseq_t seq_num, mdsno_t *mds_num) +int fld_handle_lookup(struct lu_server_fld *fld, + const struct lu_context *ctx, + fidseq_t seq_num, mdsno_t *mds_num) { int result; @@ -175,7 +178,8 @@ int fld_handle_lookup(const struct lu_context *ctx, return result; } -int fld_iam_init(const struct lu_context *ctx, struct lu_fld *fld) +int fld_iam_init(struct lu_server_fld *fld, + const struct lu_context *ctx) { struct dt_device *dt = fld->fld_dt; struct dt_object *dt_obj; @@ -218,7 +222,8 @@ int fld_iam_init(const struct lu_context *ctx, struct lu_fld *fld) RETURN(rc); } -void fld_iam_fini(const struct lu_context *ctx, struct lu_fld *fld) +void fld_iam_fini(struct lu_server_fld *fld, + const struct lu_context *ctx) { if (!IS_ERR(fld->fld_cookie) && fld->fld_cookie != NULL) { fld->fld_dt->dd_ops->dt_index_fini(ctx, fld->fld_cookie); diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index 6822d91..aa30b85 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -66,14 +66,22 @@ enum fld_op { #define FLD_SERVICE_WATCHDOG_TIMEOUT (obd_timeout * 1000) -int fld_handle_insert(const struct lu_context *ctx, - struct lu_fld *fld, fidseq_t seq_num, mdsno_t mdsno); -int fld_handle_delete(const struct lu_context *ctx, - struct lu_fld *fld, fidseq_t seq_num); -int fld_handle_lookup(const struct lu_context *ctx, - struct lu_fld *fld, fidseq_t seq_num, mdsno_t *mds); +int fld_handle_insert(struct lu_server_fld *fld, + const struct lu_context *ctx, + fidseq_t seq_num, mdsno_t mdsno); -int fld_iam_init(const struct lu_context *ctx, struct lu_fld *fld); -void fld_iam_fini(const struct lu_context *ctx, struct lu_fld *fld); +int fld_handle_delete(struct lu_server_fld *fld, + const struct lu_context *ctx, + fidseq_t seq_num); + +int fld_handle_lookup(struct lu_server_fld *fld, + const struct lu_context *ctx, + fidseq_t seq_num, mdsno_t *mds); + +int fld_iam_init(struct lu_server_fld *fld, + const struct lu_context *ctx); + +void fld_iam_fini(struct lu_server_fld *fld, + const struct lu_context *ctx); #endif diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 5c0eaf6..26d6eed 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -429,15 +429,15 @@ struct lu_site { * * yes, it's heavy. */ - spinlock_t ls_guard; + spinlock_t ls_guard; /* * Hash-table where objects are indexed by fid. */ - struct hlist_head *ls_hash; + struct hlist_head *ls_hash; /* * Bit-mask for hash-table size. */ - int ls_hash_mask; + int ls_hash_mask; /* @@ -448,27 +448,27 @@ struct lu_site { * the ->ls_lru.prev (this is due to the non-existence of * list_for_each_entry_safe_reverse()). */ - struct list_head ls_lru; + struct list_head ls_lru; /* * Total number of objects in this site. Protected by ->ls_guard. */ - unsigned ls_total; + unsigned ls_total; /* * Total number of objects in this site with reference counter greater * than 0. Protected by ->ls_guard. */ - unsigned ls_busy; + unsigned ls_busy; /* * Top-level device for this stack. */ - struct lu_device *ls_top_dev; + struct lu_device *ls_top_dev; /* current server index */ - __u32 ls_node_id; + __u32 ls_node_id; /* * Fid location database */ - struct lu_fld *ls_fld; + struct lu_server_fld *ls_fld; /* * Server Seq Manager diff --git a/lustre/include/lustre_fld.h b/lustre/include/lustre_fld.h index a468a4b..eeee541 100644 --- a/lustre/include/lustre_fld.h +++ b/lustre/include/lustre_fld.h @@ -22,10 +22,11 @@ #ifndef __LINUX_FLD_H #define __LINUX_FLD_H + /* - * fld (fid location database) interface. + * FLD (Fid Location Database) interface. */ -struct lu_fld { +struct lu_server_fld { struct proc_dir_entry *fld_proc_entry; struct ptlrpc_service *fld_service; struct dt_device *fld_dt; @@ -34,8 +35,35 @@ struct lu_fld { struct dt_index_cookie *fld_cookie; }; -int fld_server_init(const struct lu_context *ctx, struct lu_fld *fld, - struct dt_device *dt); -void fld_server_fini(const struct lu_context *ctx, struct lu_fld *fld); +struct lu_client_fld { + struct proc_dir_entry *fld_proc_entry; + struct obd_export *fld_exp; +}; + +/* server methods */ +int fld_server_init(struct lu_server_fld *fld, + const struct lu_context *ctx, + struct dt_device *dt); + +void fld_server_fini(struct lu_server_fld *fld, + const struct lu_context *ctx); + +/* client methods */ +int fld_client_init(struct lu_client_fld *fld, + struct obd_export *exp); + +void fld_client_fini(struct lu_client_fld *fld); + +int fld_client_create(struct lu_client_fld *fld, + __u64 seq, __u64 mds_num); + +int fld_client_delete(struct lu_client_fld *fld, + __u64 seq, __u64 mds_num); + +int fld_client_get(struct lu_client_fld *fld, + __u64 lu_seq, __u64 *mds_num); + +int fld_client_lookup(struct lu_client_fld *fld, + __u64 lu_seq, __u64 *mds_num); #endif diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index a742aba..e0f69c3 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1590,7 +1590,7 @@ static int mdt_fld_init(const struct lu_context *ctx, struct mdt_device *m) OBD_ALLOC_PTR(ls->ls_fld); if (ls->ls_fld != NULL) - rc = fld_server_init(ctx, ls->ls_fld, m->mdt_bottom); + rc = fld_server_init(ls->ls_fld, ctx, m->mdt_bottom); else rc = -ENOMEM; @@ -1603,7 +1603,7 @@ static int mdt_fld_fini(const struct lu_context *ctx, struct mdt_device *m) ENTRY; if (ls && ls->ls_fld) { - fld_server_fini(ctx, ls->ls_fld); + fld_server_fini(ls->ls_fld, ctx); OBD_FREE_PTR(ls->ls_fld); } RETURN(0);