Skip to content

Commit

Permalink
brlocks/lglocks: API cleanups
Browse files Browse the repository at this point in the history
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: Andi Kleen <ak@linux.intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Andi Kleen authored and Al Viro committed May 30, 2012
1 parent eea62f8 commit 962830d
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 95 deletions.
4 changes: 2 additions & 2 deletions fs/dcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,7 @@ static int prepend_path(const struct path *path,
bool slash = false;
int error = 0;

br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
while (dentry != root->dentry || vfsmnt != root->mnt) {
struct dentry * parent;

Expand Down Expand Up @@ -2606,7 +2606,7 @@ static int prepend_path(const struct path *path,
error = prepend(buffer, buflen, "/", 1);

out:
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
return error;

global_root:
Expand Down
16 changes: 8 additions & 8 deletions fs/file_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
lg_local_lock(files_lglock);
lg_local_lock(&files_lglock);
__file_sb_list_add(file, sb);
lg_local_unlock(files_lglock);
lg_local_unlock(&files_lglock);
}

/**
Expand All @@ -435,9 +435,9 @@ void file_sb_list_add(struct file *file, struct super_block *sb)
void file_sb_list_del(struct file *file)
{
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);
lg_local_unlock_cpu(files_lglock, file_list_cpu(file));
lg_local_unlock_cpu(&files_lglock, file_list_cpu(file));
}
}

Expand Down Expand Up @@ -484,7 +484,7 @@ void mark_files_ro(struct super_block *sb)
struct file *f;

retry:
lg_global_lock(files_lglock);
lg_global_lock(&files_lglock);
do_file_list_for_each_entry(sb, f) {
struct vfsmount *mnt;
if (!S_ISREG(f->f_path.dentry->d_inode->i_mode))
Expand All @@ -501,12 +501,12 @@ void mark_files_ro(struct super_block *sb)
file_release_write(f);
mnt = mntget(f->f_path.mnt);
/* This can sleep, so we can't hold the spinlock. */
lg_global_unlock(files_lglock);
lg_global_unlock(&files_lglock);
mnt_drop_write(mnt);
mntput(mnt);
goto retry;
} while_file_list_for_each_entry;
lg_global_unlock(files_lglock);
lg_global_unlock(&files_lglock);
}

void __init files_init(unsigned long mempages)
Expand All @@ -524,6 +524,6 @@ void __init files_init(unsigned long mempages)
n = (mempages * (PAGE_SIZE / 1024)) / 10;
files_stat.max_files = max_t(unsigned long, n, NR_FILE);
files_defer_init();
lg_lock_init(files_lglock);
lg_lock_init(&files_lglock, "files_lglock");
percpu_counter_init(&nr_files, 0);
}
24 changes: 12 additions & 12 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ static int unlazy_walk(struct nameidata *nd, struct dentry *dentry)
mntget(nd->path.mnt);

rcu_read_unlock();
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
nd->flags &= ~LOOKUP_RCU;
return 0;

Expand Down Expand Up @@ -507,14 +507,14 @@ static int complete_walk(struct nameidata *nd)
if (unlikely(!__d_rcu_to_refcount(dentry, nd->seq))) {
spin_unlock(&dentry->d_lock);
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
return -ECHILD;
}
BUG_ON(nd->inode != dentry->d_inode);
spin_unlock(&dentry->d_lock);
mntget(nd->path.mnt);
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
}

if (likely(!(nd->flags & LOOKUP_JUMPED)))
Expand Down Expand Up @@ -681,15 +681,15 @@ int follow_up(struct path *path)
struct mount *parent;
struct dentry *mountpoint;

br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
parent = mnt->mnt_parent;
if (&parent->mnt == path->mnt) {
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
return 0;
}
mntget(&parent->mnt);
mountpoint = dget(mnt->mnt_mountpoint);
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
dput(path->dentry);
path->dentry = mountpoint;
mntput(path->mnt);
Expand Down Expand Up @@ -947,7 +947,7 @@ static int follow_dotdot_rcu(struct nameidata *nd)
if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
return -ECHILD;
}

Expand Down Expand Up @@ -1265,7 +1265,7 @@ static void terminate_walk(struct nameidata *nd)
if (!(nd->flags & LOOKUP_ROOT))
nd->root.mnt = NULL;
rcu_read_unlock();
br_read_unlock(vfsmount_lock);
br_read_unlock(&vfsmount_lock);
}
}

Expand Down Expand Up @@ -1620,7 +1620,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
nd->path = nd->root;
nd->inode = inode;
if (flags & LOOKUP_RCU) {
br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
rcu_read_lock();
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
} else {
Expand All @@ -1633,7 +1633,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,

if (*name=='/') {
if (flags & LOOKUP_RCU) {
br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
rcu_read_lock();
set_root_rcu(nd);
} else {
Expand All @@ -1646,7 +1646,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
struct fs_struct *fs = current->fs;
unsigned seq;

br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
rcu_read_lock();

do {
Expand Down Expand Up @@ -1682,7 +1682,7 @@ static int path_init(int dfd, const char *name, unsigned int flags,
if (fput_needed)
*fp = file;
nd->seq = __read_seqcount_begin(&nd->path.dentry->d_seq);
br_read_lock(vfsmount_lock);
br_read_lock(&vfsmount_lock);
rcu_read_lock();
} else {
path_get(&file->f_path);
Expand Down
Loading

0 comments on commit 962830d

Please sign in to comment.