From aa8258e9fb887d45c0a5754f158015e035ce37bc Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Sat, 25 Feb 2006 14:42:03 +0000 Subject: [PATCH] fix --- ChangeLog | 14 ++++++++++++++ kernel/dir.c | 10 ++++++++-- lib/fuse.c | 2 +- lib/fuse_lowlevel.c | 9 +++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ddcf712..43a0e7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2006-02-25 Miklos Szeredi + + * Lowlevel lib: return all-zero statvfs data if filesystem doesn't + implement method. This is needed on FreeBSD, and nicer on Linux + too. Highlevel lib already did this. Reported by Csaba Henk + + * Fix negative entry handling. There was a bug, that negative + lookups with timeouts (nodeid == 0) returned -EIO. + +2006-02-23 Miklos Szeredi + + * Fix race between RELEASE and UNLINK, which might leave + .fuse_hidden* files around + 2006-02-21 Miklos Szeredi * fusexmp_fh: implement flush() method and call close() on the diff --git a/kernel/dir.c b/kernel/dir.c index 478f576..1cee4a2 100644 --- a/kernel/dir.c +++ b/kernel/dir.c @@ -117,6 +117,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) /* Doesn't hurt to "reset" the validity timeout */ fuse_invalidate_entry_cache(entry); + + /* For negative dentries, always do a fresh lookup */ if (!inode) return 0; @@ -128,6 +130,9 @@ static int fuse_dentry_revalidate(struct dentry *entry, struct nameidata *nd) fuse_lookup_init(req, entry->d_parent->d_inode, entry, &outarg); request_send(fc, req); err = req->out.h.error; + /* Zero nodeid is same as -ENOENT */ + if (!err && !outarg.nodeid) + err = -ENOENT; if (!err) { struct fuse_inode *fi = get_fuse_inode(inode); if (outarg.nodeid != get_node_id(inode)) { @@ -217,8 +222,9 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, fuse_lookup_init(req, dir, entry, &outarg); request_send(fc, req); err = req->out.h.error; - if (!err && ((outarg.nodeid && invalid_nodeid(outarg.nodeid)) || - !valid_mode(outarg.attr.mode))) + /* Zero nodeid is same as -ENOENT, but with valid timeout */ + if (!err && outarg.nodeid && + (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) err = -EIO; if (!err && outarg.nodeid) { inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, diff --git a/lib/fuse.c b/lib/fuse.c index ac6a2d5..0b31233 100644 --- a/lib/fuse.c +++ b/lib/fuse.c @@ -1331,6 +1331,7 @@ static void fuse_release(fuse_req_t req, fuse_ino_t ino, struct node *node; int unlink_hidden; + pthread_rwlock_rdlock(&f->tree_lock); pthread_mutex_lock(&f->lock); node = get_node(f, ino); assert(node->open_count > 0); @@ -1338,7 +1339,6 @@ static void fuse_release(fuse_req_t req, fuse_ino_t ino, unlink_hidden = (node->is_hidden && !node->open_count); pthread_mutex_unlock(&f->lock); - pthread_rwlock_rdlock(&f->tree_lock); path = get_path(f, ino); if (f->conf.debug) { printf("RELEASE[%llu] flags: 0x%x\n", (unsigned long long) fi->fh, diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index 12f6c82..8437eb4 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -653,8 +653,13 @@ static void do_statfs(fuse_req_t req) { if (req->f->op.statfs) req->f->op.statfs(req); - else - fuse_reply_err(req, ENOSYS); + else { + struct statvfs buf = { + .f_namemax = 255, + .f_bsize = 512, + }; + fuse_reply_statfs(req, &buf); + } } static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, -- 2.30.2