Blame view
fs/fs_pin.c
1.48 KB
efb170c22
|
1 2 3 |
#include <linux/fs.h> #include <linux/slab.h> #include <linux/fs_pin.h> |
8fa1f1c2b
|
4 |
#include "internal.h" |
efb170c22
|
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#include "mount.h" static void pin_free_rcu(struct rcu_head *head) { kfree(container_of(head, struct fs_pin, rcu)); } static DEFINE_SPINLOCK(pin_lock); void pin_put(struct fs_pin *p) { if (atomic_long_dec_and_test(&p->count)) call_rcu(&p->rcu, pin_free_rcu); } void pin_remove(struct fs_pin *pin) { spin_lock(&pin_lock); hlist_del(&pin->m_list); hlist_del(&pin->s_list); spin_unlock(&pin_lock); } void pin_insert(struct fs_pin *pin, struct vfsmount *m) { spin_lock(&pin_lock); hlist_add_head(&pin->s_list, &m->mnt_sb->s_pins); hlist_add_head(&pin->m_list, &real_mount(m)->mnt_pins); spin_unlock(&pin_lock); } |
8fa1f1c2b
|
35 |
void mnt_pin_kill(struct mount *m) |
efb170c22
|
36 37 38 39 40 |
{ while (1) { struct hlist_node *p; struct fs_pin *pin; rcu_read_lock(); |
8fa1f1c2b
|
41 |
p = ACCESS_ONCE(m->mnt_pins.first); |
efb170c22
|
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
if (!p) { rcu_read_unlock(); break; } pin = hlist_entry(p, struct fs_pin, m_list); if (!atomic_long_inc_not_zero(&pin->count)) { rcu_read_unlock(); cpu_relax(); continue; } rcu_read_unlock(); pin->kill(pin); } } |
8fa1f1c2b
|
56 |
void sb_pin_kill(struct super_block *sb) |
efb170c22
|
57 58 59 60 61 |
{ while (1) { struct hlist_node *p; struct fs_pin *pin; rcu_read_lock(); |
8fa1f1c2b
|
62 |
p = ACCESS_ONCE(sb->s_pins.first); |
efb170c22
|
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
if (!p) { rcu_read_unlock(); break; } pin = hlist_entry(p, struct fs_pin, s_list); if (!atomic_long_inc_not_zero(&pin->count)) { rcu_read_unlock(); cpu_relax(); continue; } rcu_read_unlock(); pin->kill(pin); } } |