mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
bsdacct: turn acct off for all pidns-s on umount time
All the bsd_acct_strcts with opened accounting are linked into a global list. So, the acct_auto_close(_mnt) walks one and drops the accounting for each. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Balbir Singh <balbir@in.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
0b6b030fc3
commit
b5a7174875
1 changed files with 16 additions and 12 deletions
|
@ -89,9 +89,11 @@ struct bsd_acct_struct {
|
||||||
struct file *file;
|
struct file *file;
|
||||||
struct pid_namespace *ns;
|
struct pid_namespace *ns;
|
||||||
struct timer_list timer;
|
struct timer_list timer;
|
||||||
|
struct list_head list;
|
||||||
};
|
};
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(acct_lock);
|
static DEFINE_SPINLOCK(acct_lock);
|
||||||
|
static LIST_HEAD(acct_list);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called whenever the timer says to check the free space.
|
* Called whenever the timer says to check the free space.
|
||||||
|
@ -188,12 +190,14 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file,
|
||||||
acct->needcheck = 0;
|
acct->needcheck = 0;
|
||||||
acct->file = NULL;
|
acct->file = NULL;
|
||||||
acct->ns = NULL;
|
acct->ns = NULL;
|
||||||
|
list_del(&acct->list);
|
||||||
}
|
}
|
||||||
if (file) {
|
if (file) {
|
||||||
acct->file = file;
|
acct->file = file;
|
||||||
acct->ns = ns;
|
acct->ns = ns;
|
||||||
acct->needcheck = 0;
|
acct->needcheck = 0;
|
||||||
acct->active = 1;
|
acct->active = 1;
|
||||||
|
list_add(&acct->list, &acct_list);
|
||||||
/* It's been deleted if it was used before so this is safe */
|
/* It's been deleted if it was used before so this is safe */
|
||||||
setup_timer(&acct->timer, acct_timeout, (unsigned long)acct);
|
setup_timer(&acct->timer, acct_timeout, (unsigned long)acct);
|
||||||
acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
|
acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
|
||||||
|
@ -314,13 +318,13 @@ void acct_auto_close_mnt(struct vfsmount *m)
|
||||||
{
|
{
|
||||||
struct bsd_acct_struct *acct;
|
struct bsd_acct_struct *acct;
|
||||||
|
|
||||||
acct = init_pid_ns.bacct;
|
|
||||||
if (acct == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
spin_lock(&acct_lock);
|
spin_lock(&acct_lock);
|
||||||
if (acct->file && acct->file->f_path.mnt == m)
|
restart:
|
||||||
acct_file_reopen(acct, NULL, NULL);
|
list_for_each_entry(acct, &acct_list, list)
|
||||||
|
if (acct->file && acct->file->f_path.mnt == m) {
|
||||||
|
acct_file_reopen(acct, NULL, NULL);
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
spin_unlock(&acct_lock);
|
spin_unlock(&acct_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,13 +339,13 @@ void acct_auto_close(struct super_block *sb)
|
||||||
{
|
{
|
||||||
struct bsd_acct_struct *acct;
|
struct bsd_acct_struct *acct;
|
||||||
|
|
||||||
acct = init_pid_ns.bacct;
|
|
||||||
if (acct == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
spin_lock(&acct_lock);
|
spin_lock(&acct_lock);
|
||||||
if (acct->file && acct->file->f_path.mnt->mnt_sb == sb)
|
restart:
|
||||||
acct_file_reopen(acct, NULL, NULL);
|
list_for_each_entry(acct, &acct_list, list)
|
||||||
|
if (acct->file && acct->file->f_path.mnt->mnt_sb == sb) {
|
||||||
|
acct_file_reopen(acct, NULL, NULL);
|
||||||
|
goto restart;
|
||||||
|
}
|
||||||
spin_unlock(&acct_lock);
|
spin_unlock(&acct_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue