Commit 32dc730860155b235f13e0cd3fe58b263279baf9

Authored by Al Viro
1 parent 84b92d39f9

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>

Showing 1 changed file with 10 additions and 30 deletions Side-by-side Diff

... ... @@ -84,11 +84,10 @@
84 84 * the cache line to have the data after getting the lock.
85 85 */
86 86 struct bsd_acct_struct {
87   - volatile int active;
88   - volatile int needcheck;
  87 + int active;
  88 + unsigned long needcheck;
89 89 struct file *file;
90 90 struct pid_namespace *ns;
91   - struct timer_list timer;
92 91 struct list_head list;
93 92 };
94 93  
... ... @@ -96,15 +95,6 @@
96 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 98 * Check the amount of free space and suspend/resume accordingly.
109 99 */
110 100 static int check_free_space(struct bsd_acct_struct *acct, struct file *file)
111 101  
... ... @@ -112,12 +102,12 @@
112 102 struct kstatfs sbuf;
113 103 int res;
114 104 int act;
115   - sector_t resume;
116   - sector_t suspend;
  105 + u64 resume;
  106 + u64 suspend;
117 107  
118 108 spin_lock(&acct_lock);
119 109 res = acct->active;
120   - if (!file || !acct->needcheck)
  110 + if (!file || time_is_before_jiffies(acct->needcheck))
121 111 goto out;
122 112 spin_unlock(&acct_lock);
123 113  
... ... @@ -127,8 +117,8 @@
127 117 suspend = sbuf.f_blocks * SUSPEND;
128 118 resume = sbuf.f_blocks * RESUME;
129 119  
130   - sector_div(suspend, 100);
131   - sector_div(resume, 100);
  120 + do_div(suspend, 100);
  121 + do_div(resume, 100);
132 122  
133 123 if (sbuf.f_bavail <= suspend)
134 124 act = -1;
... ... @@ -160,10 +150,7 @@
160 150 }
161 151 }
162 152  
163   - del_timer(&acct->timer);
164   - acct->needcheck = 0;
165   - acct->timer.expires = jiffies + ACCT_TIMEOUT*HZ;
166   - add_timer(&acct->timer);
  153 + acct->needcheck = jiffies + ACCT_TIMEOUT*HZ;
167 154 res = acct->active;
168 155 out:
169 156 spin_unlock(&acct_lock);
170 157  
... ... @@ -185,9 +172,7 @@
185 172 if (acct->file) {
186 173 old_acct = acct->file;
187 174 old_ns = acct->ns;
188   - del_timer(&acct->timer);
189 175 acct->active = 0;
190   - acct->needcheck = 0;
191 176 acct->file = NULL;
192 177 acct->ns = NULL;
193 178 list_del(&acct->list);
194 179  
... ... @@ -195,13 +180,9 @@
195 180 if (file) {
196 181 acct->file = file;
197 182 acct->ns = ns;
198   - acct->needcheck = 0;
  183 + acct->needcheck = jiffies + ACCT_TIMEOUT*HZ;
199 184 acct->active = 1;
200 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 187 if (old_acct) {
207 188 mnt_unpin(old_acct->f_path.mnt);
... ... @@ -348,7 +329,6 @@
348 329 if (acct == NULL)
349 330 return;
350 331  
351   - del_timer_sync(&acct->timer);
352 332 spin_lock(&acct_lock);
353 333 if (acct->file != NULL)
354 334 acct_file_reopen(acct, NULL, NULL);
... ... @@ -498,7 +478,7 @@
498 478 * Fill the accounting struct with the needed info as recorded
499 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 483 ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER;
504 484 strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm));