提交 962830df 编写于 作者: A Andi Kleen 提交者: Al Viro

brlocks/lglocks: API cleanups

lglocks and brlocks are currently generated with some complicated macros
in lglock.h.  But there's no reason to not just use common utility
functions and put all the data into a common data structure.

In preparation, this patch changes the API to look more like normal
function calls with pointers, not magic macros.

The patch is rather large because I move over all users in one go to keep
it bisectable.  This impacts the VFS somewhat in terms of lines changed.
But no actual behaviour change.

[akpm@linux-foundation.org: checkpatch fixes]
Signed-off-by: NAndi Kleen <ak@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 eea62f83
...@@ -2575,7 +2575,7 @@ static int prepend_path(const struct path *path, ...@@ -2575,7 +2575,7 @@ static int prepend_path(const struct path *path,
bool slash = false; bool slash = false;
int error = 0; int error = 0;
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
while (dentry != root->dentry || vfsmnt != root->mnt) { while (dentry != root->dentry || vfsmnt != root->mnt) {
struct dentry * parent; struct dentry * parent;
...@@ -2606,7 +2606,7 @@ static int prepend_path(const struct path *path, ...@@ -2606,7 +2606,7 @@ static int prepend_path(const struct path *path,
error = prepend(buffer, buflen, "/", 1); error = prepend(buffer, buflen, "/", 1);
out: out:
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return error; return error;
global_root: global_root:
......
...@@ -420,9 +420,9 @@ static inline void __file_sb_list_add(struct file *file, struct super_block *sb) ...@@ -420,9 +420,9 @@ static inline void __file_sb_list_add(struct file *file, struct super_block *sb)
*/ */
void file_sb_list_add(struct file *file, struct super_block *sb) void file_sb_list_add(struct file *file, struct super_block *sb)
{ {
lg_local_lock(files_lglock); lg_local_lock(&files_lglock);
__file_sb_list_add(file, sb); __file_sb_list_add(file, sb);
lg_local_unlock(files_lglock); lg_local_unlock(&files_lglock);
} }
/** /**
...@@ -435,9 +435,9 @@ void file_sb_list_add(struct file *file, struct super_block *sb) ...@@ -435,9 +435,9 @@ void file_sb_list_add(struct file *file, struct super_block *sb)
void file_sb_list_del(struct file *file) void file_sb_list_del(struct file *file)
{ {
if (!list_empty(&file->f_u.fu_list)) { if (!list_empty(&file->f_u.fu_list)) {
lg_local_lock_cpu(files_lglock, file_list_cpu(file)); lg_local_lock_cpu(&files_lglock, file_list_cpu(file));
list_del_init(&file->f_u.fu_list); list_del_init(&file->f_u.fu_list);
lg_local_unlock_cpu(files_lglock, file_list_cpu(file)); lg_local_unlock_cpu(&files_lglock, file_list_cpu(file));
} }
} }
...@@ -484,7 +484,7 @@ void mark_files_ro(struct super_block *sb) ...@@ -484,7 +484,7 @@ void mark_files_ro(struct super_block *sb)
struct file *f; struct file *f;
retry: retry:
lg_global_lock(files_lglock); lg_global_lock(&files_lglock);
do_file_list_for_each_entry(sb, f) { do_file_list_for_each_entry(sb, f) {
struct vfsmount *mnt; struct vfsmount *mnt;
if (!S_ISREG(f->f_path.dentry->d_inode->i_mode)) if (!S_ISREG(f->f_path.dentry->d_inode->i_mode))
...@@ -501,12 +501,12 @@ void mark_files_ro(struct super_block *sb) ...@@ -501,12 +501,12 @@ void mark_files_ro(struct super_block *sb)
file_release_write(f); file_release_write(f);
mnt = mntget(f->f_path.mnt); mnt = mntget(f->f_path.mnt);
/* This can sleep, so we can't hold the spinlock. */ /* This can sleep, so we can't hold the spinlock. */
lg_global_unlock(files_lglock); lg_global_unlock(&files_lglock);
mnt_drop_write(mnt); mnt_drop_write(mnt);
mntput(mnt); mntput(mnt);
goto retry; goto retry;
} while_file_list_for_each_entry; } while_file_list_for_each_entry;
lg_global_unlock(files_lglock); lg_global_unlock(&files_lglock);
} }
void __init files_init(unsigned long mempages) void __init files_init(unsigned long mempages)
...@@ -524,6 +524,6 @@ void __init files_init(unsigned long mempages) ...@@ -524,6 +524,6 @@ void __init files_init(unsigned long mempages)
n = (mempages * (PAGE_SIZE / 1024)) / 10; n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = max_t(unsigned long, n, NR_FILE); files_stat.max_files = max_t(unsigned long, n, NR_FILE);
files_defer_init(); files_defer_init();
lg_lock_init(files_lglock); lg_lock_init(&files_lglock, "files_lglock");
percpu_counter_init(&nr_files, 0); percpu_counter_init(&nr_files, 0);
} }
...@@ -449,7 +449,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry) ...@@ -449,7 +449,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
mntget(nd->path.mnt); mntget(nd->path.mnt);
rcu_read_unlock(); rcu_read_unlock();
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
nd->flags &= ~LOOKUP_RCU; nd->flags &= ~LOOKUP_RCU;
return 0; return 0;
...@@ -507,14 +507,14 @@ static int complete_walk(struct nameidata *nd) ...@@ -507,14 +507,14 @@ static int complete_walk(struct nameidata *nd)
if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) { if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) {
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
rcu_read_unlock(); rcu_read_unlock();
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return -ECHILD; return -ECHILD;
} }
BUG_ON(nd->inode != dentry->d_inode); BUG_ON(nd->inode != dentry->d_inode);
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
mntget(nd->path.mnt); mntget(nd->path.mnt);
rcu_read_unlock(); rcu_read_unlock();
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
} }
if (likely(!(nd->flags & LOOKUP_JUMPED))) if (likely(!(nd->flags & LOOKUP_JUMPED)))
...@@ -681,15 +681,15 @@ int follow_up(struct path *path) ...@@ -681,15 +681,15 @@ int follow_up(struct path *path)
struct mount *parent; struct mount *parent;
struct dentry *mountpoint; struct dentry *mountpoint;
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
parent = mnt->mnt_parent; parent = mnt->mnt_parent;
if (&parent->mnt == path->mnt) { if (&parent->mnt == path->mnt) {
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return 0; return 0;
} }
mntget(&parent->mnt); mntget(&parent->mnt);
mountpoint = dget(mnt->mnt_mountpoint); mountpoint = dget(mnt->mnt_mountpoint);
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
dput(path->dentry); dput(path->dentry);
path->dentry = mountpoint; path->dentry = mountpoint;
mntput(path->mnt); mntput(path->mnt);
...@@ -947,7 +947,7 @@ static int follow_dotdot_rcu(struct nameidata *nd) ...@@ -947,7 +947,7 @@ static int follow_dotdot_rcu(struct nameidata *nd)
if (!(nd->flags & LOOKUP_ROOT)) if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL; nd->root.mnt = NULL;
rcu_read_unlock(); rcu_read_unlock();
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return -ECHILD; return -ECHILD;
} }
...@@ -1265,7 +1265,7 @@ static void terminate_walk(struct nameidata *nd) ...@@ -1265,7 +1265,7 @@ static void terminate_walk(struct nameidata *nd)
if (!(nd->flags & LOOKUP_ROOT)) if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL; nd->root.mnt = NULL;
rcu_read_unlock(); rcu_read_unlock();
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
} }
} }
...@@ -1620,7 +1620,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, ...@@ -1620,7 +1620,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
nd->path = nd->root; nd->path = nd->root;
nd->inode = inode; nd->inode = inode;
if (flags & LOOKUP_RCU) { if (flags & LOOKUP_RCU) {
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
rcu_read_lock(); rcu_read_lock();
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
} else { } else {
...@@ -1633,7 +1633,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, ...@@ -1633,7 +1633,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
if (*name=='/') { if (*name=='/') {
if (flags & LOOKUP_RCU) { if (flags & LOOKUP_RCU) {
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
rcu_read_lock(); rcu_read_lock();
set_root_rcu(nd); set_root_rcu(nd);
} else { } else {
...@@ -1646,7 +1646,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, ...@@ -1646,7 +1646,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
struct fs_struct *fs = current->fs; struct fs_struct *fs = current->fs;
unsigned seq; unsigned seq;
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
rcu_read_lock(); rcu_read_lock();
do { do {
...@@ -1682,7 +1682,7 @@ static int path_init(int dfd, const char *name, unsigned int flags, ...@@ -1682,7 +1682,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
if (fput_needed) if (fput_needed)
*fp = file; *fp = file;
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq); nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
rcu_read_lock(); rcu_read_lock();
} else { } else {
path_get(&file->f_path); path_get(&file->f_path);
......
...@@ -397,7 +397,7 @@ static int mnt_make_readonly(struct mount *mnt) ...@@ -397,7 +397,7 @@ static int mnt_make_readonly(struct mount *mnt)
{ {
int ret = 0; int ret = 0;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
/* /*
* After storing MNT_WRITE_HOLD, we'll read the counters. This store * After storing MNT_WRITE_HOLD, we'll read the counters. This store
...@@ -431,15 +431,15 @@ static int mnt_make_readonly(struct mount *mnt) ...@@ -431,15 +431,15 @@ static int mnt_make_readonly(struct mount *mnt)
*/ */
smp_wmb(); smp_wmb();
mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return ret; return ret;
} }
static void __mnt_unmake_readonly(struct mount *mnt) static void __mnt_unmake_readonly(struct mount *mnt)
{ {
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
mnt->mnt.mnt_flags &= ~MNT_READONLY; mnt->mnt.mnt_flags &= ~MNT_READONLY;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
int sb_prepare_remount_readonly(struct super_block *sb) int sb_prepare_remount_readonly(struct super_block *sb)
...@@ -451,7 +451,7 @@ int sb_prepare_remount_readonly(struct super_block *sb) ...@@ -451,7 +451,7 @@ int sb_prepare_remount_readonly(struct super_block *sb)
if (atomic_long_read(&sb->s_remove_count)) if (atomic_long_read(&sb->s_remove_count))
return -EBUSY; return -EBUSY;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) { list_for_each_entry(mnt, &sb->s_mounts, mnt_instance) {
if (!(mnt->mnt.mnt_flags & MNT_READONLY)) { if (!(mnt->mnt.mnt_flags & MNT_READONLY)) {
mnt->mnt.mnt_flags |= MNT_WRITE_HOLD; mnt->mnt.mnt_flags |= MNT_WRITE_HOLD;
...@@ -473,7 +473,7 @@ int sb_prepare_remount_readonly(struct super_block *sb) ...@@ -473,7 +473,7 @@ int sb_prepare_remount_readonly(struct super_block *sb)
if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD) if (mnt->mnt.mnt_flags & MNT_WRITE_HOLD)
mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD; mnt->mnt.mnt_flags &= ~MNT_WRITE_HOLD;
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return err; return err;
} }
...@@ -522,14 +522,14 @@ struct vfsmount *lookup_mnt(struct path *path) ...@@ -522,14 +522,14 @@ struct vfsmount *lookup_mnt(struct path *path)
{ {
struct mount *child_mnt; struct mount *child_mnt;
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
child_mnt = __lookup_mnt(path->mnt, path->dentry, 1); child_mnt = __lookup_mnt(path->mnt, path->dentry, 1);
if (child_mnt) { if (child_mnt) {
mnt_add_count(child_mnt, 1); mnt_add_count(child_mnt, 1);
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return &child_mnt->mnt; return &child_mnt->mnt;
} else { } else {
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return NULL; return NULL;
} }
} }
...@@ -714,9 +714,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void ...@@ -714,9 +714,9 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
mnt->mnt.mnt_sb = root->d_sb; mnt->mnt.mnt_sb = root->d_sb;
mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt_parent = mnt; mnt->mnt_parent = mnt;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts); list_add_tail(&mnt->mnt_instance, &root->d_sb->s_mounts);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return &mnt->mnt; return &mnt->mnt;
} }
EXPORT_SYMBOL_GPL(vfs_kern_mount); EXPORT_SYMBOL_GPL(vfs_kern_mount);
...@@ -745,9 +745,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root, ...@@ -745,9 +745,9 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
mnt->mnt.mnt_root = dget(root); mnt->mnt.mnt_root = dget(root);
mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt_parent = mnt; mnt->mnt_parent = mnt;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_add_tail(&mnt->mnt_instance, &sb->s_mounts); list_add_tail(&mnt->mnt_instance, &sb->s_mounts);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
if (flag & CL_SLAVE) { if (flag & CL_SLAVE) {
list_add(&mnt->mnt_slave, &old->mnt_slave_list); list_add(&mnt->mnt_slave, &old->mnt_slave_list);
...@@ -803,35 +803,36 @@ static void mntput_no_expire(struct mount *mnt) ...@@ -803,35 +803,36 @@ static void mntput_no_expire(struct mount *mnt)
{ {
put_again: put_again:
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
if (likely(atomic_read(&mnt->mnt_longterm))) { if (likely(atomic_read(&mnt->mnt_longterm))) {
mnt_add_count(mnt, -1); mnt_add_count(mnt, -1);
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return; return;
} }
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
mnt_add_count(mnt, -1); mnt_add_count(mnt, -1);
if (mnt_get_count(mnt)) { if (mnt_get_count(mnt)) {
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return; return;
} }
#else #else
mnt_add_count(mnt, -1); mnt_add_count(mnt, -1);
if (likely(mnt_get_count(mnt))) if (likely(mnt_get_count(mnt)))
return; return;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
#endif #endif
if (unlikely(mnt->mnt_pinned)) { if (unlikely(mnt->mnt_pinned)) {
mnt_add_count(mnt, mnt->mnt_pinned + 1); mnt_add_count(mnt, mnt->mnt_pinned + 1);
mnt->mnt_pinned = 0; mnt->mnt_pinned = 0;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
acct_auto_close_mnt(&mnt->mnt); acct_auto_close_mnt(&mnt->mnt);
goto put_again; goto put_again;
} }
list_del(&mnt->mnt_instance); list_del(&mnt->mnt_instance);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
mntfree(mnt); mntfree(mnt);
} }
...@@ -857,21 +858,21 @@ EXPORT_SYMBOL(mntget); ...@@ -857,21 +858,21 @@ EXPORT_SYMBOL(mntget);
void mnt_pin(struct vfsmount *mnt) void mnt_pin(struct vfsmount *mnt)
{ {
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
real_mount(mnt)->mnt_pinned++; real_mount(mnt)->mnt_pinned++;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
EXPORT_SYMBOL(mnt_pin); EXPORT_SYMBOL(mnt_pin);
void mnt_unpin(struct vfsmount *m) void mnt_unpin(struct vfsmount *m)
{ {
struct mount *mnt = real_mount(m); struct mount *mnt = real_mount(m);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
if (mnt->mnt_pinned) { if (mnt->mnt_pinned) {
mnt_add_count(mnt, 1); mnt_add_count(mnt, 1);
mnt->mnt_pinned--; mnt->mnt_pinned--;
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
EXPORT_SYMBOL(mnt_unpin); EXPORT_SYMBOL(mnt_unpin);
...@@ -988,12 +989,12 @@ int may_umount_tree(struct vfsmount *m) ...@@ -988,12 +989,12 @@ int may_umount_tree(struct vfsmount *m)
BUG_ON(!m); BUG_ON(!m);
/* write lock needed for mnt_get_count */ /* write lock needed for mnt_get_count */
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
for (p = mnt; p; p = next_mnt(p, mnt)) { for (p = mnt; p; p = next_mnt(p, mnt)) {
actual_refs += mnt_get_count(p); actual_refs += mnt_get_count(p);
minimum_refs += 2; minimum_refs += 2;
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
if (actual_refs > minimum_refs) if (actual_refs > minimum_refs)
return 0; return 0;
...@@ -1020,10 +1021,10 @@ int may_umount(struct vfsmount *mnt) ...@@ -1020,10 +1021,10 @@ int may_umount(struct vfsmount *mnt)
{ {
int ret = 1; int ret = 1;
down_read(&namespace_sem); down_read(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
if (propagate_mount_busy(real_mount(mnt), 2)) if (propagate_mount_busy(real_mount(mnt), 2))
ret = 0; ret = 0;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_read(&namespace_sem); up_read(&namespace_sem);
return ret; return ret;
} }
...@@ -1040,13 +1041,13 @@ void release_mounts(struct list_head *head) ...@@ -1040,13 +1041,13 @@ void release_mounts(struct list_head *head)
struct dentry *dentry; struct dentry *dentry;
struct mount *m; struct mount *m;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
dentry = mnt->mnt_mountpoint; dentry = mnt->mnt_mountpoint;
m = mnt->mnt_parent; m = mnt->mnt_parent;
mnt->mnt_mountpoint = mnt->mnt.mnt_root; mnt->mnt_mountpoint = mnt->mnt.mnt_root;
mnt->mnt_parent = mnt; mnt->mnt_parent = mnt;
m->mnt_ghosts--; m->mnt_ghosts--;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
dput(dentry); dput(dentry);
mntput(&m->mnt); mntput(&m->mnt);
} }
...@@ -1112,12 +1113,12 @@ static int do_umount(struct mount *mnt, int flags) ...@@ -1112,12 +1113,12 @@ static int do_umount(struct mount *mnt, int flags)
* probably don't strictly need the lock here if we examined * probably don't strictly need the lock here if we examined
* all race cases, but it's a slowpath. * all race cases, but it's a slowpath.
*/ */
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
if (mnt_get_count(mnt) != 2) { if (mnt_get_count(mnt) != 2) {
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return -EBUSY; return -EBUSY;
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
if (!xchg(&mnt->mnt_expiry_mark, 1)) if (!xchg(&mnt->mnt_expiry_mark, 1))
return -EAGAIN; return -EAGAIN;
...@@ -1159,7 +1160,7 @@ static int do_umount(struct mount *mnt, int flags) ...@@ -1159,7 +1160,7 @@ static int do_umount(struct mount *mnt, int flags)
} }
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
event++; event++;
if (!(flags & MNT_DETACH)) if (!(flags & MNT_DETACH))
...@@ -1171,7 +1172,7 @@ static int do_umount(struct mount *mnt, int flags) ...@@ -1171,7 +1172,7 @@ static int do_umount(struct mount *mnt, int flags)
umount_tree(mnt, 1, &umount_list); umount_tree(mnt, 1, &umount_list);
retval = 0; retval = 0;
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umount_list); release_mounts(&umount_list);
return retval; return retval;
...@@ -1286,19 +1287,19 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry, ...@@ -1286,19 +1287,19 @@ struct mount *copy_tree(struct mount *mnt, struct dentry *dentry,
q = clone_mnt(p, p->mnt.mnt_root, flag); q = clone_mnt(p, p->mnt.mnt_root, flag);
if (!q) if (!q)
goto Enomem; goto Enomem;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_add_tail(&q->mnt_list, &res->mnt_list); list_add_tail(&q->mnt_list, &res->mnt_list);
attach_mnt(q, &path); attach_mnt(q, &path);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
} }
return res; return res;
Enomem: Enomem:
if (res) { if (res) {
LIST_HEAD(umount_list); LIST_HEAD(umount_list);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
umount_tree(res, 0, &umount_list); umount_tree(res, 0, &umount_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
release_mounts(&umount_list); release_mounts(&umount_list);
} }
return NULL; return NULL;
...@@ -1318,9 +1319,9 @@ void drop_collected_mounts(struct vfsmount *mnt) ...@@ -1318,9 +1319,9 @@ void drop_collected_mounts(struct vfsmount *mnt)
{ {
LIST_HEAD(umount_list); LIST_HEAD(umount_list);
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
umount_tree(real_mount(mnt), 0, &umount_list); umount_tree(real_mount(mnt), 0, &umount_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umount_list); release_mounts(&umount_list);
} }
...@@ -1448,7 +1449,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, ...@@ -1448,7 +1449,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
if (err) if (err)
goto out_cleanup_ids; goto out_cleanup_ids;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
if (IS_MNT_SHARED(dest_mnt)) { if (IS_MNT_SHARED(dest_mnt)) {
for (p = source_mnt; p; p = next_mnt(p, source_mnt)) for (p = source_mnt; p; p = next_mnt(p, source_mnt))
...@@ -1467,7 +1468,7 @@ static int attach_recursive_mnt(struct mount *source_mnt, ...@@ -1467,7 +1468,7 @@ static int attach_recursive_mnt(struct mount *source_mnt,
list_del_init(&child->mnt_hash); list_del_init(&child->mnt_hash);
commit_tree(child); commit_tree(child);
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
return 0; return 0;
...@@ -1565,10 +1566,10 @@ static int do_change_type(struct path *path, int flag) ...@@ -1565,10 +1566,10 @@ static int do_change_type(struct path *path, int flag)
goto out_unlock; goto out_unlock;
} }
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL)) for (m = mnt; m; m = (recurse ? next_mnt(m, mnt) : NULL))
change_mnt_propagation(m, type); change_mnt_propagation(m, type);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
out_unlock: out_unlock:
up_write(&namespace_sem); up_write(&namespace_sem);
...@@ -1617,9 +1618,9 @@ static int do_loopback(struct path *path, char *old_name, ...@@ -1617,9 +1618,9 @@ static int do_loopback(struct path *path, char *old_name,
err = graft_tree(mnt, path); err = graft_tree(mnt, path);
if (err) { if (err) {
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
umount_tree(mnt, 0, &umount_list); umount_tree(mnt, 0, &umount_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
out2: out2:
unlock_mount(path); unlock_mount(path);
...@@ -1677,16 +1678,16 @@ static int do_remount(struct path *path, int flags, int mnt_flags, ...@@ -1677,16 +1678,16 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
else else
err = do_remount_sb(sb, flags, data, 0); err = do_remount_sb(sb, flags, data, 0);
if (!err) { if (!err) {
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK; mnt_flags |= mnt->mnt.mnt_flags & MNT_PROPAGATION_MASK;
mnt->mnt.mnt_flags = mnt_flags; mnt->mnt.mnt_flags = mnt_flags;
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
up_write(&sb->s_umount); up_write(&sb->s_umount);
if (!err) { if (!err) {
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
touch_mnt_namespace(mnt->mnt_ns); touch_mnt_namespace(mnt->mnt_ns);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
} }
return err; return err;
} }
...@@ -1893,9 +1894,9 @@ int finish_automount(struct vfsmount *m, struct path *path) ...@@ -1893,9 +1894,9 @@ int finish_automount(struct vfsmount *m, struct path *path)
/* remove m from any expiration list it may be on */ /* remove m from any expiration list it may be on */
if (!list_empty(&mnt->mnt_expire)) { if (!list_empty(&mnt->mnt_expire)) {
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_del_init(&mnt->mnt_expire); list_del_init(&mnt->mnt_expire);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
} }
mntput(m); mntput(m);
...@@ -1911,11 +1912,11 @@ int finish_automount(struct vfsmount *m, struct path *path) ...@@ -1911,11 +1912,11 @@ int finish_automount(struct vfsmount *m, struct path *path)
void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list) void mnt_set_expiry(struct vfsmount *mnt, struct list_head *expiry_list)
{ {
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list); list_add_tail(&real_mount(mnt)->mnt_expire, expiry_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
} }
EXPORT_SYMBOL(mnt_set_expiry); EXPORT_SYMBOL(mnt_set_expiry);
...@@ -1935,7 +1936,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) ...@@ -1935,7 +1936,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
return; return;
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
/* extract from the expiration list every vfsmount that matches the /* extract from the expiration list every vfsmount that matches the
* following criteria: * following criteria:
...@@ -1954,7 +1955,7 @@ void mark_mounts_for_expiry(struct list_head *mounts) ...@@ -1954,7 +1955,7 @@ void mark_mounts_for_expiry(struct list_head *mounts)
touch_mnt_namespace(mnt->mnt_ns); touch_mnt_namespace(mnt->mnt_ns);
umount_tree(mnt, 1, &umounts); umount_tree(mnt, 1, &umounts);
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umounts); release_mounts(&umounts);
...@@ -2218,9 +2219,9 @@ void mnt_make_shortterm(struct vfsmount *m) ...@@ -2218,9 +2219,9 @@ void mnt_make_shortterm(struct vfsmount *m)
struct mount *mnt = real_mount(m); struct mount *mnt = real_mount(m);
if (atomic_add_unless(&mnt->mnt_longterm, -1, 1)) if (atomic_add_unless(&mnt->mnt_longterm, -1, 1))
return; return;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
atomic_dec(&mnt->mnt_longterm); atomic_dec(&mnt->mnt_longterm);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
#endif #endif
} }
...@@ -2250,9 +2251,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns, ...@@ -2250,9 +2251,9 @@ static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
new_ns->root = new; new_ns->root = new;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
list_add_tail(&new_ns->list, &new->mnt_list); list_add_tail(&new_ns->list, &new->mnt_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
/* /*
* Second pass: switch the tsk->fs->* elements and mark new vfsmounts * Second pass: switch the tsk->fs->* elements and mark new vfsmounts
...@@ -2416,9 +2417,9 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry, ...@@ -2416,9 +2417,9 @@ bool is_path_reachable(struct mount *mnt, struct dentry *dentry,
int path_is_under(struct path *path1, struct path *path2) int path_is_under(struct path *path1, struct path *path2)
{ {
int res; int res;
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2); res = is_path_reachable(real_mount(path1->mnt), path1->dentry, path2);
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return res; return res;
} }
EXPORT_SYMBOL(path_is_under); EXPORT_SYMBOL(path_is_under);
...@@ -2505,7 +2506,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, ...@@ -2505,7 +2506,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
/* make sure we can reach put_old from new_root */ /* make sure we can reach put_old from new_root */
if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new)) if (!is_path_reachable(real_mount(old.mnt), old.dentry, &new))
goto out4; goto out4;
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
detach_mnt(new_mnt, &parent_path); detach_mnt(new_mnt, &parent_path);
detach_mnt(root_mnt, &root_parent); detach_mnt(root_mnt, &root_parent);
/* mount old root on put_old */ /* mount old root on put_old */
...@@ -2513,7 +2514,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root, ...@@ -2513,7 +2514,7 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
/* mount new_root on / */ /* mount new_root on / */
attach_mnt(new_mnt, &root_parent); attach_mnt(new_mnt, &root_parent);
touch_mnt_namespace(current->nsproxy->mnt_ns); touch_mnt_namespace(current->nsproxy->mnt_ns);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
chroot_fs_refs(&root, &new); chroot_fs_refs(&root, &new);
error = 0; error = 0;
out4: out4:
...@@ -2576,7 +2577,7 @@ void __init mnt_init(void) ...@@ -2576,7 +2577,7 @@ void __init mnt_init(void)
for (u = 0; u < HASH_SIZE; u++) for (u = 0; u < HASH_SIZE; u++)
INIT_LIST_HEAD(&mount_hashtable[u]); INIT_LIST_HEAD(&mount_hashtable[u]);
br_lock_init(vfsmount_lock); br_lock_init(&vfsmount_lock);
err = sysfs_init(); err = sysfs_init();
if (err) if (err)
...@@ -2596,9 +2597,9 @@ void put_mnt_ns(struct mnt_namespace *ns) ...@@ -2596,9 +2597,9 @@ void put_mnt_ns(struct mnt_namespace *ns)
if (!atomic_dec_and_test(&ns->count)) if (!atomic_dec_and_test(&ns->count))
return; return;
down_write(&namespace_sem); down_write(&namespace_sem);
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
umount_tree(ns->root, 0, &umount_list); umount_tree(ns->root, 0, &umount_list);
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
up_write(&namespace_sem); up_write(&namespace_sem);
release_mounts(&umount_list); release_mounts(&umount_list);
kfree(ns); kfree(ns);
......
...@@ -257,12 +257,12 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, ...@@ -257,12 +257,12 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry,
prev_src_mnt = child; prev_src_mnt = child;
} }
out: out:
br_write_lock(vfsmount_lock); br_write_lock(&vfsmount_lock);
while (!list_empty(&tmp_list)) { while (!list_empty(&tmp_list)) {
child = list_first_entry(&tmp_list, struct mount, mnt_hash); child = list_first_entry(&tmp_list, struct mount, mnt_hash);
umount_tree(child, 0, &umount_list); umount_tree(child, 0, &umount_list);
} }
br_write_unlock(vfsmount_lock); br_write_unlock(&vfsmount_lock);
release_mounts(&umount_list); release_mounts(&umount_list);
return ret; return ret;
} }
......
...@@ -23,12 +23,12 @@ static unsigned mounts_poll(struct file *file, poll_table *wait) ...@@ -23,12 +23,12 @@ static unsigned mounts_poll(struct file *file, poll_table *wait)
poll_wait(file, &p->ns->poll, wait); poll_wait(file, &p->ns->poll, wait);
br_read_lock(vfsmount_lock); br_read_lock(&vfsmount_lock);
if (p->m.poll_event != ns->event) { if (p->m.poll_event != ns->event) {
p->m.poll_event = ns->event; p->m.poll_event = ns->event;
res |= POLLERR | POLLPRI; res |= POLLERR | POLLPRI;
} }
br_read_unlock(vfsmount_lock); br_read_unlock(&vfsmount_lock);
return res; return res;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册