diff options
-rw-r--r-- | ChangeLog.txt | 4 | ||||
-rw-r--r-- | pseudo.c | 196 |
2 files changed, 8 insertions, 192 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt index 3dc98ab..6850e42 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,7 @@ +2011-01-24: + * (mhatle) Revert last result cache and related commits. + caching proved to be unreliable. + 2011-01-14: * (seebs) Automatically create prefix/state directories. * (mhatle) Avoid caching OP_EXEC calls @@ -425,9 +425,6 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) { int found_path = 0, found_ino = 0; int prefer_ino = 0; - static pseudo_msg_t cache_msg = { .op = 0 }; - static char * cache_path = NULL; - if (!msg) return 1; @@ -471,60 +468,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) { /* Lookup the full path, with inode and dev if available */ if (msg->pathlen && msg->dev && msg->ino) { - if (cache_msg.pathlen == msg->pathlen && - cache_msg.dev == msg->dev && - cache_msg.ino == msg->ino && - !strcmp(cache_path, msg->path)) { - /* Found it in the cache! */ -#ifdef NPROFILE - pseudo_diag("cache hit -- by_file_exact\n"); -#endif - /* Change the cache to match the msg */ - cache_msg.type = msg->type; - cache_msg.op = msg->op; - cache_msg.result = msg->result; - cache_msg.access = msg->access; - cache_msg.fd = msg->fd; -#ifdef NVALIDATE - if (!pdb_find_file_exact(msg)) { - if (cache_msg.pathlen != msg->pathlen || - cache_msg.dev != msg->dev || - cache_msg.ino != msg->ino || - cache_msg.uid != msg->uid || - cache_msg.gid != msg->gid || - cache_msg.mode != msg->mode || - cache_msg.rdev != msg->rdev || - cache_msg.nlink != msg->nlink || - cache_msg.deleting != msg->deleting) { - pseudo_diag("Cache mismatch [%s]: Database differs from cache\n" - " cache vs result:\n" - " dev (%llu,%llu) ino (%llu,%llu)\n" - " uid (%d,%d) gid (%d,%d) mode (0%o,0%o)\n" - " rdev (%llu,%llu) nlink (%d,%d) deleting (%d,%d)\n", - msg->pathlen ? msg->path : "no path", - (unsigned long long) cache_msg.dev, (unsigned long long) msg->dev, - (unsigned long long) cache_msg.ino, (unsigned long long) msg->ino, - (unsigned long long) cache_msg.uid, (unsigned int) msg->uid, - (unsigned long long) cache_msg.gid, (unsigned int) msg->gid, - cache_msg.mode, msg->mode, - (unsigned long long) cache_msg.rdev, (unsigned int) msg->rdev, - cache_msg.nlink, msg->nlink, - cache_msg.deleting, msg->deleting); - } - } else { - pseudo_diag("Cache mismatch [%s]: Not found in DB\n", - msg->pathlen ? msg->path : "no path"); - } -#endif - - by_path = cache_msg; - by_ino = cache_msg; - /* no need to restore msg */ - found_path = 1; - found_ino = 1; - /* note: we have to avoid freeing this later */ - path_by_ino = msg->path; - } else if (!pdb_find_file_exact(msg)) { + if (!pdb_find_file_exact(msg)) { /* restore header contents */ by_path = *msg; by_ino = *msg; @@ -540,51 +484,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) { if (msg->pathlen) { /* for now, don't canonicalize paths anymore */ /* used to do it here, but now doing it in client */ - if (cache_msg.pathlen == msg->pathlen && - !strcmp(cache_path, msg->path)) { -#ifdef NPROFILE - pseudo_diag("cache hit -- by_path\n"); -#endif - /* Change the cache to match the msg */ - cache_msg.type = msg->type; - cache_msg.op = msg->op; - cache_msg.result = msg->result; - cache_msg.access = msg->access; - cache_msg.fd = msg->fd; -#ifdef NVALIDATE - if (!pdb_find_file_exact(msg)) { - if (cache_msg.pathlen != msg->pathlen || - cache_msg.dev != msg->dev || - cache_msg.ino != msg->ino || - cache_msg.uid != msg->uid || - cache_msg.gid != msg->gid || - cache_msg.mode != msg->mode || - cache_msg.rdev != msg->rdev || - cache_msg.nlink != msg->nlink || - cache_msg.deleting != msg->deleting) { - pseudo_diag("Cache mismatch [%s]: Database differs from cache\n" - " cache vs result:\n" - " dev (%llu,%llu) ino (%llu,%llu)\n" - " uid (%d,%d) gid (%d,%d) mode (0%o,0%o)\n" - " rdev (%llu,%llu) nlink (%d,%d) deleting (%d,%d)\n", - msg->pathlen ? msg->path : "no path", - (unsigned long long) cache_msg.dev, (unsigned long long) msg->dev, - (unsigned long long) cache_msg.ino, (unsigned long long) msg->ino, - (unsigned long long) cache_msg.uid, (unsigned int) msg->uid, - (unsigned long long) cache_msg.gid, (unsigned int) msg->gid, - cache_msg.mode, msg->mode, - (unsigned long long) cache_msg.rdev, (unsigned int) msg->rdev, - cache_msg.nlink, msg->nlink, - cache_msg.deleting, msg->deleting); - } - } else { - pseudo_diag("Cache mismatch [%s]: Not found in DB\n", - msg->pathlen ? msg->path : "no path"); - } -#endif - by_path = cache_msg; - found_path = 1; - } else if (!pdb_find_file_path(msg)) { + if (!pdb_find_file_path(msg)) { by_path = *msg; found_path = 1; } else { @@ -595,51 +495,7 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) { } /* search on original inode -- in case of mismatch */ if (msg->dev && msg->ino) { - if (cache_msg.dev == msg->dev && - cache_msg.ino == msg->ino) { -#ifdef NPROFILE - pseudo_diag("cache hit -- by_ino\n"); -#endif - /* Change the cache to match the msg */ - cache_msg.type = msg->type; - cache_msg.op = msg->op; - cache_msg.result = msg->result; - cache_msg.access = msg->access; - cache_msg.fd = msg->fd; -#ifdef NVALIDATE - if (!pdb_find_file_exact(msg)) { - if (cache_msg.pathlen != msg->pathlen || - cache_msg.dev != msg->dev || - cache_msg.ino != msg->ino || - cache_msg.uid != msg->uid || - cache_msg.gid != msg->gid || - cache_msg.mode != msg->mode || - cache_msg.rdev != msg->rdev || - cache_msg.nlink != msg->nlink || - cache_msg.deleting != msg->deleting) { - pseudo_diag("Cache mismatch [%s]: Database differs from cache\n" - " cache vs result:\n" - " dev (%llu,%llu) ino (%llu,%llu)\n" - " uid (%d,%d) gid (%d,%d) mode (0%o,0%o)\n" - " rdev (%llu,%llu) nlink (%d,%d) deleting (%d,%d)\n", - msg->pathlen ? msg->path : "no path", - (unsigned long long) cache_msg.dev, (unsigned long long) msg->dev, - (unsigned long long) cache_msg.ino, (unsigned long long) msg->ino, - (unsigned long long) cache_msg.uid, (unsigned int) msg->uid, - (unsigned long long) cache_msg.gid, (unsigned int) msg->gid, - cache_msg.mode, msg->mode, - (unsigned long long) cache_msg.rdev, (unsigned int) msg->rdev, - cache_msg.nlink, msg->nlink, - cache_msg.deleting, msg->deleting); - } - } else { - pseudo_diag("Cache mismatch [%s]: Not found in DB\n", - msg->pathlen ? msg->path : "no path"); - } -#endif - found_ino = 1; - path_by_ino = cache_path; - } else if (!pdb_find_file_dev(&by_ino)) { + if (!pdb_find_file_dev(&by_ino)) { found_ino = 1; path_by_ino = pdb_get_file_path(&by_ino); } @@ -1017,52 +873,8 @@ pseudo_op(pseudo_msg_t *msg, const char *program, const char *tag) { break; } - /* Cache previous values... */ - if (msg->op != OP_MAY_UNLINK && - msg->op != OP_DID_UNLINK && - msg->op != OP_CANCEL_UNLINK && - msg->op != OP_UNLINK && - msg->op != OP_EXEC ) { - cache_msg = *msg; - - if (path_by_ino) { - /* if path_by_ino is already the cache path, - * no need to dup it. - */ - if (path_by_ino != cache_path) { - free(cache_path); - cache_path = strdup(path_by_ino); - } else { - /* don't want to free this */ - path_by_ino = NULL; - } - } else { - free(cache_path); - cache_path = strdup(msg->path); - } - if (cache_path) { - cache_msg.pathlen = strlen(cache_path) + 1; - } else { - cache_msg.pathlen = 0; - } - } else { - cache_msg.pathlen = 0; - cache_msg.dev = 0; - cache_msg.ino = 0; - /* if path_by_ino was the same pointer, - * mark it NULL so we don't try to free - * it. - */ - if (path_by_ino == cache_path) - path_by_ino = NULL; - free(cache_path); - cache_path = NULL; - } - /* in the case of an exact match, we just used the pointer - * rather than allocating space. If we used the cached path, - * and this pointer has already been invalidated, it'll be - * NULL now. + * rather than allocating space. */ if (path_by_ino != msg->path) { free(path_by_ino); |