From: Pavel Emelyanov <xemul@openvz.org>
To: Oleg Nesterov <oleg@tv-sign.ru>,
Sukadev Bhattiprolu <sukadev@us.ibm.com>,
Alexey Dobriyan <adobriyan@openvz.org>
Cc: Linux Containers <containers@lists.osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH 9/10] Bsdacct: stop accounting for all namespaces on umount time
Date: Thu, 10 Apr 2008 12:58:07 +0400 [thread overview]
Message-ID: <47FDD69F.4040007@openvz.org> (raw)
In-Reply-To: <47FDD267.80700@openvz.org>
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.
BTW, it worth dropping the acct->file != NULL check from these
routines, but I noticed this only when started sending the set :(
... Will do it in the v2.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
kernel/acct.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/kernel/acct.c b/kernel/acct.c
index febbbc6..7fc9f9d 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -89,9 +89,11 @@ struct bsd_acct_struct {
struct file *file;
struct pid_namespace *ns;
struct timer_list timer;
+ struct list_head list;
};
static DEFINE_SPINLOCK(acct_lock);
+static LIST_HEAD(acct_list);
/*
* 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->file = NULL;
acct->ns = NULL;
+ list_del(&acct->list);
}
if (file) {
acct->file = file;
acct->ns = ns;
acct->needcheck = 0;
acct->active = 1;
+ list_add(&acct->list, &acct_list);
/* It's been deleted if it was used before so this is safe */
setup_timer(&acct->timer, acct_timeout, (unsigned long)acct);
acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
@@ -314,13 +318,13 @@ void acct_auto_close_mnt(struct vfsmount *m)
{
struct bsd_acct_struct *acct;
- acct = init_pid_ns.bacct;
- if (acct == NULL)
- return;
-
spin_lock(&acct_lock);
- if (acct->file && acct->file->f_path.mnt == m)
- acct_file_reopen(acct, NULL, NULL);
+restart:
+ 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);
}
@@ -335,13 +339,13 @@ void acct_auto_close(struct super_block *sb)
{
struct bsd_acct_struct *acct;
- acct = init_pid_ns.bacct;
- if (acct == NULL)
- return;
-
spin_lock(&acct_lock);
- if (acct->file && acct->file->f_path.mnt->mnt_sb == sb)
- acct_file_reopen(acct, NULL, NULL);
+restart:
+ 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);
}
--
1.5.3.4
next prev parent reply other threads:[~2008-04-10 8:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-10 8:40 [PATCH 0/10] Make bsd process accounting work in pid namespaces Pavel Emelyanov
2008-04-10 8:41 ` [PATCH 1/10] Bsdacct: rename acct_glbl structure Pavel Emelyanov
2008-04-10 8:43 ` [PATCH 2/10] Pidns: use kzalloc to allocate new pid namespace Pavel Emelyanov
2008-04-10 8:44 ` [PATCH 3/10] Pidns: add struct bsd_acct_struct *bacct field on pid_namespace Pavel Emelyanov
2008-04-10 8:45 ` [PATCH 4/10] Bsdacct: fix bogus comment near acct_process Pavel Emelyanov
2008-04-10 8:47 ` [PATCH 5/10] Bsdacct: make check timer accept an argument Pavel Emelyanov
2008-04-10 8:49 ` [PATCH 6/10] Bsdacct: make the acct_lock global Pavel Emelyanov
2008-04-10 8:51 ` [PATCH 7/10] Bsdacct: stop using global bsd_acct_struct instance in internal functions Pavel Emelyanov
2008-04-10 8:54 ` [PATCH 8/10] Bsdacct: make bsd_acct_struct per pid namespace Pavel Emelyanov
2008-04-10 8:58 ` Pavel Emelyanov [this message]
2008-04-10 8:59 ` [PATCH 10/10] Bsdacct: account task in each namespace is is visible from Pavel Emelyanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47FDD69F.4040007@openvz.org \
--to=xemul@openvz.org \
--cc=adobriyan@openvz.org \
--cc=containers@lists.osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
--cc=sukadev@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox