diff options
author | Arnd Bergmann <arnd@arndb.de> | 2011-01-24 10:14:12 +0100 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2011-03-02 22:27:48 +0100 |
commit | 788257d6101d986ac8f2741aaa35974af47f574c (patch) | |
tree | 332d877e09d8b5de6a4bdfba8111dd04e84a722b /fs/ufs/namei.c | |
parent | 9a311b96c3065f362e3348cb5d7af1a57ca6bff9 (diff) | |
download | linux-stable-788257d6101d986ac8f2741aaa35974af47f574c.tar.gz linux-stable-788257d6101d986ac8f2741aaa35974af47f574c.tar.bz2 linux-stable-788257d6101d986ac8f2741aaa35974af47f574c.zip |
ufs: remove the BKL
This introduces a new per-superblock mutex in UFS to replace
the big kernel lock. I have been careful to avoid nested
calls to lock_ufs and to get the lock order right with
respect to other mutexes, in particular lock_super.
I did not make any attempt to prove that the big kernel
lock is not needed in a particular place in the code,
which is very possible.
The mutex has a significant performance impact, so it is only
used on SMP or PREEMPT configurations.
As Nick Piggin noticed, any allocation inside of the lock
may end up deadlocking when we get to ufs_getfrag_block
in the reclaim task, so we now use GFP_NOFS.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Nick Bowler <nbowler@elliptictech.com>
Cc: Evgeniy Dushistov <dushistov@mail.ru>
Cc: Nick Piggin <npiggin@gmail.com>
Diffstat (limited to 'fs/ufs/namei.c')
-rw-r--r-- | fs/ufs/namei.c | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c index 12f39b9e4437..205030a707fe 100644 --- a/fs/ufs/namei.c +++ b/fs/ufs/namei.c @@ -29,7 +29,6 @@ #include <linux/time.h> #include <linux/fs.h> -#include <linux/smp_lock.h> #include "ufs_fs.h" #include "ufs.h" @@ -55,16 +54,16 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, stru if (dentry->d_name.len > UFS_MAXNAMLEN) return ERR_PTR(-ENAMETOOLONG); - lock_kernel(); + lock_ufs(dir->i_sb); ino = ufs_inode_by_name(dir, &dentry->d_name); if (ino) { inode = ufs_iget(dir->i_sb, ino); if (IS_ERR(inode)) { - unlock_kernel(); + unlock_ufs(dir->i_sb); return ERR_CAST(inode); } } - unlock_kernel(); + unlock_ufs(dir->i_sb); d_add(dentry, inode); return NULL; } @@ -93,9 +92,9 @@ static int ufs_create (struct inode * dir, struct dentry * dentry, int mode, inode->i_fop = &ufs_file_operations; inode->i_mapping->a_ops = &ufs_aops; mark_inode_dirty(inode); - lock_kernel(); + lock_ufs(dir->i_sb); err = ufs_add_nondir(dentry, inode); - unlock_kernel(); + unlock_ufs(dir->i_sb); } UFSD("END: err=%d\n", err); return err; @@ -115,9 +114,9 @@ static int ufs_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t init_special_inode(inode, mode, rdev); ufs_set_inode_dev(inode->i_sb, UFS_I(inode), rdev); mark_inode_dirty(inode); - lock_kernel(); + lock_ufs(dir->i_sb); err = ufs_add_nondir(dentry, inode); - unlock_kernel(); + unlock_ufs(dir->i_sb); } return err; } @@ -133,7 +132,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, if (l > sb->s_blocksize) goto out_notlocked; - lock_kernel(); + lock_ufs(dir->i_sb); inode = ufs_new_inode(dir, S_IFLNK | S_IRWXUGO); err = PTR_ERR(inode); if (IS_ERR(inode)) @@ -156,7 +155,7 @@ static int ufs_symlink (struct inode * dir, struct dentry * dentry, err = ufs_add_nondir(dentry, inode); out: - unlock_kernel(); + unlock_ufs(dir->i_sb); out_notlocked: return err; @@ -172,9 +171,9 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir, struct inode *inode = old_dentry->d_inode; int error; - lock_kernel(); + lock_ufs(dir->i_sb); if (inode->i_nlink >= UFS_LINK_MAX) { - unlock_kernel(); + unlock_ufs(dir->i_sb); return -EMLINK; } @@ -183,7 +182,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir, ihold(inode); error = ufs_add_nondir(dentry, inode); - unlock_kernel(); + unlock_ufs(dir->i_sb); return error; } @@ -195,7 +194,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode) if (dir->i_nlink >= UFS_LINK_MAX) goto out; - lock_kernel(); + lock_ufs(dir->i_sb); inode_inc_link_count(dir); inode = ufs_new_inode(dir, S_IFDIR|mode); @@ -216,7 +215,7 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, int mode) err = ufs_add_link(dentry, inode); if (err) goto out_fail; - unlock_kernel(); + unlock_ufs(dir->i_sb); d_instantiate(dentry, inode); out: @@ -228,7 +227,7 @@ out_fail: iput (inode); out_dir: inode_dec_link_count(dir); - unlock_kernel(); + unlock_ufs(dir->i_sb); goto out; } @@ -259,7 +258,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry) struct inode * inode = dentry->d_inode; int err= -ENOTEMPTY; - lock_kernel(); + lock_ufs(dir->i_sb); if (ufs_empty_dir (inode)) { err = ufs_unlink(dir, dentry); if (!err) { @@ -268,7 +267,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry) inode_dec_link_count(dir); } } - unlock_kernel(); + unlock_ufs(dir->i_sb); return err; } |