From: Miklos Szeredi Date: Wed, 1 Feb 2006 13:39:15 +0000 (+0000) Subject: fix X-Git-Tag: fuse_2_6_0_pre1~16 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=08dab162b8029e95079e7d78c93429961ae8398e;p=qemu-gpiodev%2Flibfuse.git fix --- diff --git a/lib/fuse.c b/lib/fuse.c index fda97b3..b2a1904 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -693,6 +693,11 @@ static void fuse_getattr(fuse_req_t req, fuse_ino_t ino, } pthread_rwlock_unlock(&f->tree_lock); if (!err) { + if (f->conf.auto_cache) { + pthread_mutex_lock(&f->lock); + update_stat(get_node(f, ino), &buf); + pthread_mutex_unlock(&f->lock); + } set_stat(f, ino, &buf); fuse_reply_attr(req, &buf, f->conf.attr_timeout); } else @@ -781,6 +786,11 @@ static void fuse_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr, } pthread_rwlock_unlock(&f->tree_lock); if (!err) { + if (f->conf.auto_cache) { + pthread_mutex_lock(&f->lock); + update_stat(get_node(f, ino), &buf); + pthread_mutex_unlock(&f->lock); + } set_stat(f, ino, &buf); fuse_reply_attr(req, &buf, f->conf.attr_timeout); } else @@ -1127,26 +1137,29 @@ static void open_auto_cache(struct fuse *f, fuse_ino_t ino, const char *path, struct fuse_file_info *fi) { struct node *node = get_node(f, ino); - struct timespec now; - curr_time(&now); - if (diff_timespec(&now, &node->stat_updated) > f->conf.attr_timeout) { - struct stat stbuf; - int err; + if (node->cache_valid) { + struct timespec now; - if (f->op.fgetattr) - err = f->op.fgetattr(path, &stbuf, fi); - else - err = f->op.getattr(path, &stbuf); + curr_time(&now); + if (diff_timespec(&now, &node->stat_updated) > f->conf.attr_timeout) { + struct stat stbuf; + int err; - if (!err) - update_stat(node, &stbuf); - else - node->cache_valid = 0; + if (f->op.fgetattr) + err = f->op.fgetattr(path, &stbuf, fi); + else + err = f->op.getattr(path, &stbuf); + + if (!err) + update_stat(node, &stbuf); + else + node->cache_valid = 0; + } } if (node->cache_valid) fi->keep_cache = 1; - else - node->cache_valid = 1; + + node->cache_valid = 1; } static void fuse_open(fuse_req_t req, fuse_ino_t ino,