[patch] build off of memory device

Jason Helfman jgh at FreeBSD.org
Mon Feb 13 18:18:07 EST 2012


Hello All,

swills@ and myself and have worked on the following patch.

It allows one to build off of a memory device, ufs or zfs, configured
through a new tinderbox option called "configMd"

The entire build is created and executed in the memory device, which we
have found to result in much faster builds, as well as cleanup of the jail.
(ie. we've put it through the ringer, and it is blazing fast :) )

http://people.freebsd.org/~jgh/files/tinder_md.patch.txt

Attached is the patch, as well.

Thanks for your consideration,
Jason

-- 
Jason Helfman         | FreeBSD Committer
jgh at FreeBSD.org       | http://people.freebsd.org/~jgh
-------------- next part --------------
Index: portstools/tinderbox/lib/tc_command.pl
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.pl,v
retrieving revision 1.176
diff -u -r1.176 tc_command.pl
--- portstools/tinderbox/lib/tc_command.pl	23 Oct 2011 15:22:21 -0000	1.176
+++ portstools/tinderbox/lib/tc_command.pl	30 Dec 2011 17:43:30 -0000
@@ -132,6 +132,13 @@
                 usage  => "[-d <log directory> | -D] [-c | -C] [-z | -Z]",
                 optstr => 'd:DcCzZ',
         },
+        "configMd" => {
+                func => \&configMd,
+                help =>
+                    "Configure Tinderbox to build against a memory device",
+                usage  => "[-s <memory size>] [-t <filesystem type>]",
+                optstr => 's:t:',
+        },
         "listJails" => {
                 func  => \&listJails,
                 help  => "List all jails in the datastore",
@@ -1007,6 +1014,39 @@
                     . "\n");
 }
 
+sub configMd {
+        my @config = ();
+        my $size;
+        my $fstype;
+
+        if (scalar(keys %{$opts}) == 0) {
+                configGet("md");
+                cleanup($ds, 0, undef);
+        }
+
+        $size = new Tinderbox::Config();
+        $size->setOptionName("size");
+
+        $fstype = new Tinderbox::Config();
+        $fstype->setOptionName("fstype");
+
+        if ($opts->{'s'}) {
+                $size->setOptionValue($opts->{'s'});
+                push @config, $size;
+        }
+
+        if ($opts->{'t'}) {
+                $fstype->setOptionValue($opts->{'t'});
+                push @config, $fstype;
+        }
+
+        $ds->updateConfig("md", @config)
+            or cleanup($ds, 1,
+                      "Failed to update tinderd configuration: "
+                    . $ds->getError()
+                    . "\n");
+}
+
 sub configOptions {
         my @config = ();
         my $enabled;
Index: portstools/tinderbox/lib/tc_command.sh
===================================================================
RCS file: /space/cvs/marcuscom-cvs/portstools/tinderbox/lib/tc_command.sh,v
retrieving revision 1.145
diff -u -r1.145 tc_command.sh
--- portstools/tinderbox/lib/tc_command.sh	15 Nov 2011 07:03:39 -0000	1.145
+++ portstools/tinderbox/lib/tc_command.sh	30 Dec 2011 17:43:31 -0000
@@ -1310,6 +1310,25 @@
     tinderbuild_reset ${buildName}
     cleanDirs ${buildName} ${BUILD_DIR}
 
+    if [ "${MD_FSTYPE}" = "ufs" -o "${MD_FSTYPE}" = "zfs" ]; then
+      if [ ! -z ${MD_SIZE} ] ; then
+        # setup md (ramdisk) backing for the build
+        mdconfig -a -t swap -s $MD_SIZE > /tmp/tinderd_md.${build}
+        read MD_UNIT </tmp/tinderd_md.${build}
+
+        if [ ${MD_FSTYPE} = "ufs" ]; then
+          newfs -m 0 -o time /dev/${MD_UNIT}
+          mount /dev/${MD_UNIT} ${BUILD_DIR}
+	else
+          zpool create ${MD_UNIT} /dev/${MD_UNIT}
+          zfs set compression=on ${MD_UNIT}
+          zfs set mountpoint=${BUILD_DIR} ${MD_UNIT}
+	fi
+      fi
+    else
+      echo "You must define either ufs or zfs as your memory device."
+    fi
+
     # Extract the tarball
     echo "makeBuild: extracting jail tarball"
     tar -C ${BUILD_DIR} -xpf ${JAIL_TARBALL}
@@ -1452,6 +1471,21 @@
     cleanupMounts -t builddistcache -b $1
     cleanupMounts -t buildoptions -b $1
     umount -f $(tinderLoc buildroot $1)/dev >/dev/null 2>&1
+
+    if [ "${MD_FSTYPE}" = "ufs" -o "${MD_FSTYPE}" = "zfs" ]; then
+        if [ -f /tmp/tinderd_md.${build} ] ; then
+          read MD_UNIT </tmp/tinderd_md.${build}
+          df | grep ${build} | grep ${MD_UNIT}
+            if [ $? -eq 0 ]; then
+	      if [ ${MD_FSTYPE} = "ufs" ]; then
+                umount -f /dev/${MD_UNIT}
+	      else
+                zpool destroy ${MD_UNIT}
+              fi
+              mdconfig -d -u ${MD_UNIT}
+            fi
+        fi
+    fi
 }
 
 tinderbuild_cleanup () {
@@ -1468,6 +1502,17 @@
     rm -f "/tmp/tb_pipe0.${build}_${date}"
     rm -f "/tmp/tb_pipe1.${build}_${date}"
     rm -f "/tmp/tb_pipe2.${build}_${date}"
+
+    if [ "${MD_FSTYPE}" = "ufs" -o "${MD_FSTYPE}" = "zfs" ]; then
+      read MD_UNIT </tmp/tinderd_md.${build}
+        if [ ${MD_FSTYPE} = "ufs" ]; then
+          umount -f /dev/${MD_UNIT}
+	else
+          zpool destroy ${MD_UNIT}
+	fi
+        mdconfig -d -u ${MD_UNIT}
+    fi
+
     echo 
 
     exit $1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://marcuscom.com/pipermail/tinderbox-list/attachments/20120213/bb0cc7c8/attachment.bin>


More information about the tinderbox-list mailing list