pax_global_header00006660000000000000000000000064127427510250014517gustar00rootroot0000000000000052 comment=37dc927f969c34947f2de49afd5bb4cc95078768 writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/000077500000000000000000000000001274275102500217635ustar00rootroot00000000000000writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/Makefile000077500000000000000000000011461274275102500234300ustar00rootroot00000000000000#!/usr/bin/make -f # -*- makefile -*- default: all all: man/writeboost.8 man/writeboost.8: pod2man -s8 --stderr --utf8 sbin/writeboost $@ || rm -fv $@ clean: rm -fv man/writeboost.8 #install: all # install --preserve-timestamps --verbose .PHONY: test test_man test: test_man sh -n sbin/writeboost test_man: man/writeboost.8 @for M in writeboost.8 writeboosttab.5; do \ echo "Checking $$M" ;\ lexgrog "man/$$M" || break ;\ W=$$(man --warnings -E UTF-8 -l -Tutf8 -Z "man/$$M" 2>&1 >>/dev/null) ;\ if [ -n "$$W" ]; then echo "$$W"; break; fi ;\ done writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/README.md000066400000000000000000000023571274275102500232510ustar00rootroot00000000000000_writeboost_ is a user-space utility to activate _[dm-writeboost](https://github.com/akiradeveloper/dm-writeboost)_ device mappings. _[dm-writeboost](https://github.com/akiradeveloper/dm-writeboost)_ is a software using log-structured caching to accelerate block IO. _[dm-writeboost](https://github.com/akiradeveloper/dm-writeboost)_ is written by Akira Hayakawa and implemented as loadable module for Linux. See more at https://github.com/akiradeveloper/dm-writeboost #### AUTHOR Dmitry Smirnov #### COPYRIGHT Copyright 2015 Libre Solutions Pty Ltd (http://raid6.com.au) #### LICENSE This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/etc/000077500000000000000000000000001274275102500225365ustar00rootroot00000000000000writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/etc/writeboosttab000066400000000000000000000005371274275102500253560ustar00rootroot00000000000000## dm-writeboost "tab" (mappings) file, see writeboosttab(5). ##{DM target name} {cached block device e.g. HDD} {caching block device e.g. SSD} [options] ## ## wb_hdd /dev/disk/by-uuid/2e8260bc-024c-4252-a695-a73898c974c7 /dev/disk/by-partuuid/43372b68-3407-45fa-9b2f-61afe9c26a68 writeback_threshold=70,sync_data_interval=3600 ## writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/man/000077500000000000000000000000001274275102500225365ustar00rootroot00000000000000writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/man/writeboosttab.5000066400000000000000000000044111274275102500255140ustar00rootroot00000000000000.TH WRITEBOOSTTAB 5 "2015-05-07" "writeboost" "File Formats" .SH NAME writeboosttab - mappings of cache(d) devices .SH SYNOPSIS .B /etc/writeboosttab . .SH DESCRIPTION The file .B writeboosttab contains information about mappings between caching and cached block devices for writeboost utility. Each mapping is described on a separate line; Empty lines and lines starting with '#' are ignored; Fields on each line are separated by tabs or spaces; .B The first field .RI ( dm_name ) .RS This field describes the name of device-mapepr block device that will be created as result of mapping. .LP Typically after successful mapping the .I dm_name will appear in the .I /dev/mapper folder. .RE .B The second field .RI ( hdd_device ) .RS This field describes path to the cached block device, typically "slow" (rotational) HDD. .RE .B The third field .RI ( ssd_device ). .RS This field describes path to the caching block device, typically "fast" SSD. .RE .B The forth field .RI ( options ) .RS This optional field describes comma-separated list of options passed to dm-writeboost. .RE It is recommended to use reliable paths to block devices like .I /dev/disk/by-uuid/{UUID} or similar. . .SH EXAMPLES The following is an example of an entry in the .B /etc/writeboosttab file: .sp .RS 4 .nf cached_hdd /dev/disk/by-uuid/2e8260bc-024c-4252-a695-a73898c974c7 /dev/disk/by-partuuid/43372b68-3407-45fa-9b2f-61afe9c26a68 writeback_threshold=70,sync_data_interval=3600 .fi .RE . .SH FILES .IR /etc/writeboosttab . .SH "SEE ALSO" .BR writeboost (8) . .SH AUTHOR Dmitry Smirnov . .SH COPYRIGHT Copyright 2015 Libre Solutions Pty Ltd (http://raid6.com.au) . .SH LICENSE This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/sbin/000077500000000000000000000000001274275102500227165ustar00rootroot00000000000000writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/sbin/writeboost000077500000000000000000000112761274275102500250540ustar00rootroot00000000000000#!/bin/sh : <<=cut =head1 NAME writeboost - create dm-writeboost device-mapper mappings =head1 SYNOPSYS writeboost [ B<-u> ] [ B ] =head1 DESCRIPTION writeboost is a utility to create dm-writeboost device-mapper mappings as per definitions in the "/etc/writeboosttab" file. =head1 OPTIONS =over 4 =item B Act on given device from the first field of the I file. When not given writeboost acts on all devices listed in I. =item B<-h>, B<--help> Show usage and options. =item B<-u> Un-map all mappings (or un-map only given B). =back =head1 SEE ALSO I(5) =head1 DM-WRITEBOOST dm-writeboost is a software using log-structured caching to accelerate block IO. dm-writeboost is written by Akira Hayakawa and implemented as loadable module for Linux. See more at https://github.com/akiradeveloper/dm-writeboost =head1 AVAILABILITY https://gitlab.com/onlyjob/writeboost =head1 VERSION 1.20160718 =head1 DONATIONS Donations are much appreciated, please consider donating: Bitcoins : 15nCM6Rs4zoQKhBV55XxcPfwPKeAEHPbAn Litecoins : LZMLDNSfy3refx7bKQtEvPyYSbNHsfzLRZ AUD/PayPal : https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=onlyjob%40gmail%2ecom&lc=AU¤cy_code=AUD =head1 AUTHOR Dmitry Smirnov =head1 COPYRIGHT Copyright 2015-2016 Libre Solutions Pty Ltd (http://raid6.com.au) =head1 LICENSE This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . =cut U="" DEV="" while [ -n "$1" ]; do if [ "$1" = "-h" -o "$1" = "-?" -o "$1" = "--help" ]; then perldoc "$0" || grep --before-context=999 --regexp '^=cut$' "$0" exit 0 elif [ "$1" = "-u" ]; then U=1 elif [ "${1#-}" = "$1" ]; then DEV="${1##/dev/mapper/}" else echo -e "E: unknown option. Usage:" 1>&2 echo " $(basename $0) [ -t THRESHOLD ] [ -n ] [ -0 ] directory" exit 1 fi shift done set -u ## writeboost while read -r M H S O; do [ -z "${M%%#*}" ] && continue ## skip comments. [ -z "${M%%/*}" ] && continue ## skip invalid map names. ## skip empty lines / fields. [ -z "$M" ] && continue [ -z "$H" ] && continue [ -z "$S" ] && continue [ -n "${DEV}" -a ! "${DEV}" = "$M" ] && continue ## act only on given device # echo ":: $M : $H : $S : $O" ## check block devices. if [ -b "/dev/mapper/$M" ]; then ## already mapped. if [ -n "$U" ]; then logger --tag writeboost --stderr "un-mapping $M" ( ## https://github.com/akiradeveloper/dm-writeboost/issues/57 dmsetup suspend "$M" dmsetup message "$M" 0 drop_caches logger --tag writeboost --stderr "caches dropped; removing $M" E=$(dmsetup remove "$M" 2>&1 || dmsetup resume "$M") ## unmap or resume suspended device. if [ -b "/dev/mapper/$M" ]; then logger --tag writeboost --stderr "error: unable to un-map $M ($E)" else dd if=/dev/zero of="$S" count=1 bs=4096 oflag=direct 2>>/dev/null logger --tag writeboost --stderr "$M un-mapped." fi ) & fi continue fi [ -n "$U" ] && continue ## not mapping because un-map is requested. [ -b "$H" ] || (logger --tag writeboost --stderr "error: $H is not a block device."; continue) [ -b "$S" ] || (logger --tag writeboost --stderr "error: $S is not a block device."; continue) B=$(blockdev --getsize $H) [ -z "$B" ] && continue ## unable to get size of cached device. logger --tag writeboost --stderr "mapping $M" dmsetup create "$M" --table "0 $B writeboost $H $S" if [ -b "/dev/mapper/$M" ]; then logger --tag writeboost --stderr "$M mapped." [ -z "$O" ] && continue IFS_BAK="${IFS}" IFS=',' for I in $O; do dmsetup message "$M" 0 ${I%%=*} ${I##*=} done IFS="${IFS_BAK}" else logger --tag writeboost --stderr "error mapping $M" fi done < "/etc/writeboosttab" ## wait for background jobs. wait writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/writeboost.init000066400000000000000000000022411274275102500250500ustar00rootroot00000000000000#!/bin/sh ### BEGIN INIT INFO # Provides: writeboost # Required-Start: $local_fs # Required-Stop: $local_fs # Should-Start: $syslog # Should-Stop: $syslog # X-Start-Before: cryptdisks # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start the writeboost mapper # Description: (dm-)writeboost is a log-structured cache for Linux ### END INIT INFO DAEMON=/sbin/writeboost NAME=writeboost # Exit if executable is not installed [ -x $DAEMON ] || exit 0 # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS # define LSB log_* functions. . /lib/lsb/init-functions case "$1" in start) log_action_begin_msg "$NAME: mapping devices" $DAEMON log_action_end_msg 0 ;; stop) log_action_begin_msg "$NAME: un-mapping devices" $DAEMON -u log_action_end_msg 0 ;; reload|force-reload|restart) $0 stop $0 start ;; status) ## return status 0 if process is running. status_of_proc "$DAEMON" "$NAME" ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2 ;; esac writeboost-1.20160718-37dc927f969c34947f2de49afd5bb4cc95078768/writeboost.service000066400000000000000000000005541274275102500255520ustar00rootroot00000000000000[Unit] Description=(dm-)writeboost mapper Documentation=man:writeboost DefaultDependencies=false Before=cryptsetup.target Before=local-fs.target [Service] Type=oneshot RemainAfterExit=no TimeoutStartSec=600 ExecStart=/sbin/writeboost ExecStop=/sbin/writeboost -u [Install] WantedBy=cryptsetup-pre.target WantedBy=local-fs-pre.target #Alias=dm-writeboost.service