Whamcloud - gitweb
add lu_context to various operations
authornikita <nikita>
Tue, 16 May 2006 21:17:06 +0000 (21:17 +0000)
committernikita <nikita>
Tue, 16 May 2006 21:17:06 +0000 (21:17 +0000)
lustre/cmm/cmm_device.c
lustre/cmm/mdc_device.c
lustre/include/linux/dt_object.h
lustre/include/linux/lu_object.h
lustre/include/linux/obd_class.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_handler.c
lustre/osd/osd_handler.c
lustre/osd/osd_internal.h

index 0b87a37..f0c1bcc 100644 (file)
@@ -96,25 +96,26 @@ static struct md_device_operations cmm_md_ops = {
 extern struct lu_device_type mdc_device_type;
 
 /* add new MDC to the CMM, create MDC lu_device and connect it to mdc_obd */
-static int cmm_add_mdc(struct cmm_device * cm, struct lustre_cfg *cfg)
+static int cmm_add_mdc(struct lu_context *ctx,
+                       struct cmm_device * cm, struct lustre_cfg *cfg)
 {
         struct lu_device_type *ldt = &mdc_device_type;
         struct lu_device *ld;
         int rc;
         ENTRY;
-        
+
         /*TODO check this MDC exists already */
 
         ld = ldt->ldt_ops->ldto_device_alloc(ldt, cfg);
-        
+
         ld->ld_site = cmm2lu_dev(cm)->ld_site;
 
-        rc = ldt->ldt_ops->ldto_device_init(ld, NULL);
+        rc = ldt->ldt_ops->ldto_device_init(ctx, ld, NULL);
         if (rc)
                 ldt->ldt_ops->ldto_device_free(ld);
 
         /* pass config to the just created MDC */
-        rc = ld->ld_ops->ldo_process_config(ld, cfg);
+        rc = ld->ld_ops->ldo_process_config(ctx, ld, cfg);
         if (rc == 0) {
                 struct mdc_device *mc = lu2mdc_dev(ld);
                 list_add_tail(&mc->mc_linkage, &cm->cmm_targets);
@@ -124,7 +125,8 @@ static int cmm_add_mdc(struct cmm_device * cm, struct lustre_cfg *cfg)
 }
 
 
-static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int cmm_process_config(struct lu_context *ctx,
+                              struct lu_device *d, struct lustre_cfg *cfg)
 {
         struct cmm_device *m = lu2cmm_dev(d);
         struct lu_device *next = md2lu_dev(m->cmm_child);
@@ -132,9 +134,9 @@ static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg)
 
         switch(cfg->lcfg_command) {
         case LCFG_ADD_MDC:
-                err = cmm_add_mdc(m, cfg);
+                err = cmm_add_mdc(ctx, m, cfg);
                 break;
-        case LCFG_SETUP: 
+        case LCFG_SETUP:
         {
                 const char *index = lustre_cfg_string(cfg, 2);
                 LASSERT(index);
@@ -142,7 +144,7 @@ static int cmm_process_config(struct lu_device *d, struct lustre_cfg *cfg)
                 /* no break; to pass cfg further */
         }
         default:
-                err = next->ld_ops->ldo_process_config(next, cfg);
+                err = next->ld_ops->ldo_process_config(ctx, next, cfg);
         }
         RETURN(err);
 }
@@ -197,7 +199,8 @@ void cmm_type_fini(struct lu_device_type *t)
         return;
 }
 
-static int cmm_device_init(struct lu_device *d, struct lu_device *next)
+static int cmm_device_init(struct lu_context *ctx,
+                           struct lu_device *d, struct lu_device *next)
 {
         struct cmm_device *m = lu2cmm_dev(d);
         int err = 0;
@@ -211,19 +214,20 @@ static int cmm_device_init(struct lu_device *d, struct lu_device *next)
         RETURN(err);
 }
 
-static struct lu_device *cmm_device_fini(struct lu_device *ld)
+static struct lu_device *cmm_device_fini(struct lu_context *ctx,
+                                         struct lu_device *ld)
 {
        struct cmm_device *cm = lu2cmm_dev(ld);
         struct mdc_device *mc, *tmp;
         ENTRY;
-        
+
         /* finish all mdc devices */
         list_for_each_entry_safe(mc, tmp, &cm->cmm_targets, mc_linkage) {
                 struct lu_device *ld_m = mdc2lu_dev(mc);
 
                 list_del(&mc->mc_linkage);
                 lu_device_put(cmm2lu_dev(cm));
-                ld->ld_type->ldt_ops->ldto_device_fini(ld_m);
+                ld->ld_type->ldt_ops->ldto_device_fini(ctx, ld_m);
                 ld->ld_type->ldt_ops->ldto_device_free(ld_m);
         }
 
index c4264d0..7558a6a 100644 (file)
@@ -114,7 +114,7 @@ static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg)
 
                 CDEBUG(D_CONFIG, "connect to %s(%s)\n",
                        mdc->obd_name, mdc->obd_uuid.uuid);
-                
+
                 rc = obd_connect(&conn, mdc, &mdt->obd_uuid, NULL);
 
                 if (rc) {
@@ -125,11 +125,12 @@ static int mdc_add_obd(struct mdc_device *mc, struct lustre_cfg *cfg)
                         mc->mc_num = simple_strtol(index, NULL, 10);
                 }
         }
-        
+
         RETURN(rc);
 }
 
-static int mdc_process_config(struct lu_device *ld, struct lustre_cfg *cfg)
+static int mdc_process_config(struct lu_context *ctx,
+                              struct lu_device *ld, struct lustre_cfg *cfg)
 {
         struct mdc_device *mc = lu2mdc_dev(ld);
         int rc;
@@ -169,13 +170,13 @@ static int mdc_device_connect(struct mdc_device *mc)
         rc = ptlrpc_init_import(imp);
         if (rc != 0)
                 RETURN(rc);
-       
+
         rc = ptlrpc_connect_import(imp, NULL);
         if (rc != 0) {
                 LASSERT (imp->imp_state == LUSTRE_IMP_DISCON);
                 RETURN(rc);
         }
-        
+
         ptlrpc_pinger_add_import(imp);
         //TODO other initializations
         LASSERT(imp->imp_connection);
@@ -183,7 +184,8 @@ static int mdc_device_connect(struct mdc_device *mc)
         RETURN(0);
 }
 
-static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
+static int mdc_device_init(struct lu_context *ctx,
+                           struct lu_device *ld, struct lu_device *next)
 {
         struct mdc_device *mc = lu2mdc_dev(ld);
         struct mdc_cli_desc *desc = &mc->mc_desc;
@@ -203,7 +205,7 @@ static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
 
         sema_init(&cli->cl_sem, 1);
         cli->cl_conn_count = 0;
-        
+
         rc = ldlm_get_ref();
         if (rc != 0) {
                 CERROR("ldlm_get_ref failed: %d\n", rc);
@@ -212,11 +214,11 @@ static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
 
         ptlrpc_init_client(rq_portal, rp_portal, obd->obd_type->typ_name,
                            &desc->cl_ldlm_client);
-        
+
         imp = class_new_import(obd);
         if (imp == NULL)
                 GOTO(err_ldlm, rc = -ENOENT);
-        
+
         imp->imp_client = &desc->cl_ldlm_client;
         imp->imp_connect_op = connect_op;
         imp->imp_initial_recov = 1;
@@ -232,11 +234,11 @@ static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
 
         desc->cl_import = imp;
         cli->cl_import = imp;
-        
+
         rc = mdc_device_connect(mc);
-        
+
         RETURN(0);
-        
+
 err_import:
         class_destroy_import(imp);
 err_ldlm:
@@ -247,11 +249,12 @@ err:
         RETURN(rc);
 }
 
-static struct lu_device *mdc_device_fini(struct lu_device *ld)
+static struct lu_device *mdc_device_fini(struct lu_context *ctx,
+                                         struct lu_device *ld)
 {
        struct mdc_device *mc = lu2mdc_dev(ld);
         struct mdc_cli_desc *desc = &mc->mc_desc;
-        
+
         ENTRY;
 
         class_destroy_import(desc->cl_import);
@@ -292,7 +295,8 @@ struct lu_device *mdc_device_alloc(struct lu_device_type *ldt,
         RETURN (ld);
 }
 #endif
-static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
+static int mdc_device_init(struct lu_context *ctx,
+                           struct lu_device *ld, struct lu_device *next)
 {
         /* struct mdc_device *mc = lu2mdc_dev(ld); */
         int rc = 0;
@@ -302,10 +306,11 @@ static int mdc_device_init(struct lu_device *ld, struct lu_device *next)
         RETURN(rc);
 }
 
-static struct lu_device *mdc_device_fini(struct lu_device *ld)
+static struct lu_device *mdc_device_fini(struct lu_context *ctx,
+                                         struct lu_device *ld)
 {
        /* struct mdc_device *mc = lu2mdc_dev(ld); */
-       
+
         ENTRY;
 
         RETURN (NULL);
index a1b5ef4..ab4c73f 100644 (file)
@@ -217,7 +217,7 @@ enum dt_index_flags {
  * Features, required from index to support file system directories (mapping
  * names to fids).
  */
-extern struct dt_index_features dt_directory_features;
+extern const struct dt_index_features dt_directory_features;
 
 /*
  * Per-dt-object operations on object as index.
index 5422a16..bee960c 100644 (file)
@@ -143,7 +143,8 @@ struct lu_device_operations {
         /*
          * process config specific for device
          */
-        int  (*ldo_process_config)(struct lu_device *, struct lustre_cfg *);
+        int  (*ldo_process_config)(struct lu_context *ctx,
+                                   struct lu_device *, struct lustre_cfg *);
 };
 
 /*
@@ -269,12 +270,14 @@ struct lu_device_type_operations {
         /*
          * Initialize the devices after allocation
          */
-        int  (*ldto_device_init)(struct lu_device *, struct lu_device *);
+        int  (*ldto_device_init)(struct lu_context *ctx,
+                                 struct lu_device *, struct lu_device *);
         /*
          * Finalize device. Dual to ->ldto_device_init(). Returns pointer to
          * the next device in the stack.
          */
-        struct lu_device *(*ldto_device_fini)(struct lu_device *);
+        struct lu_device *(*ldto_device_fini)(struct lu_context *ctx,
+                                              struct lu_device *);
 
         /*
          * Initialize device type. This is called on module load.
index f9e311a..df36942 100644 (file)
@@ -421,8 +421,15 @@ obd_process_config(struct obd_device *obd, int datalen, void *data)
         ldt = obd->obd_type->typ_lu;
         d = obd->obd_lu_dev;
         if (ldt != NULL && d != NULL) {
-                rc = d->ld_ops->ldo_process_config(d,
-                                                   (struct lustre_cfg *)data);
+                struct lu_context ctx;
+
+                rc = lu_context_init(&ctx);
+                if (rc == 0) {
+                        lu_context_enter(&ctx);
+                        rc = d->ld_ops->ldo_process_config(&ctx, d, data);
+                        lu_context_exit(&ctx);
+                        lu_context_fini(&ctx);
+                }
         } else {
                 OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP);
                 rc = OBP(obd, process_config)(obd, datalen, data);
index 99a3ba3..13a6292 100644 (file)
@@ -62,6 +62,21 @@ static struct md_object_operations mdd_obj_ops;
 static struct md_dir_operations    mdd_dir_ops;
 static struct lu_object_operations mdd_lu_obj_ops;
 
+static struct lu_context_key       mdd_thread_key;
+
+struct mdd_thread_info {
+        struct txn_param mti_param;
+};
+
+static struct mdd_thread_info *mdd_ctx_info(struct lu_context *ctx)
+{
+        struct mdd_thread_info *info;
+
+        info = lu_context_key_get(ctx, &mdd_thread_key);
+        LASSERT(info != NULL);
+        return info;
+}
+
 static int lu_device_is_mdd(struct lu_device *d)
 {
        /*
@@ -274,7 +289,7 @@ static int mdd_object_print(struct lu_context *ctxt,
         return seq_printf(f, LUSTRE_MDD0_NAME"-object@%p", o);
 }
 
-static int mdd_fs_setup(struct mdd_device *mdd)
+static int mdd_fs_setup(struct lu_context *ctx, struct mdd_device *mdd)
 {
         return 0;
 }
@@ -284,7 +299,8 @@ static int mdd_fs_cleanup(struct mdd_device *mdd)
         return 0;
 }
 
-static int mdd_device_init(struct lu_device *d, struct lu_device *next)
+static int mdd_device_init(struct lu_context *ctx,
+                           struct lu_device *d, struct lu_device *next)
 {
         struct mdd_device *mdd = lu2mdd_dev(d);
         int rc = -EFAULT;
@@ -293,7 +309,7 @@ static int mdd_device_init(struct lu_device *d, struct lu_device *next)
 
         mdd->mdd_child = lu2dt_dev(next);
 
-        rc = mdd_fs_setup(mdd);
+        rc = mdd_fs_setup(ctx, mdd);
         if (rc)
                 GOTO(err, rc);
 
@@ -303,7 +319,8 @@ err:
         RETURN(rc);
 }
 
-static struct lu_device *mdd_device_fini(struct lu_device *d)
+static struct lu_device *mdd_device_fini(struct lu_context *ctx,
+                                         struct lu_device *d)
 {
        struct mdd_device *m = lu2mdd_dev(d);
         struct lu_device *next = &m->mdd_child->dd_lu_dev;
@@ -311,7 +328,8 @@ static struct lu_device *mdd_device_fini(struct lu_device *d)
         return next;
 }
 
-static int mdd_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int mdd_process_config(struct lu_context *ctx,
+                              struct lu_device *d, struct lustre_cfg *cfg)
 {
         struct mdd_device *m = lu2mdd_dev(d);
         struct lu_device *next = &m->mdd_child->dd_lu_dev;
@@ -320,7 +338,7 @@ static int mdd_process_config(struct lu_device *d, struct lustre_cfg *cfg)
         switch(cfg->lcfg_command) {
 
         default:
-                err = next->ld_ops->ldo_process_config(next, cfg);
+                err = next->ld_ops->ldo_process_config(ctx, next, cfg);
         }
 
         RETURN(err);
@@ -497,7 +515,8 @@ __mdd_index_insert(struct lu_context *ctxt, struct mdd_object *pobj,
         int rc;
         struct dt_object *next = mdd_object_child(pobj);
 
-        rc = next->do_index_ops->dio_insert(ctxt, next, lf, name, handle);
+        rc = next->do_index_ops->dio_insert(ctxt, next, (struct dt_rec *)lf,
+                                            (struct dt_key *)name, handle);
         return rc;
 }
 
@@ -513,8 +532,9 @@ __mdd_index_delete(struct lu_context *ctxt, struct mdd_device *mdd,
 
         mdd_lock2(ctxt, pobj, obj);
 
-        rc = next->do_index_ops->dio_delete(ctxt, next, mdd_object_getfid(obj),
-                                            name, handle);
+        rc = next->do_index_ops->dio_delete(ctxt, next,
+                                            (const struct dt_rec *)mdd_object_getfid(obj),
+                                            (struct dt_key *)name, handle);
         mdd_unlock2(ctxt, pobj, obj);
 
         RETURN(rc);
@@ -765,7 +785,7 @@ struct lu_device *mdd_device_alloc(struct lu_device_type *t,
         return l;
 }
 
-void mdd_device_free(struct lu_device *lu)
+static void mdd_device_free(struct lu_device *lu)
 {
         struct mdd_device *m = lu2mdd_dev(lu);
 
@@ -775,13 +795,14 @@ void mdd_device_free(struct lu_device *lu)
         OBD_FREE_PTR(m);
 }
 
-int mdd_type_init(struct lu_device_type *t)
+static int mdd_type_init(struct lu_device_type *t)
 {
-        return 0;
+        return lu_context_key_register(&mdd_thread_key);
 }
 
-void mdd_type_fini(struct lu_device_type *t)
+static void mdd_type_fini(struct lu_device_type *t)
 {
+        lu_context_key_degister(&mdd_thread_key);
 }
 
 static struct lu_device_type_operations mdd_device_type_ops = {
@@ -801,6 +822,27 @@ static struct lu_device_type mdd_device_type = {
         .ldt_ops  = &mdd_device_type_ops
 };
 
+static void *mdd_key_init(struct lu_context *ctx)
+{
+        struct mdd_thread_info *info;
+
+        OBD_ALLOC_PTR(info);
+        if (info == NULL)
+                info = ERR_PTR(-ENOMEM);
+        return info;
+}
+
+static void mdd_key_fini(struct lu_context *ctx, void *data)
+{
+        struct mdd_thread_info *info = data;
+        OBD_FREE_PTR(info);
+}
+
+static struct lu_context_key mdd_thread_key = {
+        .lct_init = mdd_key_init,
+        .lct_fini = mdd_key_fini
+};
+
 struct lprocfs_vars lprocfs_mdd_obd_vars[] = {
         { 0 }
 };
index 77f6236..87b13f3 100644 (file)
@@ -20,6 +20,7 @@ struct mdd_device {
         int                              mdd_max_mddize;
         int                              mdd_max_cookiesize;
         struct file                     *mdd_rcvd_filp;
+        struct lu_fid                    mdd_root_fid;
         spinlock_t                       mdd_transno_lock;
         __u64                            mdd_last_transno;
         __u64                            mdd_mount_count;
index 441c562..6daa44f 100644 (file)
@@ -1017,7 +1017,7 @@ static int mdt_intent_policy(struct ldlm_namespace *ns,
         int offset = MDS_REQ_INTENT_REC_OFF;
         int rc;
         struct mdt_thread_info *info;
-        
+
         ENTRY;
 
         LASSERT(req != NULL);
@@ -1197,7 +1197,8 @@ err_mdt_svc:
         RETURN(rc);
 }
 
-static void mdt_stack_fini(struct mdt_device *m, struct lu_device *d)
+static void mdt_stack_fini(struct lu_context *ctx,
+                           struct mdt_device *m, struct lu_device *d)
 {
         /* goes through all stack */
         while (d != NULL) {
@@ -1209,7 +1210,7 @@ static void mdt_stack_fini(struct mdt_device *m, struct lu_device *d)
 
                 /* each fini() returns next device in stack of layers
                  * * so we can avoid the recursion */
-                n = ldt->ldt_ops->ldto_device_fini(d);
+                n = ldt->ldt_ops->ldto_device_fini(ctx, d);
                 ldt->ldt_ops->ldto_device_free(d);
 
                 type = ldt->ldt_obd_type;
@@ -1221,7 +1222,8 @@ static void mdt_stack_fini(struct mdt_device *m, struct lu_device *d)
         m->mdt_child = NULL;
 }
 
-static struct lu_device *mdt_layer_setup(const char *typename,
+static struct lu_device *mdt_layer_setup(struct lu_context *ctx,
+                                         const char *typename,
                                          struct lu_device *child,
                                          struct lustre_cfg *cfg)
 {
@@ -1254,7 +1256,7 @@ static struct lu_device *mdt_layer_setup(const char *typename,
         d->ld_site = child->ld_site;
 
         type->typ_refcnt++;
-        rc = ldt->ldt_ops->ldto_device_init(d, child);
+        rc = ldt->ldt_ops->ldto_device_init(ctx, d, child);
         if (rc) {
                 CERROR("can't init device '%s', rc %d\n", typename, rc);
                 GOTO(out_alloc, rc);
@@ -1271,25 +1273,26 @@ out:
         RETURN(ERR_PTR(rc));
 }
 
-static int mdt_stack_init(struct mdt_device *m, struct lustre_cfg *cfg)
+static int mdt_stack_init(struct lu_context *ctx,
+                          struct mdt_device *m, struct lustre_cfg *cfg)
 {
         struct lu_device  *d = &m->mdt_md_dev.md_lu_dev;
         struct lu_device  *tmp;
         int rc;
 
         /* init the stack */
-        tmp = mdt_layer_setup(LUSTRE_OSD0_NAME, d, cfg);
+        tmp = mdt_layer_setup(ctx, LUSTRE_OSD0_NAME, d, cfg);
         if (IS_ERR(tmp)) {
                 RETURN (PTR_ERR(tmp));
         }
         m->mdt_bottom = lu2dt_dev(tmp);
         d = tmp;
-        tmp = mdt_layer_setup(LUSTRE_MDD0_NAME, d, cfg);
+        tmp = mdt_layer_setup(ctx, LUSTRE_MDD0_NAME, d, cfg);
         if (IS_ERR(tmp)) {
                 GOTO(out, rc = PTR_ERR(tmp));
         }
         d = tmp;
-        tmp = mdt_layer_setup(LUSTRE_CMM0_NAME, d, cfg);
+        tmp = mdt_layer_setup(ctx, LUSTRE_CMM0_NAME, d, cfg);
         if (IS_ERR(tmp)) {
                 GOTO(out, rc = PTR_ERR(tmp));
         }
@@ -1298,12 +1301,12 @@ static int mdt_stack_init(struct mdt_device *m, struct lustre_cfg *cfg)
 
         /* process setup config */
         tmp = &m->mdt_md_dev.md_lu_dev;
-        rc = tmp->ld_ops->ldo_process_config(tmp, cfg);
+        rc = tmp->ld_ops->ldo_process_config(ctx, tmp, cfg);
 
 out:
         /* fini from last known good lu_device */
         if (rc)
-                mdt_stack_fini(m, d);
+                mdt_stack_fini(ctx, m, d);
 
         return rc;
 }
@@ -1311,16 +1314,26 @@ out:
 static void mdt_fini(struct mdt_device *m)
 {
         struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
+        struct lu_context ctx;
+        int rc;
 
         ENTRY;
 
+        rc = lu_context_init(&ctx);
+        if (rc != 0) {
+                CERROR("Cannot initialize context: %d\n", rc);
+                EXIT;
+        }
+
+        lu_context_enter(&ctx);
+
         mdt_stop_ptlrpc_service(m);
 
         /* finish the stack */
-        mdt_stack_fini(m, md2lu_dev(m->mdt_child));
+        mdt_stack_fini(&ctx, m, md2lu_dev(m->mdt_child));
 
         mdt_fld_fini(m);
-        
+
         LASSERT(atomic_read(&d->ld_ref) == 0);
         md_device_fini(&m->mdt_md_dev);
 
@@ -1340,6 +1353,9 @@ static void mdt_fini(struct mdt_device *m)
                 d->ld_site = NULL;
         }
 
+        lu_context_exit(&ctx);
+        lu_context_fini(&ctx);
+
         EXIT;
 }
 
@@ -1371,17 +1387,23 @@ static int mdt_init0(struct mdt_device *m,
                 GOTO(err_fini_site, rc);
         }
 
+        rc = lu_context_init(&ctx);
+        if (rc != 0)
+                GOTO(err_fini_site, rc);
+
+        lu_context_enter(&ctx);
+
         /* init the stack */
-        rc = mdt_stack_init(m, cfg);
+        rc = mdt_stack_init(&ctx, m, cfg);
         if (rc) {
                 CERROR("can't init device stack, rc %d\n", rc);
-                GOTO(err_fini_site, rc);
+                GOTO(err_fini_ctx, rc);
         }
 
         /* set server index */
         LASSERT(num);
         s->ls_node_id = simple_strtol(num, NULL, 10);
-        
+
         m->mdt_seq_mgr = seq_mgr_init(&seq_mgr_ops, m);
         if (!m->mdt_seq_mgr) {
                 CERROR("can't initialize sequence manager\n");
@@ -1389,19 +1411,11 @@ static int mdt_init0(struct mdt_device *m,
         }
         /* set initial sequence by mds index */
         m->mdt_seq_mgr->m_seq = s->ls_node_id * LUSTRE_SEQ_RANGE;
-        
-        rc = lu_context_init(&ctx);
-        if (rc != 0)
-                GOTO(err_fini_mgr, rc);
 
-        lu_context_enter(&ctx);
         /* init sequence info after device stack is initialized. */
         rc = seq_mgr_setup(&ctx, m->mdt_seq_mgr);
-        lu_context_exit(&ctx);
         if (rc)
-                GOTO(err_fini_ctx, rc);
-
-        lu_context_fini(&ctx);
+                GOTO(err_fini_mgr, rc);
 
         snprintf(ns_name, sizeof ns_name, LUSTRE_MDT0_NAME"-%p", m);
         m->mdt_namespace = ldlm_namespace_new(ns_name, LDLM_NAMESPACE_SERVER);
@@ -1418,6 +1432,9 @@ static int mdt_init0(struct mdt_device *m,
         if (rc)
                 GOTO(err_free_fld, rc);
 
+        lu_context_exit(&ctx);
+        lu_context_fini(&ctx);
+
         RETURN(0);
 
 err_free_fld:
@@ -1425,13 +1442,14 @@ err_free_fld:
 err_free_ns:
         ldlm_namespace_free(m->mdt_namespace, 0);
         m->mdt_namespace = NULL;
-err_fini_ctx:
-        lu_context_fini(&ctx);
 err_fini_mgr:
         seq_mgr_fini(m->mdt_seq_mgr);
         m->mdt_seq_mgr = NULL;
 err_fini_stack:
-        mdt_stack_fini(m, md2lu_dev(m->mdt_child));
+        mdt_stack_fini(&ctx, m, md2lu_dev(m->mdt_child));
+err_fini_ctx:
+        lu_context_exit(&ctx);
+        lu_context_fini(&ctx);
 err_fini_site:
         lu_site_fini(s);
         OBD_FREE_PTR(s);
@@ -1439,7 +1457,8 @@ err_fini_site:
 }
 
 /* used by MGS to process specific configurations */
-static int mdt_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int mdt_process_config(struct lu_context *ctx,
+                              struct lu_device *d, struct lustre_cfg *cfg)
 {
         struct lu_device *next = md2lu_dev(mdt_dev(d)->mdt_child);
         int err;
@@ -1449,7 +1468,7 @@ static int mdt_process_config(struct lu_device *d, struct lustre_cfg *cfg)
                 /* all MDT specific commands should be here */
         default:
                 /* others are passed further */
-                err = next->ld_ops->ldo_process_config(next, cfg);
+                err = next->ld_ops->ldo_process_config(ctx, next, cfg);
         }
         RETURN(err);
 }
index 32c9aa7..069c3ee 100644 (file)
@@ -81,11 +81,12 @@ static int   osd_object_exists (struct lu_context *ctx, struct lu_object *o);
 static int   osd_object_print  (struct lu_context *ctx,
                                 struct seq_file *f, const struct lu_object *o);
 static void  osd_device_free   (struct lu_device *m);
-static int   osd_device_init   (struct lu_device *d, struct lu_device *);
 static void *osd_key_init      (struct lu_context *ctx);
 static void  osd_key_fini      (struct lu_context *ctx, void *data);
 static int   osd_has_index     (struct osd_object *obj);
 static void  osd_object_init0  (struct osd_object *obj);
+static int   osd_device_init   (struct lu_context *ctx,
+                                struct lu_device *d, struct lu_device *);
 static int   osd_fid_lookup    (struct lu_context *ctx, struct osd_object *obj,
                                 const struct lu_fid *fid);
 static int   osd_inode_getattr (struct lu_context *ctx,
@@ -108,8 +109,9 @@ static struct osd_device  *osd_dev          (const struct lu_device *d);
 static struct osd_device  *osd_dt_dev       (const struct dt_device *d);
 static struct osd_object  *osd_dt_obj       (const struct dt_object *d);
 static struct osd_device  *osd_obj2dev      (struct osd_object *o);
-static struct lu_device   *osd_device_fini  (struct lu_device *d);
 static struct lu_device   *osd2lu_dev       (struct osd_device * osd);
+static struct lu_device   *osd_device_fini  (struct lu_context *ctx,
+                                             struct lu_device *d);
 static struct lu_device   *osd_device_alloc (struct lu_device_type *t,
                                              struct lustre_cfg *cfg);
 static struct lu_object   *osd_object_alloc (struct lu_context *ctx,
@@ -621,7 +623,7 @@ static int osd_index_insert(struct lu_context *ctxt, struct dt_object *dt,
         return 0;
 }
 
-struct dt_index_features dt_directory_features;
+const struct dt_index_features dt_directory_features;
 
 static int osd_index_probe(struct lu_context *ctxt, struct dt_object *dt,
                            const struct dt_index_features *feat)
@@ -674,7 +676,8 @@ static void osd_key_fini(struct lu_context *ctx, void *data)
         OBD_FREE_PTR(info);
 }
 
-static int osd_device_init(struct lu_device *d, struct lu_device *next)
+static int osd_device_init(struct lu_context *ctx,
+                           struct lu_device *d, struct lu_device *next)
 {
         return 0;
 }
@@ -683,7 +686,8 @@ extern void osd_oi_init0(struct osd_oi *oi, __u64 root_ino, __u32 root_gen);
 extern int osd_oi_find_fid(struct osd_oi *oi,
                            __u64 ino, __u32 gen, struct lu_fid *fid);
 
-static int osd_mount(struct osd_device *o, struct lustre_cfg *cfg)
+static int osd_mount(struct lu_context *ctx,
+                     struct osd_device *o, struct lustre_cfg *cfg)
 {
         struct lustre_mount_info *lmi;
         const char *dev = lustre_cfg_string(cfg, 0);
@@ -726,11 +730,12 @@ static int osd_mount(struct osd_device *o, struct lustre_cfg *cfg)
                         result = PTR_ERR(d);
         }
         if (result != 0)
-                osd_device_fini(osd2lu_dev(o));
+                osd_device_fini(ctx, osd2lu_dev(o));
         RETURN(result);
 }
 
-static struct lu_device *osd_device_fini(struct lu_device *d)
+static struct lu_device *osd_device_fini(struct lu_context *ctx,
+                                         struct lu_device *d)
 {
         struct osd_device *o = osd_dev(d);
 
@@ -782,14 +787,15 @@ static void osd_device_free(struct lu_device *d)
         OBD_FREE_PTR(o);
 }
 
-static int osd_process_config(struct lu_device *d, struct lustre_cfg *cfg)
+static int osd_process_config(struct lu_context *ctx,
+                              struct lu_device *d, struct lustre_cfg *cfg)
 {
         struct osd_device *o = osd_dev(d);
         int err;
 
         switch(cfg->lcfg_command) {
         case LCFG_SETUP:
-                err = osd_mount(o, cfg);
+                err = osd_mount(ctx, o, cfg);
                 break;
         default:
                 err = -ENOTTY;
index 674eac3..a84500e 100644 (file)
@@ -51,18 +51,28 @@ struct osd_object {
         struct rw_semaphore  oo_sem;
 };
 
+/*
+ * osd device.
+ */
 struct osd_device {
+        /* super-class */
         struct dt_device          od_dt_dev;
+        /* information about underlying file system */
         struct lustre_mount_info *od_mount;
+        /* object index */
         struct osd_oi             od_oi;
+        /* root directory */
         struct dentry            *od_root_dir;
+        /*
+         * XXX temporary stuff for object index: directory where every object
+         * is named by its fid.
+         */
         struct dentry            *od_obj_area;
 };
 
 struct dentry *osd_lookup(struct dentry *parent, const char *name);
 struct dentry *osd_open(struct dentry *parent, const char *name, mode_t mode);
 
-
 struct osd_thread_info {
         struct lu_fid       oti_fid;
         struct osd_inode_id oti_id;