Skip to content

Commit

Permalink
fs: replace f_rcuhead with f_task_work
Browse files Browse the repository at this point in the history
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/[email protected]
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Jens Axboe <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
brauner committed Dec 12, 2023
1 parent 24fa3ae commit 372a34e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/*
Expand Down Expand Up @@ -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(),
Expand Down
4 changes: 3 additions & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit 372a34e

Please sign in to comment.