mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-12 00:00:00 +00:00
cgroup: introduce cgroup_ino()
mm/memory-failure.c::hwpoison_filter_task() has been reaching into cgroup to extract the associated ino to be used as a filtering criterion. This is an implementation detail which shouldn't be depended upon from outside cgroup proper and is about to change with the scheduled kernfs conversion. This patch introduces a proper interface to determine the associated ino, cgroup_ino(), and updates hwpoison_filter_task() to use it instead of reaching directly into cgroup. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Li Zefan <lizefan@huawei.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: Wu Fengguang <fengguang.wu@intel.com>
This commit is contained in:
parent
2da440a26c
commit
b166492406
@ -507,6 +507,15 @@ static inline const char *cgroup_name(const struct cgroup *cgrp)
|
|||||||
return rcu_dereference(cgrp->name)->name;
|
return rcu_dereference(cgrp->name)->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* returns ino associated with a cgroup, 0 indicates unmounted root */
|
||||||
|
static inline ino_t cgroup_ino(struct cgroup *cgrp)
|
||||||
|
{
|
||||||
|
if (cgrp->dentry)
|
||||||
|
return cgrp->dentry->d_inode->i_ino;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
|
static inline struct cgroup_subsys_state *seq_css(struct seq_file *seq)
|
||||||
{
|
{
|
||||||
struct cgroup_open_file *of = seq->private;
|
struct cgroup_open_file *of = seq->private;
|
||||||
|
@ -792,7 +792,10 @@ static struct inode *cgroup_new_inode(umode_t mode, struct super_block *sb)
|
|||||||
struct inode *inode = new_inode(sb);
|
struct inode *inode = new_inode(sb);
|
||||||
|
|
||||||
if (inode) {
|
if (inode) {
|
||||||
inode->i_ino = get_next_ino();
|
do {
|
||||||
|
/* ino 0 is reserved for dummy_root */
|
||||||
|
inode->i_ino = get_next_ino();
|
||||||
|
} while (!inode->i_ino);
|
||||||
inode->i_mode = mode;
|
inode->i_mode = mode;
|
||||||
inode->i_uid = current_fsuid();
|
inode->i_uid = current_fsuid();
|
||||||
inode->i_gid = current_fsgid();
|
inode->i_gid = current_fsgid();
|
||||||
|
@ -145,14 +145,10 @@ static int hwpoison_filter_task(struct page *p)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
css = mem_cgroup_css(mem);
|
css = mem_cgroup_css(mem);
|
||||||
/* root_mem_cgroup has NULL dentries */
|
ino = cgroup_ino(css->cgroup);
|
||||||
if (!css->cgroup->dentry)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ino = css->cgroup->dentry->d_inode->i_ino;
|
|
||||||
css_put(css);
|
css_put(css);
|
||||||
|
|
||||||
if (ino != hwpoison_filter_memcg)
|
if (!ino || ino != hwpoison_filter_memcg)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user