2 #include <linux/slab.h>
3 #include <linux/fs_pin.h>
7 static void pin_free_rcu(struct rcu_head
*head
)
9 kfree(container_of(head
, struct fs_pin
, rcu
));
12 static DEFINE_SPINLOCK(pin_lock
);
14 void pin_put(struct fs_pin
*p
)
16 if (atomic_long_dec_and_test(&p
->count
))
17 call_rcu(&p
->rcu
, pin_free_rcu
);
20 void pin_remove(struct fs_pin
*pin
)
23 hlist_del(&pin
->m_list
);
24 hlist_del(&pin
->s_list
);
25 spin_unlock(&pin_lock
);
28 void pin_insert(struct fs_pin
*pin
, struct vfsmount
*m
)
31 hlist_add_head(&pin
->s_list
, &m
->mnt_sb
->s_pins
);
32 hlist_add_head(&pin
->m_list
, &real_mount(m
)->mnt_pins
);
33 spin_unlock(&pin_lock
);
36 void mnt_pin_kill(struct mount
*m
)
42 p
= ACCESS_ONCE(m
->mnt_pins
.first
);
47 pin
= hlist_entry(p
, struct fs_pin
, m_list
);
48 if (!atomic_long_inc_not_zero(&pin
->count
)) {
58 void sb_pin_kill(struct super_block
*sb
)
64 p
= ACCESS_ONCE(sb
->s_pins
.first
);
69 pin
= hlist_entry(p
, struct fs_pin
, s_list
);
70 if (!atomic_long_inc_not_zero(&pin
->count
)) {