]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
vfs: Move autoclose of BSD accounting into a work queue
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 12 Apr 2014 19:49:10 +0000 (12:49 -0700)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 16 Apr 2014 00:13:26 +0000 (17:13 -0700)
The autoclose of BSD accounting writes a record to the BSD accounting
file.  When mntput is called from moderaly deep within the stack the
(3KiB or so) generating I/O can be problemenatic as some I/O paths
require nearly 5KiB of stack on their own.

Avoid the possibility of stack overflow by moving the close of the BSD
accounting file into a work queue.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
kernel/acct.c

index 8d6e145138bb9d2e39e93933177f63536d73d018..1853dd4a1d010f1279392915d4c5c76ec755720b 100644 (file)
@@ -93,6 +93,7 @@ struct bsd_acct_struct {
 
 static DEFINE_SPINLOCK(acct_lock);
 static LIST_HEAD(acct_list);
+static LIST_HEAD(acct_close_list);
 
 /*
  * Check the amount of free space and suspend/resume accordingly.
@@ -280,6 +281,20 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
        return error;
 }
 
+static void acct_close_mnts(struct work_struct *unused)
+{
+       struct bsd_acct_struct *acct;
+
+       spin_lock(&acct_lock);
+restart:
+       list_for_each_entry(acct, &acct_close_list, list) {
+               acct_file_reopen(acct, NULL, NULL);
+               goto restart;
+       }
+       spin_unlock(&acct_lock);
+}
+static DECLARE_WORK(acct_close_work, acct_close_mnts);
+
 /**
  * acct_auto_close - turn off a filesystem's accounting if it is on
  * @m: vfsmount being shut down
@@ -289,15 +304,15 @@ SYSCALL_DEFINE1(acct, const char __user *, name)
  */
 void acct_auto_close_mnt(struct vfsmount *m)
 {
-       struct bsd_acct_struct *acct;
+       struct bsd_acct_struct *acct, *tmp;
 
        spin_lock(&acct_lock);
-restart:
-       list_for_each_entry(acct, &acct_list, list)
+       list_for_each_entry_safe(acct, tmp, &acct_list, list) {
                if (acct->file && acct->file->f_path.mnt == m) {
-                       acct_file_reopen(acct, NULL, NULL);
-                       goto restart;
+                       list_move_tail(&acct->list, &acct_close_list);
+                       schedule_work(&acct_close_work);
                }
+       }
        spin_unlock(&acct_lock);
 }