diff mbox series

[RFC,20/20] fs: remove f_version

Message ID 20240830-vfs-file-f_version-v1-20-6d3e4816aa7b@kernel.org (mailing list archive)
State New
Headers show
Series file: remove f_version | expand

Commit Message

Christian Brauner Aug. 30, 2024, 1:05 p.m. UTC
Now that detecting concurrent seeks is done by the filesystems that
require it we can remove f_version and free up 8 bytes for future
extensions.

Signed-off-by: Christian Brauner <brauner@kernel.org>
---
 fs/read_write.c    | 9 ++++-----
 include/linux/fs.h | 4 +---
 2 files changed, 5 insertions(+), 8 deletions(-)

Comments

Jan Kara Sept. 3, 2024, 1:45 p.m. UTC | #1
On Fri 30-08-24 15:05:01, Christian Brauner wrote:
> Now that detecting concurrent seeks is done by the filesystems that
> require it we can remove f_version and free up 8 bytes for future
> extensions.
> 
> Signed-off-by: Christian Brauner <brauner@kernel.org>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/read_write.c    | 9 ++++-----
>  include/linux/fs.h | 4 +---
>  2 files changed, 5 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 47f7b4e32a53..981146f50568 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -62,7 +62,8 @@ static loff_t vfs_setpos_cookie(struct file *file, loff_t offset,
>  
>  	if (offset != file->f_pos) {
>  		file->f_pos = offset;
> -		*cookie = 0;
> +		if (cookie)
> +			*cookie = 0;
>  	}
>  	return offset;
>  }
> @@ -81,7 +82,7 @@ static loff_t vfs_setpos_cookie(struct file *file, loff_t offset,
>   */
>  loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize)
>  {
> -	return vfs_setpos_cookie(file, offset, maxsize, &file->f_version);
> +	return vfs_setpos_cookie(file, offset, maxsize, NULL);
>  }
>  EXPORT_SYMBOL(vfs_setpos);
>  
> @@ -362,10 +363,8 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence)
>  	}
>  	retval = -EINVAL;
>  	if (offset >= 0 || unsigned_offsets(file)) {
> -		if (offset != file->f_pos) {
> +		if (offset != file->f_pos)
>  			file->f_pos = offset;
> -			file->f_version = 0;
> -		}
>  		retval = offset;
>  	}
>  out:
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index ca4925008244..7e11ce172140 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1003,7 +1003,6 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
>   * @f_pos_lock: lock protecting file position
>   * @f_pipe: specific to pipes
>   * @f_pos: file position
> - * @f_version: file version
>   * @f_security: LSM security context of this file
>   * @f_owner: file owner
>   * @f_wb_err: writeback error
> @@ -1034,11 +1033,10 @@ struct file {
>  		u64			f_pipe;
>  	};
>  	loff_t				f_pos;
> -	u64				f_version;
> -	/* --- cacheline 2 boundary (128 bytes) --- */
>  #ifdef CONFIG_SECURITY
>  	void				*f_security;
>  #endif
> +	/* --- cacheline 2 boundary (128 bytes) --- */
>  	struct fown_struct		*f_owner;
>  	errseq_t			f_wb_err;
>  	errseq_t			f_sb_err;
> 
> -- 
> 2.45.2
>
diff mbox series

Patch

diff --git a/fs/read_write.c b/fs/read_write.c
index 47f7b4e32a53..981146f50568 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -62,7 +62,8 @@  static loff_t vfs_setpos_cookie(struct file *file, loff_t offset,
 
 	if (offset != file->f_pos) {
 		file->f_pos = offset;
-		*cookie = 0;
+		if (cookie)
+			*cookie = 0;
 	}
 	return offset;
 }
@@ -81,7 +82,7 @@  static loff_t vfs_setpos_cookie(struct file *file, loff_t offset,
  */
 loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize)
 {
-	return vfs_setpos_cookie(file, offset, maxsize, &file->f_version);
+	return vfs_setpos_cookie(file, offset, maxsize, NULL);
 }
 EXPORT_SYMBOL(vfs_setpos);
 
@@ -362,10 +363,8 @@  loff_t default_llseek(struct file *file, loff_t offset, int whence)
 	}
 	retval = -EINVAL;
 	if (offset >= 0 || unsigned_offsets(file)) {
-		if (offset != file->f_pos) {
+		if (offset != file->f_pos)
 			file->f_pos = offset;
-			file->f_version = 0;
-		}
 		retval = offset;
 	}
 out:
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ca4925008244..7e11ce172140 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1003,7 +1003,6 @@  static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
  * @f_pos_lock: lock protecting file position
  * @f_pipe: specific to pipes
  * @f_pos: file position
- * @f_version: file version
  * @f_security: LSM security context of this file
  * @f_owner: file owner
  * @f_wb_err: writeback error
@@ -1034,11 +1033,10 @@  struct file {
 		u64			f_pipe;
 	};
 	loff_t				f_pos;
-	u64				f_version;
-	/* --- cacheline 2 boundary (128 bytes) --- */
 #ifdef CONFIG_SECURITY
 	void				*f_security;
 #endif
+	/* --- cacheline 2 boundary (128 bytes) --- */
 	struct fown_struct		*f_owner;
 	errseq_t			f_wb_err;
 	errseq_t			f_sb_err;