diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 471ea70be48daadca5619dc7957d8cc319f1e507..c4c59c7d0038cfc2ecfa50ca3d8d33f4cb6dbd94 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -56,6 +56,7 @@ struct fuse_file *fuse_file_alloc(void) kfree(ff); ff = NULL; } + INIT_LIST_HEAD(&ff->write_entry); atomic_set(&ff->count, 0); } return ff; @@ -150,12 +151,18 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir) { struct fuse_file *ff = file->private_data; if (ff) { + struct fuse_conn *fc = get_fuse_conn(inode); + fuse_release_fill(ff, get_node_id(inode), file->f_flags, isdir ? FUSE_RELEASEDIR : FUSE_RELEASE); /* Hold vfsmount and dentry until release is finished */ ff->reserved_req->vfsmount = mntget(file->f_path.mnt); ff->reserved_req->dentry = dget(file->f_path.dentry); + + spin_lock(&fc->lock); + list_del(&ff->write_entry); + spin_unlock(&fc->lock); /* * Normally this will send the RELEASE request, * however if some asynchronous READ or WRITE requests diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index b24fc9b386f826b10220f39136f4eda8def271f4..5657cca0d0cb959a9ac8ff1a728b5f541682239f 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h @@ -70,6 +70,9 @@ struct fuse_inode { /** Version of last attribute change */ u64 attr_version; + + /** Files usable in writepage. Protected by fc->lock */ + struct list_head write_files; }; /** FUSE specific file data */ @@ -82,6 +85,9 @@ struct fuse_file { /** Refcount */ atomic_t count; + + /** Entry on inode's write_files list */ + struct list_head write_entry; }; /** One input argument of a request */ diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 3c13981f48e2c3ede7b28c0b5f4870fb24de66f4..49d716036ea76f105b2f77a5a20b3b24ce55a6f2 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -56,6 +56,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) fi->i_time = 0; fi->nodeid = 0; fi->nlookup = 0; + INIT_LIST_HEAD(&fi->write_files); fi->forget_req = fuse_request_alloc(); if (!fi->forget_req) { kmem_cache_free(fuse_inode_cachep, inode); @@ -68,6 +69,7 @@ static struct inode *fuse_alloc_inode(struct super_block *sb) static void fuse_destroy_inode(struct inode *inode) { struct fuse_inode *fi = get_fuse_inode(inode); + BUG_ON(!list_empty(&fi->write_files)); if (fi->forget_req) fuse_request_free(fi->forget_req); kmem_cache_free(fuse_inode_cachep, inode);