Commit cdf6ac2a authored by Miklos Szeredi's avatar Miklos Szeredi

fuse: get rid of ff->readdir.lock

The same protection is provided by file->f_pos_lock.

Note, this relies on the fact that file->f_mode has FMODE_ATOMIC_POS.
This flag is cleared by stream_open(), which would prevent locking of
f_pos_lock.

Prior to commit 7de64d52 ("fuse: break up fuse_open_common()")
FOPEN_STREAM on a directory would cause stream_open() to be called.
After this commit this is not done anymore, so f_pos_lock will always
be locked.
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
parent efc4105a
...@@ -69,7 +69,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release) ...@@ -69,7 +69,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release)
} }
INIT_LIST_HEAD(&ff->write_entry); INIT_LIST_HEAD(&ff->write_entry);
mutex_init(&ff->readdir.lock);
refcount_set(&ff->count, 1); refcount_set(&ff->count, 1);
RB_CLEAR_NODE(&ff->polled_node); RB_CLEAR_NODE(&ff->polled_node);
init_waitqueue_head(&ff->poll_wait); init_waitqueue_head(&ff->poll_wait);
...@@ -82,7 +81,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release) ...@@ -82,7 +81,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release)
void fuse_file_free(struct fuse_file *ff) void fuse_file_free(struct fuse_file *ff)
{ {
kfree(ff->args); kfree(ff->args);
mutex_destroy(&ff->readdir.lock);
kfree(ff); kfree(ff);
} }
......
...@@ -243,12 +243,6 @@ struct fuse_file { ...@@ -243,12 +243,6 @@ struct fuse_file {
/* Readdir related */ /* Readdir related */
struct { struct {
/*
* Protects below fields against (crazy) parallel readdir on
* same open file. Uncontended in the normal case.
*/
struct mutex lock;
/* Dir stream position */ /* Dir stream position */
loff_t pos; loff_t pos;
......
...@@ -592,15 +592,11 @@ int fuse_readdir(struct file *file, struct dir_context *ctx) ...@@ -592,15 +592,11 @@ int fuse_readdir(struct file *file, struct dir_context *ctx)
if (fuse_is_bad(inode)) if (fuse_is_bad(inode))
return -EIO; return -EIO;
mutex_lock(&ff->readdir.lock);
err = UNCACHED; err = UNCACHED;
if (ff->open_flags & FOPEN_CACHE_DIR) if (ff->open_flags & FOPEN_CACHE_DIR)
err = fuse_readdir_cached(file, ctx); err = fuse_readdir_cached(file, ctx);
if (err == UNCACHED) if (err == UNCACHED)
err = fuse_readdir_uncached(file, ctx); err = fuse_readdir_uncached(file, ctx);
mutex_unlock(&ff->readdir.lock);
return err; return err;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment