From: Alex Zhuravlev Date: Tue, 14 Aug 2012 17:35:34 +0000 (+0400) Subject: LU-1301 mgs: osd api based setup X-Git-Tag: 2.3.51~50 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=a3c6722c8b105ac201e3d3469e396d91159cbf84 LU-1301 mgs: osd api based setup Add new mgs_fs_setup() and mgs_fs_cleanup() routines to initialize local objects using OSD API. The corresponding old mgs_fs_setup() and mgs_fs_cleanup() routines are still called so that lvfs-based functions still work during the transition. Signed-off-by: Alex Zhuravlev Change-Id: Ib4bb83e6f8b3e5146363197b9793a810a9242b19 Reviewed-on: http://review.whamcloud.com/3675 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Mike Pershin --- diff --git a/lustre/mgs/mgs_fs.c b/lustre/mgs/mgs_fs.c index 3b57c67..6bab713 100644 --- a/lustre/mgs/mgs_fs.c +++ b/lustre/mgs/mgs_fs.c @@ -54,6 +54,7 @@ #include #include #include +#include #include "mgs_internal.h" int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp, @@ -143,7 +144,7 @@ struct lvfs_callback_ops mgs_lvfs_ops = { l_fid2dentry: mgs_lvfs_fid2dentry, }; -int mgs_fs_setup(const struct lu_env *env, struct mgs_device *mgs) +int mgs_fs_setup_old(const struct lu_env *env, struct mgs_device *mgs) { struct obd_device *obd = mgs->mgs_obd; struct dt_device_param p; @@ -192,7 +193,7 @@ int mgs_fs_setup(const struct lu_env *env, struct mgs_device *mgs) MOUNT_CONFIGS_DIR, rc); GOTO(err_pop, rc); } - mgs->mgs_configs_dir = dentry; + mgs->mgs_configs_dir_old = dentry; /* create directory to store nid table versions */ dentry = simple_mkdir(cfs_fs_pwd(current->fs), mnt, MGS_NIDTBL_DIR, @@ -211,7 +212,7 @@ err_pop: return rc; } -int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *mgs) +int mgs_fs_cleanup_old(const struct lu_env *env, struct mgs_device *mgs) { struct obd_device *obd = mgs->mgs_obd; struct lvfs_run_ctxt saved; @@ -221,10 +222,10 @@ int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *mgs) push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL); - if (mgs->mgs_configs_dir) { - l_dput(mgs->mgs_configs_dir); - mgs->mgs_configs_dir = NULL; - } + if (mgs->mgs_configs_dir_old) { + l_dput(mgs->mgs_configs_dir_old); + mgs->mgs_configs_dir_old = NULL; + } shrink_dcache_sb(mgs->mgs_sb); @@ -235,3 +236,99 @@ int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *mgs) return rc; } + +int mgs_fs_setup(const struct lu_env *env, struct mgs_device *mgs) +{ + struct lu_fid fid; + struct dt_object *o; + struct lu_fid rfid; + struct dt_object *root; + int rc; + ENTRY; + + /* FIXME what's this? Do I need it? */ + rc = cfs_cleanup_group_info(); + if (rc) + RETURN(rc); + + /* XXX: fix when support for N:1 layering is implemented */ + LASSERT(mgs->mgs_dt_dev.dd_lu_dev.ld_site); + mgs->mgs_dt_dev.dd_lu_dev.ld_site->ls_top_dev = + &mgs->mgs_dt_dev.dd_lu_dev; + + /* Setup the configs dir */ + fid.f_seq = FID_SEQ_LOCAL_NAME; + fid.f_oid = 1; + fid.f_ver = 0; + rc = local_oid_storage_init(env, mgs->mgs_bottom, &fid, &mgs->mgs_los); + if (rc) + GOTO(out, rc); + + rc = dt_root_get(env, mgs->mgs_bottom, &rfid); + if (rc) + GOTO(out_los, rc); + + root = dt_locate_at(env, mgs->mgs_bottom, &rfid, + &mgs->mgs_dt_dev.dd_lu_dev); + if (unlikely(IS_ERR(root))) + GOTO(out_los, PTR_ERR(root)); + + o = local_file_find_or_create(env, mgs->mgs_los, root, + MOUNT_CONFIGS_DIR, + S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO); + if (IS_ERR(o)) + GOTO(out_root, rc = PTR_ERR(o)); + + mgs->mgs_configs_dir = o; + + /* create directory to store nid table versions */ + o = local_file_find_or_create(env, mgs->mgs_los, root, MGS_NIDTBL_DIR, + S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO); + if (IS_ERR(o)) { + lu_object_put(env, &mgs->mgs_configs_dir->do_lu); + mgs->mgs_configs_dir = NULL; + GOTO(out_root, rc = PTR_ERR(o)); + } + + mgs->mgs_nidtbl_dir = o; + +out_root: + lu_object_put(env, &root->do_lu); +out_los: + if (rc) { + local_oid_storage_fini(env, mgs->mgs_los); + mgs->mgs_los = NULL; + } +out: + mgs->mgs_dt_dev.dd_lu_dev.ld_site->ls_top_dev = NULL; + + if (rc == 0) { + rc = mgs_fs_setup_old(env, mgs); + if (rc) + mgs_fs_cleanup(env, mgs); + } + + return rc; +} + +int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *mgs) +{ + mgs_fs_cleanup_old(env, mgs); + + class_disconnect_exports(mgs->mgs_obd); /* cleans up client info too */ + + if (mgs->mgs_configs_dir) { + lu_object_put(env, &mgs->mgs_configs_dir->do_lu); + mgs->mgs_configs_dir = NULL; + } + if (mgs->mgs_nidtbl_dir) { + lu_object_put(env, &mgs->mgs_nidtbl_dir->do_lu); + mgs->mgs_nidtbl_dir = NULL; + } + if (mgs->mgs_los) { + local_oid_storage_fini(env, mgs->mgs_los); + mgs->mgs_los = NULL; + } + + return 0; +} diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 4eb656f..84fe7d2 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -164,7 +164,8 @@ struct mgs_device { struct ptlrpc_service *mgs_service; struct dt_device *mgs_bottom; struct obd_export *mgs_bottom_exp; - struct dentry *mgs_configs_dir; + struct dt_object *mgs_configs_dir; + struct dentry *mgs_configs_dir_old; struct dt_object *mgs_nidtbl_dir; cfs_list_t mgs_fs_db_list; cfs_spinlock_t mgs_lock; /* covers mgs_fs_db_list */ @@ -195,8 +196,6 @@ int mgs_check_index(const struct lu_env *env, struct mgs_device *mgs, struct mgs int mgs_check_failnid(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti); int mgs_write_log_target(const struct lu_env *env, struct mgs_device *mgs, struct mgs_target_info *mti, struct fs_db *fsdb); -int mgs_upgrade_sv_14(const struct lu_env *env, struct mgs_device *mgs, - struct mgs_target_info *mti, struct fs_db *fsdb); int mgs_erase_log(const struct lu_env *env, struct mgs_device *mgs, char *name); int mgs_erase_logs(const struct lu_env *env, struct mgs_device *mgs, diff --git a/lustre/mgs/mgs_llog.c b/lustre/mgs/mgs_llog.c index d0ff8f3..79ee0e8 100644 --- a/lustre/mgs/mgs_llog.c +++ b/lustre/mgs/mgs_llog.c @@ -67,7 +67,7 @@ int class_dentry_readdir(const struct lu_env *env, ENTRY; push_ctxt(&saved, &mgs->mgs_obd->obd_lvfs_ctxt, NULL); - dentry = dget(mgs->mgs_configs_dir); + dentry = dget(mgs->mgs_configs_dir_old); if (IS_ERR(dentry)) GOTO(out_pop, rc = PTR_ERR(dentry)); mnt = mntget(mgs->mgs_vfsmnt);