Whamcloud - gitweb
- fixes and cleanups in error messages and in code.
authoryury <yury>
Fri, 19 Nov 2004 14:36:00 +0000 (14:36 +0000)
committeryury <yury>
Fri, 19 Nov 2004 14:36:00 +0000 (14:36 +0000)
- changed mds_alloc_inode_sid() to allocate lustre_id in memory if there is
no passed one. This makes mds stuff do not use lustre_id allocated on stack
if there is only need to allocate inode sid without using it later. This
makes stack consumption smaller by 40 bytes in each such a case.

- in mds_setup() whrn comparing strings passed from userspace use strncmp()
- root lustre_id should be set up also in cases when there is no profile.
- making do not use lustre_id allocated on stack in places where it is possible.

- moving mds_finish_transno() calling to place where dput() for dchild is
already called to make sure, that unlink op got to current transaction.

- lots of changes in lconf. MDSDEV stuff is changed substantionaly. Removing
bugs prone code, replacing it by new one about setting up MDS, LMV, etc.
Added more verbose messages about MDS, LMV configuration. Removed redundant
stuff about forming mount options. It now is moved to function and be used from
few places.

- fixes in CMOBD and COBD objects about using LMV.

- fixed double client_ref adding to LMV, what led to double client config
writing on MDS setup.

14 files changed:
lustre/liblustre/namei.c
lustre/lmv/lmv_obd.c
lustre/lvfs/fsfilt_ext3.c
lustre/mdc/mdc_locks.c
lustre/mds/handler.c
lustre/mds/mds_fs.c
lustre/mds/mds_lmv.c
lustre/mds/mds_reint.c
lustre/obdclass/genops.c
lustre/obdclass/obd_config.c
lustre/smfs/inode.c
lustre/tests/replay-dual.sh
lustre/utils/lconf
lustre/utils/lmc

index 04606fd..a0bc94d 100644 (file)
@@ -374,7 +374,6 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset,
                 LL_SAVE_INTENT(inode, it);
 
         child->p_base->pb_ino = inode;
-
         RETURN(0);
 }
 
index e88dfc4..b8b7453 100644 (file)
@@ -547,7 +547,7 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf)
         }
 
         if (lcfg->lcfg_inllen2 < 1) {
-                CERROR("LMV setup requires an OST UUID list\n");
+                CERROR("LMV setup requires an MDT UUID list\n");
                 RETURN(-EINVAL);
         }
 
@@ -590,7 +590,7 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf)
                 OBD_FREE(lmv->tgts, lmv->tgts_size);
         }
 
-        tgt_obd = class_find_client_obd(&lmv->tgts->uuid, LUSTRE_MDC_NAME, 
+        tgt_obd = class_find_client_obd(&lmv->tgts->uuid, LUSTRE_MDC_NAME,
                                         &obd->obd_uuid);
         if (!tgt_obd) {
                 CERROR("Target %s not attached\n", lmv->tgts->uuid.uuid);
@@ -631,8 +631,9 @@ static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs,
 
                 rc = obd_statfs(lmv->tgts[i].ltd_exp->exp_obd, &temp, max_age);
                 if (rc) {
-                        CERROR("can't stat MDS #%d (%s)\n", i,
-                               lmv->tgts[i].ltd_exp->exp_obd->obd_name);
+                        CERROR("can't stat MDS #%d (%s), error %d\n", i,
+                               lmv->tgts[i].ltd_exp->exp_obd->obd_name,
+                               rc);
                         RETURN(rc);
                 }
                 if (i == 0) {
index 9e72149..877cfca 100644 (file)
@@ -1194,8 +1194,8 @@ static int fsfilt_ext3_setup(struct obd_device *obd, struct super_block *sb)
                 int err;
                 
                 if (!EXT3_HAS_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_MDSNUM)) {
-                        CWARN("%s: set mdsnum %d in ext3fs\n",
-                                        obd->obd_name, mds->mds_num);
+                        CWARN("%s: set mdsnum %d in ext3\n",
+                              obd->obd_name, mds->mds_num);
                         lock_kernel();
                         handle = journal_start(sbi->s_journal, 1);
                         unlock_kernel();
index a64942d..182d5bc 100644 (file)
@@ -375,7 +375,7 @@ int mdc_enqueue(struct obd_export *exp,
                 struct mds_body *body;
 
                 body = lustre_swab_repbuf(req, 1, sizeof (*body),
-                                           lustre_swab_mds_body);
+                                          lustre_swab_mds_body);
                 if (body == NULL) {
                         CERROR ("Can't swab mds_body\n");
                         RETURN (-EPROTO);
index c3434d8..0c6b449 100644 (file)
@@ -2502,11 +2502,18 @@ int mds_alloc_inode_sid(struct obd_device *obd, struct inode *inode,
                         void *handle, struct lustre_id *id)
 {
         struct mds_obd *mds = &obd->u.mds;
-        int rc = 0;
+        int alloc = 0, rc = 0;
         ENTRY;
 
-        LASSERT(id != NULL);
         LASSERT(obd != NULL);
+        LASSERT(inode != NULL);
+
+        if (id == NULL) {
+                OBD_ALLOC(id, sizeof(*id));
+                if (id == NULL)
+                        RETURN(-ENOMEM);
+                alloc = 1;
+        }
 
         id_group(id) = mds->mds_num;
         
@@ -2525,6 +2532,8 @@ int mds_alloc_inode_sid(struct obd_device *obd, struct inode *inode,
                        "rc = %d\n", rc);
         }
 
+        if (alloc)
+                OBD_FREE(id, sizeof(*id));
         RETURN(rc);
 }
 
@@ -2677,8 +2686,10 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         /* we have to know mdsnum before touching underlying fs -bzzz */
         sema_init(&mds->mds_lmv_sem, 1);
         mds->mds_lmv_connected = 0;
+        mds->mds_lmv_name = NULL;
+        
         if (lcfg->lcfg_inllen5 > 0 && lcfg->lcfg_inlbuf5 && 
-            strcmp(lcfg->lcfg_inlbuf5, "dumb")) {
+            strncmp(lcfg->lcfg_inlbuf5, "dumb", lcfg->lcfg_inllen5)) {
                 class_uuid_t uuid;
 
                 CDEBUG(D_OTHER, "MDS: %s is master for %s\n",
@@ -2704,7 +2715,7 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         mds->mds_obd_type = MDS_MASTER_OBD;
 
         if (lcfg->lcfg_inllen6 > 0 && lcfg->lcfg_inlbuf6 &&
-            strcmp(lcfg->lcfg_inlbuf6, "dumb")) {
+            strncmp(lcfg->lcfg_inlbuf6, "dumb", lcfg->lcfg_inllen6)) {
                 if (!memcmp(lcfg->lcfg_inlbuf6, "master", strlen("master"))) {
                         mds->mds_obd_type = MDS_MASTER_OBD;
                 } else if (!memcmp(lcfg->lcfg_inlbuf6, "cache", strlen("cache"))) {
@@ -2751,12 +2762,8 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         if (rc < 0)
                 GOTO(err_fs, rc);
 
-        /*
-         * this check for @dumb string is needed to handle mounting MDS with
-         * smfs. Read lconf:MDSDEV.write_conf() for more details.
-         */
         if (lcfg->lcfg_inllen3 > 0 && lcfg->lcfg_inlbuf3 &&
-            strcmp(lcfg->lcfg_inlbuf3, "dumb")) {
+            strncmp(lcfg->lcfg_inlbuf3, "dumb", lcfg->lcfg_inllen3)) {
                 class_uuid_t uuid;
 
                 generate_random_uuid(uuid);
@@ -2768,17 +2775,19 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 
                 memcpy(mds->mds_profile, lcfg->lcfg_inlbuf3,
                        lcfg->lcfg_inllen3);
+        }
 
-                /*
-                 * setup root id in the case this is not clients write
-                 * setup. This is important, as in the case of LMV we need
-                 * mds->mds_num to be already assigned to form correct root fid.
-                 */
+        /* 
+         * setup root dir and files ID dir if lmv already connected, or there is
+         * not lmv at all.
+         */
+        if (mds->mds_lmv_exp || (lcfg->lcfg_inllen3 > 0 && lcfg->lcfg_inlbuf3 &&
+                                 strncmp(lcfg->lcfg_inlbuf3, "dumb", lcfg->lcfg_inllen3)))
+        {
                 rc = mds_fs_setup_rootid(obd);
                 if (rc)
                         GOTO(err_fs, rc);
 
-                /* setup lustre id for ID directory. */
                 rc = mds_fs_setup_virtid(obd);
                 if (rc)
                         GOTO(err_fs, rc);
index c84d86f..88159ab 100644 (file)
@@ -532,7 +532,6 @@ int mds_fs_setup_virtid(struct obd_device *obd)
 {
         int rc = 0;
         void *handle;
-        struct lustre_id id;
         struct mds_obd *mds = &obd->u.mds;
         struct inode *inode = mds->mds_id_dir->d_inode;
         ENTRY;
@@ -547,7 +546,7 @@ int mds_fs_setup_virtid(struct obd_device *obd)
         }
         
         down(&inode->i_sem);
-        rc = mds_alloc_inode_sid(obd, inode, handle, &id);
+        rc = mds_alloc_inode_sid(obd, inode, handle, NULL);
         up(&inode->i_sem);
         
         if (rc) {
index 6c76ff3..64d7cca 100644 (file)
@@ -41,9 +41,7 @@
 /*
  * TODO:
  *   - magic in mea struct
- *   - error handling is totally missed
  */
-
 int mds_lmv_connect(struct obd_device *obd, char *lmv_name)
 {
         struct mds_obd *mds = &obd->u.mds;
index 794ad59..a2a4b73 100644 (file)
@@ -279,12 +279,12 @@ int mds_fix_attr(struct inode *inode, struct mds_update_record *rec)
 void mds_steal_ack_locks(struct ptlrpc_request *req)
 {
         struct obd_export         *exp = req->rq_export;
+        char                       str[PTL_NALFMT_SIZE];
         struct list_head          *tmp;
         struct ptlrpc_reply_state *oldrep;
         struct ptlrpc_service     *svc;
         struct llog_create_locks  *lcl;
         unsigned long              flags;
-        char                       str[PTL_NALFMT_SIZE];
         int                        i;
 
         /* CAVEAT EMPTOR: spinlock order */
@@ -306,8 +306,7 @@ void mds_steal_ack_locks(struct ptlrpc_request *req)
                 list_del_init (&oldrep->rs_exp_list);
 
                 CWARN("Stealing %d locks from rs %p x"LPD64".t"LPD64
-                      " o%d NID %s\n",
-                      oldrep->rs_nlocks, oldrep,
+                      " o%d NID %s\n", oldrep->rs_nlocks, oldrep,
                       oldrep->rs_xid, oldrep->rs_transno, oldrep->rs_msg.opc,
                       ptlrpc_peernid2str(&exp->exp_connection->c_peer, str));
 
@@ -687,7 +686,6 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
         }
         case S_IFDIR:{
                 int i, nstripes = 0;
-                struct lustre_id sid;
                 
                 /*
                  * as Peter asked, mkdir() should distribute new directories
@@ -725,7 +723,7 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                                 mds_set_last_fid(obd, id_fid(rec->ur_id2));
                         } else {
                                 rc = mds_alloc_inode_sid(obd, dchild->d_inode,
-                                                         handle, &sid);
+                                                         handle, NULL);
                                 if (rc) {
                                         CERROR("mds_alloc_inode_sid() failed, inode %lu, "
                                                "rc %d\n", dchild->d_inode->i_ino, rc);
@@ -948,15 +946,13 @@ static int mds_reint_create(struct mds_update_record *rec, int offset,
                                inode->i_ino, inode->i_generation);
 
                         if (type != S_IFDIR) {
-                                struct lustre_id sid;
-                                
                                 /* 
                                  * allocate new id for @inode if it is not dir,
                                  * because for dir it was already done.
                                  */
                                 down(&inode->i_sem);
                                 rc = mds_alloc_inode_sid(obd, inode,
-                                                         handle, &sid);
+                                                         handle, NULL);
                                 up(&inode->i_sem);
                                 if (rc) {
                                         CERROR("mds_alloc_inode_sid() failed, "
@@ -2119,8 +2115,8 @@ cleanup:
                 if (err)
                         CERROR("error on parent setattr: rc = %d\n", err);
         }
-        rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL,
-                                handle, req, rc, 0);
+//        rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL,
+//                                handle, req, rc, 0);
         if (!rc)
                 (void)obd_set_info(mds->mds_lov_exp, strlen("unlinked"),
                                    "unlinked", 0, NULL);
@@ -2160,6 +2156,9 @@ cleanup:
                         ptlrpc_save_lock(req, parent_lockh, LCK_PW);
                 l_dput(dchild);
                 l_dput(dchild);
+
+                rc = mds_finish_transno(mds, dparent ? dparent->d_inode : NULL,
+                                        handle, req, rc, 0);
                 l_dput(dparent);
         case 0:
                 break;
@@ -2876,13 +2875,9 @@ static int mds_add_local_dentry(struct mds_update_record *rec, int offset,
                 if (rc)
                         GOTO(cleanup, rc);
         } else if (de->d_flags & DCACHE_CROSS_REF) {
-                struct lustre_id de_id;
-
-                /* name exists and points to remote inode */
-                mds_pack_dentry2id(obd, &de_id, de, 1);
-                
-                CDEBUG(D_OTHER, "%s: %s points to remote inode "DLID4"\n",
-                       obd->obd_name, rec->ur_tgt, OLID4(&de_id));
+                CDEBUG(D_OTHER, "%s: %s points to remote inode %lu/%lu\n",
+                       obd->obd_name, rec->ur_tgt, (unsigned long)de->d_mdsnum,
+                        (unsigned long)de->d_fid);
 
                 /* checking if we can remove local dentry. */
                 rc = mds_check_for_rename(obd, de);
index a1890b4..4c3d3f8 100644 (file)
@@ -182,7 +182,7 @@ int class_unregister_type(char *name)
         if (type->typ_ops != NULL)
                 OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
         if (type->typ_md_ops != NULL)
-                OBD_FREE (type->typ_md_ops, sizeof (*type->typ_md_ops));
+                OBD_FREE (type->typ_md_ops, sizeof(*type->typ_md_ops));
         OBD_FREE(type, sizeof(*type));
         RETURN(0);
 } /* class_unregister_type */
@@ -335,7 +335,6 @@ struct obd_device * class_devices_in_group(struct obd_uuid *grp_uuid, int *next)
         return NULL;
 }
 
-
 void obd_cleanup_caches(void)
 {
         ENTRY;
index b61a28e..46726e3 100644 (file)
@@ -81,8 +81,8 @@ static int class_attach(struct lustre_cfg *lcfg)
         uuid = lcfg->lcfg_inlbuf2;
 
         CDEBUG(D_IOCTL, "attach type %s name: %s uuid: %s\n",
-               MKSTR(lcfg->lcfg_inlbuf1),
-               MKSTR(lcfg->lcfg_dev_name), MKSTR(lcfg->lcfg_inlbuf2));
+               MKSTR(lcfg->lcfg_inlbuf1), MKSTR(lcfg->lcfg_dev_name),
+               MKSTR(lcfg->lcfg_inlbuf2));
 
         /* find the type */
         type = class_get_type(typename);
index c7fff18..8d89199 100644 (file)
@@ -164,7 +164,7 @@ struct inode *smfs_iget(struct super_block *sb, ino_t hash,
                 if (inode->i_state & I_NEW)
                         unlock_new_inode(inode);
                 CDEBUG(D_VFSTRACE, "inode: %lu/%u(%p) index %d "
-                       "ino %lu \n", inode->i_ino, inode->i_generation,
+                       "ino %d\n", inode->i_ino, inode->i_generation,
                        inode, sargs->s_index, sargs->s_ino);
                 inode->i_ino = hash;
         }
index 665dbbe..e6e06e1 100755 (executable)
@@ -18,7 +18,7 @@ gen_config() {
         add_lmv lmv1_svc
         for mds in `mds_list`; do
             MDSDEV=$TMP/${mds}-`hostname`
-            add_mds $mds --dev $MDSDEV --size $MDSSIZE  --lmv lmv1_svc
+            add_mds $mds --dev $MDSDEV --size $MDSSIZE --lmv lmv1_svc
         done
         add_lov_to_lmv lov1 lmv1_svc --stripe_sz $STRIPE_BYTES \
            --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
@@ -28,7 +28,6 @@ gen_config() {
         add_lov lov1 mds1 --stripe_sz $STRIPE_BYTES \
            --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
        MDS=mds1_svc
-
     fi
 
     add_ost ost --lov lov1 --dev $OSTDEV --size $OSTSIZE --failover
@@ -36,8 +35,6 @@ gen_config() {
     add_client client  ${MDS} --lov lov1 --path $MOUNT
 }
 
-
-
 build_test_filter
 
 SETUP=${SETUP:-"setup"}
index 22af909..b002276 100755 (executable)
@@ -776,7 +776,7 @@ def do_find_file(base, mod):
 def is_block(path):
     s = ()
     try:
-        s =  os.lstat(path)
+        s =  os.stat(path)
     except OSError:
         return 0
     return stat.S_ISBLK(s[stat.ST_MODE])
@@ -1647,6 +1647,8 @@ class LMV(Module):
     def prepare(self):
         if is_prepared(self.name):
             return
+           
+       self.info();
         for mdc in self.mdclist:
             try:
                 # Only ignore connect failures with --force, which
@@ -1655,6 +1657,7 @@ class LMV(Module):
             except CommandError, e:
                 print "Error preparing LMV %s\n" % mdc.uuid
                 raise e
+       
         lctl.lmv_setup(self.name, self.uuid, self.desc_uuid,
                        string.join(self.devlist))
 
@@ -1694,21 +1697,14 @@ class MDSDEV(Module):
         self.name = self.mds.getName()
         self.client_uuids = self.mds.get_refs('client')
         
-        # LMV instance
-       self.lmv_uuid = ""
-       self.lmv = ''
-        
-        self.master_uuid = ""
-        self.master = ''
-        
-        # it is possible to have MDS with no clients. It is master MDS
-        # in configuration with CMOBD.
-        self.lmv_uuid = self.db.get_first_ref('lmv')
-       if self.lmv_uuid:
-           self.lmv = self.db.lookup(self.lmv_uuid)
-           if self.lmv:
+       self.lmv = None
+        self.master = None
+       
+        lmv_uuid = self.db.get_first_ref('lmv')
+       if lmv_uuid != None:
+           self.lmv = self.db.lookup(lmv_uuid)
+           if self.lmv != None:
                 self.client_uuids = self.lmv.get_refs('client')
-                self.master_uuid = self.lmv_uuid
 
         # FIXME: if fstype not set, then determine based on kernel version
         self.format = self.db.get_val('autoformat', "no")
@@ -1736,27 +1732,27 @@ class MDSDEV(Module):
         else:
             # find the LOV for this MDS
             lovconfig_uuid = self.mds.get_first_ref('lovconfig')
-            if lovconfig_uuid or self.lmv:
-                if self.lmv:
+            if lovconfig_uuid or self.lmv != None:
+                if self.lmv != None:
                     lovconfig_uuid = self.lmv.get_first_ref('lovconfig')
                     lovconfig = self.lmv.lookup(lovconfig_uuid)
                     lov_uuid = lovconfig.get_first_ref('lov')
-                    if not lov_uuid:
+                    if lov_uuid == None:
                         panic(self.mds.getName() + ": No LOV found for lovconfig ", 
                               lovconfig.name)
                else:
                     lovconfig = self.mds.lookup(lovconfig_uuid)
                     lov_uuid = lovconfig.get_first_ref('lov')
-                    if not lov_uuid:
+                    if lov_uuid == None:
                        panic(self.mds.getName() + ": No LOV found for lovconfig ", 
                              lovconfig.name)
 
-                   if self.lmv:
+                   if self.lmv != None:
                        lovconfig_uuid = self.lmv.get_first_ref('lovconfig')
                        lovconfig = self.lmv.lookup(lovconfig_uuid)
                        lov_uuid = lovconfig.get_first_ref('lov')
 
-                lov = LOV(self.db.lookup(lov_uuid), lov_uuid, 'FS_name'
+                lov = LOV(self.db.lookup(lov_uuid), lov_uuid, self.name
                           config_only = 1)
 
                 # default stripe count controls default inode_size
@@ -1776,11 +1772,10 @@ class MDSDEV(Module):
         self.uuid = target_uuid
 
        # setup LMV
-       if self.master_uuid:
-           client_uuid = self.name + "_lmv_" + "UUID"
-           self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, 
-                              self.name, self.name)
-           self.master_uuid = self.master.name
+       if self.lmv != None:
+           client_uuid = self.name + "_lmv_UUID"
+           self.master = LMV(self.lmv, client_uuid, 
+                             self.name, self.name)
 
     def add_module(self, manager):
         if self.active:
@@ -1812,9 +1807,34 @@ class MDSDEV(Module):
                    manager.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype))
 
        # add LMV modules
-       if self.master_uuid:
+       if self.master != None:
             self.master.add_module(manager)
-
+           
+    def get_mount_options(self, blkdev):
+        options = def_mount_options(self.fstype, 'mds')
+            
+        if config.mountfsoptions != None:
+            if options != None:
+                options = "%s,%s" %(options, config.mountfsoptions)
+            else:
+                options = config.mountfsoptions
+            if self.mountfsoptions != None:
+                options = "%s,%s" %(options, self.mountfsoptions)
+        else:
+            if self.mountfsoptions != None:
+                if options != None:
+                    options = "%s,%s" %(options, self.mountfsoptions)
+                else:
+                    options = self.mountfsoptions
+            
+        if self.fstype == 'smfs':
+            if options != None:
+                options = "%s,type=%s,dev=%s" %(options, 
+                          self.backfstype, blkdev)
+            else:
+                options = "type=%s,dev=%s" %(self.backfstype, blkdev)
+       return options
+       
     def prepare(self):
         if not config.record and is_prepared(self.name):
             return
@@ -1824,11 +1844,10 @@ class MDSDEV(Module):
         if config.reformat:
             # run write_conf automatically, if --reformat used
             self.write_conf()
-        self.info(self.devpath, self.fstype, self.size, self.format)
         run_acceptors()
         
        # prepare LMV
-       if self.master_uuid:
+       if self.master != None:
              self.master.prepare()
             
         # never reformat here
@@ -1839,53 +1858,33 @@ class MDSDEV(Module):
         if not is_prepared('MDT'):
             lctl.newdev("mdt", 'MDT', 'MDT_UUID', setup ="")
         try: 
-            mountfsoptions = def_mount_options(self.fstype, 'mds')
-            
-            if config.mountfsoptions:
-                if mountfsoptions:
-                    mountfsoptions = mountfsoptions + ',' + config.mountfsoptions
-                else:
-                    mountfsoptions = config.mountfsoptions
-                if self.mountfsoptions:
-                    mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-            else:
-                if self.mountfsoptions:
-                    if mountfsoptions:
-                        mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-                    else:
-                        mountfsoptions = self.mountfsoptions
-            
             if self.fstype == 'smfs':
                 realdev = self.fstype
-                
-                if mountfsoptions:
-                    mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                            self.backfstype, 
-                                                            blkdev)
-                else:
-                    mountfsoptions = "type=%s,dev=%s" % (self.backfstype, 
-                                                         blkdev)
             else:
                 realdev = blkdev
-                
-            print 'MDS mount options: ' + mountfsoptions
-            
-           if not self.master_uuid:
-                self.master_uuid = 'dumb'
-                
-            if not self.obdtype:
+               
+            if self.obdtype == None:
                 self.obdtype = 'dumb'
+               
+           if self.master == None:
+               master_name = 'dumb'
+           else:
+               master_name = self.master.name
+                
+            if self.client_uuids == None:
+               profile_name = 'dumb'
+           else:
+               profile_name = self.name
             
-            if not self.client_uuids:
-               lctl.newdev("mds", self.name, self.uuid,
-                        setup ="%s %s %s %s %s %s" %(realdev, self.fstype, 
-                                               'dumb', mountfsoptions,
-                                               self.master_uuid, self.obdtype))
-            else:
-               lctl.newdev("mds", self.name, self.uuid,
-                        setup ="%s %s %s %s %s %s" %(realdev, self.fstype, 
-                                               self.name, mountfsoptions,
-                                               self.master_uuid, self.obdtype))
+           mountfsoptions = self.get_mount_options(blkdev)
+
+           self.info("mds", realdev, mountfsoptions, self.fstype, self.size, 
+                     self.format, master_name, profile_name, self.obdtype)
+           
+           lctl.newdev("mds", self.name, self.uuid,
+                       setup = "%s %s %s %s %s %s" %(realdev, 
+                           self.fstype, profile_name, mountfsoptions,
+                            master_name, self.obdtype))
 
             if development_mode():
                 procentry = "/proc/fs/lustre/mds/grp_hash_upcall"
@@ -1919,57 +1918,26 @@ class MDSDEV(Module):
             
         do_cleanup = 0
         if not is_prepared(self.name):
-            self.info(self.devpath, self.fstype, self.format)
-
             blkdev = block_dev(self.devpath, self.size, self.fstype,
                                config.reformat, self.format, self.journal_size,
                                self.inode_size, self.mkfsoptions,
                                self.backfstype, self.backdevpath)
 
-            # Even for writing logs we mount mds with supplied mount options
-            # because it will not mount smfs (if used) otherwise.
-
-            mountfsoptions = def_mount_options(self.fstype, 'mds')
-
-            if config.mountfsoptions:
-                if mountfsoptions:
-                    mountfsoptions = mountfsoptions + ',' + config.mountfsoptions
-                else:
-                    mountfsoptions = config.mountfsoptions
-                if self.mountfsoptions:
-                    mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-            else:
-                if self.mountfsoptions:
-                    if mountfsoptions:
-                        mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-                    else:
-                        mountfsoptions = self.mountfsoptions
-
             if self.fstype == 'smfs':
                 realdev = self.fstype
-                
-                if mountfsoptions:
-                    mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                            self.backfstype, 
-                                                            blkdev)
-                else:
-                    mountfsoptions = "type=%s,dev=%s" % (self.backfstype, 
-                                                         blkdev)
             else:
                 realdev = blkdev
             
-            print 'MDS mount options: ' + mountfsoptions
+            # Even for writing logs we mount mds with supplied mount options
+            # because it will not mount smfs (if used) otherwise.
+           mountfsoptions = self.get_mount_options(blkdev)
 
-            if not self.obdtype:
+            if self.obdtype == None:
                 self.obdtype = 'dumb'
                 
-            # As mount options are passed by 4th param to config tool, we need 
-            # to pass something in 3rd param. But we do not want this 3rd param
-            # be counted as a profile name for reading log on MDS setup, thus,
-            # we pass there some predefined sign like 'dumb', which will be 
-            # checked in MDS code and skipped. Probably there is more nice way
-            # like pass empty string and check it in config tool and pass null
-            # as 4th param.
+           self.info("mds", realdev, mountfsoptions, self.fstype, self.size, 
+                     self.format, "dumb", "dumb", self.obdtype)
+           
             lctl.newdev("mds", self.name, self.uuid,
                         setup ="%s %s %s %s %s %s" %(realdev, self.fstype, 
                                                      'dumb', mountfsoptions,
@@ -2078,7 +2046,7 @@ class MDSDEV(Module):
                 cleanup_error(e.rc)
                 Module.cleanup(self)
            # cleanup LMV
-           if self.master_uuid:
+           if self.master != None:
                 self.master.cleanup()
         if not self.msd_remaining() and is_prepared('MDT'):
             try:
@@ -2093,7 +2061,7 @@ class MDSDEV(Module):
                  self.backdevpath)
 
     def correct_level(self, level, op=None):
-       #if self.master_uuid:
+       #if self.master != None:
        #   level = level + 2
         return level
 
@@ -2156,6 +2124,32 @@ class OSD(Module):
 
             manager.add_lustre_module(self.osdtype, self.osdtype)
 
+    def get_mount_options(self, blkdev):
+        options = def_mount_options(self.fstype, 'ost')
+            
+        if config.mountfsoptions != None:
+            if options != None:
+                options = "%s,%s" %(options, config.mountfsoptions)
+            else:
+                options = config.mountfsoptions
+            if self.mountfsoptions != None:
+                options = "%s,%s" %(options, self.mountfsoptions)
+        else:
+            if self.mountfsoptions != None:
+                if options != None:
+                    options = "%s,%s" %(options, self.mountfsoptions)
+                else:
+                    options = self.mountfsoptions
+            
+        if self.fstype == 'smfs':
+            if options != None:
+                options = "%s,type=%s,dev=%s" %(options, 
+                   self.backfstype, blkdev)
+            else:
+                options = "type=%s,dev=%s" %(self.backfstype, 
+                   blkdev)
+       return options
+       
     # need to check /proc/mounts and /etc/mtab before
     # formatting anything.
     # FIXME: check if device is already formatted.
@@ -2165,8 +2159,6 @@ class OSD(Module):
         if not self.active:
             debug(self.uuid, "not active")
             return
-        self.info(self.osdtype, self.devpath, self.size, self.fstype,
-                  self.format, self.journal_size, self.inode_size)
         run_acceptors()
         if self.osdtype == 'obdecho':
             blkdev = ''
@@ -2176,37 +2168,16 @@ class OSD(Module):
                                self.inode_size, self.mkfsoptions, self.backfstype,
                                self.backdevpath)
 
-        mountfsoptions = def_mount_options(self.fstype, 'ost')
-            
-        if config.mountfsoptions:
-            if mountfsoptions:
-                mountfsoptions = mountfsoptions + ',' + config.mountfsoptions
-            else:
-                mountfsoptions = config.mountfsoptions
-            if self.mountfsoptions:
-                mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-        else:
-            if self.mountfsoptions:
-                if mountfsoptions:
-                    mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
-                else:
-                    mountfsoptions = self.mountfsoptions
-            
         if self.fstype == 'smfs':
             realdev = self.fstype
-                
-            if mountfsoptions:
-                mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                        self.backfstype, 
-                                                        blkdev)
-            else:
-                mountfsoptions = "type=%s,dev=%s" % (self.backfstype, 
-                                                     blkdev)
         else:
             realdev = blkdev
-                
-        print 'OSD mount options: ' + mountfsoptions
-        
+
+       mountfsoptions = self.get_mount_options(blkdev)
+       
+        self.info(self.osdtype, realdev, mountfsoptions, self.fstype, 
+                 self.size, self.format, self.journal_size, self.inode_size)
+                 
         lctl.newdev(self.osdtype, self.name, self.uuid,
                     setup ="%s %s %s %s" %(realdev, self.fstype,
                                            self.failover_ost, 
@@ -2412,9 +2383,11 @@ class CMOBD(Module):
         cache_class = cache_obd.get_class()
 
        if master_class == 'ost' or master_class == 'lov':
-            self.master = LOV(master_obd, self.master_uuid, self.name, 
+           client_uuid = "%s_lov_master_UUID" % (self.name)
+            self.master = LOV(master_obd, client_uuid, self.name, 
                               "%s_master" % (self.name));
-            self.cache = LOV(cache_obd, self.cache_uuid, self.name, 
+           client_uuid = "%s_lov_cache_UUID" % (self.name)
+            self.cache = LOV(cache_obd, client_uuid, self.name, 
                              "%s_cache" % (self.name));
         if master_class == 'mds':
            self.master = get_mdc(db, self.name, self.master_uuid) 
@@ -2422,11 +2395,13 @@ class CMOBD(Module):
            self.cache = get_mdc(db, self.name, self.cache_uuid)
             
         if master_class == 'lmv':
-            self.master = LMV(master_obd, self.master_uuid, self.name, 
-                              "%s_master" % (self.name));
+           client_uuid = "%s_lmv_master_UUID" % (self.name)
+            self.master = LMV(master_obd, client_uuid, self.name,
+                             "%s_master" % (self.name));
         if cache_class == 'lmv':
-            self.cache = LMV(cache_obd, self.cache_uuid, self.name, 
-                             "%s_cache" % (self.name));
+           client_uuid = "%s_lmv_cache_UUID" % (self.name)
+            self.cache = LMV(cache_obd, client_uuid, self.name,
+                            "%s_cache" % (self.name));
 
     # need to check /proc/mounts and /etc/mtab before
     # formatting anything.
@@ -2442,17 +2417,21 @@ class CMOBD(Module):
 
     def get_uuid(self):
         return self.uuid
+       
     def get_name(self):
         return self.name
+       
     def get_master_name(self):
-        return self.master.name
+       return self.master.name
+           
     def get_cache_name(self):
         return self.cache.name
 
     def cleanup(self):
         if is_prepared(self.name):
             Module.cleanup(self)
-        self.master.cleanup()
+       if self.master:
+           self.master.cleanup()
 
     def add_module(self, manager):
        manager.add_lustre_module('cmobd', 'cmobd')
@@ -2481,9 +2460,11 @@ class COBD(Module):
         cache_class = cache_obd.get_class()
 
        if master_class == 'ost' or master_class == 'lov':
-            self.master = LOV(master_obd, self.master_uuid, name, 
+           client_uuid = "%s_lov_master_UUID" % (self.name)
+            self.master = LOV(master_obd, client_uuid, name, 
                               "%s_master" % (self.name));
-            self.cache = LOV(cache_obd, self.cache_uuid, name, 
+           client_uuid = "%s_lov_cache_UUID" % (self.name)
+            self.cache = LOV(cache_obd, client_uuid, name, 
                              "%s_cache" % (self.name));
         if master_class == 'mds':
             self.master = get_mdc(db, name, self.master_uuid) 
@@ -2491,11 +2472,13 @@ class COBD(Module):
             self.cache = get_mdc(db, name, self.cache_uuid)
             
         if master_class == 'lmv':
-            self.master = LMV(master_obd, self.master_uuid, self.name, 
-                              "%s_master" % (self.name));
+           client_uuid = "%s_lmv_master_UUID" % (self.name)
+            self.master = LMV(master_obd, client_uuid, self.name,
+                             "%s_master" % (self.name));
         if cache_class == 'lmv':
-            self.cache = LMV(cache_obd, self.cache_uuid, self.name, 
-                             "%s_cache" % (self.name));
+           client_uuid = "%s_lmv_cache_UUID" % (self.name)
+            self.cache = LMV(cache_obd, client_uuid, self.name,
+                            "%s_cache" % (self.name));
            
     # need to check /proc/mounts and /etc/mtab before
     # formatting anything.
@@ -2569,7 +2552,7 @@ class VMDC(Module):
     def __init__(self, db, client_uuid, name, name_override = None):
         Module.__init__(self, 'VMDC', db)
         if db.get_class() == 'lmv':
-            self.mdc = LMV(db, client_uuid, name)
+            self.mdc = LMV(db, client_uuid, name, name_override)
         elif db.get_class() == 'cobd':
             self.mdc = COBD(db, client_uuid, name)
         else:
@@ -2652,8 +2635,8 @@ class Mountpoint(Module):
        if not mds:
            panic("no mds: ", self.mds_uuid)
        
-        self.vosc = VOSC(ost, client_uuid, self.name)
-       self.vmdc = VMDC(mds, client_uuid, self.name)
+        self.vosc = VOSC(ost, client_uuid, self.name, self.name)
+       self.vmdc = VMDC(mds, client_uuid, self.name, self.name)
         
         if self.mgmt_uuid:
             self.mgmtcli = ManagementClient(db.lookup(self.mgmt_uuid),
index 1d5a281..84f4a06 100755 (executable)
@@ -1368,11 +1368,10 @@ def add_lmv(gen, lustre, options):
 def new_filesystem(gen, lustre, mds_uuid, obd_uuid, mgmt_uuid):
     fs_name = new_name("FS_fsname")
     fs_uuid = new_uuid(fs_name)
-
-    obd = lookup(lustre, mds_uuid)
-    obd.appendChild(gen.ref("client", obd_uuid))
-
-    fs = gen.filesystem(fs_name, fs_uuid, mds_uuid, obd_uuid, mgmt_uuid)
+    
+    fs = gen.filesystem(fs_name, fs_uuid, mds_uuid, 
+                       obd_uuid, mgmt_uuid)
+                       
     lustre.appendChild(fs)
     return fs_uuid