Jack Schmidt
2008-Jan-23 14:20 UTC
[Dovecot] Rename file opened for read-write -- cannot edit subscriptions
Howdy, Here is a problem with fix affecting dovecot-1.0.10 (and 1.1rc13). On a linux system's CIFS mounted filesystem, it is not possible to rename a file opened read-write: $ sleep 5 >> .subscriptions.lock & mv .subscriptions.lock .subscriptions mv: cannot move `.subscriptions.lock' to `.subscriptions': Text file busy This causes problems in editing subscriptions, as the new subscription list is still open for writing before it is renamed in: lib-storage/subscription-file/subscription-file.c line 169 in dovecot version 1.0.10 (and 1.1rc13) This is an unpatched linux 2.6.21-5, CIFS mounted filesystem from a windows 2003 sp2 server. The documentation for rename(2) indicates that it is allowed to return an error when the file is already opened, so perhaps the file should be closed before the replace. Should this be done in file_dotlock_replace (before line 672) generally? Here is a patch that does so: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: dovecot-rename.diff URL: <http://dovecot.org/pipermail/dovecot/attachments/20080123/c0e84a31/attachment-0002.pl>
Timo Sirainen
2008-Jan-31 15:52 UTC
[Dovecot] Rename file opened for read-write -- cannot edit subscriptions
On Wed, 2008-01-23 at 09:20 -0500, Jack Schmidt wrote:> On a linux system's CIFS mounted filesystem, it is not possible to > rename a file opened read-write: > > $ sleep 5 >> .subscriptions.lock & mv .subscriptions.lock .subscriptions > mv: cannot move `.subscriptions.lock' to `.subscriptions': Text file busyDoes this happen only if the file is opened by the same process, or also if it's opened by another process? Sounds like it happens no matter who has the file open.> The documentation for rename(2) indicates that it is allowed to return > an error when the file is already opened,I don't see it saying that in Debian unstable or in UNIX98 specs.> so perhaps the file should be > closed before the replace. Should this be done in file_dotlock_replace > (before line 672) generally?This is a similar patch than I've previously suggested to people having similar NFS problems: http://dovecot.org/list/dovecot/2006-December/018145.html But I don't really want to make it work like that as default. It most likely doesn't fix all the possible places in code where this can happen. Or if this same problem happens when another process has the file opened, this doesn't help with it either. So if someone is using a system where this is a problem, I'd rather have them patch this code themselves so they know that Dovecot may not always work correctly. -------------- 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/20080131/0a2cf3c3/attachment-0002.bin>