Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bsdacct: make internal code work with passed bsd_acct_struct, not global

This adds the appropriate pointer to all the internal (i.e. static)
functions that work with global acct instance. API calls pass a global
instance to them (while we still have such).

Mostly this is a s/acct_globals./acct->/ over the file.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Cc: Balbir Singh <balbir@in.ibm.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Pavel Emelyanov and committed by
Linus Torvalds
6248b1b3 a75d9797

+39 -38
+39 -38
kernel/acct.c
··· 75 75 /* 76 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 82 * This structure is used so that all the data protected by lock ··· 107 106 /* 108 107 * Check the amount of free space and suspend/resume accordingly. 109 108 */ 110 - static int check_free_space(struct file *file) 109 + static int check_free_space(struct bsd_acct_struct *acct, struct file *file) 111 110 { 112 111 struct kstatfs sbuf; 113 112 int res; ··· 116 115 sector_t suspend; 117 116 118 117 spin_lock(&acct_lock); 119 - res = acct_globals.active; 120 - if (!file || !acct_globals.needcheck) 118 + res = acct->active; 119 + if (!file || !acct->needcheck) 121 120 goto out; 122 121 spin_unlock(&acct_lock); 123 122 ··· 138 137 act = 0; 139 138 140 139 /* 141 - * If some joker switched acct_globals.file under us we'ld better be 140 + * If some joker switched acct->file under us we'ld better be 142 141 * silent and _not_ touch anything. 143 142 */ 144 143 spin_lock(&acct_lock); 145 - if (file != acct_globals.file) { 144 + if (file != acct->file) { 146 145 if (act) 147 146 res = act>0; 148 147 goto out; 149 148 } 150 149 151 - if (acct_globals.active) { 150 + if (acct->active) { 152 151 if (act < 0) { 153 - acct_globals.active = 0; 152 + acct->active = 0; 154 153 printk(KERN_INFO "Process accounting paused\n"); 155 154 } 156 155 } else { 157 156 if (act > 0) { 158 - acct_globals.active = 1; 157 + acct->active = 1; 159 158 printk(KERN_INFO "Process accounting resumed\n"); 160 159 } 161 160 } 162 161 163 - del_timer(&acct_globals.timer); 164 - acct_globals.needcheck = 0; 165 - acct_globals.timer.expires = jiffies + ACCT_TIMEOUT*HZ; 166 - add_timer(&acct_globals.timer); 167 - res = acct_globals.active; 162 + del_timer(&acct->timer); 163 + acct->needcheck = 0; 164 + acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; 165 + add_timer(&acct->timer); 166 + res = acct->active; 168 167 out: 169 168 spin_unlock(&acct_lock); 170 169 return res; ··· 176 175 * 177 176 * NOTE: acct_lock MUST be held on entry and exit. 178 177 */ 179 - static void acct_file_reopen(struct file *file) 178 + static void acct_file_reopen(struct bsd_acct_struct *acct, struct file *file) 180 179 { 181 180 struct file *old_acct = NULL; 182 181 struct pid_namespace *old_ns = NULL; 183 182 184 - if (acct_globals.file) { 185 - old_acct = acct_globals.file; 186 - old_ns = acct_globals.ns; 187 - del_timer(&acct_globals.timer); 188 - acct_globals.active = 0; 189 - acct_globals.needcheck = 0; 190 - acct_globals.file = NULL; 183 + if (acct->file) { 184 + old_acct = acct->file; 185 + old_ns = acct->ns; 186 + del_timer(&acct->timer); 187 + acct->active = 0; 188 + acct->needcheck = 0; 189 + acct->file = NULL; 191 190 } 192 191 if (file) { 193 - acct_globals.file = file; 194 - acct_globals.ns = get_pid_ns(task_active_pid_ns(current)); 195 - acct_globals.needcheck = 0; 196 - acct_globals.active = 1; 192 + acct->file = file; 193 + acct->ns = get_pid_ns(task_active_pid_ns(current)); 194 + acct->needcheck = 0; 195 + acct->active = 1; 197 196 /* It's been deleted if it was used before so this is safe */ 198 - setup_timer(&acct_globals.timer, acct_timeout, 199 - (unsigned long)&acct_globals); 200 - acct_globals.timer.expires = jiffies + ACCT_TIMEOUT*HZ; 201 - add_timer(&acct_globals.timer); 197 + setup_timer(&acct->timer, acct_timeout, (unsigned long)acct); 198 + acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ; 199 + add_timer(&acct->timer); 202 200 } 203 201 if (old_acct) { 204 202 mnt_unpin(old_acct->f_path.mnt); 205 203 spin_unlock(&acct_lock); 206 - do_acct_process(old_ns, old_acct); 204 + do_acct_process(acct, old_ns, old_acct); 207 205 filp_close(old_acct, NULL); 208 206 put_pid_ns(old_ns); 209 207 spin_lock(&acct_lock); ··· 237 237 238 238 spin_lock(&acct_lock); 239 239 mnt_pin(file->f_path.mnt); 240 - acct_file_reopen(file); 240 + acct_file_reopen(&acct_globals, file); 241 241 spin_unlock(&acct_lock); 242 242 243 243 mntput(file->f_path.mnt); /* it's pinned, now give up active reference */ ··· 273 273 error = security_acct(NULL); 274 274 if (!error) { 275 275 spin_lock(&acct_lock); 276 - acct_file_reopen(NULL); 276 + acct_file_reopen(&acct_globals, NULL); 277 277 spin_unlock(&acct_lock); 278 278 } 279 279 } ··· 291 291 { 292 292 spin_lock(&acct_lock); 293 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 295 spin_unlock(&acct_lock); 296 296 } 297 297 ··· 307 307 spin_lock(&acct_lock); 308 308 if (acct_globals.file && 309 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 312 spin_unlock(&acct_lock); 313 313 } ··· 426 426 /* 427 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 432 struct pacct_struct *pacct = &current->signal->pacct; 432 433 acct_t ac; ··· 442 441 * First check to see if there is enough free_space to continue 443 442 * the process accounting system. 444 443 */ 445 - if (!check_free_space(file)) 444 + if (!check_free_space(acct, file)) 446 445 return; 447 446 448 447 /* ··· 605 604 ns = get_pid_ns(acct_globals.ns); 606 605 spin_unlock(&acct_lock); 607 606 608 - do_acct_process(ns, file); 607 + do_acct_process(&acct_globals, ns, file); 609 608 fput(file); 610 609 put_pid_ns(ns); 611 610 }