Whamcloud - gitweb
- fixed typo in lconf LMV:clanup_module()
[fs/lustre-release.git] / lustre / utils / lconf
index d74fa4f..ff9c71b 100755 (executable)
@@ -23,7 +23,7 @@
 # lconf is the main driver script for starting and stopping
 # lustre filesystem services.
 #
-# Based in part on the XML obdctl modifications done by Brian Behlendorf 
+# Based in part on the XML obdctl modifications done by Brian Behlendorf
 
 import sys, getopt, types
 import string, os, stat, popen2, socket, time, random, fcntl, select
@@ -61,10 +61,10 @@ MAX_LOOP_DEVICES = 256
 PORTALS_DIR = 'portals'
 
 # Needed to call lconf --record
-CONFIG_FILE = "" 
+CONFIG_FILE = ""
 
 # Please keep these in sync with the values in portals/kp30.h
-ptldebug_names = { 
+ptldebug_names = {
     "trace" :     (1 << 0),
     "inode" :     (1 << 1),
     "super" :     (1 << 2),
@@ -88,6 +88,7 @@ ptldebug_names = {
     "rpctrace" :  (1 << 20),
     "vfstrace" :  (1 << 21),
     "reada" :     (1 << 22),
+    "config" :    (1 << 23),
     }
 
 subsystem_names = {
@@ -114,6 +115,7 @@ subsystem_names = {
     "ptlrouter" :    (1 << 20),
     "cobd" :         (1 << 21),
     "ibnal" :        (1 << 22),
+    "cmobd" :        (1 << 23),
     }
 
 
@@ -123,11 +125,11 @@ def cleanup_error(rc):
     if not first_cleanup_error:
         first_cleanup_error = rc
 
-# ============================================================ 
+# ============================================================
 # debugging and error funcs
 
 def fixme(msg = "this feature"):
-    raise Lustre.LconfError, msg + ' not implmemented yet.'
+    raise Lustre.LconfError, msg + ' not implemented yet.'
 
 def panic(*args):
     msg = string.join(map(str,args))
@@ -240,7 +242,7 @@ class DaemonHandler:
             return pid
         except IOError:
             return 0
-        
+
     def clean_pidfile(self):
         """ Remove a stale pidfile """
         log("removing stale pidfile:", self.pidfile())
@@ -248,7 +250,7 @@ class DaemonHandler:
             os.unlink(self.pidfile())
         except OSError, e:
             log(self.pidfile(), e)
-            
+
 class AcceptorHandler(DaemonHandler):
     def __init__(self, port, net_type, send_mem, recv_mem, irq_aff):
         DaemonHandler.__init__(self, "acceptor")
@@ -265,7 +267,7 @@ class AcceptorHandler(DaemonHandler):
 
     def command_line(self):
         return string.join(map(str,('-s', self.send_mem, '-r', self.recv_mem, self.flags, self.port)))
-    
+
 acceptors = {}
 
 # start the acceptors
@@ -285,14 +287,14 @@ def run_one_acceptor(port):
         if not daemon.running():
             daemon.start()
     else:
-         panic("run_one_acceptor: No acceptor defined for port:", port)   
-        
+         panic("run_one_acceptor: No acceptor defined for port:", port)
+
 def stop_acceptor(port):
     if acceptors.has_key(port):
         daemon = acceptors[port]
         if daemon.running():
             daemon.stop()
-        
+
 
 # ============================================================
 # handle lctl interface
@@ -317,7 +319,7 @@ class LCTLInterface:
 
     def use_save_file(self, file):
         self.save_file = file
-        
+
     def record(self, dev_name, logname):
         log("Recording log", logname, "on", dev_name)
         self.record_device = dev_name
@@ -349,13 +351,14 @@ class LCTLInterface:
     device $%s
     record %s
     %s""" % (self.record_device, self.record_log, cmds)
-            
+
         debug("+", cmd_line, cmds)
         if config.noexec: return (0, [])
 
         child = popen2.Popen3(cmd_line, 1) # Capture stdout and stderr from command
         child.tochild.write(cmds + "\n")
         child.tochild.close()
+#      print "LCTL:", cmds
 
         # From "Python Cookbook" from O'Reilly
         outfile = child.fromchild
@@ -400,7 +403,7 @@ class LCTLInterface:
             raise CommandError(self.lctl, out, rc)
         return rc, out
 
-            
+
     def clear_log(self, dev, log):
         """ clear an existing log """
         cmds =  """
@@ -436,7 +439,7 @@ class LCTLInterface:
              recv_mem,
              nid, hostaddr, port, flags )
             self.run(cmds)
-    
+
     def connect(self, srv):
         self.add_uuid(srv.net_type, srv.nid_uuid, srv.nid)
         if srv.net_type  in ('tcp',) and not config.lctl_dump:
@@ -452,7 +455,7 @@ class LCTLInterface:
     device $%s
     recover %s""" %(dev_name, new_conn)
         self.run(cmds)
-                
+
     # add a route to a range
     def add_route(self, net, gw, lo, hi):
         cmds =  """
@@ -465,7 +468,7 @@ class LCTLInterface:
         except CommandError, e:
             log ("ignore: ")
             e.dump()
-                
+
     def del_route(self, net, gw, lo, hi):
         cmds =  """
   ignore_errors
@@ -508,7 +511,7 @@ class LCTLInterface:
   quit""" % (net_type,
              nid, hostaddr)
                 self.run(cmds)
-        
+
     # disconnect one connection
     def disconnect(self, srv):
         self.del_uuid(srv.nid_uuid)
@@ -543,7 +546,7 @@ class LCTLInterface:
   setup %s
   quit""" % (name, setup)
         self.run(cmds)
-        
+
 
     # create a new device with lctl
     def newdev(self, type, name, uuid, setup = ""):
@@ -553,7 +556,7 @@ class LCTLInterface:
         except CommandError, e:
             self.cleanup(name, uuid, 0)
             raise e
-        
+
 
     # cleanup a device
     def cleanup(self, name, uuid, force, failover = 0):
@@ -568,23 +571,42 @@ class LCTLInterface:
         self.run(cmds)
 
     # create an lov
-    def lov_setup(self, name, uuid, desc_uuid, mdsuuid, stripe_cnt,
-                  stripe_sz, stripe_off,
-                      pattern, devlist):
+    def lov_setup(self, name, uuid, desc_uuid, stripe_cnt,
+                  stripe_sz, stripe_off, pattern):
         cmds = """
   attach lov %s %s
-  lov_setup %s %d %d %d %s %s
-  quit""" % (name, uuid, desc_uuid, stripe_cnt, stripe_sz, stripe_off,
-             pattern, devlist)
+  lov_setup %s %d %d %d %s
+  quit""" % (name, uuid, desc_uuid, stripe_cnt, stripe_sz, stripe_off, pattern)
         self.run(cmds)
 
-    # create an lov
-    def lov_setconfig(self, uuid, mdsuuid, stripe_cnt, stripe_sz, stripe_off,
-                      pattern, devlist):
+    # add an OBD to a LOV
+    def lov_add_obd(self, name, uuid, obd_uuid, index, gen):
         cmds = """
-  cfg_device $%s
-  lov_setconfig %s %d %d %d %s %s
-  quit""" % (mdsuuid, uuid, stripe_cnt, stripe_sz, stripe_off, pattern, devlist)
+  lov_modify_tgts add %s %s %s %s
+  quit""" % (name, obd_uuid, index, gen)
+        self.run(cmds)
+
+    # create an lmv
+    def lmv_setup(self, name, uuid, desc_uuid, devlist):
+        cmds = """
+  attach lmv %s %s
+  lmv_setup %s %s
+  quit""" % (name, uuid, desc_uuid, devlist)
+        self.run(cmds)
+
+    # delete an OBD from a LOV
+    def lov_del_obd(self, name, uuid, obd_uuid, index, gen):
+        cmds = """
+  lov_modify_tgts del %s %s %s %s
+  quit""" % (name, obd_uuid, index, gen)
+        self.run(cmds)
+
+    # deactivate an OBD
+    def deactivate(self, name):
+        cmds = """
+  device $%s
+  deactivate
+  quit""" % (name)
         self.run(cmds)
 
     # dump the log file
@@ -632,7 +654,6 @@ class LCTLInterface:
   quit""" % (timeout,)
         self.run(cmds)
 
-    # delete mount options
     def set_lustre_upcall(self, upcall):
         cmds = """
   set_lustre_upcall %s
@@ -704,7 +725,7 @@ def find_module(src_dir, dev_dir, modname):
     modbase = src_dir +'/'+ dev_dir +'/'+ modname
     for modext in '.ko', '.o':
         module = modbase + modext
-        try: 
+        try:
             if os.access(module, os.R_OK):
                 return module
         except OSError:
@@ -719,7 +740,7 @@ def is_block(path):
     except OSError:
         return 0
     return stat.S_ISBLK(s[stat.ST_MODE])
-
+    
 # build fs according to type
 # fixme: dangerous
 def mkfs(dev, devsize, fstype, jsize, isize, mkfsoptions, isblock=1):
@@ -746,7 +767,7 @@ def mkfs(dev, devsize, fstype, jsize, isize, mkfsoptions, isblock=1):
             if devsize > 1024 * 1024:
                 jsize = ((devsize / 102400) * 4)
             if jsize > 400:
-                jsize = 400        
+                jsize = 400
         if jsize:  jopt = "-J size=%d" %(jsize,)
         if isize:  iopt = "-I %d" %(isize,)
         mkfs = 'mkfs.ext2 -j -b 4096 '
@@ -800,10 +821,14 @@ def find_assigned_loop(file):
 
 # create file if necessary and assign the first free loop device
 def init_loop(file, size, fstype, journal_size, inode_size, 
-              mkfsoptions, reformat, backfstype, backfile):
+              mkfsoptions, reformat, autoformat, backfstype, backfile):
     if fstype == 'smfs':
         realfile = backfile
         realfstype = backfstype
+        if is_block(backfile):
+            if reformat or (need_format(realfstype, backfile) and autoformat == 'yes'):
+                mkfs(realfile, size, realfstype, journal_size, inode_size, mkfsoptions, isblock=0)
+            return realfile
     else:
         realfile = file
         realfstype = fstype
@@ -849,7 +874,7 @@ def clean_loop(file):
 
 # determine if dev is formatted as a <fstype> filesystem
 def need_format(fstype, dev):
-    # FIXME don't know how to implement this    
+    # FIXME don't know how to implement this
     return 0
 
 # initialize a block device if needed
@@ -860,7 +885,7 @@ def block_dev(dev, size, fstype, reformat, autoformat, journal_size,
         
     if fstype == 'smfs' or not is_block(dev):
         dev = init_loop(dev, size, fstype, journal_size, inode_size,
-                        mkfsoptions, reformat, backfstype, backdev)
+                        mkfsoptions, reformat, autoformat, backfstype, backdev)
     elif reformat or (need_format(fstype, dev) and autoformat == 'yes'):
         mkfs(dev, size, fstype, journal_size, inode_size, mkfsoptions,
              isblock=0)
@@ -868,7 +893,7 @@ def block_dev(dev, size, fstype, reformat, autoformat, journal_size,
 #        panic("device:", dev,
 #              "not prepared, and autoformat is not set.\n",
 #              "Rerun with --reformat option to format ALL filesystems")
-        
+
     return dev
 
 def if2addr(iface):
@@ -880,6 +905,15 @@ def if2addr(iface):
     ip = string.split(addr, ':')[1]
     return ip
 
+def def_mount_options(fstype, target):
+    """returns deafult mount options for passed fstype and target (mds, ost)"""
+    if fstype == 'ext3' or fstype == 'ldiskfs':
+        mountfsoptions = "errors=remount-ro"
+        if target == 'ost' and sys_get_branch() == '2.4':
+            mountfsoptions = "%s,asyncdel" % (mountfsoptions)
+        return mountfsoptions
+    return ""
+        
 def sys_get_elan_position_file():
     procfiles = ["/proc/elan/device0/position",
                  "/proc/qsnet/elan4/device0/position",
@@ -897,7 +931,7 @@ def sys_get_local_nid(net_type, wildcard, cluster_id):
     else:
         local = sys_get_local_address(net_type, wildcard, cluster_id)
     return local
-        
+
 def sys_get_local_address(net_type, wildcard, cluster_id):
     """Return the local address for the network type."""
     local = ""
@@ -925,7 +959,7 @@ def sys_get_local_address(net_type, wildcard, cluster_id):
                     elan_id = a[1]
                     break
             try:
-                nid = my_int(cluster_id) + my_int(elan_id) 
+                nid = my_int(cluster_id) + my_int(elan_id)
                 local = "%d" % (nid)
             except ValueError, e:
                 local = elan_id
@@ -936,6 +970,22 @@ def sys_get_local_address(net_type, wildcard, cluster_id):
 
     return local
 
+def sys_get_branch():
+    """Returns kernel release"""
+    try:
+        fp = open('/proc/sys/kernel/osrelease')
+        lines = fp.readlines()
+        fp.close()
+        
+        for l in lines:
+            version = string.split(l)
+            a = string.split(version[0], '.')
+            return a[0] + '.' + a[1]
+    except IOError, e:
+        log(e)
+    return ""
+
+
 def mod_loaded(modname):
     """Check if a module is already loaded. Look in /proc/modules for it."""
     try:
@@ -986,7 +1036,7 @@ def fs_is_mounted(path):
     except IOError, e:
         log(e)
     return 0
-        
+
 
 class kmod:
     """Manage kernel modules"""
@@ -1052,7 +1102,7 @@ class Module:
         self._server = None
         self._connected = 0
         self.kmod = kmod(config.lustre, config.portals)
-        
+
     def info(self, *args):
         msg = string.join(map(str,args))
         print self.module_name + ":", self.name, self.uuid, msg
@@ -1066,7 +1116,7 @@ class Module:
             log(self.module_name, "cleanup failed: ", self.name)
             e.dump()
             cleanup_error(e.rc)
-            
+
     def add_portals_module(self, dev_dir, modname):
         """Append a module to list of modules to load."""
         self.kmod.add_portals_module(dev_dir, modname)
@@ -1078,7 +1128,7 @@ class Module:
     def load_module(self):
         """Load all the modules in the list in the order they appear."""
         self.kmod.load_module()
-            
+
     def cleanup_module(self):
         """Unload the modules in the list in reverse order."""
         if self.safe_to_clean():
@@ -1086,10 +1136,10 @@ class Module:
 
     def safe_to_clean(self):
         return 1
-        
+
     def safe_to_clean_modules(self):
         return self.safe_to_clean()
-        
+
 class Network(Module):
     def __init__(self,db):
         Module.__init__(self, 'NETWORK', db)
@@ -1134,7 +1184,7 @@ class Network(Module):
         return "NID_%s_UUID" %(nid,)
 
     def prepare(self):
-        if is_network_prepared():
+        if not config.record and is_network_prepared():
             return
         self.info(self.net_type, self.nid, self.port)
         if not (config.record and self.generic_nid):
@@ -1184,6 +1234,9 @@ class Network(Module):
         if  node_is_router():
             self.disconnect_peer_gateways()
 
+    def correct_level(self, level, op=None):
+        return level
+
 class RouteTable(Module):
     def __init__(self,db):
         Module.__init__(self, 'ROUTES', db)
@@ -1212,9 +1265,9 @@ class RouteTable(Module):
             return None
 
         return Network(srvdb)
-        
+
     def prepare(self):
-        if is_network_prepared():
+        if not config.record and is_network_prepared():
             return
         self.info()
         for net_type, gw, gw_cluster_id, tgt_cluster_id, lo, hi in self.db.get_route_tbl():
@@ -1256,7 +1309,7 @@ class Management(Module):
         self.add_lustre_module('mgmt', 'mgmt_svc')
 
     def prepare(self):
-        if is_prepared(self.name):
+        if not config.record and is_prepared(self.name):
             return
         self.info()
         lctl.newdev("mgmt", self.name, self.uuid)
@@ -1268,6 +1321,9 @@ class Management(Module):
         if is_prepared(self.name):
             Module.cleanup(self)
 
+    def correct_level(self, level, op=None):
+        return level
+
 # This is only needed to load the modules; the LDLM device
 # is now created automatically.
 class LDLM(Module):
@@ -1283,6 +1339,10 @@ class LDLM(Module):
     def cleanup(self):
         return
 
+    def correct_level(self, level, op=None):
+        return level
+
+
 class LOV(Module):
     def __init__(self, db, uuid, fs_name, name_override = None, config_only = None):
         Module.__init__(self, 'LOV', db)
@@ -1290,10 +1350,10 @@ class LOV(Module):
             self.name = "lov_%s" % name_override
         self.add_lustre_module('lov', 'lov')
         self.mds_uuid = self.db.get_first_ref('mds')
-        self.stripe_sz = self.db.get_val_int('stripesize', 65536)
+        self.stripe_sz = self.db.get_val_int('stripesize', 1048576)
         self.stripe_off = self.db.get_val_int('stripeoffset', 0)
         self.pattern = self.db.get_val_int('stripepattern', 0)
-        self.devlist = self.db.get_refs('obd')
+        self.devlist = self.db.get_lov_tgts('lov_tgt')
         self.stripe_cnt = self.db.get_val_int('stripecount', len(self.devlist))
         self.osclist = []
         self.desc_uuid = self.uuid
@@ -1303,49 +1363,54 @@ class LOV(Module):
             self.config_only = 1
             return
         self.config_only = None
-        mds= self.db.lookup(self.mds_uuid)
+        mds = self.db.lookup(self.mds_uuid)
         self.mds_name = mds.getName()
-        for obd_uuid in self.devlist:
+        for (obd_uuid, index, gen, active) in self.devlist:
+            if obd_uuid == '':
+                continue
             obd = self.db.lookup(obd_uuid)
             osc = get_osc(obd, self.uuid, fs_name)
             if osc:
-                self.osclist.append(osc)
+                self.osclist.append((osc, index, gen, active))
             else:
                 panic('osc not found:', obd_uuid)
-            
+    def get_uuid(self):
+        return self.uuid
+    def get_name(self):
+        return self.name
     def prepare(self):
-        if is_prepared(self.name):
+        if not config.record and is_prepared(self.name):
             return
-        if self.config_only:
-            panic("Can't prepare config_only LOV ", self.name)
-            
-        for osc in self.osclist:
+        self.info(self.mds_uuid, self.stripe_cnt, self.stripe_sz,
+                  self.stripe_off, self.pattern, self.devlist,
+                  self.mds_name)
+        lctl.lov_setup(self.name, self.uuid, self.desc_uuid,  self.stripe_cnt,
+                       self.stripe_sz, self.stripe_off, self.pattern)
+        for (osc, index, gen, active) in self.osclist:
+            target_uuid = osc.target_uuid
             try:
                 # Only ignore connect failures with --force, which
                 # isn't implemented here yet.
+                osc.active = active
                 osc.prepare(ignore_connect_failure=0)
             except CommandError, e:
                 print "Error preparing OSC %s\n" % osc.uuid
                 raise e
-        self.info(self.mds_uuid, self.stripe_cnt, self.stripe_sz,
-                  self.stripe_off, self.pattern, self.devlist, self.mds_name)
-        lctl.lov_setup(self.name, self.uuid,
-                       self.desc_uuid, self.mds_name, self.stripe_cnt,
-                       self.stripe_sz, self.stripe_off, self.pattern,
-                       string.join(self.devlist))
+            lctl.lov_add_obd(self.name, self.uuid, target_uuid, index, gen)
 
     def cleanup(self):
+        for (osc, index, gen, active) in self.osclist:
+            target_uuid = osc.target_uuid
+            osc.cleanup()
         if is_prepared(self.name):
             Module.cleanup(self)
         if self.config_only:
             panic("Can't clean up config_only LOV ", self.name)
-        for osc in self.osclist:
-            osc.cleanup()
 
     def load_module(self):
         if self.config_only:
             panic("Can't load modules for config_only LOV ", self.name)
-        for osc in self.osclist:
+        for (osc, index, gen, active) in self.osclist:
             osc.load_module()
             break
         Module.load_module(self)
@@ -1354,10 +1419,70 @@ class LOV(Module):
         if self.config_only:
             panic("Can't cleanup modules for config_only LOV ", self.name)
         Module.cleanup_module(self)
-        for osc in self.osclist:
-            osc.cleanup_module()
+        for (osc, index, gen, active) in self.osclist:
+            if active:
+                osc.cleanup_module()
             break
 
+    def correct_level(self, level, op=None):
+        return level
+
+class LMV(Module):
+    def __init__(self, db, uuid, fs_name, name_override = None):
+        Module.__init__(self, 'LMV', db)
+        if name_override != None:
+            self.name = "lmv_%s" % name_override
+        self.add_lustre_module('lmv', 'lmv')
+        self.devlist = self.db.get_refs('mds')
+        self.mdclist = []
+        self.desc_uuid = self.uuid
+        self.uuid = uuid
+        self.fs_name = fs_name
+        for mds_uuid in self.devlist:
+            mds = self.db.lookup(mds_uuid)
+           if not mds:
+               panic("MDS not found!")
+           mdc = MDC(mds, self.uuid, fs_name)
+           if mdc:
+                self.mdclist.append(mdc)
+            else:
+                panic('mdc not found:', mds_uuid)
+            
+    def prepare(self):
+        if is_prepared(self.name):
+            return
+        for mdc in self.mdclist:
+            try:
+                # Only ignore connect failures with --force, which
+                # isn't implemented here yet.
+                mdc.prepare(ignore_connect_failure=0)
+            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))
+
+    def cleanup(self):
+        for mdc in self.mdclist:
+            mdc.cleanup()
+        if is_prepared(self.name):
+            Module.cleanup(self)
+
+    def load_module(self):
+        for mdc in self.mdclist:
+            mdc.load_module()
+            break
+        Module.load_module(self)
+
+    def cleanup_module(self):
+        Module.cleanup_module(self)
+        for mdc in self.mdclist:
+            mdc.cleanup_module()
+            break
+
+    def correct_level(self, level, op=None):
+        return level
+
 class MDSDEV(Module):
     def __init__(self,db):
         Module.__init__(self, 'MDSDEV', db)
@@ -1370,11 +1495,24 @@ class MDSDEV(Module):
         self.nspath = self.db.get_val('nspath', '')
         self.mkfsoptions = self.db.get_val('mkfsoptions', '')
         self.mountfsoptions = self.db.get_val('mountfsoptions', '')
-        # overwrite the orignal MDSDEV name and uuid with the MDS name and uuid
+        self.cachetype = self.db.get_val('cachetype', '')
+       # overwrite the orignal MDSDEV name and uuid with the MDS name and uuid
         target_uuid = self.db.get_first_ref('target')
         mds = self.db.lookup(target_uuid)
         self.name = mds.getName()
         self.filesystem_uuids = mds.get_refs('filesystem')
+       self.lmv_uuid = ''
+       self.lmv = ''
+        self.master_mds = ""
+       if not self.filesystem_uuids:
+           self.lmv_uuid = self.db.get_first_ref('lmv')
+           if not self.lmv_uuid:
+               panic("ALERT: can't find lvm uuid")
+           if self.lmv_uuid:
+               self.lmv = self.db.lookup(self.lmv_uuid)
+               if self.lmv:
+                   self.filesystem_uuids = self.lmv.get_refs('filesystem')
+                    self.master_mds = self.lmv_uuid
         # FIXME: if fstype not set, then determine based on kernel version
         self.format = self.db.get_val('autoformat', "no")
         if mds.get_val('failover', 0):
@@ -1396,11 +1534,28 @@ class MDSDEV(Module):
             # find the LOV for this MDS
             lovconfig_uuid = mds.get_first_ref('lovconfig')
             if not lovconfig_uuid:
-                panic("No LOV config found for MDS ", mds.name)
-            lovconfig = mds.lookup(lovconfig_uuid)
-            lov_uuid = lovconfig.get_first_ref('lov')
-            if not lov_uuid:
-                panic("No LOV found for lovconfig ", lovconfig.name)
+                if not self.lmv_uuid:
+                    panic("No LOV found for lovconfig ", lovconfig.name)
+
+               if not self.lmv:
+                   panic("No LMV initialized and not lovconfig_uuid found")
+                   
+                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:
+                    panic("No LOV found for lovconfig ", lovconfig.name)
+           else:
+                lovconfig = mds.lookup(lovconfig_uuid)
+                lov_uuid = lovconfig.get_first_ref('lov')
+                if not lov_uuid:
+                    panic("No LOV found for lovconfig ", lovconfig.name)
+
+               if self.lmv:
+                   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', config_only = 1)
 
             # default stripe count controls default inode_size
@@ -1418,11 +1573,19 @@ class MDSDEV(Module):
 
         self.target_dev_uuid = self.uuid
         self.uuid = target_uuid
+       # setup LMV
+       if self.master_mds:
+            client_uuid = generate_client_uuid(self.name)
+           client_uuid = self.name + "_lmv_" + "UUID"
+           self.master = LMV(self.db.lookup(self.lmv_uuid), client_uuid, self.name, self.name)
+           self.master_mds = self.master.name
 
-        # loading modules
+        # modules
         self.add_lustre_module('mdc', 'mdc')
         self.add_lustre_module('osc', 'osc')
         self.add_lustre_module('lov', 'lov')
+        self.add_lustre_module('lmv', 'lmv')
+        self.add_lustre_module('ost', 'ost')
         self.add_lustre_module('mds', 'mds')
 
         if self.fstype == 'smfs':
@@ -1439,12 +1602,18 @@ class MDSDEV(Module):
         if self.fstype == 'smfs':
             self.add_lustre_module('lvfs', 'fsfilt_%s' % (self.backfstype))
 
+       for options in string.split(self.mountfsoptions, ','):
+           if options == 'snap':
+               if not self.fstype == 'smfs':
+                   panic("mountoptions with snap, but fstype is not smfs\n")
+               self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype))
+               self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype))
     def load_module(self):
         if self.active:
             Module.load_module(self)
-            
+
     def prepare(self):
-        if is_prepared(self.name):
+        if not config.record and is_prepared(self.name):
             return
         if not self.active:
             debug(self.uuid, "not active")
@@ -1454,37 +1623,56 @@ class MDSDEV(Module):
             self.write_conf()
         self.info(self.devpath, self.fstype, self.size, self.format)
         run_acceptors()
+       # prepare LMV
+       if self.master_mds:
+             self.master.prepare()
         # never reformat here
         blkdev = block_dev(self.devpath, self.size, self.fstype, 0,
                            self.format, self.journal_size, self.inode_size,
                            self.mkfsoptions, self.backfstype, self.backdevpath)
+        
         if not is_prepared('MDT'):
             lctl.newdev("mdt", 'MDT', 'MDT_UUID', setup ="")
         try: 
-            if config.mountfsoptions != None:
-                mountfsoptions = config.mountfsoptions
-                if self.mountfsoptions != None:
-                    mountfsoptions = mountfsoptions + ' ' + self.mountfsoptions
+            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:
-                mountfsoptions = self.mountfsoptions
+                if self.mountfsoptions:
+                    if mountfsoptions:
+                        mountfsoptions = mountfsoptions + ',' + self.mountfsoptions
+                    else:
+                        mountfsoptions = self.mountfsoptions
             
-            # we count, that mountfsoptions is always not None for smfs    
             if self.fstype == 'smfs':
                 realdev = self.fstype
-                mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                        self.backfstype, 
-                                                        blkdev)
+                
+                if mountfsoptions:
+                    mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
+                                                            self.backfstype, 
+                                                            blkdev)
+                else:
+                    mountfsoptions = "type=%s,dev=%s" % (self.backfstype, 
+                                                         blkdev)
             else:
                 realdev = blkdev
                 
-            if mountfsoptions != None:
-                lctl.newdev("mds", self.name, self.uuid,
-                            setup ="%s %s %s %s" %(realdev, self.fstype, 
-                                                   self.name, mountfsoptions))
-            else:
-                lctl.newdev("mds", self.name, self.uuid,
-                            setup ="%s %s %s" %(realdev, self.fstype, 
-                                                self.name))
+            print 'MDS mount options: ' + mountfsoptions
+            
+           if not self.master_mds:
+                self.master_mds = 'dumb'           
+            if not self.cachetype:
+                self.cachetype = 'dumb'
+           lctl.newdev("mds", self.name, self.uuid,
+                        setup ="%s %s %s %s %s %s" %(realdev, self.fstype, 
+                                               self.name, mountfsoptions,
+                                               self.master_mds, self.cachetype))
         except CommandError, e:
             if e.rc == 2:
                 panic("MDS is missing the config log. Need to run " +
@@ -1493,52 +1681,77 @@ class MDSDEV(Module):
                 raise e
 
     def write_conf(self):
-        if is_prepared(self.name):
-            return
-        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)
-                          
-        if config.mountfsoptions != None:
-            mountfsoptions = config.mountfsoptions
-            if self.mountfsoptions != None:
-                mountfsoptions = mountfsoptions + ' ' + self.mountfsoptions
-        else:
-            mountfsoptions = self.mountfsoptions
+        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.
 
-       # 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
        
-        # we count, that mountfsoptions is always not None for smfs    
-        if self.fstype == 'smfs':
-            realdev = self.fstype
-            mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                    self.backfstype, 
-                                                    blkdev)
-        else:
-            realdev = blkdev
-            
-       # 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 @dumb, which will be checked
-       # in MDS code and skipped.
-        if mountfsoptions != None:
+                print 'MDS mount options: ' + mountfsoptions
+
+            # 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.
             lctl.newdev("mds", self.name, self.uuid,
-                        setup ="%s %s %s %s" %(realdev, self.fstype, 'dumb', 
-                                               mountfsoptions))
-        else:
-            lctl.newdev("mds", self.name, self.uuid,
-                        setup ="%s %s %s" %(realdev, self.fstype, 'dumb'))
+                        setup ="%s %s %s %s" %(realdev, self.fstype, 
+                                               'dumb', mountfsoptions))
+            do_cleanup = 1
 
         # record logs for the MDS lov
         for uuid in self.filesystem_uuids:
             log("recording clients for filesystem:", uuid)
             fs = self.db.lookup(uuid)
-            obd_uuid = fs.get_first_ref('obd')
+
+            # this is ugly, should be organized nice later.
+            target_uuid = self.db.get_first_ref('target')
+            mds = self.db.lookup(target_uuid)
+            
+            lovconfig_uuid = mds.get_first_ref('lovconfig')
+            if lovconfig_uuid:
+                lovconfig = mds.lookup(lovconfig_uuid)
+                obd_uuid = lovconfig.get_first_ref('lov')
+            else:
+                obd_uuid = fs.get_first_ref('obd')
+                
             client_uuid = generate_client_uuid(self.name)
             client = VOSC(self.db.lookup(obd_uuid), client_uuid, self.name,
                           self.name)
@@ -1548,6 +1761,7 @@ class MDSDEV(Module):
             client.prepare()
             lctl.mount_option(self.name, client.get_name(), "")
             lctl.end_record()
+            process_updates(self.db, self.name, self.name, client)
 
             config.cleanup = 1
             lctl.clear_log(self.name, self.name + '-clean')
@@ -1555,10 +1769,15 @@ class MDSDEV(Module):
             client.cleanup()
             lctl.del_mount_option(self.name)
             lctl.end_record()
+            process_updates(self.db, self.name, self.name + '-clean', client)
             config.cleanup = 0
             config.record = 0
 
         # record logs for each client
+        if config.noexec:
+            noexec_opt = '-n'
+        else:
+            noexec_opt = ''
         if config.ldapurl:
             config_options = "--ldapurl " + config.ldapurl + " --config " + config.config
         else:
@@ -1575,9 +1794,7 @@ class MDSDEV(Module):
                         debug("recording", client_name)
                         old_noexec = config.noexec
                         config.noexec = 0
-                        noexec_opt = ('', '-n')
-                        ret, out = run (sys.argv[0],
-                                        noexec_opt[old_noexec == 1],
+                        ret, out = run (sys.argv[0], noexec_opt,
                                         " -v --record --nomod",
                                         "--record_log", client_name,
                                         "--record_device", self.name,
@@ -1585,8 +1802,7 @@ class MDSDEV(Module):
                                         config_options)
                         if config.verbose:
                             for s in out: log("record> ", string.strip(s))
-                        ret, out = run (sys.argv[0],
-                                        noexec_opt[old_noexec == 1],
+                        ret, out = run (sys.argv[0], noexec_opt,
                                         "--cleanup -v --record --nomod",
                                         "--record_log", client_name + "-clean",
                                         "--record_device", self.name,
@@ -1595,19 +1811,20 @@ class MDSDEV(Module):
                         if config.verbose:
                             for s in out: log("record> ", string.strip(s))
                         config.noexec = old_noexec
-        try:
-            lctl.cleanup(self.name, self.uuid, 0, 0)
-        except CommandError, e:
-            log(self.module_name, "cleanup failed: ", self.name)
-            e.dump()
-            cleanup_error(e.rc)
-            Module.cleanup(self)
+        if do_cleanup:
+            try:
+                lctl.cleanup(self.name, self.uuid, 0, 0)
+            except CommandError, e:
+                log(self.module_name, "cleanup failed: ", self.name)
+                e.dump()
+                cleanup_error(e.rc)
+                Module.cleanup(self)
         
-        if self.fstype == 'smfs':
-            clean_loop(self.backdevpath)
-        else:
-            clean_loop(self.devpath)
+            if self.fstype == 'smfs':
+                clean_loop(self.backdevpath)
+            else:
+                clean_loop(self.devpath)
+
     def msd_remaining(self):
         out = lctl.device_list()
         for s in out:
@@ -1634,6 +1851,9 @@ class MDSDEV(Module):
                 e.dump()
                 cleanup_error(e.rc)
                 Module.cleanup(self)
+           # cleanup LMV
+           if self.master_mds:
+                self.master.cleanup()
         if not self.msd_remaining() and is_prepared('MDT'):
             try:
                 lctl.cleanup("MDT", "MDT_UUID", config.force,
@@ -1648,6 +1868,11 @@ class MDSDEV(Module):
         else:
             clean_loop(self.devpath)
 
+    def correct_level(self, level, op=None):
+       #if self.master_mds:
+       #   level = level + 2
+        return level
+
 class OSD(Module):
     def __init__(self, db):
         Module.__init__(self, 'OSD', db)
@@ -1680,7 +1905,7 @@ class OSD(Module):
             self.active = 0
         if self.active and config.group and config.group != ost.get_val('group'):
             self.active = 0
-            
+
         self.target_dev_uuid = self.uuid
         self.uuid = target_uuid
         # modules
@@ -1695,6 +1920,13 @@ class OSD(Module):
         if self.fstype == 'smfs':
             self.add_lustre_module('lvfs' , 'fsfilt_%s' % (self.backfstype))
 
+       for options in self.mountfsoptions:
+           if options == 'snap':
+               if not self.fstype == 'smfs':
+                   panic("mountoptions with snap, but fstype is not smfs\n")
+               self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.fstype))
+               self.add_lustre_module('lvfs', 'fsfilt_snap_%s' % (self.backfstype))
+
         self.add_lustre_module(self.osdtype, self.osdtype)
 
     def load_module(self):
@@ -1720,31 +1952,42 @@ class OSD(Module):
                                config.reformat, self.format, self.journal_size,
                                self.inode_size, self.mkfsoptions, self.backfstype,
                                self.backdevpath)
-        if config.mountfsoptions != None:
-            mountfsoptions = config.mountfsoptions
-            if self.mountfsoptions != None:
-                mountfsoptions = mountfsoptions + ' ' + self.mountfsoptions
-        else:
-            mountfsoptions = self.mountfsoptions
 
-        # we count, that mountfsoptions is always not None for smfs    
+        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
-            mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
-                                                    self.backfstype,
-                                                    blkdev)
+                
+            if mountfsoptions:
+                mountfsoptions = "%s,type=%s,dev=%s" % (mountfsoptions, 
+                                                        self.backfstype, 
+                                                        blkdev)
+            else:
+                mountfsoptions = "type=%s,dev=%s" % (self.backfstype, 
+                                                     blkdev)
         else:
             realdev = blkdev
-            
-        if mountfsoptions != None:
-            lctl.newdev(self.osdtype, self.name, self.uuid,
-                        setup ="%s %s %s %s" %(realdev, self.fstype,
-                                               self.failover_ost, 
-                                               mountfsoptions))
-        else:
-            lctl.newdev(self.osdtype, self.name, self.uuid,
-                        setup ="%s %s %s" %(realdev, self.fstype,
-                                            self.failover_ost))
+                
+        print 'OSD mount options: ' + mountfsoptions
+        
+        lctl.newdev(self.osdtype, self.name, self.uuid,
+                    setup ="%s %s %s %s" %(realdev, self.fstype,
+                                           self.failover_ost, 
+                                           mountfsoptions))
         if not is_prepared('OSS'):
             lctl.newdev("ost", 'OSS', 'OSS_UUID', setup ="")
 
@@ -1787,12 +2030,15 @@ class OSD(Module):
             else:
                 clean_loop(self.devpath)
 
+    def correct_level(self, level, op=None):
+        return level
+
 def mgmt_uuid_for_fs(mtpt_name):
     if not mtpt_name:
         return ''
-    mtpt_db = toplevel.lookup_name(mtpt_name)
+    mtpt_db = toplustreDB.lookup_name(mtpt_name)
     fs_uuid = mtpt_db.get_first_ref('filesystem')
-    fs = toplevel.lookup(fs_uuid)
+    fs = toplustreDB.lookup(fs_uuid)
     if not fs:
         return ''
     return fs.get_first_ref('mgmt')
@@ -1804,11 +2050,12 @@ class Client(Module):
         self.target_name = tgtdb.getName()
         self.target_uuid = tgtdb.getUUID()
         self.db = tgtdb
+        self.active = 1
 
         self.tgt_dev_uuid = get_active_target(tgtdb)
         if not self.tgt_dev_uuid:
-            panic("No target device found for target:", self.target_name)
-            
+            panic("No target device found for target(1):", self.target_name)
+
         self.kmod = kmod(config.lustre, config.portals)
         self._server = None
         self._connected = 0
@@ -1837,13 +2084,14 @@ class Client(Module):
         self._server_nets = get_ost_net(self.db, srv_uuid)
         if len(self._server_nets) == 0:
             panic ("Unable to find a server for:", srv_uuid)
-
+    def get_name(self):
+        return self.name
     def get_servers(self):
         return self._server_nets
 
     def prepare(self, ignore_connect_failure = 0):
         self.info(self.target_uuid)
-        if is_prepared(self.name):
+        if not config.record and is_prepared(self.name):
             self.cleanup()
         try:
             srv = choose_local_server(self.get_servers())
@@ -1859,7 +2107,7 @@ class Client(Module):
             if not ignore_connect_failure:
                 raise e
         if srv:
-            if self.target_uuid in config.inactive and self.permits_inactive():
+            if self.permits_inactive() and (self.target_uuid in config.inactive or self.active == 0):
                 debug("%s inactive" % self.target_uuid)
                 inactive_p = "inactive"
             else:
@@ -1884,6 +2132,16 @@ class Client(Module):
                 e.dump()
                 cleanup_error(e.rc)
 
+    def correct_level(self, level, op=None):
+        return level
+
+    def deactivate(self):
+        try:
+            lctl.deactivate(self.name)
+        except CommandError, e:
+            log(self.module_name, "deactivate failed: ", self.name)
+            e.dump()
+            cleanup_error(e.rc)
 
 class MDC(Client):
     def __init__(self, db, uuid, fs_name):
@@ -1907,37 +2165,191 @@ class ManagementClient(Client):
         Client.__init__(self, db, uuid, 'mgmt_cli', '',
                         self_name = mgmtcli_name_for_uuid(db.getUUID()),
                         module_dir = 'mgmt')
-            
+class VLOV(Module):
+    def __init__(self, db, uuid, fs_name, name_override = None, config_only = None):
+        Module.__init__(self, 'VLOV', db)
+        if name_override != None:
+            self.name = "lov_%s" % name_override
+        self.add_lustre_module('lov', 'lov')
+        self.stripe_sz = 65536 
+        self.stripe_off = 0 
+        self.pattern =  0
+        self.stripe_cnt = 1 
+        self.desc_uuid = self.uuid
+        self.uuid = generate_client_uuid(self.name)
+        self.fs_name = fs_name
+        self.osc = get_osc(db, self.uuid, fs_name)
+        if not self.osc:        
+           panic('osc not found:', self.uuid)
+       if config_only:
+            self.config_only = 1
+            return
+        self.config_only = None
+    def get_uuid(self):
+        return self.uuid
+    def get_name(self):
+        return self.name
+    def prepare(self):
+        if not config.record and is_prepared(self.name):
+            return
+        lctl.lov_setup(self.name, self.uuid, self.desc_uuid, self.stripe_cnt,
+                       self.stripe_sz, self.stripe_off, self.pattern)
+        target_uuid = self.osc.target_uuid
+        try:
+           self.osc.active = 1 
+            self.osc.prepare(ignore_connect_failure=0)
+        except CommandError, e:
+            print "Error preparing OSC %s\n" % osc.uuid
+            raise e
+        lctl.lov_add_obd(self.name, self.uuid, target_uuid, 0, 1)
+
+    def cleanup(self):
+        target_uuid = self.osc.target_uuid
+        self.osc.cleanup()
+        if is_prepared(self.name):
+            Module.cleanup(self)
+        if self.config_only:
+            panic("Can't clean up config_only LOV ", self.name)
+
+    def load_module(self):
+        if self.config_only:
+            panic("Can't load modules for config_only LOV ", self.name)
+        self.osc.load_module()
+        Module.load_module(self)
+
+    def cleanup_module(self):
+        if self.config_only:
+            panic("Can't cleanup modules for config_only LOV ", self.name)
+        Module.cleanup_module(self)
+        self.osc.cleanup_module()
+
+    def correct_level(self, level, op=None):
+        return level
+
+class CMOBD(Module):
+    def __init__(self,db):
+       Module.__init__(self, 'CMOBD', db)
+       self.name = self.db.getName(); 
+       self.uuid = generate_client_uuid(self.name)
+       self.master_uuid = self.db.get_first_ref('masterobd')
+       self.cache_uuid = self.db.get_first_ref('cacheobd')
+       self.add_lustre_module('cmobd', 'cmobd')
+       master_obd = self.db.lookup(self.master_uuid)
+       if not master_obd:
+           panic('master obd not found:', self.master_uuid)
+       cache_obd = self.db.lookup(self.cache_uuid)
+       if not cache_obd:
+           panic('cache obd not found:', self.cache_uuid)
+       
+       if master_obd.get_class() == 'ost':
+           self.client_uuid = generate_client_uuid(self.name) 
+           self.master= VLOV(master_obd, self.client_uuid, self.name, 
+                           "%s_master" % (self.name))
+           self.master_uuid = self.master.get_uuid()
+       else:
+           self.master = get_mdc(db, self.name, self.master_uuid) 
+    # need to check /proc/mounts and /etc/mtab before
+    # formatting anything.
+    # FIXME: check if device is already formatted.
+    def prepare(self):
+        self.master.prepare()
+        if not config.record and is_prepared(self.name):
+            return
+        self.info(self.master_uuid, self.cache_uuid)
+        lctl.newdev("cmobd", self.name, self.uuid,
+                    setup ="%s %s" %(self.master_uuid,
+                                     self.cache_uuid))
+
+    def cleanup(self):
+        if is_prepared(self.name):
+            Module.cleanup(self)
+        self.master.cleanup()
+
+    def load_module(self):
+        self.master.load_module()
+        Module.load_module(self)
+
+    def cleanup_module(self):
+        Module.cleanup_module(self)
+        self.master.cleanup_module()
+                                                                                                                                                                                                     
+    def correct_level(self, level, op=None):
+        return level
+
 class COBD(Module):
-    def __init__(self, db):
+    def __init__(self, db, uuid, name, type, name_override = None):
         Module.__init__(self, 'COBD', db)
+        self.name = self.db.getName(); 
+        self.uuid = generate_client_uuid(self.name)
         self.real_uuid = self.db.get_first_ref('realobd')
         self.cache_uuid = self.db.get_first_ref('cacheobd')
-        self.add_lustre_module('cobd' , 'cobd')
-
+        self.add_lustre_module('cobd', 'cobd')
+        real_obd = self.db.lookup(self.real_uuid)
+        if not real_obd:
+            panic('real obd not found:', self.real_uuid)
+        cache_obd = self.db.lookup(self.cache_uuid)
+        if not cache_obd:
+            panic('cache obd not found:', self.cache_uuid)
+        if type == 'obd':
+            self.real = LOV(real_obd, self.real_uuid, name, 
+                            "%s_real" % (self.name));
+            self.cache = LOV(cache_obd, self.cache_uuid, name, 
+                            "%s_cache" % (self.name));
+        else:
+            self.real = get_mdc(db,  name, self.real_uuid) 
+            self.cache = get_mdc(db, name, self.cache_uuid) 
     # need to check /proc/mounts and /etc/mtab before
     # formatting anything.
     # FIXME: check if device is already formatted.
+    def get_uuid(self):
+        return self.uuid
+    def get_name(self):
+        return self.name
+    def get_real_name(self):
+        return self.real.name
+    def get_cache_name(self):
+        return self.cache.name
     def prepare(self):
-        if is_prepared(self.name):
+        self.real.prepare()
+        self.cache.prepare()
+        if not config.record and is_prepared(self.name):
             return
         self.info(self.real_uuid, self.cache_uuid)
         lctl.newdev("cobd", self.name, self.uuid,
-                    setup ="%s %s" %(self.real_uuid, self.cache_uuid))
+                    setup ="%s %s" %(self.real.name,
+                                     self.cache.name))
 
+    def cleanup(self):
+        if is_prepared(self.name):
+            Module.cleanup(self)
+        self.real.cleanup()
+        self.cache.cleanup()
+
+    def load_module(self):
+        self.real.load_module()
+        Module.load_module(self)
+
+    def cleanup_module(self):
+        Module.cleanup_module(self)
+        self.real.cleanup_module()
 
 # virtual interface for  OSC and LOV
 class VOSC(Module):
-    def __init__(self, db, uuid, fs_name, name_override = None):
+    def __init__(self, db, client_uuid, name, name_override = None):
         Module.__init__(self, 'VOSC', db)
         if db.get_class() == 'lov':
-            self.osc = LOV(db, uuid, fs_name, name_override)
+            self.osc = LOV(db, client_uuid, name, name_override)
+            self.type = 'lov'
+        elif db.get_class() == 'cobd':
+            self.osc = COBD(db, client_uuid, name, 'obd')
+            self.type = 'cobd'
         else:
-            self.osc = get_osc(db, uuid, fs_name)
+            self.osc = OSC(db, client_uuid, name)
+            self.type = 'osc'
     def get_uuid(self):
-        return self.osc.uuid
+        return self.osc.get_uuid()
     def get_name(self):
-        return self.osc.name
+        return self.osc.get_name()
     def prepare(self):
         self.osc.prepare()
     def cleanup(self):
@@ -1946,7 +2358,33 @@ class VOSC(Module):
         self.osc.load_module()
     def cleanup_module(self):
         self.osc.cleanup_module()
-
+    def correct_level(self, level, op=None):
+        return self.osc.correct_level(level, op)
+
+# virtual interface for MDC and LMV
+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)
+        elif db.get_class() == 'cobd':
+            self.mdc = COBD(db, client_uuid, name, 'mds')
+        else:
+            self.mdc = MDC(db, client_uuid, name)
+    def get_uuid(self):
+        return self.mdc.uuid
+    def get_name(self):
+        return self.mdc.name
+    def prepare(self):
+        self.mdc.prepare()
+    def cleanup(self):
+        self.mdc.cleanup()
+    def load_module(self):
+        self.mdc.load_module()
+    def cleanup_module(self):
+        self.mdc.cleanup_module()
+    def correct_level(self, level, op=None):
+        return self.mdc.correct_level(level, op)
 
 class ECHO_CLIENT(Module):
     def __init__(self,db):
@@ -1958,7 +2396,7 @@ class ECHO_CLIENT(Module):
         self.osc = VOSC(obd, self.uuid, self.name)
 
     def prepare(self):
-        if is_prepared(self.name):
+        if not config.record and is_prepared(self.name):
             return
         run_acceptors()
         self.osc.prepare() # XXX This is so cheating. -p
@@ -1980,6 +2418,8 @@ class ECHO_CLIENT(Module):
         Module.cleanup_module(self)
         self.osc.cleanup_module()
 
+    def correct_level(self, level, op=None):
+        return level
 
 def generate_client_uuid(name):
         client_uuid = '%05x_%.19s_%05x%05x' % (int(random.random() * 1048576),
@@ -1988,23 +2428,35 @@ def generate_client_uuid(name):
                                                int(random.random() * 1048576))
         return client_uuid[:36]
 
-
 class Mountpoint(Module):
     def __init__(self,db):
         Module.__init__(self, 'MTPT', db)
         self.path = self.db.get_val('path')
+       self.clientoptions = self.db.get_val('clientoptions', '')
         self.fs_uuid = self.db.get_first_ref('filesystem')
         fs = self.db.lookup(self.fs_uuid)
-        self.mds_uuid = fs.get_first_ref('mds')
+        self.mds_uuid = fs.get_first_ref('lmv')
+       if not self.mds_uuid:
+           self.mds_uuid = fs.get_first_ref('mds')
         self.obd_uuid = fs.get_first_ref('obd')
         self.mgmt_uuid = fs.get_first_ref('mgmt')
-        obd = self.db.lookup(self.obd_uuid)
         client_uuid = generate_client_uuid(self.name)
-        self.vosc = VOSC(obd, client_uuid, self.name)
-        self.mdc = get_mdc(db, client_uuid, self.name, self.mds_uuid)
 
+        ost = self.db.lookup(self.obd_uuid)
+        if not ost:
+            panic("no ost: ", self.obd_uuid)
+            
+        mds = self.db.lookup(self.mds_uuid)
+       if not mds:
+           panic("no mds: ", self.mds_uuid)
+       
         self.add_lustre_module('mdc', 'mdc')
+        self.add_lustre_module('lmv', 'lmv')
         self.add_lustre_module('llite', 'llite')
+        
+        self.vosc = VOSC(ost, client_uuid, self.name)
+       self.vmdc = VMDC(mds, client_uuid, self.name)
+        
         if self.mgmt_uuid:
             self.mgmtcli = ManagementClient(db.lookup(self.mgmt_uuid),
                                             client_uuid)
@@ -2012,26 +2464,41 @@ class Mountpoint(Module):
             self.mgmtcli = None
 
     def prepare(self):
-        if fs_is_mounted(self.path):
+        if not config.record and fs_is_mounted(self.path):
             log(self.path, "already mounted.")
             return
         run_acceptors()
         if self.mgmtcli:
             self.mgmtcli.prepare()
         self.vosc.prepare()
-        self.mdc.prepare()
-        mdc_name = self.mdc.name
+        self.vmdc.prepare()
+        vmdc_name = self.vmdc.get_name()
 
         self.info(self.path, self.mds_uuid, self.obd_uuid)
         if config.record or config.lctl_dump:
-            lctl.mount_option(local_node_name, self.vosc.get_name(), mdc_name)
+            lctl.mount_option(local_node_name, self.vosc.get_name(), vmdc_name)
             return
-        cmd = "mount -t lustre_lite -o osc=%s,mdc=%s %s %s" % \
-              (self.vosc.get_name(), mdc_name, config.config, self.path)
+
+        if config.clientoptions:
+            if self.clientoptions:
+                self.clientoptions = self.clientoptions + ',' + \
+                                    config.clientoptions
+            else:
+                self.clientoptions = config.clientoptions
+        if self.clientoptions:
+            self.clientoptions = ',' + self.clientoptions
+            # Linux kernel will deal with async and not pass it to ll_fill_super,
+            # so replace it with Lustre async
+            self.clientoptions = string.replace(self.clientoptions, "async", 
+                                               "lasync")
+
+        cmd = "mount -t lustre_lite -o osc=%s,mdc=%s%s %s %s" % \
+              (self.vosc.get_name(), vmdc_name, self.clientoptions, 
+              config.config, self.path)
         run("mkdir", self.path)
         ret, val = run(cmd)
         if ret:
-            self.mdc.cleanup()            
+            self.vmdc.cleanup()            
             self.vosc.cleanup()
             panic("mount failed:", self.path, ":", string.join(val))
 
@@ -2052,7 +2519,7 @@ class Mountpoint(Module):
             if fs_is_mounted(self.path):
                 panic("fs is still mounted:", self.path)
 
-        self.mdc.cleanup()
+        self.vmdc.cleanup()
         self.vosc.cleanup()
         if self.mgmtcli:
             self.mgmtcli.cleanup()
@@ -2069,6 +2536,8 @@ class Mountpoint(Module):
         if self.mgmtcli:
             self.mgmtcli.cleanup_module()
 
+    def correct_level(self, level, op=None):
+        return level
 
 # ============================================================
 # misc query functions
@@ -2082,14 +2551,14 @@ def get_ost_net(self, osd_uuid):
     node = self.lookup(node_uuid)
     if not node:
         panic("unable to find node for osd_uuid:", osd_uuid,
-              " node_ref:", node_uuid)
+              " node_ref:", node_uuid_)
     for net_uuid in node.get_networks():
         db = node.lookup(net_uuid)
         srv_list.append(Network(db))
     return srv_list
 
 
-# the order of iniitailization is based on level. 
+# the order of iniitailization is based on level.
 def getServiceLevel(self):
     type = self.get_class()
     ret=0;
@@ -2105,13 +2574,17 @@ def getServiceLevel(self):
         ret = 30
     elif type in ('mdsdev',):
         ret = 40
+    elif type in ('lmv',):
+        ret = 45
+    elif type in ('cmobd',):
+        ret = 50 
     elif type in ('mountpoint', 'echoclient'):
         ret = 70
     else:
         panic("Unknown type: ", type)
 
     if ret < config.minlevel or ret > config.maxlevel:
-        ret = 0 
+        ret = 0
     return ret
 
 #
@@ -2119,7 +2592,7 @@ def getServiceLevel(self):
 # [(level, db_object),]
 def getServices(self):
     list = []
-    for ref_class, ref_uuid in self.get_all_refs(): 
+    for ref_class, ref_uuid in self.get_all_refs():
             servdb = self.lookup(ref_uuid)
             if  servdb:
                 level = getServiceLevel(servdb)
@@ -2133,7 +2606,7 @@ def getServices(self):
 
 
 ############################################################
-# MDC UUID hack - 
+# MDC UUID hack -
 # FIXME: clean this mess up!
 #
 # OSC is no longer in the xml, so we have to fake it.
@@ -2142,16 +2615,15 @@ def get_osc(ost_db, uuid, fs_name):
     osc = OSC(ost_db, uuid, fs_name)
     return osc
 
-def get_mdc(db, uuid, fs_name, mds_uuid):
+def get_mdc(db, fs_name, mds_uuid):
     mds_db = db.lookup(mds_uuid);
     if not mds_db:
-        panic("no mds:", mds_uuid)
-    mdc = MDC(mds_db, uuid, fs_name)
+        error("no mds:", mds_uuid)
+    mdc = MDC(mds_db, mds_uuid, fs_name)
     return mdc
 
 ############################################################
 # routing ("rooting")
-
 # list of (nettype, cluster_id, nid)
 local_clusters = []
 
@@ -2243,7 +2715,7 @@ def find_route(srv_list):
             if  (r[3] <= to and to <= r[4]) and cluster_id == r[2]:
                 result.append((srv, r))
     return result
-           
+
 def get_active_target(db):
     target_uuid = db.getUUID()
     target_name = db.getName()
@@ -2259,7 +2731,7 @@ def get_server_by_nid_uuid(db,  nid_uuid):
         net = Network(n)
         if net.nid_uuid == nid_uuid:
             return net
-        
+
 
 ############################################################
 # lconf level logic
@@ -2279,7 +2751,9 @@ def newService(db):
     elif type == 'osd':
         n = OSD(db)
     elif type == 'cobd':
-        n = COBD(db)
+        n = COBD(db, "YOU_SHOULD_NEVER_SEE_THIS_UUID")
+    elif type == 'cmobd':
+        n = CMOBD(db)
     elif type == 'mdsdev':
         n = MDSDEV(db)
     elif type == 'mountpoint':
@@ -2288,13 +2762,15 @@ def newService(db):
         n = ECHO_CLIENT(db)
     elif type == 'mgmt':
         n = Management(db)
+    elif type == 'lmv':
+        n = LMV(db)
     else:
         panic ("unknown service type:", type)
     return n
 
 #
 # Prepare the system to run lustre using a particular profile
-# in a the configuration. 
+# in a the configuration.
 #  * load & the modules
 #  * setup networking for the current node
 #  * make sure partitions are in place and prepared
@@ -2307,10 +2783,144 @@ def for_each_profile(db, prof_list, operation):
             panic("profile:", profile, "not found.")
         services = getServices(prof_db)
         operation(services)
-        
+
+def magic_get_osc(db, rec, lov):
+    if lov:
+        lov_uuid = lov.get_uuid()
+        lov_name = lov.osc.fs_name
+    else:
+        lov_uuid = rec.getAttribute('lov_uuidref')
+        # FIXME: better way to find the mountpoint?
+        filesystems = db.root_node.getElementsByTagName('filesystem')
+        fsuuid = None
+        for fs in filesystems:
+            ref = fs.getElementsByTagName('obd_ref')
+            if ref[0].getAttribute('uuidref') == lov_uuid:
+                fsuuid = fs.getAttribute('uuid')
+                break
+
+        if not fsuuid:
+            panic("malformed xml: lov uuid '" + lov_uuid + "' referenced in 'add' record is not used by any filesystems.")
+
+        mtpts = db.root_node.getElementsByTagName('mountpoint')
+        lov_name = None
+        for fs in mtpts:
+            ref = fs.getElementsByTagName('filesystem_ref')
+            if ref[0].getAttribute('uuidref') == fsuuid:
+                lov_name = fs.getAttribute('name')
+                break
+
+        if not lov_name:
+            panic("malformed xml: 'add' record references lov uuid '" + lov_uuid + "', which references filesystem uuid '" + fsuuid + "', which does not reference a mountpoint.")
+
+    print "lov_uuid: " + lov_uuid + "; lov_name: " + lov_name
+
+    ost_uuid = rec.getAttribute('ost_uuidref')
+    obd = db.lookup(ost_uuid)
+
+    if not obd:
+        panic("malformed xml: 'add' record references ost uuid '" + ost_uuid + "' which cannot be found.")
+
+    osc = get_osc(obd, lov_uuid, lov_name)
+    if not osc:
+        panic('osc not found:', obd_uuid)
+    return osc
+
+# write logs for update records.  sadly, logs of all types -- and updates in
+# particular -- are something of an afterthought.  lconf needs rewritten with
+# these as core concepts.  so this is a pretty big hack.
+def process_update_record(db, update, lov):
+    for rec in update.childNodes:
+        if rec.nodeType != rec.ELEMENT_NODE:
+            continue
+
+        log("found "+rec.nodeName+" record in update version " +
+            str(update.getAttribute('version')))
+
+        lov_uuid = rec.getAttribute('lov_uuidref')
+        ost_uuid = rec.getAttribute('ost_uuidref')
+        index = rec.getAttribute('index')
+        gen = rec.getAttribute('generation')
+
+        if not lov_uuid or not ost_uuid or not index or not gen:
+            panic("malformed xml: 'update' record requires lov_uuid, ost_uuid, index, and generation.")
+
+        if not lov:
+            tmplov = db.lookup(lov_uuid)
+            if not tmplov:
+                panic("malformed xml: 'delete' record contains lov UUID '" + lov_uuid + "', which cannot be located.")
+            lov_name = tmplov.getName()
+        else:
+            lov_name = lov.osc.name
+
+        # ------------------------------------------------------------- add
+        if rec.nodeName == 'add':
+            if config.cleanup:
+                lctl.lov_del_obd(lov_name, lov_uuid, ost_uuid, index, gen)
+                continue
+
+            osc = magic_get_osc(db, rec, lov)
+
+            try:
+                # Only ignore connect failures with --force, which
+                # isn't implemented here yet.
+                osc.prepare(ignore_connect_failure=0)
+            except CommandError, e:
+                print "Error preparing OSC %s\n" % osc.uuid
+                raise e
+
+            lctl.lov_add_obd(lov_name, lov_uuid, ost_uuid, index, gen)
+
+        # ------------------------------------------------------ deactivate
+        elif rec.nodeName == 'deactivate':
+            if config.cleanup:
+                continue
+
+            osc = magic_get_osc(db, rec, lov)
+
+            try:
+                osc.deactivate()
+            except CommandError, e:
+                print "Error deactivating OSC %s\n" % osc.uuid
+                raise e
+
+        # ---------------------------------------------------------- delete
+        elif rec.nodeName == 'delete':
+            if config.cleanup:
+                continue
+
+            osc = magic_get_osc(db, rec, lov)
+
+            try:
+                config.cleanup = 1
+                osc.cleanup()
+                config.cleanup = 0
+            except CommandError, e:
+                print "Error cleaning up OSC %s\n" % osc.uuid
+                raise e
+
+            lctl.lov_del_obd(lov_name, lov_uuid, ost_uuid, index, gen)
+
+def process_updates(db, log_device, log_name, lov = None):
+    updates = db.root_node.getElementsByTagName('update')
+    for u in updates:
+        if not u.childNodes:
+            log("ignoring empty update record (version " +
+                str(u.getAttribute('version')) + ")")
+            continue
+
+        version = u.getAttribute('version')
+        real_name = "%s-%s" % (log_name, version)
+        lctl.clear_log(log_device, real_name)
+        lctl.record(log_device, real_name)
+
+        process_update_record(db, u, lov)
+
+        lctl.end_record()
+
 def doWriteconf(services):
-    if config.nosetup:
-        return
+    #if config.nosetup:
+    #    return
     for s in services:
         if s[1].get_class() == 'mdsdev':
             n = newService(s[1])
@@ -2319,10 +2929,19 @@ def doWriteconf(services):
 def doSetup(services):
     if config.nosetup:
         return
+    slist = []
     for s in services:
         n = newService(s[1])
-        n.prepare()
-    
+       n.level = s[0]
+       slist.append((n.level, n))
+    nlist = []
+    for n in slist:
+       nl = n[1].correct_level(n[0])
+       nlist.append((nl, n[1]))
+    nlist.sort()
+    for n in nlist:
+        n[1].prepare()
+
 def doModules(services):
     if config.nomod:
         return
@@ -2333,11 +2952,20 @@ def doModules(services):
 def doCleanup(services):
     if config.nosetup:
         return
-    services.reverse()
+    slist = []
     for s in services:
         n = newService(s[1])
-        if n.safe_to_clean():
-            n.cleanup()
+       n.level = s[0]
+       slist.append((n.level, n))
+    nlist = []
+    for n in slist:
+       nl = n[1].correct_level(n[0])
+       nlist.append((nl, n[1]))
+    nlist.sort()
+    nlist.reverse()
+    for n in nlist:
+        if n[1].safe_to_clean():
+            n[1].cleanup()
 
 def doUnloadModules(services):
     if config.nomod:
@@ -2349,7 +2977,7 @@ def doUnloadModules(services):
             n.cleanup_module()
 
 #
-# Load profile for 
+# Load profile for
 def doHost(lustreDB, hosts):
     global is_router, local_node_name
     node_db = None
@@ -2367,7 +2995,7 @@ def doHost(lustreDB, hosts):
     timeout = node_db.get_val_int('timeout', 0)
     ptldebug = node_db.get_val('ptldebug', '')
     subsystem = node_db.get_val('subsystem', '')
-    
+
     find_local_clusters(node_db)
     if not is_router:
         find_local_routes(lustreDB)
@@ -2377,6 +3005,7 @@ def doHost(lustreDB, hosts):
     prof_list = node_db.get_refs('profile')
 
     if config.write_conf:
+        lustreDB.close()
         for_each_profile(node_db, prof_list, doModules)
         sys_make_devices()
         for_each_profile(node_db, prof_list, doWriteconf)
@@ -2405,6 +3034,7 @@ def doHost(lustreDB, hosts):
 
         for_each_profile(node_db, prof_list, doCleanup)
         for_each_profile(node_db, prof_list, doUnloadModules)
+        lustreDB.close()
 
     else:
         # ugly hack, only need to run lctl commands for --dump
@@ -2435,22 +3065,24 @@ def doHost(lustreDB, hosts):
         sys_set_portals_upcall(portals_upcall)
 
         for_each_profile(node_db, prof_list, doSetup)
+        lustreDB.close()
 
-def doRecovery(db, lctl, tgt_uuid, client_uuid, nid_uuid):
-    tgt = db.lookup(tgt_uuid)
+def doRecovery(lustreDB, lctl, tgt_uuid, client_uuid, nid_uuid):
+    tgt = lustreDB.lookup(tgt_uuid)
     if not tgt:
         raise Lustre.LconfError("doRecovery: "+ tgt_uuid +" not found.")
     new_uuid = get_active_target(tgt)
     if not new_uuid:
         raise Lustre.LconfError("doRecovery: no active target found for: " +
                                 tgt_uuid)
-    net = choose_local_server(get_ost_net(db, new_uuid))
+    net = choose_local_server(get_ost_net(lustreDB, new_uuid))
     if not net:
         raise Lustre.LconfError("Unable to find a connection to:" + new_uuid)
 
     log("Reconnecting", tgt_uuid, " to ",  net.nid_uuid);
     try:
-        oldnet = get_server_by_nid_uuid(db, nid_uuid)
+        oldnet = get_server_by_nid_uuid(lustreDB, nid_uuid)
+        lustreDB.close()
         if oldnet:
             lctl.disconnect(oldnet)
     except CommandError, e:
@@ -2470,7 +3102,7 @@ def setupModulePath(cmd, portals_dir = PORTALS_DIR):
     base = os.path.dirname(cmd)
     if development_mode():
         if not config.lustre:
-            debug('using objdir module paths')            
+            debug('using objdir module paths')
             config.lustre = (os.path.join(base, ".."))
         # normalize the portals dir, using command line arg if set
         if config.portals:
@@ -2480,7 +3112,7 @@ def setupModulePath(cmd, portals_dir = PORTALS_DIR):
         debug('config.portals', config.portals)
     elif config.lustre and config.portals:
         # production mode
-        # if --lustre and --portals, normalize portals 
+        # if --lustre and --portals, normalize portals
         # can ignore POTRALS_DIR here, since it is probly useless here
         config.portals = os.path.join(config.lustre, config.portals)
         debug('config.portals B', config.portals)
@@ -2535,7 +3167,7 @@ def sys_optimize_elan ():
                  "/proc/qsnet/elan4/config/elan4_mainint_punt_loops"]
     for p in procfiles:
         if os.access(p, os.R_OK):
-            run ("echo 0 > " + p)
+            run ("echo 1 > " + p)
 
 def sys_set_ptldebug(ptldebug):
     if config.ptldebug:
@@ -2571,8 +3203,8 @@ def sys_set_netmem_max(path, max):
         fp = open(path, 'w')
         fp.write('%d\n' %(max))
         fp.close()
-    
-    
+
+
 def sys_make_devices():
     if not os.access('/dev/portals', os.R_OK):
         run('mknod /dev/portals c 10 240')
@@ -2586,7 +3218,7 @@ def add_to_path(new_dir):
     if new_dir in syspath:
         return
     os.environ['PATH'] = os.environ['PATH'] + ':' + new_dir
-    
+
 def default_debug_path():
     path = '/tmp/lustre-log'
     if os.path.isdir('/r'):
@@ -2655,6 +3287,7 @@ lconf_options = [
     ('reformat', "Reformat all devices (without question)"),
     ('mkfsoptions', "Additional options for the mk*fs command line", PARAM),
     ('mountfsoptions', "Additional options for mount fs command line", PARAM),
+    ('clientoptions', "Additional options for Lustre", PARAM),
     ('dump',  "Dump the kernel debug log to file before portals is unloaded",
                PARAM),
     ('write_conf', "Save all the client config information on mds."),
@@ -2664,7 +3297,7 @@ lconf_options = [
               PARAM),
     ('minlevel', "Minimum level of services to configure/cleanup",
                  INTPARAM, 0),
-    ('maxlevel', """Maximum level of services to configure/cleanup 
+    ('maxlevel', """Maximum level of services to configure/cleanup
                     Levels are aproximatly like:
                             10 - netwrk
                             20 - device, ldlm
@@ -2695,14 +3328,14 @@ lconf_options = [
     ('inactive', """The name of an inactive service, to be ignored during
                     mounting (currently OST-only). Can be repeated.""",
                 PARAMLIST),
-    ]      
+    ]
 
 def main():
-    global lctl, config, toplevel, CONFIG_FILE
+    global lctl, config, toplustreDB, CONFIG_FILE
 
     # in the upcall this is set to SIG_IGN
     signal.signal(signal.SIGCHLD, signal.SIG_DFL)
-    
+
     cl = Lustre.Options("lconf", "config.xml", lconf_options)
     try:
         config, args = cl.parse(sys.argv[1:])
@@ -2725,7 +3358,7 @@ def main():
     random.seed(seed)
 
     sanitise_path()
-    
+
     init_select(config.select)
 
     if len(args) > 0:
@@ -2750,8 +3383,9 @@ def main():
         except Exception:
             panic("%s does not appear to be a config file." % (args[0]))
             sys.exit(1) # make sure to die here, even in debug mode.
+        config_file.close()
         CONFIG_FILE = args[0]
-        db = Lustre.LustreDB_XML(dom.documentElement, dom.documentElement)
+        lustreDB = Lustre.LustreDB_XML(dom.documentElement, dom.documentElement)
         if not config.config:
             config.config = os.path.basename(args[0])# use full path?
             if config.config[-4:] == '.xml':
@@ -2760,7 +3394,7 @@ def main():
         if not config.config:
             panic("--ldapurl requires --config name")
         dn = "config=%s,fs=lustre" % (config.config)
-        db = Lustre.LustreDB_LDAP('', {}, base=dn, url = config.ldapurl)
+        lustreDB = Lustre.LustreDB_LDAP('', {}, base=dn, url = config.ldapurl)
     elif config.ptldebug or config.subsystem:
         sys_set_ptldebug(None)
         sys_set_subsystem(None)
@@ -2770,9 +3404,9 @@ def main():
         print 'see lconf --help for command summary'
         sys.exit(1)
 
-    toplevel = db
+    toplustreDB = lustreDB
 
-    ver = db.get_version()
+    ver = lustreDB.get_version()
     if not ver:
         panic("No version found in config data, please recreate.")
     if ver != Lustre.CONFIG_VERSION:
@@ -2804,10 +3438,14 @@ def main():
         lctl.clear_log(config.record_device, config.record_log)
         lctl.record(config.record_device, config.record_log)
 
-    doHost(db, node_list)
+    doHost(lustreDB, node_list)
 
-    if config.record:
-        lctl.end_record()
+    if not config.record:
+        return
+
+    lctl.end_record()
+
+    process_updates(lustreDB, config.record_device, config.record_log)
 
 if __name__ == "__main__":
     try: