Skip to content

Commit ceaa5e8

Browse files
committed
ocfs2: store cookie in private data
Store the cookie to detect concurrent seeks on directories in file->private_data. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jan Kara <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 7a7ce8b commit ceaa5e8

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

fs/ocfs2/dir.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,7 @@ int ocfs2_readdir(struct file *file, struct dir_context *ctx)
19321932
{
19331933
int error = 0;
19341934
struct inode *inode = file_inode(file);
1935+
struct ocfs2_file_private *fp = file->private_data;
19351936
int lock_level = 0;
19361937

19371938
trace_ocfs2_readdir((unsigned long long)OCFS2_I(inode)->ip_blkno);
@@ -1952,7 +1953,7 @@ int ocfs2_readdir(struct file *file, struct dir_context *ctx)
19521953
goto bail_nolock;
19531954
}
19541955

1955-
error = ocfs2_dir_foreach_blk(inode, &file->f_version, ctx, false);
1956+
error = ocfs2_dir_foreach_blk(inode, &fp->cookie, ctx, false);
19561957

19571958
ocfs2_inode_unlock(inode, lock_level);
19581959
if (error)

fs/ocfs2/file.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,13 @@ static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in,
27502750
return remapped > 0 ? remapped : ret;
27512751
}
27522752

2753+
static loff_t ocfs2_dir_llseek(struct file *file, loff_t offset, int whence)
2754+
{
2755+
struct ocfs2_file_private *fp = file->private_data;
2756+
2757+
return generic_llseek_cookie(file, offset, whence, &fp->cookie);
2758+
}
2759+
27532760
const struct inode_operations ocfs2_file_iops = {
27542761
.setattr = ocfs2_setattr,
27552762
.getattr = ocfs2_getattr,
@@ -2797,7 +2804,7 @@ const struct file_operations ocfs2_fops = {
27972804

27982805
WRAP_DIR_ITER(ocfs2_readdir) // FIXME!
27992806
const struct file_operations ocfs2_dops = {
2800-
.llseek = generic_file_llseek,
2807+
.llseek = ocfs2_dir_llseek,
28012808
.read = generic_read_dir,
28022809
.iterate_shared = shared_ocfs2_readdir,
28032810
.fsync = ocfs2_sync_file,
@@ -2843,7 +2850,7 @@ const struct file_operations ocfs2_fops_no_plocks = {
28432850
};
28442851

28452852
const struct file_operations ocfs2_dops_no_plocks = {
2846-
.llseek = generic_file_llseek,
2853+
.llseek = ocfs2_dir_llseek,
28472854
.read = generic_read_dir,
28482855
.iterate_shared = shared_ocfs2_readdir,
28492856
.fsync = ocfs2_sync_file,

fs/ocfs2/file.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ struct ocfs2_alloc_context;
2020
enum ocfs2_alloc_restarted;
2121

2222
struct ocfs2_file_private {
23+
u64 cookie;
2324
struct file *fp_file;
2425
struct mutex fp_mutex;
2526
struct ocfs2_lock_res fp_flock;

0 commit comments

Comments
 (0)