Clean up brlocks/lglocks v2
PATCH 1/1 Clean up brlocks/lglocks v2
From: Andi Kleen <[email protected]>
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.
Since there are at least two users it makes sense to share this code in a library. This is also easier maintainable than a macro forest.
This will also make it later possible to dynamically allocate lglocks and also use them in modules (this would both still need some additional, but now straightforward, code)
In general the users now 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.
v2: Do a nightmare merge with the latest tree
--- fs/dcache.c | 4 +- fs/file_table.c | 17 ++--- fs/internal.h | 3 +- fs/namei.c | 24 +++--- fs/namespace.c | 140 ++++++++++++++++++------------------ fs/pnode.c | 4 +- fs/proc_namespace.c | 4 +- include/linux/lglock.h | 187 +++++++++--------------------------------------- kernel/Makefile | 2 +- kernel/lglock.c | 136 +++++++++++++++++++++++++++++++++++ 10 files changed, 268 insertions(+), 253 deletions(-) create mode 100644 kernel/lglock.c
fs/dcache.c +2 -2
@@ -2459,7 +2459,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;
@@ -2490,7 +2490,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:
fs/file_table.c +8 -9
@@ -34,7 +34,6 @@ struct files_stat_struct files_stat = { .max_files = NR_FILE }; -DECLARE_LGLOCK (files_lglock);DEFINE_LGLOCK (files_lglock);/* SLAB cache for file structures */
@@ -422,9 +421,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); }/**
@@ -437,9 +436,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)); } }
@@ -486,7 +485,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))
@@ -503,12 +502,12 @@ retry: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)
@@ -526,6 +525,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 ); }
fs/internal.h +1 -2
@@ -56,8 +56,7 @@ extern int sb_prepare_remount_readonly(struct super_block *);extern void __init mnt_init (void ); -DECLARE_BRLOCK (vfsmount_lock); - +extern struct lglock vfsmount_lock;/* * fs_struct.c
fs/namei.c +12 -12
@@ -464,7 +464,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 ;
@@ -522,14 +522,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 )))
@@ -696,15 +696,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);
@@ -962,7 +962,7 @@ failed:if (!(nd->flags &LOOKUP_ROOT )) nd->root.mnt =NULL ;rcu_read_unlock (); -br_read_unlock (vfsmount_lock); +br_read_unlock (&vfsmount_lock);return -ECHILD ; }
@@ -1256,7 +1256,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); } }
@@ -1490,7 +1490,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 {
@@ -1503,7 +1503,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 {
@@ -1516,7 +1516,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 {
@@ -1552,7 +1552,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);
fs/namespace.c +70 -70
424 lines not on this page · raw message
fs/pnode.c +2 -2
@@ -257,12 +257,12 @@ int propagate_mnt(struct mount *dest_mnt, struct dentry *dest_dentry, prev_src_mnt = child; } out: -br_write_lock (vfsmount_lock); +br_write_lock (&vfsmount_lock);while (!list_empty (&tmp_list)) { child = list_first_entry(&tmp_list, struct mount, mnt_hash);umount_tree (child,0 , &umount_list); } -br_write_unlock (vfsmount_lock); +br_write_unlock (&vfsmount_lock);release_mounts (&umount_list);return ret; }
fs/proc_namespace.c +2 -2
@@ -23,12 +23,12 @@ static unsigned mounts_poll(struct file *file, poll_table *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) { p->m.poll_event = ns->event; res |=POLLERR |POLLPRI ; } -br_read_unlock (vfsmount_lock); +br_read_unlock (&vfsmount_lock);return res; }
include/linux/lglock.h +34 -153
204 lines not on this page · raw message
kernel/Makefile +1 -1
@@ -10,7 +10,7 @@ obj-y = fork.o exec_domain.o panic.o printk.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o nsproxy.o srcu.o semaphore.o \ notifier.o ksysfs.o cred.o \ - async.o range.o groups.o + async.o range.o groups.o lglock.o ifdef CONFIG_FUNCTION_TRACER # Do not trace debug files and internal ftrace files
kernel/lglock.c new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
1.7.7.4