dss.git
9 years agotv.c: Remove unused functions.
Andre Noll [Sat, 3 Jan 2015 16:11:06 +0000 (16:11 +0000)]
tv.c: Remove unused functions.

Quite a few public functions of tv.c are not used anywhere in dss,
so let's get rid of them. We can easily add them back in case they
are neeed in the future.

Found by cppcheck.

9 years agostr.c: Remove pointless initialization.
Andre Noll [Sat, 3 Jan 2015 16:08:00 +0000 (16:08 +0000)]
str.c: Remove pointless initialization.

The variable p is initialized to a different value a few lines later
and the value set in the definition is not used in between.

Found by cppcheck.

9 years agoRemove non-functional SEE ALSO links from index.html.
Andre Noll [Sat, 3 Jan 2015 16:05:58 +0000 (16:05 +0000)]
Remove non-functional SEE ALSO links from index.html.

It's nice to have references to ssh and rsync in the SEE ALSO section
of the man page. On the web page, however, they do not add much value
since the links generated by man2html do not work. This patch omits
the broken links.

9 years agoNEWS update
Andre Noll [Tue, 6 Jan 2015 19:54:55 +0000 (20:54 +0100)]
NEWS update

9 years agoChange background color of web pages to white.
Andre Noll [Mon, 18 Aug 2014 12:01:34 +0000 (14:01 +0200)]
Change background color of web pages to white.

The old colors looked a little like the 90s ;)

9 years agoMerge branch 'refs/heads/t/min-complete'
Andre Noll [Fri, 12 Dec 2014 13:21:53 +0000 (14:21 +0100)]
Merge branch 'refs/heads/t/min-complete'

9 years agoNEWS: Fix indentation of 0.1.5 items.
Andre Noll [Wed, 24 Sep 2014 13:39:41 +0000 (15:39 +0200)]
NEWS: Fix indentation of 0.1.5 items.

The generated html looked terrible. No real changes.

9 years agoindex.html.in: Fix gitweb link.
Andre Noll [Wed, 24 Sep 2014 13:28:39 +0000 (15:28 +0200)]
index.html.in: Fix gitweb link.

Apparently the symlink workaround for the gitweb pages on
git.tuebingen.mpg.de does not work any more although the symlink
dss->dss.git is still in place.

This commit changes the link on the web page to include the .git
suffix.

9 years agoIntroduce --min-complete.
Andre Noll [Tue, 18 Feb 2014 13:16:02 +0000 (14:16 +0100)]
Introduce --min-complete.

Currently dss cowardly refuses to remove the last complete snapshot
even if disk space is low, and fails if there is not enough disk space
left for a second snapshot. However, in some situations it is more
important to have a recent snapshot and to to keep dss up and running.

This commit introduces a new integer option, --min-complete, which
defaults to one to resemble the old behaviour.

If it is set to zero, dss will happily remove the last complete
snapshot, even if it is used as the reference directory for rsync's
--link-dest option. This is dangerous, but it's the only way to keep
dss going.

Conversely, --min-complete may be set to a value greater than one
to guarantee there is always a certain number of complete snapshots
available.

9 years agoChange email address and URLs.
Andre Noll [Sat, 16 Aug 2014 10:00:18 +0000 (12:00 +0200)]
Change email address and URLs.

The web and email service of systemlinux.org was down for two
weeks. Meanwhile the dss web pages found a new home at the MPI campus
of Tübingen.

This commit changes the email addresses and the home page URL.

10 years agoSilence clang warnings.
Andre Noll [Tue, 21 Jan 2014 15:56:37 +0000 (16:56 +0100)]
Silence clang warnings.

The -Wno-sign-compare option is supposed to not print the noisy
warnings for comparisons between signed and unsigned values.
Currently, in DEBUG_CFLAGS this option is followed by -W which causes
clang (but not gcc) to turn on these warnings again. As CFLAGS contains
-Wall, the -W option was redundant anyway, so this patch removes it.

10 years agodss-0.1.5. v0.1.5
Andre Noll [Tue, 14 Jan 2014 14:22:04 +0000 (15:22 +0100)]
dss-0.1.5.

10 years agoMerge branch 't/exit_fix'
Andre Noll [Tue, 14 Jan 2014 14:15:38 +0000 (15:15 +0100)]
Merge branch 't/exit_fix'

Was cooking since 2013-10.

10 years agoMerge branch 't/dia'
Andre Noll [Wed, 16 Oct 2013 12:35:46 +0000 (14:35 +0200)]
Merge branch 't/dia'

The single commit of this branch is more than one year old. I totally
forgot about it, but here it is:

311ec5 Switch logo from skencil to dia.

The web page has been updated to contain the new image.

10 years agoKill children on fatal errors.
Andre Noll [Wed, 16 Oct 2013 12:17:46 +0000 (14:17 +0200)]
Kill children on fatal errors.

If dss is about to die because it received SIGINT or SIGTERM, we first
restart the rsync process by sending SIGCONT, then send SIGTERM to
both the rsync and the rm process to get rid of any child processes.

This works fine, but there are other fatal errors for which we miss
to clean up as thoroughly, most importantly if there is not enough
free disk space for a single snapshot.

This patch moves the signal-related cleanup part to the new function
kill_children(), and changes handle_signal() and com_run() to call
this function right before the exit hook is invoked.

10 years agoTrivial: Remove trailing semicolon.
Andre Noll [Wed, 16 Oct 2013 12:28:23 +0000 (14:28 +0200)]
Trivial: Remove trailing semicolon.

11 years agorsync: Remove hardcoded --quiet option.
Andre Noll [Thu, 20 Dec 2012 13:38:41 +0000 (14:38 +0100)]
rsync: Remove hardcoded --quiet option.

When running in daemon mode, the stdout and stderr stream of dss and
all its child processes are redirected to /dev/null. In particular any
output from the rsync process is discarded. Therefore, whenever a new
snapshot is created, dss currently passes --quiet to the underlying
rsync command, along with --archive and --delete.

However, as was pointed out by Sebastian Schultheiß, if the rsync
command fails for unknown reasons, the --quiet option complicates
debugging for the questionable benefit of saving the I/O for a few
writes to /dev/null.

This patch removes the --quiet option.

11 years agoMerge branch 't/zero-rsync-fix'
Andre Noll [Thu, 20 Dec 2012 13:36:42 +0000 (14:36 +0100)]
Merge branch 't/zero-rsync-fix'

11 years agoReject insane number of intervals.
Andre Noll [Sun, 28 Oct 2012 19:11:16 +0000 (20:11 +0100)]
Reject insane number of intervals.

Nobody needs more than 2^30 snapshots. More importantly, values
larger than 32 for --num_intervals cause an integer overflow in
desired_number_of_snapshots() because the number of snapshots in
interval zero does not fit in an unsigned int in this case.

This patch adds a test to check_config() that rejects values larger
than 30 for the --num_intervals option.

Many thanks to Klaus Kopec for pointing out this bug.

11 years agoDon't create two snapshots in the same second.
Andre Noll [Mon, 1 Oct 2012 17:10:02 +0000 (19:10 +0200)]
Don't create two snapshots in the same second.

This can only happen if all of the follwing are true:

(a) source and destination directories are small
(b) rsync completes successfully within one second
(c) At most two snapshots are missing

In this case the rename() call which changes the snapshot name from
*-incomplete to the proper name fails for the second snapshot with
EEXIST. This is because the previous snapshot name coincides with
the name of the second snapshot.

The fix is a bit ugly but also non-invasive and simple: Just sleep
one second in this case.

11 years agoMerge branch 't/rename_system_files'
Andre Noll [Sun, 16 Sep 2012 11:34:07 +0000 (13:34 +0200)]
Merge branch 't/rename_system_files'

Has been cooking for several weeks. The conflicts

daemon.c
exec.c
file.c
ipc.c
sig.c

are trivial and can be resolved easily.

11 years agoSwitch logo from skencil to dia.
Andre Noll [Wed, 8 Aug 2012 19:47:56 +0000 (21:47 +0200)]
Switch logo from skencil to dia.

The sketch/skencil project appears to be inactive for years, and
it is no longer shipped on recent Linux distributions. This commit
replaces the sketch source file dss.sk by dss.dia, a source file for
dia, an GTK+ based diagram creation program. The new logo looks very
similar to the old one but was created from scratch.

dia allows to convert a .dia file to PNG image data. This patch also
adjusts the Makefile to produce the dss.png logo from dss.dia.

11 years agoRename source files which also exist as system headers.
Andre Noll [Sat, 11 Aug 2012 18:32:19 +0000 (20:32 +0200)]
Rename source files which also exist as system headers.

As pointed out by Daniel Richard G. some of the dss header files
are named the same as system header files.

This patch renames these headers as well as their corresponding .c
files. Specifically, error.h, fd.h, signal.h, string.h and time.h
become err.h, file.h, sig.h, str.h and tv.h.

11 years agoMake the dss log facility C89 conform.
Daniel Richard G [Fri, 10 Aug 2012 12:41:22 +0000 (14:41 +0200)]
Make the dss log facility C89 conform.

Variadic macros were introduced in C99, so they are not supported on
ANSI C compilers. Since currently all DSS_*_LOG macros are variadic,
we need a replacement for these. Moreover, since not all compilers
support __func__ or an equivalent, we need to check for this feature
as well and provide a workaround if necessary.

This patch introduces the new public function dss_log_set_params()
which saves the given log level, filename, line number and the
function name in global variables. The DSS_*_LOG macros are changed
to receive a single argument only, which is the usual variadic list,
enclosed in additional parentheses.

The new DSS_*_LOG macros first set the log parameters by calling
dss_log_set_params(), then call dss_log() with the variadic list as
the argument. dss_log() is patched to print the function name only
if __func__ is supported and fall back to file name and the line
number otherwise.

All DSS_*_LOG() calls are changed to the new syntax.

11 years agoipc.c: Eliminate per-field struct initializations.
Daniel Richard G [Fri, 10 Aug 2012 12:20:57 +0000 (14:20 +0200)]
ipc.c: Eliminate per-field struct initializations.

This replaces the C99-only initializations in mutex_lock() and
mutex_try_lock() by equivalent but portable code.

11 years agoHave foo.c #include foo.h.
Daniel Richard G [Fri, 10 Aug 2012 12:16:22 +0000 (14:16 +0200)]
Have foo.c #include foo.h.

This is both to ensure function signature consistency, and to
eliminate GCC's "no previous declaration for _____" warnings.

11 years agoMark find_oldest_removable_snapshot() as static.
Daniel Richard G [Fri, 10 Aug 2012 12:10:55 +0000 (14:10 +0200)]
Mark find_oldest_removable_snapshot() as static.

It is not used outside the source file in which it is defined.

11 years agoMerge branch 't/gcc-compat_fix'
Andre Noll [Wed, 15 Aug 2012 09:34:48 +0000 (11:34 +0200)]
Merge branch 't/gcc-compat_fix'

* e1f886 Only define gcc function attributes on gcc.

11 years agoMerge branch 't/cleanups'
Andre Noll [Wed, 15 Aug 2012 09:32:10 +0000 (11:32 +0200)]
Merge branch 't/cleanups'

The changes in this branch are an attempt to make dss compile cleanly
with the more strict compiler flags (GCC 4.6 on Linux).

    -pedantic -fno-common -W -Wall -Wcast-align -Wformat=2
    -Wpointer-arith -Wundef -Waggregate-return -Wcast-qual
    -Wmissing-declarations -Wnested-externs -Wstrict-prototypes

This is only a first step that addresses the easier warnings. Some,
like the ones stemming from the variadic macros, have yet to be fixed.

* 9e6c2f Remove some debug messages.
* 899f88 string.c: Fix a statement-before-declaration issue.
* 83ebb4 Remove trailing commas.
* 2ed0d7 snap.h: Fix HSA_ITEM.
* 508350 Fix "comma after last element" warning.
* 97fbf4 compare_snapshots(): Add const keyword.
* b28495 Avoid per-element initializers.
* 9528cf dss.c: Fix initialization of argv[].
* 4526f9 dss.c: Remove redundant const.
* 2183c6 Makefile: Split CPPFLAGS.

Conflicts:
error.h

11 years agoMerge branch 't/ipc'
Andre Noll [Fri, 10 Aug 2012 11:49:54 +0000 (13:49 +0200)]
Merge branch 't/ipc'

4d9f41 mutex_get(): Change parameter from key_t to int.
55c90e Implement --reload.
492928 Add the --kill subcommand.
dd42f7 Use semaphore locking to avoid starting dss multiple times.
17eea8 Introduce get_config_file_name().

That topic was cooking in next for a quite some time now.

11 years agoOnly define gcc function attributes on gcc.
Daniel Richard G [Mon, 6 Aug 2012 18:39:53 +0000 (20:39 +0200)]
Only define gcc function attributes on gcc.

These gcc extensions help the compiler optimize function calls,
but are unavailable if dss is not compiled with gcc.

This patch defines the corresponding macros to empty if __GNUC__
is not defined, or if the gcc version is too old to support the
particular function attribute.

11 years agoRemove some debug messages.
Daniel Richard G [Thu, 2 Aug 2012 18:04:42 +0000 (20:04 +0200)]
Remove some debug messages.

These were only helpful during development and are commented out
for quite some time now. Remove them.

11 years agostring.c: Fix a statement-before-declaration issue.
Daniel Richard G [Thu, 2 Aug 2012 18:00:29 +0000 (20:00 +0200)]
string.c: Fix a statement-before-declaration issue.

11 years agoRemove trailing commas.
Daniel Richard G [Sat, 4 Aug 2012 11:22:53 +0000 (13:22 +0200)]
Remove trailing commas.

11 years agosnap.h: Fix HSA_ITEM.
Daniel Richard G [Sat, 4 Aug 2012 11:22:45 +0000 (13:22 +0200)]
snap.h: Fix HSA_ITEM.

This changes the second definition of HSA_ITEM to avoid C99
subscripted element initializers.

11 years agoFix "comma after last element" warning.
Daniel Richard G [Thu, 2 Aug 2012 17:53:12 +0000 (19:53 +0200)]
Fix "comma after last element" warning.

This changes the definition of DSS_ERRORS so that it includes the commas,
and removes the comma from both definitions of DSS_ERROR. This
avoids "comma after last element" warnings, which on some compilers
produces an error.

11 years agocompare_snapshots(): Add const keyword.
Daniel Richard G [Sat, 4 Aug 2012 11:20:17 +0000 (13:20 +0200)]
compare_snapshots(): Add const keyword.

This fixes a "cast drops const qualifier" warning.

11 years agoAvoid per-element initializers.
Daniel Richard G [Sat, 4 Aug 2012 11:16:20 +0000 (13:16 +0200)]
Avoid per-element initializers.

Per-element struct initializers are not supported in ANSI C. This
construct doesn't gain much in terms of readability, and breaks
compatibility with older/stricter compilers.

11 years agodss.c: Fix initialization of argv[].
Daniel Richard G [Thu, 2 Aug 2012 17:45:38 +0000 (19:45 +0200)]
dss.c: Fix initialization of argv[].

argv[] can't be declared in this way because the initializers are not
computable at compile time. GCC allows this construct, but stricter
compilers don't.

11 years agodss.c: Remove redundant const.
Daniel Richard G [Thu, 2 Aug 2012 17:37:23 +0000 (19:37 +0200)]
dss.c: Remove redundant const.

hook_status_description[] had a redundant const keyword, per GCC.

11 years agoMakefile: Split CPPFLAGS.
Daniel Richard G [Thu, 2 Aug 2012 17:30:46 +0000 (19:30 +0200)]
Makefile: Split CPPFLAGS.

-W*/-O*/-g options belong in CFLAGS, not CPPFLAGS. CPPFLAGS is for
preprocessor-specific (-D*/-I*) options.

11 years agomutex_get(): Change parameter from key_t to int.
Andre Noll [Fri, 3 Aug 2012 08:45:10 +0000 (10:45 +0200)]
mutex_get(): Change parameter from key_t to int.

The two callers obtain the key from get_key_or_die(), which
returns int. So pass an int anyway. This fixes a warning on
NetBSD:

ipc.c:263: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'key_t'

11 years agoerror.h: Remove is_errno().
Andre Noll [Fri, 3 Aug 2012 08:25:11 +0000 (10:25 +0200)]
error.h: Remove is_errno().

This inline function is unused.

11 years agoMerge branch 't/exec_cleanups'
Andre Noll [Fri, 20 Jul 2012 14:05:41 +0000 (16:05 +0200)]
Merge branch 't/exec_cleanups'

06a23c Simplify exec functions.

Was cooking quite long and no problems showed up.

11 years agoImplement --reload.
Andre Noll [Sat, 26 Mar 2011 14:37:06 +0000 (15:37 +0100)]
Implement --reload.

This is literally the same as --kill, the only difference being that
SIGHUP rather than SIGTERM is sent.

11 years agoAdd the --kill subcommand.
Andre Noll [Sat, 13 Nov 2010 19:51:28 +0000 (20:51 +0100)]
Add the --kill subcommand.

It works as follows: Whenever a semaphore operation is performed, the
PID of the process is stored in the sempid field of the semaphore.
This PID can be obtained from a different process by calling semctl
with the GETPID command.

com_kill() first tries to acquire the lock by calling the new
mutex_try_lock() function of ipc.c. In contrast to mutex_lock(),
mutex_try_lock() only operates on the first semaphore in the semaphore
set, leaving the sempid field of the second semaphore unchanged. If
mutex_try_lock() succeeds, no running dss process is holding the lock
and the kill command fails. Otherwise, some dss process is running
whose PID can be obtained by calling semctl() on the second semaphore.

11 years agoUse semaphore locking to avoid starting dss multiple times.
Andre Noll [Sat, 13 Nov 2010 19:31:10 +0000 (20:31 +0100)]
Use semaphore locking to avoid starting dss multiple times.

It's trickier than one might expect but it is hopefully also much
better than any pidfile-based approach.

This patch adds ipc.c and ipc.h containing the public lock_dss()
function which acquires a semaphore-based lock whose key is based
on the hash of the resolved path name of the dss config file. This
allows different instances of dss to coexist.

All semaphore operations are called with both the SEM_UNDO and the
IPC_NOWAIT flag. SEM_UNDO guarantees that no stale lock remains after
dss was killed by SIGKIlL while IPC_NOWAIT makes the call to lock_dss()
fail if another process is already holding the lock.

The prune/create/run commands simply take the lock at startup and
exit if it could not be acquired.

The underlying semaphore set contains two semaphores. This is necessary
to implement the --kill subcommand which is done in a subsequent patch.

11 years agoIntroduce get_config_file_name().
Andre Noll [Sat, 13 Nov 2010 19:21:04 +0000 (20:21 +0100)]
Introduce get_config_file_name().

ATM, the config file name is computed in parse_config(). However, for the ipc
stuff we'll need that information as well, so move the computation to a separate
helper function().

11 years agodoc: Add a second example config file.
Andre Noll [Mon, 30 Apr 2012 19:30:35 +0000 (21:30 +0200)]
doc: Add a second example config file.

This commit provides another example for the INSTALL file. It
illustrates the use of some more sophisticated config options of dss.

Many thanks to Ivo Welch who suggested this change.

12 years agoSimplify exec functions.
Andre Noll [Sat, 18 Jun 2011 12:31:11 +0000 (14:31 +0200)]
Simplify exec functions.

These were copied from elsewhere long ago and are more general
than what is needed for dss.

13 years agoNEWS update.
Andre Noll [Thu, 31 Mar 2011 21:54:37 +0000 (23:54 +0200)]
NEWS update.

13 years agoNEWS update
Andre Noll [Mon, 7 Feb 2011 16:58:58 +0000 (17:58 +0100)]
NEWS update

13 years agoMerge branch 't/recycling'
Andre Noll [Mon, 7 Feb 2011 16:57:40 +0000 (17:57 +0100)]
Merge branch 't/recycling'

13 years agoMerge branch 't/logfile_only_for_daemon'
Andre Noll [Mon, 7 Feb 2011 16:56:36 +0000 (17:56 +0100)]
Merge branch 't/logfile_only_for_daemon'

13 years agoMinor documentation improvements.
Andre Noll [Sun, 14 Nov 2010 11:17:38 +0000 (12:17 +0100)]
Minor documentation improvements.

13 years agoInclude the NEWS file in the web page.
Andre Noll [Sat, 13 Nov 2010 20:33:03 +0000 (21:33 +0100)]
Include the NEWS file in the web page.

Reformat the release headers in the NEWS file to make the html variant
produced by grutatxt nicer.

13 years agoINSTALL: Fix typo in example.
Andre Noll [Wed, 10 Nov 2010 14:30:20 +0000 (15:30 +0100)]
INSTALL: Fix typo in example.

The dss command line option is called --ls rather than --list. Thanks to Henry
Vogt who spotted this documentation bug.

13 years agoMention that inode monitoring works also for ext2 and ext4.
Andre Noll [Tue, 9 Nov 2010 20:58:04 +0000 (21:58 +0100)]
Mention that inode monitoring works also for ext2 and ext4.

13 years agoChange default program for all hooks from /bin/true to true.
Andre Noll [Tue, 9 Nov 2010 17:43:49 +0000 (18:43 +0100)]
Change default program for all hooks from /bin/true to true.

At least on Mac OS, true is /usr/bin/true, not /bin/true. So the old default
/bin/true causes all hooks to fail on these systems. Since we execute external
programs via execvp() anyway, there is no need to hardcode the path.

Thanks to Henry Vogt for pointing out this flaw.

13 years agodss-0.1.4. v0.1.4
Andre Noll [Mon, 8 Nov 2010 09:52:18 +0000 (10:52 +0100)]
dss-0.1.4.

13 years agoAdd NEWS file.
Andre Noll [Mon, 8 Nov 2010 09:48:10 +0000 (10:48 +0100)]
Add NEWS file.

It contains the release date and the some notes about what has
changed. The text is identical to what is listed as "Changes" on
the freshmeat pages.

13 years agoChange copyright year from 2009 to 2010.
Andre Noll [Sat, 6 Nov 2010 14:14:35 +0000 (15:14 +0100)]
Change copyright year from 2009 to 2010.

Better late than never..

13 years agoIntroduce snapshot recycling.
Andre Noll [Fri, 14 May 2010 12:43:51 +0000 (14:43 +0200)]
Introduce snapshot recycling.

When snapshotting large file systems whose contents do not change much between
snapshots, we end up removing large amounts of files just to recreate (hard
links to) most of them afterwards. This patch changes snapshot creation so that
outdated, redundant and orphaned snapshots are reused as the basis for new
snapshots. Only if no existing snapshot is suitable for recycling, a new one is
created.

13 years agoUse logfile only for --run --daemon.
Andre Noll [Sat, 17 Apr 2010 12:43:00 +0000 (14:43 +0200)]
Use logfile only for --run --daemon.

In all other cases it does not really make sense, so it is
better to write log output to stderr in these cases, even if
--logfile was given.

13 years agoDump config and internal state on SIGHUP.
Andre Noll [Mon, 5 Apr 2010 22:32:47 +0000 (00:32 +0200)]
Dump config and internal state on SIGHUP.

This patch changes the signal handling of SIGHUP so information about
the internal state and the config are written to the log file.

Both the old and the reloaded configuration are written to make it
easier to investigate what has changed.

Internal state output consist of the value of all global variables,
inclusing hook state, PIDs, free disk space and path information.

The patch also adds a one-line description of each possible hook state,
and this description is also printed on SIGHUP.

13 years agoMerge branch 't/unconditional_hooks'
Andre Noll [Wed, 12 May 2010 09:04:36 +0000 (11:04 +0200)]
Merge branch 't/unconditional_hooks'

13 years agoUnify sending of signals.
Andre Noll [Wed, 12 May 2010 09:00:55 +0000 (11:00 +0200)]
Unify sending of signals.

This patch introduces dss_kill(), a wrapper for kill(2) which
prints a nice log message and checks the return value of the
the underlying call to kill().

13 years agoSkip unnecessary check whether next snapshot is due.
Andre Noll [Wed, 12 May 2010 08:23:18 +0000 (10:23 +0200)]
Skip unnecessary check whether next snapshot is due.

If the status of the create hook is PRE_SUCCESS, we _know_ that
the next snapshot is due.

14 years agoDon't check whether hooks are given.
Andre Noll [Mon, 5 Apr 2010 19:39:12 +0000 (21:39 +0200)]
Don't check whether hooks are given.

Just use the default /bin/true if no hook was given.

14 years agoMake all hooks default to /bin/true.
Andre Noll [Mon, 5 Apr 2010 19:58:30 +0000 (21:58 +0200)]
Make all hooks default to /bin/true.

This way, we can always execute the hook which should simplify
the code a bit.

14 years agoRemove a noisy debug log message.
Andre Noll [Fri, 16 Apr 2010 11:46:18 +0000 (13:46 +0200)]
Remove a noisy debug log message.

This message was not very useful at all and spammed the log quite a bit.

14 years agoInvalidate create_pid if create process has died.
Andre Noll [Fri, 16 Apr 2010 11:39:28 +0000 (13:39 +0200)]
Invalidate create_pid if create process has died.

We're checking create_pid against zero at several places, for example before
sending a signal to the create process. So set create_pid is zero in
handle_sigchld() if the create process just died.

14 years agoLog a message when sending signals to the create process.
Andre Noll [Mon, 5 Apr 2010 18:37:14 +0000 (20:37 +0200)]
Log a message when sending signals to the create process.

14 years agopre_remove_hook: Really pass full path of the snapshot.
Andre Noll [Mon, 5 Apr 2010 18:35:47 +0000 (20:35 +0200)]
pre_remove_hook: Really pass full path of the snapshot.

We computed and logged the correct command, but executed the
wrong one.

14 years agoReuse old rsync argv if rsync has to be restarted.
Andre Noll [Thu, 25 Mar 2010 13:49:47 +0000 (14:49 +0100)]
Reuse old rsync argv if rsync has to be restarted.

If rsync must be restarted due to an exit code of 12 or 13,
create_rsync_argv() was called even if the old rsync_argv should
be reused in this case. This (correctly) triggers the assertion

assert(!name_of_reference_snapshot);

in create_rsync_argv(). Fix this by not calling create_rsync_argv()
if there is a reference snapshot.

14 years agoDon't invalidate current_snapshot_time during compute_next_snapshot_time().
Andre Noll [Thu, 25 Mar 2010 13:43:20 +0000 (14:43 +0100)]
Don't invalidate current_snapshot_time during compute_next_snapshot_time().

This bug could lead to snapshots with creation time Jan 1 1970.

14 years agoAvoid busy loop on rsync exit status 12 or 13.
Andre Noll [Fri, 12 Mar 2010 14:47:07 +0000 (15:47 +0100)]
Avoid busy loop on rsync exit status 12 or 13.

Although we set the next snapshot time to now + 60 seconds in case
rsync exits with exit status 12 or 13, we miss to check this time
barrier in case the snapshot creation status is HS_NEEDS_RESTART.

Fix this by adding an additional check in the switch() statement
of the select loop. As this change would trigger the assertion

snapshot_creation_status == HS_READY

in next_snapshot_is_due(), remove this assertion.

14 years agoFix create mode in case no post-create hook is given.
Andre Noll [Fri, 12 Mar 2010 13:32:17 +0000 (14:32 +0100)]
Fix create mode in case no post-create hook is given.

Without the patch, dss would hang forever waiting for the post-create
hook to die.

14 years agoIntroduce --no-resume.
Andre Noll [Mon, 1 Feb 2010 09:21:35 +0000 (10:21 +0100)]
Introduce --no-resume.

If the dss daemon (or the rsync process) is killed while a snaphot
is being created, e.g. because of a server shutdown, the latest
snapshot remains incomplete until it is removed by the usual shapshot
pruning mechanism.

This patch changes the snapshot creation behaviour if the
most recently created snapshot happens to be incomplete and the
new --no-resume option is not given. In this case the directory
of the incomplete snapshot is reused as the destination directory
for the the new snapshot.

This change saves disk space and reduces the snapshot creation time,
depending of course on how far the previous rsync process got before
it was interrupted.

14 years agoFix two typos in comments.
Andre Noll [Thu, 3 Sep 2009 19:29:29 +0000 (21:29 +0200)]
Fix two typos in comments.

14 years agoProperly invalidate create_pid also for the post-create hook.
Andre Noll [Fri, 28 Aug 2009 13:23:57 +0000 (15:23 +0200)]
Properly invalidate create_pid also for the post-create hook.

If the process associated with the create_pid dies, handle_sigchld()
investigates snapshot_creation_status to tell whether the pre-create
hook, the rsync process or the post-create hook has died.

In the first two cases, handle_pre_create_hook_exit() and
handle_rsync_exit() are called, respectively. Both functions correctly
invalidate create_pid (by resetting it to zero).

However, the post-create hook handling code misses to reset
create_pid. This causes dss to send SIGTERM to this pid on exit,
which might be fatal as the pid might have been reassigned to some
unrelated process in the meanwhile.

Fix this bug by moving the invalidation of create_pid to the end of
the "if (pid == create_pid)" clause, which even saves a line of code.

Many thanks to Sebastian Stark who pointed out that bug.

14 years agoDump the dss configuration on startup and on SIGHUP.
Andre Noll [Fri, 28 Aug 2009 11:42:51 +0000 (13:42 +0200)]
Dump the dss configuration on startup and on SIGHUP.

This makes it possible to look at the current dss configuration
(which may differ from what is contained in the config file).

This feature is handy for the users of dss and it helps to debug the
dss code.

14 years agoImprove error diagnostics.
Andre Noll [Fri, 28 Aug 2009 09:28:57 +0000 (11:28 +0200)]
Improve error diagnostics.

When parsing the command line options we must not error out if a
required option was not given because that option might be specified
in the config file. Therefore we have to call cmdline_parser_ext()
with params->check_required = 0.

However, if --config-file is not given and the default config file
(~/.dssrc) does not exist, we end up with no check for required
options at all.

In particular, if the required --dest-dir option is not given,
conf.dest_dir is NULL and we call chdir(NULL) which returns EBADADRESS
at least on Linux. This causes dss to print the error message

Aug 28 11:35:07 main: Bad address

which is not really helpful. Fix this shortcoming by calling
cmdline_parser_ext() _again_ if no config file was read by
parse_config_file(). This second call uses params->check_required =
1, so that a proper error message is printed if any required options
are missing.

In the above example, the output changes to

./dss: '--source-dir' option required
./dss: '--dest-dir' option required

which is much better.

14 years agoImprove next_snapshot_is_due().
Andre Noll [Fri, 28 Aug 2009 09:12:30 +0000 (11:12 +0200)]
Improve next_snapshot_is_due().

Currently it's a bit weird how next_snapshot_is_due() decides whether
the next snapshot time has to be (re-)computed:

On startup, next_snapshot_time is zero as it is declared
static.

next_snapshot_is_due() checks whether next_snapshot_time is
greater than the current time. If yes, then next_snapshot_time
needs not be updated and the function returns false.

Otherwise (e.g. if it is called for the first time),
next_snapshot_time is recomputed, next_snapshot_is_due()
checks again if it is greater than the current time and
returns false if it is, true otherwise.

Consequently, dss computes the next snapshot time twice per snapshot.
Moreover, it compares next_snapshot_time twice against the current time
where one comparison would suffice. The code is thus less efficient
and harder to understand than necessary. This patch addresses both
issues. It introduces the two trivial helper functions

next_snapshot_time_is_valid() and invalidate_next_snapshot_time().

The former function simply tests next_snapshot_time against zero. It
is called from next_snapshot_is_due(). If it returns false, the new
compute_next_snapshot_time() is called (which makes next_snapshot_time
valid). Next, the usual comparison against the current time is
performed.

invalidate_next_snapshot_time() sets next_snapshot_time to zero. It
is called from pre_create_hook() and from handle_sighup(), the latter
call is necessary because changes in the config file might lead to
different snapshot creation times.

14 years agoSimplify computation of next snapshot time.
Andre Noll [Thu, 27 Aug 2009 14:27:29 +0000 (16:27 +0200)]
Simplify computation of next snapshot time.

Using an int64_t rather than a struct timeval for the next snapshot time
makes the code simpler and more readable as we don't have to use the
tv_xxx() functions to perform manipulations.

14 years agoFix off-by-one bug in find_outdated_snapshot().
Andre Noll [Thu, 27 Aug 2009 12:55:02 +0000 (14:55 +0200)]
Fix off-by-one bug in find_outdated_snapshot().

The man page sayeth:

"dss removes any snapshots older than n times u",

where n is the number of unit intervals and u is the duration of
a unit interval. As intervals count from zero, this means that a
snapshot should be considered outdated if its interval number
is greater _or equal_ than n.

However, the current code only removes snapshots in intervals
strictly greater than n. Fix this bug and clarify the documentation.

14 years agoMake snapshot creation trump snapshot removal.
Andre Noll [Wed, 26 Aug 2009 11:24:12 +0000 (13:24 +0200)]
Make snapshot creation trump snapshot removal.

This patch changes the behaviour of dss in case the following three
conditions are all met:

(1) There is at least one snapshot which could be deleted
    (orphaned, redundant, outdated).
(2) Disk space is not low.
(3) A new snapshot is due.

A common case where these conditions are fulfilled is when dss is
started after it was not running for some time, for example due to
a server crash on Friday evening...

In this situation the old code created a new snapshot only after all
orphaned/redundant/outdated have been removed, which can take hours
and is not what one usually wants to happen in the above mentioned
scenario. Instead, it is desirable to create a new snapshot ASAP,
and only after this snapshot has been created, the removal of old
snapshots should take place.

This patch implements this behaviour and goes even one step further:
If disk space is not low and a new snapshot is due or being created,
dss won't trigger snapshot removal any more.

Another positive side effect of this change is that snapshot creation
times become more stable since the rsync process will only be
interrupted by a rm process if disk space is low.

14 years agoMove check for low disk space to try_to_free_disk_space().
Andre Noll [Mon, 24 Aug 2009 08:34:46 +0000 (10:34 +0200)]
Move check for low disk space to try_to_free_disk_space().

The value is only used there, so move the check to this function.

14 years agodss-0.1.3. v0.1.3
Andre Noll [Mon, 6 Jul 2009 13:55:13 +0000 (15:55 +0200)]
dss-0.1.3.

14 years agoChange copyright year from 2008 to 2009.
Andre Noll [Fri, 3 Jul 2009 15:03:39 +0000 (17:03 +0200)]
Change copyright year from 2008 to 2009.

A bit late, but better late than never.

14 years agoTry harder to avoid removing the reference snapshot.
Andre Noll [Mon, 29 Jun 2009 09:36:25 +0000 (11:36 +0200)]
Try harder to avoid removing the reference snapshot.

With the old code, it was possible that dss decided to remove the
snapshot which is currently being used as the hardlink directory for
the current rsync process. This patch changes the behaviour so that
reference snapshots are never removed.

The downside of this approach is of course that it is now easier to
fill up the disk..

14 years agoDon't remove the last snapshot unless disk space is low.
Andre Noll [Mon, 8 Jun 2009 06:15:18 +0000 (08:15 +0200)]
Don't remove the last snapshot unless disk space is low.

14 years agoDon't busy-loop if pre-create hook returns non-zero.
Andre Noll [Mon, 8 Jun 2009 05:57:30 +0000 (07:57 +0200)]
Don't busy-loop if pre-create hook returns non-zero.

Sleep at least one minute before retrying.

14 years agoFix removal of orphaned snapshots.
Andre Noll [Sun, 7 Jun 2009 19:44:50 +0000 (21:44 +0200)]
Fix removal of orphaned snapshots.

These were detected but not removed due to the goto jumping to the
wrong label.

14 years agoImprove documentation of the remove hooks.
Andre Noll [Sun, 7 Jun 2009 19:16:41 +0000 (21:16 +0200)]
Improve documentation of the remove hooks.

14 years agoClean up snapshot removal logic.
Andre Noll [Thu, 4 Jun 2009 11:47:35 +0000 (13:47 +0200)]
Clean up snapshot removal logic.

Replace the remove_xxx_snapshot() functions by find_xxx_snapshot()
and start the actual removal in the caller. This simplifies the
code a bit and makes it much more readable. It also simplifies the
--dry-run handling for com_prune().

14 years agoRemove orphaned snapshots first if disk space is low.
Andre Noll [Fri, 29 May 2009 20:09:06 +0000 (22:09 +0200)]
Remove orphaned snapshots first if disk space is low.

If the dss process gets killed, an orphaned snapshot might result.
Detect this case and prefer to remove such orphaned snapshots before
resorting to remove the oldest snapshot.

14 years agoFix some typos.
Andre Noll [Fri, 29 May 2009 20:03:19 +0000 (22:03 +0200)]
Fix some typos.

14 years agoRestart rsync also on exit value 12.
Andre Noll [Fri, 29 May 2009 11:49:13 +0000 (13:49 +0200)]
Restart rsync also on exit value 12.

An exit value of 12 means "Error in rsync protocol data stream",
and it happens regularly for rsync-3 without apparent reason. So
restart the rsync process also in this case.

14 years agoFix return value of remove_oldest_snapshot().
Andre Noll [Tue, 5 May 2009 08:53:43 +0000 (10:53 +0200)]
Fix return value of remove_oldest_snapshot().

We _must_ return non-zero if the remove was initiated. The old code
would exit with

try_to_free_disk_space: uhuhu: not enough disk space for a single snapshot

even though there are plenty of snapshots available that can be deleted.