Whamcloud - gitweb
Default mount options stuff.
authoryury <yury>
Wed, 12 May 2004 10:27:04 +0000 (10:27 +0000)
committeryury <yury>
Wed, 12 May 2004 10:27:04 +0000 (10:27 +0000)
lustre/smfs/dir.c
lustre/tests/local.sh
lustre/utils/lconf

index ca479a0..0c5b82d 100644 (file)
@@ -179,7 +179,7 @@ exit:
         RETURN(rc);
 }
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) && !defined(CONFIG_RH_2_4_20))
 static int smfs_lookup_raw(struct inode *dir, const char *name,
                            int len, ino_t *data)
 {
index 44fa4b9..4bf2e5d 100755 (executable)
@@ -25,20 +25,6 @@ OST_BACKFSTYPE=${OST_BACKFSTYPE:-ext3}
 MDS_BACKDEV=${MDS_BACKDEV:-$TMP/mds1-`hostname`}
 OST_BACKDEV=${OST_BACKDEV:-$TMP/ost1-`hostname`}
 
-MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"errors=remount-ro"}
-OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"errors=remount-ro"}
-
-# adding some options needed for ext3 on 2.4.x kernels
-if test "x$(uname -r | sed -e 's/-.*//' -e 's/\.[[:digit:]]*$//')" = "x2.4"; then
-    if test "x$FSTYPE" = "xext3" || test "x$FSTYPE" = "xldiskfs"; then
-       if test "x$OST_MOUNT_OPTS" = "x"; then
-           OST_MOUNT_OPTS="asyncdel"
-       else
-           OST_MOUNT_OPTS="$OST_MOUNT_OPTS,asyncdel"
-       fi
-    fi
-fi
-
 # specific journal size for the ost, in MB
 JSIZE=${JSIZE:-0}
 [ "$JSIZE" -gt 0 ] && JARG="--journal_size $JSIZE"
@@ -55,15 +41,16 @@ ${LMC} --add node --node localhost || exit 10
 ${LMC} --add net --node  localhost --nid `hostname` --nettype $NETWORKTYPE || exit 11
 ${LMC} --add net --node client --nid '*' --nettype $NETWORKTYPE || exit 12
 
-echo "MDS mount options are: $MDS_MOUNT_OPTS"
+[ "x$MDS_MOUNT_OPTS" != "x" ] &&
+    MDS_MOUNT_OPTS="--mountfsoptions $MDS_MOUNT_OPTS"
 
 # configure mds server
 ${LMC} --add mds --nspath /mnt/mds_ns --node localhost --mds mds1 \
 --fstype $FSTYPE --backfstype $MDS_BACKFSTYPE --dev $MDSDEV \
---backdev $MDS_BACKDEV --mountfsoptions $MDS_MOUNT_OPTS \
---size $MDSSIZE $JARG $IARG || exit 20
+--backdev $MDS_BACKDEV $MDS_MOUNT_OPTS --size $MDSSIZE $JARG $IARG || exit 20
 
-echo "OST mount options are: $OST_MOUNT_OPTS"
+[ "x$OST_MOUNT_OPTS" != "x" ] &&
+    OST_MOUNT_OPTS="--mountfsoptions $OST_MOUNT_OPTS"
 
 # configure ost
 ${LMC} -m $config --add lov --lov lov1 --mds mds1 --stripe_sz $STRIPE_BYTES \
@@ -71,8 +58,7 @@ ${LMC} -m $config --add lov --lov lov1 --mds mds1 --stripe_sz $STRIPE_BYTES \
 
 ${LMC} --add ost --nspath /mnt/ost_ns --node localhost --lov lov1 \
 --fstype $FSTYPE --backfstype $OST_BACKFSTYPE --dev $OSTDEV \
---backdev $OST_BACKDEV --mountfsoptions $OST_MOUNT_OPTS \
---size $OSTSIZE $JARG || exit 30
+--backdev $OST_BACKDEV $OST_MOUNT_OPTS --size $OSTSIZE $JARG || exit 30
 
 # create client config
 ${LMC} --add mtpt --node localhost --path $MOUNT --mds mds1 --lov lov1 || exit 40
index d74fa4f..bb3a45d 100755 (executable)
@@ -719,7 +719,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):
@@ -880,6 +880,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",
@@ -936,6 +945,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:
@@ -1458,33 +1483,44 @@ class MDSDEV(Module):
         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
+                
+            lctl.newdev("mds", self.name, self.uuid,
+                        setup ="%s %s %s %s" %(realdev, self.fstype, 
+                                               self.name, mountfsoptions))
         except CommandError, e:
             if e.rc == 2:
                 panic("MDS is missing the config log. Need to run " +
@@ -1501,39 +1537,51 @@ class MDSDEV(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
 
        # Even for writing logs we mount mds with supplied mount options
        # because it will not mount smfs (if used) otherwise.
        
-        # we count, that mountfsoptions is always not None for smfs    
+        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
-            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
-            
+       
+        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 @dumb, which will be checked
-       # in MDS code and skipped.
-        if mountfsoptions != None:
-            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'))
-
+       # 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))
         # record logs for the MDS lov
         for uuid in self.filesystem_uuids:
             log("recording clients for filesystem:", uuid)
@@ -1720,31 +1768,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 ="")