mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
struct file: use anonymous union member for rcuhead and llist
Once upon a time we couldn't afford anon unions; these days minimal gcc version had been raised enough to take care of that. Reviewed-by: Jan Kara <jack@suse.cz> Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
@@ -45,7 +45,7 @@ static struct percpu_counter nr_files __cacheline_aligned_in_smp;
|
|||||||
|
|
||||||
static void file_free_rcu(struct rcu_head *head)
|
static void file_free_rcu(struct rcu_head *head)
|
||||||
{
|
{
|
||||||
struct file *f = container_of(head, struct file, f_u.fu_rcuhead);
|
struct file *f = container_of(head, struct file, f_rcuhead);
|
||||||
|
|
||||||
put_cred(f->f_cred);
|
put_cred(f->f_cred);
|
||||||
kmem_cache_free(filp_cachep, f);
|
kmem_cache_free(filp_cachep, f);
|
||||||
@@ -56,7 +56,7 @@ static inline void file_free(struct file *f)
|
|||||||
security_file_free(f);
|
security_file_free(f);
|
||||||
if (!(f->f_mode & FMODE_NOACCOUNT))
|
if (!(f->f_mode & FMODE_NOACCOUNT))
|
||||||
percpu_counter_dec(&nr_files);
|
percpu_counter_dec(&nr_files);
|
||||||
call_rcu(&f->f_u.fu_rcuhead, file_free_rcu);
|
call_rcu(&f->f_rcuhead, file_free_rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -142,7 +142,7 @@ static struct file *__alloc_file(int flags, const struct cred *cred)
|
|||||||
f->f_cred = get_cred(cred);
|
f->f_cred = get_cred(cred);
|
||||||
error = security_file_alloc(f);
|
error = security_file_alloc(f);
|
||||||
if (unlikely(error)) {
|
if (unlikely(error)) {
|
||||||
file_free_rcu(&f->f_u.fu_rcuhead);
|
file_free_rcu(&f->f_rcuhead);
|
||||||
return ERR_PTR(error);
|
return ERR_PTR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,13 +341,13 @@ static void delayed_fput(struct work_struct *unused)
|
|||||||
struct llist_node *node = llist_del_all(&delayed_fput_list);
|
struct llist_node *node = llist_del_all(&delayed_fput_list);
|
||||||
struct file *f, *t;
|
struct file *f, *t;
|
||||||
|
|
||||||
llist_for_each_entry_safe(f, t, node, f_u.fu_llist)
|
llist_for_each_entry_safe(f, t, node, f_llist)
|
||||||
__fput(f);
|
__fput(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ____fput(struct callback_head *work)
|
static void ____fput(struct callback_head *work)
|
||||||
{
|
{
|
||||||
__fput(container_of(work, struct file, f_u.fu_rcuhead));
|
__fput(container_of(work, struct file, f_rcuhead));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -374,8 +374,8 @@ void fput(struct file *file)
|
|||||||
struct task_struct *task = current;
|
struct task_struct *task = current;
|
||||||
|
|
||||||
if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
|
if (likely(!in_interrupt() && !(task->flags & PF_KTHREAD))) {
|
||||||
init_task_work(&file->f_u.fu_rcuhead, ____fput);
|
init_task_work(&file->f_rcuhead, ____fput);
|
||||||
if (!task_work_add(task, &file->f_u.fu_rcuhead, TWA_RESUME))
|
if (!task_work_add(task, &file->f_rcuhead, TWA_RESUME))
|
||||||
return;
|
return;
|
||||||
/*
|
/*
|
||||||
* After this task has run exit_task_work(),
|
* After this task has run exit_task_work(),
|
||||||
@@ -384,7 +384,7 @@ void fput(struct file *file)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (llist_add(&file->f_u.fu_llist, &delayed_fput_list))
|
if (llist_add(&file->f_llist, &delayed_fput_list))
|
||||||
schedule_delayed_work(&delayed_fput_work, 1);
|
schedule_delayed_work(&delayed_fput_work, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -924,9 +924,9 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index)
|
|||||||
|
|
||||||
struct file {
|
struct file {
|
||||||
union {
|
union {
|
||||||
struct llist_node fu_llist;
|
struct llist_node f_llist;
|
||||||
struct rcu_head fu_rcuhead;
|
struct rcu_head f_rcuhead;
|
||||||
} f_u;
|
};
|
||||||
struct path f_path;
|
struct path f_path;
|
||||||
struct inode *f_inode; /* cached value */
|
struct inode *f_inode; /* cached value */
|
||||||
const struct file_operations *f_op;
|
const struct file_operations *f_op;
|
||||||
|
Reference in New Issue
Block a user