Disable creation of hardlinks in message store

Simon Matter simon.matter at ch.sauter-bc.com
Thu Jun 2 09:17:50 EDT 2005

> I've tried to get rid of hardlinked files in our cyrus spools to make
> partial mailbox restores easier and more safe. My first idea was to set
> "singleinstancestore: no" in imapd.conf and make all payload files
> independant from each other. Unfortunately I realized later that while
> incoming messages are stored in independant files, the IMAP COPY command
> still creates hardlinked message files. Of course there is nothing wrong
> with singleinstancestore because the manpage clearly states that only
> delivery via lmtp/nntp is affected.
> I have now looked at the code and found that mailbox_copyfile() has a
> nolink parameter which controls the copy/link behaviour. My idea was to
> create a new config option to disable hardlinks completely.
> My questions:
> - is such an option a very bad idea?
> - does such a patch already exist somewhere?
> - what's the best name of a new config option?
> - is there a chance to have such a patch accepted into the distribution?

I'd like to include the following patch into my cyrus-imapd rpm packages
to address the issue mentioned above. While testing it on a test box it
seemed to work very well. Do the cyrus developers see any possible problem
with it?


diff -Naur cyrus-imapd-2.2.12.orig/imap/mailbox.c
--- cyrus-imapd-2.2.12.orig/imap/mailbox.c      2005-02-14
07:39:57.000000000 +0100
+++ cyrus-imapd-2.2.12/imap/mailbox.c   2005-06-02 13:33:31.000000000 +0200
@@ -2657,7 +2657,7 @@
     unsigned long src_size = 0;
     int n;

-    if (!nolink) {
+    if (!nolink && !config_getswitch(IMAPOPT_NOLINKIMAPSPOOL)) {
        if (link(from, to) == 0) return 0;
        if (errno == EEXIST) {
            if (unlink(to) == -1) {
diff -Naur cyrus-imapd-2.2.12.orig/lib/imapoptions
--- cyrus-imapd-2.2.12.orig/lib/imapoptions     2004-07-21
21:07:45.000000000 +0200
+++ cyrus-imapd-2.2.12/lib/imapoptions  2005-06-02 13:29:01.000000000 +0200
@@ -556,6 +556,13 @@
 /* Prefix to be prepended to newsgroup names to make the corresponding
    IMAP mailbox names. */

+{ "nolinkimapspool", 0, SWITCH }
+/* If enabled, no hard links are ever created for messages even with
+   \fBsingleinstancestore\fR enabled. This is useful to make partial
+   mailbox restores easier with backup software which doesn't handle
+   hard links very well, resulting in a potentially much higher disk
+   space usage. */
 { "notifysocket", "{configdirectory}/socket/notify", STRING }
 /* Unix domain socket that the new mail notification daemon listens on. */

Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html

More information about the Info-cyrus mailing list