2014-08-07 14:39:04 +02:00
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/fs_pin.h>
|
2014-05-22 00:22:52 +02:00
|
|
|
#include "internal.h"
|
2014-08-07 14:39:04 +02:00
|
|
|
#include "mount.h"
|
|
|
|
|
|
|
|
static DEFINE_SPINLOCK(pin_lock);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2015-01-11 16:57:27 +01:00
|
|
|
void pin_insert_group(struct fs_pin *pin, struct vfsmount *m, struct hlist_head *p)
|
2014-08-07 14:39:04 +02:00
|
|
|
{
|
|
|
|
spin_lock(&pin_lock);
|
2015-01-11 16:57:27 +01:00
|
|
|
if (p)
|
|
|
|
hlist_add_head(&pin->s_list, p);
|
2014-08-07 14:39:04 +02:00
|
|
|
hlist_add_head(&pin->m_list, &real_mount(m)->mnt_pins);
|
|
|
|
spin_unlock(&pin_lock);
|
|
|
|
}
|
|
|
|
|
2015-01-11 16:57:27 +01:00
|
|
|
void pin_insert(struct fs_pin *pin, struct vfsmount *m)
|
|
|
|
{
|
|
|
|
pin_insert_group(pin, m, &m->mnt_sb->s_pins);
|
|
|
|
}
|
|
|
|
|
2014-05-22 00:22:52 +02:00
|
|
|
void mnt_pin_kill(struct mount *m)
|
2014-08-07 14:39:04 +02:00
|
|
|
{
|
|
|
|
while (1) {
|
|
|
|
struct hlist_node *p;
|
|
|
|
struct fs_pin *pin;
|
|
|
|
rcu_read_lock();
|
2014-05-22 00:22:52 +02:00
|
|
|
p = ACCESS_ONCE(m->mnt_pins.first);
|
2014-08-07 14:39:04 +02:00
|
|
|
if (!p) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pin = hlist_entry(p, struct fs_pin, m_list);
|
|
|
|
pin->kill(pin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-11 16:57:27 +01:00
|
|
|
void group_pin_kill(struct hlist_head *p)
|
2014-08-07 14:39:04 +02:00
|
|
|
{
|
|
|
|
while (1) {
|
2015-01-11 16:57:27 +01:00
|
|
|
struct hlist_node *q;
|
2014-08-07 14:39:04 +02:00
|
|
|
struct fs_pin *pin;
|
|
|
|
rcu_read_lock();
|
2015-01-11 16:57:27 +01:00
|
|
|
q = ACCESS_ONCE(p->first);
|
|
|
|
if (!q) {
|
2014-08-07 14:39:04 +02:00
|
|
|
rcu_read_unlock();
|
|
|
|
break;
|
|
|
|
}
|
2015-01-11 16:57:27 +01:00
|
|
|
pin = hlist_entry(q, struct fs_pin, s_list);
|
2014-08-07 14:39:04 +02:00
|
|
|
pin->kill(pin);
|
|
|
|
}
|
|
|
|
}
|