diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-12-08 20:08:42 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-01-03 22:52:41 -0500 |
commit | 32dc730860155b235f13e0cd3fe58b263279baf9 (patch) | |
tree | 9595ab7e5bf116e059daa5cc38d9dfc4af100e87 /kernel | |
parent | 84b92d39f98f669a3073168f88692782aec525a8 (diff) |
get rid of timer in kern/acct.c
... and clean it up a bit, while we are at it
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/acct.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/kernel/acct.c b/kernel/acct.c index fa7eb3de2ddc..8cba12429d82 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -84,11 +84,10 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
84 | * the cache line to have the data after getting the lock. | 84 | * the cache line to have the data after getting the lock. |
85 | */ | 85 | */ |
86 | struct bsd_acct_struct { | 86 | struct bsd_acct_struct { |
87 | volatile int active; | 87 | int active; |
88 | volatile int needcheck; | 88 | unsigned long needcheck; |
89 | struct file *file; | 89 | struct file *file; |
90 | struct pid_namespace *ns; | 90 | struct pid_namespace *ns; |
91 | struct timer_list timer; | ||
92 | struct list_head list; | 91 | struct list_head list; |
93 | }; | 92 | }; |
94 | 93 | ||
@@ -96,15 +95,6 @@ static DEFINE_SPINLOCK(acct_lock); | |||
96 | static LIST_HEAD(acct_list); | 95 | static LIST_HEAD(acct_list); |
97 | 96 | ||
98 | /* | 97 | /* |
99 | * Called whenever the timer says to check the free space. | ||
100 | */ | ||
101 | static void acct_timeout(unsigned long x) | ||
102 | { | ||
103 | struct bsd_acct_struct *acct = (struct bsd_acct_struct *)x; | ||
104 | acct->needcheck = 1; | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * Check the amount of free space and suspend/resume accordingly. | 98 | * Check the amount of free space and suspend/resume accordingly. |
109 | */ | 99 | */ |
110 | static int check_free_space(struct bsd_acct_struct *acct, struct file *file) | 100 | static int check_free_space(struct bsd_acct_struct *acct, struct file *file) |
@@ -112,12 +102,12 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) | |||
112 | struct kstatfs sbuf; | 102 | struct kstatfs sbuf; |
113 | int res; | 103 | int res; |
114 | int act; | 104 | int act; |
115 | sector_t resume; | 105 | u64 resume; |
116 | sector_t suspend; | 106 | u64 suspend; |
117 | 107 | ||
118 | spin_lock(&acct_lock); | 108 | spin_lock(&acct_lock); |
119 | res = acct->active; | 109 | res = acct->active; |
120 | if (!file || !acct->needcheck) | 110 | if (!file || time_is_before_jiffies(acct->needcheck)) |
121 | goto out; | 111 | goto out; |
122 | spin_unlock(&acct_lock); | 112 | spin_unlock(&acct_lock); |
123 | 113 | ||
@@ -127,8 +117,8 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) | |||
127 | suspend = sbuf.f_blocks * SUSPEND; | 117 | suspend = sbuf.f_blocks * SUSPEND; |
128 | resume = sbuf.f_blocks * RESUME; | 118 | resume = sbuf.f_blocks * RESUME; |
129 | 119 | ||
130 | sector_div(suspend, 100); | 120 | do_div(suspend, 100); |
131 | sector_div(resume, 100); | 121 | do_div(resume, 100); |
132 | 122 | ||
133 | if (sbuf.f_bavail <= suspend) | 123 | if (sbuf.f_bavail <= suspend) |
134 | act = -1; | 124 | act = -1; |
@@ -160,10 +150,7 @@ static int check_free_space(struct bsd_acct_struct *acct, struct file *file) | |||
160 | } | 150 | } |
161 | } | 151 | } |
162 | 152 | ||
163 | del_timer(&acct->timer); | 153 | acct->needcheck = jiffies + ACCT_TIMEOUT*HZ; |
164 | acct->needcheck = 0; | ||
165 | acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; | ||
166 | add_timer(&acct->timer); | ||
167 | res = acct->active; | 154 | res = acct->active; |
168 | out: | 155 | out: |
169 | spin_unlock(&acct_lock); | 156 | spin_unlock(&acct_lock); |
@@ -185,9 +172,7 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file, | |||
185 | if (acct->file) { | 172 | if (acct->file) { |
186 | old_acct = acct->file; | 173 | old_acct = acct->file; |
187 | old_ns = acct->ns; | 174 | old_ns = acct->ns; |
188 | del_timer(&acct->timer); | ||
189 | acct->active = 0; | 175 | acct->active = 0; |
190 | acct->needcheck = 0; | ||
191 | acct->file = NULL; | 176 | acct->file = NULL; |
192 | acct->ns = NULL; | 177 | acct->ns = NULL; |
193 | list_del(&acct->list); | 178 | list_del(&acct->list); |
@@ -195,13 +180,9 @@ static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file, | |||
195 | if (file) { | 180 | if (file) { |
196 | acct->file = file; | 181 | acct->file = file; |
197 | acct->ns = ns; | 182 | acct->ns = ns; |
198 | acct->needcheck = 0; | 183 | acct->needcheck = jiffies + ACCT_TIMEOUT*HZ; |
199 | acct->active = 1; | 184 | acct->active = 1; |
200 | list_add(&acct->list, &acct_list); | 185 | list_add(&acct->list, &acct_list); |
201 | /* It's been deleted if it was used before so this is safe */ | ||
202 | setup_timer(&acct->timer, acct_timeout, (unsigned long)acct); | ||
203 | acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; | ||
204 | add_timer(&acct->timer); | ||
205 | } | 186 | } |
206 | if (old_acct) { | 187 | if (old_acct) { |
207 | mnt_unpin(old_acct->f_path.mnt); | 188 | mnt_unpin(old_acct->f_path.mnt); |
@@ -348,7 +329,6 @@ void acct_exit_ns(struct pid_namespace *ns) | |||
348 | if (acct == NULL) | 329 | if (acct == NULL) |
349 | return; | 330 | return; |
350 | 331 | ||
351 | del_timer_sync(&acct->timer); | ||
352 | spin_lock(&acct_lock); | 332 | spin_lock(&acct_lock); |
353 | if (acct->file != NULL) | 333 | if (acct->file != NULL) |
354 | acct_file_reopen(acct, NULL, NULL); | 334 | acct_file_reopen(acct, NULL, NULL); |
@@ -498,7 +478,7 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
498 | * Fill the accounting struct with the needed info as recorded | 478 | * Fill the accounting struct with the needed info as recorded |
499 | * by the different kernel functions. | 479 | * by the different kernel functions. |
500 | */ | 480 | */ |
501 | memset((caddr_t)&ac, 0, sizeof(acct_t)); | 481 | memset(&ac, 0, sizeof(acct_t)); |
502 | 482 | ||
503 | ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; | 483 | ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; |
504 | strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); | 484 | strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); |