RandomDan n00b
Joined: 03 Jul 2005 Posts: 10 Location: Doncaster, United Kingdom
|
Posted: Tue Jul 15, 2014 2:02 pm Post subject: courier-imapd and OCFS2 |
|
|
Hello all,
This is an odd problem to say the least.
Some background: Some time ago, I swapped out /home on GlusterFS to /home on primary/primary OCFS2 on DRBD setup. All seemed well at first. Everything appeared to work, everything was fast, I was a happy man.
Then recently I noticed that some emails were going missing, but couldn't spot a pattern.
What I've found is a problem which I think lies in OCFS2 or in courier-imapd. It only appears to show itself when a mail client (Thunderbird in my case, by messages filters, which is why I hadn't noticed) tries to move an email from one IMAP account to my IMAP account. What appears to happen is that the new mail message is successfully created in ~/.maildir/tmp and not moved to ~/.maildir/cur.
I couldn't find any errors logged by courier anywhere and ignored it for a while... then I noticed this:
Code: |
Jul 14 13:20:08 defiant kernel: (courier-imapd,20893,1):ocfs2_link:790 ERROR: status = -2
|
A little bit of digging in the courier source and I found this function....
Code: |
int maildir_movetmpnew(const char *tmpname, const char *newname)
{
if (link(tmpname, newname) == 0)
{
unlink(tmpname);
return 0;
}
if (errno != EXDEV)
return -1;
/* AFS? */
return rename(tmpname, newname);
}
|
Which on the face of it seems to be more complicated than needs be and expects problems on AFS. So in the spirit of testing, I changed the function to be:
Code: |
int maildir_movetmpnew(const char *tmpname, const char *newname)
{
return rename(tmpname, newname);
}
|
Normal operation has now returned.
While I can see what's happening in that function... I don't get why it needs to be so complicated in the first place (I presume there's a good reason, but if simple rename works on AFS, why not for everything else?) and I don't see why my change would fix it. My gut feeling is there is a race condition in OCFS2 that link/unlink suffer from and that rename does not.
Can anyone should some light on this? Anyone else tried courier-imap on OCFS2?
Any thoughts very welcome. I'm planning on raising this upstream, but I'm genuinely not sure which upstream to go with!
Thanks in advance.
Dan |
|