netdev: remove pathetic compile-command lines
[safe/jmp/linux-2.6] / kernel / acct.c
index febbbc6..f6006a6 100644 (file)
@@ -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);
 }
 
@@ -544,7 +548,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
 #endif
 
        spin_lock_irq(&current->sighand->siglock);
-       tty = current->signal->tty;
+       tty = current->signal->tty;     /* Safe as we hold the siglock */
        ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0;
        ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime)));
        ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime)));
@@ -627,15 +631,9 @@ void acct_collect(long exitcode, int group_dead)
        spin_unlock_irq(&current->sighand->siglock);
 }
 
-/**
- * acct_process - now just a wrapper around do_acct_process
- *
- * handles process accounting for an exiting task
- */
-void acct_process(void)
+static void acct_process_in_ns(struct pid_namespace *ns)
 {
        struct file *file = NULL;
-       struct pid_namespace *ns = task_active_pid_ns(current);
        struct bsd_acct_struct *acct;
 
        acct = ns->bacct;
@@ -657,3 +655,22 @@ void acct_process(void)
        do_acct_process(acct, ns, file);
        fput(file);
 }
+
+/**
+ * acct_process - now just a wrapper around acct_process_in_ns,
+ * which in turn is a wrapper around do_acct_process.
+ *
+ * handles process accounting for an exiting task
+ */
+void acct_process(void)
+{
+       struct pid_namespace *ns;
+
+       /*
+        * This loop is safe lockless, since current is still
+        * alive and holds its namespace, which in turn holds
+        * its parent.
+        */
+       for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent)
+               acct_process_in_ns(ns);
+}