├── .arcconfig ├── .arclint ├── .arctools └── clang-format-linter │ ├── LICENSE │ ├── README.md │ ├── __phutil_library_init__.php │ ├── __phutil_library_map__.php │ └── lint │ └── linter │ └── ClangFormatLinter.php ├── .clang-format ├── .gitignore ├── AUTHORS ├── COPYRIGHT ├── Makefile ├── README.md ├── benchmarks ├── Makefile ├── aurora.conf ├── fb-post.sh ├── ffs.sh ├── lighttpd.conf ├── networkfs.f ├── nginx.conf ├── posix │ ├── Makefile │ ├── posix.c │ └── posix.sh ├── redis.conf ├── requirements ├── rocksdb.sh ├── run.py ├── runall.sh ├── runffs.sh ├── runsls.sh ├── runzfs.sh ├── scripts │ ├── macro │ │ ├── fileserver.f │ │ ├── mongo.f │ │ ├── varmail.f │ │ └── webserver.f │ ├── micro │ │ ├── createfiles-16t-64k.f │ │ ├── randomw-4t-4k.f │ │ ├── randomw-4t-64k.f │ │ ├── seqwrite-4t-4k.f │ │ ├── seqwrite-4t-64k.f │ │ ├── writedsync-4t-4k.f │ │ └── writedsync-4t-64k.f │ └── supermicro │ │ ├── randomw-4t-4k.f │ │ ├── randomw-4t-64k.f │ │ ├── seqwrite-4t-4k.f │ │ └── seqwrite-4t-64k.f ├── setup.sh ├── skylake4.conf ├── sls.conf ├── slsbenchmarks.sh ├── vmobject │ ├── Makefile │ ├── vmobject.c │ └── vmobject.sh ├── vmregion │ ├── Makefile │ └── vmregion.c └── zfs.sh ├── include ├── Makefile ├── btree.h ├── slos.h ├── slos_bnode.h ├── slos_btree.h ├── slos_inode.h ├── slos_io.h ├── sls.h ├── sls_data.h ├── sls_debug_common.h ├── sls_ioctl.h ├── sls_message.h ├── sls_wal.h └── slsfs.h ├── libsls ├── Makefile ├── sls.3 ├── sls.c ├── sls_private.c ├── sls_private.h └── sls_wal.c ├── metropolis ├── Makefile ├── metr_internal.h ├── metr_ioctl.c ├── metr_restore.c ├── metr_syscall.c └── metr_syscall.h ├── scripts ├── ckpt.d ├── create_root_subr.sh ├── memsnap.d ├── rest.d └── stages.d ├── slfs ├── slsfs_dir.c ├── slsfs_dir.h ├── slsfs_vfsops.c └── slsfs_vnops.c ├── slos ├── Makefile ├── debug.h ├── slos_alloc.c ├── slos_alloc.h ├── slos_btree.c ├── slos_inode.c ├── slos_io.c ├── slos_radix.c ├── slos_radix.h ├── slos_subr.c ├── slos_subr.h ├── slsfs_buf.c └── slsfs_buf.h ├── sls ├── Makefile ├── debug.h ├── pts_internal.h ├── sls_backend.c ├── sls_backend.h ├── sls_ckpt.c ├── sls_file.c ├── sls_file.h ├── sls_filebackend.c ├── sls_internal.h ├── sls_io.c ├── sls_io.h ├── sls_ioctl.c ├── sls_kqueue.c ├── sls_kv.c ├── sls_kv.h ├── sls_load.c ├── sls_load.h ├── sls_pager.c ├── sls_pager.h ├── sls_partition.c ├── sls_partition.h ├── sls_pgresident.c ├── sls_pipe.c ├── sls_posixshm.c ├── sls_prefault.c ├── sls_prefault.h ├── sls_proc.c ├── sls_proc.h ├── sls_pts.c ├── sls_region.c ├── sls_rest.c ├── sls_socket.c ├── sls_sockrcv.c ├── sls_socksnd.c ├── sls_syscall.c ├── sls_syscall.h ├── sls_sysv.c ├── sls_sysv.h ├── sls_table.c ├── sls_table.h ├── sls_vm.c ├── sls_vm.h ├── sls_vmobject.c ├── sls_vmobject.h ├── sls_vmspace.c ├── sls_vmspace.h ├── sls_vnode.c ├── sls_vnode.h ├── slsbk_slos.c └── sysv_internal.h ├── tests ├── 001-load-unload.sh ├── 002-load-mount-unload.sh ├── 003-mount-unmount.sh ├── 004-load-double-sls.sh ├── 005-unload-double-sls.sh ├── 006-load-double-slos.sh ├── 007-unload-double-slos.sh ├── 008-mount-double.sh ├── 009-unload-slos-before-unmount.sh ├── 010-unmount-before-sls.sh ├── 011-sls-without-slsfs.sh ├── 012-invalid-slsfs.sh ├── 013-mount-snapshots.sh ├── 014-remount-check.sh ├── 101-simple-file-io.sh ├── 102-fd-chroot.sh ├── 103-kilofile.sh ├── 104-wal-file.sh ├── 105-sas-file.sh ├── 106-sas-multiple.sh ├── 107-sas-ipc.sh ├── 108-sas-fork.sh ├── 109-sas-ipc-checkpoint.sh ├── 110-sas-fork-checkpoint.sh ├── 111-sastrack.sh ├── 201-simple-mem-ckpt.sh ├── 202-simple-osd-ckpt.sh ├── 203-busy-loop.sh ├── 204-print-stdout.sh ├── 205-array-traversal.sh ├── 206-mmap-file.sh ├── 207-mmap-anonymous.sh ├── 208-signal-handler.sh ├── 209-pthreads-mutex.sh ├── 210-file-vnode.sh ├── 211-fork-simple.sh ├── 212-file-fifo.sh ├── 213-fork-shm.sh ├── 214-file-pipes.sh ├── 215-file-posixshm.sh ├── 216-sysv-shm.sh ├── 217-file-udplisten.sh ├── 218-file-tcplisten.sh ├── 219-kqueue.sh ├── 220-pgroups.sh ├── 221-lazy-osd-ckpt.sh ├── 222-self-ckpt-mem.sh ├── 223-restore-mem-multiple.sh ├── 224-restore-osd-multiple.sh ├── 225-memsnap-osd-poll.sh ├── 226-memsnap-osd-block.sh ├── 227-memsnap-mem.sh ├── 228-wal.sh ├── 229-chroot.sh ├── 230-chroot-devfs.sh ├── 231-memsnap-osd-nowait.sh ├── 232-metropolis.sh ├── 233-metropolis-fork.sh ├── 234-metropolis-exec.sh ├── 235-metropolis-accept.sh ├── 236-metropolis-exit.sh ├── 237-metropolis-accept4.sh ├── 238-metropolis-simple.sh ├── 239-metropolis-pymetro-multiple.sh ├── 240-metropolis-partitions.sh ├── 241-metropolis-partitions-cached.sh ├── 242-cached-restore.sh ├── 243-prefault-restore.sh ├── 244-precopy-restore.sh ├── 245-amplified-checkpoint.sh ├── 246-remount-sls.sh ├── 247-remount-slos.sh ├── 248-delta-restore.sh ├── 249-pgresident.sh ├── 250-simple-file-ckpt.sh ├── 251-simple-socket-ckpt.sh ├── 252-simple-socket-restore.sh ├── 254-delta-checkpoint.sh ├── 255-delta-socket.sh ├── 256-memsnap-unaligned.sh ├── 257-memsnap-sync.sh ├── 258-shadow-default.sh ├── 259-shadow-objprotect.sh ├── 260-shadow-tracebuf.sh ├── 261-memshadow-default.sh ├── 262-memshadow-objprotect.sh ├── 263-memshadow-tracebuf.sh ├── Makefile ├── README.md ├── array │ ├── .gitignore │ ├── Makefile │ └── array.c ├── aurora ├── compute │ ├── Makefile │ └── compute.c ├── delta │ ├── Makefile │ └── delta.c ├── fd │ ├── Makefile │ └── fd.c ├── fifo │ ├── Makefile │ └── fifo.c ├── fork │ ├── Makefile │ └── fork.c ├── forkshm │ ├── Makefile │ └── forkshm.c ├── forkwait │ ├── Makefile │ └── forkwait.c ├── journal │ ├── Makefile │ └── journal.c ├── kqueue │ ├── Makefile │ └── kqueue.c ├── llist │ ├── Makefile │ └── llist.c ├── main │ ├── Makefile │ └── main.c ├── memshadow │ ├── Makefile │ └── memshadow.c ├── memsnap │ ├── Makefile │ └── memsnap.c ├── metroclient │ ├── Makefile │ └── metroclient.c ├── metrodelta │ ├── Makefile │ └── metrodelta.c ├── metroparts │ ├── Makefile │ └── metroparts.c ├── metropolis │ ├── Makefile │ └── metropolis.c ├── metroserver │ ├── Makefile │ └── metroserver.c ├── metrosimple │ ├── Makefile │ └── metrosimple.c ├── mmap │ ├── Makefile │ └── mmap.c ├── multithread │ ├── Makefile │ └── multithread.c ├── pgroup │ ├── Makefile │ └── pgroup.c ├── pipe │ ├── Makefile │ └── pipe.c ├── posixshm │ ├── Makefile │ └── posixshm.c ├── print │ ├── Makefile │ └── print.c ├── register │ ├── Makefile │ └── register.c ├── sas │ ├── Makefile │ └── sas.c ├── sasfork │ ├── Makefile │ └── sasfork.c ├── sasipc │ ├── Makefile │ └── sasipc.c ├── sastrack │ ├── Makefile │ └── sastrack.c ├── selfie │ ├── Makefile │ └── selfie.c ├── shadow │ ├── Makefile │ └── shadow.c ├── sharemap │ ├── Makefile │ └── sharemap.c ├── signal │ ├── Makefile │ └── signal.c ├── sleep │ ├── Makefile │ └── sleep.c ├── slsfs │ ├── Makefile │ └── file.c ├── socketpair │ ├── Makefile │ └── socketpair.c ├── sysvshm │ ├── Makefile │ └── sysvshm.c ├── tcplisten │ ├── Makefile │ └── tcplisten.c ├── testbench ├── testbench.blacklist ├── udplisten │ ├── Makefile │ └── udplisten.c ├── unixlisten │ ├── Makefile │ └── unixlisten.c ├── unlink │ ├── Makefile │ └── unlink.c ├── wal │ ├── Makefile │ └── wal.c └── walfd │ ├── Makefile │ └── walfd.c └── tools ├── Makefile ├── newfs_sls ├── Makefile └── newfs_sls.c ├── radixdbg ├── Makefile ├── radixdbg.c ├── radixdbg.h ├── radixnode.c └── radixnode.h ├── server ├── Makefile └── server.c ├── slsctl ├── Makefile ├── attach.c ├── checkpoint.c ├── listsnaps.c ├── partadd.c ├── partadd.h ├── partadd_file.c ├── partadd_memory.c ├── partadd_recv.c ├── partadd_send.c ├── partadd_slos.c ├── partdel.c ├── pgresident.c ├── restore.c ├── slsctl.c ├── slsctl.h └── spawn.c └── slsdb ├── Makefile ├── btree.cc ├── btree.h ├── directory.cc ├── directory.h ├── file.cc ├── file.h ├── slsdb.cc ├── snapshot.cc ├── snapshot.h ├── util.cc └── util.h /.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "phabricator.uri" : "https://review.rcs.uwaterloo.ca", 3 | "load" : [ ".arctools/clang-format-linter" ] 4 | } 5 | -------------------------------------------------------------------------------- /.arclint: -------------------------------------------------------------------------------- 1 | { 2 | "linters": { 3 | "clang-format": { 4 | "type": "clang-format", 5 | "include": "(\\.(c|cc|cpp|h)$)", 6 | "bin": [ 7 | "/usr/local/bin/clang-format", 8 | "/usr/local/bin/clang-format16", 9 | "/usr/local/bin/clang-format14", 10 | "/usr/local/bin/clang-format11", 11 | "/usr/local/bin/clang-format10" 12 | ] 13 | }, 14 | "python": { 15 | "type": "pep8", 16 | "include": "(\\.py$)" 17 | }, 18 | "spelling": { 19 | "type": "spelling" 20 | }, 21 | "chmod": { 22 | "type": "chmod" 23 | }, 24 | "merge-conflict": { 25 | "type": "merge-conflict", 26 | "exclude": "(\\.md$)" 27 | }, 28 | "filename": { 29 | "type": "filename" 30 | }, 31 | "json": { 32 | "type": "json", 33 | "include": "(\\.arclint|\\.json$)" 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /.arctools/clang-format-linter/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Valerii Hiora 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of clang-format-linter nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /.arctools/clang-format-linter/__phutil_library_init__.php: -------------------------------------------------------------------------------- 1 | 2, 11 | 'class' => array( 12 | 'ClangFormatLinter' => 'lint/linter/ClangFormatLinter.php', 13 | ), 14 | 'function' => array(), 15 | 'xmap' => array( 16 | 'ClangFormatLinter' => 'ArcanistExternalLinter', 17 | ), 18 | )); 19 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Ali Mashtizadeh 2 | Emil Tsalapatis 3 | Hongbo Zhang 4 | Ryan Hancock 5 | Tavian Barnes 6 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-2021 The Aurora authors. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 1. Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | 2. Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 13 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 14 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 15 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 16 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 17 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 18 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 19 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 20 | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 21 | OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 22 | SUCH DAMAGE. 23 | 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR=include libsls metropolis sls slos benchmarks tests tools 2 | 3 | IDENT=${:!sysctl -n kern.ident!} 4 | .if (${IDENT} == "FASTDBG") 5 | .MAKEOVERRIDES=FASTDBG 6 | .elif (${IDENT} == "SLOWDBG") 7 | .MAKEOVERRIDES=SLOWDBG 8 | .elif (${IDENT} == "PERF") 9 | .MAKEOVERRIDES=PERF 10 | .elif (${IDENT} == "GENERIC") 11 | .MAKEOVERRIDES=GENERIC 12 | .else 13 | .warning Unknown kernel ident 14 | .endif 15 | 16 | .include 17 | -------------------------------------------------------------------------------- /benchmarks/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR = posix vmobject vmregion 2 | 3 | BINDIR=/usr/aurora/tests 4 | .MAKE.EXPORTED=BINDIR 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /benchmarks/aurora.conf: -------------------------------------------------------------------------------- 1 | disks=[vtbd1] 2 | slosmodule=slos/slos.ko 3 | slsmodule=sls/sls.ko 4 | stripename=st0 5 | stripe=65536 6 | newfs=./tools/newfs_sls/newfs_sls 7 | slsctl=./tools/slsctl/slsctl 8 | mountdir=/testmnt 9 | slsperiod=100 10 | type=slos 11 | oid=1000 12 | checkpointtime=1000 13 | benchaddr=129.97.75.126 14 | benchport=6379 15 | sshuser=etsal 16 | sshaddr=tortilla 17 | sshport=77 18 | sshkey=/root/.ssh/tortilla 19 | clients=[tortilla] 20 | -------------------------------------------------------------------------------- /benchmarks/fb-post.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | touch tmp 3 | grep -E "ms]" $1 | awk '{ printf "%s, %s, %s, %s, %s\n", $1, $2, $3, $4, $5 }' >> tmp 4 | mv tmp $1 5 | -------------------------------------------------------------------------------- /benchmarks/ffs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | mkdir -p results/fs/ffs/micro 3 | mkdir -p results/fs/ffs/macro 4 | mkdir -p results/fs/ffs/supermicro 5 | chmod a+rw -R results/fs/ffs 6 | 7 | ./run.py allbenchmarks scripts/micro -c skylake.conf -o results/fs/ffs/micro --runs 3 --withgstat --type ffs 8 | ./run.py allbenchmarks scripts/macro -c skylake.conf -o results/fs/ffs/macro --runs 3 --withgstat --type ffs 9 | ./run.py allbenchmarks scripts/supermicro -c skylake.conf -o results/fs/ffs/supermicro --runs 3 --withgstat --type ffs 10 | -------------------------------------------------------------------------------- /benchmarks/posix/Makefile: -------------------------------------------------------------------------------- 1 | NAME=posix 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | CFLAGS += -O0 -pthread -I ../../include 6 | LDADD += -lsls 7 | LDFLAGS += -L ../../libsls 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /benchmarks/posix/posix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SLSDIR="/root/sls" 4 | BIN="/$SLSDIR/tests/posix/posix" 5 | 6 | source "$SLSDIR/scripts/bench.sh" 7 | 8 | aurstripe 9 | aurload 10 | 11 | dtrace "$SLSDIR/scripts/posix.d" > "$SLSDIR/posix.csv" & 12 | "$BIN" "$MOUNTDIR" 13 | pkill -SIGTERM dtrace 14 | sleep 2 15 | 16 | aurunload 17 | -------------------------------------------------------------------------------- /benchmarks/requirements: -------------------------------------------------------------------------------- 1 | ConfigArgParse==1.2.3 2 | -------------------------------------------------------------------------------- /benchmarks/rocksdb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . ../tests/aurora 3 | 4 | AURORACTL=$SRCROOT/tools/slsctl/slsctl 5 | BACKEND="slos" 6 | PERIOD="10" 7 | OID="1000" 8 | 9 | 10 | db_bench() { 11 | db_bench \ 12 | --benchmarks=fillbatch,mixgraph \ 13 | --use_direct_io_for_flush_and_compaction=true \ 14 | --use_direct_reads=true \ 15 | --cache_size=$((256 << 20)) \ 16 | --key_dist_a=0.002312 \ 17 | --key_dist_b=0.3467 \ 18 | --keyrange_dist_a=14.18 \ 19 | --keyrange_dist_b=0.3467 \ 20 | --keyrange_dist_c=0.0164 \ 21 | --keyrange_dist_d=-0.08082 \ 22 | --keyrange_num=30 \ 23 | --value_k=0.2615 \ 24 | --value_sigma=25.45 \ 25 | --iter_k=2.517 \ 26 | --iter_sigma=14.236 \ 27 | --mix_get_ratio=0.83 \ 28 | --mix_put_ratio=0.14 \ 29 | --mix_seek_ratio=0.03 \ 30 | --sine_mix_rate_interval_milliseconds=5000 \ 31 | --sine_a=1000 \ 32 | --sine_b=0.000073 \ 33 | --sine_d=4500 \ 34 | --perf_level=2 \ 35 | --num=$ROCKSDB_NUM \ 36 | --key_size=48 \ 37 | --db=/testmnt/tmp-db \ 38 | --wal_dir=/testmnt/wal \ 39 | --duration=$ROCKSDB_DUR \ 40 | --histogram=1 \ 41 | --write_buffer_size=$((16 << 30)) \ 42 | --disable_auto_compactions \ 43 | --threads=24 \ 44 | "${@:2}" 45 | cd - 46 | return $? 47 | } 48 | 49 | stress_aurora() 50 | { 51 | 52 | aursetup 53 | $AURORACTL partadd $BACKEND -o $OID -d -t $PERIOD 54 | 55 | db_bench baseline --sync=false --disable_wal=true & 56 | FUNC_PID="$!" 57 | sleep 1 58 | 59 | pid=`pidof db_bench` 60 | $AURORACTL attach -o $OID -p $pid 2>> $LOG >> $LOG 61 | $AURORACTL checkpoint -o $OID -r >> $LOG 2>> $LOG 62 | 63 | wait $FUNC_PID 64 | if [ $? -eq 124 ];then 65 | echo "[Aurora] Issue with db_bench, restart required" 66 | exit 1 67 | fi 68 | sleep 2 69 | 70 | aurteardown 71 | } 72 | 73 | for i in `seq 1 5` ; do 74 | stress_aurora 75 | done 76 | 77 | 78 | echo "[DONE] Done...\n" 79 | 80 | -------------------------------------------------------------------------------- /benchmarks/runall.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | 3 | CONF="benchmarks/skylake4.conf" 4 | 5 | ./benchmarks/run.py webbench --conf "$CONF" --server nginx 6 | ./benchmarks/run.py webbench --conf "$CONF" --server lighttpd 7 | ./benchmarks/run.py webbench --conf "$CONF" --server tomcat 8 | ./benchmarks/run.py kvbench --conf "$CONF" --kvstore redis 9 | ./benchmarks/run.py mutilatebench --conf "$CONF" 10 | ./benchmarks/run.py ffbench --conf "$CONF" 11 | -------------------------------------------------------------------------------- /benchmarks/runffs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z $1 ] 4 | then 5 | echo "Give directory to place runs in as argument" 6 | exit 7 | fi 8 | 9 | if [ -z $2 ] 10 | then 11 | echo "Require number of runs" 12 | exit 13 | fi 14 | 15 | 16 | #gstripe destroy st0 17 | gstripe create -s 65536 -v st0 nvd0 nvd1 #nvd2 nvd3 18 | 19 | DRIVE=/dev/stripe/st0 20 | 21 | MNT=/testmnt 22 | 23 | for run in $(seq 1 $2) 24 | do 25 | DIR=$1/$run 26 | mkdir $DIR 27 | 28 | echo "" 29 | echo "Run $run of $2 started..." 30 | echo "" 31 | 32 | newfs -j -S 4096 -b 65536 $DRIVE 33 | mount $DRIVE $MNT 34 | cd scripts 35 | for entry in `ls *.f` 36 | do 37 | echo $entry 38 | filebench -f $entry > $DIR/$entry.out 39 | done 40 | cd .. 41 | umount $MNT 42 | done; 43 | gstripe destroy st0 44 | 45 | 46 | -------------------------------------------------------------------------------- /benchmarks/runsls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z $1 ] 4 | then 5 | echo "Give directory to place runs in as argument" 6 | exit 7 | fi 8 | 9 | DRIVE=/dev/stripe/st0 10 | MNT=/testmnt 11 | 12 | #gstripe create -s 65536 -v st0 nvd0 nvd1 #nvd2 nvd3 13 | 14 | echo "" 15 | echo "Run started..." 16 | echo "" 17 | 18 | cd scripts 19 | for entry in `ls *.f` 20 | do 21 | #../../tools/newosd/newosd $DRIVE 22 | #kldload ../../slos/slos.ko 23 | #mount -rw -t slsfs $DRIVE /testmnt 24 | 25 | #echo $entry 26 | filebench -f $entry > $1/$entry.out 27 | 28 | #umount $MNT 29 | #kldunload slos.ko 30 | done 31 | cd .. 32 | 33 | 34 | -------------------------------------------------------------------------------- /benchmarks/runzfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z $1 ] 4 | then 5 | echo "Give directory to place runs in as argument" 6 | exit 7 | fi 8 | 9 | MNT=/testmnt 10 | 11 | for run in $(seq 1 $2) 12 | do 13 | echo "" 14 | echo "Run $run of $2 started..." 15 | echo "" 16 | 17 | zpool create benchmark /dev/nvd0 /dev/nvd1 18 | zfs create benchmark/testmnt 19 | 20 | zfs set mountpoint=/testmnt benchmark/testmnt 21 | zfs set compression=lz4 benchmark 22 | zfs set recordsize=64k benchmark 23 | # Uncomment line below to disable the ZIL 24 | zfs set sync=disabled benchmark 25 | #zfs set sync=default benchmark 26 | 27 | DIR=$1/$run 28 | mkdir $DIR 29 | 30 | cd scripts 31 | for entry in `ls *.f` 32 | do 33 | echo $entry 34 | filebench -f $entry > $DIR/$entry.out 35 | done 36 | cd .. 37 | 38 | zfs destroy -r benchmark/testmnt 39 | zpool destroy benchmark 40 | done; 41 | 42 | -------------------------------------------------------------------------------- /benchmarks/scripts/macro/fileserver.f: -------------------------------------------------------------------------------- 1 | # 2 | # CDDL HEADER START 3 | # 4 | # The contents of this file are subject to the terms of the 5 | # Common Development and Distribution License (the "License"). 6 | # You may not use this file except in compliance with the License. 7 | # 8 | # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 | # or http://www.opensolaris.org/os/licensing. 10 | # See the License for the specific language governing permissions 11 | # and limitations under the License. 12 | # 13 | # When distributing Covered Code, include this CDDL HEADER in each 14 | # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 | # If applicable, add the following below this CDDL HEADER, with the 16 | # fields enclosed by brackets "[]" replaced with your own identifying 17 | # information: Portions Copyright [yyyy] [name of copyright owner] 18 | # 19 | # CDDL HEADER END 20 | # 21 | # 22 | # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 | # Use is subject to license terms. 24 | # 25 | 26 | set $dir=/testmnt 27 | set $nfiles=10000 28 | set $meandirwidth=20 29 | set $filesize=cvar(type=cvar-gamma,parameters=mean:131072;gamma:1.5) 30 | set $nthreads=1 31 | set $iosize=1m 32 | set $meanappendsize=16k 33 | 34 | define fileset name=bigfileset,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$meandirwidth,prealloc=80 35 | 36 | define process name=filereader,instances=1 37 | { 38 | thread name=filereaderthread,memsize=10m,instances=$nthreads 39 | { 40 | flowop createfile name=createfile1,filesetname=bigfileset,fd=1 41 | flowop writewholefile name=wrtfile1,srcfd=1,fd=1,iosize=$iosize 42 | flowop closefile name=closefile1,fd=1 43 | flowop openfile name=openfile1,filesetname=bigfileset,fd=1 44 | flowop appendfilerand name=appendfilerand1,iosize=$meanappendsize,fd=1 45 | flowop closefile name=closefile2,fd=1 46 | flowop openfile name=openfile2,filesetname=bigfileset,fd=1 47 | flowop readwholefile name=readfile1,fd=1,iosize=$iosize 48 | flowop closefile name=closefile3,fd=1 49 | flowop deletefile name=deletefile1,filesetname=bigfileset 50 | flowop statfile name=statfile1,filesetname=bigfileset 51 | } 52 | } 53 | 54 | run 30 55 | echo "File-server Version 3.0 personality successfully loaded" 56 | 57 | -------------------------------------------------------------------------------- /benchmarks/scripts/macro/mongo.f: -------------------------------------------------------------------------------- 1 | # 2 | # CDDL HEADER START 3 | # 4 | # The contents of this file are subject to the terms of the 5 | # Common Development and Distribution License (the "License"). 6 | # You may not use this file except in compliance with the License. 7 | # 8 | # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 | # or http://www.opensolaris.org/os/licensing. 10 | # See the License for the specific language governing permissions 11 | # and limitations under the License. 12 | # 13 | # When distributing Covered Code, include this CDDL HEADER in each 14 | # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 | # If applicable, add the following below this CDDL HEADER, with the 16 | # fields enclosed by brackets "[]" replaced with your own identifying 17 | # information: Portions Copyright [yyyy] [name of copyright owner] 18 | # 19 | # CDDL HEADER END 20 | # 21 | # 22 | # Copyright 2008 Sun Microsystems, Inc. All rights reserved. 23 | # Use is subject to license terms. 24 | # 25 | # ident "%Z%%M% %I% %E% SMI" 26 | 27 | set $dir=/testmnt 28 | set $nfiles=1000 29 | set $dirwidth=20 30 | set $filesize=16k 31 | set $nthreads=1 32 | set $meaniosize=16k 33 | set $readiosize=1m 34 | 35 | set mode quit firstdone 36 | 37 | define fileset name=postset,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$dirwidth,prealloc,paralloc 38 | define fileset name=postsetdel,path=$dir,size=$filesize,entries=$nfiles,dirwidth=$dirwidth,prealloc,paralloc 39 | 40 | define process name=filereader,instances=1 41 | { 42 | thread name=filereaderthread,memsize=10m,instances=$nthreads 43 | { 44 | flowop openfile name=openfile1,filesetname=postset,fd=1 45 | flowop appendfilerand name=appendfilerand1,iosize=$meaniosize,fd=1 46 | flowop closefile name=closefile1,fd=1 47 | flowop openfile name=openfile2,filesetname=postset,fd=1 48 | flowop readwholefile name=readfile1,fd=1,iosize=$readiosize 49 | flowop closefile name=closefile2,fd=1 50 | flowop deletefile name=deletefile1,filesetname=postsetdel 51 | } 52 | } 53 | 54 | run 30 55 | 56 | echo "Mongo-like Version 2.3 personality successfully loaded" 57 | -------------------------------------------------------------------------------- /benchmarks/scripts/micro/createfiles-16t-64k.f: -------------------------------------------------------------------------------- 1 | # 2 | # CDDL HEADER START 3 | # 4 | # The contents of this file are subject to the terms of the 5 | # Common Development and Distribution License (the "License"). 6 | # You may not use this file except in compliance with the License. 7 | # 8 | # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 | # or http://www.opensolaris.org/os/licensing. 10 | # See the License for the specific language governing permissions 11 | # and limitations under the License. 12 | # 13 | # When distributing Covered Code, include this CDDL HEADER in each 14 | # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 | # If applicable, add the following below this CDDL HEADER, with the 16 | # fields enclosed by brackets "[]" replaced with your own identifying 17 | # information: Portions Copyright [yyyy] [name of copyright owner] 18 | # 19 | # CDDL HEADER END 20 | # 21 | # 22 | # Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 | # Use is subject to license terms. 24 | # 25 | 26 | set $dir=/testmnt 27 | set $nfiles=50000 28 | set $meandirwidth=100 29 | set $meanfilesize=16k 30 | set $iosize=64k 31 | set $nthreads=16 32 | 33 | set mode quit firstdone 34 | 35 | define fileset name=bigfileset,path=$dir,size=$meanfilesize,entries=$nfiles,dirwidth=$meandirwidth 36 | 37 | define process name=filecreate,instances=1 38 | { 39 | 40 | thread name=filecreatethread,memsize=10m,instances=$nthreads 41 | { 42 | flowop createfile name=createfile1,filesetname=bigfileset,fd=1 43 | flowop writewholefile name=writefile1,fd=1,iosize=$iosize 44 | flowop closefile name=closefile1,fd=1 45 | } 46 | 47 | } 48 | 49 | run 10 50 | 51 | echo "Createfiles Version 3.0 personality successfully loaded" 52 | -------------------------------------------------------------------------------- /benchmarks/scripts/micro/randomw-4t-4k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=4k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $runtime=30 8 | 9 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 10 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | 14 | define process name=rand-rw,instances=1 15 | { 16 | thread name=thwr1,memsize=5m,instances=$nthreads 17 | { 18 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset 19 | } 20 | thread name=thwr2,memsize=5m,instances=$nthreads 21 | { 22 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset 23 | } 24 | thread name=thwr3,memsize=5m,instances=$nthreads 25 | { 26 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset 27 | } 28 | thread name=thwr4,memsize=5m,instances=$nthreads 29 | { 30 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset 31 | } 32 | } 33 | 34 | run $runtime 35 | echo "Random RW Version 3.0 personality successfully loaded" 36 | -------------------------------------------------------------------------------- /benchmarks/scripts/micro/randomw-4t-64k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=64k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $runtime=30 8 | 9 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 10 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | 14 | define process name=rand-rw,instances=1 15 | { 16 | thread name=thwr1,memsize=5m,instances=$nthreads 17 | { 18 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset,directio=$directio 19 | } 20 | thread name=thwr2,memsize=5m,instances=$nthreads 21 | { 22 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset,directio=$directio 23 | } 24 | thread name=thwr3,memsize=5m,instances=$nthreads 25 | { 26 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset,directio=$directio 27 | } 28 | thread name=thwr4,memsize=5m,instances=$nthreads 29 | { 30 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset,directio=$directio 31 | } 32 | } 33 | 34 | run $runtime 35 | echo "Random RW Version 3.0 personality successfully loaded" 36 | -------------------------------------------------------------------------------- /benchmarks/scripts/micro/writedsync-4t-4k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=4k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $iter=100 8 | set $runtime=30 9 | 10 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 14 | 15 | define process name=rand-rw,instances=1 16 | { 17 | thread name=thwr1,memsize=5m,instances=$nthreads 18 | { 19 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 20 | flowop fsync name=sync-file1 21 | } 22 | thread name=thwr2,memsize=5m,instances=$nthreads 23 | { 24 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 25 | flowop fsync name=sync-file2 26 | } 27 | thread name=thwr3,memsize=5m,instances=$nthreads 28 | { 29 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 30 | flowop fsync name=sync-file3 31 | } 32 | thread name=thwr4,memsize=5m,instances=$nthreads 33 | { 34 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 35 | flowop fsync name=sync-file4 36 | } 37 | } 38 | 39 | run 30 40 | echo "Random RW Version 3.0 personality successfully loaded" 41 | -------------------------------------------------------------------------------- /benchmarks/scripts/micro/writedsync-4t-64k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=64k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $iter=100 8 | set $runtime=30 9 | 10 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 14 | 15 | define process name=rand-rw,instances=1 16 | { 17 | thread name=thwr1,memsize=5m,instances=$nthreads 18 | { 19 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 20 | flowop fsync name=sync-file1 21 | } 22 | thread name=thwr2,memsize=5m,instances=$nthreads 23 | { 24 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 25 | flowop fsync name=sync-file2 26 | } 27 | thread name=thwr3,memsize=5m,instances=$nthreads 28 | { 29 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 30 | flowop fsync name=sync-file3 31 | } 32 | thread name=thwr4,memsize=5m,instances=$nthreads 33 | { 34 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset,directio=$directio,iters=$iter 35 | flowop fsync name=sync-file4 36 | } 37 | } 38 | 39 | run 30 40 | echo "Random RW Version 3.0 personality successfully loaded" 41 | -------------------------------------------------------------------------------- /benchmarks/scripts/supermicro/randomw-4t-4k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=4k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $runtime=30 8 | 9 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 10 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | 14 | define process name=rand-rw,instances=1 15 | { 16 | thread name=thwr1,memsize=5m,instances=$nthreads 17 | { 18 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset 19 | } 20 | thread name=thwr2,memsize=5m,instances=$nthreads 21 | { 22 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset 23 | } 24 | thread name=thwr3,memsize=5m,instances=$nthreads 25 | { 26 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset 27 | } 28 | thread name=thwr4,memsize=5m,instances=$nthreads 29 | { 30 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset 31 | } 32 | } 33 | 34 | run $runtime 35 | echo "Random RW Version 3.0 personality successfully loaded" 36 | -------------------------------------------------------------------------------- /benchmarks/scripts/supermicro/randomw-4t-64k.f: -------------------------------------------------------------------------------- 1 | set $dir=/testmnt 2 | set $filesize=2g 3 | set $iosize=64k 4 | set $nthreads=1 5 | set $workingset=0 6 | set $directio=0 7 | set $runtime=30 8 | 9 | define file name=largefile1,path=$dir,size=$filesize,prealloc,reuse,paralloc 10 | define file name=largefile2,path=$dir,size=$filesize,prealloc,reuse,paralloc 11 | define file name=largefile3,path=$dir,size=$filesize,prealloc,reuse,paralloc 12 | define file name=largefile4,path=$dir,size=$filesize,prealloc,reuse,paralloc 13 | 14 | define process name=rand-rw,instances=1 15 | { 16 | thread name=thwr1,memsize=5m,instances=$nthreads 17 | { 18 | flowop write name=rw1,filename=largefile1,iosize=$iosize,random,workingset=$workingset,directio=$directio 19 | } 20 | thread name=thwr2,memsize=5m,instances=$nthreads 21 | { 22 | flowop write name=rw2,filename=largefile2,iosize=$iosize,random,workingset=$workingset,directio=$directio 23 | } 24 | thread name=thwr3,memsize=5m,instances=$nthreads 25 | { 26 | flowop write name=rw3,filename=largefile3,iosize=$iosize,random,workingset=$workingset,directio=$directio 27 | } 28 | thread name=thwr4,memsize=5m,instances=$nthreads 29 | { 30 | flowop write name=rw4,filename=largefile4,iosize=$iosize,random,workingset=$workingset,directio=$directio 31 | } 32 | } 33 | 34 | run $runtime 35 | echo "Random RW Version 3.0 personality successfully loaded" 36 | -------------------------------------------------------------------------------- /benchmarks/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "Installing Packages for Lighttpd benchmark [lighttpd, wrk]" 4 | pkg install -y lighttpd 5 | pkg install -y wrk 6 | pkg install -y pidof 7 | 8 | echo "Installing python [Python3.7]" 9 | pkg install -y python37-3.7.8 10 | python3.7 -m venv ~/venv 11 | . ~/venv/bin/activate 12 | 13 | echo "Installing Packages for pip in virtualenv" 14 | python -m pip install --upgrade pip 15 | python -m pip install -r requirements 16 | 17 | 18 | -------------------------------------------------------------------------------- /benchmarks/skylake4.conf: -------------------------------------------------------------------------------- 1 | disks=[nvd0, nvd1, nvd2, nvd3] 2 | slosmodule=slos/slos.ko 3 | slsmodule=sls/sls.ko 4 | stripename=st0 5 | stripe=65536 6 | newfs=./tools/newfs_sls/newfs_sls 7 | slsctl=./tools/slsctl/slsctl 8 | mountdir=/testmnt 9 | slsperiod=100 10 | type=slos 11 | oid=1000 12 | checkpointtime=100 13 | benchaddr=skylake4 14 | benchport=6379 15 | sshuser=etsal 16 | sshaddr=skylake5 17 | sshport=77 18 | sshkey=/root/.ssh/wrk 19 | clients=[skylake2,skylake3,skylake6,skylake7,skylake8] 20 | -------------------------------------------------------------------------------- /benchmarks/sls.conf: -------------------------------------------------------------------------------- 1 | disks=[nvd0, nvd1, nvd2, nvd3] 2 | slosmodule=slos/slos.ko 3 | slsmodule=sls/sls.ko 4 | stripename=st0 5 | stripe=65536 6 | newfs=./tools/newfs_sls/newfs_sls 7 | slsctl=./tools/slsctl/slsctl 8 | mountdir=/testmnt 9 | slsperiod=100 10 | type=slos 11 | oid=1000 12 | checkpointtime=100 13 | benchaddr=skylake4 14 | benchport=6379 15 | sshuser=etsal 16 | sshaddr=skylake3 17 | sshport=77 18 | sshkey=/root/.ssh/wrk 19 | clients=[skylake2,skylake3,skylake6,skylake7,skylake8] 20 | -------------------------------------------------------------------------------- /benchmarks/slsbenchmarks.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | 3 | mkdir -p results/fs/sls/micro 4 | mkdir results/fs/sls/macro 5 | mkdir results/fs/sls/supermicro 6 | chmod -R a+rw results 7 | 8 | ./run.py allseries scripts/supermicro 1 200 20 -c skylake.conf -o results/fs/sls/supermicro --type sls --runs 3 --withgstat 9 | ./run.py allbenchmarks scripts/micro -c skylake.conf -o results/fs/sls/micro --type sls --runs 4 --withgstat 10 | ./run.py allbenchmarks scripts/macro -c skylake.conf -o results/fs/sls/macro --type sls --runs 3 --withgstat 11 | -------------------------------------------------------------------------------- /benchmarks/vmobject/Makefile: -------------------------------------------------------------------------------- 1 | NAME=vmobject 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | CFLAGS += -O0 -pthread -I ../../include 6 | LDADD += -lsls 7 | LDFLAGS += -L ../../libsls 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /benchmarks/vmobject/vmobject.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SLSDIR="/root/sls" 4 | BIN="/$SLSDIR/tests/vmobject/vmobject" 5 | 6 | source "$SLSDIR/scripts/bench.sh" 7 | 8 | vmobject () { 9 | aurstripe 10 | aurload 11 | OBJCNT=$1 12 | SIZEKB=$(( $2 / 1024)) 13 | SIZEMB=$(( $SIZEKB / 1024)) 14 | RUNNO=$3 15 | "$BIN" "$OBJCNT" "$SIZE" > "vmobject-$OBJCNT-$SIZE-$RUNNO" 16 | aurunload 17 | 18 | } 19 | 20 | # Get numbers from 4KB to 1GB, rising exponentially. Use only one object. 21 | for SIZEPWR in $(seq 12 30); 22 | do 23 | for RUNNO in $(seq 1 2); 24 | do 25 | OBJCNT=1 26 | SIZE=$(dc -e "2 $SIZEPWR ^ p") 27 | vmobject "$OBJCNT" "$SIZE" "$RUNNO" 28 | done 29 | done 30 | 31 | # Get numbers from 1GB to 8GB, rising 1GB at a time. Use only one object. 32 | for SIZEGB in $(seq 1 8); 33 | do 34 | for RUNNO in $(seq 1 2); 35 | do 36 | OBJCNT=1 37 | SIZE=$(( 1024 * 1024 * 1024 * SIZEGB )) 38 | vmobject $OBJCNT "$SIZE" "$RUNNO" 39 | done 40 | done 41 | 42 | 43 | # Get numbers from 8GB to 80GB, rising 8GB at a time. Use only one object. 44 | for SIZEGB in $(seq 8 8 88); 45 | do 46 | for RUNNO in $(seq 1 2); 47 | do 48 | OBJCNT=1 49 | SIZE=$(( 1024 * 1024 * 1024 * SIZEGB )) 50 | vmobject $OBJCNT "$SIZE" "$RUNNO" 51 | done 52 | done 53 | 54 | -------------------------------------------------------------------------------- /benchmarks/vmregion/Makefile: -------------------------------------------------------------------------------- 1 | NAME=vmregion 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | CFLAGS += -O0 -pthread -I ../../include 6 | LDADD += -lsls 7 | LDFLAGS += -L ../../libsls 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /benchmarks/zfs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/local/bin/bash 2 | mkdir -p results/fs/zfs/micro 3 | mkdir -p results/fs/zfs/macro 4 | mkdir -p results/fs/zfs/supermicro 5 | mkdir -p results/fs/zfs/checksum 6 | mkdir -p results/fs/zfs/checksum/micro 7 | mkdir -p results/fs/zfs/checksum/supermicro 8 | mkdir -p results/fs/zfs/checksum/macro 9 | chmod a+rw -R results/fs/zfs 10 | 11 | ./run.py allbenchmarks scripts/micro -c skylake.conf -o results/fs/zfs/checksum/micro --checksum --runs 3 --type zfs 12 | ./run.py allbenchmarks scripts/macro -c skylake.conf -o results/fs/zfs/checksum/macro --checksum --runs 3 --type zfs 13 | ./run.py allbenchmarks scripts/supermicro -c skylake.conf -o results/fs/zfs/checksum/supermicro --checksum --runs 3 --type zfs 14 | 15 | ./run.py allbenchmarks scripts/micro -c skylake.conf -o results/fs/zfs/micro --runs 3 --type zfs 16 | ./run.py allbenchmarks scripts/macro -c skylake.conf -o results/fs/zfs/macro --runs 3 --type zfs 17 | ./run.py allbenchmarks scripts/supermicro -c skylake.conf -o results/fs/zfs/supermicro --runs 3 --type zfs 18 | -------------------------------------------------------------------------------- /include/Makefile: -------------------------------------------------------------------------------- 1 | INCS=btree.h slos_bnode.h slos_btree.h slos_inode.h slos_io.h slos.h \ 2 | sls_data.h sls_debug_common.h sls_ioctl.h sls_message.h sls_wal.h sls.h slsfs.h 3 | 4 | .include 5 | -------------------------------------------------------------------------------- /include/slos_io.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLOS_IO_H_ 2 | #define _SLOS_IO_H_ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #ifndef _KERNEL 9 | #error "No serviceable parts inside" 10 | #endif /* _KERNEL */ 11 | 12 | struct buf; 13 | 14 | /* XXX We won't need this here when we use direct buffer IOs from the SLS. */ 15 | void slos_uioinit(struct uio *auio, uint64_t off, enum uio_rw rwflag, 16 | struct iovec *aiovs, size_t iovcnt); 17 | 18 | int slos_sbread(struct slos *slos); 19 | int slos_sbat(struct slos *slos, int index, struct slos_sb *sb); 20 | 21 | /* Direct SLOS IO. */ 22 | int slos_iotask_create(struct vnode *vp, struct buf *bp, bool async); 23 | boolean_t slos_hasblock( 24 | struct vnode *vp, uint64_t lblkno_req, int *rbehind, int *rahead); 25 | 26 | int slos_io_init(void); 27 | void slos_io_uninit(void); 28 | 29 | extern int slos_pbufcnt; 30 | 31 | extern uint64_t slos_io_initiated; 32 | extern uint64_t slos_io_done; 33 | 34 | #endif /* _SLOS_IO_H_ */ 35 | -------------------------------------------------------------------------------- /include/sls.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_H_ 2 | #define _SLS_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "sls_ioctl.h" 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* Low-level APIs */ 16 | int sls_memsnap(uint64_t oid, void *addr); 17 | int sls_memsnap_epoch(uint64_t oid, void *addr, uint64_t *epoch); 18 | int sls_checkpoint(uint64_t oid, bool recurse); 19 | int sls_checkpoint_epoch(uint64_t oid, bool recurse, uint64_t *epoch); 20 | int sls_epochwait(uint64_t oid, uint64_t epoch, bool sync, bool *isdone); 21 | int sls_restore(uint64_t oid, bool rest_stopped); 22 | 23 | int sls_attach(uint64_t oid, uint64_t pid); 24 | int sls_partadd(uint64_t oid, const struct sls_attr attr, int backendfd); 25 | int sls_partdel(uint64_t oid); 26 | 27 | struct sls_stat { 28 | int type; 29 | int streamid; 30 | uint64_t ckptid; 31 | }; 32 | 33 | int sls_epochdone(uint64_t oid, uint64_t epoch, bool *isdone); 34 | int sls_untilepoch(uint64_t oid, uint64_t epoch); 35 | int sls_metropolis(uint64_t oid); 36 | int sls_metropolis_spawn(uint64_t oid, int s); 37 | int sls_insls(uint64_t *oid, bool *insls); 38 | 39 | /* Storage Control APIs */ 40 | int slos_openvol(const char *dev); 41 | int slos_closevol(int backendid); 42 | int slos_stat(struct statfs *sfs); 43 | 44 | /* High-level APIs */ 45 | int sls_suspend(uint64_t oid); 46 | int sls_resume(uint64_t oid); 47 | int sls_getattr(uint64_t oid, struct sls_attr *attr); 48 | 49 | /* High-level APIs for Current Process */ 50 | int sls_ffork(int fd); 51 | int sls_stat(int streamid, struct sls_stat *st); 52 | int sls_barrier(int streamid); 53 | 54 | /* Get list of resident pages in the partition. */ 55 | int sls_pgresident(uint64_t oid, int fd); 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif /* _SLS_H_ */ 62 | -------------------------------------------------------------------------------- /include/sls_debug_common.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SLS_DEBUG_COMMON_H_ 3 | #define _SLS_DEBUG_COMMON_H_ 4 | 5 | #include 6 | #include 7 | 8 | #ifdef KTR 9 | #define DEBUG(fmt) \ 10 | do { \ 11 | CTR1(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 12 | __func__); \ 13 | } while (0) 14 | 15 | #define DEBUG1(fmt, ...) \ 16 | do { \ 17 | CTR2(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 18 | __func__, ##__VA_ARGS__); \ 19 | } while (0) 20 | 21 | #define DEBUG2(fmt, ...) \ 22 | do { \ 23 | CTR3(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 24 | __func__, ##__VA_ARGS__); \ 25 | } while (0) 26 | 27 | #define DEBUG3(fmt, ...) \ 28 | do { \ 29 | CTR4(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 30 | __func__, ##__VA_ARGS__); \ 31 | } while (0) 32 | 33 | #define DEBUG4(fmt, ...) \ 34 | do { \ 35 | CTR5(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 36 | __func__, ##__VA_ARGS__); \ 37 | } while (0) 38 | 39 | #define DEBUG5(fmt, ...) \ 40 | do { \ 41 | CTR6(KTR_THIS_MODULE, "%s:"__XSTRING(__LINE__) " " fmt, \ 42 | __func__, ##__VA_ARGS__); \ 43 | } while (0) 44 | 45 | #else 46 | 47 | #define DEBUG(fmt, ...) ((void)(0)); 48 | #define DEBUG1(fmt, ...) ((void)(0)); 49 | #define DEBUG2(fmt, ...) ((void)(0)); 50 | #define DEBUG3(fmt, ...) ((void)(0)); 51 | #define DEBUG4(fmt, ...) ((void)(0)); 52 | #define DEBUG5(fmt, ...) ((void)(0)); 53 | 54 | #endif // KTR 55 | 56 | #endif /* _SLS_DEBUG_COMMON_H_ */ 57 | -------------------------------------------------------------------------------- /include/sls_message.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_MESSAGE_H_ 2 | #define _SLS_MESSAGE_H_ 3 | 4 | enum slsmsgtype { 5 | SLSMSG_REGISTER, 6 | SLSMSG_CKPTSTART, 7 | SLSMSG_RECMETA, 8 | SLSMSG_RECPAGES, 9 | SLSMSG_CKPTDONE, 10 | SLSMSG_DONE, 11 | SLSMSG_TYPES, 12 | }; 13 | 14 | struct slsmsg_register { 15 | enum slsmsgtype slsmsg_type; 16 | uint64_t slsmsg_oid; 17 | }; 18 | 19 | struct slsmsg_ckptstart { 20 | enum slsmsgtype slsmsg_type; 21 | uint64_t slsmsg_epoch; 22 | }; 23 | 24 | struct slsmsg_recmeta { 25 | enum slsmsgtype slsmsg_type; 26 | uint64_t slsmsg_uuid; 27 | uint64_t slsmsg_metalen; 28 | uint64_t slsmsg_rectype; 29 | uint64_t slsmsg_totalsize; 30 | }; 31 | 32 | struct slsmsg_recpages { 33 | enum slsmsgtype slsmsg_type; 34 | uint64_t slsmsg_len; 35 | uint64_t slsmsg_offset; 36 | }; 37 | 38 | struct slsmsg_ckptdone { 39 | enum slsmsgtype slsmsg_type; 40 | }; 41 | 42 | struct slsmsg_done { 43 | enum slsmsgtype slsmsg_type; 44 | }; 45 | 46 | union slsmsg { 47 | struct slsmsg_register slsmsgregister; 48 | struct slsmsg_ckptstart slsmsgckpt; 49 | struct slsmsg_recmeta slsmsgrecmeta; 50 | struct slsmsg_recpages slsmsgrecpages; 51 | struct slsmsg_ckptdone slsmsgckptdone; 52 | struct slsmsg_done slsmsgrecdone; 53 | }; 54 | 55 | #endif /* _SLS_MESSAGE_H_ */ 56 | -------------------------------------------------------------------------------- /include/sls_wal.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_WAL_H_ 2 | #define _SLS_WAL_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* A write-ahead log for SLS memory transactions. */ 13 | struct sls_wal { 14 | uint64_t oid; 15 | char *mapping; 16 | size_t size; 17 | uint64_t epoch; 18 | pthread_mutex_t mutex; 19 | }; 20 | 21 | /* Open a write-ahead log backed by the given file. */ 22 | int sls_wal_open(struct sls_wal *wal, uint64_t oid, size_t size); 23 | 24 | /* Perform a transactional memcpy(). */ 25 | void sls_wal_memcpy( 26 | struct sls_wal *wal, void *dest, const void *src, size_t size); 27 | 28 | /* Make sure the write-ahead log is persisted. */ 29 | int sls_wal_sync(struct sls_wal *wal); 30 | 31 | /* Replay the operations from a write-ahead log. */ 32 | void sls_wal_replay(struct sls_wal *wal); 33 | 34 | /* Close a write-ahead log. */ 35 | int sls_wal_close(struct sls_wal *wal); 36 | 37 | /* Specify a point at which execution will resume after a crash. */ 38 | int sls_wal_savepoint(struct sls_wal *wal); 39 | 40 | int slsfs_sas_create(char *path, size_t size); 41 | int slsfs_sas_map(int fd, void **addrp); 42 | 43 | int sas_trace_start(int fd); 44 | int sas_trace_end(int fd); 45 | int sas_trace_abort(int fd); 46 | int sas_trace_commit(int fd); 47 | int sas_refresh_protection(int fd); 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif // _SLS_WAL_H_ 54 | -------------------------------------------------------------------------------- /libsls/Makefile: -------------------------------------------------------------------------------- 1 | 2 | LIB= sls 3 | SRCS = sls.c sls_private.c sls_wal.c 4 | MAN = 5 | CFLAGS = -I../include -fPIC 6 | LDADD= -lsbuf 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /libsls/sls.3: -------------------------------------------------------------------------------- 1 | .Dd May 17, 2019 2 | .Dt LIBSLS 3 3 | .Os Aurora Single-Level Store 4 | .Sh NAME 5 | .Nm libsls 6 | .Nd Aurora Single-Level Store Library 7 | .Sh LIBRARY 8 | .Lb libsls 9 | .Sh SYNOPSIS 10 | .In sls/sls.h 11 | .Sh DESCRIPTION 12 | .Sh FUNCTION OVERVIEW 13 | .Bl -tag -width "01234567890123456789" 14 | .It Sy "Function Description" 15 | .It Fn sls_attach 16 | Enable persistent mode by attaching to a process. 17 | .It Fn sls_detach 18 | Disable persistent mode by detaching from a process. 19 | .It Fn sls_suspend 20 | Suspend a process to the persistent store. 21 | .It Fn sls_resume 22 | Resume a process from the persistent store. 23 | .It Fn sls_getattr 24 | Get SLS process attributes. 25 | .It Fn sls_setattr 26 | Set SLS process attributes. 27 | .It Fn sls_getckptid 28 | Get current checkpoint generation number. This is a monotonically increasing 29 | number of the last persistent checkpoint. 30 | .It Fn sls_enter 31 | Enable persistent mode on the current process 32 | .It Fn sls_exit 33 | Disable persistent mode on the current process 34 | .It Fn sls_ffork 35 | Write a checkpoint to the file descriptor. On resume the process can 36 | distinguish itself. 37 | .It Fn sls_stat 38 | Read metadata of an SLS stream. 39 | .It Fn sls_barrier 40 | Wait for the current process state to be stored to disk or transmitted to a 41 | remote node. 42 | .El 43 | .Sh RETURN VALUES 44 | .Sh AUTHORS 45 | .Nm libsls 46 | was written by the Reliable Computer Systems group at the University of 47 | Waterloo. 48 | -------------------------------------------------------------------------------- /libsls/sls_private.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "sls_private.h" 13 | 14 | static int _slsfd = -1; 15 | static int _metrfd = -1; 16 | 17 | /* Generic ioctl for the SLS device. */ 18 | int 19 | sls_ioctl(long ionum, void *args) 20 | { 21 | int status; 22 | 23 | if (_slsfd < 0) { 24 | _slsfd = open("/dev/sls", O_RDWR); 25 | if (_slsfd < 0) { 26 | fprintf( 27 | stderr, "ERROR: Could not open SLS device: %m\n"); 28 | return (-1); 29 | } 30 | } 31 | 32 | status = ioctl(_slsfd, ionum, args); 33 | if (status < 0) { 34 | fprintf(stderr, "ERROR: SLS proc ioctl failed: %m\n"); 35 | return (-1); 36 | } 37 | 38 | return (status); 39 | } 40 | 41 | /* Generic ioctl for the SLS device. */ 42 | int 43 | metr_ioctl(long ionum, void *args) 44 | { 45 | int status; 46 | 47 | if (_metrfd < 0) { 48 | _metrfd = open("/dev/metropolis", O_RDWR); 49 | if (_metrfd < 0) { 50 | fprintf(stderr, 51 | "ERROR: Could not open SLS Metropolis: %m\n"); 52 | return (-1); 53 | } 54 | } 55 | 56 | status = ioctl(_metrfd, ionum, args); 57 | if (status < 0) { 58 | fprintf(stderr, "ERROR: Metropolis proc ioctl failed: %m\n"); 59 | return (-1); 60 | } 61 | 62 | return (status); 63 | } 64 | -------------------------------------------------------------------------------- /libsls/sls_private.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_PRIVATE_H__ 2 | #define _SLS_PRIVATE_H__ 3 | 4 | #include "sls_ioctl.h" 5 | 6 | int sls_ioctl(long ionum, void *args); 7 | int metr_ioctl(long ionum, void *args); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /metropolis/Makefile: -------------------------------------------------------------------------------- 1 | KMOD = metropolis 2 | CLEANFILES = .depend* 3 | DPSRCS = offset.inc 4 | SRCS = metr_ioctl.c metr_restore.c metr_syscall.c vnode_if.h 5 | CFLAGS += -DKDTRACE_HOOKS -DSMP -DKLD_TIED -I../include -g 6 | CLEANFILES = .depend* 7 | WITH_CTF = 1 8 | 9 | .ifdef PERF 10 | DEBUG_FLAGS += -g3 -O2 -DDDB 11 | .endif 12 | 13 | .ifdef FASTDBG 14 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DKTR -DDDB 15 | .endif 16 | 17 | .ifdef SLOWDBG 18 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DDEBUG_LOCKS -DKTR -DDDB -DWITNESS 19 | .endif 20 | 21 | .include 22 | -------------------------------------------------------------------------------- /metropolis/metr_syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef _METR_SYSCALL_H_ 2 | #define _METR_SYSCALL_H_ 3 | 4 | /* The Aurora syscall vector. */ 5 | extern struct sysentvec metrsys_sysvec; 6 | 7 | void metropolis_initsysvec(void); 8 | void metropolis_finisysvec(void); 9 | 10 | #endif /* _METR_SYSCALL_H_ */ 11 | -------------------------------------------------------------------------------- /scripts/ckpt.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | unsigned long checkpoint_start, last_checkpoint_event; 5 | unsigned long stopclock_start, meta_start; 6 | 7 | BEGIN { 8 | checkpoint_start = timestamp; 9 | last_checkpoint_event = timestamp; 10 | stopclock_start = timestamp; 11 | meta_start = timestamp; 12 | } 13 | 14 | fbt::sls_ckpt:entry 15 | { 16 | checkpoint_start = timestamp; 17 | last_checkpoint_event = timestamp; 18 | stopclock_start = timestamp; 19 | meta_start = timestamp; 20 | } 21 | 22 | sls:::stopclock_start 23 | { 24 | stopclock_start = timestamp; 25 | } 26 | 27 | 28 | sls:::meta_start 29 | { 30 | meta_start = timestamp; 31 | } 32 | 33 | sls:::meta_finish 34 | { 35 | @tavg["Metadata copy"] = avg(timestamp - meta_start); 36 | } 37 | 38 | fbt::slsckpt_filedesc:entry 39 | { 40 | tstart["filedesc"] = timestamp; 41 | } 42 | 43 | fbt::slsckpt_filedesc:return 44 | { 45 | @tavg["filedesc"] = avg(timestamp - tstart["filedesc"]); 46 | } 47 | 48 | fbt::slsckpt_file:entry 49 | { 50 | tstart["file"] = timestamp; 51 | } 52 | 53 | fbt::slsckpt_file:return 54 | { 55 | @tavg["file"] = avg(timestamp - tstart["file"]); 56 | } 57 | 58 | sls:::stopclock_start 59 | { 60 | stopclock_start = timestamp; 61 | } 62 | 63 | sls:::stopclock_finish 64 | { 65 | @tavg["Application stop time"] = avg(timestamp - checkpoint_start); 66 | proc_last_checkpoint_event = timestamp; 67 | } 68 | 69 | sls::sls_ckpt: 70 | { 71 | @tavg[stringof(arg0)] = avg(timestamp - last_checkpoint_event); 72 | last_checkpoint_event = timestamp; 73 | } 74 | 75 | fbt::sls_ckpt:return 76 | { 77 | @tavg["Total time"] = avg(timestamp - checkpoint_start); 78 | } 79 | 80 | fbt::slos_iotask_create:entry 81 | { 82 | task_start = timestamp; 83 | } 84 | 85 | 86 | fbt::slos_iotask_create:return 87 | { 88 | task_start = timestamp; 89 | @tavg["Task IO"] = avg(timestamp - checkpoint_start); 90 | } 91 | 92 | END 93 | { 94 | printa(@tavg); 95 | } 96 | -------------------------------------------------------------------------------- /scripts/memsnap.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | int memsnap_start, last_memsnap_event; 5 | int stopclock_start, stopclock_finish; 6 | 7 | fbt::slsckpt_dataregion:entry 8 | { 9 | memsnap_start = last_memsnap_event = timestamp; 10 | } 11 | 12 | sls::slsckpt_dataregion: 13 | { 14 | @tround[stringof(arg0)] = sum(timestamp - last_memsnap_event); 15 | @tavg[stringof(arg0)] = avg(timestamp - last_memsnap_event); 16 | @ttotal[stringof(arg0)] = sum(timestamp - last_memsnap_event); 17 | 18 | last_memsnap_event = timestamp; 19 | } 20 | 21 | sls:::stopclock_start 22 | { 23 | stopclock_start = timestamp; 24 | } 25 | 26 | sls:::stopclock_finish 27 | { 28 | stopclock_finish = timestamp; 29 | @tround["Stop time"] = sum(stopclock_finish - stopclock_start); 30 | @tavg["Stop time"] = avg(stopclock_finish - stopclock_start); 31 | @ttotal["Stop time"] = sum(stopclock_finish - stopclock_start); 32 | } 33 | 34 | sls::slsckpt_dataregion_fillckpt: 35 | { 36 | @tround[stringof(arg0)] = sum(timestamp - last_memsnap_event); 37 | @tavg[stringof(arg0)] = avg(timestamp - last_memsnap_event); 38 | @ttotal[stringof(arg0)] = sum(timestamp - last_memsnap_event); 39 | last_memsnap_event = timestamp; 40 | } 41 | 42 | fbt::slsckpt_dataregion:return 43 | { 44 | @tround["Total time"] = sum(last_memsnap_event - memsnap_start); 45 | @tavg["Total time"] = avg(last_memsnap_event - memsnap_start); 46 | @ttotal["Total time"] = sum(last_memsnap_event - memsnap_start); 47 | printf("\nIteration:\n"); 48 | printa(@tround); 49 | clear(@tround); 50 | } 51 | 52 | END 53 | { 54 | printf("\nAverages:\n"); 55 | printa(@tavg); 56 | printf("\nTotals:\n"); 57 | printa(@ttotal); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /scripts/rest.d: -------------------------------------------------------------------------------- 1 | #!/usr/sbin/dtrace -s 2 | 3 | #pragma D option quiet 4 | int restore_start, last_restore_event; 5 | int proc_restore_start, proc_last_restore_event; 6 | int restore_start; 7 | 8 | BEGIN 9 | { 10 | } 11 | 12 | fbt::slsrest_metadata:entry 13 | { 14 | proc_restore_start = proc_last_restore_event = timestamp; 15 | } 16 | 17 | fbt::sls_rest:entry 18 | { 19 | restore_start = last_restore_event = timestamp; 20 | } 21 | 22 | sls::slsrest_metadata: 23 | { 24 | printf("%s\t%d ns\n", stringof(arg0), timestamp - proc_last_restore_event); 25 | proc_last_restore_event = timestamp; 26 | } 27 | 28 | sls::sls_rest: 29 | { 30 | printf("%s\t%d ns\n", stringof(arg0), timestamp - last_restore_event); 31 | last_restore_event = timestamp; 32 | } 33 | 34 | sls::slsrest_start: 35 | { 36 | restore_start = timestamp; 37 | } 38 | 39 | sls::slsrest_end: 40 | { 41 | printf("Restore latency %d ns\n", timestamp - restore_start); 42 | } 43 | 44 | END 45 | { 46 | printf("%s\t%d ns\n", "Total time", last_restore_event - restore_start); 47 | } 48 | -------------------------------------------------------------------------------- /slfs/slsfs_dir.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLSFS_DIR_H_ 2 | #define _SLSFS_DIR_H_ 3 | 4 | #define SLSFS_NAME_LEN (255) 5 | 6 | int slsfs_init_dir(struct vnode *dvp, struct vnode *vp, struct componentname *); 7 | int slsfs_add_dirent( 8 | struct vnode *vp, uint64_t ino, char *nameptr, long namelen, uint8_t type); 9 | int slsfs_lookup_name( 10 | struct vnode *vp, struct componentname *name, struct dirent *dir_p); 11 | int slsfs_unlink_dir( 12 | struct vnode *dvp, struct vnode *vp, struct componentname *name); 13 | int slsfs_dirempty(struct vnode *vp); 14 | int slsfs_update_dirent( 15 | struct vnode *tdvp, struct vnode *fvp, struct vnode *tvp); 16 | 17 | void slsfs_declink(struct vnode *vp); 18 | 19 | #endif /* _SLSFS_DIR_H_ */ 20 | -------------------------------------------------------------------------------- /slos/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PATH: ./ ../slfs 3 | 4 | KMOD = slos 5 | DPSRCS = offset.inc 6 | 7 | SRCS = slos_alloc.c slos_btree.c slos_inode.c slos_io.c slos_radix.c slos_subr.c 8 | 9 | SRCS += slsfs_vnops.c slsfs_vfsops.c slsfs_dir.c \ 10 | slsfs_buf.c vnode_if.h 11 | 12 | CFLAGS += -DKDTRACE_HOOKS -DKLD_TIED -DSMP -I../include 13 | CLEANFILES = .depend* 14 | WITH_CTF = 1 15 | 16 | .ifdef SLOS_TEST 17 | DEBUG_FLAGS += -DSLOS_TEST 18 | .endif 19 | 20 | .ifdef PERF 21 | DEBUG_FLAGS += -g3 -O2 -DDB 22 | .endif 23 | 24 | .ifdef FASTDBG 25 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DKTR -DDDB 26 | WITH_CTF = 1 27 | .endif 28 | 29 | .ifdef SLOWDBG 30 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DDEBUG_LOCKS -DKTR -DWITNESS -DDDB 31 | .endif 32 | 33 | .include 34 | -------------------------------------------------------------------------------- /slos/debug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SLOS_DEBUG_H_ 3 | #define _SLOS_DEBUG_H_ 4 | 5 | #define KTR_THIS_MODULE KTR_SPARE5 6 | 7 | #include 8 | 9 | #endif /* _SLOS_DEBUG_H_ */ 10 | -------------------------------------------------------------------------------- /slos/slos_alloc.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLOS_ALLOC_H_ 2 | #define _SLOS_ALLOC_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define OTREE(slos) (&((slos)->slos_alloc.a_offset->sn_tree)) 8 | #define STREE(slos) (&((slos)->slos_alloc.a_size->sn_tree)) 9 | 10 | int slos_allocator_init(struct slos *slos); 11 | int uint64_t_comp(const void *k1, const void *k2); 12 | int slos_allocator_uninit(struct slos *slos); 13 | int slos_allocator_sync(struct slos *slos, struct slos_sb *newsb); 14 | int slos_blkalloc(struct slos *slos, size_t bytes, diskptr_t *ptr); 15 | int slos_blkalloc_large(struct slos *slos, size_t bytes, diskptr_t *ptr); 16 | int slos_blkalloc_wal(struct slos *slos, size_t bytes, diskptr_t *ptr); 17 | 18 | int slos_freebytes(SYSCTL_HANDLER_ARGS); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /slos/slos_subr.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLOS_SUBR_H_ 2 | #define _SLOS_SUBR_H_ 3 | 4 | int slos_remove_node( 5 | struct vnode *dvp, struct vnode *vp, struct componentname *name); 6 | int slos_destroy_node(struct slos_node *vp); 7 | 8 | int slos_truncate(struct vnode *vp, size_t size); 9 | int slos_setupfakedev(struct slos *slos, struct slos_node *vp); 10 | void slos_generic_rc(void *ctx, bnode_ptr p); 11 | 12 | int slos_bufwrite(struct buf *buf); 13 | int slos_bufsync(struct bufobj *bufobj, int waitfor); 14 | void slos_bufbdflush(struct bufobj *bufobj, struct buf *buf); 15 | void slos_bufstrategy(struct bufobj *bo, struct buf *bp); 16 | 17 | int slos_sync_vp(struct vnode *vp, int release); 18 | 19 | /* Identifier allocator */ 20 | extern struct unrhdr *slsid_unr; 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /slos/slsfs_buf.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLSFS_BUF_H_ 2 | #define _SLSFS_BUF_H_ 3 | 4 | #define ENDPOINT(iter, blksize) \ 5 | (ITER_KEY_T((iter), uint64_t) * blksize) + \ 6 | (ITER_VAL_T((iter), diskptr_t).size) 7 | #define INTERSECT(leftiter, right, blksize) \ 8 | (ENDPOINT(leftiter, blksize) > (right * blksize)) 9 | 10 | /* 11 | * Given some vnode, bcreate will create a struct buf at the given logical 12 | * block number (lbn), of size xfersize and allocate it and attach it to the 13 | * given pointer at buf. 14 | */ 15 | int slsfs_balloc(struct vnode *node, uint64_t lbn, size_t xfersize, int gbflag, 16 | struct buf **buf); 17 | 18 | int slsfs_retrieve_buf(struct vnode *vp, uint64_t offset, uint64_t size, 19 | enum uio_rw rw, int gbflag, struct buf **bp); 20 | 21 | /* 22 | * Given some vnode will read in the buffer associated with the logical block 23 | * number (lbn), and attach it to the pointer at buf. 24 | */ 25 | int slsfs_bread(struct vnode *node, uint64_t lbn, size_t size, 26 | struct ucred *cred, int flags, struct buf **buf); 27 | 28 | int slsfs_devbread( 29 | struct slos *slos, uint64_t lbn, size_t size, struct buf **bpp); 30 | 31 | void slsfs_bdirty(struct buf *buf); 32 | int slsfs_bundirty(struct buf *buf); 33 | 34 | /* 35 | * Lookup Logical Block Number 36 | * Checks whether a specific node has a logical block number associated with 37 | * it. This function is used to figure whether to issue a bcreate or a bread 38 | * 39 | * On success will return a physical block number of >= 0 (pbn) 40 | * 41 | * On failure will return a physical block number of -1 42 | */ 43 | int slsfs_lookupbln( 44 | struct slos_node *svp, uint64_t lbn, struct fnode_iter *iter); 45 | 46 | #endif /* _SLSFS_BUF_H_ */ 47 | -------------------------------------------------------------------------------- /sls/Makefile: -------------------------------------------------------------------------------- 1 | KMOD = sls 2 | CLEANFILES = .depend* 3 | DPSRCS = offset.inc 4 | SRCS = sls_backend.c sls_ioctl.c sls_vmspace.c sls_vmobject.c sls_proc.c sls_load.c sls_io.c \ 5 | sls_rest.c sls_file.c sls_ckpt.c sls_kqueue.c sls_pipe.c \ 6 | sls_socket.c sls_partition.c sls_table.c sls_kv.c sls_syscall.c sls_sysv.c \ 7 | sls_pts.c sls_vnode.c sls_posixshm.c sls_pager.c sls_vm.c sls_prefault.c \ 8 | sls_socksnd.c sls_pgresident.c sls_filebackend.c sls_region.c \ 9 | sls_sockrcv.c slsbk_slos.c vnode_if.h 10 | CFLAGS += -DKDTRACE_HOOKS -DSMP -DKLD_TIED -I../include -g 11 | CLEANFILES = .depend* 12 | WITH_CTF = 1 13 | 14 | .ifdef SLS_MSG 15 | DEBUG_FLAGS += -DSLS_MSG 16 | .endif 17 | 18 | .ifdef SLS_TEST 19 | DEBUG_FLAGS += -DSLS_TEST 20 | .endif 21 | 22 | .ifdef PERF 23 | DEBUG_FLAGS += -g3 -O2 -DDDB 24 | .endif 25 | 26 | .ifdef FASTDBG 27 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DKTR -DDDB 28 | .endif 29 | 30 | .ifdef SLOWDBG 31 | DEBUG_FLAGS += -g3 -O0 -DINVARIANTS -DINVARIANT_SUPPORT -DDEBUG_LOCKS -DKTR -DDDB -DWITNESS 32 | .endif 33 | 34 | .include 35 | -------------------------------------------------------------------------------- /sls/debug.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SLS_DEBUG_H_ 3 | #define _SLS_DEBUG_H_ 4 | 5 | #define KTR_THIS_MODULE KTR_SPARE4 6 | 7 | #include 8 | 9 | #endif /* _SLS_DEBUG_H_ */ 10 | -------------------------------------------------------------------------------- /sls/pts_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTS_INTERNAL_ 2 | #define _PTS_INTERNAL_ 3 | 4 | #define TTYINQ_QUOTESIZE (TTYINQ_DATASIZE / BMSIZE) 5 | #define BMSIZE 32 6 | 7 | struct ttyinq_block { 8 | struct ttyinq_block *tib_prev; 9 | struct ttyinq_block *tib_next; 10 | uint32_t tib_quotes[TTYINQ_QUOTESIZE]; 11 | char tib_data[TTYINQ_DATASIZE]; 12 | }; 13 | 14 | struct ttyoutq_block { 15 | struct ttyoutq_block *tob_next; 16 | char tob_data[TTYOUTQ_DATASIZE]; 17 | }; 18 | 19 | #endif /* _PTS_INTERNAL_ */ 20 | -------------------------------------------------------------------------------- /sls/sls_backend.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "sls_backend.h" 7 | #include "sls_internal.h" 8 | #include "sls_partition.h" 9 | 10 | int 11 | slsbk_setup(struct sls_backend_ops *ops, int type, struct sls_backend **slsbkp) 12 | { 13 | struct sls_backend *slsbk; 14 | int error; 15 | 16 | slsbk = malloc(sizeof(*slsbk), M_SLSMM, M_NOWAIT | M_ZERO); 17 | if (slsbk == NULL) 18 | return (ENOMEM); 19 | 20 | slsbk->bk_type = type; 21 | slsbk->bk_ops = ops; 22 | 23 | error = (slsbk->bk_ops->slsbk_setup)(slsbk); 24 | if (error != 0) { 25 | free(slsbk, M_SLSMM); 26 | return (error); 27 | } 28 | 29 | *slsbkp = slsbk; 30 | 31 | return (0); 32 | } 33 | 34 | int 35 | slsbk_teardown(struct sls_backend *slsbk) 36 | { 37 | int error; 38 | 39 | error = (slsbk->bk_ops->slsbk_teardown)(slsbk); 40 | if (error != 0) 41 | return (error); 42 | 43 | free(slsbk, M_SLSMM); 44 | return (0); 45 | } 46 | 47 | int 48 | slsbk_import(struct sls_backend *slsbk) 49 | { 50 | return (slsbk->bk_ops->slsbk_import)(slsbk); 51 | } 52 | 53 | int 54 | slsbk_export(struct sls_backend *slsbk) 55 | { 56 | return (slsbk->bk_ops->slsbk_export)(slsbk); 57 | } 58 | 59 | int 60 | slsbk_partadd(struct sls_backend *slsbk, struct slspart *slsp) 61 | { 62 | slsp->slsp_bk = slsbk; 63 | return (slsbk->bk_ops->slsbk_partadd)(slsbk, slsp); 64 | } 65 | 66 | int 67 | slsbk_setepoch(struct sls_backend *slsbk, uint64_t oid, uint64_t epoch) 68 | { 69 | return (slsbk->bk_ops->slsbk_setepoch)(slsbk, oid, epoch); 70 | } 71 | -------------------------------------------------------------------------------- /sls/sls_backend.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_BACKEND_H_ 2 | #define _SLS_BACKEND_H_ 3 | 4 | #include 5 | 6 | #define SLSBK_PRIVSIZE (4096) 7 | 8 | struct slspart; 9 | struct sls_backend; 10 | 11 | struct sls_backend_ops { 12 | int (*slsbk_setup)(struct sls_backend *bk); 13 | int (*slsbk_teardown)(struct sls_backend *bk); 14 | int (*slsbk_import)(struct sls_backend *bk); 15 | int (*slsbk_export)(struct sls_backend *bk); 16 | int (*slsbk_partadd)(struct sls_backend *bk, struct slspart *slsp); 17 | int (*slsbk_setepoch)(struct sls_backend *bk, uint64_t oid, 18 | uint64_t epoch); 19 | }; 20 | 21 | struct sls_backend { 22 | int bk_type; 23 | struct sls_backend_ops *bk_ops; 24 | LIST_ENTRY(sls_backend) bk_backends; 25 | char bk_data[SLSBK_PRIVSIZE]; 26 | }; 27 | 28 | int slsbk_setup(struct sls_backend_ops *ops, int type, 29 | struct sls_backend **slsbkp); 30 | int slsbk_teardown(struct sls_backend *slsbk); 31 | int slsbk_import(struct sls_backend *slsbk); 32 | int slsbk_export(struct sls_backend *slsbk); 33 | int slsbk_partadd(struct sls_backend *slsbk, struct slspart *slsp); 34 | int slsbk_setepoch(struct sls_backend *slsbk, uint64_t oid, uint64_t epoch); 35 | 36 | extern struct sls_backend_ops slosbk_ops; 37 | extern struct sls_backend_ops recvbk_ops; 38 | 39 | #endif /* _SLS_BACKEND_H_ */ 40 | -------------------------------------------------------------------------------- /sls/sls_file.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_FD_H_ 2 | #define _SLS_FD_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "sls_data.h" 10 | #include "sls_internal.h" 11 | #include "sls_kv.h" 12 | 13 | /* Maximum size of a UNIX socket address */ 14 | #define UNADDR_MAX (104) 15 | #define DEVFS_ROOT "/dev/" 16 | 17 | int slspts_checkpoint_vnode(struct vnode *vp, struct sbuf *sb); 18 | 19 | int slskq_restore_knotes_all(struct proc *p, struct slskv_table *kevtable); 20 | 21 | void slskq_attach_locked(struct proc *p, struct kqueue *kq); 22 | void slskq_attach(struct proc *p, struct kqueue *kq); 23 | void slskq_detach(struct kqueue *kq); 24 | 25 | int slsckpt_filedesc( 26 | struct proc *p, struct slsckpt_data *sckpt_data, struct sbuf *sb); 27 | int slsrest_filedesc(struct proc *p, struct slsfiledesc *slsfiledesc, 28 | struct slsrest_data *restdata); 29 | 30 | int slsrest_file( 31 | void *slsbacker, struct slsfile *info, struct slsrest_data *restdata); 32 | bool slsckpt_vnode_istty(struct vnode *vp); 33 | 34 | int slsfile_extractfp(int fd, struct file **fpp); 35 | void slsfile_attemptclose(int fd); 36 | 37 | struct slsfile_ops { 38 | bool (*slsfile_supported)(struct file *); 39 | int (*slsfile_slsid)(struct file *, uint64_t *); 40 | int (*slsfile_checkpoint)( 41 | struct file *fp, struct sbuf *sb, struct slsckpt_data *sckpt_data); 42 | int (*slsfile_restore)(void *slsbacker, struct slsfile *finfo, 43 | struct slsrest_data *restdata, struct file **fpp); 44 | }; 45 | 46 | #endif /* _SLS_FD_H_ */ 47 | -------------------------------------------------------------------------------- /sls/sls_io.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_IO_H_ 2 | #define _SLS_IO_H_ 3 | 4 | int slsio_open_vfs(char *name, int *fdp); 5 | int slsio_open_sls(uint64_t oid, bool create, struct file **fpp); 6 | int slsio_fpread(struct file *fp, void *buf, size_t size); 7 | int slsio_fpwrite(struct file *fp, void *buf, size_t size); 8 | int slsio_fdread(int fd, char *buf, size_t len, off_t *offp); 9 | int slsio_fdwrite(int fd, char *buf, size_t len, off_t *offp); 10 | int slsio_fdwritev(int fd, struct iovec *aiov, size_t count, off_t *offp); 11 | int sls_write_rcvdone(struct slspart *slsp); 12 | 13 | #endif /* _SLS_IO_H_ */ 14 | -------------------------------------------------------------------------------- /sls/sls_load.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_LOAD_H_ 2 | #define _SLS_LOAD_H_ 3 | 4 | #include 5 | 6 | #include "sls_kv.h" 7 | 8 | /* 9 | * XXX These calls can be refactored as preprocessor wrappers around a simple 10 | * function that takes the size and the magic number to check against (we can 11 | * assume that it is always the first field of the struct that is the magic 12 | * number, so we can typecast to a uint64_t). 13 | */ 14 | int slsload_thread(struct slsthread *slsthread, char **bufp, size_t *bufsizep); 15 | int slsload_proc(struct slsproc *slsproc, char **bufp, size_t *bufsizep); 16 | int slsload_vmentry(struct slsvmentry *entry, char **bufp, size_t *bufsizep); 17 | int slsload_vnode(struct slsvnode *slsvnode, char **bufp, size_t *bufsizep); 18 | int slsload_sysvshm(struct slssysvshm *shm, char **bufp, size_t *bufsizep); 19 | 20 | int slsload_file( 21 | struct slsfile *file, void **data, char **bufp, size_t *bufsizep); 22 | int slsload_filedesc( 23 | struct slsfiledesc **filedescp, char **bufp, size_t *bufsizep); 24 | int slsload_vmspace(struct slsvmspace *vm, struct shmmap_state **shmstate, 25 | char **bufp, size_t *bufsizep); 26 | int slsload_sockbuf( 27 | struct mbuf **mp, uint64_t *sbid, char **bufp, size_t *bufsizep); 28 | 29 | int sls_info(void *info, size_t infosize, char **bufp, size_t *bufsizep); 30 | 31 | #endif /* _SLS_LOAD_H_ */ 32 | -------------------------------------------------------------------------------- /sls/sls_pager.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_SWAPPER_H_ 2 | #define _SLS_SWAPPER_H_ 3 | 4 | void slsvm_pager_register(void); 5 | struct buf *sls_swap_getreadbuf( 6 | vm_object_t obj, vm_pindex_t pindex, size_t npages); 7 | void sls_pager_register(void); 8 | struct buf *sls_pager_readbuf( 9 | vm_object_t obj, vm_pindex_t pindex, size_t npages, bool *retry); 10 | struct buf *sls_pager_writebuf( 11 | vm_object_t obj, vm_pindex_t pindex, size_t targetsize, bool *retry); 12 | 13 | void sls_pager_unregister(void); 14 | void sls_pager_swapoff(void); 15 | 16 | int sls_pager_obj_init(vm_object_t obj); 17 | 18 | #define b_aurobj b_fsprivate2 19 | 20 | #endif /* _SLS_SWAPPER_H_ */ 21 | -------------------------------------------------------------------------------- /sls/sls_prefault.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_PREFAULT_H_ 2 | #define _SLS_PREFAULT_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | struct sls_prefault { 11 | uint64_t pre_slsid; 12 | size_t pre_size; /* Size of the bitmap in _bits_. */ 13 | bitstr_t *pre_map; /* The bitmap itself. */ 14 | }; 15 | 16 | int slspre_create(uint64_t slsid, size_t size, struct sls_prefault **slsprep); 17 | void slspre_destroy(struct sls_prefault *slsprep); 18 | 19 | int slspre_vector_populated(uint64_t objid, vm_object_t obj); 20 | int slspre_vector_empty( 21 | uint64_t objid, size_t size, struct sls_prefault **slsprep); 22 | 23 | void slspre_mark(uint64_t prefaultid, vm_pindex_t start, vm_pindex_t stop); 24 | 25 | int slspre_export(void); 26 | int slspre_import(void); 27 | 28 | int slspre_vnode(struct vnode *vp, struct sls_attr attr); 29 | 30 | int slspre_clear(SYSCTL_HANDLER_ARGS); 31 | 32 | #endif /* _SLS_PREFAULT_H_ */ 33 | -------------------------------------------------------------------------------- /sls/sls_proc.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_PROC_H_ 2 | #define _SLS_PROC_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "sls_data.h" 23 | #include "sls_internal.h" 24 | #include "sls_kv.h" 25 | 26 | int slsproc_checkpoint(struct proc *p, struct sbuf *sb, slsset *procset, 27 | struct slsckpt_data *sckpt_data); 28 | int slsproc_restore(struct proc *p, char **bufp, size_t *buflenp, struct slsrest_data *restdata); 29 | 30 | #endif /* _SLS_PROC_H_ */ 31 | -------------------------------------------------------------------------------- /sls/sls_syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_SYSCALL_H_ 2 | #define _SLS_SYSCALL_H_ 3 | 4 | void slssyscall_initsysvec(void); 5 | void slssyscall_finisysvec(void); 6 | 7 | void sls_exit_procremove(struct proc *p); 8 | extern void (*sls_exit_hook)(struct proc *p); 9 | 10 | extern struct sysentvec slssyscall_sysvec; 11 | 12 | #endif /* _SLS_SYSCALL_H_ */ 13 | -------------------------------------------------------------------------------- /sls/sls_sysv.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_SYSV_H_ 2 | #define _SLS_SYSV_H_ 3 | 4 | #include 5 | 6 | #include "sls_internal.h" 7 | #include "sls_kv.h" 8 | 9 | int slsckpt_sysvshm(struct slsckpt_data *sckpt); 10 | int slsrest_sysvshm(struct slssysvshm *info, struct slskv_table *objtable); 11 | 12 | #endif /* _SLS_SYSV_H_ */ 13 | -------------------------------------------------------------------------------- /sls/sls_table.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLSTABLE_H_ 2 | #define _SLSTABLE_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | #include "sls_internal.h" 14 | #include "sls_kv.h" 15 | #include "sls_prefault.h" 16 | 17 | /* 18 | * Read from and write to the SLOS. 19 | */ 20 | int sls_read_slos(struct slspart *slsp, struct slsckpt_data **sckptp, 21 | struct slskv_table *objtable); 22 | 23 | int sls_readdata_prefault( 24 | struct vnode *vp, vm_object_t obj, struct sls_prefault *slspre); 25 | int sls_write_slos(uint64_t oid, struct slsckpt_data *sckpt); 26 | int sls_write_slos_dataregion(struct slsckpt_data *sckpt); 27 | 28 | struct sls_record *sls_getrecord_empty(uint64_t slsid, uint64_t type); 29 | struct sls_record *sls_getrecord( 30 | struct sbuf *sb, uint64_t slsid, uint64_t type); 31 | int sls_record_seal(struct sls_record *rec); 32 | void sls_record_destroy(struct sls_record *rec); 33 | void sls_free_rectable(struct slskv_table *rectable); 34 | 35 | extern unsigned int sls_async_slos; 36 | 37 | int slstable_init(void); 38 | void slstable_fini(void); 39 | 40 | int sls_readmeta(char *buf, size_t buflen, struct slskv_table *table); 41 | 42 | int sls_read_file(struct slspart *slsp, struct slsckpt_data **sckpt, 43 | struct slskv_table *objtable); 44 | int sls_write_file(struct slspart *slsp, struct slsckpt_data *sckpt); 45 | int sls_write_socket(struct slspart *slsp, struct slsckpt_data *sckpt); 46 | 47 | #endif /* _SLSTABLE_H_ */ 48 | -------------------------------------------------------------------------------- /sls/sls_vm.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLSVM_H_ 2 | #define _SLSVM_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "sls_internal.h" 19 | #include "sls_kv.h" 20 | 21 | #define OBJT_ISANONYMOUS(obj) \ 22 | ((obj != NULL) && \ 23 | ((obj->type == OBJT_DEFAULT) || (obj->type == OBJT_SWAP))) 24 | 25 | int slsvm_entry_shadow_single(struct proc *p, struct slskv_table *table, 26 | vm_map_entry_t entry); 27 | int slsvm_entry_shadow(struct proc *p, struct slskv_table *table, 28 | vm_map_entry_t entry, bool need_protect); 29 | void slsvm_objtable_collapsenew( 30 | struct slskv_table *objtable, struct slskv_table *newtable); 31 | void slsvm_objtable_collapse( 32 | struct slskv_table *objtable, struct slskv_table *newtable); 33 | int slsvm_procset_shadow(slsset *procset, struct slsckpt_data *sckpt); 34 | void slsvm_forceshadow( 35 | vm_object_t shadow, vm_object_t source, vm_ooffset_t offset); 36 | 37 | void slsvm_object_shadowexact(vm_object_t *objp); 38 | void slsvm_object_reftransfer(vm_object_t src, vm_object_t dst); 39 | int slsvm_object_shadow(struct slskv_table *objtable, vm_object_t *objp); 40 | void slsvm_object_copy( 41 | struct proc *p, struct vm_map_entry *entry, vm_object_t obj); 42 | void slsvm_object_precopy(vm_object_t object, vm_object_t parent); 43 | 44 | void slsvm_print_chain(vm_object_t shadow); 45 | void slsvm_print_crc32_vmspace(struct vmspace *vm); 46 | void slsvm_print_crc32_object(vm_object_t obj); 47 | 48 | void slsvm_print_vmobject(struct vm_object *obj); 49 | void slsvm_print_vmspace(struct vmspace *space); 50 | void slsvm_print_chain(vm_object_t shadow); 51 | void slsvm_object_scan(void); 52 | 53 | void slsvm_pages_dump(struct vmspace *vm, struct slskv_table *table); 54 | void slsvm_pages_check(struct vmspace *vm, struct slskv_table *table); 55 | 56 | #endif /* _SLSVM_H_ */ 57 | -------------------------------------------------------------------------------- /sls/sls_vmobject.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_VMOBJECT_H_ 2 | #define _SLS_VMOBJECT_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "sls_data.h" 8 | #include "sls_internal.h" 9 | #include "sls_kv.h" 10 | #include "sls_load.h" 11 | #include "sls_table.h" 12 | 13 | int slsvmobj_checkpoint(vm_object_t obj, struct slsckpt_data *sckpt_data); 14 | int slsvmobj_checkpoint_shm(vm_object_t *objp, struct slsckpt_data *sckpt_data); 15 | int slsvmobj_restore_all( 16 | struct slsckpt_data *sckpt_data, struct slskv_table *objtable); 17 | 18 | #endif /* _SLS_VMOBJECT_H_ */ 19 | -------------------------------------------------------------------------------- /sls/sls_vmspace.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_MEM_H_ 2 | #define _SLS_MEM_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "sls_data.h" 8 | #include "sls_internal.h" 9 | #include "sls_kv.h" 10 | #include "sls_load.h" 11 | #include "sls_table.h" 12 | 13 | #define SLS_VMSPACE_INFO_MAGIC 0x736c7303 14 | 15 | int slsvmspace_checkpoint( 16 | struct vmspace *vm, struct sbuf *sb, struct slsckpt_data *sckpt_data); 17 | 18 | int slsvmspace_restore(struct proc *p, char **bufp, size_t *buflenp, 19 | struct slsrest_data *restdata); 20 | #endif /* _SLS_MEM_H_ */ 21 | -------------------------------------------------------------------------------- /sls/sls_vnode.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLS_VNODE_H_ 2 | #define _SLS_VNODE_H_ 3 | 4 | #include "sls_internal.h" 5 | 6 | int slsckpt_vnode_serialize(struct slsckpt_data *sckpt_data); 7 | int slsckpt_vnode(struct vnode *vp, struct slsckpt_data *sckpt_data); 8 | int slsvn_restore_vnode(struct slsvnode *info, struct slsckpt_data *sckpt); 9 | 10 | #endif /* _SLS_VNODE_H_ */ 11 | -------------------------------------------------------------------------------- /sls/sysv_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _COPIED_FD_H 2 | #define _COPIED_FD_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | extern int shm_last_free, shm_nused, shmalloced; 13 | extern vm_size_t shm_committed; 14 | extern struct shmid_kernel *shmsegs; 15 | 16 | struct shmmap_state { 17 | vm_offset_t va; 18 | int shmid; 19 | }; 20 | 21 | #define SHMSEG_FREE 0x0200 22 | #define SHMSEG_REMOVED 0x0400 23 | #define SHMSEG_ALLOCATED 0x0800 24 | 25 | MALLOC_DECLARE(M_SHM); 26 | MALLOC_DECLARE(M_SHMFD); 27 | 28 | struct shm_mapping { 29 | char *sm_path; 30 | Fnv32_t sm_fnv; 31 | struct shmfd *sm_shmfd; 32 | LIST_ENTRY(shm_mapping) sm_link; 33 | }; 34 | 35 | extern u_long shm_hash; 36 | extern LIST_HEAD(, shm_mapping) *shm_dictionary; 37 | 38 | struct ttyoutq_block { 39 | struct ttyoutq_block *tob_next; 40 | char tob_data[TTYOUTQ_DATASIZE]; 41 | }; 42 | 43 | #define BMSIZE 32 44 | #define TTYINQ_QUOTESIZE (TTYINQ_DATASIZE / BMSIZE) 45 | 46 | struct ttyinq_block { 47 | struct ttyinq_block *tib_prev; 48 | struct ttyinq_block *tib_next; 49 | uint32_t tib_quotes[TTYINQ_QUOTESIZE]; 50 | char tib_data[TTYINQ_DATASIZE]; 51 | }; 52 | 53 | #endif /* _COPIED_FD_H */ 54 | -------------------------------------------------------------------------------- /tests/001-load-unload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Normal load unload SLOS cycle without mounting. 4 | 5 | . aurora 6 | 7 | for i in `seq 3` 8 | do 9 | kldload slos 10 | if [ $? -ne 0 ]; then 11 | echo "Failed to load modules" 12 | exit 1 13 | fi 14 | 15 | kldunload slos 16 | if [ $? -ne 0 ]; then 17 | echo "Failed to unload SLOS" 18 | exit 1 19 | fi 20 | done 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/002-load-mount-unload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Full setup and teardown, including mount/unmount. 4 | 5 | . aurora 6 | 7 | for i in `seq 3` 8 | do 9 | aursetup 10 | if [ $? -ne 0 ]; then 11 | echo "Failed to set up Aurora" 12 | exit 1 13 | fi 14 | 15 | aurteardown 16 | if [ $? -ne 0 ]; then 17 | echo "Failed to tear down Aurora" 18 | exit 1 19 | fi 20 | done 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/003-mount-unmount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | kldload slos 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to load the SLOS" 8 | exit 1 9 | fi 10 | 11 | slsnewfs 12 | if [ $? -ne 0 ]; then 13 | echo "Failed to create the SLSFS" 14 | exit 1 15 | fi 16 | 17 | slsmount 18 | if [ $? -ne 0 ]; then 19 | echo "Failed to mount Aurora" 20 | exit 1 21 | fi 22 | 23 | for i in `seq 3` 24 | do 25 | slsunmount 26 | if [ $? -ne 0 ]; then 27 | echo "Failed to unmount the SLSFS" 28 | exit 1 29 | fi 30 | 31 | slsmount 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to remount the SLSFS" 34 | exit 1 35 | fi 36 | done 37 | 38 | slsunmount 39 | if [ $? -ne 0 ]; then 40 | echo "Failed to unmount the SLSFS" 41 | exit 1 42 | fi 43 | 44 | kldunload slos 45 | if [ $? -ne 0 ]; then 46 | echo "Failed to unload the SLOS" 47 | exit 1 48 | fi 49 | 50 | 51 | -------------------------------------------------------------------------------- /tests/004-load-double-sls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to load the SLS twice. Should fail. 4 | 5 | . aurora 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to set up Aurora" 10 | exit 1 11 | fi 12 | 13 | kldload sls 2> /dev/null 14 | if [ $? -eq 0 ]; then 15 | echo "Remounted the SLS twice" 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | 25 | 26 | exit 0 27 | -------------------------------------------------------------------------------- /tests/005-unload-double-sls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unload the sls twice. Should fail. 4 | 5 | . aurora 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to set up Aurora" 10 | exit 1 11 | fi 12 | 13 | kldunload metropolis 14 | if [ $? -ne 0 ]; then 15 | echo "Failed to unload Metropolis" 16 | exit 1 17 | fi 18 | 19 | kldunload sls 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to unload the SLS" 22 | exit 1 23 | fi 24 | 25 | kldunload sls 2> /dev/null 26 | if [ $? -eq 0 ]; then 27 | echo "Unloaded the SLS twice" 28 | exit 1 29 | fi 30 | 31 | slsunmount 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to unmount the SLSFS" 34 | exit 1 35 | fi 36 | 37 | kldunload slos 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to unload the SLOS" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/006-load-double-slos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to load the slos twice. Should fail. 4 | 5 | . aurora 6 | 7 | kldload slos 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to load the modules" 10 | exit 1 11 | fi 12 | 13 | kldload slos 2> /dev/null 14 | if [ $? -eq 0 ]; then 15 | echo "Loaded the SLOS module twice" 16 | exit 1 17 | fi 18 | 19 | kldunload slos 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to unload the modules" 22 | exit 1 23 | fi 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/007-unload-double-slos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unload the slos twice. Should fail. 4 | 5 | . aurora 6 | 7 | kldload slos 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to load the SLOS" 10 | exit 1 11 | fi 12 | 13 | kldunload slos 14 | if [ $? -ne 0 ]; then 15 | echo "Failed to unload the SLOS" 16 | exit 1 17 | fi 18 | 19 | kldunload slos 2> /dev/null 20 | if [ $? -eq 0 ]; then 21 | echo "Unloaded the SLOS twice" 22 | exit 1 23 | fi 24 | 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/008-mount-double.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unload the slos twice. Should fail. 4 | 5 | . aurora 6 | 7 | kldload slos 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to load the modules" 10 | exit 1 11 | fi 12 | 13 | slsnewfs 2> /dev/null 14 | if [ $? -ne 0 ]; then 15 | echo "Failed to create the SLSFS" 16 | exit 1 17 | fi 18 | 19 | slsmount 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to mount the SLSFS" 22 | exit 1 23 | fi 24 | 25 | slsmount 2> /dev/null 26 | if [ $? -eq 0 ]; then 27 | echo "Mounted the SLSFS twice" 28 | exit 1 29 | fi 30 | 31 | slsunmount 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to unmount the SLSFS" 34 | exit 1 35 | fi 36 | 37 | kldunload slos 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to unload the SLOS" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/009-unload-slos-before-unmount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unload the slos while the FS is still active. Should fail. 4 | 5 | . aurora 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to set up Aurora" 10 | exit 1 11 | fi 12 | 13 | kldunload metropolis 14 | if [ $? -ne 0 ]; then 15 | echo "Failed to unload Metropolis" 16 | exit 1 17 | fi 18 | 19 | kldunload sls 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to unload SLS" 22 | exit 1 23 | fi 24 | 25 | kldunload slos 2>&1 26 | if [ $? -eq 0 ]; then 27 | echo "Unloaded the SLOS with an FS mounted" 28 | exit 1 29 | fi 30 | 31 | slsunmount 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to unmount FS" 34 | exit 1 35 | fi 36 | 37 | kldunload slos 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to remove the SLOS" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/010-unmount-before-sls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unmount with a running SLS. Should fail. 4 | 5 | . aurora 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to load the SLOS" 10 | exit 1 11 | fi 12 | 13 | slsunmount 2>&1 14 | if [ $? -eq 0 ]; then 15 | echo "Unmounted with the SLS running" 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to unload the SLOS" 22 | exit 1 23 | fi 24 | 25 | 26 | exit 0 27 | -------------------------------------------------------------------------------- /tests/011-sls-without-slsfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to load the sls without a mounted FS. Should fail. 4 | 5 | kldload slos 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to load the SLOS" 8 | exit 1 9 | fi 10 | 11 | kldload sls 2>&1 12 | if [ $? -eq 0 ]; then 13 | echo "Mounted the SLS without a file system" 14 | exit 1 15 | fi 16 | 17 | kldunload slos 2> /dev/null 18 | if [ $? -ne 0 ]; then 19 | echo "Unloaded the SLOS while the SLSFS is mounted" 20 | exit 1 21 | fi 22 | 23 | exit 0 24 | -------------------------------------------------------------------------------- /tests/012-invalid-slsfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | # Destroy any existing ramdisks that may have valid FSes from previous tests. 6 | MDDISK=`mdconfig -a -t malloc -s 10g` 7 | DISK="$MDDISK" 8 | DISKPATH="/dev/$DISK" 9 | 10 | kldload slos 11 | if [ $? -ne 0 ]; then 12 | echo "Failed to load SLOS" 13 | mdconfig -d -u $MDDISK 14 | exit 1 15 | fi 16 | 17 | # We attempt to mount the invalid FS multiple times to ensure we abort the mount 18 | # cleanly in the kernel. Improper error handling in the kernel (e.g. forgetting to 19 | # release taken locks before aborting the mount) can freeze the system on multiple 20 | # mount attempts. 21 | for i in `seq 5` 22 | do 23 | slsmount 2>&1 24 | if [ $? -eq 0 ]; then 25 | echo "Loaded corrupted SLOS" 26 | mdconfig -d -u $MDDISK 27 | exit 1 28 | fi 29 | 30 | sleep 1 31 | done 32 | 33 | mdconfig -d -u $MDDISK 34 | 35 | kldunload slos 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to unload SLOS" 38 | exit 1 39 | fi 40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/014-remount-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Attempt to unload the slos twice. Should fail. 4 | 5 | . aurora 6 | SRCROOT="$PWD/.." 7 | 8 | aursetup 2> /dev/null > /dev/null 9 | if [ $? -ne 0 ]; then 10 | echo "Aurora setup failed" 11 | exit 1 12 | fi 13 | 14 | kldunload sls 2> /dev/null > /dev/null 15 | 16 | GIGFILE=/tmp/gigfile 17 | 18 | dd if=/dev/urandom of=$GIGFILE bs=1G count=1 > /dev/null 2> /dev/null 19 | 20 | cp -r $SRCROOT $MNT/src 21 | cp $GIGFILE $MNT/ 22 | ln -s $MNT/$(basename $GIGFILE) $MNT/gigfileln 23 | 24 | 25 | slsunmount 2> /dev/null 26 | if [ $? -ne 0 ]; then 27 | echo "Failed to unmount the SLSFS" 28 | exit 1 29 | fi 30 | 31 | slsmount 2> /dev/null 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to mount" 34 | exit 1 35 | fi 36 | 37 | diff $SRCROOT $MNT/src 38 | 39 | if [ $? -ne 0 ]; then 40 | echo "Diff after remount corrupt" 41 | exit 1 42 | fi 43 | 44 | diff $GIGFILE $MNT/$(basename $GIGFILE) 45 | if [ $? -ne 0 ]; then 46 | echo "Diff after remount corrupt" 47 | exit 1 48 | fi 49 | 50 | if [ `readlink $MNT/gigfileln` != "$MNT/$(basename $GIGFILE)" ]; then 51 | echo "Bad link" 52 | exit 1 53 | fi 54 | 55 | 56 | aurteardown 57 | 58 | rm $GIGFILE 59 | 60 | exit 0 61 | -------------------------------------------------------------------------------- /tests/101-simple-file-io.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | echo foo > $MOUNTPT/foo 12 | rm $MOUNTPT/foo 13 | 14 | dd if=/dev/random of=$MOUNTPT/bar bs=1m count=10 2> /dev/null 15 | rm $MOUNTPT/bar 16 | 17 | mkdir $MOUNTPT/foo 18 | rmdir $MOUNTPT/foo 19 | 20 | ln -s garbage_string:123 $MOUNTPT/bar 21 | rm $MOUNTPT/bar 22 | aurteardown 23 | if [ $? -ne 0 ]; then 24 | echo "Failed to tear down Aurora" 25 | exit 1 26 | fi 27 | 28 | exit 0 29 | -------------------------------------------------------------------------------- /tests/102-fd-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test whether using the devfs on a chroot works properly. 4 | 5 | . aurora 6 | 7 | # Load the SLOS and mount the SLSFS 8 | kldload slos 9 | slsnewfs 10 | slsmount 11 | 12 | # Mount the devfs 13 | mkdir -p $MNT/dev 14 | mount -t devfs devfs $MNT/dev 15 | 16 | # Create the root 17 | installroot 18 | 19 | # Copy over the workload and run it 20 | cp ./fd/fd "/$MNT/fd" 21 | chroot "/$MNT" "/fd" / > /dev/null 2> /dev/null & 22 | PID=`pidof fd` 23 | 24 | # Wait for a bit then kill it 25 | sleep 2 26 | pkill fd 27 | sleep 2 28 | 29 | # Remove the devfs, the slsfs, and the slos, in that order 30 | umount "$MNT/dev" 31 | if [ $? -ne 0 ]; then 32 | echo "Failed to tear down Aurora" 33 | exit 1 34 | fi 35 | 36 | slsunmount 37 | if [ $? -ne 0 ]; then 38 | echo "Failed to tear down Aurora" 39 | exit 1 40 | fi 41 | 42 | kldunload slos 43 | if [ $? -ne 0 ]; then 44 | echo "Failed to tear down Aurora" 45 | exit 1 46 | fi 47 | 48 | exit 0 49 | -------------------------------------------------------------------------------- /tests/103-kilofile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FILESIZE=$(( 1024 * 1024 )) 4 | NUMFILES=1024 5 | 6 | # Test whether 7 | make_file_with_data(){ 8 | TMPFILE=`mktemp /tmp/slstemp.XXXXX` 9 | dd if=/dev/random of=/$TMPFILE bs=$FILESIZE count=1 > /dev/null 2> /dev/null 10 | echo $TMPFILE 11 | } 12 | 13 | . aurora 14 | 15 | # Load the SLOS and mount the SLSFS 16 | kldload slos 17 | slsnewfs 18 | slsmount 19 | 20 | # Create 1K files outside of the SLOS, copy them into it 21 | # Create the one file we will check in the SLOS. 22 | INITIAL=`make_file_with_data` 23 | INITIAL_INSLSFS="$MNT/initial" 24 | cp $INITIAL $MNT/initial 25 | 26 | # Create a file and load it up into the SLOS using 27 | # different names. 28 | TMPFILE=`make_file_with_data` 29 | for i in `seq 1 $(( $NUMFILES - 1 ))`; do 30 | SLSTMP=`mktemp $MNT/slstemp.XXXXX` 31 | cp $TMPFILE $SLSTMP 32 | done 33 | rm $TMPFILE 34 | 35 | # Read back the initial file and test for differences. 36 | INITIAL_READBACK="/tmp/readback" 37 | cp $INITIAL_INSLSFS $INITIAL_READBACK 38 | 39 | if [ ! -z `diff $INITIAL $INITIAL_READBACK` ]; then 40 | rm $INITIAL_READBACK 41 | rm $INITIAL 42 | 43 | echo "File read back differs from initial" 44 | exit 1 45 | fi 46 | 47 | rm $INITIAL_READBACK 48 | rm $INITIAL 49 | 50 | slsunmount 51 | if [ $? -ne 0 ]; then 52 | echo "Failed to tear down Aurora" 53 | exit 1 54 | fi 55 | 56 | kldunload slos 57 | if [ $? -ne 0 ]; then 58 | echo "Failed to tear down Aurora" 59 | exit 1 60 | fi 61 | 62 | exit 0 63 | -------------------------------------------------------------------------------- /tests/104-wal-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | TESTDIR=$PWD 7 | 8 | cd /testmnt 9 | 10 | "$TESTDIR/walfd/walfd" "$MNT" > /dev/null 2> /dev/null 11 | CODE=$? 12 | 13 | cd $TESTDIR 14 | if [ $CODE -ne 0 ]; 15 | then 16 | echo "Did not read back a sync'd write - $CODE" 17 | aurteardown 18 | exit 1 19 | fi 20 | 21 | cd $TESTDIR 22 | aurteardown 23 | -------------------------------------------------------------------------------- /tests/105-sas-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | TESTDIR=$PWD 7 | 8 | cd $MNT 9 | 10 | "$TESTDIR/sas/sas" "$MNT" 1 11 | #"$TESTDIR/sas/sas" "$MNT" 1 12 | #"$TESTDIR/sas/sas" "$MNT" 1 13 | CODE=$? 14 | 15 | cd $TESTDIR 16 | if [ $CODE -ne 0 ]; 17 | then 18 | echo "Test SAS returned code $CODE" 19 | aurteardown 20 | exit 1 21 | fi 22 | 23 | cd $TESTDIR 24 | aurteardown 25 | -------------------------------------------------------------------------------- /tests/106-sas-multiple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | TESTDIR=$PWD 7 | 8 | cd $MNT 9 | 10 | "$TESTDIR/sas/sas" "$MNT" 1000 11 | CODE=$? 12 | 13 | cd $TESTDIR 14 | if [ $CODE -ne 0 ]; 15 | then 16 | echo "Test SAS returned code $CODE" 17 | aurteardown 18 | exit 1 19 | fi 20 | 21 | cd $TESTDIR 22 | aurteardown 23 | -------------------------------------------------------------------------------- /tests/107-sas-ipc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | TESTDIR=$PWD 7 | 8 | cd $MNT 9 | 10 | "$TESTDIR/sasipc/sasipc" "$MNT" 100 11 | CODE=$? 12 | 13 | cd $TESTDIR 14 | if [ $CODE -ne 0 ]; 15 | then 16 | echo "Test SAS returned code $CODE" 17 | aurteardown 18 | exit 1 19 | fi 20 | 21 | cd $TESTDIR 22 | aurteardown 23 | -------------------------------------------------------------------------------- /tests/108-sas-fork.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | TESTDIR=$PWD 7 | 8 | cd $MNT 9 | 10 | "$TESTDIR/sasfork/sasfork" "$MNT" 100 11 | CODE=$? 12 | 13 | cd $TESTDIR 14 | if [ $CODE -ne 0 ]; 15 | then 16 | echo "Test SAS returned code $CODE" 17 | aurteardown 18 | exit 1 19 | fi 20 | 21 | cd $TESTDIR 22 | aurteardown 23 | -------------------------------------------------------------------------------- /tests/109-sas-ipc-checkpoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1050 4 | 5 | . aurora 6 | aursetup 7 | 8 | TESTDIR=$PWD 9 | 10 | cd $MNT 11 | 12 | "$TESTDIR/sasipc/sasipc" "$MNT" 1000 & 13 | PID=$! 14 | 15 | slsctl partadd slos -o $OID -t 100 -d -i 16 | slsctl attach -o $OID -p $PID 17 | slsctl checkpoint -o $OID -r 18 | 19 | wait $PID 20 | CODE=$? 21 | 22 | sysctl aurora 23 | 24 | cd $TESTDIR 25 | if [ $CODE -ne 0 ]; 26 | then 27 | echo "Test SAS returned code $CODE" 28 | aurteardown 29 | exit 1 30 | fi 31 | 32 | cd $TESTDIR 33 | aurteardown 34 | -------------------------------------------------------------------------------- /tests/110-sas-fork-checkpoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1050 4 | 5 | . aurora 6 | aursetup 7 | 8 | TESTDIR=$PWD 9 | 10 | cd $MNT 11 | 12 | "$TESTDIR/sasfork/sasfork" "$MNT" 1000 & 13 | PID=$! 14 | echo $PID 15 | 16 | slsctl partadd slos -o $OID -t 100 -d -i 17 | slsctl attach -o $OID -p $PID 18 | slsctl checkpoint -o $OID -r 19 | 20 | wait $PID 21 | CODE=$? 22 | 23 | sysctl aurora 24 | 25 | cd $TESTDIR 26 | if [ $CODE -ne 0 ]; 27 | then 28 | echo "Test SAS returned code $CODE" 29 | aurteardown 30 | exit 1 31 | fi 32 | 33 | cd $TESTDIR 34 | aurteardown 35 | -------------------------------------------------------------------------------- /tests/111-sastrack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1050 4 | 5 | . aurora 6 | aursetup 7 | 8 | TESTDIR=$PWD 9 | 10 | cd $MNT 11 | 12 | "$TESTDIR/sastrack/sastrack" $MNT & 13 | PID=$! 14 | echo $PID 15 | 16 | #slsctl partadd slos -o $OID -t 100 -d -i 17 | #slsctl attach -o $OID -p $PID 18 | #slsctl checkpoint -o $OID -r 19 | 20 | wait $PID 21 | CODE=$? 22 | 23 | cd $TESTDIR 24 | if [ $CODE -ne 0 ]; 25 | then 26 | echo "Test SAS returned code $CODE" 27 | aurteardown 28 | exit 1 29 | fi 30 | 31 | cd $TESTDIR 32 | aurteardown 33 | -------------------------------------------------------------------------------- /tests/201-simple-mem-ckpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | slsunmount 2>&1 12 | 13 | dd if=/dev/zero of=/dev/null bs=1m 1>&2 & 14 | 15 | slscheckpoint `jobid %1` 16 | if [ $? -ne 0 ]; 17 | then 18 | echo "Checkpoint failed with $?" 19 | exit 1 20 | fi 21 | 22 | killandwait %1 23 | 24 | slsrestore 25 | if [ $? -ne 0 ]; 26 | then 27 | echo "Restore failed with $?" 28 | exit 1 29 | fi 30 | 31 | sleep 1 32 | killandwait $! 2> /dev/null 33 | killall dd 34 | 35 | aurteardown 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to tear down Aurora" 38 | exit 1 39 | fi 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /tests/202-simple-osd-ckpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | dd if=/dev/zero of=/dev/null bs=1m 1>&2 & 12 | 13 | slsosdcheckpoint `jobid %1` 14 | if [ $? -ne 0 ]; 15 | then 16 | echo "Checkpoint failed with $?" 17 | aurteardown 18 | exit 1 19 | fi 20 | 21 | killandwait %1 22 | 23 | slsosdrestore 24 | if [ $? -ne 0 ] && [ $? -ne 3 ]; 25 | then 26 | echo "Restore failed with $?" 27 | aurteardown 28 | exit 1 29 | fi 30 | 31 | REST=$! 32 | 33 | sleep 1 34 | 35 | aurteardown 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to tear down Aurora" 38 | exit 1 39 | fi 40 | 41 | wait $REST 42 | EXIT=$? 43 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 44 | then 45 | echo "Process exited with $EXIT" 46 | exit 1 47 | fi 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /tests/203-busy-loop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | # Redirect to /dev/null, we don't care about stdin. 8 | ./compute/compute > /dev/null & 9 | PID=$! 10 | sleep 1 11 | 12 | slscheckpoint $PID 13 | if [ $? -ne 0 ]; 14 | then 15 | echo Checkpoint failed 16 | exit 1 17 | fi 18 | 19 | killandwait $PID 20 | 21 | slsrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo Restore failed 25 | exit 1 26 | fi 27 | 28 | REST=$! 29 | 30 | sleep 1 31 | 32 | aurteardown 33 | if [ $? -ne 0 ]; then 34 | echo "Failed to tear down Aurora" 35 | exit 1 36 | fi 37 | 38 | wait $REST 39 | EXIT=$? 40 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 41 | then 42 | echo "Process exited with $EXIT" 43 | exit 1 44 | fi 45 | 46 | exit 0 47 | -------------------------------------------------------------------------------- /tests/204-print-stdout.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | ./print/print > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slscheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo Checkpoint failed 19 | exit 1 20 | fi 21 | 22 | sleep 1 23 | killandwait $PID 24 | 25 | slsrestore 26 | if [ $? -ne 0 ]; 27 | then 28 | echo Restore failed 29 | exit 1 30 | fi 31 | 32 | REST=$! 33 | 34 | sleep 1 35 | 36 | aurteardown 37 | if [ $? -ne 0 ]; then 38 | echo "Failed to tear down Aurora" 39 | exit 1 40 | fi 41 | 42 | wait $REST 43 | EXIT=$? 44 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 45 | then 46 | echo "Process exited with $EXIT" 47 | exit 1 48 | fi 49 | 50 | exit 0 51 | -------------------------------------------------------------------------------- /tests/205-array-traversal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | ./array/array > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slscheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo Checkpoint failed 19 | aurteardown 20 | exit 1 21 | fi 22 | 23 | sleep 1 24 | killandwait $PID 25 | 26 | slsrestore 27 | # Killing the workload using a signal makes the restore exit with 3. 28 | if [ $? -ne 0 ]; 29 | then 30 | echo Restore failed 31 | exit 1 32 | fi 33 | 34 | REST=$! 35 | 36 | sleep 1 37 | 38 | aurteardown 39 | if [ $? -ne 0 ]; then 40 | echo "Failed to tear down Aurora" 41 | exit 1 42 | fi 43 | 44 | wait $REST 45 | EXIT=$? 46 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 47 | then 48 | echo "Process exited with $EXIT" 49 | exit 1 50 | fi 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/206-mmap-file.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./mmap/mmap" "$MNT" file > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | 29 | wait `pidof mmap` 30 | 31 | EXIT=$? 32 | if [ $EXIT -ne 0 ]; 33 | then 34 | echo "Restored process exited with $EXIT" 35 | exit 1 36 | fi 37 | 38 | rm "$MNT/testfile" 39 | aurteardown 40 | if [ $? -ne 0 ]; then 41 | echo "Failed to tear down Aurora" 42 | exit 1 43 | fi 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/207-mmap-anonymous.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./mmap/mmap" "$MNT" anon > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | 29 | wait `pidof mmap` 30 | 31 | EXIT=$? 32 | if [ $EXIT -ne 0 ]; 33 | then 34 | echo "Restored process exited with $EXIT" 35 | exit 1 36 | fi 37 | 38 | aurteardown 39 | if [ $? -ne 0 ]; then 40 | echo "Failed to tear down Aurora" 41 | exit 1 42 | fi 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/208-signal-handler.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./signal/signal" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slsosdcheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | kill -SIGUSR1 $PID 19 | killandwait $PID 20 | 21 | slsosdrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Restore failed" 25 | exit 1 26 | fi 27 | 28 | sleep 2 29 | pkill -SIGUSR1 signal 30 | wait $! 31 | 32 | EXIT=$? 33 | if [ $EXIT -ne 0 ]; 34 | then 35 | echo "Process exited with $EXIT" 36 | exit 1 37 | fi 38 | 39 | aurteardown 40 | if [ $? -ne 0 ]; then 41 | echo "Failed to tear down Aurora" 42 | exit 1 43 | fi 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/209-pthreads-mutex.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./multithread/multithread" "$MNT" file > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | killandwait $PID 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | pkill multithread 29 | wait $! 30 | 31 | # 15 is the return code for SIGTERM 32 | if [ $? -ne 0 -a $? -ne 15 ]; 33 | then 34 | echo "Process exited with nonzero" 35 | exit 1 36 | fi 37 | 38 | aurteardown 39 | if [ $? -ne 0 ]; then 40 | echo "Failed to tear down Aurora" 41 | exit 1 42 | fi 43 | 44 | exit 0 45 | -------------------------------------------------------------------------------- /tests/210-file-vnode.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./fd/fd" "$MNT" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | 27 | wait $! 28 | if [ $? -ne 0 ]; 29 | then 30 | echo "Process exited with nonzero" 31 | exit 1 32 | fi 33 | 34 | rm "$MNT/testfile" 35 | aurteardown 36 | if [ $? -ne 0 ]; then 37 | echo "Failed to tear down Aurora" 38 | exit 1 39 | fi 40 | 41 | exit 0 42 | -------------------------------------------------------------------------------- /tests/211-fork-simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./forkwait/forkwait" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | pkill forkwait 19 | wait $PID 20 | 21 | slsrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Restore failed with $?" 25 | exit 1 26 | fi 27 | 28 | sleep 1 29 | 30 | wait $! 31 | if [ $? -ne 0 ]; 32 | then 33 | echo "Process exited with nonzero" 34 | exit 1 35 | fi 36 | 37 | aurteardown 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to tear down Aurora" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/212-file-fifo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FIFO="testfifo" 4 | . aurora 5 | aursetup 6 | 7 | # Create it outside the process to put it in the name cache. 8 | mkfifo $FIFO 2> /dev/null 9 | sleep 1 10 | 11 | "./fifo/fifo" $PWD > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slscheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | rm $FIFO 19 | echo "Checkpoint failed with $?" 20 | exit 1 21 | fi 22 | 23 | sleep 1 24 | wait $PID 25 | 26 | slsrestore 27 | if [ $? -ne 0 ]; 28 | then 29 | rm $FIFO 30 | echo "Restore failed with $?" 31 | exit 1 32 | fi 33 | 34 | sleep 1 35 | 36 | wait $! 37 | if [ $? -ne 0 ]; 38 | then 39 | rm $FIFO 40 | echo "Process exited with nonzero" 41 | exit 1 42 | fi 43 | 44 | rm $FIFO 45 | 46 | aurteardown 47 | if [ $? -ne 0 ]; then 48 | echo "Failed to tear down Aurora" 49 | exit 1 50 | fi 51 | 52 | exit 0 53 | -------------------------------------------------------------------------------- /tests/213-fork-shm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1050 4 | 5 | . aurora 6 | aursetup 7 | 8 | TESTDIR=$PWD 9 | 10 | cd $MNT 11 | 12 | "$TESTDIR/forkshm/forkshm" "$MNT" 1000 1 & 13 | PID=$! 14 | echo $PID 15 | 16 | slsctl partadd slos -o $OID -t 100 -d -i 17 | slsctl attach -o $OID -p $PID 18 | slsctl checkpoint -o $OID -r 19 | 20 | wait $PID 21 | CODE=$? 22 | 23 | sysctl aurora 24 | 25 | cd $TESTDIR 26 | if [ $CODE -ne 0 ]; 27 | then 28 | echo "Test SAS returned code $CODE" 29 | aurteardown 30 | exit 1 31 | fi 32 | 33 | cd $TESTDIR 34 | aurteardown 35 | -------------------------------------------------------------------------------- /tests/214-file-pipes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./pipe/pipe" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | 29 | wait $! 30 | if [ $? -ne 0 ]; 31 | then 32 | echo "Process exited with $?" 33 | exit 1 34 | fi 35 | 36 | aurteardown 37 | if [ $? -ne 0 ]; then 38 | echo "Failed to tear down Aurora" 39 | exit 1 40 | fi 41 | 42 | exit 0 43 | -------------------------------------------------------------------------------- /tests/215-file-posixshm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./posixshm/posixshm" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | # This destroys the segment. 19 | wait $PID 20 | 21 | slsrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Restore failed with $?" 25 | exit 1 26 | fi 27 | 28 | sleep 1 29 | 30 | wait $! 31 | if [ $? -ne 0 ]; 32 | then 33 | echo "Process exited with $?" 34 | exit 1 35 | fi 36 | 37 | aurteardown 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to tear down Aurora" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/216-sysv-shm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./sysvshm/sysvshm" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | # The segment is destroyed by the test, recreated by the SLS. 19 | wait $PID 20 | 21 | slsrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Restore failed with $?" 25 | exit 1 26 | fi 27 | 28 | sleep 1 29 | 30 | wait $! 31 | if [ $? -ne 0 ]; 32 | then 33 | echo "Process exited with $?" 34 | exit 1 35 | fi 36 | 37 | aurteardown 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to tear down Aurora" 40 | exit 1 41 | fi 42 | 43 | exit 0 44 | -------------------------------------------------------------------------------- /tests/217-file-udplisten.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./udplisten/udplisten" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | killandwait $PID 18 | sleep 1 19 | 20 | slsrestore 21 | if [ $? -ne 0 ]; 22 | then 23 | echo "Restore failed with $?" 24 | exit 1 25 | fi 26 | PID=$! 27 | 28 | sleep 1 29 | printf "message\0" | nc -u -N localhost 6668 & 30 | sleep 1 31 | killandwait $! 32 | 33 | wait $PID 34 | if [ $? -ne 0 ]; 35 | then 36 | echo "Process exited with $?" 37 | exit 1 38 | fi 39 | 40 | aurteardown 41 | if [ $? -ne 0 ]; then 42 | echo "Failed to tear down Aurora" 43 | exit 1 44 | fi 45 | 46 | exit 0 47 | -------------------------------------------------------------------------------- /tests/218-file-tcplisten.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./udplisten/udplisten" > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | # Write out a message, keep the connected socket open. 18 | printf "message\0" | nc -u localhost 6668 & 19 | 20 | killandwait $PID 21 | sleep 10 22 | 23 | slsrestore 24 | if [ $? -ne 0 ]; 25 | then 26 | echo "Restore failed with $?" 27 | exit 1 28 | fi 29 | PID=$! 30 | 31 | sleep 1 32 | printf "message\0" | nc -u -N localhost 6668 & 33 | sleep 1 34 | killandwait $! 35 | 36 | wait $PID 37 | if [ $? -ne 0 ]; 38 | then 39 | echo "Process exited with $?" 40 | exit 1 41 | fi 42 | 43 | aurteardown 44 | if [ $? -ne 0 ]; then 45 | echo "Failed to tear down Aurora" 46 | exit 1 47 | fi 48 | 49 | exit 0 50 | -------------------------------------------------------------------------------- /tests/219-kqueue.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | ./kqueue/kqueue > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slscheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo Checkpoint failed 19 | exit 1 20 | fi 21 | 22 | sleep 1 23 | wait $PID 24 | 25 | slsrestore 26 | ## Killing the workload using a signal makes the restore exit with 3. 27 | if [ $? -ne 0 ]; 28 | then 29 | echo Restore failed 30 | exit 1 31 | fi 32 | 33 | REST=$! 34 | 35 | sleep 2 36 | 37 | aurteardown 38 | if [ $? -ne 0 ]; then 39 | echo "Failed to tear down Aurora" 40 | exit 1 41 | fi 42 | 43 | wait $REST 44 | EXIT=$? 45 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 46 | then 47 | echo "Process exited with $EXIT" 48 | exit 1 49 | fi 50 | 51 | exit 0 52 | -------------------------------------------------------------------------------- /tests/220-pgroups.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | ./pgroup/pgroup & # > /dev/null 2> /dev/null & 7 | PID=$! 8 | echo $PID 9 | sleep 5 10 | 11 | slscheckpoint $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Checkpoint failed with $?" 15 | exit 1 16 | fi 17 | 18 | sleep 2 19 | pkill `pidof pgroup` 20 | wait $PID 21 | sleep 2 22 | 23 | slsrestore 24 | if [ $? -ne 0 ]; 25 | then 26 | echo "Restore failed with $?" 27 | exit 1 28 | fi 29 | 30 | sleep 1 31 | 32 | wait $! 33 | if [ $? -ne 0 ]; 34 | then 35 | echo "Process exited with nonzero" 36 | exit 1 37 | fi 38 | 39 | aurteardown 40 | if [ $? -ne 0 ]; then 41 | echo "Failed to tear down Aurora" 42 | exit 1 43 | fi 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/221-lazy-osd-ckpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | dd if=/dev/zero of=/dev/null bs=1m 1>&2 & 7 | 8 | OID="4567" 9 | slslazycheckpoint `jobid %1` $OID 10 | if [ $? -ne 0 ]; 11 | then 12 | echo Checkpoint failed 13 | aurteardown 14 | exit 1 15 | fi 16 | 17 | killandwait %1 18 | 19 | slslazyrestore $OID 20 | if [ $? -ne 0 ]; 21 | then 22 | echo "Restore failed" 23 | aurteardown 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | killandwait $! 29 | 30 | 31 | aurteardown 32 | if [ $? -ne 0 ]; then 33 | echo "Failed to tear down Aurora" 34 | exit 1 35 | fi 36 | 37 | exit 0 38 | -------------------------------------------------------------------------------- /tests/222-self-ckpt-mem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./selfie/selfie" > /dev/null 2> /dev/null & 7 | PID=$! 8 | wait $PID 9 | 10 | slsrestore 11 | PID=$! 12 | wait $PID 13 | 14 | RET=$? 15 | if [ $RET -ne 0 ]; 16 | then 17 | echo "Process exited with nonzero $RET" 18 | exit 1 19 | fi 20 | 21 | aurteardown 22 | if [ $? -ne 0 ]; then 23 | echo "Failed to tear down Aurora" 24 | exit 1 25 | fi 26 | 27 | exit 0 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/223-restore-mem-multiple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./mmap/mmap" "$MNT" anon > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slscheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | for i in 1 2 3 4 5; do 20 | slsrestore 21 | PID=$! 22 | wait $PID 23 | 24 | RET=$? 25 | if [ $? -ne 0 ]; 26 | then 27 | echo "Process exited with nonzero" 28 | exit 1 29 | fi 30 | done 31 | 32 | aurteardown 33 | if [ $? -ne 0 ]; then 34 | echo "Failed to tear down Aurora" 35 | exit 1 36 | fi 37 | 38 | exit 0 39 | 40 | 41 | -------------------------------------------------------------------------------- /tests/224-restore-osd-multiple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | "./mmap/mmap" "$MNT" anon > /dev/null 2> /dev/null & 7 | PID=$! 8 | sleep 1 9 | 10 | slsosdcheckpoint $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo "Checkpoint failed with $?" 14 | exit 1 15 | fi 16 | 17 | sleep 1 18 | wait $PID 19 | 20 | for i in 1 2 3 4 5; do 21 | slsosdrestore 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Restore failed with $?" 25 | exit 1 26 | fi 27 | 28 | wait $! 29 | if [ $? -ne 0 ]; 30 | then 31 | echo "Process exited with nonzero" 32 | exit 1 33 | fi 34 | done 35 | 36 | aurteardown 37 | if [ $? -ne 0 ]; then 38 | echo "Failed to tear down Aurora" 39 | exit 1 40 | fi 41 | 42 | exit 0 43 | 44 | 45 | -------------------------------------------------------------------------------- /tests/225-memsnap-osd-poll.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1055 4 | 5 | . aurora 6 | aursetup 7 | 8 | sleep 3 9 | 10 | # Let the workload snapshot itself and exit with an error. 11 | "./memsnap/memsnap" -p > /dev/null 2 >/dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | wait $PID 16 | 17 | slsctl restore -o $OID & 18 | PID=$! 19 | if [ $? -ne 0 ]; 20 | then 21 | echo "Restore failed with $?" 22 | exit 1 23 | fi 24 | 25 | # Get the error value, it should be zero. 26 | wait $PID 27 | RET=$? 28 | if [ $RET -ne 0 ]; 29 | then 30 | echo "Process exited with $RET" 31 | exit 1 32 | fi 33 | 34 | aurteardown 35 | if [ $? -ne 0 ]; then 36 | echo "Failed to tear down Aurora" 37 | exit 1 38 | fi 39 | 40 | exit 0 41 | 42 | 43 | -------------------------------------------------------------------------------- /tests/226-memsnap-osd-block.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1055 4 | 5 | . aurora 6 | aursetup 7 | 8 | sleep 3 9 | 10 | # Let the workload snapshot itself and exit with an error. 11 | "./memsnap/memsnap" -w > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | wait $PID 16 | 17 | slsctl restore -o $OID & 18 | PID=$! 19 | if [ $? -ne 0 ]; 20 | then 21 | echo "Restore failed with $?" 22 | exit 1 23 | fi 24 | 25 | # Get the error value, it should be zero. 26 | wait $PID 27 | if [ $? -ne 0 ]; 28 | then 29 | echo "Process exited with nonzero" 30 | exit 1 31 | fi 32 | 33 | aurteardown 34 | if [ $? -ne 0 ]; then 35 | echo "Failed to tear down Aurora" 36 | exit 1 37 | fi 38 | 39 | exit 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/227-memsnap-mem.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | # Let the workload snapshot itself and exit with an error. 7 | "./memsnap/memsnap" -m > /dev/null 2> /dev/null & 8 | PID=$! 9 | sleep 1 10 | 11 | wait $PID 12 | 13 | slsrestore 14 | if [ $? -ne 0 ]; 15 | then 16 | echo "Restore failed with $?" 17 | exit 1 18 | fi 19 | 20 | # Get the error value, it should be zero. 21 | wait $! 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Process exited with nonzero" 25 | exit 1 26 | fi 27 | 28 | aurteardown 29 | if [ $? -ne 0 ]; then 30 | echo "Failed to tear down Aurora" 31 | exit 1 32 | fi 33 | 34 | exit 0 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/228-wal.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | # Let the workload snapshot itself and exit with an error. 7 | "./wal/wal" >/dev/null 2>&1 & 8 | PID=$! 9 | wait $PID 10 | 11 | slsosdrestore 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Restore failed with $?" 15 | exit 1 16 | fi 17 | 18 | # Get the error value, it should be zero. 19 | wait $! 20 | if [ $? -ne 0 ]; 21 | then 22 | echo "Process exited with nonzero" 23 | exit 1 24 | fi 25 | 26 | aurteardown 27 | if [ $? -ne 0 ]; then 28 | echo "Failed to tear down Aurora" 29 | exit 1 30 | fi 31 | 32 | exit 0 33 | -------------------------------------------------------------------------------- /tests/229-chroot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | installroot $MNT 6 | 7 | # Like test 206 (file), but using the SLOS as a root filesystem. 8 | cp "./mmap/mmap" "$MNT/mmap" 9 | chroot "$MNT" "/mmap" / anon > /dev/null 2> /dev/null & 10 | PID=$! 11 | sleep 1 12 | 13 | slscheckpoint $PID 14 | if [ $? -ne 0 ]; 15 | then 16 | echo "Checkpoint failed with $?" 17 | exit 1 18 | fi 19 | 20 | sleep 1 21 | wait $PID 22 | 23 | slsrestore 24 | if [ $? -ne 0 ]; 25 | then 26 | echo "Restore failed with $?" 27 | exit 1 28 | fi 29 | 30 | sleep 1 31 | 32 | wait `pidof mmap` 33 | 34 | EXIT=$? 35 | if [ $EXIT -ne 0 ]; 36 | then 37 | echo "Process exited with $EXIT" 38 | exit 1 39 | fi 40 | 41 | aurteardown 42 | if [ $? -ne 0 ]; then 43 | echo "Failed to tear down Aurora" 44 | exit 1 45 | fi 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /tests/230-chroot-devfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Test whether using the devfs on a chroot works properly. 4 | 5 | . aurora 6 | aursetup 7 | 8 | installroot 9 | 10 | cp ./fd/fd "/$MNT/fd" 11 | chroot "/$MNT" "/fd" / > /dev/null 2> /dev/null & 12 | PID=`pidof fd` 13 | sleep 1 14 | 15 | slscheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo "Checkpoint failed with $?" 19 | umount "$MNT/dev" 20 | exit 1 21 | fi 22 | 23 | sleep 1 24 | wait $PID 25 | 26 | slsrestore 27 | if [ $? -ne 0 ]; 28 | then 29 | echo "Restore failed with $?" 30 | umount "$MNT/dev" 31 | exit 1 32 | fi 33 | 34 | wait $! 35 | if [ $? -ne 0 ]; 36 | then 37 | echo "Process exited with nonzero" 38 | umount "$MNT/dev" 39 | exit 1 40 | fi 41 | 42 | rm -f "$MNT/testfile" 43 | 44 | sleep 3 45 | 46 | aurteardown 47 | 48 | exit 0 49 | -------------------------------------------------------------------------------- /tests/231-memsnap-osd-nowait.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1055 4 | 5 | . aurora 6 | aursetup 7 | 8 | sleep 3 9 | 10 | # Let the workload snapshot itself and exit with an error. 11 | "./memsnap/memsnap" -w > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | wait $PID 16 | 17 | slsctl restore -o $OID & 18 | PID=$! 19 | if [ $? -ne 0 ]; 20 | then 21 | echo "Restore failed with $?" 22 | exit 1 23 | fi 24 | 25 | # Get the error value, it should be zero. 26 | wait $PID 27 | if [ $? -ne 0 ]; 28 | then 29 | echo "Process exited with nonzero" 30 | exit 1 31 | fi 32 | 33 | aurteardown 34 | if [ $? -ne 0 ]; then 35 | echo "Failed to tear down Aurora" 36 | exit 1 37 | fi 38 | 39 | exit 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /tests/232-metropolis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis 1>&2 & 8 | PID=$! 9 | 10 | wait $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo Metropolis mode failed 14 | aurteardown exit 1 15 | fi 16 | 17 | aurteardown 18 | if [ $? -ne 0 ]; then 19 | echo "Failed to tear down Aurora" 20 | exit 1 21 | fi 22 | -------------------------------------------------------------------------------- /tests/233-metropolis-fork.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis -f 1>&2 & 8 | PID=$! 9 | 10 | wait $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo Metropolis mode failed 14 | aurteardown exit 1 15 | fi 16 | 17 | aurteardown 18 | if [ $? -ne 0 ]; then 19 | echo "Failed to tear down Aurora" 20 | exit 1 21 | fi 22 | -------------------------------------------------------------------------------- /tests/234-metropolis-exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis -e 1>&2 & 8 | PID=$! 9 | 10 | wait $PID 11 | if [ $? -ne 0 ]; 12 | then 13 | echo Metropolis mode failed 14 | aurteardown exit 1 15 | fi 16 | 17 | aurteardown 18 | if [ $? -ne 0 ]; then 19 | echo "Failed to tear down Aurora" 20 | exit 1 21 | fi 22 | -------------------------------------------------------------------------------- /tests/235-metropolis-accept.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis -a 1>&2 & 8 | PID=$! 9 | 10 | # Wait for the run to finish. The restore happens internally. 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | aurteardown > /dev/null 2> /dev/null 15 | echo "Process exited with nonzero" 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/236-metropolis-exit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis -x 1>&2 & 8 | PID=$! 9 | 10 | sleep 2 11 | 12 | # Tear down the module. This should kill the process. 13 | aurteardown 14 | if [ $? -ne 0 ]; then 15 | echo "Failed to tear down Aurora" 16 | exit 1 17 | fi 18 | 19 | # Wait for the run to finish. The restore happens internally. 20 | wait $PID 21 | EXIT=$? 22 | if [ $(( $EXIT & 127 )) -ne 0 -a $EXIT -ne $(( 128 | 9 )) ]; 23 | then 24 | echo "Process exited with $EXIT, should have exited with 0 or SIG{KILL, TERM}" 25 | exit 1 26 | fi 27 | -------------------------------------------------------------------------------- /tests/237-metropolis-accept4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | ./metropolis/metropolis -a 1>&2 & 8 | PID=$! 9 | 10 | # Wait for the run to finish. The restore happens internally. 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | aurteardown > /dev/null 2> /dev/null 15 | echo "Process exited with nonzero" 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/238-metropolis-simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | echo "$PWD" 8 | ./metrosimple/metrosimple 1>&2 & 9 | PID=$! 10 | 11 | wait $PID 12 | RET=$? 13 | if [ $RET -ne 0 ]; 14 | then 15 | echo "Metropolis mode failed with $RET" 16 | aurteardown 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | -------------------------------------------------------------------------------- /tests/239-metropolis-pymetro-multiple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | echo "$PWD" 8 | ./metrosimple/metrosimple -s 1>&2 & 9 | PID=$! 10 | 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Metropolis mode failed" 15 | aurteardown 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/240-metropolis-partitions.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | echo "$PWD" 8 | ./metroparts/metroparts 1>&2 & 9 | PID=$! 10 | 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Metropolis mode failed" 15 | aurteardown 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/241-metropolis-partitions-cached.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | echo "$PWD" 8 | ./metroparts/metroparts -c 1>&2 & 9 | PID=$! 10 | 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Metropolis mode failed" 15 | aurteardown 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/242-cached-restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | restore_and_wait() { 4 | slsctl restore -o $OID & 5 | if [ $? -ne 0 ] && [ $? -ne 3 ]; 6 | then 7 | echo "Restore failed with $?" 8 | aurteardown 9 | exit 1 10 | fi 11 | 12 | sleep 1 13 | pkill array 14 | sleep 2 15 | } 16 | 17 | export OID=1000 18 | 19 | . aurora 20 | 21 | aursetup 22 | if [ $? -ne 0 ]; then 23 | echo "Failed to set up Aurora" 24 | exit 1 25 | fi 26 | 27 | ./array/array >/dev/null 2>/dev/null & 28 | PID="$!" 29 | 30 | slsctl partadd slos -o $OID -c -l -i 31 | slsctl attach -o $OID -p $PID 32 | 33 | slsctl checkpoint -o $OID 34 | if [ $? -ne 0 ]; 35 | then 36 | echo "Checkpoint failed with $?" 37 | aurteardown 38 | exit 1 39 | fi 40 | 41 | sleep 1 42 | killandwait $PID 43 | 44 | restore_and_wait 45 | if [ $? -ne 0 ]; then 46 | echo "Failed initial restore" 47 | aurteardown 48 | exit 1 49 | fi 50 | 51 | restore_and_wait 52 | if [ $? -ne 0 ]; then 53 | echo "Failed second restore" 54 | aurteardown 55 | exit 1 56 | fi 57 | 58 | aurteardown 59 | if [ $? -ne 0 ]; then 60 | echo "Failed to tear down Aurora" 61 | exit 1 62 | fi 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /tests/243-prefault-restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | restore_and_wait() { 4 | slsctl restore -o $OID & 5 | if [ $? -ne 0 ] && [ $? -ne 3 ]; 6 | then 7 | echo "Restore failed with $?" 8 | aurteardown 9 | exit 1 10 | fi 11 | 12 | sleep 1 13 | pkill array 14 | sleep 2 15 | } 16 | 17 | export OID=1000 18 | 19 | . aurora 20 | 21 | aursetup 22 | if [ $? -ne 0 ]; then 23 | echo "Failed to set up Aurora" 24 | exit 1 25 | fi 26 | 27 | ./array/array >/dev/null 2>/dev/null & 28 | PID="$!" 29 | 30 | slsctl partadd slos -o $OID -p -l -i 31 | slsctl attach -o $OID -p $PID 32 | 33 | slsctl checkpoint -o $OID 34 | if [ $? -ne 0 ]; 35 | then 36 | echo "Checkpoint failed with $?" 37 | aurteardown 38 | exit 1 39 | fi 40 | 41 | sleep 1 42 | killandwait $PID 43 | 44 | restore_and_wait 45 | if [ $? -ne 0 ]; then 46 | echo "Failed initial restore" 47 | aurteardown 48 | exit 1 49 | fi 50 | 51 | restore_and_wait 52 | if [ $? -ne 0 ]; then 53 | echo "Failed second restore" 54 | aurteardown 55 | exit 1 56 | fi 57 | 58 | aurteardown 59 | if [ $? -ne 0 ]; then 60 | echo "Failed to tear down Aurora" 61 | exit 1 62 | fi 63 | 64 | exit 0 65 | 66 | -------------------------------------------------------------------------------- /tests/244-precopy-restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | restore_and_wait() { 4 | slsctl restore -o $OID & 5 | if [ $? -ne 0 ] && [ $? -ne 3 ]; 6 | then 7 | echo "Restore failed with $?" 8 | aurteardown 9 | exit 1 10 | fi 11 | 12 | sleep 1 13 | pkill array 14 | sleep 2 15 | } 16 | 17 | export OID=1000 18 | 19 | . aurora 20 | 21 | aursetup 22 | if [ $? -ne 0 ]; then 23 | echo "Failed to set up Aurora" 24 | exit 1 25 | fi 26 | 27 | ./array/array >/dev/null 2>/dev/null & 28 | PID="$!" 29 | 30 | slsctl partadd slos -o $OID -p -e -c -i 31 | slsctl attach -o $OID -p $PID 32 | 33 | slsctl checkpoint -o $OID 34 | if [ $? -ne 0 ]; 35 | then 36 | echo "Checkpoint failed with $?" 37 | aurteardown 38 | exit 1 39 | fi 40 | 41 | sleep 1 42 | killandwait $PID 43 | 44 | restore_and_wait 45 | if [ $? -ne 0 ]; then 46 | echo "Failed initial restore" 47 | aurteardown 48 | exit 1 49 | fi 50 | 51 | restore_and_wait 52 | if [ $? -ne 0 ]; then 53 | echo "Failed second restore" 54 | aurteardown 55 | exit 1 56 | fi 57 | 58 | aurteardown 59 | if [ $? -ne 0 ]; then 60 | echo "Failed to tear down Aurora" 61 | exit 1 62 | fi 63 | 64 | exit 0 65 | -------------------------------------------------------------------------------- /tests/245-amplified-checkpoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export OID=1000 4 | 5 | . aurora 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to set up Aurora" 10 | exit 1 11 | fi 12 | 13 | ./array/array >/dev/null 2>/dev/null & 14 | PID="$!" 15 | 16 | slsctl partadd slos -o $OID -a 50 -i 17 | slsctl attach -o $OID -p $PID 18 | 19 | slsctl checkpoint -o $OID 20 | if [ $? -ne 0 ]; 21 | then 22 | echo "Checkpoint failed with $?" 23 | aurteardown 24 | exit 1 25 | fi 26 | 27 | sleep 1 28 | killandwait $PID 29 | 30 | # This call is supposed to fail. 31 | slsctl restore -o $OID >/dev/null 2>/dev/null 32 | if [ $? -eq 0 ]; 33 | then 34 | echo "Restored amplified write" 35 | aurteardown 36 | exit 1 37 | fi 38 | 39 | aurteardown 40 | if [ $? -ne 0 ]; then 41 | echo "Failed to tear down Aurora" 42 | exit 1 43 | fi 44 | 45 | exit 0 46 | -------------------------------------------------------------------------------- /tests/246-remount-sls.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | ./array/array > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slsosdcheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo Checkpoint failed 19 | exit 1 20 | fi 21 | 22 | sleep 1 23 | killandwait $PID 24 | 25 | kldunload metropolis 26 | kldunload sls 27 | kldload sls 28 | kldload metropolis 29 | 30 | slsosdrestore 31 | # Killing the workload using a signal makes the restore exit with 3. 32 | if [ $? -ne 0 ]; 33 | then 34 | echo Restore failed 35 | exit 1 36 | fi 37 | 38 | REST=$! 39 | 40 | sleep 1 41 | 42 | aurteardown 43 | if [ $? -ne 0 ]; then 44 | echo "Failed to tear down Aurora" 45 | exit 1 46 | fi 47 | 48 | wait $REST 49 | EXIT=$? 50 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 51 | then 52 | echo "Process exited with $EXIT" 53 | exit 1 54 | fi 55 | 56 | exit 0 57 | -------------------------------------------------------------------------------- /tests/247-remount-slos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | if [ $? -ne 0 ]; then 7 | echo "Failed to set up Aurora" 8 | exit 1 9 | fi 10 | 11 | ./array/array > /dev/null 2> /dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | slsosdcheckpoint $PID 16 | if [ $? -ne 0 ]; 17 | then 18 | echo Checkpoint failed 19 | exit 1 20 | fi 21 | 22 | sleep 1 23 | killandwait $PID 24 | 25 | kldunload metropolis 26 | kldunload sls 27 | slsunmount 28 | slsmount 29 | kldload sls 30 | kldload metropolis 31 | 32 | slsosdrestore 33 | # Killing the workload using a signal makes the restore exit with 3. 34 | if [ $? -ne 0 ]; 35 | then 36 | echo Restore failed 37 | exit 1 38 | fi 39 | 40 | REST=$! 41 | 42 | sleep 1 43 | 44 | aurteardown 45 | if [ $? -ne 0 ]; then 46 | echo "Failed to tear down Aurora" 47 | exit 1 48 | fi 49 | 50 | wait $REST 51 | EXIT=$? 52 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 53 | then 54 | echo "Process exited with $EXIT" 55 | exit 1 56 | fi 57 | 58 | exit 0 59 | -------------------------------------------------------------------------------- /tests/248-delta-restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | aursetup 6 | 7 | echo "$PWD" 8 | ./metroparts/metroparts -d 1>&2 & 9 | PID=$! 10 | 11 | wait $PID 12 | if [ $? -ne 0 ]; 13 | then 14 | echo "Metropolis mode failed" 15 | aurteardown 16 | exit 1 17 | fi 18 | 19 | aurteardown 20 | if [ $? -ne 0 ]; then 21 | echo "Failed to tear down Aurora" 22 | exit 1 23 | fi 24 | -------------------------------------------------------------------------------- /tests/249-pgresident.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | OID=1600 6 | FILENAME="pgresident" 7 | 8 | rm -f $FILENAME 9 | 10 | aursetup 11 | if [ $? -ne 0 ]; then 12 | echo "Failed to set up Aurora" 13 | exit 1 14 | fi 15 | 16 | slsunmount 2>&1 17 | 18 | ./array/array > /dev/null 2> /dev/null & 19 | PID=$! 20 | sleep 1 21 | 22 | slsctl partadd slos -o $OID 23 | RET=$? 24 | if [ $RET -ne 0 ]; 25 | then 26 | echo "Adding partition failed with $RET" 27 | exit 1 28 | fi 29 | 30 | slsctl attach -o $OID -p `jobid %1` 31 | RET=$? 32 | if [ $? -ne 0 ]; 33 | then 34 | echo "Attaching to partition failed with $RET" 35 | exit 1 36 | fi 37 | 38 | slsctl pgresident -o $OID -f $FILENAME 39 | RET=$? 40 | if [ $? -ne 0 ]; 41 | then 42 | echo "Page resident counting failed with $RET" 43 | exit 1 44 | fi 45 | 46 | killandwait %1 47 | 48 | #rm -f $FILENAME 49 | 50 | aurteardown 51 | if [ $? -ne 0 ]; then 52 | echo "Failed to tear down Aurora" 53 | exit 1 54 | fi 55 | 56 | exit 0 57 | -------------------------------------------------------------------------------- /tests/250-simple-file-ckpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CKPTDIR="/ckptdir" 4 | OID=10101 5 | 6 | . aurora 7 | 8 | # We need to store the checkpoints in a file system like FFS 9 | # that has ioctl() calls for seeking holes and data. 10 | ffssetup() 11 | { 12 | MD=`mdconfig -a -t malloc -s 1g` 13 | newfs "/dev/$MD" 14 | mount -t ufs "/dev/$MD" $CKPTDIR 15 | } 16 | 17 | ffsteardown() 18 | { 19 | umount $CKPTDIR 20 | mdconfig -d -u $MD 21 | rm -r $CKPTDIR 22 | } 23 | 24 | aursetup 25 | if [ $? -ne 0 ]; then 26 | echo "Failed to set up Aurora" 27 | exit 1 28 | fi 29 | 30 | # Clean up mount directory 31 | rm -rf $CKPTDIR 32 | mkdir $CKPTDIR 33 | 34 | ffssetup 35 | 36 | ./array/array > /dev/null 2> /dev/null & 37 | PID=$! 38 | sleep 1 39 | 40 | 41 | slsctl partadd file -o $OID -f $CKPTDIR 42 | if [ $? -ne 0 ]; 43 | then 44 | echo "Partadd failed" 45 | aurteardown 46 | ffsteardown 47 | exit 1 48 | fi 49 | 50 | slsctl attach -p $PID -o $OID 51 | if [ $? -ne 0 ]; 52 | then 53 | echo "Attach failed" 54 | aurteardown 55 | ffsteardown 56 | exit 1 57 | fi 58 | 59 | slsctl checkpoint -o $OID -r 60 | if [ $? -ne 0 ]; 61 | then 62 | echo Checkpoint failed 63 | aurteardown 64 | ffsteardown 65 | exit 1 66 | fi 67 | 68 | sleep 1 69 | killandwait $PID 70 | 71 | slsctl restore -o $OID & 72 | # Killing the workload using a signal makes the restore exit with 3. 73 | if [ $? -ne 0 ]; 74 | then 75 | echo Restore failed 76 | aurteardown 77 | ffsteardown 78 | exit 1 79 | fi 80 | 81 | REST=$! 82 | 83 | sleep 1 84 | 85 | aurteardown 86 | if [ $? -ne 0 ]; then 87 | echo "Failed to tear down Aurora" 88 | exit 1 89 | fi 90 | 91 | wait $REST 92 | EXIT=$? 93 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 94 | then 95 | echo "Process exited with $EXIT" 96 | exit 1 97 | fi 98 | 99 | ffsteardown 100 | 101 | exit 0 102 | -------------------------------------------------------------------------------- /tests/251-simple-socket-ckpt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | CKPTDIR="/ckptdir" 4 | SOCKOID=10101 5 | FILEOID=10102 6 | PORT=5040 7 | ADDR="127.0.0.1" 8 | 9 | . aurora 10 | 11 | # See test 250 for details. 12 | ffssetup() 13 | { 14 | MD=`mdconfig -a -t malloc -s 1g` 15 | newfs "/dev/$MD" 16 | mount -t ufs "/dev/$MD" $CKPTDIR 17 | } 18 | 19 | ffsteardown() 20 | { 21 | umount $CKPTDIR 22 | mdconfig -d -u $MD 23 | rm -r $CKPTDIR 24 | } 25 | 26 | 27 | aursetup 28 | if [ $? -ne 0 ]; then 29 | echo "Failed to set up Aurora" 30 | exit 1 31 | fi 32 | 33 | 34 | # Clean up file descriptor 35 | rm -rf $CKPTDIR 36 | mkdir -p $CKPTDIR 37 | 38 | ffssetup 39 | 40 | ./array/array > /dev/null 2> /dev/null & 41 | PID=$! 42 | sleep 1 43 | 44 | # Start up the server 45 | ../tools/server/server $CKPTDIR & 46 | SERVER=$! 47 | sleep 2 48 | 49 | slsctl partadd send -o $SOCKOID -P $PORT -A $ADDR 50 | if [ $? -ne 0 ]; 51 | then 52 | echo "Partadd failed" 53 | aurteardown 54 | ffsteardown 55 | exit 1 56 | fi 57 | 58 | slsctl attach -p $PID -o $SOCKOID 59 | if [ $? -ne 0 ]; 60 | then 61 | echo "Attach failed" 62 | aurteardown 63 | ffsteardown 64 | exit 1 65 | fi 66 | 67 | slsctl checkpoint -o $SOCKOID -r 68 | if [ $? -ne 0 ]; 69 | then 70 | echo Checkpoint failed 71 | aurteardown 72 | ffsteardown 73 | exit 1 74 | fi 75 | 76 | sleep 1 77 | killandwait $PID 78 | 79 | # Kill the server 80 | killandwait $SERVER 81 | 82 | echo "Restoring $FILEOID" 83 | slsctl restore -o $FILEOID & 84 | # Killing the workload using a signal makes the restore exit with 3. 85 | if [ $? -ne 0 ]; 86 | then 87 | echo Restore failed 88 | exit 1 89 | fi 90 | 91 | REST=$! 92 | 93 | sleep 3 94 | 95 | aurteardown 96 | if [ $? -ne 0 ]; then 97 | echo "Failed to tear down Aurora" 98 | exit 1 99 | fi 100 | 101 | wait $REST 102 | EXIT=$? 103 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 104 | then 105 | echo "Process exited with $EXIT" 106 | exit 1 107 | fi 108 | 109 | ffsteardown 110 | 111 | exit 0 112 | -------------------------------------------------------------------------------- /tests/252-simple-socket-restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SENDOID=10101 4 | RECVOID=10102 5 | PORT=5040 6 | ADDR="127.0.0.1" 7 | 8 | . aurora 9 | 10 | aursetup 11 | if [ $? -ne 0 ]; then 12 | echo "Failed to set up Aurora" 13 | exit 1 14 | fi 15 | 16 | ./array/array > /dev/null 2> /dev/null & 17 | PID=$! 18 | sleep 1 19 | 20 | # XXX Partadd for the receive 21 | slsctl partadd recv -o $RECVOID -P $PORT -A $ADDR 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Recv partadd failed" 25 | aurteardown 26 | exit 1 27 | fi 28 | 29 | slsctl partadd send -o $SENDOID -P $PORT -A $ADDR 30 | if [ $? -ne 0 ]; 31 | then 32 | echo "Send partadd failed" 33 | aurteardown 34 | exit 1 35 | fi 36 | 37 | slsctl attach -p $PID -o $SENDOID 38 | if [ $? -ne 0 ]; 39 | then 40 | echo "Attach failed" 41 | aurteardown 42 | exit 1 43 | fi 44 | 45 | slsctl checkpoint -o $SENDOID -r 46 | if [ $? -ne 0 ]; 47 | then 48 | echo Checkpoint failed 49 | aurteardown 50 | exit 1 51 | fi 52 | 53 | sleep 2 54 | killandwait $PID 55 | sleep 2 56 | 57 | echo "Restoring $RECVOID" 58 | slsctl restore -o $RECVOID & 59 | # Killing the workload using a signal makes the restore exit with 3. 60 | if [ $? -ne 0 ]; 61 | then 62 | echo Restore failed 63 | exit 1 64 | fi 65 | 66 | REST=$! 67 | 68 | sleep 3 69 | 70 | aurteardown 71 | if [ $? -ne 0 ]; then 72 | echo "Failed to tear down Aurora" 73 | exit 1 74 | fi 75 | 76 | wait $REST 77 | EXIT=$? 78 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 79 | then 80 | echo "Process exited with $EXIT" 81 | exit 1 82 | fi 83 | 84 | exit 0 85 | -------------------------------------------------------------------------------- /tests/254-delta-checkpoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | 5 | OID=1000 6 | 7 | aursetup 8 | if [ $? -ne 0 ]; then 9 | echo "Failed to set up Aurora" 10 | exit 1 11 | fi 12 | 13 | slsctl partadd slos -o $OID -d 14 | 15 | ./delta/delta >/dev/null 2>/dev/null & 16 | 17 | PID=`jobid %1` 18 | 19 | sleep 1 20 | slsctl attach -o $OID -p $PID 21 | RET=$? 22 | if [ $RET -ne 0 ]; 23 | then 24 | echo "attach failed with $RET" 25 | aurteardown 26 | exit 1 27 | fi 28 | 29 | for i in `seq 0 4`; 30 | do 31 | # Full checkpoint 32 | slsctl checkpoint -o $OID 33 | RET=$? 34 | if [ $RET -ne 0 ]; 35 | then 36 | echo "checkpoint failed with $RET" 37 | aurteardown 38 | exit 1 39 | fi 40 | done 41 | 42 | sleep 1 43 | 44 | killandwait $PID 45 | 46 | slsctl restore -o $OID & 47 | RET=$? 48 | if [ $RET -ne 0 ] && [ $RET -ne 3 ]; 49 | then 50 | echo "Restore failed with $RET" 51 | aurteardown 52 | exit 1 53 | fi 54 | 55 | REST=$! 56 | 57 | sleep 1 58 | 59 | pkill $REST 60 | 61 | aurteardown 62 | if [ $? -ne 0 ]; then 63 | echo "Failed to tear down Aurora" 64 | exit 1 65 | fi 66 | 67 | wait $REST 68 | EXIT=$? 69 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 70 | then 71 | echo "Process exited with $EXIT" 72 | exit 1 73 | fi 74 | 75 | exit 0 76 | -------------------------------------------------------------------------------- /tests/255-delta-socket.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SENDOID=10101 4 | RECVOID=10102 5 | PORT=5040 6 | ADDR="127.0.0.1" 7 | 8 | . aurora 9 | 10 | aursetup 11 | if [ $? -ne 0 ]; then 12 | echo "Failed to set up Aurora" 13 | exit 1 14 | fi 15 | 16 | ./array/array > /dev/null 2> /dev/null & 17 | PID=$! 18 | sleep 1 19 | 20 | # XXX Partadd for the receive 21 | slsctl partadd recv -o $RECVOID -P $PORT -A $ADDR -d 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Recv partadd failed" 25 | aurteardown 26 | exit 1 27 | fi 28 | 29 | slsctl partadd send -o $SENDOID -P $PORT -A $ADDR -d -t 100 30 | if [ $? -ne 0 ]; 31 | then 32 | echo "Send partadd failed" 33 | aurteardown 34 | exit 1 35 | fi 36 | 37 | slsctl attach -p $PID -o $SENDOID 38 | if [ $? -ne 0 ]; 39 | then 40 | echo "Attach failed" 41 | aurteardown 42 | exit 1 43 | fi 44 | 45 | slsctl checkpoint -o $SENDOID -r 46 | if [ $? -ne 0 ]; 47 | then 48 | echo Checkpoint failed 49 | aurteardown 50 | exit 1 51 | fi 52 | 53 | sleep 5 54 | kill $PID 55 | sleep 2 56 | 57 | aurteardown 58 | if [ $? -ne 0 ]; then 59 | echo "Failed to tear down Aurora" 60 | exit 1 61 | fi 62 | 63 | wait $REST 64 | EXIT=$? 65 | if [ $EXIT -ne 0 -a $EXIT -ne 9 ]; 66 | then 67 | echo "Process exited with $EXIT" 68 | exit 1 69 | fi 70 | 71 | exit 0 72 | -------------------------------------------------------------------------------- /tests/256-memsnap-unaligned.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | # Let the workload snapshot itself and exit with an error. 7 | "./memsnap/memsnap" -m -u > /dev/null 2> /dev/null & 8 | PID=$! 9 | sleep 1 10 | 11 | wait $PID 12 | 13 | slsrestore 14 | if [ $? -ne 0 ]; 15 | then 16 | echo "Restore failed with $?" 17 | exit 1 18 | fi 19 | 20 | # Get the error value, it should be zero. 21 | wait $! 22 | if [ $? -ne 0 ]; 23 | then 24 | echo "Process exited with nonzero" 25 | exit 1 26 | fi 27 | 28 | aurteardown 29 | if [ $? -ne 0 ]; then 30 | echo "Failed to tear down Aurora" 31 | exit 1 32 | fi 33 | 34 | exit 0 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/257-memsnap-sync.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OID=1055 4 | 5 | . aurora 6 | aursetup 7 | 8 | sleep 3 9 | 10 | # Let the workload snapshot itself and exit with an error. 11 | "./memsnap/memsnap" -s > /dev/null 2 >/dev/null & 12 | PID=$! 13 | sleep 1 14 | 15 | wait $PID 16 | 17 | slsctl restore -o $OID & 18 | PID=$! 19 | if [ $? -ne 0 ]; 20 | then 21 | echo "Restore failed with $?" 22 | exit 1 23 | fi 24 | 25 | # Get the error value, it should be zero. 26 | wait $PID 27 | RET=$? 28 | if [ $RET -ne 0 ]; 29 | then 30 | echo "Process exited with $RET" 31 | exit 1 32 | fi 33 | 34 | aurteardown 35 | if [ $? -ne 0 ]; then 36 | echo "Failed to tear down Aurora" 37 | exit 1 38 | fi 39 | 40 | exit 0 41 | 42 | 43 | -------------------------------------------------------------------------------- /tests/258-shadow-default.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=0 10 | sysctl aurora.tracebuf=0 11 | ./shadow/shadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/259-shadow-objprotect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=1 10 | sysctl aurora.tracebuf=0 11 | ./shadow/shadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/260-shadow-tracebuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=1 10 | sysctl aurora.tracebuf=1 11 | ./shadow/shadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/261-memshadow-default.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=0 10 | sysctl aurora.tracebuf=0 11 | ./memshadow/memshadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/262-memshadow-objprotect.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=1 10 | sysctl aurora.tracebuf=0 11 | ./memshadow/memshadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/263-memshadow-tracebuf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | . aurora 4 | aursetup 5 | 6 | sleep 1 7 | 8 | # Let the workload snapshot itself and exit with an error. 9 | sysctl aurora.objprotect=1 10 | sysctl aurora.tracebuf=1 11 | ./memshadow/memshadow 12 | 13 | RET=$? 14 | if [ $RET -ne 0 ]; 15 | then 16 | echo "Process exited with $RET" 17 | exit 1 18 | fi 19 | 20 | aurteardown 21 | if [ $? -ne 0 ]; then 22 | echo "Failed to tear down Aurora" 23 | exit 1 24 | fi 25 | 26 | exit 0 27 | 28 | 29 | -------------------------------------------------------------------------------- /tests/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR = array compute delta fd fifo fork forkshm forkwait journal kqueue llist main memshadow memsnap \ 2 | metrodelta metropolis mmap multithread register pipe pgroup posixshm \ 3 | print metroclient metroserver metrosimple metroparts sas sasfork sasipc sastrack selfie sharemap shadow \ 4 | signal sleep slsfs socketpair sysvshm tcplisten udplisten unixlisten unlink wal walfd 5 | 6 | BINDIR=/tmp 7 | .MAKE.EXPORTED=BINDIR 8 | 9 | .include 10 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | TESTING 2 | ======= 3 | 4 | Testing is done by running the `testbench` script from this directory. The 5 | script creates a memory disk and flashes the filesystem into it. Every test 6 | starts with a fresh filesystem and module. Assuming tests do not corrupt kernel 7 | state and properly signal failure, we can then one feature at a time and treat 8 | it as a given for all tests after that. 9 | 10 | The tests are number XYZ, where X is the category of the test, and YZ is the 11 | test number, The categories are as follows: 12 | 13 | | Code | Category | 14 | | :---: | :---------------------------------------------------: | 15 | | 0 | Basic module insertion and removal | 16 | | 1 | SLFS filesystem | 17 | | 2 | SLS microbenchmarks | 18 | | 3 | Metropolis microbenchmarks | 19 | | 4 | Performance microbenchmarks | 20 | | 5 | Aurora macrobenchmarks | 21 | | 6 | Metropolis macrobenchmarks | 22 | -------------------------------------------------------------------------------- /tests/array/.gitignore: -------------------------------------------------------------------------------- 1 | array 2 | -------------------------------------------------------------------------------- /tests/array/Makefile: -------------------------------------------------------------------------------- 1 | PROG = array 2 | SRCS = array.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/array/array.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define ARRAY_SIZE (8) 7 | #define ITERATIONS (300) 8 | 9 | int arr[ARRAY_SIZE]; 10 | 11 | int 12 | main() 13 | { 14 | printf("%d\n", getpid()); 15 | memset(arr, 0x3f, sizeof(arr)); 16 | printf("%x\n", (unsigned int)arr); 17 | for (int i = 0; i < ITERATIONS; i++) { 18 | sleep(1); 19 | printf("%d %x\n", i, arr[i % ARRAY_SIZE]++); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /tests/aurora: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | slsnewfs() 4 | { 5 | # Pipe to /dev/null if there is no log 6 | TESTLOG=${TESTLOG:-"/dev/null"} 7 | newfs_sls $DISKPATH >> $TESTLOG 2>> $TESTLOG 8 | } 9 | 10 | slsmount() 11 | { 12 | mkdir -p $MNT 13 | mount -t slsfs $DISKPATH $MNT 14 | ret=$? 15 | if [ $ret -ne 0 ]; then 16 | return $ret 17 | fi 18 | 19 | mkdir -p $MNT/dev 20 | mkdir -p $MNT/proc 21 | mount -t procfs proc $MNT/proc 22 | mount -t devfs devfs $MNT/dev 23 | mount -t fdescfs fdesc $MNT/dev/fd 24 | } 25 | 26 | slsunmount() 27 | { 28 | umount fdesc $MNT/dev/fd >/dev/null 2>/dev/null 29 | umount $MNT/dev >/dev/null 2>/dev/null 30 | umount proc $MNT/proc >/dev/null 2>/dev/null 31 | umount $MNT 32 | } 33 | 34 | aursetup() 35 | { 36 | kldload slos 37 | slsnewfs 38 | slsmount 39 | kldload sls 40 | kldload metropolis 41 | } 42 | 43 | aurteardown() 44 | { 45 | kldunload metropolis 46 | kldunload sls 47 | slsunmount 48 | kldunload slos 49 | } 50 | 51 | slscheckpoint() 52 | { 53 | slsctl attach -p $1 -m 54 | slsctl checkpoint -m -r 55 | } 56 | 57 | slsrestore() 58 | { 59 | slsctl restore -m & 60 | } 61 | 62 | slsosdcheckpoint() 63 | { 64 | slsctl attach -p $1 65 | slsctl checkpoint -r 66 | } 67 | 68 | slslazycheckpoint() 69 | { 70 | slsctl partadd slos -o $2 -l -i 71 | slsctl attach -p $1 -o $2 72 | slsctl checkpoint -o $2 -r 73 | } 74 | 75 | slsosdrestore() 76 | { 77 | slsctl restore & 78 | } 79 | 80 | slslazyrestore() 81 | { 82 | slsctl restore -o $1 & 83 | } 84 | 85 | killandwait() 86 | { 87 | kill $1 88 | wait $1 89 | } 90 | 91 | installroot() 92 | { 93 | SLSROOT="/usr/freebsd-dist/base.txz" 94 | 95 | # Unpack the root into the mount if it exists 96 | tar -C "$MNT" -xf "$SLSROOT" --exclude "proc/*" --exclude "dev/*" 97 | } 98 | -------------------------------------------------------------------------------- /tests/compute/Makefile: -------------------------------------------------------------------------------- 1 | NAME=compute 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/compute/compute.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define CYCLES (100 * 1000 * 1000L) 7 | 8 | #define BOGUS_CONSTANT (0xFF5) 9 | 10 | int 11 | main() 12 | { 13 | long long i, j; 14 | int bogus; 15 | 16 | bogus = BOGUS_CONSTANT; 17 | for (i = 0; i >= 0; i++) { 18 | for (j = 0; j < CYCLES; j++) 19 | /* 20 | * Bogus computation 21 | * to avoid optimizing 22 | * out the loop 23 | */ 24 | bogus = (bogus * BOGUS_CONSTANT) % 10; 25 | } 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/delta/Makefile: -------------------------------------------------------------------------------- 1 | NAME=delta 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/delta/delta.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define PAGE_SIZE (4096) 7 | 8 | char buf[PAGE_SIZE]; 9 | 10 | void 11 | modify() 12 | { 13 | char val = (rand() % ('z' - 'a')) + 'a'; 14 | int i; 15 | 16 | memset(buf, val, PAGE_SIZE); 17 | for (i = 0; i < PAGE_SIZE; i++) { 18 | if (buf[i] != val) { 19 | printf("INCONSISTENCY\n"); 20 | exit(1); 21 | } 22 | } 23 | memset(buf, 0, PAGE_SIZE); 24 | usleep(500 * 1000); 25 | printf("CONSISTENT\n"); 26 | } 27 | 28 | int 29 | main() 30 | { 31 | for (;;) 32 | modify(); 33 | 34 | return (0); 35 | } 36 | -------------------------------------------------------------------------------- /tests/fd/Makefile: -------------------------------------------------------------------------------- 1 | NAME=fd 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/fifo/Makefile: -------------------------------------------------------------------------------- 1 | NAME=fifo 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -lpthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/fifo/fifo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define PATH ("testfifo") 11 | #define MSG ("Message") 12 | char buf[sizeof(MSG)]; 13 | 14 | int 15 | main(int argc, char *argv[]) 16 | { 17 | int error; 18 | pid_t pid; 19 | int fd; 20 | 21 | if (argc != 2) { 22 | printf("Usage:./fifo basedir\n"); 23 | exit(1); 24 | } 25 | 26 | error = chdir(argv[1]); 27 | if (error < 0) { 28 | perror("chdir"); 29 | exit(1); 30 | } 31 | 32 | error = mkfifo(PATH, O_RDWR); 33 | if (error < 0 && errno != EEXIST) { 34 | perror("mkfifo"); 35 | exit(1); 36 | } 37 | 38 | fd = open(PATH, O_RDWR); 39 | if (fd < 0) { 40 | perror("open"); 41 | exit(1); 42 | } 43 | 44 | pid = fork(); 45 | if (pid < 0) { 46 | perror("fork"); 47 | exit(1); 48 | } 49 | 50 | if (pid == 0) { 51 | /* The child writes. */ 52 | sleep(120); 53 | write(fd, MSG, sizeof(MSG)); 54 | exit(0); 55 | } 56 | 57 | /* 58 | * The parent tries to read immediately, gets stuck. It should correctly 59 | * try to read after the restore. 60 | */ 61 | 62 | error = read(fd, buf, sizeof(MSG)); 63 | if (error < 0) { 64 | perror("read"); 65 | exit(1); 66 | } 67 | 68 | return (0); 69 | } 70 | -------------------------------------------------------------------------------- /tests/fork/Makefile: -------------------------------------------------------------------------------- 1 | PROG = fork 2 | SRCS = fork.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/fork/fork.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define ARRAY_SIZE 8 10 | 11 | int arr[ARRAY_SIZE]; 12 | 13 | int 14 | main() 15 | { 16 | int pid, status; 17 | printf("%d\n", getpid()); 18 | memset(arr, 0x3f, sizeof(arr)); 19 | printf("%x\n", (unsigned int)arr); 20 | for (int i = 0; i < 100; i++) { 21 | sleep(1); 22 | printf("%d %x\n", i, arr[i % ARRAY_SIZE]++); 23 | if ((pid = fork()) == 0) 24 | exit(0); 25 | waitpid(-1, &status, 0); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/forkshm/Makefile: -------------------------------------------------------------------------------- 1 | PROG = forkshm 2 | SRCS = forkshm.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/forkwait/Makefile: -------------------------------------------------------------------------------- 1 | PROG = forkwait 2 | SRCS = forkwait.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/forkwait/forkwait.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | void 10 | childfunction(void) 11 | { 12 | sleep(2); 13 | sleep(2); 14 | exit(0); 15 | } 16 | 17 | int 18 | main() 19 | { 20 | int pid, status; 21 | int childpid; 22 | 23 | pid = fork(); 24 | if (pid < 0) { 25 | perror("fork"); 26 | exit(1); 27 | } 28 | 29 | if (pid == 0) 30 | childfunction(); 31 | 32 | childpid = wait(&status); 33 | if (childpid < 0) { 34 | perror("wait"); 35 | exit(1); 36 | } else if (WIFEXITED(status) && WEXITSTATUS(status) != 0) { 37 | fprintf(stderr, "Process exited with status %d\n", 38 | WEXITSTATUS(status)); 39 | exit(2); 40 | } else if (WIFSIGNALED(status)) { 41 | fprintf(stderr, "Process terminated with signal %d\n", 42 | WTERMSIG(status)); 43 | exit(4); 44 | } 45 | 46 | printf("Successfully waited\n"); 47 | return (0); 48 | } 49 | -------------------------------------------------------------------------------- /tests/journal/Makefile: -------------------------------------------------------------------------------- 1 | PROG = journal 2 | SRCS = journal.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/journal/journal.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | double 10 | subtract(struct timespec a, struct timespec b) 11 | { 12 | uint64_t s = (a.tv_sec - b.tv_sec); 13 | if (a.tv_nsec < b.tv_nsec) { 14 | a.tv_nsec += 1000000000; 15 | s -= 1; 16 | } 17 | double ns_u = (float)(a.tv_nsec - b.tv_nsec) / 1000.0; 18 | double convert = s * 1000000; 19 | convert += ns_u; 20 | return convert; 21 | } 22 | 23 | double 24 | do_one(int fd, char *buf, int sz) 25 | { 26 | struct timespec sp1; 27 | struct timespec sp2; 28 | 29 | int error = clock_gettime(CLOCK_REALTIME_FAST, &sp1); 30 | if (error) { 31 | perror("clock_gettime (1)"); 32 | return -1; 33 | } 34 | 35 | if (sz) 36 | pwrite(fd, buf, sz, 0L); 37 | 38 | error = clock_gettime(CLOCK_REALTIME_FAST, &sp2); 39 | if (error) { 40 | perror("clock_gettime (2)"); 41 | return -1; 42 | } 43 | double time = subtract(sp2, sp1); 44 | 45 | return time; 46 | } 47 | 48 | int 49 | main(int argc, char *argv[]) 50 | { 51 | if (argc != 3) { 52 | printf("./main \n"); 53 | return -1; 54 | } 55 | char *ptr; 56 | /* Create an in-memory buffer to be flushed. */ 57 | long int size = strtol(argv[2], &ptr, 10); 58 | char *buf = malloc(size); 59 | int fd = open(argv[1], O_RDWR); 60 | if (fd == -1) { 61 | perror("open"); 62 | return -1; 63 | } 64 | 65 | #define NSAMPLES 5 66 | double samples[NSAMPLES]; 67 | double baseline; 68 | 69 | /* Get the baseline latency. */ 70 | for (int i = 0; i < NSAMPLES; i++) 71 | baseline += do_one(fd, buf, 0); 72 | baseline /= NSAMPLES; 73 | 74 | /* Get the average latency of the sample minus the baseline. */ 75 | for (int i = 0; i < NSAMPLES; i++) 76 | samples[i] = do_one(fd, buf, size) - baseline; 77 | 78 | double avg = 0; 79 | for (int i = 1; i < NSAMPLES; i++) 80 | avg += samples[i]; 81 | 82 | avg /= (NSAMPLES - 1); 83 | 84 | printf("%.0fus\n", avg); 85 | 86 | return (0); 87 | } 88 | -------------------------------------------------------------------------------- /tests/kqueue/Makefile: -------------------------------------------------------------------------------- 1 | NAME=kqueue 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | MAN= 6 | 7 | .include 8 | -------------------------------------------------------------------------------- /tests/llist/Makefile: -------------------------------------------------------------------------------- 1 | NAME=llist 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -static 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/main/Makefile: -------------------------------------------------------------------------------- 1 | LDADD= -lsls -lsbuf 2 | LDFLAGS= -L../../libsls 3 | CFLAGS= -I../../include 4 | 5 | PROG = main 6 | SRCS = main.c 7 | CFLAGS += 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/memshadow/Makefile: -------------------------------------------------------------------------------- 1 | NAME=memshadow 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/memsnap/Makefile: -------------------------------------------------------------------------------- 1 | NAME=memsnap 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metroclient/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metroclient 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metrodelta/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metrodelta 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metroparts/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metroparts 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metropolis/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metropolis 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metroserver/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metroserver 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/metrosimple/Makefile: -------------------------------------------------------------------------------- 1 | NAME=metrosimple 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/mmap/Makefile: -------------------------------------------------------------------------------- 1 | NAME=mmap 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/mmap/mmap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define MMAP_SIZE (PAGE_SIZE * 64) 13 | 14 | static int 15 | mmap_file(void **addr) 16 | { 17 | void *mapping; 18 | int error; 19 | int fd; 20 | 21 | fd = open("testfile", O_RDWR | O_TRUNC | O_CREAT, 0666); 22 | if (fd < 0) { 23 | perror("open"); 24 | close(fd); 25 | return (-1); 26 | } 27 | 28 | /* Make sure the file is large enough. */ 29 | error = lseek(fd, MMAP_SIZE - 1, SEEK_SET); 30 | assert(error > 0); 31 | 32 | error = write(fd, "", 1); 33 | assert(error >= 0); 34 | 35 | mapping = mmap( 36 | NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 37 | if (mapping == MAP_FAILED) { 38 | perror("mmap"); 39 | close(fd); 40 | return (-1); 41 | } 42 | 43 | *addr = mapping; 44 | 45 | close(fd); 46 | return (0); 47 | } 48 | 49 | static int 50 | mmap_anon(void **addr) 51 | { 52 | void *mapping; 53 | 54 | mapping = mmap(NULL, MMAP_SIZE, PROT_READ | PROT_WRITE, 55 | MAP_ANON | MAP_PRIVATE, -1, 0); 56 | if (mapping == MAP_FAILED) { 57 | perror("mmap"); 58 | return (-1); 59 | } 60 | 61 | *addr = mapping; 62 | return (0); 63 | } 64 | 65 | int 66 | main(int argc, char **argv) 67 | { 68 | int error; 69 | void *mapping; 70 | int i; 71 | 72 | if (argc != 3) { 73 | printf("Usage:./mmap basedir \n"); 74 | exit(1); 75 | } 76 | 77 | error = chdir(argv[1]); 78 | if (error < 0) { 79 | perror("chdir"); 80 | exit(1); 81 | } 82 | 83 | if (strcmp(argv[2], "anon") == 0) 84 | error = mmap_anon(&mapping); 85 | else if (strcmp(argv[2], "file") == 0) 86 | error = mmap_file(&mapping); 87 | else 88 | error = EINVAL; 89 | 90 | if (error != 0) { 91 | printf("Error %d\n", error); 92 | exit(1); 93 | } 94 | 95 | memset(mapping, 'a', MMAP_SIZE); 96 | 97 | sleep(5); 98 | 99 | for (i = 0; i < MMAP_SIZE; i++) { 100 | if (((char *)mapping)[i] != 'a') { 101 | printf("Error\n"); 102 | exit(1); 103 | } 104 | } 105 | 106 | printf("Success\n"); 107 | 108 | return (0); 109 | } 110 | -------------------------------------------------------------------------------- /tests/multithread/Makefile: -------------------------------------------------------------------------------- 1 | NAME=multithread 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -pthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/multithread/multithread.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | /* Constants */ 7 | #define NUMTHREADS (5) 8 | #define SLEEPTIME (1) 9 | #define CYCLES (100 * 1000 * 1000) 10 | 11 | /* 12 | * Each value causes a different action in the 13 | * thread function. 14 | */ 15 | enum action { 16 | NOTHING, 17 | SLEEP, 18 | COMPUTE, 19 | PRINT, 20 | NUM_ACTIONS, 21 | }; 22 | 23 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 24 | 25 | /* 26 | * Exists solely to confuse -O2 compilation and 27 | * prevent the computational loop from being 28 | * optimized out. 29 | */ 30 | int compute_var[NUMTHREADS]; 31 | 32 | int 33 | payload(enum action payload_action, void *data) 34 | { 35 | int i = 0; 36 | long long threadno; 37 | 38 | threadno = (long long)data; 39 | 40 | switch (payload_action) { 41 | 42 | case NOTHING: 43 | break; 44 | 45 | case SLEEP: 46 | sleep(SLEEPTIME); 47 | break; 48 | 49 | case COMPUTE: 50 | /* Totally bogus computation */ 51 | for (i = 0; i < CYCLES; i++) 52 | compute_var[threadno] = (compute_var[threadno] + 127) % 53 | 37; 54 | break; 55 | 56 | case PRINT: 57 | printf("Thread %lld printing %d\n", threadno, 58 | compute_var[threadno]); 59 | break; 60 | 61 | default: 62 | printf("ERROR: INVALID PAYLOAD\n"); 63 | exit(1); 64 | } 65 | 66 | return i; 67 | } 68 | 69 | void * 70 | thread_func(void *data) 71 | { 72 | 73 | for (;;) { 74 | pthread_mutex_lock(&mutex); 75 | payload(COMPUTE, data); 76 | payload(PRINT, data); 77 | pthread_mutex_unlock(&mutex); 78 | payload(COMPUTE, data); 79 | } 80 | 81 | pthread_exit(NULL); 82 | } 83 | 84 | int 85 | main() 86 | { 87 | pthread_t threads[NUMTHREADS]; 88 | long long i; 89 | 90 | for (i = 0; i < NUMTHREADS; i++) 91 | pthread_create(&threads[i], NULL, thread_func, (void *)i); 92 | 93 | pthread_exit(NULL); 94 | } 95 | -------------------------------------------------------------------------------- /tests/pgroup/Makefile: -------------------------------------------------------------------------------- 1 | PROG = pgroup 2 | SRCS = pgroup.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/pipe/Makefile: -------------------------------------------------------------------------------- 1 | PROG = pipe 2 | SRCS = pipe.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/pipe/pipe.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #define MSG ("Message") 11 | char buf[sizeof(MSG)]; 12 | 13 | int 14 | main(int argc, char *argv[]) 15 | { 16 | int error; 17 | int pipes[2]; 18 | pid_t pid; 19 | 20 | error = pipe(pipes); 21 | if (error < 0) { 22 | perror("pipe"); 23 | exit(1); 24 | } 25 | 26 | pid = fork(); 27 | if (pid < 0) { 28 | perror("fork"); 29 | exit(1); 30 | } 31 | 32 | if (pid == 0) { 33 | /* The child writes. */ 34 | sleep(120); 35 | write(pipes[1], MSG, sizeof(MSG)); 36 | exit(0); 37 | } 38 | 39 | /* 40 | * The parent tries to read immediately, gets stuck. It should correctly 41 | * try to read after the restore. 42 | */ 43 | 44 | error = read(pipes[0], buf, sizeof(MSG)); 45 | if (error < 0) { 46 | perror("read"); 47 | exit(1); 48 | } 49 | 50 | return (0); 51 | } 52 | -------------------------------------------------------------------------------- /tests/posixshm/Makefile: -------------------------------------------------------------------------------- 1 | NAME=posixshm 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/posixshm/posixshm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define POSIXPATH ("/fake/path/posixshm") 13 | #define SHM_SIZE (4096) 14 | 15 | int 16 | main() 17 | { 18 | key_t key; 19 | pid_t pid; 20 | char *shm; 21 | uint8_t *mtx; 22 | int error, i; 23 | int fd; 24 | char c; 25 | 26 | fd = shm_open(POSIXPATH, O_RDWR | O_CREAT, 0666); 27 | if (fd < 0) { 28 | perror("shm_open"); 29 | exit(1); 30 | } 31 | 32 | shm_unlink(POSIXPATH); 33 | 34 | error = ftruncate(fd, getpagesize()); 35 | if (error != 0) { 36 | perror("ftruncate"); 37 | exit(1); 38 | } 39 | 40 | shm = (char *)mmap( 41 | NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 42 | if (shm == MAP_FAILED) { 43 | perror("mmap"); 44 | exit(1); 45 | } 46 | 47 | c = 'a' + (random() % ('z' - 'a' + 1)); 48 | memset(shm, c, SHM_SIZE); 49 | munmap(shm, SHM_SIZE); 50 | 51 | sleep(5); 52 | 53 | shm = (char *)mmap( 54 | NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); 55 | if (shm == MAP_FAILED) { 56 | perror("mmap"); 57 | exit(1); 58 | } 59 | 60 | for (i = 0; i < SHM_SIZE; i++) { 61 | if (shm[i] != c) { 62 | printf("Found byte '%d' instead of %d", shm[i], c); 63 | exit(1); 64 | } 65 | } 66 | 67 | close(fd); 68 | printf("Done.\n"); 69 | 70 | return 0; 71 | } 72 | -------------------------------------------------------------------------------- /tests/print/Makefile: -------------------------------------------------------------------------------- 1 | NAME=print 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/print/print.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define CYCLES (100 * 1000 * 1000L) 7 | 8 | #define BOGUS_CONSTANT (0xFF5) 9 | 10 | int 11 | main() 12 | { 13 | long long i, j; 14 | int bogus; 15 | 16 | bogus = BOGUS_CONSTANT; 17 | for (i = 0; i >= 0; i++) { 18 | for (j = 0; j < CYCLES; j++) 19 | /* 20 | * Bogus computation 21 | * to avoid optimizing 22 | * out the loop 23 | */ 24 | bogus = (bogus * BOGUS_CONSTANT) % 10; 25 | printf("%d %lld\n", bogus, i); 26 | } 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /tests/register/Makefile: -------------------------------------------------------------------------------- 1 | NAME=register 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -pthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/register/register.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define CYCLES (1000 * 1000 * 1000) 5 | 6 | int 7 | main() 8 | { 9 | volatile register uint64_t r13 asm("r13"); 10 | volatile register uint64_t r14 asm("r14"); 11 | volatile register uint64_t r15 asm("r15"); 12 | 13 | /* XXX We cannot use these registers it seems. 14 | volatile register uint16_t cs asm ("cs"); 15 | volatile register uint16_t ds asm ("ds"); 16 | volatile register uint16_t es asm ("es"); 17 | volatile register uint16_t fs asm ("fs"); 18 | volatile register uint16_t gs asm ("gs"); 19 | volatile register uint16_t ss asm ("ss"); 20 | */ 21 | 22 | uint16_t fs; 23 | 24 | for (;;) { 25 | r13 = r14 = 0; 26 | 27 | for (r15 = 0; r15 < CYCLES; r15++) { 28 | r13 += 1; 29 | r14 += 2; 30 | } 31 | 32 | asm volatile("mov %%fs, %0\n\t" : "=r"(fs)); 33 | 34 | printf("fs %u\n", fs); 35 | printf("r13 %lu\tr14 %lu\n", r13, r14); 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /tests/sas/Makefile: -------------------------------------------------------------------------------- 1 | NAME = sas 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/sasfork/Makefile: -------------------------------------------------------------------------------- 1 | NAME = sasfork 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/sasipc/Makefile: -------------------------------------------------------------------------------- 1 | NAME = sasipc 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/sastrack/Makefile: -------------------------------------------------------------------------------- 1 | NAME = sastrack 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/selfie/Makefile: -------------------------------------------------------------------------------- 1 | NAME=selfie 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/selfie/selfie.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | int 14 | main(int argc, char **argv) 15 | { 16 | void *addr; 17 | int error; 18 | 19 | printf("1\n"); 20 | /* Attach ourselves to the partition. */ 21 | error = sls_attach(SLS_DEFAULT_MPARTITION, getpid()); 22 | if (error != 0) 23 | exit(1); 24 | 25 | printf("2\n"); 26 | /* Do a full checkpoint. */ 27 | error = sls_checkpoint(SLS_DEFAULT_MPARTITION, false); 28 | if (error != 0) 29 | exit(1); 30 | 31 | printf("3\n"); 32 | /* If we restore successfully, sleep for a bit and exit. */ 33 | sleep(2); 34 | 35 | return (0); 36 | } 37 | -------------------------------------------------------------------------------- /tests/shadow/Makefile: -------------------------------------------------------------------------------- 1 | NAME=shadow 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/sharemap/Makefile: -------------------------------------------------------------------------------- 1 | PROG = sharemap 2 | SRCS = sharemap.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/sharemap/sharemap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define FILE_SIZE (128 * 4096) 13 | 14 | void *sharemap; 15 | 16 | void 17 | ping() 18 | { 19 | int ret; 20 | 21 | printf("%d\n", getpid()); 22 | 23 | for (;;) { 24 | sleep(1); 25 | 26 | while (atomic_cmpset_int((u_int *)sharemap, 0, 1) == 0) 27 | ; 28 | 29 | printf("ping\n"); 30 | } 31 | } 32 | 33 | void 34 | pong() 35 | { 36 | int ret; 37 | 38 | printf("%d\n", getpid()); 39 | 40 | for (;;) { 41 | sleep(1); 42 | 43 | while (atomic_cmpset_int((u_int *)sharemap, 1, 0) == 0) 44 | ; 45 | 46 | printf("pong\n"); 47 | } 48 | } 49 | 50 | int 51 | main(int argc, char **argv) 52 | { 53 | pid_t pid; 54 | int error; 55 | 56 | if (argc != 1) { 57 | printf("Usage: ./sharemap\n"); 58 | return 0; 59 | } 60 | 61 | sharemap = mmap(NULL, FILE_SIZE, PROT_READ | PROT_WRITE, 62 | MAP_SHARED | MAP_ANON, -1, 0); 63 | 64 | if (sharemap == MAP_FAILED) { 65 | perror("mmap"); 66 | return (0); 67 | } 68 | 69 | printf("%p\n", sharemap); 70 | printf("%d\n", *((int *)sharemap)); 71 | 72 | *((int *)sharemap) = 0; 73 | 74 | pid = fork(); 75 | if (pid == 0) 76 | pong(); 77 | else if (pid > 0) 78 | ping(); 79 | else 80 | perror("fork"); 81 | 82 | return (0); 83 | } 84 | -------------------------------------------------------------------------------- /tests/signal/Makefile: -------------------------------------------------------------------------------- 1 | NAME=signal 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -O0 -pthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/signal/signal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #define SIGMSG ("SIGUSR1 handler called successfully.\n") 7 | 8 | void 9 | handle_sigusr(int signal) 10 | { 11 | char *msg = SIGMSG; 12 | 13 | write(STDOUT_FILENO, SIGMSG, sizeof(SIGMSG)); 14 | exit(0); 15 | } 16 | 17 | int 18 | main() 19 | { 20 | struct sigaction sa; 21 | int i; 22 | void *addr; 23 | 24 | sa.sa_handler = handle_sigusr; 25 | sa.sa_flags = SA_RESTART; 26 | 27 | sigfillset(&sa.sa_mask); 28 | 29 | if (sigaction(SIGUSR1, &sa, NULL) < 0) { 30 | printf("Setting up SIGUSR failed.\n"); 31 | exit(1); 32 | } 33 | 34 | sleep(5); 35 | 36 | printf("Waiting for the signal...\n"); 37 | 38 | sleep(1000); 39 | printf("Signal never arrived\n"); 40 | 41 | exit(1); 42 | } 43 | -------------------------------------------------------------------------------- /tests/sleep/Makefile: -------------------------------------------------------------------------------- 1 | NAME=sleep 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -lpthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/sleep/sleep.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int 5 | main() 6 | { 7 | int i; 8 | 9 | for (i = 0; i >= 0; i++) { 10 | sleep(1); 11 | printf("%d\n", i); 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /tests/slsfs/Makefile: -------------------------------------------------------------------------------- 1 | NAME=file 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += -lpthread 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/slsfs/file.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int 10 | main() 11 | { 12 | int error; 13 | 14 | int fd = open("/testmnt/test.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); 15 | ssize_t size = pwrite(fd, "hello", 5, 10000); 16 | if (size == -1) { 17 | printf("%s - uh oh", strerror(errno)); 18 | return 1; 19 | } 20 | if (size != 5) { 21 | printf("%s - uh oh", strerror(errno)); 22 | return 1; 23 | } 24 | char ding[255]; 25 | size = pread(fd, ding, 255, 0); 26 | printf("%zd read\n", size); 27 | if (size == -1) { 28 | printf("%s - uh oh", strerror(errno)); 29 | return -1; 30 | } 31 | ding[size + 1] = '\0'; 32 | printf("I read: %s\n", ding); 33 | close(fd); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /tests/socketpair/Makefile: -------------------------------------------------------------------------------- 1 | NAME=socketpair 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/socketpair/socketpair.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | int 11 | main(void) 12 | { 13 | pid_t pid; 14 | int error; 15 | int sv[2]; /* the pair of socket descriptors */ 16 | char buf; /* for data exchange between processes */ 17 | 18 | if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == -1) { 19 | perror("socketpair"); 20 | exit(0); 21 | } 22 | 23 | pid = fork(); 24 | if (pid < 0) { 25 | perror("fork"); 26 | exit(0); 27 | } 28 | 29 | if (pid > 0) { 30 | for (;;) { 31 | error = read(sv[1], &buf, 1); 32 | if (error == -1) { 33 | perror("read"); 34 | continue; 35 | } 36 | 37 | printf("%c\n", buf); 38 | } 39 | 40 | } else { 41 | for (;;) { 42 | error = write(sv[0], "b", 1); 43 | if (error == -1) { 44 | perror("write"); 45 | continue; 46 | } 47 | 48 | sleep(1); 49 | } 50 | } 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /tests/sysvshm/Makefile: -------------------------------------------------------------------------------- 1 | NAME=sysvshm 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/sysvshm/sysvshm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define SHM_SIZE (4096) 13 | 14 | char * 15 | getsysvshm(key_t key, int *shmid, int flag) 16 | { 17 | char *shm; 18 | 19 | *shmid = shmget(key, SHM_SIZE, flag | 0666); 20 | if (*shmid < 0) { 21 | shmctl(*shmid, IPC_RMID, NULL); 22 | perror("shmget"); 23 | exit(1); 24 | } 25 | 26 | /* 27 | * Temporarily attach the segment to initialize the first byte, 28 | * which we will be using it for arbitrating access to the buffer. 29 | */ 30 | shm = (char *)shmat(*shmid, 0, 0); 31 | if (shm == (void *)-1) { 32 | perror("shmat"); 33 | shmctl(*shmid, IPC_RMID, NULL); 34 | exit(1); 35 | } 36 | 37 | return (shm); 38 | } 39 | 40 | int 41 | main() 42 | { 43 | char path[1024]; 44 | key_t key; 45 | char *shm; 46 | int shmid; 47 | int error; 48 | char *ret; 49 | char c; 50 | int i; 51 | 52 | ret = getcwd(path, 1024); 53 | if (ret == NULL) { 54 | perror("getcwd"); 55 | exit(1); 56 | } 57 | 58 | key = ftok(path, 0); 59 | if (key < 0) { 60 | perror("ftok"); 61 | exit(1); 62 | } 63 | 64 | shm = getsysvshm(key, &shmid, IPC_CREAT); 65 | 66 | c = 'a' + (random() % ('z' - 'a' + 1)); 67 | memset(shm, c, SHM_SIZE); 68 | 69 | error = shmdt(shm); 70 | if (error != 0) { 71 | perror("shmdt"); 72 | shmctl(shmid, IPC_RMID, NULL); 73 | exit(1); 74 | } 75 | 76 | sleep(200); 77 | 78 | shm = getsysvshm(key, &shmid, 0); 79 | for (i = 0; i < SHM_SIZE; i++) { 80 | if (shm[i] != c) { 81 | printf("Found byte '%d' instead of %d", shm[i], c); 82 | shmdt(shm); 83 | shmctl(shmid, IPC_RMID, NULL); 84 | exit(1); 85 | } 86 | } 87 | 88 | error = shmdt(shm); 89 | if (error != 0) { 90 | perror("shmdt"); 91 | shmctl(shmid, IPC_RMID, NULL); 92 | exit(1); 93 | } 94 | 95 | error = shmctl(shmid, IPC_RMID, NULL); 96 | if (error != 0) { 97 | perror("shmctl"); 98 | exit(1); 99 | } 100 | printf("SYSV test succeeded\n"); 101 | 102 | return (0); 103 | } 104 | -------------------------------------------------------------------------------- /tests/tcplisten/Makefile: -------------------------------------------------------------------------------- 1 | NAME=tcplisten 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/testbench.blacklist: -------------------------------------------------------------------------------- 1 | 014-remount-check.sh 2 | 229-chroot.sh 3 | 230-chroot-devfs.sh 4 | 232-metropolis.sh 5 | 233-metropolis-fork.sh 6 | 234-metropolis-exec.sh 7 | 235-metropolis-accept.sh 8 | 236-metropolis-exit.sh 9 | 237-metropolis-accept4.sh 10 | 238-metropolis-simple.sh 11 | 239-metropolis-pymetro-multiple.sh 12 | 240-metropolis-partitions.sh 13 | 241-metropolis-partitions-cached.sh 14 | -------------------------------------------------------------------------------- /tests/udplisten/Makefile: -------------------------------------------------------------------------------- 1 | NAME=udplisten 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/udplisten/udplisten.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define LOCALHOST ("127.0.0.1") 15 | #define SOCKET (6668) 16 | #define BACKLOG (4) 17 | #define MSG ("message") 18 | #define BUFSIZE (sizeof(MSG)) 19 | 20 | char buf[BUFSIZE]; 21 | 22 | int 23 | main(void) 24 | { 25 | struct sockaddr_in sockaddr; 26 | ssize_t datalen; 27 | int sock; 28 | size_t len; 29 | int error; 30 | 31 | sock = socket(AF_INET, SOCK_DGRAM, 0); 32 | if (sock == -1) { 33 | perror("socket"); 34 | exit(0); 35 | } 36 | 37 | sockaddr.sin_family = AF_INET; 38 | sockaddr.sin_port = htons(SOCKET); 39 | error = inet_pton(AF_INET, LOCALHOST, &sockaddr.sin_addr.s_addr); 40 | if (error == -1) { 41 | perror("inet_pton"); 42 | exit(0); 43 | } 44 | 45 | error = bind(sock, (struct sockaddr *)&sockaddr, sizeof(sockaddr)); 46 | if (error == -1) { 47 | perror("bind"); 48 | exit(0); 49 | } 50 | 51 | sleep(5); 52 | memset(buf, 0, BUFSIZE); 53 | datalen = recv(sock, buf, BUFSIZE, 0); 54 | if (datalen == -1) { 55 | perror("recv"); 56 | exit(1); 57 | } 58 | 59 | if (strncmp(buf, MSG, BUFSIZE)) { 60 | printf("Got %s instead of %s\n", buf, MSG); 61 | exit(1); 62 | } 63 | 64 | printf("Data received: %s\n", buf); 65 | printf("Server done.\n"); 66 | 67 | return (0); 68 | } 69 | -------------------------------------------------------------------------------- /tests/unixlisten/Makefile: -------------------------------------------------------------------------------- 1 | NAME=unixlisten 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | CFLAGS += 6 | MAN= 7 | 8 | .include 9 | -------------------------------------------------------------------------------- /tests/unixlisten/unixlisten.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #define UNADDR ("localsocket") 15 | /* Found by inspecting struct sockaddr_un. */ 16 | #define UNADDR_MAX (108) 17 | #define BUFSIZE (1024) 18 | 19 | char buf[BUFSIZE]; 20 | 21 | int 22 | main(void) 23 | { 24 | struct sockaddr_un local, remote; 25 | int lstsock, rcvsock; 26 | socklen_t addrlen; 27 | ssize_t msglen; 28 | int error; 29 | 30 | local.sun_family = AF_UNIX; 31 | strlcpy(local.sun_path, UNADDR, UNADDR_MAX); 32 | 33 | /* Create the blank socket. */ 34 | lstsock = socket(AF_UNIX, SOCK_STREAM, 0); 35 | if (lstsock == -1) { 36 | perror("socket"); 37 | exit(0); 38 | } 39 | 40 | /* Bind it to the address given in sockaddr_in. */ 41 | error = bind(lstsock, (struct sockaddr *)&local, sizeof(local)); 42 | if (error == -1) { 43 | perror("bind"); 44 | exit(0); 45 | } 46 | 47 | error = listen(lstsock, 512); 48 | if (error == -1) { 49 | perror("listen"); 50 | exit(0); 51 | } 52 | 53 | for (;;) { 54 | printf("Waiting for a connection...\n"); 55 | 56 | addrlen = sizeof(remote); 57 | rcvsock = accept(lstsock, (struct sockaddr *)&remote, &addrlen); 58 | if (rcvsock < 0) { 59 | perror("accept"); 60 | exit(0); 61 | } 62 | printf("Connection received.\n"); 63 | 64 | for (;;) { 65 | msglen = recv(rcvsock, &buf, BUFSIZE, 0); 66 | if (msglen < 0) { 67 | perror("recv"); 68 | exit(0); 69 | } 70 | 71 | if (msglen == 0) 72 | break; 73 | 74 | printf("Received: %s\n", buf); 75 | } 76 | 77 | printf("Connection done.\n"); 78 | } 79 | 80 | exit(0); 81 | } 82 | -------------------------------------------------------------------------------- /tests/unlink/Makefile: -------------------------------------------------------------------------------- 1 | PROG = unlink 2 | SRCS = unlink.c 3 | CFLAGS += 4 | MAN = 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tests/unlink/unlink.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /* The working set size in pages */ 10 | #define MEMSIZE (4) 11 | #define FILENAME ("/tmp/unlink") 12 | 13 | int 14 | main() 15 | { 16 | char *array; 17 | int error; 18 | int fd; 19 | int i; 20 | 21 | array = (char *)malloc(MEMSIZE * PAGE_SIZE); 22 | if (array == NULL) { 23 | printf("Error: malloc failed\n"); 24 | return 0; 25 | } 26 | 27 | fd = open(FILENAME, O_CREAT | O_RDWR); 28 | if (fd < 0) { 29 | perror("open"); 30 | return 0; 31 | } 32 | 33 | error = unlink(FILENAME); 34 | if (error != 0) { 35 | printf("Error: Unlink failed with %d", error); 36 | return 0; 37 | } 38 | 39 | for (;;) { 40 | for (i = 0; i < MEMSIZE; i++) 41 | array[i * PAGE_SIZE] = 'a' + (random() % ('z' - 'a')); 42 | } 43 | 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /tests/wal/Makefile: -------------------------------------------------------------------------------- 1 | NAME = wal 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/wal/wal.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int 9 | main() 10 | { 11 | struct sls_wal wal; 12 | int forty_two = 42, twenty_four = 24; 13 | int value; 14 | 15 | if (sls_wal_open(&wal, SLS_DEFAULT_PARTITION, 4096) != 0) { 16 | perror("sls_wal_open()"); 17 | return (EXIT_FAILURE); 18 | } 19 | 20 | sls_wal_memcpy(&wal, &value, &twenty_four, sizeof(value)); 21 | printf("value: %d\n", value); 22 | 23 | if (sls_wal_savepoint(&wal) != 0) { 24 | perror("sls_wal_sync()"); 25 | return (EXIT_FAILURE); 26 | } 27 | 28 | value = 0; 29 | sls_wal_replay(&wal); 30 | printf("value: %d\n", value); 31 | 32 | if (value == 42) { 33 | goto done; 34 | } else if (value != 24) { 35 | fprintf(stderr, "Unexpected value %d\n", value); 36 | return (EXIT_FAILURE); 37 | } 38 | 39 | sls_wal_memcpy(&wal, &value, &forty_two, sizeof(value)); 40 | printf("value: %d\n", value); 41 | 42 | if (sls_wal_sync(&wal) != 0) { 43 | perror("sls_wal_sync()"); 44 | return (EXIT_FAILURE); 45 | } 46 | 47 | done: 48 | if (sls_wal_close(&wal) != 0) { 49 | perror("sls_wal_close()"); 50 | return (EXIT_FAILURE); 51 | } 52 | 53 | return (value == 42 ? EXIT_SUCCESS : EXIT_FAILURE); 54 | } 55 | -------------------------------------------------------------------------------- /tests/walfd/Makefile: -------------------------------------------------------------------------------- 1 | NAME = walfd 2 | 3 | PROG = $(NAME) 4 | SRC = $(NAME).c 5 | LDADD = -lsls 6 | LDFLAGS = -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN = 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tests/walfd/walfd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define KB (1024) 16 | #define MB (1024 * KB) 17 | #define GB (1024 * MB) 18 | 19 | int 20 | main() 21 | { 22 | char readme[256]; 23 | memset(readme, '\0', 256); 24 | char mywrite[MB]; 25 | int rand = open("/dev/random", O_RDONLY); 26 | int written; 27 | int total_write = 0; 28 | 29 | int wal_fd = slsfs_create_wal("test_wal.log", O_RDWR, 0600, 1 * GB); 30 | if (wal_fd < 0) { 31 | return -1; 32 | } 33 | 34 | written = read(rand, mywrite, MB); 35 | if (written != MB) { 36 | perror("Problem reading random"); 37 | return errno; 38 | } 39 | 40 | for (int i = 0; i < 1024; i++) { 41 | written = write(wal_fd, mywrite, MB); 42 | if (written != MB) { 43 | perror("Problem writing to the WAL"); 44 | return errno; 45 | } 46 | total_write += MB; 47 | } 48 | written = write(wal_fd, mywrite, MB); 49 | if (errno != ENOMEM) { 50 | printf("Should be an error\n"); 51 | return -1; 52 | } 53 | 54 | if (total_write != GB) { 55 | printf("Not enough written"); 56 | return -1; 57 | } 58 | 59 | fsync(wal_fd); 60 | 61 | written = pread(wal_fd, readme, 256, 0); 62 | if (written < 0) { 63 | perror("Problem reading from the WAL"); 64 | return errno; 65 | } 66 | 67 | close(wal_fd); 68 | 69 | if (strncmp(readme, mywrite, 10) != 0) { 70 | printf("What was written to the WAL was not what was read\n"); 71 | return -1; 72 | } 73 | 74 | int reg_fd = open("test_wal.log", O_RDWR); 75 | if (reg_fd < 0) { 76 | perror("Could not open file"); 77 | return -1; 78 | } 79 | 80 | written = read(reg_fd, readme, 256); 81 | if (written < 0) { 82 | perror("Did not properly read back WAL in regular open path"); 83 | return errno; 84 | } 85 | 86 | if (strncmp(readme, mywrite, 10) != 0) { 87 | perror( 88 | "What was written to the W#AL was not what was read in regular open"); 89 | return -1; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /tools/Makefile: -------------------------------------------------------------------------------- 1 | SUBDIR = slsctl newfs_sls radixdbg slsdb server 2 | 3 | BINDIR=/sbin 4 | .MAKE.EXPORTED=BINDIR 5 | 6 | .include 7 | -------------------------------------------------------------------------------- /tools/newfs_sls/Makefile: -------------------------------------------------------------------------------- 1 | PROG= newfs_sls 2 | SRCS= newfs_sls.c 3 | MAN= 4 | 5 | 6 | LDFLAGS= -L../../libsls 7 | CFLAGS= -I../../include 8 | 9 | .include 10 | -------------------------------------------------------------------------------- /tools/radixdbg/Makefile: -------------------------------------------------------------------------------- 1 | PROG= radixdbg 2 | SRCS= radixdbg.c radixnode.c 3 | MAN= 4 | 5 | 6 | LDADD= -ledit 7 | LDFLAGS= -L../../libsls 8 | CFLAGS= -I../../include 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tools/radixdbg/radixdbg.h: -------------------------------------------------------------------------------- 1 | #ifndef _RADIX_DB_H_ 2 | #define _RADIX_DB_H_ 3 | 4 | #include 5 | 6 | #define SECTORSIZE (512) 7 | #define BLKSIZE (4096) 8 | #define EPOCH_INVAL (UINT64_MAX) 9 | 10 | #endif /* _RADIX_DB_H_ */ 11 | -------------------------------------------------------------------------------- /tools/radixdbg/radixnode.h: -------------------------------------------------------------------------------- 1 | #ifndef _SRDX_H_ 2 | #define _SRDX_H_ 3 | 4 | #define STREE_INVAL \ 5 | ((diskblk_t) { 0xbabababababababaULL, 0xcdcdcdcdcdcdcdcdULL }) 6 | #define STREE_VALSIZE (sizeof(diskblk_t)) 7 | #define STREE_VALVALID(value) ((value).offset != STREE_INVAL.offset) 8 | 9 | #define STREE_DEPTH (5) 10 | #define SRDXCAP (BLKSIZE / STREE_VALSIZE) 11 | #define SRDXMASK (SRDXCAP - 1) 12 | #define SRDXVAL(srdx, i) (((diskblk_t *)(srdx))[(i)]) 13 | #define KEYMAX ((SRDXCAP * SRDXCAP * SRDXCAP * SRDXCAP * SRDXCAP)) 14 | 15 | typedef void *rdxnode; 16 | 17 | struct stree_iter { 18 | rdxnode siter_nodes[STREE_DEPTH]; 19 | uint64_t siter_key; 20 | diskblk_t siter_value; 21 | }; 22 | 23 | int siter_start(int fd, uint64_t root, uint64_t key, struct stree_iter *siter); 24 | int siter_iter(int fd, struct stree_iter *siter); 25 | void siter_end(struct stree_iter *siter); 26 | 27 | #endif /* _SRDX_H_ */ 28 | -------------------------------------------------------------------------------- /tools/server/Makefile: -------------------------------------------------------------------------------- 1 | NAME=server 2 | 3 | PROG= $(NAME) 4 | SRC= $(NAME).c 5 | LDADD= -lsls 6 | LDFLAGS= -L../../libsls 7 | CFLAGS += -I../../include -g 8 | MAN= 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tools/slsctl/Makefile: -------------------------------------------------------------------------------- 1 | PROG= slsctl 2 | SRCS= slsctl.c attach.c partadd.c partdel.c \ 3 | checkpoint.c restore.c spawn.c \ 4 | listsnaps.c pgresident.c \ 5 | partadd_slos.c partadd_file.c \ 6 | partadd_memory.c partadd_send.c \ 7 | partadd_recv.c 8 | MAN= 9 | 10 | LDADD= -lsls -lsbuf -ledit 11 | LDFLAGS= -L../../libsls 12 | CFLAGS= -I../../include 13 | 14 | .include 15 | -------------------------------------------------------------------------------- /tools/slsctl/attach.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | static struct option attach_longopts[] = { 16 | { "memory", no_argument, NULL, 'm' }, 17 | { "oid", required_argument, NULL, 'o' }, 18 | { "pid", required_argument, NULL, 'p' }, 19 | { "help", no_argument, NULL, 'h' }, 20 | { NULL, no_argument, NULL, 0 }, 21 | }; 22 | 23 | void 24 | attach_usage(void) 25 | { 26 | printf("Usage: slsctl attach -p -o -m\n"); 27 | } 28 | 29 | int 30 | attach_main(int argc, char *argv[]) 31 | { 32 | int opt; 33 | int error; 34 | uint64_t pid = 0; 35 | uint64_t oid = 0; 36 | bool isrecursive = false; 37 | 38 | pid = 0; 39 | oid = 0; 40 | 41 | while ((opt = getopt_long( 42 | argc, argv, "o:p:mh", attach_longopts, NULL)) != -1) { 43 | switch (opt) { 44 | case 'o': 45 | oid = strtol(optarg, NULL, 10); 46 | break; 47 | 48 | case 'm': 49 | if (oid == 0) { 50 | oid = SLS_DEFAULT_MPARTITION; 51 | } 52 | break; 53 | 54 | case 'p': 55 | pid = strtol(optarg, NULL, 10); 56 | break; 57 | 58 | case 'h': 59 | default: 60 | attach_usage(); 61 | return 0; 62 | } 63 | } 64 | 65 | if (oid == 0) { 66 | oid = SLS_DEFAULT_PARTITION; 67 | } 68 | 69 | if (pid == 0 || optind != argc) { 70 | attach_usage(); 71 | return 0; 72 | } 73 | 74 | if (sls_attach(oid, pid) < 0) 75 | return 1; 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /tools/slsctl/checkpoint.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | static struct option checkpoint_longopts[] = { 16 | { "memory", no_argument, NULL, 'm' }, 17 | { "oid", required_argument, NULL, 'o' }, 18 | { "recursive", no_argument, NULL, 'r' }, 19 | { "help", no_argument, NULL, 'h' }, 20 | { NULL, no_argument, NULL, 0 }, 21 | }; 22 | 23 | void 24 | checkpoint_usage(void) 25 | { 26 | printf("Usage: slsctl checkpoint <-o oid> [-r] [-m] \n"); 27 | } 28 | 29 | int 30 | checkpoint_main(int argc, char *argv[]) 31 | { 32 | int opt; 33 | uint64_t oid = SLS_DEFAULT_PARTITION; 34 | bool recurse = false; 35 | bool synchronous = false; 36 | 37 | while ((opt = getopt_long( 38 | argc, argv, "mo:rsh", checkpoint_longopts, NULL)) != -1) { 39 | switch (opt) { 40 | case 'm': 41 | if (oid == SLS_DEFAULT_PARTITION) { 42 | oid = SLS_DEFAULT_MPARTITION; 43 | } 44 | break; 45 | case 'o': 46 | oid = strtol(optarg, NULL, 10); 47 | break; 48 | case 'r': 49 | recurse = true; 50 | break; 51 | case 'h': 52 | default: 53 | checkpoint_usage(); 54 | return 0; 55 | } 56 | } 57 | 58 | if (optind != argc) { 59 | checkpoint_usage(); 60 | return (0); 61 | } 62 | 63 | if (sls_checkpoint(oid, recurse) < 0) 64 | return 1; 65 | 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /tools/slsctl/partadd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "partadd.h" 21 | 22 | struct partcmd { 23 | const char *name; 24 | void (*usage)(); 25 | int (*cmd)(int, char **); 26 | } partcmdtable[] = { { "slos", &partadd_slos_usage, &partadd_slos_main }, 27 | { "memory", &partadd_memory_usage, &partadd_memory_main }, 28 | { "file", &partadd_file_usage, &partadd_file_main }, 29 | { "send", &partadd_send_usage, &partadd_send_main }, 30 | { "recv", &partadd_recv_usage, &partadd_recv_main }, 31 | { NULL, NULL, NULL } }; 32 | 33 | void 34 | partadd_usage(void) 35 | { 36 | printf("Usage: slsctl partadd -o [options]\n"); 37 | 38 | exit(0); 39 | } 40 | 41 | void 42 | partadd_base_usage(char *backend, struct option *opts) 43 | { 44 | struct option opt; 45 | int i; 46 | 47 | printf("Full options list for %s:\n", backend); 48 | for (i = 0, opt = opts[0]; opt.name != NULL; opt = opts[++i]) 49 | printf("-%c\t%s\n", opt.val, opt.name); 50 | } 51 | 52 | int 53 | partadd_main(int argc, char *argv[]) 54 | { 55 | int error; 56 | int i; 57 | 58 | /* Ignore the first argument, which is the partcmd line. */ 59 | argc -= 1; 60 | argv += 1; 61 | 62 | assert(argc > 0); 63 | 64 | /* Search for the partcmd. */ 65 | for (i = 0; partcmdtable[i].name != NULL; i++) { 66 | if (strcmp(argv[0], partcmdtable[i].name) != 0) 67 | continue; 68 | 69 | return partcmdtable[i].cmd(argc, (char **)argv); 70 | } 71 | 72 | /* No matches. */ 73 | printf("Unrecognized command '%s'\n", argv[0]); 74 | 75 | return (EINVAL); 76 | } 77 | -------------------------------------------------------------------------------- /tools/slsctl/partadd.h: -------------------------------------------------------------------------------- 1 | #ifndef _PARTADD_H_ 2 | #define _PARTADD_H_ 3 | 4 | void partadd_base_usage(char *backend, struct option *opts); 5 | 6 | void partadd_slos_usage(void); 7 | int partadd_slos_main(int argc, char *argv[]); 8 | 9 | void partadd_memory_usage(void); 10 | int partadd_memory_main(int argc, char *argv[]); 11 | 12 | void partadd_file_usage(void); 13 | int partadd_file_main(int argc, char *argv[]); 14 | 15 | void partadd_send_usage(void); 16 | int partadd_send_main(int argc, char *argv[]); 17 | 18 | void partadd_recv_usage(void); 19 | int partadd_recv_main(int argc, char *argv[]); 20 | 21 | #endif /* _PARTADD_H_ */ 22 | -------------------------------------------------------------------------------- /tools/slsctl/partadd_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "partadd.h" 19 | 20 | static struct option partadd_file_longopts[] = { 21 | { "delta", no_argument, NULL, 'd' }, 22 | { "filename", required_argument, NULL, 'f' }, 23 | { "ignore unlinked files", required_argument, NULL, 'i' }, 24 | { "oid", required_argument, NULL, 'o' }, 25 | { "period", required_argument, NULL, 't' }, 26 | { NULL, no_argument, NULL, 0 }, 27 | }; 28 | 29 | void 30 | partadd_file_usage(void) 31 | { 32 | partadd_base_usage("file", partadd_file_longopts); 33 | } 34 | 35 | int 36 | partadd_file_main(int argc, char *argv[]) 37 | { 38 | struct sls_attr attr; 39 | uint64_t oid = 0; 40 | int fd = -1; 41 | int error; 42 | int opt; 43 | 44 | attr = (struct sls_attr) { 45 | .attr_target = SLS_FILE, 46 | .attr_mode = SLS_FULL, 47 | .attr_period = 0, 48 | .attr_flags = 0, 49 | .attr_amplification = 1, 50 | }; 51 | 52 | while ((opt = getopt_long(argc, argv, "df:io:t:", partadd_file_longopts, 53 | NULL)) != -1) { 54 | switch (opt) { 55 | case 'd': 56 | attr.attr_mode = SLS_DELTA; 57 | break; 58 | 59 | case 'f': 60 | fd = open(optarg, O_DIRECTORY); 61 | if (fd < 0) { 62 | perror("open"); 63 | partadd_file_usage(); 64 | return (0); 65 | } 66 | break; 67 | 68 | case 'i': 69 | attr.attr_flags |= SLSATTR_IGNUNLINKED; 70 | break; 71 | 72 | case 'o': 73 | oid = strtol(optarg, NULL, 10); 74 | break; 75 | 76 | case 't': 77 | attr.attr_period = strtol(optarg, NULL, 10); 78 | break; 79 | 80 | default: 81 | printf("Invalid option '%c'\n", opt); 82 | partadd_file_usage(); 83 | return (0); 84 | } 85 | } 86 | 87 | if (oid == 0 || optind != argc) { 88 | partadd_file_usage(); 89 | return (0); 90 | } 91 | 92 | if (sls_partadd(oid, attr, fd) < 0) 93 | return (1); 94 | 95 | return (0); 96 | } 97 | -------------------------------------------------------------------------------- /tools/slsctl/partadd_memory.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "partadd.h" 19 | 20 | static struct option partadd_memory_longopts[] = { 21 | { "oid", required_argument, NULL, 'o' }, 22 | { "period", required_argument, NULL, 't' }, 23 | { "ignore unlinked files", required_argument, NULL, 'i' }, 24 | { NULL, no_argument, NULL, 0 }, 25 | }; 26 | 27 | void 28 | partadd_memory_usage() 29 | { 30 | partadd_base_usage("memory", partadd_memory_longopts); 31 | } 32 | 33 | int 34 | partadd_memory_main(int argc, char *argv[]) 35 | { 36 | struct sls_attr attr; 37 | uint64_t oid = 0; 38 | int port = 0; 39 | int error; 40 | int opt; 41 | 42 | attr = (struct sls_attr) { 43 | .attr_target = SLS_MEM, 44 | .attr_mode = SLS_FULL, 45 | .attr_period = 0, 46 | .attr_flags = 0, 47 | .attr_amplification = 1, 48 | }; 49 | 50 | while ((opt = getopt_long(argc, argv, "io:t:", partadd_memory_longopts, 51 | NULL)) != -1) { 52 | switch (opt) { 53 | case 'i': 54 | attr.attr_flags |= SLSATTR_IGNUNLINKED; 55 | break; 56 | 57 | case 'o': 58 | oid = strtol(optarg, NULL, 10); 59 | break; 60 | 61 | case 't': 62 | attr.attr_period = strtol(optarg, NULL, 10); 63 | break; 64 | 65 | default: 66 | printf("Invalid option '%c'\n", opt); 67 | partadd_memory_usage(); 68 | return (0); 69 | } 70 | } 71 | 72 | if (oid == 0 || optind != argc) { 73 | partadd_memory_usage(); 74 | return (0); 75 | } 76 | 77 | if (sls_partadd(oid, attr, -1) < 0) 78 | return (1); 79 | 80 | return (0); 81 | } 82 | -------------------------------------------------------------------------------- /tools/slsctl/partdel.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | static struct option partdel_longopts[] = { 16 | { "oid", required_argument, NULL, 'o' }, 17 | { NULL, no_argument, NULL, 0 }, 18 | }; 19 | 20 | void 21 | partdel_usage(void) 22 | { 23 | printf("Usage: slsctl partdel -o oid\n"); 24 | } 25 | 26 | int 27 | partdel_main(int argc, char *argv[]) 28 | { 29 | int oid = -1; 30 | int opt; 31 | 32 | while ((opt = getopt_long(argc, argv, "o:", partdel_longopts, NULL)) != 33 | -1) { 34 | switch (opt) { 35 | case 'o': 36 | oid = strtol(optarg, NULL, 10); 37 | break; 38 | default: 39 | partdel_usage(); 40 | return 0; 41 | } 42 | } 43 | 44 | if (optind != argc || oid == -1) { 45 | partdel_usage(); 46 | return 0; 47 | } 48 | 49 | if (sls_partdel(oid) < 0) 50 | return 1; 51 | 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /tools/slsctl/pgresident.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | static struct option pgresident_longopts[] = { 13 | { "oid", no_argument, NULL, 'o' }, 14 | { "filename", required_argument, NULL, 'f' }, 15 | { NULL, no_argument, NULL, 0 }, 16 | }; 17 | 18 | void 19 | pgresident_usage(void) 20 | { 21 | printf("Usage: slsctl pgresident -o -f \n"); 22 | } 23 | 24 | int 25 | pgresident_main(int argc, char *argv[]) 26 | { 27 | char *filename = NULL; 28 | uint64_t oid = 0; 29 | int error; 30 | int opt; 31 | int fd; 32 | 33 | while ((opt = getopt_long( 34 | argc, argv, "f:o:", pgresident_longopts, NULL)) != -1) { 35 | switch (opt) { 36 | case 'f': 37 | filename = optarg; 38 | break; 39 | 40 | case 'o': 41 | /* The ID of the process. */ 42 | oid = strtol(optarg, NULL, 10); 43 | break; 44 | 45 | default: 46 | pgresident_usage(); 47 | return (0); 48 | } 49 | } 50 | 51 | if (optind != argc) { 52 | pgresident_usage(); 53 | return (0); 54 | } 55 | 56 | if (oid == 0) { 57 | pgresident_usage(); 58 | return (0); 59 | } 60 | 61 | if (filename == NULL) { 62 | pgresident_usage(); 63 | return (0); 64 | } 65 | 66 | /* Open the file and pass it to the SLS for writing. */ 67 | fd = open(filename, O_CREAT | O_EXCL | O_RDWR, 0644); 68 | if (fd < 0) { 69 | perror("open"); 70 | return (1); 71 | } 72 | 73 | if ((error = sls_pgresident(oid, fd)) < 0) 74 | return (1); 75 | 76 | close(fd); 77 | 78 | return (0); 79 | } 80 | -------------------------------------------------------------------------------- /tools/slsctl/slsctl.h: -------------------------------------------------------------------------------- 1 | #ifndef _SLSCTL_H_ 2 | #define _SLSCTL_H_ 3 | 4 | void checkpoint_usage(void); 5 | int checkpoint_main(int argc, char *argv[]); 6 | 7 | void restore_usage(void); 8 | int restore_main(int argc, char *argv[]); 9 | 10 | void snaplist_usage(void); 11 | int snaplist_main(int argc, char *argv[]); 12 | 13 | void snapdel_usage(void); 14 | int snapdel_main(int argc, char *argv[]); 15 | 16 | void attach_usage(void); 17 | int attach_main(int argc, char *argv[]); 18 | 19 | void partadd_usage(void); 20 | int partadd_main(int argc, char *argv[]); 21 | 22 | void partdel_usage(void); 23 | int partdel_main(int argc, char *argv[]); 24 | 25 | void listsnaps_usage(void); 26 | int listsnaps_main(int argc, char *argv[]); 27 | 28 | void mountsnap_usage(void); 29 | int mountsnap_main(int argc, char *argv[]); 30 | 31 | void epoch_usage(void); 32 | int epoch_main(int argc, char *argv[]); 33 | 34 | void spawn_usage(void); 35 | int spawn_main(int argc, char *argv[]); 36 | 37 | void pgresident_usage(void); 38 | int pgresident_main(int argc, char *argv[]); 39 | 40 | #endif /* _SLSCTL_H_ */ 41 | -------------------------------------------------------------------------------- /tools/slsdb/Makefile: -------------------------------------------------------------------------------- 1 | PROG= slsdb 2 | SRCS= slsdb.cc file.cc directory.cc btree.cc snapshot.cc util.cc 3 | MAN= 4 | 5 | 6 | LDADD= -ledit 7 | LDFLAGS= -L../../libsls -lc++ 8 | CFLAGS= -I../../include 9 | 10 | .include 11 | -------------------------------------------------------------------------------- /tools/slsdb/btree.h: -------------------------------------------------------------------------------- 1 | #ifndef __SLSBTREE_H__ 2 | #define __SLSBTREE_H__ 3 | 4 | #define ITER_GOOD (0) 5 | #define ITER_CORRUPT (1) 6 | #define ITER_END (2) 7 | 8 | class Snapshot; 9 | 10 | template class BtreeNode; 11 | 12 | template class Btree; 13 | 14 | template class BtreeIter { 15 | public: 16 | BtreeIter(BtreeIter *n) 17 | : node(n->node) 18 | , at(n->at) {}; 19 | BtreeIter() 20 | : at(-1) 21 | , node() {}; 22 | BtreeIter(BtreeNode &node, int at) 23 | : node(node) 24 | , at(at) {}; 25 | 26 | K key(); 27 | V val(); 28 | 29 | BtreeIter next(); 30 | int valid(); 31 | BtreeNode node; 32 | int at; 33 | }; 34 | 35 | template class BtreeNode { 36 | public: 37 | BtreeNode(Btree *btree, Snapshot *sb, long blknum) 38 | : btree(btree) 39 | , snap(sb) 40 | , blknum(blknum) 41 | { 42 | init(); 43 | }; 44 | BtreeNode(BtreeNode *node); 45 | BtreeNode(BtreeNode &node); 46 | BtreeNode(BtreeNode const &node); 47 | BtreeNode() = default; 48 | ~BtreeNode(); 49 | 50 | int init(); 51 | int failed(); 52 | int verify(); 53 | int type() { return NODE_TYPE(&node); } 54 | int size() { return node.fn_dnode->dn_numkeys; } 55 | 56 | BtreeIter follow_to(K key, long blknum); 57 | BtreeNode follow(K key); 58 | BtreeIter parent(); 59 | void print(); 60 | std::string toString(); 61 | 62 | BtreeIter keymax(K key); 63 | 64 | Btree *btree; 65 | struct fbtree tree; 66 | struct fnode node; 67 | int error = 0; 68 | char data[4096]; 69 | Snapshot *snap; 70 | long blknum; 71 | }; 72 | 73 | template class Btree { 74 | public: 75 | Btree() = default; 76 | Btree(Snapshot *sb, long blknum) 77 | : snap(sb) 78 | , blknum(blknum) {}; 79 | 80 | BtreeIter keymax(K key); 81 | BtreeNode getRoot(); 82 | int verify(); 83 | std::string toString(); 84 | 85 | Snapshot *snap; 86 | struct fbtree tree; 87 | long blknum; 88 | }; 89 | #endif 90 | -------------------------------------------------------------------------------- /tools/slsdb/directory.h: -------------------------------------------------------------------------------- 1 | #ifndef __DIRECTORY_H__ 2 | #define __DIRECTORY_H__ 3 | 4 | #include "file.h" 5 | 6 | class SDir : public SFile { 7 | public: 8 | SDir() 9 | : SFile() {}; 10 | SDir(Snapshot *sb, slos_inode &ino); 11 | ~SDir() {}; 12 | 13 | void print(); 14 | }; 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tools/slsdb/file.h: -------------------------------------------------------------------------------- 1 | #ifndef __SLSFILE_H__ 2 | #define __SLSFILE_H__ 3 | 4 | class SFile; 5 | class InodeFile; 6 | 7 | enum class SType { INODE_ROOT, SREG, SDIR, CKSUM, SBLK, SCHR }; 8 | 9 | class SFile { 10 | public: 11 | SFile(); 12 | SFile(Snapshot *snap, slos_inode &ino, SType type); 13 | virtual ~SFile() {}; 14 | 15 | int failed(); 16 | std::string toString(); 17 | 18 | int dumpTo(std::string path); 19 | virtual void print(); 20 | void hexdump(); 21 | int verify(); 22 | 23 | friend std::shared_ptr createFile(Snapshot *sb, long blknum); 24 | 25 | protected: 26 | void writeData(std::ostream &where); 27 | 28 | struct slos_inode ino; 29 | long blknum; 30 | int error; 31 | SType type; 32 | Snapshot *snap; 33 | 34 | Btree tree; 35 | }; 36 | 37 | class SReg : public SFile { 38 | public: 39 | SReg() 40 | : SFile() {}; 41 | SReg(Snapshot *sb, slos_inode &ino); 42 | ~SReg() {}; 43 | 44 | void print() {}; 45 | }; 46 | 47 | class InodeFile : public SFile { 48 | public: 49 | InodeFile(Snapshot *sb, slos_inode &ino); 50 | ~InodeFile() {}; 51 | 52 | void print() {}; 53 | 54 | std::shared_ptr getFile(uint64_t inodeNum); 55 | std::vector> availableInodes(); 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /tools/slsdb/snapshot.h: -------------------------------------------------------------------------------- 1 | #ifndef __SNAPSHOT_H__ 2 | #define __SNAPSHOT_H__ 3 | 4 | class SFile; 5 | class InodeFile; 6 | 7 | class Snapshot { 8 | public: 9 | Snapshot(int dev, struct slos_sb &sb) 10 | : super(sb) 11 | , dev(dev) {}; 12 | std::string toString(int verbose = 0); 13 | std::shared_ptr getInodeFile(); 14 | int verify(); 15 | 16 | struct slos_sb super; 17 | int dev; 18 | }; 19 | 20 | std::shared_ptr createFile(Snapshot *sb, long blknum); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /tools/slsdb/util.cc: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | std::string 6 | time_to_string(uint64_t sec, uint64_t nsec) 7 | { 8 | time_t timesec = sec; 9 | struct tm ltime; 10 | char buf[64]; 11 | std::string rval; 12 | 13 | if (localtime_r(×ec, <ime) == NULL) { 14 | perror("localtime_r"); 15 | return ""; 16 | } 17 | 18 | strftime(buf, sizeof(buf), "%F %T", <ime); 19 | 20 | snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ".%09lu", nsec); 21 | 22 | rval = buf; 23 | 24 | return rval; 25 | } 26 | 27 | void 28 | hexdump(const char *data, size_t length, off_t off) 29 | { 30 | const size_t row_size = 16; 31 | bool stop = false; 32 | 33 | for (size_t row = 0; !stop; row++) { 34 | size_t ix = row * row_size; 35 | if (ix >= length) { 36 | break; 37 | } 38 | 39 | printf("%08lx ", row * row_size + off); 40 | for (size_t col = 0; col < row_size; col++) { 41 | size_t ix = row * row_size + col; 42 | if (length != 0 && ix > length) { 43 | stop = true; 44 | for (; col < row_size; col++) { 45 | printf(" "); 46 | } 47 | break; 48 | } 49 | 50 | printf("%02X ", (unsigned char)data[ix]); 51 | } 52 | printf(" |"); 53 | 54 | for (size_t col = 0; col < row_size; col++) { 55 | size_t ix = row * row_size + col; 56 | if (length != 0 && ix > length) { 57 | stop = true; 58 | for (; col < row_size; col++) { 59 | printf(" "); 60 | } 61 | break; 62 | } 63 | 64 | unsigned char c = (unsigned char)data[ix]; 65 | if (c >= 0x20 && c < 0x7F) 66 | printf("%c", c); 67 | else 68 | putchar('.'); 69 | } 70 | printf("|"); 71 | printf("\n"); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /tools/slsdb/util.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __UTIL_H__ 3 | #define __UTIL_H__ 4 | 5 | #define SECTOR_SIZE 512 6 | #define ROUNDUP(a, b) ((((a) + (b - 1)) / (b)) * (b)) 7 | 8 | std::string time_to_string(uint64_t sec, uint64_t nsec); 9 | void hexdump(const char *data, size_t length, off_t off); 10 | 11 | #endif /* __UTIL_H__ */ 12 | --------------------------------------------------------------------------------