Skip to content

Commit cdf6ac2

Browse files
author
Miklos Szeredi
committed
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 7de64d5 ("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: Miklos Szeredi <mszeredi@redhat.com>
1 parent efc4105 commit cdf6ac2

File tree

3 files changed

+0
-12
lines changed

3 files changed

+0
-12
lines changed

fs/fuse/file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release)
6969
}
7070

7171
INIT_LIST_HEAD(&ff->write_entry);
72-
mutex_init(&ff->readdir.lock);
7372
refcount_set(&ff->count, 1);
7473
RB_CLEAR_NODE(&ff->polled_node);
7574
init_waitqueue_head(&ff->poll_wait);
@@ -82,7 +81,6 @@ struct fuse_file *fuse_file_alloc(struct fuse_mount *fm, bool release)
8281
void fuse_file_free(struct fuse_file *ff)
8382
{
8483
kfree(ff->args);
85-
mutex_destroy(&ff->readdir.lock);
8684
kfree(ff);
8785
}
8886

fs/fuse/fuse_i.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,6 @@ struct fuse_file {
243243

244244
/* Readdir related */
245245
struct {
246-
/*
247-
* Protects below fields against (crazy) parallel readdir on
248-
* same open file. Uncontended in the normal case.
249-
*/
250-
struct mutex lock;
251-
252246
/* Dir stream position */
253247
loff_t pos;
254248

fs/fuse/readdir.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,11 @@ int fuse_readdir(struct file *file, struct dir_context *ctx)
592592
if (fuse_is_bad(inode))
593593
return -EIO;
594594

595-
mutex_lock(&ff->readdir.lock);
596-
597595
err = UNCACHED;
598596
if (ff->open_flags & FOPEN_CACHE_DIR)
599597
err = fuse_readdir_cached(file, ctx);
600598
if (err == UNCACHED)
601599
err = fuse_readdir_uncached(file, ctx);
602600

603-
mutex_unlock(&ff->readdir.lock);
604-
605601
return err;
606602
}

0 commit comments

Comments
 (0)