From 65224bacf78ff7fdb8502bb1c2655223f6a1bb44 Mon Sep 17 00:00:00 2001 From: pravins Date: Wed, 26 Nov 2008 07:38:34 +0000 Subject: [PATCH] b=17785 i=Huang hua i=Rahul This patch contains llo API interface change. Now it allows to create object in specified path. Fixes bug in object create in directory other than "/" Adds llo unregister api. --- lustre/fid/fid_handler.c | 3 +++ lustre/fld/fld_handler.c | 1 + lustre/include/md_object.h | 5 ++++- lustre/mdd/mdd_device.c | 4 ++++ lustre/mdt/mdt_handler.c | 1 + lustre/obdclass/dt_object.c | 4 +++- lustre/obdclass/md_local_object.c | 37 +++++++++++++++++++++++++++---------- lustre/osd/osd_handler.c | 1 + lustre/osd/osd_oi.c | 2 +- 9 files changed, 45 insertions(+), 13 deletions(-) diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index 2b28571..9e3d7ad 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -586,6 +586,9 @@ static int __init fid_mod_init(void) static void __exit fid_mod_exit(void) { + llo_local_obj_unregister(&llod_seq_srv); + llo_local_obj_unregister(&llod_seq_ctl); + lu_context_key_degister(&seq_thread_key); if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) { lprocfs_remove(&seq_type_proc_dir); diff --git a/lustre/fld/fld_handler.c b/lustre/fld/fld_handler.c index a5809bc..0f6e7cc 100644 --- a/lustre/fld/fld_handler.c +++ b/lustre/fld/fld_handler.c @@ -101,6 +101,7 @@ static int __init fld_mod_init(void) static void __exit fld_mod_exit(void) { + llo_local_obj_unregister(&llod_fld_index); 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); diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 9202385..718e336 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -809,8 +809,10 @@ static inline int mdo_rename_tgt(const struct lu_env *env, struct dt_device; /** * Structure to hold object information. This is used to create object + * \pre llod_dir exist */ struct lu_local_obj_desc { + const char *llod_dir; const char *llod_name; __u32 llod_oid; int llod_is_index; @@ -846,7 +848,8 @@ struct md_object *llo_store_create(const struct lu_env *env, const char *objname, const struct lu_fid *fid); -int llo_local_obj_register(struct lu_local_obj_desc *); +void llo_local_obj_register(struct lu_local_obj_desc *); +void llo_local_obj_unregister(struct lu_local_obj_desc *); int llo_local_objects_setup(const struct lu_env *env, struct md_device * md, diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 3e7f17a..76ef1c6 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -510,6 +510,10 @@ static int __init mdd_mod_init(void) static void __exit mdd_mod_exit(void) { + llo_local_obj_unregister(&llod_capa_key); + llo_local_obj_unregister(&llod_mdd_orphan); + llo_local_obj_unregister(&llod_mdd_root); + class_unregister_type(LUSTRE_MDD_NAME); } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d9437f7..4e8333b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -5353,6 +5353,7 @@ static int __init mdt_mod_init(void) static void __exit mdt_mod_exit(void) { + llo_local_obj_unregister(&mdt_last_recv); class_unregister_type(LUSTRE_MDT_NAME); } diff --git a/lustre/obdclass/dt_object.c b/lustre/obdclass/dt_object.c index a4bbb9a..79c160e 100644 --- a/lustre/obdclass/dt_object.c +++ b/lustre/obdclass/dt_object.c @@ -313,7 +313,7 @@ static struct dt_object *dt_store_resolve(const struct lu_env *env, struct dt_thread_info *info = lu_context_key_get(&env->le_ctx, &dt_key); struct dt_find_hint *dfh = &info->dti_dfh; - struct dt_object *obj = dfh->dfh_o; + struct dt_object *obj; char *local = info->dti_buf; int result; @@ -331,6 +331,8 @@ static struct dt_object *dt_store_resolve(const struct lu_env *env, result = dt_path_parser(env, local, dt_find_entry, dfh); if (result != 0) obj = ERR_PTR(result); + else + obj = dfh->dfh_o; } } else { obj = ERR_PTR(result); diff --git a/lustre/obdclass/md_local_object.c b/lustre/obdclass/md_local_object.c index 919c284..7446cd8 100644 --- a/lustre/obdclass/md_local_object.c +++ b/lustre/obdclass/md_local_object.c @@ -135,7 +135,7 @@ static int llo_lookup(const struct lu_env *env, spec->sp_feat = NULL; spec->sp_cr_flags = 0; - spec->sp_cr_lookup = 1; + spec->sp_cr_lookup = 0; spec->sp_cr_mode = 0; spec->sp_ck_split = 0; @@ -148,6 +148,10 @@ static int llo_lookup(const struct lu_env *env, /** * Function to look up path component, this is passed to parsing * function. \see llo_store_resolve + * + * \retval rc returns error code for lookup or locate operation + * + * pointer to object is returned in data (lfh->lfh_pobj) */ static int llo_find_entry(const struct lu_env *env, const char *name, void *data) @@ -205,7 +209,7 @@ struct md_object *llo_store_resolve(const struct lu_env *env, struct llo_thread_info *info = llo_env_info(env); struct llo_find_hint *lfh = &info->lti_lfh; char *local = info->lti_buf; - struct md_object *obj = lfh->lfh_pobj; + struct md_object *obj; int result; strncpy(local, path, DT_MAX_PATH); @@ -224,6 +228,8 @@ struct md_object *llo_store_resolve(const struct lu_env *env, result = dt_path_parser(env, local, llo_find_entry, lfh); if (result != 0) obj = ERR_PTR(result); + else + obj = lfh->lfh_pobj; } } else { obj = ERR_PTR(result); @@ -367,19 +373,27 @@ EXPORT_SYMBOL(llo_store_create); /** * Register object for 'create on first mount' facility. + * objects are created in order of registration. */ -int llo_local_obj_register(struct lu_local_obj_desc *llod) +void llo_local_obj_register(struct lu_local_obj_desc *llod) { mutex_lock(&llo_lock); - list_add(&llod->llod_linkage, &llo_lobj_list); + list_add_tail(&llod->llod_linkage, &llo_lobj_list); mutex_unlock(&llo_lock); - - return 0; } EXPORT_SYMBOL(llo_local_obj_register); +void llo_local_obj_unregister(struct lu_local_obj_desc *llod) +{ + mutex_lock(&llo_lock); + list_del(&llod->llod_linkage); + mutex_unlock(&llo_lock); +} + +EXPORT_SYMBOL(llo_local_obj_unregister); + /** * Created registed objects. */ @@ -392,24 +406,26 @@ int llo_local_objects_setup(const struct lu_env *env, struct lu_fid *fid; struct lu_local_obj_desc *scan; struct md_object *mdo; + const char *dir; int rc = 0; fid = &info->lti_cfid; - mutex_lock(&llo_lock); list_for_each_entry(scan, &llo_lobj_list, llod_linkage) { - lu_local_obj_fid(fid, scan->llod_oid); + dir = ""; + if (scan->llod_dir) + dir = scan->llod_dir; if (scan->llod_is_index) mdo = llo_store_create_index(env, md, dt , - "", scan->llod_name, + dir, scan->llod_name, fid, scan->llod_feat); else mdo = llo_store_create(env, md, dt, - "", scan->llod_name, + dir, scan->llod_name, fid); if (IS_ERR(mdo) && PTR_ERR(mdo) != -EEXIST) { rc = PTR_ERR(mdo); @@ -444,4 +460,5 @@ int llo_global_init(void) void llo_global_fini(void) { lu_context_key_degister(&llod_key); + LASSERT(list_empty(&llo_lobj_list)); } diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index ff60505..2652d7e 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -3784,6 +3784,7 @@ static int __init osd_mod_init(void) static void __exit osd_mod_exit(void) { + llo_local_obj_unregister(&llod_osd_rem_obj_dir); class_unregister_type(LUSTRE_OSD_NAME); } diff --git a/lustre/osd/osd_oi.c b/lustre/osd/osd_oi.c index ad03c3c..5a43a54 100644 --- a/lustre/osd/osd_oi.c +++ b/lustre/osd/osd_oi.c @@ -123,7 +123,7 @@ static int osd_oi_index_create(struct osd_thread_info *info, oi_feat.dif_keysize_max = oi_descr[i].fid_size, mdo = llo_store_create_index(env, mdev, dev, - "/", name, + "", name, oi_fid, &oi_feat); if (IS_ERR(mdo)) -- 1.8.3.1