]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Merge branch 't/logfile_only_for_daemon'
authorAndre Noll <maan@systemlinux.org>
Mon, 7 Feb 2011 16:56:36 +0000 (17:56 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 7 Feb 2011 16:56:36 +0000 (17:56 +0100)
19 files changed:
INSTALL
Makefile
NEWS [new file with mode: 0644]
daemon.c
df.c
dss.c
dss.ggo
error.h
exec.c
fd.c
fd.h
index.html.in
log.h
signal.c
signal.h
snap.c
snap.h
string.c
time.c

diff --git a/INSTALL b/INSTALL
index 1043ec514884e406adf75dc91678fc8ef1bed775..ff4274b26b3560f404aaaf73591deb6efa998c61 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -51,7 +51,7 @@ Then execute the commands
 
 In order to print the list of all snapshots created so far, use
 
-       dss --list
+       dss --ls
 
 Yes, it's really that easy. Of course, dss supports many more
 features and config options such as taking snapshots from remote
index f59e315752fd83e8949e0392e2c96e198b4d9a67..99b82867cb66c3cba358dce6c64019d2e237de2e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,10 +45,12 @@ dss.1: dss dss.1.inc
 clean:
        rm -f *.o dss dss.1 dss.1.html Makefile.deps *.ppm *.png *~ cmdline.c cmdline.h index.html
 
-index.html: dss.1.html index.html.in INSTALL README
+index.html: dss.1.html index.html.in INSTALL README NEWS
        sed -e '/@README@/,$$d' index.html.in > $@
        grutatxt -nb < README >> $@
-       sed -e '1,/@README@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
+       sed -e '1,/@README@/d' -e '/@NEWS@/,$$d' index.html.in >> $@
+       grutatxt -nb < NEWS >> $@
+       sed -e '1,/@NEWS@/d' -e '/@INSTALL@/,$$d' index.html.in >> $@
        grutatxt -nb < INSTALL >> $@
        sed -e '1,/@INSTALL@/d' -e '/@MAN_PAGE@/,$$d' index.html.in >> $@
        sed -e '1,/Return to Main Contents/d' -e '/Index/,$$d' dss.1.html >> $@
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..6b9deec
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,36 @@
+0.1.4 (2010-11-08)
+~~~~~~~~~~~~~~~~~~
+This version of dss contains some new features, many improvements of
+existing features and several bug fixes.
+
+Support for resuming snapshot creation after restart has been added
+and snapshot removal is deferred until at least one current snapshot
+exists. The internal handling of the various hooks has been simplified
+and many error messages have been clarified. On SIGHUP, dss now writes
+its configuration and internal state to the log file.
+
+0.1.3 (2009-06-06)
+~~~~~~~~~~~~~~~~~~
+You can now specify pre-rm/post-rm-hooks that are executed whenever
+a snapshot is deleted. This release adds better compatibility with
+rsync 3.0, and avoids busy loops when automatically restarting the
+rsync process.
+
+0.1.2 (2009-03-05)
+~~~~~~~~~~~~~~~~~~
+This release includes the reason why a snapshot gets removed in the
+log message. It will never remove the snapshot that is currently
+being created. It will really pass the full path to the last complete
+snapshot in the post_create_hook.
+
+0.1.1 (2008-11-13)
+~~~~~~~~~~~~~~~~~~
+This release prevents busy loops on rsync exit code 13. It ignores
+any snapshot directory with creation time &gt; completion time. It
+opens /dev/null for reading and writing when executing rsync. It shows
+human readable snapshot creation duration when listing snapshots. It
+restarts the rsync process if it returned with exit code 13.
+
+0.1.0 (2008-10-10)
+~~~~~~~~~~~~~~~~~~
+Initial public release.
index 17a171e07c1f4865295c8ef3678c414fdfe4616f..d48e30c995245986bc0761eda9e7ecf52c0736e0 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/df.c b/df.c
index 37e2b4317a01448cc8e255d30ca3534bf644940e..513bd19ca8750cdcfeef08747b34e6ac57cc1eba 100644 (file)
--- a/df.c
+++ b/df.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/dss.c b/dss.c
index e32e7e20a1efcad97f213b7da6212bb881ccc248..b4ad2d28960a3c89e9b489d365f45ffed1376e8e 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -64,7 +64,106 @@ enum hook_status snapshot_removal_status;
 
 
 DEFINE_DSS_ERRLIST;
+static const char const *hook_status_description[] = {HOOK_STATUS_ARRAY};
 
+/* may be called with ds == NULL. */
+static int disk_space_low(struct disk_space *ds)
+{
+       struct disk_space ds_struct;
+
+       if (!ds) {
+               int ret = get_disk_space(".", &ds_struct);
+               if (ret < 0)
+                       return ret;
+               ds = &ds_struct;
+       }
+       if (conf.min_free_mb_arg)
+               if (ds->free_mb < conf.min_free_mb_arg)
+                       return 1;
+       if (conf.min_free_percent_arg)
+               if (ds->percent_free < conf.min_free_percent_arg)
+                       return 1;
+       if (conf.min_free_percent_inodes_arg)
+               if (ds->percent_free_inodes < conf.min_free_percent_inodes_arg)
+                       return 1;
+       return 0;
+}
+
+static void dump_dss_config(const char *msg)
+{
+       const char dash[] = "-----------------------------";
+       int ret;
+       FILE *log = logfile? logfile : stderr;
+       struct disk_space ds;
+       int64_t now = get_current_time();
+
+       if (conf.loglevel_arg > INFO)
+               return;
+
+       fprintf(log, "%s <%s config> %s\n", dash, msg, dash);
+       fprintf(log, "\n*** disk space ***\n\n");
+       ret = get_disk_space(".", &ds);
+       if (ret >= 0) {
+               DSS_INFO_LOG("disk space low: %s\n", disk_space_low(&ds)?
+                       "yes" : "no");
+               log_disk_space(&ds);
+       } else
+               DSS_ERROR_LOG("can not get free disk space: %s\n",
+                       dss_strerror(-ret));
+
+       /* we continue on errors from get_disk_space */
+
+       fprintf(log, "\n*** command line and config file options ***\n\n");
+       cmdline_parser_dump(log, &conf);
+       fprintf(log, "\n*** internal state ***\n\n");
+       fprintf(log,
+               "pid: %d\n"
+               "logile: %s\n"
+               "snapshot_currently_being_removed: %s\n"
+               "path_to_last_complete_snapshot: %s\n"
+               "reference_snapshot: %s\n"
+               "snapshot_creation_status: %s\n"
+               "snapshot_removal_status: %s\n"
+               ,
+               (int) getpid(),
+               logfile? conf.logfile_arg : "stderr",
+               snapshot_currently_being_removed?
+                       snapshot_currently_being_removed->name : "(none)",
+               path_to_last_complete_snapshot?
+                       path_to_last_complete_snapshot : "(none)",
+               name_of_reference_snapshot?
+                       name_of_reference_snapshot : "(none)",
+               hook_status_description[snapshot_creation_status],
+               hook_status_description[snapshot_removal_status]
+       );
+       if (create_pid != 0)
+               fprintf(log,
+                       "create_pid: %" PRId32 "\n"
+                       "create process is %sstopped\n"
+                       ,
+                       create_pid,
+                       create_process_stopped? "" : "not "
+               );
+       if (remove_pid != 0)
+               fprintf(log, "remove_pid: %" PRId32 "\n", remove_pid);
+       if (next_snapshot_time != 0)
+               fprintf(log, "next snapshot due in %" PRId64 " seconds\n",
+                       next_snapshot_time - now);
+       if (current_snapshot_creation_time != 0)
+               fprintf(log, "current_snapshot_creation_time: %"
+                       PRId64 " (%" PRId64 " seconds ago)\n",
+                       current_snapshot_creation_time,
+                       now - current_snapshot_creation_time
+               );
+       if (next_removal_check.tv_sec != 0) {
+               fprintf(log, "next removal check: %llu (%llu seconds ago)\n",
+                       (long long unsigned)next_removal_check.tv_sec,
+                       now - (long long unsigned)next_removal_check.tv_sec
+               );
+
+       }
+       fprintf(log, "%s </%s config> %s\n", dash, msg, dash);
+}
 
 /* a litte cpp magic helps to DRY */
 #define COMMANDS \
@@ -127,25 +226,6 @@ static __printf_1_2 void dss_msg(const char* fmt,...)
        va_end(argp);
 }
 
-static int disk_space_low(void)
-{
-       struct disk_space ds;
-       int ret = get_disk_space(".", &ds);
-
-       if (ret < 0)
-               return ret;
-       if (conf.min_free_mb_arg)
-               if (ds.free_mb < conf.min_free_mb_arg)
-                       return 1;
-       if (conf.min_free_percent_arg)
-               if (ds.percent_free < conf.min_free_percent_arg)
-                       return 1;
-       if (conf.min_free_percent_inodes_arg)
-               if (ds.percent_free_inodes < conf.min_free_percent_inodes_arg)
-                       return 1;
-       return 0;
-}
-
 static void dss_get_snapshot_list(struct snapshot_list *sl)
 {
        get_snapshot_list(sl, conf.unit_interval_arg, conf.num_intervals_arg);
@@ -441,7 +521,7 @@ static int try_to_free_disk_space(void)
        const char *why;
        int low_disk_space;
 
-       ret = disk_space_low();
+       ret = disk_space_low(NULL);
        if (ret < 0)
                return ret;
        low_disk_space = ret;
@@ -903,24 +983,16 @@ static int change_to_dest_dir(void)
        return dss_chdir(conf.dest_dir_arg);
 }
 
-static void dump_dss_config(const char *msg)
-{
-       if (conf.loglevel_arg > INFO)
-               return;
-       DSS_INFO_LOG("%s\n", msg);
-       cmdline_parser_dump(logfile? logfile : stderr, &conf);
-}
-
 static int handle_sighup(void)
 {
        int ret;
 
        DSS_NOTICE_LOG("SIGHUP, re-reading config\n");
-       dump_dss_config("current config");
+       dump_dss_config("old");
        ret = parse_config_file(1);
        if (ret < 0)
                return ret;
-       dump_dss_config("new config");
+       dump_dss_config("reloaded");
        invalidate_next_snapshot_time();
        return change_to_dest_dir();
 }
@@ -1354,10 +1426,10 @@ int main(int argc, char **argv)
        }
        if (conf.daemon_given)
                daemon_init();
-       dump_dss_config("dss configuration");
        ret = change_to_dest_dir();
        if (ret < 0)
                goto out;
+       dump_dss_config("startup");
        ret = setup_signal_handling();
        if (ret < 0)
                goto out;
diff --git a/dss.ggo b/dss.ggo
index 8f1ec5cf8d3ce50194a81f569b8195eb6562a618..1662e0d36f514491c1029e674bc407a98012942d 100644 (file)
--- a/dss.ggo
+++ b/dss.ggo
@@ -1,9 +1,9 @@
-# Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
+# Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
 #
 # Licensed under the GPL v2. For licencing details see COPYING.
 
 package "dss"
-version "0.1.3"
+version "0.1.4"
 purpose "the dyadic snapshot scheduler
 
 dss creates hardlink-based snapshots of a given directory on a remote
@@ -269,7 +269,7 @@ option "pre-create-hook" r
 #~~~~~~~~~~~~~~~~~~~~~~~~~~
 "Executed before snapshot creation"
 string typestr="command"
-default = "/bin/true"
+default = "true"
 optional
 details="
        Execute this command before trying to create a new snapshot.
@@ -288,7 +288,7 @@ option "post-create-hook" o
 #~~~~~~~~~~~~~~~~~~~~~~~~~~
 "Executed after snapshot creation"
 string typestr="command"
-default = "/bin/true"
+default = "true"
 optional
 details="
        Execute this after a snapshot has successfully been
@@ -305,7 +305,7 @@ option "pre-remove-hook" -
 #~~~~~~~~~~~~~~~~~~~~~~~~~~
 "Executed before snapshot removal"
 string typestr="command"
-default = "/bin/true"
+default = "true"
 optional
 details="
        Execute this command before removing a snapshot. The full
@@ -327,7 +327,7 @@ option "post-remove-hook" -
 #~~~~~~~~~~~~~~~~~~~~~~~~~~
 "Executed after snapshot removal"
 string typestr="command"
-default = "/bin/true"
+default = "true"
 optional
 details="
        Execute this after a snapshot has successfully been removed. As
@@ -340,7 +340,7 @@ option "exit-hook" e
 #~~~~~~~~~~~~~~~~~~~
 "Executed if run command exits"
 string typestr="command"
-default = "/bin/true"
+default = "true"
 optional
 details="
        This hook is only used if the --run command was given which
@@ -401,7 +401,8 @@ details="
        Note that not every file system supports the concept of inodes.
        Moreover it is not possible to reliably detect whether this is
        the case. Therefore this feature is disabled by default. It's
-       safe to enable it for ext3 file systems on linux though.
+       safe to enable it for ext2/ext3/ext4 file systems on linux
+       though.
 
        A value of zero (the default) deactivates this check.
 "
diff --git a/error.h b/error.h
index b492c326d8c122e95b61aad6665fe20c9823fe99..9e910e2b2236bb9dae79b1d1df36ea0cb5a27b3a 100644 (file)
--- a/error.h
+++ b/error.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/exec.c b/exec.c
index a5d0cd08f34fee97921a139bef766d70191aaa69..2887cb29972b949f67bc4b4197652c8c8592b261 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2003-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2003-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/fd.c b/fd.c
index a0b897e34e07b780542f4730ce6cca731afce5c1..2b002c75a515c6d59ddbb41c79c1b2c7ebfeaa02 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/fd.h b/fd.h
index 806f8942aaf7e68bad271f521e7f5cc9720292f7..991afd4baa81755594f15016ff48a19632e8836d 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2006-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
index b42402f7720f8191ac37b191ce005ab2094aba00..d9848448345f302e5a6aedd8ce8a9e95492dff38 100644 (file)
@@ -23,6 +23,7 @@
        <hr>
 
        [<a href="#readme">README</a>]
+       [<a href="#news">NEWS</a>]
        [<a href="#download">Download</a>]
        [<a href="#install">INSTALL</a>]
        [<a href="#license">License</a>]
 
        <hr>
 
+       <center>
+               <h2>
+                       <a name="news">NEWS</a>
+               </h2>
+       </center>
+
+       @NEWS@
+
+       <hr>
 
        <center>
                <h2>
@@ -64,7 +74,7 @@
 
        <a href="http://git.tuebingen.mpg.de/cgi-bin/gitweb.cgi?p=dss.git;a=snapshot;h=HEAD;sf=tgz">tarball</a>
 
-       of the current tree. If you prefer to download the tarball of
+       of the current master branch. If you prefer to download the tarball of
        the latest release, select the corresponding <em>snapshot</em>
        link on the
 
 
        <p> Andr&eacute; Noll, <a
        href="mailto:maan@systemlinux.org">maan@systemlinux.org</a>
-       </p> Comments and bug reports are welcome Please provide
+       </p> Comments and bug reports are welcome. Please provide
        enough info such as the version of dss you are using and
        relevant parts of the logs. Including the string [dss] in
        the subject line is also a good idea.
diff --git a/log.h b/log.h
index 178c6866a590b3e22f6de5d87c29698090428162..5d38c7bfaa74bcda2aad3c0fd8058b936c1a7e47 100644 (file)
--- a/log.h
+++ b/log.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
index d22cd591c54748ac495b1079398ec16c3848f48e..3bbe87d84a810afcb21f11de65b48caf80c622ac 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2004-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
index a0e98996f7a245ca6bc9bd0816ac5af82be5dc28..0c5b3d8601db5f03a17d2a07731f479dbf15d879 100644 (file)
--- a/signal.h
+++ b/signal.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/snap.c b/snap.c
index 1ff5fd7848e079f9cc954a03316bf8e0f4ae274b..41dc3296531001d88e9beb709b66c47d2fd2090d 100644 (file)
--- a/snap.c
+++ b/snap.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/snap.h b/snap.h
index 5c2f20b2885e19919afabff1369908fdb6c5bf18..b9659aeb0784a92744ea5b3a95d37ad3908aafd4 100644 (file)
--- a/snap.h
+++ b/snap.h
@@ -1,26 +1,26 @@
 /*
- * Copyright (C) 2008-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
 
+
 /** The possible states for snapshot creation/removal. */
-enum hook_status {
-       /** We are ready to take the next snapshot. */
-       HS_READY,
-       /** The pre-create/pre-remove hook has been started. */
-       HS_PRE_RUNNING,
-       /** The pre-create/pre-remove hook exited successfully. */
-       HS_PRE_SUCCESS,
-       /** The rsync/rm process is running. */
-       HS_RUNNING,
-       /** The rsync/rm process exited successfully. */
-       HS_SUCCESS,
-       /** The rsync/rm process needs to be restarted. */
-       HS_NEEDS_RESTART,
-       /** The post-create/post-remove hook has been started. */
-       HS_POST_RUNNING,
-};
+#define HOOK_STATUS_ARRAY \
+       HSA_ITEM(HS_READY, "ready for action"), \
+       HSA_ITEM(HS_PRE_RUNNING, "pre-hook running"), \
+       HSA_ITEM(HS_PRE_SUCCESS, "pre-hook completed successfully"), \
+       HSA_ITEM(HS_RUNNING, "in progress"), \
+       HSA_ITEM(HS_SUCCESS, "process terminated successfully"), \
+       HSA_ITEM(HS_NEEDS_RESTART, "restart needed"), \
+       HSA_ITEM(HS_POST_RUNNING, "post-hook running"), \
+
+
+#define HSA_ITEM(x, y) x
+enum hook_status {HOOK_STATUS_ARRAY};
+#undef HSA_ITEM
+#define HSA_ITEM(x, y) [x] = y
+
 
 /**
  * The status of a snapshot.
index 60c53d58d84ec0c2fd017b20b02b4c6cd636b801..d370a81667af4c56509a9d85d9712b6c3a268a92 100644 (file)
--- a/string.c
+++ b/string.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2004-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
diff --git a/time.c b/time.c
index 0ad974bcac6c8fdf31363e2ad95e4c270e4a5d97..3cc1ad64ac943422b30df8a8532f629cbcc63c2d 100644 (file)
--- a/time.c
+++ b/time.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2005-2010 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */