diff options
Diffstat (limited to 'kernel/acct.c')
-rw-r--r-- | kernel/acct.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/kernel/acct.c b/kernel/acct.c index fc71c1304977..72d4760c8da8 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -75,7 +75,8 @@ int acct_parm[3] = {4, 2, 30}; | |||
75 | /* | 75 | /* |
76 | * External references and all of the globals. | 76 | * External references and all of the globals. |
77 | */ | 77 | */ |
78 | static void do_acct_process(struct pid_namespace *ns, struct file *); | 78 | static void do_acct_process(struct bsd_acct_struct *acct, |
79 | struct pid_namespace *ns, struct file *); | ||
79 | 80 | ||
80 | /* | 81 | /* |
81 | * This structure is used so that all the data protected by lock | 82 | * This structure is used so that all the data protected by lock |
@@ -106,7 +107,7 @@ static void acct_timeout(unsigned long x) | |||
106 | /* | 107 | /* |
107 | * Check the amount of free space and suspend/resume accordingly. | 108 | * Check the amount of free space and suspend/resume accordingly. |
108 | */ | 109 | */ |
109 | static int check_free_space(struct file *file) | 110 | static int check_free_space(struct bsd_acct_struct *acct, struct file *file) |
110 | { | 111 | { |
111 | struct kstatfs sbuf; | 112 | struct kstatfs sbuf; |
112 | int res; | 113 | int res; |
@@ -115,8 +116,8 @@ static int check_free_space(struct file *file) | |||
115 | sector_t suspend; | 116 | sector_t suspend; |
116 | 117 | ||
117 | spin_lock(&acct_lock); | 118 | spin_lock(&acct_lock); |
118 | res = acct_globals.active; | 119 | res = acct->active; |
119 | if (!file || !acct_globals.needcheck) | 120 | if (!file || !acct->needcheck) |
120 | goto out; | 121 | goto out; |
121 | spin_unlock(&acct_lock); | 122 | spin_unlock(&acct_lock); |
122 | 123 | ||
@@ -137,33 +138,33 @@ static int check_free_space(struct file *file) | |||
137 | act = 0; | 138 | act = 0; |
138 | 139 | ||
139 | /* | 140 | /* |
140 | * If some joker switched acct_globals.file under us we'ld better be | 141 | * If some joker switched acct->file under us we'ld better be |
141 | * silent and _not_ touch anything. | 142 | * silent and _not_ touch anything. |
142 | */ | 143 | */ |
143 | spin_lock(&acct_lock); | 144 | spin_lock(&acct_lock); |
144 | if (file != acct_globals.file) { | 145 | if (file != acct->file) { |
145 | if (act) | 146 | if (act) |
146 | res = act>0; | 147 | res = act>0; |
147 | goto out; | 148 | goto out; |
148 | } | 149 | } |
149 | 150 | ||
150 | if (acct_globals.active) { | 151 | if (acct->active) { |
151 | if (act < 0) { | 152 | if (act < 0) { |
152 | acct_globals.active = 0; | 153 | acct->active = 0; |
153 | printk(KERN_INFO "Process accounting paused\n"); | 154 | printk(KERN_INFO "Process accounting paused\n"); |
154 | } | 155 | } |
155 | } else { | 156 | } else { |
156 | if (act > 0) { | 157 | if (act > 0) { |
157 | acct_globals.active = 1; | 158 | acct->active = 1; |
158 | printk(KERN_INFO "Process accounting resumed\n"); | 159 | printk(KERN_INFO "Process accounting resumed\n"); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | del_timer(&acct_globals.timer); | 163 | del_timer(&acct->timer); |
163 | acct_globals.needcheck = 0; | 164 | acct->needcheck = 0; |
164 | acct_globals.timer.expires = jiffies + ACCT_TIMEOUT*HZ; | 165 | acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; |
165 | add_timer(&acct_globals.timer); | 166 | add_timer(&acct->timer); |
166 | res = acct_globals.active; | 167 | res = acct->active; |
167 | out: | 168 | out: |
168 | spin_unlock(&acct_lock); | 169 | spin_unlock(&acct_lock); |
169 | return res; | 170 | return res; |
@@ -175,34 +176,33 @@ out: | |||
175 | * | 176 | * |
176 | * NOTE: acct_lock MUST be held on entry and exit. | 177 | * NOTE: acct_lock MUST be held on entry and exit. |
177 | */ | 178 | */ |
178 | static void acct_file_reopen(struct file *file) | 179 | static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file) |
179 | { | 180 | { |
180 | struct file *old_acct = NULL; | 181 | struct file *old_acct = NULL; |
181 | struct pid_namespace *old_ns = NULL; | 182 | struct pid_namespace *old_ns = NULL; |
182 | 183 | ||
183 | if (acct_globals.file) { | 184 | if (acct->file) { |
184 | old_acct = acct_globals.file; | 185 | old_acct = acct->file; |
185 | old_ns = acct_globals.ns; | 186 | old_ns = acct->ns; |
186 | del_timer(&acct_globals.timer); | 187 | del_timer(&acct->timer); |
187 | acct_globals.active = 0; | 188 | acct->active = 0; |
188 | acct_globals.needcheck = 0; | 189 | acct->needcheck = 0; |
189 | acct_globals.file = NULL; | 190 | acct->file = NULL; |
190 | } | 191 | } |
191 | if (file) { | 192 | if (file) { |
192 | acct_globals.file = file; | 193 | acct->file = file; |
193 | acct_globals.ns = get_pid_ns(task_active_pid_ns(current)); | 194 | acct->ns = get_pid_ns(task_active_pid_ns(current)); |
194 | acct_globals.needcheck = 0; | 195 | acct->needcheck = 0; |
195 | acct_globals.active = 1; | 196 | acct->active = 1; |
196 | /* It's been deleted if it was used before so this is safe */ | 197 | /* It's been deleted if it was used before so this is safe */ |
197 | setup_timer(&acct_globals.timer, acct_timeout, | 198 | setup_timer(&acct->timer, acct_timeout, (unsigned long)acct); |
198 | (unsigned long)&acct_globals); | 199 | acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; |
199 | acct_globals.timer.expires = jiffies + ACCT_TIMEOUT*HZ; | 200 | add_timer(&acct->timer); |
200 | add_timer(&acct_globals.timer); | ||
201 | } | 201 | } |
202 | if (old_acct) { | 202 | if (old_acct) { |
203 | mnt_unpin(old_acct->f_path.mnt); | 203 | mnt_unpin(old_acct->f_path.mnt); |
204 | spin_unlock(&acct_lock); | 204 | spin_unlock(&acct_lock); |
205 | do_acct_process(old_ns, old_acct); | 205 | do_acct_process(acct, old_ns, old_acct); |
206 | filp_close(old_acct, NULL); | 206 | filp_close(old_acct, NULL); |
207 | put_pid_ns(old_ns); | 207 | put_pid_ns(old_ns); |
208 | spin_lock(&acct_lock); | 208 | spin_lock(&acct_lock); |
@@ -237,7 +237,7 @@ static int acct_on(char *name) | |||
237 | 237 | ||
238 | spin_lock(&acct_lock); | 238 | spin_lock(&acct_lock); |
239 | mnt_pin(file->f_path.mnt); | 239 | mnt_pin(file->f_path.mnt); |
240 | acct_file_reopen(file); | 240 | acct_file_reopen(&acct_globals, file); |
241 | spin_unlock(&acct_lock); | 241 | spin_unlock(&acct_lock); |
242 | 242 | ||
243 | mntput(file->f_path.mnt); /* it's pinned, now give up active reference */ | 243 | mntput(file->f_path.mnt); /* it's pinned, now give up active reference */ |
@@ -273,7 +273,7 @@ asmlinkage long sys_acct(const char __user *name) | |||
273 | error = security_acct(NULL); | 273 | error = security_acct(NULL); |
274 | if (!error) { | 274 | if (!error) { |
275 | spin_lock(&acct_lock); | 275 | spin_lock(&acct_lock); |
276 | acct_file_reopen(NULL); | 276 | acct_file_reopen(&acct_globals, NULL); |
277 | spin_unlock(&acct_lock); | 277 | spin_unlock(&acct_lock); |
278 | } | 278 | } |
279 | } | 279 | } |
@@ -291,7 +291,7 @@ void acct_auto_close_mnt(struct vfsmount *m) | |||
291 | { | 291 | { |
292 | spin_lock(&acct_lock); | 292 | spin_lock(&acct_lock); |
293 | if (acct_globals.file && acct_globals.file->f_path.mnt == m) | 293 | if (acct_globals.file && acct_globals.file->f_path.mnt == m) |
294 | acct_file_reopen(NULL); | 294 | acct_file_reopen(&acct_globals, NULL); |
295 | spin_unlock(&acct_lock); | 295 | spin_unlock(&acct_lock); |
296 | } | 296 | } |
297 | 297 | ||
@@ -307,7 +307,7 @@ void acct_auto_close(struct super_block *sb) | |||
307 | spin_lock(&acct_lock); | 307 | spin_lock(&acct_lock); |
308 | if (acct_globals.file && | 308 | if (acct_globals.file && |
309 | acct_globals.file->f_path.mnt->mnt_sb == sb) { | 309 | acct_globals.file->f_path.mnt->mnt_sb == sb) { |
310 | acct_file_reopen(NULL); | 310 | acct_file_reopen(&acct_globals, NULL); |
311 | } | 311 | } |
312 | spin_unlock(&acct_lock); | 312 | spin_unlock(&acct_lock); |
313 | } | 313 | } |
@@ -426,7 +426,8 @@ static u32 encode_float(u64 value) | |||
426 | /* | 426 | /* |
427 | * do_acct_process does all actual work. Caller holds the reference to file. | 427 | * do_acct_process does all actual work. Caller holds the reference to file. |
428 | */ | 428 | */ |
429 | static void do_acct_process(struct pid_namespace *ns, struct file *file) | 429 | static void do_acct_process(struct bsd_acct_struct *acct, |
430 | struct pid_namespace *ns, struct file *file) | ||
430 | { | 431 | { |
431 | struct pacct_struct *pacct = ¤t->signal->pacct; | 432 | struct pacct_struct *pacct = ¤t->signal->pacct; |
432 | acct_t ac; | 433 | acct_t ac; |
@@ -441,7 +442,7 @@ static void do_acct_process(struct pid_namespace *ns, struct file *file) | |||
441 | * First check to see if there is enough free_space to continue | 442 | * First check to see if there is enough free_space to continue |
442 | * the process accounting system. | 443 | * the process accounting system. |
443 | */ | 444 | */ |
444 | if (!check_free_space(file)) | 445 | if (!check_free_space(acct, file)) |
445 | return; | 446 | return; |
446 | 447 | ||
447 | /* | 448 | /* |
@@ -604,7 +605,7 @@ void acct_process(void) | |||
604 | ns = get_pid_ns(acct_globals.ns); | 605 | ns = get_pid_ns(acct_globals.ns); |
605 | spin_unlock(&acct_lock); | 606 | spin_unlock(&acct_lock); |
606 | 607 | ||
607 | do_acct_process(ns, file); | 608 | do_acct_process(&acct_globals, ns, file); |
608 | fput(file); | 609 | fput(file); |
609 | put_pid_ns(ns); | 610 | put_pid_ns(ns); |
610 | } | 611 | } |