aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2014-08-07 08:00:52 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-08-07 14:40:08 -0400
commit1629d0eb3ead0e0c49e4402049ec7b5b31b81cd7 (patch)
treef080a4025e9c9b6d2bea11da4c8aa49b3ea54869 /kernel
parent215748e67d893169de9e62c3416e9e035e9e9c5f (diff)
start carving bsd_acct_struct up
pull generic parts into struct fs_pin. Eventually we want those to replace mnt_pin()/mnt_unpin() mess; that stuff will move to fs/*. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/acct.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 2d9e04d98998..afeaaa6f49bf 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -78,7 +78,7 @@ int acct_parm[3] = {4, 2, 30};
78 */ 78 */
79static void do_acct_process(struct bsd_acct_struct *acct); 79static void do_acct_process(struct bsd_acct_struct *acct);
80 80
81struct bsd_acct_struct { 81struct fs_pin {
82 atomic_long_t count; 82 atomic_long_t count;
83 union { 83 union {
84 struct { 84 struct {
@@ -87,6 +87,10 @@ struct bsd_acct_struct {
87 }; 87 };
88 struct rcu_head rcu; 88 struct rcu_head rcu;
89 }; 89 };
90};
91
92struct bsd_acct_struct {
93 struct fs_pin pin;
90 struct mutex lock; 94 struct mutex lock;
91 int active; 95 int active;
92 unsigned long needcheck; 96 unsigned long needcheck;
@@ -96,9 +100,9 @@ struct bsd_acct_struct {
96 struct completion done; 100 struct completion done;
97}; 101};
98 102
99static void acct_free_rcu(struct rcu_head *head) 103static void pin_free_rcu(struct rcu_head *head)
100{ 104{
101 kfree(container_of(head, struct bsd_acct_struct, rcu)); 105 kfree(container_of(head, struct fs_pin, rcu));
102} 106}
103 107
104static DEFINE_SPINLOCK(acct_lock); 108static DEFINE_SPINLOCK(acct_lock);
@@ -138,15 +142,15 @@ out:
138 return acct->active; 142 return acct->active;
139} 143}
140 144
141static void acct_put(struct bsd_acct_struct *p) 145static void pin_put(struct fs_pin *p)
142{ 146{
143 if (atomic_long_dec_and_test(&p->count)) 147 if (atomic_long_dec_and_test(&p->count))
144 call_rcu(&p->rcu, acct_free_rcu); 148 call_rcu(&p->rcu, pin_free_rcu);
145} 149}
146 150
147static struct bsd_acct_struct *__acct_get(struct bsd_acct_struct *res) 151static struct bsd_acct_struct *__acct_get(struct bsd_acct_struct *res)
148{ 152{
149 if (!atomic_long_inc_not_zero(&res->count)) { 153 if (!atomic_long_inc_not_zero(&res->pin.count)) {
150 rcu_read_unlock(); 154 rcu_read_unlock();
151 cpu_relax(); 155 cpu_relax();
152 return NULL; 156 return NULL;
@@ -155,7 +159,7 @@ static struct bsd_acct_struct *__acct_get(struct bsd_acct_struct *res)
155 mutex_lock(&res->lock); 159 mutex_lock(&res->lock);
156 if (!res->ns) { 160 if (!res->ns) {
157 mutex_unlock(&res->lock); 161 mutex_unlock(&res->lock);
158 acct_put(res); 162 pin_put(&res->pin);
159 return NULL; 163 return NULL;
160 } 164 }
161 return res; 165 return res;
@@ -200,22 +204,22 @@ static void acct_kill(struct bsd_acct_struct *acct,
200 schedule_work(&acct->work); 204 schedule_work(&acct->work);
201 wait_for_completion(&acct->done); 205 wait_for_completion(&acct->done);
202 spin_lock(&acct_lock); 206 spin_lock(&acct_lock);
203 hlist_del(&acct->m_list); 207 hlist_del(&acct->pin.m_list);
204 hlist_del(&acct->s_list); 208 hlist_del(&acct->pin.s_list);
205 spin_unlock(&acct_lock); 209 spin_unlock(&acct_lock);
206 ns->bacct = new; 210 ns->bacct = new;
207 if (new) { 211 if (new) {
208 struct vfsmount *m = new->file->f_path.mnt; 212 struct vfsmount *m = new->file->f_path.mnt;
209 spin_lock(&acct_lock); 213 spin_lock(&acct_lock);
210 hlist_add_head(&new->s_list, &m->mnt_sb->s_pins); 214 hlist_add_head(&new->pin.s_list, &m->mnt_sb->s_pins);
211 hlist_add_head(&new->m_list, &real_mount(m)->mnt_pins); 215 hlist_add_head(&new->pin.m_list, &real_mount(m)->mnt_pins);
212 spin_unlock(&acct_lock); 216 spin_unlock(&acct_lock);
213 mutex_unlock(&new->lock); 217 mutex_unlock(&new->lock);
214 } 218 }
215 acct->ns = NULL; 219 acct->ns = NULL;
216 atomic_long_dec(&acct->count); 220 atomic_long_dec(&acct->pin.count);
217 mutex_unlock(&acct->lock); 221 mutex_unlock(&acct->lock);
218 acct_put(acct); 222 pin_put(&acct->pin);
219 } 223 }
220} 224}
221 225
@@ -249,7 +253,7 @@ static int acct_on(struct filename *pathname)
249 return -EIO; 253 return -EIO;
250 } 254 }
251 255
252 atomic_long_set(&acct->count, 1); 256 atomic_long_set(&acct->pin.count, 1);
253 acct->file = file; 257 acct->file = file;
254 acct->needcheck = jiffies; 258 acct->needcheck = jiffies;
255 acct->ns = ns; 259 acct->ns = ns;
@@ -264,8 +268,8 @@ static int acct_on(struct filename *pathname)
264 } else { 268 } else {
265 ns->bacct = acct; 269 ns->bacct = acct;
266 spin_lock(&acct_lock); 270 spin_lock(&acct_lock);
267 hlist_add_head(&acct->s_list, &mnt->mnt_sb->s_pins); 271 hlist_add_head(&acct->pin.s_list, &mnt->mnt_sb->s_pins);
268 hlist_add_head(&acct->m_list, &real_mount(mnt)->mnt_pins); 272 hlist_add_head(&acct->pin.m_list, &real_mount(mnt)->mnt_pins);
269 spin_unlock(&acct_lock); 273 spin_unlock(&acct_lock);
270 mutex_unlock(&acct->lock); 274 mutex_unlock(&acct->lock);
271 } 275 }
@@ -317,7 +321,7 @@ void acct_auto_close_mnt(struct hlist_head *list)
317 break; 321 break;
318 acct_kill(__acct_get(hlist_entry(p, 322 acct_kill(__acct_get(hlist_entry(p,
319 struct bsd_acct_struct, 323 struct bsd_acct_struct,
320 m_list)), NULL); 324 pin.m_list)), NULL);
321 rcu_read_lock(); 325 rcu_read_lock();
322 } 326 }
323 rcu_read_unlock(); 327 rcu_read_unlock();
@@ -332,7 +336,7 @@ void acct_auto_close(struct hlist_head *list)
332 break; 336 break;
333 acct_kill(__acct_get(hlist_entry(p, 337 acct_kill(__acct_get(hlist_entry(p,
334 struct bsd_acct_struct, 338 struct bsd_acct_struct,
335 s_list)), NULL); 339 pin.s_list)), NULL);
336 rcu_read_lock(); 340 rcu_read_lock();
337 } 341 }
338 rcu_read_unlock(); 342 rcu_read_unlock();
@@ -613,7 +617,7 @@ static void slow_acct_process(struct pid_namespace *ns)
613 if (acct) { 617 if (acct) {
614 do_acct_process(acct); 618 do_acct_process(acct);
615 mutex_unlock(&acct->lock); 619 mutex_unlock(&acct->lock);
616 acct_put(acct); 620 pin_put(&acct->pin);
617 } 621 }
618 } 622 }
619} 623}