Commit 9db9f9e3 authored by Alessio Igor Bogani's avatar Alessio Igor Bogani Committed by Jan Kara

udf: Remove unnecessary bkl usages

The udf_readdir(), udf_lookup(), udf_create(), udf_mknod(), udf_mkdir(),
udf_rmdir(), udf_link(), udf_get_parent() and udf_unlink() seems already
adequately protected by i_mutex held by VFS invoking calls. The udf_rename()
instead should be already protected by lock_rename again by VFS. The
udf_ioctl(), udf_fill_super() and udf_evict_inode() don't requires any further
protection.

This work was supported by a hardware donation from the CE Linux Forum.
Signed-off-by: default avatarAlessio Igor Bogani <abogani@texware.it>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 7db09be6
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include "udf_i.h" #include "udf_i.h"
...@@ -190,18 +189,14 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -190,18 +189,14 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
struct inode *dir = filp->f_path.dentry->d_inode; struct inode *dir = filp->f_path.dentry->d_inode;
int result; int result;
lock_kernel();
if (filp->f_pos == 0) { if (filp->f_pos == 0) {
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) { if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
unlock_kernel();
return 0; return 0;
} }
filp->f_pos++; filp->f_pos++;
} }
result = do_udf_readdir(dir, filp, filldir, dirent); result = do_udf_readdir(dir, filp, filldir, dirent);
unlock_kernel();
return result; return result;
} }
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <linux/string.h> /* memset */ #include <linux/string.h> /* memset */
#include <linux/capability.h> #include <linux/capability.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/smp_lock.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/aio.h> #include <linux/aio.h>
...@@ -149,8 +148,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -149,8 +148,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
long old_block, new_block; long old_block, new_block;
int result = -EINVAL; int result = -EINVAL;
lock_kernel();
if (file_permission(filp, MAY_READ) != 0) { if (file_permission(filp, MAY_READ) != 0) {
udf_debug("no permission to access inode %lu\n", inode->i_ino); udf_debug("no permission to access inode %lu\n", inode->i_ino);
result = -EPERM; result = -EPERM;
...@@ -196,7 +193,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -196,7 +193,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
} }
out: out:
unlock_kernel();
return result; return result;
} }
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "udfdecl.h" #include "udfdecl.h"
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/smp_lock.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
...@@ -96,9 +95,7 @@ void udf_evict_inode(struct inode *inode) ...@@ -96,9 +95,7 @@ void udf_evict_inode(struct inode *inode)
kfree(iinfo->i_ext.i_data); kfree(iinfo->i_ext.i_data);
iinfo->i_ext.i_data = NULL; iinfo->i_ext.i_data = NULL;
if (want_delete) { if (want_delete) {
lock_kernel();
udf_free_inode(inode); udf_free_inode(inode);
unlock_kernel();
} }
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/smp_lock.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/crc-itu-t.h> #include <linux/crc-itu-t.h>
...@@ -263,7 +262,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, ...@@ -263,7 +262,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
if (dentry->d_name.len > UDF_NAME_LEN - 2) if (dentry->d_name.len > UDF_NAME_LEN - 2)
return ERR_PTR(-ENAMETOOLONG); return ERR_PTR(-ENAMETOOLONG);
lock_kernel();
#ifdef UDF_RECOVERY #ifdef UDF_RECOVERY
/* temporary shorthand for specifying files by inode number */ /* temporary shorthand for specifying files by inode number */
if (!strncmp(dentry->d_name.name, ".B=", 3)) { if (!strncmp(dentry->d_name.name, ".B=", 3)) {
...@@ -275,7 +273,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, ...@@ -275,7 +273,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
}; };
inode = udf_iget(dir->i_sb, lb); inode = udf_iget(dir->i_sb, lb);
if (!inode) { if (!inode) {
unlock_kernel();
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
} else } else
...@@ -291,11 +288,9 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, ...@@ -291,11 +288,9 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
loc = lelb_to_cpu(cfi.icb.extLocation); loc = lelb_to_cpu(cfi.icb.extLocation);
inode = udf_iget(dir->i_sb, &loc); inode = udf_iget(dir->i_sb, &loc);
if (!inode) { if (!inode) {
unlock_kernel();
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
} }
unlock_kernel();
return d_splice_alias(inode, dentry); return d_splice_alias(inode, dentry);
} }
...@@ -562,10 +557,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -562,10 +557,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
int err; int err;
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
lock_kernel();
inode = udf_new_inode(dir, mode, &err); inode = udf_new_inode(dir, mode, &err);
if (!inode) { if (!inode) {
unlock_kernel();
return err; return err;
} }
...@@ -583,7 +576,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -583,7 +576,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
inode->i_nlink--; inode->i_nlink--;
mark_inode_dirty(inode); mark_inode_dirty(inode);
iput(inode); iput(inode);
unlock_kernel();
return err; return err;
} }
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
...@@ -596,7 +588,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode, ...@@ -596,7 +588,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
if (fibh.sbh != fibh.ebh) if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh); brelse(fibh.ebh);
brelse(fibh.sbh); brelse(fibh.sbh);
unlock_kernel();
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
return 0; return 0;
...@@ -614,7 +605,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, ...@@ -614,7 +605,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
if (!old_valid_dev(rdev)) if (!old_valid_dev(rdev))
return -EINVAL; return -EINVAL;
lock_kernel();
err = -EIO; err = -EIO;
inode = udf_new_inode(dir, mode, &err); inode = udf_new_inode(dir, mode, &err);
if (!inode) if (!inode)
...@@ -627,7 +617,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, ...@@ -627,7 +617,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
inode->i_nlink--; inode->i_nlink--;
mark_inode_dirty(inode); mark_inode_dirty(inode);
iput(inode); iput(inode);
unlock_kernel();
return err; return err;
} }
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
...@@ -646,7 +635,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode, ...@@ -646,7 +635,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
err = 0; err = 0;
out: out:
unlock_kernel();
return err; return err;
} }
...@@ -659,7 +647,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -659,7 +647,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
struct udf_inode_info *dinfo = UDF_I(dir); struct udf_inode_info *dinfo = UDF_I(dir);
struct udf_inode_info *iinfo; struct udf_inode_info *iinfo;
lock_kernel();
err = -EMLINK; err = -EMLINK;
if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1) if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1)
goto out; goto out;
...@@ -712,7 +699,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode) ...@@ -712,7 +699,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
err = 0; err = 0;
out: out:
unlock_kernel();
return err; return err;
} }
...@@ -794,7 +780,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -794,7 +780,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
struct kernel_lb_addr tloc; struct kernel_lb_addr tloc;
retval = -ENOENT; retval = -ENOENT;
lock_kernel();
fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
if (!fi) if (!fi)
goto out; goto out;
...@@ -826,7 +811,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -826,7 +811,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
brelse(fibh.sbh); brelse(fibh.sbh);
out: out:
unlock_kernel();
return retval; return retval;
} }
...@@ -840,7 +824,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry) ...@@ -840,7 +824,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
struct kernel_lb_addr tloc; struct kernel_lb_addr tloc;
retval = -ENOENT; retval = -ENOENT;
lock_kernel();
fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
if (!fi) if (!fi)
goto out; goto out;
...@@ -870,7 +853,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry) ...@@ -870,7 +853,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
brelse(fibh.sbh); brelse(fibh.sbh);
out: out:
unlock_kernel();
return retval; return retval;
} }
...@@ -1050,15 +1032,12 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1050,15 +1032,12 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
struct fileIdentDesc cfi, *fi; struct fileIdentDesc cfi, *fi;
int err; int err;
lock_kernel();
if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) {
unlock_kernel();
return -EMLINK; return -EMLINK;
} }
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err); fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
if (!fi) { if (!fi) {
unlock_kernel();
return err; return err;
} }
cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
...@@ -1079,7 +1058,6 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1079,7 +1058,6 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
mark_inode_dirty(inode); mark_inode_dirty(inode);
ihold(inode); ihold(inode);
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
unlock_kernel();
return 0; return 0;
} }
...@@ -1100,7 +1078,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1100,7 +1078,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
struct kernel_lb_addr tloc; struct kernel_lb_addr tloc;
struct udf_inode_info *old_iinfo = UDF_I(old_inode); struct udf_inode_info *old_iinfo = UDF_I(old_inode);
lock_kernel();
ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi); ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
if (ofi) { if (ofi) {
if (ofibh.sbh != ofibh.ebh) if (ofibh.sbh != ofibh.ebh)
...@@ -1224,7 +1201,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1224,7 +1201,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
brelse(nfibh.ebh); brelse(nfibh.ebh);
brelse(nfibh.sbh); brelse(nfibh.sbh);
} }
unlock_kernel();
return retval; return retval;
} }
...@@ -1237,7 +1213,6 @@ static struct dentry *udf_get_parent(struct dentry *child) ...@@ -1237,7 +1213,6 @@ static struct dentry *udf_get_parent(struct dentry *child)
struct fileIdentDesc cfi; struct fileIdentDesc cfi;
struct udf_fileident_bh fibh; struct udf_fileident_bh fibh;
lock_kernel();
if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi)) if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi))
goto out_unlock; goto out_unlock;
...@@ -1249,11 +1224,9 @@ static struct dentry *udf_get_parent(struct dentry *child) ...@@ -1249,11 +1224,9 @@ static struct dentry *udf_get_parent(struct dentry *child)
inode = udf_iget(child->d_inode->i_sb, &tloc); inode = udf_iget(child->d_inode->i_sb, &tloc);
if (!inode) if (!inode)
goto out_unlock; goto out_unlock;
unlock_kernel();
return d_obtain_alias(inode); return d_obtain_alias(inode);
out_unlock: out_unlock:
unlock_kernel();
return ERR_PTR(-EACCES); return ERR_PTR(-EACCES);
} }
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/cdrom.h> #include <linux/cdrom.h>
#include <linux/nls.h> #include <linux/nls.h>
#include <linux/smp_lock.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -1911,8 +1910,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -1911,8 +1910,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
struct kernel_lb_addr rootdir, fileset; struct kernel_lb_addr rootdir, fileset;
struct udf_sb_info *sbi; struct udf_sb_info *sbi;
lock_kernel();
uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
uopt.uid = -1; uopt.uid = -1;
uopt.gid = -1; uopt.gid = -1;
...@@ -1921,10 +1918,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -1921,10 +1918,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
uopt.dmode = UDF_INVALID_MODE; uopt.dmode = UDF_INVALID_MODE;
sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
if (!sbi) { if (!sbi)
unlock_kernel();
return -ENOMEM; return -ENOMEM;
}
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
...@@ -2071,7 +2066,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -2071,7 +2066,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
goto error_out; goto error_out;
} }
sb->s_maxbytes = MAX_LFS_FILESIZE; sb->s_maxbytes = MAX_LFS_FILESIZE;
unlock_kernel();
return 0; return 0;
error_out: error_out:
...@@ -2092,7 +2086,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ...@@ -2092,7 +2086,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
kfree(sbi); kfree(sbi);
sb->s_fs_info = NULL; sb->s_fs_info = NULL;
unlock_kernel();
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment