]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs: replace f_rcuhead with f_task_work
authorChristian Brauner <brauner@kernel.org>
Thu, 30 Nov 2023 12:49:09 +0000 (13:49 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 12 Dec 2023 13:24:13 +0000 (14:24 +0100)
The naming is actively misleading since we switched to
SLAB_TYPESAFE_BY_RCU. rcu_head is #define callback_head. Use
callback_head directly and rename f_rcuhead to f_task_work.

Add comments in there to explain what it's used for.

Link: https://lore.kernel.org/r/20231130-vfs-files-fixes-v1-3-e73ca6f4ea83@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/file_table.c
include/linux/fs.h

index 6deac386486d0244fa9e5ba51746caab946e1e9f..3ba764d73fc9b97ded9c8782717cb4baf6971be0 100644 (file)
@@ -407,7 +407,7 @@ static void delayed_fput(struct work_struct *unused)
 
 static void ____fput(struct callback_head *work)
 {
-       __fput(container_of(work, struct file, f_rcuhead));
+       __fput(container_of(work, struct file, f_task_work));
 }
 
 /*
@@ -438,8 +438,8 @@ void fput(struct file *file)
                        return;
                }
                if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
-                       init_task_work(&file->f_rcuhead, ____fput);
-                       if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME))
+                       init_task_work(&file->f_task_work, ____fput);
+                       if (!task_work_add(task, &file->f_task_work, TWA_RESUME))
                                return;
                        /*
                         * After this task has run exit_task_work(),
index 98b7a7a8c42e36cc140d14797cf8eb00f7c36f76..354fd02e0e111bc229d4c6e4aa805256cc19b7d4 100644 (file)
@@ -991,8 +991,10 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
  */
 struct file {
        union {
+               /* fput() uses task work when closing and freeing file (default). */
+               struct callback_head    f_task_work;
+               /* fput() must use workqueue (most kernel threads). */
                struct llist_node       f_llist;
-               struct rcu_head         f_rcuhead;
                unsigned int            f_iocb_flags;
        };