dovecot-1.1: squat: Flush NFS caches.
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 25 03:11:22 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/7512b6d8afe1
changeset: 7544:7512b6d8afe1
user: Timo Sirainen <tss at iki.fi>
date: Sun May 25 03:11:15 2008 +0300
description:
squat: Flush NFS caches.
diffstat:
1 file changed, 15 insertions(+), 5 deletions(-)
src/plugins/fts-squat/squat-trie.c | 20 +++++++++++++++-----
diffs (65 lines):
diff -r 8a4ac809d472 -r 7512b6d8afe1 src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c Sun May 25 02:58:42 2008 +0300
+++ b/src/plugins/fts-squat/squat-trie.c Sun May 25 03:11:15 2008 +0300
@@ -7,6 +7,7 @@
#include "istream.h"
#include "ostream.h"
#include "unichar.h"
+#include "nfs-workarounds.h"
#include "file-cache.h"
#include "seq-range-array.h"
#include "squat-uidlist.h"
@@ -246,7 +247,9 @@ static int squat_trie_is_file_stale(stru
{
struct stat st, st2;
- if (stat(trie->path, &st) < 0) {
+ if ((trie->flags & SQUAT_INDEX_FLAG_NFS_FLUSH) != 0)
+ nfs_flush_file_handle_cache(trie->path);
+ if (nfs_safe_stat(trie->path, &st) < 0) {
if (errno == ENOENT)
return 1;
@@ -254,6 +257,8 @@ static int squat_trie_is_file_stale(stru
return -1;
}
if (fstat(trie->fd, &st2) < 0) {
+ if (errno == ESTALE)
+ return 1;
i_error("fstat(%s) failed: %m", trie->path);
return -1;
}
@@ -281,7 +286,7 @@ static int squat_trie_lock(struct squat_
*file_lock_r = NULL;
*dotlock_r = NULL;
- while (trie->fd != -1) {
+ for (;;) {
if (trie->lock_method != FILE_LOCK_METHOD_DOTLOCK) {
ret = file_wait_lock(trie->fd, trie->path, lock_type,
trie->lock_method,
@@ -302,7 +307,7 @@ static int squat_trie_lock(struct squat_
file and try to lock again */
ret = squat_trie_is_file_stale(trie);
if (ret == 0)
- return 1;
+ break;
if (*file_lock_r != NULL)
file_unlock(file_lock_r);
@@ -314,8 +319,13 @@ static int squat_trie_lock(struct squat_
squat_trie_close(trie);
if (squat_trie_open_fd(trie) < 0)
return -1;
- }
- return 0;
+ if (trie->fd == -1)
+ return 0;
+ }
+
+ if ((trie->flags & SQUAT_INDEX_FLAG_NFS_FLUSH) != 0)
+ nfs_flush_read_cache_locked(trie->path, trie->fd);
+ return 1;
}
static void
More information about the dovecot-cvs
mailing list