take count and rcu_head out of fs_pin
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
360f54796e
commit
34cece2e8a
2 changed files with 10 additions and 14 deletions
|
@ -1,14 +1,8 @@
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
|
|
||||||
struct fs_pin {
|
struct fs_pin {
|
||||||
atomic_long_t count;
|
struct hlist_node s_list;
|
||||||
union {
|
struct hlist_node m_list;
|
||||||
struct {
|
|
||||||
struct hlist_node s_list;
|
|
||||||
struct hlist_node m_list;
|
|
||||||
};
|
|
||||||
struct rcu_head rcu;
|
|
||||||
};
|
|
||||||
void (*kill)(struct fs_pin *);
|
void (*kill)(struct fs_pin *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,8 @@ static void do_acct_process(struct bsd_acct_struct *acct);
|
||||||
|
|
||||||
struct bsd_acct_struct {
|
struct bsd_acct_struct {
|
||||||
struct fs_pin pin;
|
struct fs_pin pin;
|
||||||
|
atomic_long_t count;
|
||||||
|
struct rcu_head rcu;
|
||||||
struct mutex lock;
|
struct mutex lock;
|
||||||
int active;
|
int active;
|
||||||
unsigned long needcheck;
|
unsigned long needcheck;
|
||||||
|
@ -126,8 +128,8 @@ static int check_free_space(struct bsd_acct_struct *acct)
|
||||||
|
|
||||||
static void acct_put(struct bsd_acct_struct *p)
|
static void acct_put(struct bsd_acct_struct *p)
|
||||||
{
|
{
|
||||||
if (atomic_long_dec_and_test(&p->pin.count))
|
if (atomic_long_dec_and_test(&p->count))
|
||||||
kfree_rcu(p, pin.rcu);
|
kfree_rcu(p, rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct bsd_acct_struct *acct_get(struct pid_namespace *ns)
|
static struct bsd_acct_struct *acct_get(struct pid_namespace *ns)
|
||||||
|
@ -141,7 +143,7 @@ static struct bsd_acct_struct *acct_get(struct pid_namespace *ns)
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!atomic_long_inc_not_zero(&res->pin.count)) {
|
if (!atomic_long_inc_not_zero(&res->count)) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
goto again;
|
goto again;
|
||||||
|
@ -179,7 +181,7 @@ static void acct_kill(struct bsd_acct_struct *acct,
|
||||||
pin_remove(&acct->pin);
|
pin_remove(&acct->pin);
|
||||||
ns->bacct = new;
|
ns->bacct = new;
|
||||||
acct->ns = NULL;
|
acct->ns = NULL;
|
||||||
atomic_long_dec(&acct->pin.count);
|
atomic_long_dec(&acct->count);
|
||||||
mutex_unlock(&acct->lock);
|
mutex_unlock(&acct->lock);
|
||||||
acct_put(acct);
|
acct_put(acct);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +191,7 @@ static void acct_pin_kill(struct fs_pin *pin)
|
||||||
{
|
{
|
||||||
struct bsd_acct_struct *acct;
|
struct bsd_acct_struct *acct;
|
||||||
acct = container_of(pin, struct bsd_acct_struct, pin);
|
acct = container_of(pin, struct bsd_acct_struct, pin);
|
||||||
if (!atomic_long_inc_not_zero(&pin->count)) {
|
if (!atomic_long_inc_not_zero(&acct->count)) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
cpu_relax();
|
cpu_relax();
|
||||||
return;
|
return;
|
||||||
|
@ -250,7 +252,7 @@ static int acct_on(struct filename *pathname)
|
||||||
mnt = file->f_path.mnt;
|
mnt = file->f_path.mnt;
|
||||||
file->f_path.mnt = internal;
|
file->f_path.mnt = internal;
|
||||||
|
|
||||||
atomic_long_set(&acct->pin.count, 1);
|
atomic_long_set(&acct->count, 1);
|
||||||
acct->pin.kill = acct_pin_kill;
|
acct->pin.kill = acct_pin_kill;
|
||||||
acct->file = file;
|
acct->file = file;
|
||||||
acct->needcheck = jiffies;
|
acct->needcheck = jiffies;
|
||||||
|
|
Loading…
Reference in a new issue