/sbin/writeboost is in writeboost 1.20160718-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | #!/bin/sh
: <<=cut
=head1 NAME
writeboost - create dm-writeboost device-mapper mappings
=head1 SYNOPSYS
writeboost [ B<-u> ] [ B<device> ]
=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<device>
Act on given device from the first field of the I</etc/writeboosttab> file.
When not given writeboost acts on all devices listed in I</etc/writeboosttab>.
=item B<-h>, B<--help>
Show usage and options.
=item B<-u>
Un-map all mappings (or un-map only given B<device>).
=back
=head1 SEE ALSO
I<writeboosttab>(5)
=head1 DM-WRITEBOOST
dm-writeboost is a software using log-structured caching to accelerate
block IO. dm-writeboost is written by Akira Hayakawa <ruby.wktk@gmail.com>
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 <onlyjob@member.fsf.org>
=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 <http://www.gnu.org/licenses/>.
=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
|