From f2e76e29ecc5cbb74089b5cc03a51378f0a4b05d Mon Sep 17 00:00:00 2001 From: wangdi Date: Fri, 14 Jul 2006 09:34:22 +0000 Subject: [PATCH] Branch: b_new_cmd serval fixes about mdd lov --- lustre/cmm/cmm_device.c | 28 +++++++++++++--------------- lustre/include/lu_object.h | 7 ------- lustre/include/md_object.h | 5 +++++ lustre/include/obd.h | 2 ++ lustre/mdd/mdd_handler.c | 2 +- lustre/mdd/mdd_internal.h | 5 ++--- lustre/mdd/mdd_lov.c | 27 ++++++++++++++++++--------- lustre/mds/mds_lov.c | 4 ---- lustre/mdt/mdt_handler.c | 17 ++++------------- 9 files changed, 45 insertions(+), 52 deletions(-) diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index ba05142..561d93a 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -77,9 +77,22 @@ static int cmm_statfs(const struct lu_context *ctxt, struct md_device *md, RETURN (rc); } +int cmm_notify(struct md_device *md, struct obd_device *watched, + enum obd_notify_event ev, void *data) +{ + struct cmm_device *cmm_dev = md2cmm_dev(md); + int rc; + + rc = cmm_child_ops(cmm_dev)->mdo_notify(cmm_dev->cmm_child, watched, + ev, data); + + return rc; +} + static struct md_device_operations cmm_md_ops = { .mdo_root_get = cmm_root_get, .mdo_statfs = cmm_statfs, + .mdo_notify = cmm_notify }; extern struct lu_device_type mdc_device_type; @@ -188,24 +201,9 @@ static int cmm_process_config(const struct lu_context *ctx, RETURN(err); } -int cmm_notify(const struct lu_context *ctx, struct lu_device *d, - struct obd_device *watched, enum obd_notify_event ev, - void *data) -{ - struct cmm_device *m = lu2cmm_dev(d); - struct lu_device *next = md2lu_dev(m->cmm_child); - int err; - ENTRY; - - err = next->ld_ops->ldo_notify(ctx, next, watched, ev, data); - - RETURN(err); - -} static struct lu_device_operations cmm_lu_ops = { .ldo_object_alloc = cmm_object_alloc, .ldo_process_config = cmm_process_config, - .ldo_notify = cmm_notify }; /* --- lu_device_type operations --- */ diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 415bd2c..3f6eef0 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -141,13 +141,6 @@ struct lu_device_operations { int (*ldo_process_config)(const struct lu_context *ctx, struct lu_device *, struct lustre_cfg *); - /* - * notify function for metadata stack - */ - int (*ldo_notify)(const struct lu_context *ctx, struct lu_device *d, - struct obd_device *watched, enum obd_notify_event ev, - void *data); - }; /* diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index a7f75ea..ddb1ac6 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -108,6 +108,11 @@ struct md_device_operations { struct md_device *m, struct lu_fid *f); int (*mdo_statfs)(const struct lu_context *ctx, struct md_device *m, struct kstatfs *sfs); + /* + * notify function for metadata stack + */ + int (*mdo_notify)(struct md_device *m, struct obd_device *watched, + enum obd_notify_event ev, void *data); }; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 6838b97..1326bc3 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -28,6 +28,7 @@ #define IOC_MDC_MAX_NR 50 #include +#include #include #include #include @@ -426,6 +427,7 @@ struct md_lov_info { int md_lov_max_mdsize; int md_lov_max_cookiesize; struct semaphore md_lov_orphan_recovery_sem; + struct lu_context md_lov_ctxt; struct md_lov_ops *md_lov_ops; }; diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 20a2e50..fc13810 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -314,7 +314,6 @@ out: struct lu_device_operations mdd_lu_ops = { .ldo_object_alloc = mdd_object_alloc, .ldo_process_config = mdd_process_config, - .ldo_notify = mdd_notify }; static struct lu_object_operations mdd_lu_obj_ops = { @@ -1018,6 +1017,7 @@ static int mdd_close(const struct lu_context *ctxt, struct md_object *obj) struct md_device_operations mdd_ops = { .mdo_root_get = mdd_root_get, .mdo_statfs = mdd_statfs, + .mdo_notify = mdd_notify }; static struct md_dir_operations mdd_dir_ops = { diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index f66f939..ce2dc0c 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -55,9 +55,8 @@ struct mdd_thread_info { int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd, struct lustre_cfg *cfg); int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd); -int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld, - struct obd_device *watched, enum obd_notify_event ev, - void *data); +int mdd_notify(struct md_device *md, struct obd_device *watched, + enum obd_notify_event ev, void *data); int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj, const void *buf, int buf_len, const char *name); diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index 6a89c13..a066a77 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -143,6 +143,7 @@ int mdd_lov_fini(const struct lu_context *ctxt, struct mdd_device *mdd) mli->md_lov_exp = NULL; } + lu_context_fini(&mli->md_lov_ctxt); dt_object_fini(mli->md_lov_objid_obj); return 0; } @@ -182,16 +183,21 @@ int mdd_lov_init(const struct lu_context *ctxt, struct mdd_device *mdd, rc = md_lov_connect(obd, lov_info, lov_name, &obd->obd_uuid, &mdd_lov_ops, ctxt); if (rc) + GOTO(out, rc); + + rc = lu_context_init(&lov_info->md_lov_ctxt); +out: + if (rc) mdd_lov_fini(ctxt, mdd); + RETURN(rc); } -int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld, - struct obd_device *watched, enum obd_notify_event ev, - void *data) +int mdd_notify(struct md_device *md, struct obd_device *watched, + enum obd_notify_event ev, void *data) { - struct mdd_device *mdd = lu2mdd_dev(ld); - struct obd_device *obd = ld->ld_site->ls_top_dev->ld_obd; + struct mdd_device *mdd = lu2mdd_dev(&md->md_lu_dev); + struct obd_device *obd = md2lu_dev(md)->ld_site->ls_top_dev->ld_obd; int rc = 0; ENTRY; @@ -201,10 +207,13 @@ int mdd_notify(const struct lu_context *ctxt, struct lu_device *ld, rc = 0; RETURN(rc); } - - rc = md_lov_start_synchronize(obd, &mdd->mdd_lov_info, watched, data, - !(ev == OBD_NOTIFY_SYNC), ctxt); - + + lu_context_enter(&mdd->mdd_lov_info.md_lov_ctxt); + rc = md_lov_start_synchronize(obd, &mdd->mdd_lov_info, watched, data, + !(ev == OBD_NOTIFY_SYNC), + &mdd->mdd_lov_info.md_lov_ctxt); + lu_context_exit(&mdd->mdd_lov_info.md_lov_ctxt); + RETURN(rc); } diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index a9b2c32..451b952 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -779,7 +779,6 @@ int md_lov_start_synchronize(struct obd_device *obd, struct md_lov_info *mli, disconnect the LOV. This of course means a cleanup won't finish for as long as the sync is blocking. */ class_incref(obd); -#if 0 if (nonblock) { /* Synchronize in the background */ rc = cfs_kernel_thread(mds_lov_synchronize, mlsi, @@ -797,9 +796,6 @@ int md_lov_start_synchronize(struct obd_device *obd, struct md_lov_info *mli, } else { rc = __mds_lov_synchronize((void *)mlsi); } -#else - rc = __mds_lov_synchronize((void *)mlsi); -#endif RETURN(rc); } EXPORT_SYMBOL(md_lov_start_synchronize); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index ea7278f..17165b8 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2543,24 +2543,15 @@ static int mdt_notify(struct obd_device *obd, struct obd_device *watched, enum obd_notify_event ev, void *data) { struct mdt_device *mdt; - struct lu_device *next; - struct lu_context ctxt; + struct md_device *next; int rc; ENTRY; - /*FIXME: allocation here may have some problems :( */ - rc = lu_context_init(&ctxt); - if (rc) - GOTO(out, rc); - mdt = mdt_dev(obd->obd_lu_dev); - next = md2lu_dev(mdt->mdt_child); + next = mdt->mdt_child; - lu_context_enter(&ctxt); - rc = next->ld_ops->ldo_notify(&ctxt, next, watched, ev, data); - lu_context_exit(&ctxt); -out: - lu_context_fini(&ctxt); + rc = next->md_ops->mdo_notify(next, watched, ev, data); + RETURN(rc); } -- 1.8.3.1