ARM: dts: imx6sx: add i.mx6sx sabreauto board support
[linux/fpc-iii.git] / fs / fs_pin.c
blob9368236ca100bc311fe721c15eca9e3bfdcb2f0f
1 #include <linux/fs.h>
2 #include <linux/slab.h>
3 #include <linux/fs_pin.h>
4 #include "internal.h"
5 #include "mount.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)
22 spin_lock(&pin_lock);
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)
30 spin_lock(&pin_lock);
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)
38 while (1) {
39 struct hlist_node *p;
40 struct fs_pin *pin;
41 rcu_read_lock();
42 p = ACCESS_ONCE(m->mnt_pins.first);
43 if (!p) {
44 rcu_read_unlock();
45 break;
47 pin = hlist_entry(p, struct fs_pin, m_list);
48 if (!atomic_long_inc_not_zero(&pin->count)) {
49 rcu_read_unlock();
50 cpu_relax();
51 continue;
53 rcu_read_unlock();
54 pin->kill(pin);
58 void sb_pin_kill(struct super_block *sb)
60 while (1) {
61 struct hlist_node *p;
62 struct fs_pin *pin;
63 rcu_read_lock();
64 p = ACCESS_ONCE(sb->s_pins.first);
65 if (!p) {
66 rcu_read_unlock();
67 break;
69 pin = hlist_entry(p, struct fs_pin, s_list);
70 if (!atomic_long_inc_not_zero(&pin->count)) {
71 rcu_read_unlock();
72 cpu_relax();
73 continue;
75 rcu_read_unlock();
76 pin->kill(pin);