aboutsummaryrefslogtreecommitdiffstats
path: root/fs/file_table.c
diff options
context:
space:
mode:
authorChristian Brauner <[email protected]>2024-08-30 13:04:59 +0000
committerChristian Brauner <[email protected]>2024-09-12 09:58:45 +0000
commit5e9b50dea970ae6d3e1309d4254157099734a2af (patch)
tree89f9d1704d813436a4125ebc615a4dd0278578a6 /fs/file_table.c
parentubifs: store cookie in private data (diff)
downloadkernel-5e9b50dea970ae6d3e1309d4254157099734a2af.tar.gz
kernel-5e9b50dea970ae6d3e1309d4254157099734a2af.zip
fs: add f_pipe
Only regular files with FMODE_ATOMIC_POS and directories need f_pos_lock. Place a new f_pipe member in a union with f_pos_lock that they can use and make them stop abusing f_version in follow-up patches. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'fs/file_table.c')
-rw-r--r--fs/file_table.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/file_table.c b/fs/file_table.c
index 3ef558f27a1c..7ce4d5dac080 100644
--- a/fs/file_table.c
+++ b/fs/file_table.c
@@ -156,6 +156,13 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
}
spin_lock_init(&f->f_lock);
+ /*
+ * Note that f_pos_lock is only used for files raising
+ * FMODE_ATOMIC_POS and directories. Other files such as pipes
+ * don't need it and since f_pos_lock is in a union may reuse
+ * the space for other purposes. They are expected to initialize
+ * the respective member when opening the file.
+ */
mutex_init(&f->f_pos_lock);
f->f_flags = flags;
f->f_mode = OPEN_FMODE(flags);