aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acct.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-07-25 04:48:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:47 -0400
commitb5a7174875ea570cc675f2c503e800db8efdd6a7 (patch)
tree19bddd97fa7bfc762a6f2bf3fa88d3df45ba52aa /kernel/acct.c
parent0b6b030fc30d169bb406b34b4fc60d99dde4a9c6 (diff)
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>
Diffstat (limited to 'kernel/acct.c')
-rw-r--r--kernel/acct.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index febbbc67157e..7fc9f9dd1e9e 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -89,9 +89,11 @@ struct bsd_acct_struct {
89 struct file *file; 89 struct file *file;
90 struct pid_namespace *ns; 90 struct pid_namespace *ns;
91 struct timer_list timer; 91 struct timer_list timer;
92 struct list_head list;
92}; 93};
93 94
94static DEFINE_SPINLOCK(acct_lock); 95static DEFINE_SPINLOCK(acct_lock);
96static LIST_HEAD(acct_list);
95 97
96/* 98/*
97 * Called whenever the timer says to check the free space. 99 * 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,
188 acct->needcheck = 0; 190 acct->needcheck = 0;
189 acct->file = NULL; 191 acct->file = NULL;
190 acct->ns = NULL; 192 acct->ns = NULL;
193 list_del(&acct->list);
191 } 194 }
192 if (file) { 195 if (file) {
193 acct->file = file; 196 acct->file = file;
194 acct->ns = ns; 197 acct->ns = ns;
195 acct->needcheck = 0; 198 acct->needcheck = 0;
196 acct->active = 1; 199 acct->active = 1;
200 list_add(&acct->list, &acct_list);
197 /* It's been deleted if it was used before so this is safe */ 201 /* It's been deleted if it was used before so this is safe */
198 setup_timer(&acct->timer, acct_timeout, (unsigned long)acct); 202 setup_timer(&acct->timer, acct_timeout, (unsigned long)acct);
199 acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; 203 acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
@@ -314,13 +318,13 @@ void acct_auto_close_mnt(struct vfsmount *m)
314{ 318{
315 struct bsd_acct_struct *acct; 319 struct bsd_acct_struct *acct;
316 320
317 acct = init_pid_ns.bacct;
318 if (acct == NULL)
319 return;
320
321 spin_lock(&acct_lock); 321 spin_lock(&acct_lock);
322 if (acct->file && acct->file->f_path.mnt == m) 322restart:
323 acct_file_reopen(acct, NULL, NULL); 323 list_for_each_entry(acct, &acct_list, list)
324 if (acct->file && acct->file->f_path.mnt == m) {
325 acct_file_reopen(acct, NULL, NULL);
326 goto restart;
327 }
324 spin_unlock(&acct_lock); 328 spin_unlock(&acct_lock);
325} 329}
326 330
@@ -335,13 +339,13 @@ void acct_auto_close(struct super_block *sb)
335{ 339{
336 struct bsd_acct_struct *acct; 340 struct bsd_acct_struct *acct;
337 341
338 acct = init_pid_ns.bacct;
339 if (acct == NULL)
340 return;
341
342 spin_lock(&acct_lock); 342 spin_lock(&acct_lock);
343 if (acct->file && acct->file->f_path.mnt->mnt_sb == sb) 343restart:
344 acct_file_reopen(acct, NULL, NULL); 344 list_for_each_entry(acct, &acct_list, list)
345 if (acct->file && acct->file->f_path.mnt->mnt_sb == sb) {
346 acct_file_reopen(acct, NULL, NULL);
347 goto restart;
348 }
345 spin_unlock(&acct_lock); 349 spin_unlock(&acct_lock);
346} 350}
347 351