Whamcloud - gitweb
move lmi get/put from lu_site_init/fini to the mdt
authortappro <tappro>
Mon, 17 Apr 2006 11:53:00 +0000 (11:53 +0000)
committertappro <tappro>
Mon, 17 Apr 2006 11:53:00 +0000 (11:53 +0000)
lustre/include/linux/lu_object.h
lustre/mdt/mdt_handler.c
lustre/obdclass/lu_object.c

index 3d79be9..f8cdf55 100644 (file)
@@ -446,7 +446,7 @@ int lu_object_print(struct lu_context *ctxt,
 struct lu_object *lu_object_find(struct lu_context *ctxt,
                                  struct lu_site *s, const struct lu_fid *f);
 
-int  lu_site_init(struct lu_site *, struct lu_device *, struct lustre_cfg *);
+int  lu_site_init(struct lu_site *, struct lu_device *);
 void lu_site_fini(struct lu_site *s);
 
 void lu_device_get(struct lu_device *d);
index 5e96ab8..dafb921 100644 (file)
@@ -1247,9 +1247,16 @@ out:
 static void mdt_fini(struct mdt_device *m)
 {
         struct lu_device *d = &m->mdt_md_dev.md_lu_dev;
-
+        
         mdt_stop_ptlrpc_service(m);
+        
+        /* finish the stack */
+        mdt_stack_fini(m);
+
         if (d->ld_site != NULL) {
+                struct lustre_mount_info *lmi = d->ld_site->ls_lmi;
+                if (lmi)
+                        server_put_mount(lmi->lmi_name, lmi->lmi_mnt);
                 lu_site_fini(d->ld_site);
                 OBD_FREE_PTR(d->ld_site);
                 d->ld_site = NULL;
@@ -1259,9 +1266,6 @@ static void mdt_fini(struct mdt_device *m)
                 m->mdt_namespace = NULL;
         }
 
-        /* finish the stack */
-        mdt_stack_fini(m);
-
         if (m->mdt_seq_mgr) {
                 seq_mgr_fini(m->mdt_seq_mgr);
                 m->mdt_seq_mgr = NULL;
@@ -1278,6 +1282,9 @@ static int mdt_init0(struct mdt_device *m,
         struct lu_site *s;
         char   ns_name[48];
         struct lu_context ctx;
+        const char *dev = lustre_cfg_string(cfg, 0);
+        struct lustre_mount_info *lmi;
+
         ENTRY;
 
         OBD_ALLOC_PTR(s);
@@ -1287,16 +1294,26 @@ static int mdt_init0(struct mdt_device *m,
         md_device_init(&m->mdt_md_dev, t);
         m->mdt_md_dev.md_lu_dev.ld_ops = &mdt_lu_ops;
         
-        rc = lu_site_init(s, &m->mdt_md_dev.md_lu_dev, cfg);
+        rc = lu_site_init(s, &m->mdt_md_dev.md_lu_dev);
         if (rc) {
                 CERROR("can't init lu_site, rc %d\n", rc);
                 GOTO(err_fini_site, rc);
         }
+        
+        /* get mount */
+        lmi = server_get_mount(dev);
+        if (lmi == NULL) {
+                CERROR("Cannot get mount info for %s!\n", dev);
+                GOTO(err_fini_site, rc = -EFAULT);
+        }
+        //put lmi into lu_site
+        s->ls_lmi = lmi;
+        
         /* init the stack */
         rc = mdt_stack_init(m, cfg);
         if (rc) {
                 CERROR("can't init device stack, rc %d\n", rc);
-                GOTO(err_fini_site, rc);
+                GOTO(err_fini_mount, rc);
         }
 
         m->mdt_seq_mgr = seq_mgr_init(&seq_mgr_ops, m);
@@ -1346,7 +1363,8 @@ err_fini_mgr:
         m->mdt_seq_mgr = NULL;
 err_fini_stack:
         mdt_stack_fini(m);
-
+err_fini_mount:
+        server_put_mount(lmi->lmi_name, lmi->lmi_mnt);
 err_fini_site:
         lu_site_fini(s);
         OBD_FREE_PTR(s);
index 5709c18..7434a69 100644 (file)
@@ -248,42 +248,31 @@ enum {
         LU_SITE_HTABLE_MASK = LU_SITE_HTABLE_SIZE - 1
 };
 
-int lu_site_init(struct lu_site *s, struct lu_device *top,
-                 struct lustre_cfg *cfg)
+int lu_site_init(struct lu_site *s, struct lu_device *top)
 {
         int result;
-        const char *dev   = lustre_cfg_string(cfg, 0);
-        struct lustre_mount_info *lmi;
-
         ENTRY;
 
         memset(s, 0, sizeof *s);
-        /* get mount */
-        lmi = server_get_mount(dev);
-        if (lmi != NULL) {
-                s->ls_lmi = lmi;
-                spin_lock_init(&s->ls_guard);
-                CFS_INIT_LIST_HEAD(&s->ls_lru);
-                s->ls_top_dev = top;
-                top->ld_site = s;
-                lu_device_get(top);
-                /*
-                 * XXX nikita: fixed size hash-table.
-                 */
-                s->ls_hash_mask = LU_SITE_HTABLE_MASK;
-                OBD_ALLOC(s->ls_hash,
-                          LU_SITE_HTABLE_SIZE * sizeof s->ls_hash[0]);
-                if (s->ls_hash != NULL) {
-                        int i;
-                        for (i = 0; i < LU_SITE_HTABLE_SIZE; i++)
-                                INIT_HLIST_HEAD(&s->ls_hash[i]);
-                        result = 0;
-                } else
-                        result = -ENOMEM;
+        spin_lock_init(&s->ls_guard);
+        CFS_INIT_LIST_HEAD(&s->ls_lru);
+        s->ls_top_dev = top;
+        top->ld_site = s;
+        lu_device_get(top);
+        /*
+         * XXX nikita: fixed size hash-table.
+         */
+        s->ls_hash_mask = LU_SITE_HTABLE_MASK;
+        OBD_ALLOC(s->ls_hash, LU_SITE_HTABLE_SIZE * sizeof s->ls_hash[0]);
+        if (s->ls_hash != NULL) {
+                int i;
+                for (i = 0; i < LU_SITE_HTABLE_SIZE; i++)
+                        INIT_HLIST_HEAD(&s->ls_hash[i]);
+                result = 0;
         } else {
-                CERROR("Cannot get mount info for %s!\n", dev);
-                result = -EFAULT;
+                result = -ENOMEM;
         }
+
         RETURN(result);
 }
 EXPORT_SYMBOL(lu_site_init);
@@ -294,9 +283,6 @@ void lu_site_fini(struct lu_site *s)
         LASSERT(s->ls_total == 0);
         LASSERT(s->ls_busy == 0);
 
-        if (s->ls_lmi)
-                server_put_mount(s->ls_lmi->lmi_name, s->ls_lmi->lmi_mnt);
-
         if (s->ls_hash != NULL) {
                 int i;
                 for (i = 0; i < LU_SITE_HTABLE_SIZE; i++)