Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Wed, 26 Jul 2006 07:15:09 +0000 (07:15 +0000)
committerwangdi <wangdi>
Wed, 26 Jul 2006 07:15:09 +0000 (07:15 +0000)
1)keep mdd obd fsfilt and make it support llog.
2)others fixes for llog and lov

lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_lov.c
lustre/mds/handler.c
lustre/mds/mds_fs.c
lustre/mds/mds_internal.h
lustre/mds/mds_lov.c
lustre/obdclass/llog_lvfs.c

index 951fc39..bb0f175 100644 (file)
@@ -308,6 +308,7 @@ static int mdd_process_config(const struct lu_context *ctxt,
         struct mdd_device *m    = lu2mdd_dev(d);
         struct dt_device  *dt   = m->mdd_child;
         struct lu_device  *next = &dt->dd_lu_dev;
+        char              *dev = lustre_cfg_string(cfg, 0);
         int rc;
 
         switch(cfg->lcfg_command) {
@@ -316,10 +317,11 @@ static int mdd_process_config(const struct lu_context *ctxt,
                 if (rc)
                         GOTO(out, rc);
                 dt->dd_ops->dt_conf_get(ctxt, dt, &m->mdd_dt_conf);
+
                 rc = mdd_mount(ctxt, m);
                 if (rc)
                         GOTO(out, rc);
-                rc = mdd_init_obd(ctxt, m);
+                rc = mdd_init_obd(ctxt, m, dev);
                 if (rc) {
                         CERROR("lov init error %d \n", rc);
                         GOTO(out, rc);
index a168cb5..6ed34f6 100644 (file)
@@ -53,7 +53,8 @@ struct mdd_thread_info {
         struct lov_mds_md mti_lmm;
 };
 
-int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd);
+int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd, 
+                 char *dev);
 int mdd_xattr_set(const struct lu_context *ctxt, struct md_object *obj,
                   const void *buf, int buf_len, const char *name, int fl);
 int mdd_lov_set_md(const struct lu_context *ctxt, struct md_object *pobj,
index f4d2801..d478777 100644 (file)
@@ -154,7 +154,8 @@ static struct md_lov_ops mdd_lov_ops = {
 };
 
 /*The obd is created for handling data stack for mdd*/
-int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd)
+int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd, 
+                 char *dev)
 {
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg      *lcfg;
@@ -168,6 +169,7 @@ int mdd_init_obd(const struct lu_context *ctxt, struct mdd_device *mdd)
         lustre_cfg_bufs_set_string(&bufs, 1, MDD_OBD_TYPE);
         lustre_cfg_bufs_set_string(&bufs, 2, MDD_OBD_UUID);
         lustre_cfg_bufs_set_string(&bufs, 3, MDD_OBD_PROFILE);
+        lustre_cfg_bufs_set_string(&bufs, 4, (char*)dev);
 
         lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
         if (!lcfg)
index 1f35aac..fdc3108 100644 (file)
@@ -2678,27 +2678,81 @@ static __attribute__((unused)) void /*__exit*/ mds_exit(void)
 static int mds_cmd_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 {
         struct mds_obd *mds = &obd->u.mds;
+        struct lvfs_run_ctxt saved;
+        const char     *dev;
+        struct vfsmount *mnt;
+        struct lustre_sb_info *lsi;
+        struct lustre_mount_info *lmi;
+        struct dentry  *dentry;
         int rc = 0;
         ENTRY;
 
         CDEBUG(D_INFO, "obd %s setup \n", obd->obd_name);
         if (strcmp(obd->obd_name, MDD_OBD_NAME))
                 RETURN(0);
+     
+        if (lcfg->lcfg_bufcount < 5) {
+                CERROR("invalid arg for setup %s\n", MDD_OBD_NAME);
+                RETURN(-EINVAL);
+        }
+        dev = lustre_cfg_string(lcfg, 4);
+        lmi = server_get_mount(dev);
+        LASSERT(lmi != NULL); 
+        
+        lsi = s2lsi(lmi->lmi_sb);
+        mnt = lmi->lmi_mnt;
         
+        obd->obd_fsops = fsfilt_get_ops(MT_STR(lsi->lsi_ldd));
+        mds_init_ctxt(obd, mnt);
+
+        push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+        dentry = simple_mkdir(current->fs->pwd, "OBJECTS", 0777, 1);
+        if (IS_ERR(dentry)) {
+                rc = PTR_ERR(dentry);
+                CERROR("cannot create OBJECTS directory: rc = %d\n", rc);
+                GOTO(err_pop, rc);
+        }
+        mds->mds_objects_dir = dentry;
+
+        dentry = lookup_one_len("__iopen__", current->fs->pwd,
+                                strlen("__iopen__"));
+        if (IS_ERR(dentry)) {
+                rc = PTR_ERR(dentry);
+                CERROR("cannot lookup __iopen__ directory: rc = %d\n", rc);
+                GOTO(err_pop, rc);
+        }
+
+        mds->mds_fid_de = dentry;
+        if (!dentry->d_inode || is_bad_inode(dentry->d_inode)) {
+                rc = -ENOENT;
+                CERROR("__iopen__ directory has no inode? rc = %d\n", rc);
+                GOTO(err_fid, rc);
+        }
+
         rc = mds_lov_presetup(mds, lcfg);
         if (rc < 0)
-                RETURN(rc);
+                GOTO(err_objects, rc);
 
         /* Don't wait for mds_postrecov trying to clear orphans */
         obd->obd_async_recov = 1;
         rc = mds_postsetup(obd);
         obd->obd_async_recov = 0;
-
+        
+        if (rc)
+                GOTO(err_objects, rc);
+        
         sema_init(&mds->mds_orphan_recovery_sem, 1);
         mds->mds_max_mdsize = sizeof(struct lov_mds_md);
         mds->mds_max_cookiesize = sizeof(struct llog_cookie);
-        
+
+err_pop:
+        pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         RETURN(rc);
+err_fid:
+        dput(mds->mds_fid_de);
+err_objects:
+        dput(mds->mds_objects_dir);
+        goto err_pop;
 }
 
 static int mds_cmd_cleanup(struct obd_device *obd)
index 82214b0..615937a 100644 (file)
@@ -413,31 +413,39 @@ err_msd:
         RETURN(rc);
 }
 
-int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
+void mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt)
 {
         struct mds_obd *mds = &obd->u.mds;
-        struct lvfs_run_ctxt saved;
-        struct dentry *dentry;
-        struct file *file;
-        int rc;
-        ENTRY;
-
-        rc = cleanup_group_info();
-        if (rc)
-                RETURN(rc);
 
         mds->mds_vfsmnt = mnt;
         /* why not mnt->mnt_sb instead of mnt->mnt_root->d_inode->i_sb? */
         obd->u.obt.obt_sb = mnt->mnt_root->d_inode->i_sb;
 
         fsfilt_setup(obd, obd->u.obt.obt_sb);
-
+        
         OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
         obd->obd_lvfs_ctxt.pwdmnt = mnt;
         obd->obd_lvfs_ctxt.pwd = mnt->mnt_root;
         obd->obd_lvfs_ctxt.fs = get_ds();
         obd->obd_lvfs_ctxt.cb_ops = mds_lvfs_ops;
+        return;
+}
 
+int mds_fs_setup(struct obd_device *obd, struct vfsmount *mnt)
+{
+        struct mds_obd *mds = &obd->u.mds;
+        struct lvfs_run_ctxt saved;
+        struct dentry *dentry;
+        struct file *file;
+        int rc;
+        ENTRY;
+
+        rc = cleanup_group_info();
+        if (rc)
+                RETURN(rc);
+
+        mds_init_ctxt(obd, mnt);
+        
         /* setup the directory tree */
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         dentry = simple_mkdir(current->fs->pwd, "ROOT", 0755, 0);
@@ -651,6 +659,10 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
         /* the owner of object file should always be root */
         ucred.luc_cap = current->cap_effective | CAP_SYS_RESOURCE;
 
+        if (strcmp(exp->exp_obd->obd_name, MDD_OBD_NAME)) {
+                RETURN(0);
+        }
+        
         push_ctxt(&saved, &exp->exp_obd->obd_lvfs_ctxt, &ucred);
 
         sprintf(fidname, "OBJECTS/%u.%u", tmpname, current->pid);
index 3a61aa9..ce4bd3a 100644 (file)
@@ -224,6 +224,7 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa,
 int mds_obd_destroy(struct obd_export *exp, struct obdo *oa,
                     struct lov_stripe_md *ea, struct obd_trans_info *oti,
                     struct obd_export *md_exp);
+void mds_init_ctxt(struct obd_device *obd, struct vfsmount *mnt);
 
 /* mds/handler.c */
 extern struct lvfs_callback_ops mds_lvfs_ops;
index eda390f..8b314a4 100644 (file)
@@ -316,6 +316,7 @@ static int mds_lov_update_mds(struct obd_device *obd,
                 llog_cat_initialize(obd, mli->md_lov_desc.ld_tgt_count);
                 up(&mli->md_lov_orphan_recovery_sem);
         }
+#else
         CDEBUG(D_CONFIG, "reset llogs idx=%d\n", idx);
         llog_cat_initialize(obd, mli->md_lov_desc.ld_tgt_count);
 #endif
@@ -685,6 +686,7 @@ static int __mds_lov_synchronize(void *data)
 {
         struct mds_lov_sync_info *mlsi = data;
         struct obd_device *obd = mlsi->mlsi_obd;
+        struct mds_obd *mds = &obd->u.mds;
         struct obd_device *watched = mlsi->mlsi_watched;
         struct md_lov_info *mli = mlsi->mlsi_mli;
         const void *ctxt = mlsi->mlsi_ctxt;
@@ -709,7 +711,6 @@ static int __mds_lov_synchronize(void *data)
         if (rc != 0)
                 GOTO(out, rc);
 
-#if 0
         rc = llog_connect(llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT),
                           mds->mds_lov_desc.ld_tgt_count,
                           NULL, NULL, uuid);
@@ -719,7 +720,6 @@ static int __mds_lov_synchronize(void *data)
                        obd->obd_name, rc);
                 GOTO(out, rc);
         }
-#endif
         LCONSOLE_INFO("MDS %s: %s now active, resetting orphans\n",
               obd->obd_name, obd_uuid2str(uuid));
 
index ec9e739..d9cb8a4 100644 (file)
@@ -713,12 +713,6 @@ int llog_get_cat_list(struct obd_device *obd, struct obd_device *disk_obd,
         if (!count) 
                 return (0);
 
-        if (!strcmp(disk_obd->obd_name, MDD_OBD_NAME)) {
-                struct md_lov_info *mli = &disk_obd->u.mds.mds_lov_info;
-                rc = mli->md_lov_ops->ml_read_catlist(disk_obd, idarray,
-                                                       size, NULL);
-                return (0);
-        }
         push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
         file = filp_open(name, O_RDWR | O_CREAT | O_LARGEFILE, 0700);
         if (!file || IS_ERR(file)) {