Commit 1629d0eb3ead0e0c49e4402049ec7b5b31b81cd7
1 parent
215748e67d
Exists in
smarc_imx_lf-5.15.y
and in
32 other branches
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>
Showing 1 changed file with 23 additions and 19 deletions Side-by-side Diff
kernel/acct.c
... | ... | @@ -78,7 +78,7 @@ |
78 | 78 | */ |
79 | 79 | static void do_acct_process(struct bsd_acct_struct *acct); |
80 | 80 | |
81 | -struct bsd_acct_struct { | |
81 | +struct fs_pin { | |
82 | 82 | atomic_long_t count; |
83 | 83 | union { |
84 | 84 | struct { |
... | ... | @@ -87,6 +87,10 @@ |
87 | 87 | }; |
88 | 88 | struct rcu_head rcu; |
89 | 89 | }; |
90 | +}; | |
91 | + | |
92 | +struct bsd_acct_struct { | |
93 | + struct fs_pin pin; | |
90 | 94 | struct mutex lock; |
91 | 95 | int active; |
92 | 96 | unsigned long needcheck; |
93 | 97 | |
... | ... | @@ -96,9 +100,9 @@ |
96 | 100 | struct completion done; |
97 | 101 | }; |
98 | 102 | |
99 | -static void acct_free_rcu(struct rcu_head *head) | |
103 | +static 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 | |
104 | 108 | static DEFINE_SPINLOCK(acct_lock); |
105 | 109 | |
106 | 110 | |
... | ... | @@ -138,15 +142,15 @@ |
138 | 142 | return acct->active; |
139 | 143 | } |
140 | 144 | |
141 | -static void acct_put(struct bsd_acct_struct *p) | |
145 | +static void pin_put(struct fs_pin *p) | |
142 | 146 | { |
143 | 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 | |
147 | 151 | static 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 | 154 | rcu_read_unlock(); |
151 | 155 | cpu_relax(); |
152 | 156 | return NULL; |
... | ... | @@ -155,7 +159,7 @@ |
155 | 159 | mutex_lock(&res->lock); |
156 | 160 | if (!res->ns) { |
157 | 161 | mutex_unlock(&res->lock); |
158 | - acct_put(res); | |
162 | + pin_put(&res->pin); | |
159 | 163 | return NULL; |
160 | 164 | } |
161 | 165 | return res; |
162 | 166 | |
163 | 167 | |
164 | 168 | |
... | ... | @@ -200,22 +204,22 @@ |
200 | 204 | schedule_work(&acct->work); |
201 | 205 | wait_for_completion(&acct->done); |
202 | 206 | spin_lock(&acct_lock); |
203 | - hlist_del(&acct->m_list); | |
204 | - hlist_del(&acct->s_list); | |
207 | + hlist_del(&acct->pin.m_list); | |
208 | + hlist_del(&acct->pin.s_list); | |
205 | 209 | spin_unlock(&acct_lock); |
206 | 210 | ns->bacct = new; |
207 | 211 | if (new) { |
208 | 212 | struct vfsmount *m = new->file->f_path.mnt; |
209 | 213 | spin_lock(&acct_lock); |
210 | - hlist_add_head(&new->s_list, &m->mnt_sb->s_pins); | |
211 | - hlist_add_head(&new->m_list, &real_mount(m)->mnt_pins); | |
214 | + hlist_add_head(&new->pin.s_list, &m->mnt_sb->s_pins); | |
215 | + hlist_add_head(&new->pin.m_list, &real_mount(m)->mnt_pins); | |
212 | 216 | spin_unlock(&acct_lock); |
213 | 217 | mutex_unlock(&new->lock); |
214 | 218 | } |
215 | 219 | acct->ns = NULL; |
216 | - atomic_long_dec(&acct->count); | |
220 | + atomic_long_dec(&acct->pin.count); | |
217 | 221 | mutex_unlock(&acct->lock); |
218 | - acct_put(acct); | |
222 | + pin_put(&acct->pin); | |
219 | 223 | } |
220 | 224 | } |
221 | 225 | |
... | ... | @@ -249,7 +253,7 @@ |
249 | 253 | return -EIO; |
250 | 254 | } |
251 | 255 | |
252 | - atomic_long_set(&acct->count, 1); | |
256 | + atomic_long_set(&acct->pin.count, 1); | |
253 | 257 | acct->file = file; |
254 | 258 | acct->needcheck = jiffies; |
255 | 259 | acct->ns = ns; |
... | ... | @@ -264,8 +268,8 @@ |
264 | 268 | } else { |
265 | 269 | ns->bacct = acct; |
266 | 270 | spin_lock(&acct_lock); |
267 | - hlist_add_head(&acct->s_list, &mnt->mnt_sb->s_pins); | |
268 | - hlist_add_head(&acct->m_list, &real_mount(mnt)->mnt_pins); | |
271 | + hlist_add_head(&acct->pin.s_list, &mnt->mnt_sb->s_pins); | |
272 | + hlist_add_head(&acct->pin.m_list, &real_mount(mnt)->mnt_pins); | |
269 | 273 | spin_unlock(&acct_lock); |
270 | 274 | mutex_unlock(&acct->lock); |
271 | 275 | } |
... | ... | @@ -317,7 +321,7 @@ |
317 | 321 | break; |
318 | 322 | acct_kill(__acct_get(hlist_entry(p, |
319 | 323 | struct bsd_acct_struct, |
320 | - m_list)), NULL); | |
324 | + pin.m_list)), NULL); | |
321 | 325 | rcu_read_lock(); |
322 | 326 | } |
323 | 327 | rcu_read_unlock(); |
... | ... | @@ -332,7 +336,7 @@ |
332 | 336 | break; |
333 | 337 | acct_kill(__acct_get(hlist_entry(p, |
334 | 338 | struct bsd_acct_struct, |
335 | - s_list)), NULL); | |
339 | + pin.s_list)), NULL); | |
336 | 340 | rcu_read_lock(); |
337 | 341 | } |
338 | 342 | rcu_read_unlock(); |
... | ... | @@ -613,7 +617,7 @@ |
613 | 617 | if (acct) { |
614 | 618 | do_acct_process(acct); |
615 | 619 | mutex_unlock(&acct->lock); |
616 | - acct_put(acct); | |
620 | + pin_put(&acct->pin); | |
617 | 621 | } |
618 | 622 | } |
619 | 623 | } |