aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/acct.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/acct.c')
-rw-r--r--kernel/acct.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 05f8bc094a4b..fc71c1304977 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -83,7 +83,6 @@ static void do_acct_process(struct pid_namespace *ns, struct file *);
83 * the cache line to have the data after getting the lock. 83 * the cache line to have the data after getting the lock.
84 */ 84 */
85struct bsd_acct_struct { 85struct bsd_acct_struct {
86 spinlock_t lock;
87 volatile int active; 86 volatile int active;
88 volatile int needcheck; 87 volatile int needcheck;
89 struct file *file; 88 struct file *file;
@@ -91,8 +90,9 @@ struct bsd_acct_struct {
91 struct timer_list timer; 90 struct timer_list timer;
92}; 91};
93 92
94static struct bsd_acct_struct acct_globals __cacheline_aligned = 93static DEFINE_SPINLOCK(acct_lock);
95 {__SPIN_LOCK_UNLOCKED(acct_globals.lock)}; 94
95static struct bsd_acct_struct acct_globals __cacheline_aligned;
96 96
97/* 97/*
98 * Called whenever the timer says to check the free space. 98 * Called whenever the timer says to check the free space.
@@ -114,11 +114,11 @@ static int check_free_space(struct file *file)
114 sector_t resume; 114 sector_t resume;
115 sector_t suspend; 115 sector_t suspend;
116 116
117 spin_lock(&acct_globals.lock); 117 spin_lock(&acct_lock);
118 res = acct_globals.active; 118 res = acct_globals.active;
119 if (!file || !acct_globals.needcheck) 119 if (!file || !acct_globals.needcheck)
120 goto out; 120 goto out;
121 spin_unlock(&acct_globals.lock); 121 spin_unlock(&acct_lock);
122 122
123 /* May block */ 123 /* May block */
124 if (vfs_statfs(file->f_path.dentry, &sbuf)) 124 if (vfs_statfs(file->f_path.dentry, &sbuf))
@@ -140,7 +140,7 @@ static int check_free_space(struct file *file)
140 * If some joker switched acct_globals.file under us we'ld better be 140 * If some joker switched acct_globals.file under us we'ld better be
141 * silent and _not_ touch anything. 141 * silent and _not_ touch anything.
142 */ 142 */
143 spin_lock(&acct_globals.lock); 143 spin_lock(&acct_lock);
144 if (file != acct_globals.file) { 144 if (file != acct_globals.file) {
145 if (act) 145 if (act)
146 res = act>0; 146 res = act>0;
@@ -165,7 +165,7 @@ static int check_free_space(struct file *file)
165 add_timer(&acct_globals.timer); 165 add_timer(&acct_globals.timer);
166 res = acct_globals.active; 166 res = acct_globals.active;
167out: 167out:
168 spin_unlock(&acct_globals.lock); 168 spin_unlock(&acct_lock);
169 return res; 169 return res;
170} 170}
171 171
@@ -173,7 +173,7 @@ out:
173 * Close the old accounting file (if currently open) and then replace 173 * Close the old accounting file (if currently open) and then replace
174 * it with file (if non-NULL). 174 * it with file (if non-NULL).
175 * 175 *
176 * NOTE: acct_globals.lock MUST be held on entry and exit. 176 * NOTE: acct_lock MUST be held on entry and exit.
177 */ 177 */
178static void acct_file_reopen(struct file *file) 178static void acct_file_reopen(struct file *file)
179{ 179{
@@ -201,11 +201,11 @@ static void acct_file_reopen(struct file *file)
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_globals.lock); 204 spin_unlock(&acct_lock);
205 do_acct_process(old_ns, old_acct); 205 do_acct_process(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_globals.lock); 208 spin_lock(&acct_lock);
209 } 209 }
210} 210}
211 211
@@ -235,10 +235,10 @@ static int acct_on(char *name)
235 return error; 235 return error;
236 } 236 }
237 237
238 spin_lock(&acct_globals.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(file);
241 spin_unlock(&acct_globals.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 */
244 244
@@ -272,9 +272,9 @@ asmlinkage long sys_acct(const char __user *name)
272 } else { 272 } else {
273 error = security_acct(NULL); 273 error = security_acct(NULL);
274 if (!error) { 274 if (!error) {
275 spin_lock(&acct_globals.lock); 275 spin_lock(&acct_lock);
276 acct_file_reopen(NULL); 276 acct_file_reopen(NULL);
277 spin_unlock(&acct_globals.lock); 277 spin_unlock(&acct_lock);
278 } 278 }
279 } 279 }
280 return error; 280 return error;
@@ -289,10 +289,10 @@ asmlinkage long sys_acct(const char __user *name)
289 */ 289 */
290void acct_auto_close_mnt(struct vfsmount *m) 290void acct_auto_close_mnt(struct vfsmount *m)
291{ 291{
292 spin_lock(&acct_globals.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(NULL);
295 spin_unlock(&acct_globals.lock); 295 spin_unlock(&acct_lock);
296} 296}
297 297
298/** 298/**
@@ -304,12 +304,12 @@ void acct_auto_close_mnt(struct vfsmount *m)
304 */ 304 */
305void acct_auto_close(struct super_block *sb) 305void acct_auto_close(struct super_block *sb)
306{ 306{
307 spin_lock(&acct_globals.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(NULL);
311 } 311 }
312 spin_unlock(&acct_globals.lock); 312 spin_unlock(&acct_lock);
313} 313}
314 314
315/* 315/*
@@ -594,15 +594,15 @@ void acct_process(void)
594 if (!acct_globals.file) 594 if (!acct_globals.file)
595 return; 595 return;
596 596
597 spin_lock(&acct_globals.lock); 597 spin_lock(&acct_lock);
598 file = acct_globals.file; 598 file = acct_globals.file;
599 if (unlikely(!file)) { 599 if (unlikely(!file)) {
600 spin_unlock(&acct_globals.lock); 600 spin_unlock(&acct_lock);
601 return; 601 return;
602 } 602 }
603 get_file(file); 603 get_file(file);
604 ns = get_pid_ns(acct_globals.ns); 604 ns = get_pid_ns(acct_globals.ns);
605 spin_unlock(&acct_globals.lock); 605 spin_unlock(&acct_lock);
606 606
607 do_acct_process(ns, file); 607 do_acct_process(ns, file);
608 fput(file); 608 fput(file);