Commit b74fffdf authored by Peter Pentchev's avatar Peter Pentchev
Browse files

Update upstream source from tag 'upstream/20191016+ds1'

Update to upstream version '20191016+ds1'
with Debian dir 66d90c9a3ef73addd185fd946c2043ed62339d6c
parents 3cdb4f72 31482835
......@@ -28,7 +28,7 @@ project(mbuffer C)
find_package(Threads)
set(PACKAGE_VERSION "20190625")
set(PACKAGE_VERSION "20191016")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_LD_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O2")
......
20191016:
- autoadjust dependent parameters
- human readable buffer size information instead of kiB
20190725:
- hashing infrastructure should also be enabled with libdl available
- report input file name in message for open failure
......
......@@ -26,6 +26,7 @@
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
......@@ -163,3 +164,20 @@ int disable_directio(int fd, const char *fn)
return 0;
#endif
}
// use only once per string formatting argument
const char *hBytes(unsigned long long v)
{
static char output[16];
char *dim = " kMGT";
while ((v != 0) && ((v % 1024) == 0)) {
++dim;
v >>= 10;
}
snprintf(output,sizeof(output),"%llu%ciB",v,*dim);
return output;
}
......@@ -40,5 +40,6 @@ long long enforceSpeedLimit(unsigned long long limit, long long num, struct time
void releaseLock(void *l);
void enable_directio(int fd, const char *fn);
int disable_directio(int fd, const char *fn);
const char *hBytes(unsigned long long v);
#endif
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for mbuffer 20190725.
# Generated by GNU Autoconf 2.69 for mbuffer 20191016.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
......@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='mbuffer'
PACKAGE_TARNAME='mbuffer'
PACKAGE_VERSION='20190725'
PACKAGE_STRING='mbuffer 20190725'
PACKAGE_VERSION='20191016'
PACKAGE_STRING='mbuffer 20191016'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
......@@ -1263,7 +1263,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures mbuffer 20190725 to adapt to many kinds of systems.
\`configure' configures mbuffer 20191016 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1330,7 +1330,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of mbuffer 20190725:";;
short | recursive ) echo "Configuration of mbuffer 20191016:";;
esac
cat <<\_ACEOF
......@@ -1419,7 +1419,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
mbuffer configure 20190725
mbuffer configure 20191016
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -1895,7 +1895,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by mbuffer $as_me 20190725, which was
It was created by mbuffer $as_me 20191016, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -6545,7 +6545,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by mbuffer $as_me 20190725, which was
This file was extended by mbuffer $as_me 20191016, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -6607,7 +6607,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
mbuffer config.status 20190725
mbuffer config.status 20191016
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
AC_INIT([mbuffer],[20190725])
AC_INIT([mbuffer],[20191016])
AC_CONFIG_HEADER([config.h])
AC_CONFIG_SRCDIR([mbuffer.c])
AC_LANG([C])
......
......@@ -1073,7 +1073,7 @@ static void checkBlocksizes(dest_t *dest)
errormsg("could not stat output: %s\n",strerror(errno));
else if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
if (Blocksize % st.st_blksize != 0) {
warningmsg("Block size is not a multiple of native output size.\n");
warningmsg("Block size is not a multiple of native output size (%uB).\n",st.st_blksize);
infomsg("output device's native block-size is %d bytes\n",st.st_blksize);
infomsg("transfer block size is %lld\n", Blocksize);
if (SetOutsize)
......@@ -1093,7 +1093,7 @@ static void checkBlocksizes(dest_t *dest)
else if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) {
IDevBSize = st.st_blksize;
if ((st.st_blksize != 0) && (Blocksize % st.st_blksize != 0)) {
warningmsg("Block size is not a multiple of native input size.\n");
warningmsg("Block size is not a multiple of native input size (%uB).\n",st.st_blksize);
infomsg("input device's native block-size is %d bytes\n",st.st_blksize);
infomsg("transfer block size is %lld\n", Blocksize);
} else {
......@@ -1124,51 +1124,48 @@ static int outputIsSet()
}
int main(int argc, const char **argv)
void checkConsistency(void)
{
int c, fl, err;
sigset_t signalSet;
char *argv0 = strdup(argv[0]), *progname, null;
struct sigaction sig;
dest_t *dest = 0;
/* setup logging prefix */
progname = basename(argv0);
PrefixLen = strlen(progname);
Prefix = malloc(PrefixLen + 2);
(void) strncpy(Prefix,progname,PrefixLen);
Prefix[PrefixLen++] = ':';
Prefix[PrefixLen++] = ' ';
/* set verbose level before parsing defaults and options */
searchOptionV(argc,argv);
/* setup parameters */
initDefaults();
debugmsg("default buffer set to %d blocks of %lld bytes\n",Numblocks,Blocksize);
for (c = 1; c < argc; c++)
c = parseOption(c,argc,argv);
/* consistency check for options */
if (AutoloadTime && Timeout && Timeout <= AutoloadTime)
fatal("autoload time must be smaller than watchdog timeout\n");
// OPTION_B: number of blocks
// OPTION_S: block size
// OPTION_M: total memory
if (Options == (OPTION_B|OPTION_M|OPTION_S)) {
/* options -m -b -s set */
if (Numblocks * Blocksize != Totalmem)
fatal("inconsistent options: blocksize * number of blocks != totalsize!\n");
} else if ((Options == (OPTION_S|OPTION_M)) || (Options == OPTION_M)) {
if (Totalmem < (Blocksize*5))
fatal("total memory must be large enough for 5 blocks\n");
} else if (Options == (OPTION_S|OPTION_M)) {
Numblocks = Totalmem / Blocksize;
infomsg("adjusted number of blocks to %lu\n",Numblocks);
if (Numblocks * Blocksize != Totalmem) {
Totalmem = Numblocks * Blocksize;
infomsg("adjusted totalmem to %s\n",hBytes(Totalmem));
}
} else if (Options == OPTION_M) {
Blocksize = PgSz;
if (Totalmem/Blocksize < 5)
Blocksize = Totalmem/8;
Numblocks = Totalmem / Blocksize;
infomsg("Numblocks = %llu, Blocksize = %llu, Totalmem = %llu\n",(unsigned long long)Numblocks,(unsigned long long)Blocksize,(unsigned long long)Totalmem);
while (Numblocks > 1024) {
Blocksize <<= 1;
Numblocks = Totalmem / Blocksize;
}
infomsg("adjusted blocksize to %s, number of blocks to %lu\n",hBytes(Blocksize),Numblocks);
if (Totalmem != Blocksize * Numblocks) {
Totalmem = Blocksize * Numblocks;
infomsg("overruling total memory to %s\n",hBytes(Totalmem));
}
} else if (Options == (OPTION_B|OPTION_M)) {
if (Blocksize == 0)
fatal("blocksize must be greater than 0\n");
if (Totalmem <= Blocksize)
fatal("total memory must be larger than block size\n");
Blocksize = Totalmem / Numblocks;
infomsg("blocksize = %llu\n",(unsigned long long)Blocksize);
infomsg("adusting blocksize to %s\n",hBytes(Blocksize));
if (Totalmem != (Blocksize * Numblocks)) {
Totalmem = Blocksize * Numblocks;
infomsg("adjusting total buffer memory to %s",hBytes(Totalmem));
}
}
if (Numblocks < 5)
fatal("Number of blocks must be at least 5.\n");
if ((StartRead < 1) && (StartWrite > 0))
fatal("setting both low watermark and high watermark doesn't make any sense...\n");
if ((NumSenders-Hashers > 0) && (Autoloader || OutVolsize))
......@@ -1176,9 +1173,8 @@ int main(int argc, const char **argv)
if (Autoloader) {
if ((!OutFile) && (!Infile))
fatal("Setting autoloader time or command without using a device doesn't make any sense!\n");
if (OutFile && Infile) {
if (OutFile && Infile)
fatal("Which one is your autoloader? Input or output? Replace input or output with a pipe.\n");
}
}
/* multi volume input consistency checking */
......@@ -1191,11 +1187,35 @@ int main(int argc, const char **argv)
if ((OutVolsize != 0) && (OutVolsize < Blocksize))
/* code assumes we can write at least one block */
fatal("If non-zero, OutVolsize must be at least as large as the buffer blocksize (%llu)!\n",Blocksize);
/* SPW END */
}
if (Numblocks < 5)
fatal("Minimum block count is 5.\n");
int main(int argc, const char **argv)
{
int c, fl, err;
sigset_t signalSet;
char *argv0 = strdup(argv[0]), *progname, null;
struct sigaction sig;
dest_t *dest = 0;
/* setup logging prefix */
progname = basename(argv0);
PrefixLen = strlen(progname);
Prefix = malloc(PrefixLen + 2);
(void) strncpy(Prefix,progname,PrefixLen);
Prefix[PrefixLen++] = ':';
Prefix[PrefixLen++] = ' ';
/* set verbose level before parsing defaults and options */
searchOptionV(argc,argv);
/* setup parameters */
initDefaults();
debugmsg("default buffer set to %d blocks of %s\n",Numblocks,hBytes(Blocksize));
for (c = 1; c < argc; c++)
c = parseOption(c,argc,argv);
checkConsistency();
initBuffer();
debugmsg("creating semaphores...\n");
......
......@@ -18,6 +18,7 @@
*/
#include "mbconf.h"
#include "common.h"
#include "dest.h"
#include "hashing.h"
#include "network.h"
......@@ -433,8 +434,9 @@ void initBuffer()
Buffer = (char **) valloc(Numblocks * sizeof(char *));
if (!Buffer)
fatal("Could not allocate enough memory (%d requested): %s\n",Numblocks * sizeof(char *),strerror(errno));
infomsg("%d blocks with %sB\n",Numblocks,hBytes(Blocksize));
if (Memmap) {
infomsg("mapping temporary file to memory with %llu blocks with %llu byte (%llu kB total)...\n",(unsigned long long) Numblocks,(unsigned long long) Blocksize,(unsigned long long) ((Numblocks*Blocksize) >> 10));
infomsg("mapping temporary file with %sB as buffer\n",hBytes(Numblocks*Blocksize));
if (!Tmpfile) {
char tmplname[] = "mbuffer-XXXXXX";
char *tmpdir = getenv("TMPDIR") ? getenv("TMPDIR") : "/var/tmp";
......@@ -468,11 +470,7 @@ void initBuffer()
fatal("could not map buffer-file to memory: %s\n",strerror(errno));
debugmsg("temporary file mapped to address %p\n",Buffer[0]);
} else {
infomsg("allocating memory for %d blocks with %llu %s (%llu kB total)...\n"
,Numblocks
,Blocksize & 0x3ff ? Blocksize : (Blocksize >> 10)
,Blocksize & 0x3ff ? "bytes" : "kB"
,(unsigned long long)((Numblocks*Blocksize) >> 10));
infomsg("allocating %s as buffer\n",hBytes(Numblocks*Blocksize));
Buffer[0] = (char *) valloc(Blocksize * Numblocks);
if (Buffer[0] == 0)
fatal("Could not allocate enough memory (%lld requested): %s\n",(unsigned long long)Blocksize * Numblocks,strerror(errno));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment