diff --git a/base/mysql.hh b/base/mysql.hh index b2e87dcbd..e16558dd3 100644 --- a/base/mysql.hh +++ b/base/mysql.hh @@ -185,6 +185,24 @@ class Connection return query(sql.str()); } + bool + autocommit(bool mode) + { + return mysql_autocommit(&mysql, mode); + } + + bool + commit() + { + return mysql_commit(&mysql); + } + + bool + rollback() + { + return mysql_rollback(&mysql); + } + unsigned field_count() { diff --git a/base/stats/mysql.cc b/base/stats/mysql.cc index 8526b7866..27212b2c2 100644 --- a/base/stats/mysql.cc +++ b/base/stats/mysql.cc @@ -67,16 +67,14 @@ MySqlRun::connect(const string &host, const string &user, const string &passwd, if (mysql.error) panic("could not connect to database server\n%s\n", mysql.error); - mysql.query("LOCK TABLES runs WRITE"); - if (mysql.error) - panic("could not lock tables\n%s\n", mysql.error); + if (mysql.autocommit(false)) + panic("could not set autocommit\n"); remove(name); -// cleanup(); + //cleanup(); setup(name, sample, user, project); - mysql.query("UNLOCK TABLES"); - if (mysql.error) - panic("could not unlock tables\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); } void @@ -206,6 +204,8 @@ SetupStat::setup() if (!result) panic("could not find stat\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); assert(result.num_fields() == 16); MySQL::Row row = result.fetch_row(); @@ -293,9 +293,8 @@ SetupBin(const string &bin) Connection &mysql = MySqlDB.conn(); assert(mysql.connected()); - mysql.query("LOCK TABLES bins WRITE"); - if (mysql.error) - panic("could not lock bin table\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); uint16_t bin_id; @@ -324,9 +323,8 @@ SetupBin(const string &bin) binmap.insert(make_pair(bin, bin_id)); exit: - mysql.query("UNLOCK TABLES"); - if (mysql.error) - panic("could not unlock tables\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); return bin_id; } @@ -352,6 +350,8 @@ InsertData::flush() mysql.query(query); if (mysql.error) panic("could not insert data\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); } query[0] = '\0'; @@ -406,6 +406,9 @@ InsertSubData::setup() mysql.query(insert); // if (mysql.error) // panic("could not insert subdata\n%s\n", mysql.error); + + if (mysql.commit()) + panic("could not commit transaction\n"); } void @@ -430,6 +433,9 @@ InsertFormula(uint16_t stat, const string &formula) mysql.query(insert_ref); // if (mysql.error) // panic("could not insert formula reference\n%s\n", mysql.error); + + if (mysql.commit()) + panic("could not commit transaction\n"); } void @@ -443,6 +449,9 @@ UpdatePrereq(uint16_t stat, uint16_t prereq) mysql.query(update); if (mysql.error) panic("could not update prereq\n%s\n", mysql.error); + + if (mysql.commit()) + panic("could not commit transaction\n"); } void @@ -454,18 +463,13 @@ MySql::configure() using namespace Database; MySQL::Connection &mysql = MySqlDB.conn(); - mysql.query("LOCK TABLES " - "stats WRITE, " - "bins WRITE, " - "subdata WRITE, " - "formulas WRITE, " - "formula_ref WRITE"); - if (mysql.error) - panic("could not lock tables\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); stat_list_t::const_iterator i, end = stats().end(); - for (i = stats().begin(); i != end; ++i) + for (i = stats().begin(); i != end; ++i) { (*i)->visit(*this); + } for (i = stats().begin(); i != end; ++i) { StatData *data = *i; @@ -478,9 +482,8 @@ MySql::configure() } } - mysql.query("UNLOCK TABLES"); - if (mysql.error) - panic("could not unlock tables\n%s\n", mysql.error); + if (mysql.commit()) + panic("could not commit transaction\n"); configured = true; } @@ -632,6 +635,8 @@ MySql::configure(const FormulaData &data) void MySql::output(MainBin *bin) { + MySQL::Connection &mysql = MySqlDB.conn(); + if (bin) { bin->activate(); newdata.bin = SetupBin(bin->name()); @@ -642,8 +647,11 @@ MySql::output(MainBin *bin) Database::stat_list_t::const_iterator i, end = Database::stats().end(); for (i = Database::stats().begin(); i != end; ++i) { StatData *stat = *i; - if (bin && stat->binned() || !bin && !stat->binned()) + if (bin && stat->binned() || !bin && !stat->binned()) { stat->visit(*this); + if (mysql.commit()) + panic("could not commit transaction\n"); + } } } diff --git a/base/stats/mysql_run.hh b/base/stats/mysql_run.hh index a58244d80..d8dcb7594 100644 --- a/base/stats/mysql_run.hh +++ b/base/stats/mysql_run.hh @@ -42,6 +42,13 @@ struct MySqlRun MySQL::Connection mysql; uint16_t run_id; + protected: + void setup(const std::string &name, const std::string &sample, + const std::string &user, const std::string &project); + + void remove(const std::string &name); + void cleanup(); + public: bool connected() const { return mysql.connected(); } void connect(const std::string &host, const std::string &user, @@ -49,12 +56,6 @@ struct MySqlRun const std::string &name, const std::string &sample, const std::string &project); - void setup(const std::string &name, const std::string &sample, - const std::string &user, const std::string &project); - - void remove(const std::string &name); - void cleanup(); - MySQL::Connection &conn() { return mysql; } uint16_t run() const { return run_id; } }; diff --git a/configs/boot/iscsi-client.rcS b/configs/boot/iscsi-client.rcS new file mode 100644 index 000000000..d0916d0b9 --- /dev/null +++ b/configs/boot/iscsi-client.rcS @@ -0,0 +1,92 @@ +#!/bin/sh +# +# /etc/init.d/rcS +# + +echo -n "mounting swap..." +/sbin/swapon /dev/hdc +echo "done." + +echo -n "setting up network..." +/sbin/ifconfig lo 127.0.0.1 +/sbin/ifconfig eth0 192.168.0.10 txqueuelen 1000 + +echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle +echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse +echo "1" > /proc/sys/net/ipv4/tcp_window_scaling +echo "0" > /proc/sys/net/ipv4/tcp_timestamps +echo "0" > /proc/sys/net/ipv4/tcp_sack +echo "15" > /proc/sys/net/ipv4/tcp_fin_timeout +echo "16384" > /proc/sys/net/ipv4/tcp_max_syn_backlog +echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max +echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_rmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_wmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_mem +#echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max +echo "524287" > /proc/sys/net/core/rmem_max +echo "524287" > /proc/sys/net/core/wmem_max +echo "524287" > /proc/sys/net/core/optmem_max +echo "300000" > /proc/sys/net/core/netdev_max_backlog +echo "131072" > /proc/sys/fs/file-max +echo "10" > /proc/sys/vm/dirty_writeback_centisecs +echo "done." + +cat > /etc/initiatorname.iscsi < /etc/iscsi.conf < /var/log/iscsi.log +chmod 0600 /var/log/iscsi.log + +# Required for udev to activate/deactivate devices. +echo "/sbin/hotplug" > /proc/sys/kernel/hotplug + +/sbin/insmod /modules/iscsi_sfnet.ko + +# Create /dev/iscsictl +if [ ! -f /dev/iscsictl ]; then + while read major device + do + if [ "$device" == "iscsictl" ]; then + mknod /dev/$device c $major 0 + fi + done < /proc/devices +fi + +echo -n "waiting for server..." +/usr/bin/netcat -c -l -p 8000 + +echo -n "Starting iscsid..." +/iscsi/iscsid +echo "done." + +sleep 5 + +mount /dev/sda /mnt +cd /mnt + +initparam=`cat /proc/m5/initparam` + +if test X$initparam == X0; then + /sbin/m5 checkpoint 100000000 2000000000 + dd if=/dev/zero of=foo bs=1024k count=512 +else + /sbin/m5 checkpoint 1000000000 2000000000 + /benchmarks/dbench/dbench $initparam +fi + +echo "starting bash shell..." +/bin/bash + +echo -n "halting machine" +m5 exit diff --git a/configs/boot/iscsi-server.rcS b/configs/boot/iscsi-server.rcS new file mode 100644 index 000000000..7b409e291 --- /dev/null +++ b/configs/boot/iscsi-server.rcS @@ -0,0 +1,58 @@ +#!/bin/sh +# +# /etc/init.d/rcS +# + +echo -n "mounting swap..." +/sbin/swapon /dev/hdc +echo "done." + +echo -n "setting up network..." +/sbin/ifconfig lo 127.0.0.1 +/sbin/ifconfig eth0 192.168.0.1 txqueuelen 1000 + +echo "1" > /proc/sys/net/ipv4/tcp_tw_recycle +echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse +echo "1" > /proc/sys/net/ipv4/tcp_window_scaling +echo "0" > /proc/sys/net/ipv4/tcp_timestamps +echo "0" > /proc/sys/net/ipv4/tcp_sack +echo "15" > /proc/sys/net/ipv4/tcp_fin_timeout +echo "16384" > /proc/sys/net/ipv4/tcp_max_syn_backlog +echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max +echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_rmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_wmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_mem +#echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max +echo "524287" > /proc/sys/net/core/rmem_max +echo "524287" > /proc/sys/net/core/wmem_max +echo "524287" > /proc/sys/net/core/optmem_max +echo "300000" > /proc/sys/net/core/netdev_max_backlog +echo "131072" > /proc/sys/fs/file-max +echo "10" > /proc/sys/vm/dirty_writeback_centisecs +echo "done." + +/sbin/insmod /modules/scsi_debug.ko dev_size_mb=768 + +mke2fs -F /dev/sda + +cat > /etc/ietd.conf < /proc/sys/net/ipv4/tcp_tw_recycle +echo "1" > /proc/sys/net/ipv4/tcp_tw_reuse +echo "1" > /proc/sys/net/ipv4/tcp_window_scaling +echo "0" > /proc/sys/net/ipv4/tcp_timestamps +echo "0" > /proc/sys/net/ipv4/tcp_sack +echo "15" > /proc/sys/net/ipv4/tcp_fin_timeout +echo "16384" > /proc/sys/net/ipv4/tcp_max_syn_backlog +echo "262144" > /proc/sys/net/ipv4/ip_conntrack_max +echo "1024 65535" > /proc/sys/net/ipv4/ip_local_port_range +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_rmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_wmem +echo "10000000 10000000 10000000" > /proc/sys/net/ipv4/tcp_mem +echo "524287" > /proc/sys/net/core/rmem_max +echo "524287" > /proc/sys/net/core/wmem_max +echo "524287" > /proc/sys/net/core/optmem_max +echo "300000" > /proc/sys/net/core/netdev_max_backlog +echo "131072" > /proc/sys/fs/file-max +echo "10" > /proc/sys/vm/dirty_writeback_centisecs +echo "done." + +echo -n "starting nfs client..." +/sbin/portmap & +/sbin/lockd & +echo "done." + +echo -n "waiting for server..." +/usr/bin/netcat -c -l -p 8000 + +echo -n "mounting remote share..." +mkdir /nfs +mount 10.0.0.1:/nfs /nfs +echo "done." + +cd /nfs + +initparam=`cat /proc/m5/initparam` + +if test X$initparam == X0; then + /sbin/m5 checkpoint 100000000 2000000000 + dd if=/dev/zero of=foo bs=1024k count=512 +else + /sbin/m5 checkpoint 1000000000 2000000000 + /benchmarks/dbench/dbench $initparam +fi + +/sbin/m5 exit