Whamcloud - gitweb
landing b_cmobd_merge on HEAD
[fs/lustre-release.git] / lustre / utils / lmc
index 560c539..9878980 100755 (executable)
@@ -51,7 +51,7 @@ if not development_mode():
 import Lustre
 
 DEFAULT_PORT = 988 
-DEFAULT_STRIPE_SZ = 65536
+DEFAULT_STRIPE_SZ = 1048576
 DEFAULT_STRIPE_CNT = 1
 DEFAULT_STRIPE_PATTERN = 0
 UUID_MAX_LENGTH = 31
@@ -74,7 +74,7 @@ Object creation command summary:
   --node node_name
   --nid nid
   --cluster_id 
-  --nettype tcp|elan|gm|scimac
+  --nettype tcp|elan|gm
   --hostaddr addr
   --port port
   --tcpbuf size
@@ -84,14 +84,19 @@ Object creation command summary:
 --add mds
   --node node_name
   --mds mds_name
+  --failover
   --dev path
-  --fstype extN|ext3
+  --backdev path
+  --fstype ldiskfs|ext3
+  --backfstype ldiskfs|ext3|tmpfs
   --size size
   --nspath
   --journal_size size
   --inode_size size
   --lmv lmv_name
   --master
+  --mkfsoptions options
+  --mountfsoptions options
 
 --add lov
   --lov lov_name
@@ -104,14 +109,20 @@ Object creation command summary:
 --add ost
   --node node_name
   --ost ost_name 
+  --failover
   --lov lov_name 
   --dev path
+  --backdev path
   --size size
-  --fstype extN|ext3
+  --fstype ldiskfs|ext3
+  --backfstype ldiskfs|ext3|tmpfs
   --journal_size size
   --inode_size size
-  --obdtype obdecho|obdfilter
+  --osdtype obdecho|obdfilter
   --ostuuid uuid
+  --mkfsoptions options
+  --mountfsoptions options
+  --nspath
  
 --add mtpt  - Mountpoint
   --node node_name
@@ -122,8 +133,10 @@ Object creation command summary:
 
 --add route
   --node nodename
+  --router
   --gw nid
-  --tgt nid
+  --gateway_cluster_id nid
+  --target_cluster_id nid
   --lo nid
   --hi nid
 
@@ -137,6 +150,10 @@ Object creation command summary:
 --add lmv
   --lmv lmv_name
 
+--add cobd
+  --node node_name
+  --real_obd obd_name
+  --cache_obd obd_name
 """
 
 PARAM = Lustre.Options.PARAM
@@ -162,7 +179,7 @@ lmc_options = [
     ('subsystem', "Specify which Lustre subsystems have debug output recorded in the log",  PARAM),
 
     # network 
-    ('nettype', "Specify the network type. This can be tcp/elan/gm/scimac.", PARAM),
+    ('nettype', "Specify the network type. This can be tcp/elan/gm.", PARAM),
     ('nid', "Give the network ID, e.g ElanID/IP Address as used by portals.", PARAM),
     ('tcpbuf', "Optional argument to specify the TCP buffer size.", PARAM, "0"),
     ('port', "Optional argument to specify the TCP port number.", PARAM, DEFAULT_PORT),
@@ -186,11 +203,14 @@ lmc_options = [
     ('failover', "Enable failover support on OSTs or MDS?"),
     ('group', "", PARAM),
     ('dev', "Path of the device on local system.", PARAM,""),
+    ('backdev', "Path of the device for backing storage on local system.", PARAM,""),
     ('size', "Specify the size of the device if needed.", PARAM,"0"),
-    ('journal_size', "Specify new journal size for underlying ext3 file system.", PARAM,"0"),
-    ('inode_size', "Specify new inode size for underlying ext3 file system.", PARAM,"0"),
+    ('journal_size', "Specify new journal size for underlying file system.", PARAM,"0"),
+    ('inode_size', "Specify new inode size for underlying file system.", PARAM,"0"),
     ('fstype', "Optional argument to specify the filesystem type.", PARAM, "ext3"),
+    ('backfstype', "Optional argument to specify the backing filesystem type.", PARAM, "ext3"),
     ('mkfsoptions', "Optional argument to mkfs.", PARAM, ""),
+    ('mountfsoptions', "Optional argument to mount fs.", PARAM, ""),
     ('ostuuid', "", PARAM,""),
     ('nspath', "Local mount point of server namespace.", PARAM,""),
     ('format', ""),
@@ -207,8 +227,10 @@ lmc_options = [
     ('stripe_pattern', "Specify the stripe pattern. RAID 0 is the only one currently supported.", PARAM, 0),
 
     # cobd
-    ('real_obd', "", PARAM),
-    ('cache_obd', "", PARAM),
+    
+    ('real_obd', "Specify the real device for the cache obd system.", PARAM),
+    ('cache_obd', "Specify the cache device for the cache obd system.", PARAM),
+    ('cobd', "Specify COBD name", PARAM),
 
     ('mgmt', "Specify management/monitoring service name.", PARAM, ""),
 
@@ -378,14 +400,19 @@ class GenConfig:
         ldlm = self.newService("ldlm", name, uuid)
         return ldlm
 
-    def osd(self, name, uuid, fs, osdtype, devname, format, ost_uuid,
-            node_uuid, dev_size=0, journal_size=0, inode_size=0, nspath="", mkfsoptions=""):
+    def osd(self, name, uuid, fstype, osdtype, devname, format, ost_uuid,
+            node_uuid, dev_size=0, journal_size=0, inode_size=0, nspath="", 
+            mkfsoptions="", mountfsoptions="", backfstype="", backdevname=""):
         osd = self.newService("osd", name, uuid)
         osd.setAttribute('osdtype', osdtype)
         osd.appendChild(self.ref("target", ost_uuid))
         osd.appendChild(self.ref("node", node_uuid))
-        if fs:
-            self.addElement(osd, "fstype", fs)
+        if fstype:
+            self.addElement(osd, "fstype", fstype)
+        if backfstype:
+            self.addElement(osd, "backfstype", backfstype)
+        if backdevname:
+            self.addElement(osd, "backdevpath", backdevname)
         if devname:
             dev = self.addElement(osd, "devpath", devname)
             self.addElement(osd, "autoformat", format)
@@ -397,6 +424,8 @@ class GenConfig:
                 self.addElement(osd, "inodesize", "%s" % (inode_size))
             if mkfsoptions:
                 self.addElement(osd, "mkfsoptions", mkfsoptions)
+            if mountfsoptions:
+                self.addElement(osd, "mountfsoptions", mountfsoptions)
         if nspath:
             self.addElement(osd, "nspath", nspath)
         return osd
@@ -444,12 +473,17 @@ class GenConfig:
             lmv.appendChild(self.ref("active", uuid))
         return mds
 
-    def mdsdev(self, name, uuid, fs, devname, format, node_uuid,
+    def mdsdev(self, name, uuid, fstype, devname, format, node_uuid,
                mds_uuid, dev_size=0, journal_size=0, inode_size=256,
-               nspath="", mkfsoptions="", lmv_uuid=""):
+               nspath="", mkfsoptions="", mountfsoptions="", backfstype="", 
+               backdevname="", lmv_uuid=""):
         mdd = self.newService("mdsdev", name, uuid)
-        self.addElement(mdd, "fstype", fs)
+        self.addElement(mdd, "fstype", fstype)
+        if backfstype:
+                self.addElement(mdd, "backfstype", backfstype)
         dev = self.addElement(mdd, "devpath", devname)
+        if backdevname:
+            self.addElement(mdd, "backdevpath", backdevname)
         self.addElement(mdd, "autoformat", format)
         if dev_size:
                 self.addElement(mdd, "devsize", "%s" % (dev_size))
@@ -461,6 +495,9 @@ class GenConfig:
             self.addElement(mdd, "nspath", nspath)
         if mkfsoptions:
             self.addElement(mdd, "mkfsoptions", mkfsoptions)
+        if mountfsoptions:
+            self.addElement(mdd, "mountfsoptions", mountfsoptions)
+
         mdd.appendChild(self.ref("node", node_uuid))
         mdd.appendChild(self.ref("target", mds_uuid))
        if lmv_uuid:
@@ -659,7 +696,7 @@ def add_net(gen, lustre, options):
         port = get_option_int(options, 'port')
         tcpbuf = get_option_int(options, 'tcpbuf')
         irq_aff = get_option_int(options, 'irq_affinity')
-    elif net_type in ('elan', 'gm', 'scimac'):
+    elif net_type in ('elan', 'gm'):
         port = 0
         tcpbuf = 0
         irq_aff = 0
@@ -739,12 +776,15 @@ def add_mds(gen, lustre, options):
         mds.setAttribute('failover', "1")
 
     devname = get_option(options, 'dev')
+    backdevname = get_option(options, 'backdev')
     size = get_option(options, 'size')
     fstype = get_option(options, 'fstype')
+    backfstype = get_option(options, 'backfstype')
     journal_size = get_option(options, 'journal_size')
     inode_size = get_option(options, 'inode_size')
     nspath = get_option(options, 'nspath')
     mkfsoptions = get_option(options, 'mkfsoptions')
+    mountfsoptions = get_option(options, 'mountfsoptions')
 
     node_uuid = name2uuid(lustre, node_name, 'node')
 
@@ -762,8 +802,8 @@ def add_mds(gen, lustre, options):
 
     mdd = gen.mdsdev(mdd_name, mdd_uuid, fstype, devname,
                      get_format_flag(options), node_uuid, mds_uuid,
-                     size, journal_size, inode_size, nspath, mkfsoptions,
-                    lmv_uuid)
+                     size, journal_size, inode_size, nspath, mkfsoptions, 
+                     mountfsoptions, backfstype, backdevname, lmv_uuid)
     lustre.appendChild(mdd)
                    
 
@@ -793,19 +833,24 @@ def add_ost(gen, lustre, options):
 
     if osdtype == 'obdecho':
         fstype = ''
+        backfstype = ''
         devname = ''
+        backdevname = ''
         size = 0
-        fstype = ''
         journal_size = ''
         inode_size = ''
         mkfsoptions = ''
+        mountfsoptions = ''
     else:
         devname = get_option(options, 'dev') # can be unset for bluearcs
+        backdevname = get_option(options, 'backdev')
         size = get_option(options, 'size')
         fstype = get_option(options, 'fstype')
+        backfstype = get_option(options, 'backfstype')
         journal_size = get_option(options, 'journal_size')
         inode_size = get_option(options, 'inode_size')
         mkfsoptions = get_option(options, 'mkfsoptions')
+        mountfsoptions = get_option(options, 'mountfsoptions')
         
     nspath = get_option(options, 'nspath')
 
@@ -841,7 +886,8 @@ def add_ost(gen, lustre, options):
 
     osd = gen.osd(osdname, osd_uuid, fstype, osdtype, devname,
                   get_format_flag(options), ost_uuid, node_uuid, size,
-                  journal_size, inode_size, nspath, mkfsoptions)
+                  journal_size, inode_size, nspath, mkfsoptions, 
+                  mountfsoptions, backfstype, backdevname)
 
     node = findByName(lustre, node_name, "node")
 
@@ -857,17 +903,58 @@ def add_ost(gen, lustre, options):
                    
 def add_cobd(gen, lustre, options):
     node_name = get_option(options, 'node')
-    name = new_name('COBD_' + node_name)
+    name = get_option(options, 'cobd')
     uuid = new_uuid(name)
 
     real_name = get_option(options, 'real_obd')
     cache_name = get_option(options, 'cache_obd')
     
-    real_uuid = name2uuid(lustre, real_name, tag='obd')
-    cache_uuid = name2uuid(lustre, cache_name, tag='obd')
+    real_uuid = name2uuid(lustre, real_name, tag='lov', fatal=0)
+    cache_uuid = name2uuid(lustre, cache_name, tag='lov', fatal=0)
+
+    if real_uuid:
+        node = lookup(lustre, real_uuid)
+        rets = node.getElementsByTagName('obd_ref')
+        for ret in rets:
+            ost_uuid = ret.getAttribute('uuidref')
+            ost_node = lookup(lustre, ost_uuid)
+            ret = ost_node.getElementsByTagName('active_ref')
+            if ret:
+                osd_uuid = ret[0].getAttribute('uuidref')
+                osd_node = lookup(lustre, osd_uuid)
+                gen.addElement(osd_node, 'cachetype', 'master')
+
+    if cache_uuid:
+        node = lookup(lustre, cache_uuid)
+        rets = node.getElementsByTagName('obd_ref')
+        for ret in rets:
+            ost_uuid = ret.getAttribute('uuidref')
+            ost_node = lookup(lustre, ost_uuid)
+            ret = ost_node.getElementsByTagName('active_ref')
+            if ret:
+                osd_uuid = ret[0].getAttribute('uuidref')
+                osd_node = lookup(lustre, osd_uuid)
+                gen.addElement(osd_node, 'cachetype', 'cache')
+
+    if not real_uuid or not cache_uuid:
+        real_uuid = name2uuid(lustre,real_name, tag='mds')
+        cache_uuid = name2uuid(lustre,cache_name, tag='mds')
+        if real_uuid:
+            mds_node = lookup(lustre, real_uuid)
+            ret = mds_node.getElementsByTagName('active_ref')
+            if ret:
+                mdsdev_uuid = ret[0].getAttribute('uuidref')
+                mdsdev_node = lookup(lustre, mdsdev_uuid)
+                gen.addElement(mdsdev_node, 'cachetype', 'master')
+        if cache_uuid:
+            mds_node = lookup(lustre, cache_uuid)
+            ret = mds_node.getElementsByTagName('active_ref')
+            if ret:
+                mdsdev_uuid = ret[0].getAttribute('uuidref')
+                mdsdev_node = lookup(lustre, mdsdev_uuid)
+                gen.addElement(mdsdev_node, 'cachetype', 'cache')
 
     node = findByName(lustre, node_name, "node")
-    node_add_profile(gen, node, "cobd", uuid)
     cobd = gen.cobd(name, uuid, real_uuid, cache_uuid)
     lustre.appendChild(cobd)
 
@@ -894,6 +981,7 @@ def add_echo_client(gen, lustre, options):
 def add_lov(gen, lustre, options):
     """ create a lov """
 
+    lmv_name = get_option(options, 'lmv')
     lov_orig = get_option(options, 'lov')
     name = new_name(lov_orig)
     if name != lov_orig:
@@ -901,7 +989,6 @@ def add_lov(gen, lustre, options):
 
     mds_name = get_option(options, 'mds')
     if not mds_name:
-       lmv_name = get_option(options, 'lmv')
        if not lmv_name:
            error("LOV: MDS or LMV must be specified.");
 
@@ -977,8 +1064,20 @@ 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)
-    mds = lookup(lustre, mds_uuid)
-    mds.appendChild(gen.ref("filesystem", fs_uuid))
+    cobd = lookup(lustre, mds_uuid)
+    #SHOULD appendChild filesystem to real mds not cobd
+    ret = cobd.getElementsByTagName("cacheobd_ref")
+    if ret:
+        cacheobd_uuid = ret[0].getAttribute('uuidref') 
+        cacheobd = lookup(lustre, cacheobd_uuid)
+        cacheobd.appendChild(gen.ref("filesystem", fs_uuid))
+        ret = cobd.getElementsByTagName("realobd_ref")
+        if ret:
+            realobd_uuid = ret[0].getAttribute('uuidref')
+            realobd = lookup(lustre, realobd_uuid)
+            realobd.appendChild(gen.ref("filesystem", fs_uuid))
+    else:
+        cobd.appendChild(gen.ref("filesystem", fs_uuid))
     fs = gen.filesystem(fs_name, fs_uuid, mds_uuid, obd_uuid, mgmt_uuid)
     lustre.appendChild(fs)
     return fs_uuid
@@ -986,8 +1085,12 @@ def new_filesystem(gen, lustre, mds_uuid, obd_uuid, mgmt_uuid):
 def get_fs_uuid(gen, lustre, mds_name, obd_name, mgmt_name):
     mds_uuid = name2uuid(lustre, mds_name, tag='mds', fatal=0)
     if not mds_uuid:
-        mds_uuid = name2uuid(lustre, mds_name, tag='lmv', fatal=1)
+        mds_uuid = name2uuid(lustre, mds_name, tag='lmv', fatal=0)
+    if not mds_uuid:
+        mds_uuid = name2uuid(lustre, mds_name, tag='cobd', fatal=1) 
     obd_uuid = name2uuid(lustre, obd_name, tag='lov', fatal=0)
+    if obd_uuid == '':
+       obd_uuid = name2uuid(lustre, obd_name, tag='cobd')
     if mgmt_name:
         mgmt_uuid = name2uuid(lustre, mgmt_name, tag='mgmt', fatal=1)
     else: