Skip to content

Commit 372a34e

Browse files
committed
fs: replace f_rcuhead with f_task_work
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>
1 parent 24fa3ae commit 372a34e

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

fs/file_table.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ static void delayed_fput(struct work_struct *unused)
407407

408408
static void ____fput(struct callback_head *work)
409409
{
410-
__fput(container_of(work, struct file, f_rcuhead));
410+
__fput(container_of(work, struct file, f_task_work));
411411
}
412412

413413
/*
@@ -438,8 +438,8 @@ void fput(struct file *file)
438438
return;
439439
}
440440
if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
441-
init_task_work(&file->f_rcuhead, ____fput);
442-
if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME))
441+
init_task_work(&file->f_task_work, ____fput);
442+
if (!task_work_add(task, &file->f_task_work, TWA_RESUME))
443443
return;
444444
/*
445445
* After this task has run exit_task_work(),

include/linux/fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,10 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
991991
*/
992992
struct file {
993993
union {
994+
/* fput() uses task work when closing and freeing file (default). */
995+
struct callback_head f_task_work;
996+
/* fput() must use workqueue (most kernel threads). */
994997
struct llist_node f_llist;
995-
struct rcu_head f_rcuhead;
996998
unsigned int f_iocb_flags;
997999
};
9981000

0 commit comments

Comments
 (0)