Hi Slight problem - linux 2.4 running dovecot, Solaris 2.8 home directory server. Full lockd support etc. I had to make the following code patches (at end of mail for clarity) to get dovecot to read the users mbox files at all. 1) fcntl with F_SETLKW will not work against a Solaris 2.8 server as proved with a small test program. Other forms of fcntl (ie F_SETLK) are OK. I noticed there are some code witches, but setting mbox_lock_timeout=0 only seems to knock one of the fcntl's over to F_SETLK 2) O_CREAT | O_EXCL are documented not to work over NFS properly (see man open(2) on linux). So I knocked out the O_EXCL and combined with (1) dovecot will talk over NFS to remote mbox files. THESE ARE NOT VIABLE CODE PATCHES They illustrate a problem I found - they are hackish and totally wrong. I'm not sure of the best way to correct this problem cleanly, so I am just submitting it as a potential bug. Cheers Tim Southerwood ************************************************** --- dovecot-1.0-test28/src/lib/file-lock.c.orig 2004-07-20 14:29:47.000000000 +0100 +++ dovecot-1.0-test28/src/lib/file-lock.c 2004-07-20 14:30:15.000000000 +0100 @@ -38,7 +38,7 @@ fl.l_start = 0; fl.l_len = 0; - while (fcntl(fd, timeout != 0 ? F_SETLKW : F_SETLK, &fl) < 0) { + while (fcntl(fd, timeout != 0 ? F_SETLK : F_SETLK, &fl) < 0) { if (timeout == 0 && (errno == EACCES || errno == EAGAIN)) return 0; --- dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-lock.c.orig 2004-07-20 14:29:54.000000000 +0100 +++ dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-lock.c 2004-07-20 14:30:35.000000000 +0100 @@ -361,7 +361,7 @@ fl.l_start = 0; fl.l_len = 0; - wait_type = max_wait_time == 0 ? F_SETLK : F_SETLKW; + wait_type = max_wait_time == 0 ? F_SETLK : F_SETLK; while (fcntl(ctx->ibox->mbox_fd, wait_type, &fl) < 0) { if (errno != EINTR) { if (errno != EAGAIN && errno != EACCES) ************************************************** and ************************************************** diff -NaurbB dovecot-1.0-test28.orig/src/lib/file-dotlock.c dovecot-1.0-test28/src/lib/file-dotlock.c--- dovecot-1.0-test28.orig/src/lib/file-dotlock.c 2004-06-28 18:28:01.000000000 +0100+++ dovecot-1.0-test28/src/lib/file-dotlock.c 2004-07-20 14:50:33.000000000 +0100 @@ -192,7 +192,7 @@ return -1; } - fd = open(*path_r, O_RDWR | O_EXCL | O_CREAT, 0666); + fd = open(*path_r, O_RDWR | O_CREAT, 0666); if (fd != -1) return fd; diff -NaurbB dovecot-1.0-test28.orig/src/lib-storage/index/maildir/maildir-util.c dovecot-1.0-test28/src/lib-storage/index/maildir/maildir-util.c--- dovecot-1.0-test28.orig/src/lib-storage/index/maildir/maildir-util.c 2004-06-16 01:50:41.000000000 +0100+++ dovecot-1.0-test28/src/lib-storage/index/maildir/maildir-util.c 2004-07-20 14:51:25.000000000 +0100@@ -241,7 +241,7 @@ if (stat(path, &st) < 0 && errno == ENOENT) { /* doesn't exist */ mode_t old_mask = umask(0); - fd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode); + fd = open(path, O_WRONLY | O_CREAT, mode); umask(old_mask); if (fd != -1 || errno != EEXIST) break; diff -NaurbB dovecot-1.0-test28.orig/src/lib-storage/index/mbox/mbox-storage.c dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-storage.c--- dovecot-1.0-test28.orig/src/lib-storage/index/mbox/mbox-storage.c 2004-07-20 14:45:55.000000000 +0100+++ dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-storage.c 2004-07-20 14:49:56.000000000 +0100@@ -386,7 +386,7 @@ int fd; /* make sure inbox file itself exists */ - fd = open(storage->inbox_path, O_RDWR | O_CREAT | O_EXCL, 0660); + fd = open(storage->inbox_path, O_RDWR | O_CREAT, 0660); if (fd != -1) (void)close(fd); @@ -579,7 +579,7 @@ } /* create the mailbox file */ - fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0660); + fd = open(path, O_RDWR | O_CREAT, 0660); if (fd != -1) { (void)close(fd); return 0; diff -NaurbB dovecot-1.0-test28.orig/src/lib-storage/index/mbox/mbox-storage.c.mbox dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-storage.c.mbox--- dovecot-1.0-test28.orig/src/lib-storage/index/mbox/mbox-storage.c.mbox 2004-07-11 22:03:09.000000000 +0100+++ dovecot-1.0-test28/src/lib-storage/index/mbox/mbox-storage.c.mbox 2004-07-20 14:50:58.000000000 +0100@@ -386,7 +386,7 @@ int fd; /* make sure inbox file itself exists */ - fd = open(storage->inbox_path, O_RDWR | O_CREAT | O_EXCL, 0660); + fd = open(storage->inbox_path, O_RDWR | O_CREAT, 0660); if (fd != -1) (void)close(fd); @@ -579,7 +579,7 @@ } /* create the mailbox file */ - fd = open(path, O_RDWR | O_CREAT | O_EXCL, 0660); + fd = open(path, O_RDWR | O_CREAT, 0660); if (fd != -1) { (void)close(fd); return 0; ************************************************** -- Tim J Southerwood Senior Programmer CSG, Dept of Computing, Imperial College, London
On Tue, 2004-07-20 at 19:24, Tim Southerwood wrote:> Slight problem - linux 2.4 running dovecot, Solaris 2.8 home directory > server. Full lockd support etc. > > I had to make the following code patches (at end of mail for clarity) to > get dovecot to read the users mbox files at all. > > 1) fcntl with F_SETLKW will not work against a Solaris 2.8 server as > proved with a small test program. Other forms of fcntl (ie F_SETLK) are > OK.Hmm. I guess I could make it optionally emulate F_SETLKW by looping and checking the lock a few times a second. Or you could just disable fcntl locks: fcntl_locks_disable = yes mbox_read_locks = dotlock mbox_write_locks = dotlock> 2) O_CREAT | O_EXCL are documented not to work over NFS properly (see > man open(2) on linux). So I knocked out the O_EXCL and combined with (1) > dovecot will talk over NFS to remote mbox files.I don't think it breaks even if it's used, it just doesn't do anything? Dovecot doesn't rely on it, it's just for extra safety in case it works. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://dovecot.org/pipermail/dovecot/attachments/20040720/8a625b11/attachment-0001.bin>
Hi On Tue, 20 Jul 2004 20:29:01 +0300 Timo Sirainen <tss at iki.fi> wrote:> On Tue, 2004-07-20 at 19:24, Tim Southerwood wrote: > > Slight problem - linux 2.4 running dovecot, Solaris 2.8 home > > directory server. Full lockd support etc. > > > > I had to make the following code patches (at end of mail for > > clarity) to get dovecot to read the users mbox files at all. > > > > 1) fcntl with F_SETLKW will not work against a Solaris 2.8 server as > > proved with a small test program. Other forms of fcntl (ie F_SETLK) > > are OK. > > Hmm. I guess I could make it optionally emulate F_SETLKW by looping > and checking the lock a few times a second. Or you could just disable > fcntl locks: > > fcntl_locks_disable = yes > mbox_read_locks = dotlock > mbox_write_locks = dotlock > > > 2) O_CREAT | O_EXCL are documented not to work over NFS properly > > (see man open(2) on linux). So I knocked out the O_EXCL and combined > > with (1) dovecot will talk over NFS to remote mbox files. > > I don't think it breaks even if it's used, it just doesn't do > anything? Dovecot doesn't rely on it, it's just for extra safety in > case it works. >Not sure - it does seem to do what it's supposed according to man open (fail), according to strace. But before I make those changes, the code has problems with my setup. After it works. The test28 works perfectly in this repsect at home where I don't use NFS for mail. I think I should isolate exactly which opens need tweaking and come back with something more specific. Put this on hold as unconfirmed. Tim -- Tim Southerwood Website: http://www.dionic.net/ email: ts at DIESPAMDIE.dionic.net (remove DIESPAMDIE. to get address)
Matthias Andree
2004-Jul-22 12:08 UTC
[Dovecot] Re: Bug? 1.0.0-test28 NFS locking problems
Tim Southerwood <ts at doc.ic.ac.uk> writes:> 1) fcntl with F_SETLKW will not work against a Solaris 2.8 server as > proved with a small test program. Other forms of fcntl (ie F_SETLK) are > OK.Why not? Can you show the test program? -- Matthias Andree Encrypted mail welcome: my GnuPG key ID is 0x052E7D95 (PGP/MIME preferred)