Re: [PATCH RFC 16/20] ufs: store cookie in private data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri 30-08-24 15:04:57, Christian Brauner wrote:
> Store the cookie to detect concurrent seeks on directories in
> file->private_data.
> 
> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@xxxxxxx>

								Honza

> ---
>  fs/ufs/dir.c | 28 +++++++++++++++++++++++++---
>  1 file changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c
> index 61f25d3cf3f7..335f0ae529b4 100644
> --- a/fs/ufs/dir.c
> +++ b/fs/ufs/dir.c
> @@ -435,7 +435,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
>  	unsigned long n = pos >> PAGE_SHIFT;
>  	unsigned long npages = dir_pages(inode);
>  	unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1);
> -	bool need_revalidate = !inode_eq_iversion(inode, file->f_version);
> +	bool need_revalidate = !inode_eq_iversion(inode, *(u64 *)file->private_data);
>  	unsigned flags = UFS_SB(sb)->s_flags;
>  
>  	UFSD("BEGIN\n");
> @@ -462,7 +462,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx)
>  				offset = ufs_validate_entry(sb, kaddr, offset, chunk_mask);
>  				ctx->pos = (n<<PAGE_SHIFT) + offset;
>  			}
> -			file->f_version = inode_query_iversion(inode);
> +			*(u64 *)file->private_data = inode_query_iversion(inode);
>  			need_revalidate = false;
>  		}
>  		de = (struct ufs_dir_entry *)(kaddr+offset);
> @@ -646,9 +646,31 @@ int ufs_empty_dir(struct inode * inode)
>  	return 0;
>  }
>  
> +static int ufs_dir_open(struct inode *inode, struct file *file)
> +{
> +	file->private_data = kzalloc(sizeof(u64), GFP_KERNEL);
> +	if (!file->private_data)
> +		return -ENOMEM;
> +	return 0;
> +}
> +
> +static int ufs_dir_release(struct inode *inode, struct file *file)
> +{
> +	kfree(file->private_data);
> +	return 0;
> +}
> +
> +static loff_t ufs_dir_llseek(struct file *file, loff_t offset, int whence)
> +{
> +	return generic_llseek_cookie(file, offset, whence,
> +				     (u64 *)file->private_data);
> +}
> +
>  const struct file_operations ufs_dir_operations = {
> +	.open		= ufs_dir_open,
> +	.release	= ufs_dir_release,
>  	.read		= generic_read_dir,
>  	.iterate_shared	= ufs_readdir,
>  	.fsync		= generic_file_fsync,
> -	.llseek		= generic_file_llseek,
> +	.llseek		= ufs_dir_llseek,
>  };
> 
> -- 
> 2.45.2
> 
-- 
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux