dovecot-1.2: Linux/Solaris NFS: if there are no locks, try flush...

dovecot at dovecot.org dovecot at dovecot.org
Fri Nov 21 22:57:54 EET 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/9bcc2dd5f17f
changeset: 8476:9bcc2dd5f17f
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Nov 21 22:57:50 2008 +0200
description:
Linux/Solaris NFS: if there are no locks, try flushing data cache by flushing attr cache.

diffstat:

1 file changed, 14 insertions(+), 4 deletions(-)
src/lib/nfs-workarounds.c |   18 ++++++++++++++----

diffs (49 lines):

diff -r b64fb26e3b6f -r 9bcc2dd5f17f src/lib/nfs-workarounds.c
--- a/src/lib/nfs-workarounds.c	Fri Nov 21 22:40:48 2008 +0200
+++ b/src/lib/nfs-workarounds.c	Fri Nov 21 22:57:50 2008 +0200
@@ -214,10 +214,14 @@ static bool nfs_flush_fchown_uid(const c
 #endif
 
 #ifdef READ_CACHE_FLUSH_FCNTL
-static void nfs_flush_fcntl(const char *path, int fd)
-{
+static bool nfs_flush_fcntl(const char *path, int fd)
+{
+	static bool locks_disabled = FALSE;
 	struct flock fl;
 	int ret;
+
+	if (locks_disabled)
+		return FALSE;
 
 	/* If the file was already locked, we'll just get the same lock
 	   again. It should succeed just fine. If was was unlocked, we'll
@@ -233,12 +237,17 @@ static void nfs_flush_fcntl(const char *
 	alarm(0);
 
 	if (unlikely(ret < 0)) {
+		if (errno == ENOLCK) {
+			locks_disabled = TRUE;
+			return FALSE;
+		}
 		i_error("nfs_flush_fcntl: fcntl(%s, F_RDLCK) failed: %m", path);
-		return;
+		return FALSE;
 	}
 
 	fl.l_type = F_UNLCK;
 	(void)fcntl(fd, F_SETLKW, &fl);
+	return TRUE;
 }
 #endif
 
@@ -376,7 +385,8 @@ void nfs_flush_read_cache_unlocked(const
 void nfs_flush_read_cache_unlocked(const char *path, int fd)
 {
 #ifdef READ_CACHE_FLUSH_FCNTL
-	nfs_flush_fcntl(path, fd);
+	if (!nfs_flush_fcntl(path, fd))
+		nfs_flush_attr_cache_fd_locked(path, fd);
 #else
 	nfs_flush_read_cache_locked(path, fd);
 #endif


More information about the dovecot-cvs mailing list