Skip to content

Commit 9db9f9e

Browse files
Alessio Igor Boganijankara
authored andcommitted
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: Alessio Igor Bogani <abogani@texware.it> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 7db09be commit 9db9f9e

5 files changed

Lines changed: 1 addition & 47 deletions

File tree

‎fs/udf/dir.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include <linux/errno.h>
3131
#include <linux/mm.h>
3232
#include <linux/slab.h>
33-
#include <linux/smp_lock.h>
3433
#include <linux/buffer_head.h>
3534

3635
#include "udf_i.h"
@@ -190,18 +189,14 @@ static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
190189
struct inode *dir = filp->f_path.dentry->d_inode;
191190
int result;
192191

193-
lock_kernel();
194-
195192
if (filp->f_pos == 0) {
196193
if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
197-
unlock_kernel();
198194
return 0;
199195
}
200196
filp->f_pos++;
201197
}
202198

203199
result = do_udf_readdir(dir, filp, filldir, dirent);
204-
unlock_kernel();
205200
return result;
206201
}
207202

‎fs/udf/file.c‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
#include <linux/string.h> /* memset */
3333
#include <linux/capability.h>
3434
#include <linux/errno.h>
35-
#include <linux/smp_lock.h>
3635
#include <linux/pagemap.h>
3736
#include <linux/buffer_head.h>
3837
#include <linux/aio.h>
@@ -149,8 +148,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
149148
long old_block, new_block;
150149
int result = -EINVAL;
151150

152-
lock_kernel();
153-
154151
if (file_permission(filp, MAY_READ) != 0) {
155152
udf_debug("no permission to access inode %lu\n", inode->i_ino);
156153
result = -EPERM;
@@ -196,7 +193,6 @@ long udf_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
196193
}
197194

198195
out:
199-
unlock_kernel();
200196
return result;
201197
}
202198

‎fs/udf/inode.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

3232
#include "udfdecl.h"
3333
#include <linux/mm.h>
34-
#include <linux/smp_lock.h>
3534
#include <linux/module.h>
3635
#include <linux/pagemap.h>
3736
#include <linux/buffer_head.h>
@@ -96,9 +95,7 @@ void udf_evict_inode(struct inode *inode)
9695
kfree(iinfo->i_ext.i_data);
9796
iinfo->i_ext.i_data = NULL;
9897
if (want_delete) {
99-
lock_kernel();
10098
udf_free_inode(inode);
101-
unlock_kernel();
10299
}
103100
}
104101

‎fs/udf/namei.c‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <linux/errno.h>
2828
#include <linux/mm.h>
2929
#include <linux/slab.h>
30-
#include <linux/smp_lock.h>
3130
#include <linux/buffer_head.h>
3231
#include <linux/sched.h>
3332
#include <linux/crc-itu-t.h>
@@ -263,7 +262,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
263262
if (dentry->d_name.len > UDF_NAME_LEN - 2)
264263
return ERR_PTR(-ENAMETOOLONG);
265264

266-
lock_kernel();
267265
#ifdef UDF_RECOVERY
268266
/* temporary shorthand for specifying files by inode number */
269267
if (!strncmp(dentry->d_name.name, ".B=", 3)) {
@@ -275,7 +273,6 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
275273
};
276274
inode = udf_iget(dir->i_sb, lb);
277275
if (!inode) {
278-
unlock_kernel();
279276
return ERR_PTR(-EACCES);
280277
}
281278
} else
@@ -291,11 +288,9 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
291288
loc = lelb_to_cpu(cfi.icb.extLocation);
292289
inode = udf_iget(dir->i_sb, &loc);
293290
if (!inode) {
294-
unlock_kernel();
295291
return ERR_PTR(-EACCES);
296292
}
297293
}
298-
unlock_kernel();
299294

300295
return d_splice_alias(inode, dentry);
301296
}
@@ -562,10 +557,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
562557
int err;
563558
struct udf_inode_info *iinfo;
564559

565-
lock_kernel();
566560
inode = udf_new_inode(dir, mode, &err);
567561
if (!inode) {
568-
unlock_kernel();
569562
return err;
570563
}
571564

@@ -583,7 +576,6 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
583576
inode->i_nlink--;
584577
mark_inode_dirty(inode);
585578
iput(inode);
586-
unlock_kernel();
587579
return err;
588580
}
589581
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,
596588
if (fibh.sbh != fibh.ebh)
597589
brelse(fibh.ebh);
598590
brelse(fibh.sbh);
599-
unlock_kernel();
600591
d_instantiate(dentry, inode);
601592

602593
return 0;
@@ -614,7 +605,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
614605
if (!old_valid_dev(rdev))
615606
return -EINVAL;
616607

617-
lock_kernel();
618608
err = -EIO;
619609
inode = udf_new_inode(dir, mode, &err);
620610
if (!inode)
@@ -627,7 +617,6 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
627617
inode->i_nlink--;
628618
mark_inode_dirty(inode);
629619
iput(inode);
630-
unlock_kernel();
631620
return err;
632621
}
633622
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,
646635
err = 0;
647636

648637
out:
649-
unlock_kernel();
650638
return err;
651639
}
652640

@@ -659,7 +647,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
659647
struct udf_inode_info *dinfo = UDF_I(dir);
660648
struct udf_inode_info *iinfo;
661649

662-
lock_kernel();
663650
err = -EMLINK;
664651
if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1)
665652
goto out;
@@ -712,7 +699,6 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
712699
err = 0;
713700

714701
out:
715-
unlock_kernel();
716702
return err;
717703
}
718704

@@ -794,7 +780,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
794780
struct kernel_lb_addr tloc;
795781

796782
retval = -ENOENT;
797-
lock_kernel();
798783
fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
799784
if (!fi)
800785
goto out;
@@ -826,7 +811,6 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
826811
brelse(fibh.sbh);
827812

828813
out:
829-
unlock_kernel();
830814
return retval;
831815
}
832816

@@ -840,7 +824,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
840824
struct kernel_lb_addr tloc;
841825

842826
retval = -ENOENT;
843-
lock_kernel();
844827
fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
845828
if (!fi)
846829
goto out;
@@ -870,7 +853,6 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
870853
brelse(fibh.sbh);
871854

872855
out:
873-
unlock_kernel();
874856
return retval;
875857
}
876858

@@ -1050,15 +1032,12 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
10501032
struct fileIdentDesc cfi, *fi;
10511033
int err;
10521034

1053-
lock_kernel();
10541035
if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) {
1055-
unlock_kernel();
10561036
return -EMLINK;
10571037
}
10581038

10591039
fi = udf_add_entry(dir, dentry, &fibh, &cfi, &err);
10601040
if (!fi) {
1061-
unlock_kernel();
10621041
return err;
10631042
}
10641043
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,
10791058
mark_inode_dirty(inode);
10801059
ihold(inode);
10811060
d_instantiate(dentry, inode);
1082-
unlock_kernel();
10831061

10841062
return 0;
10851063
}
@@ -1100,7 +1078,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
11001078
struct kernel_lb_addr tloc;
11011079
struct udf_inode_info *old_iinfo = UDF_I(old_inode);
11021080

1103-
lock_kernel();
11041081
ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
11051082
if (ofi) {
11061083
if (ofibh.sbh != ofibh.ebh)
@@ -1224,7 +1201,6 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
12241201
brelse(nfibh.ebh);
12251202
brelse(nfibh.sbh);
12261203
}
1227-
unlock_kernel();
12281204

12291205
return retval;
12301206
}
@@ -1237,7 +1213,6 @@ static struct dentry *udf_get_parent(struct dentry *child)
12371213
struct fileIdentDesc cfi;
12381214
struct udf_fileident_bh fibh;
12391215

1240-
lock_kernel();
12411216
if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi))
12421217
goto out_unlock;
12431218

@@ -1249,11 +1224,9 @@ static struct dentry *udf_get_parent(struct dentry *child)
12491224
inode = udf_iget(child->d_inode->i_sb, &tloc);
12501225
if (!inode)
12511226
goto out_unlock;
1252-
unlock_kernel();
12531227

12541228
return d_obtain_alias(inode);
12551229
out_unlock:
1256-
unlock_kernel();
12571230
return ERR_PTR(-EACCES);
12581231
}
12591232

‎fs/udf/super.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include <linux/stat.h>
4949
#include <linux/cdrom.h>
5050
#include <linux/nls.h>
51-
#include <linux/smp_lock.h>
5251
#include <linux/buffer_head.h>
5352
#include <linux/vfs.h>
5453
#include <linux/vmalloc.h>
@@ -1911,8 +1910,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
19111910
struct kernel_lb_addr rootdir, fileset;
19121911
struct udf_sb_info *sbi;
19131912

1914-
lock_kernel();
1915-
19161913
uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT);
19171914
uopt.uid = -1;
19181915
uopt.gid = -1;
@@ -1921,10 +1918,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
19211918
uopt.dmode = UDF_INVALID_MODE;
19221919

19231920
sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1924-
if (!sbi) {
1925-
unlock_kernel();
1921+
if (!sbi)
19261922
return -ENOMEM;
1927-
}
19281923

19291924
sb->s_fs_info = sbi;
19301925

@@ -2071,7 +2066,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
20712066
goto error_out;
20722067
}
20732068
sb->s_maxbytes = MAX_LFS_FILESIZE;
2074-
unlock_kernel();
20752069
return 0;
20762070

20772071
error_out:
@@ -2092,7 +2086,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
20922086
kfree(sbi);
20932087
sb->s_fs_info = NULL;
20942088

2095-
unlock_kernel();
20962089
return -EINVAL;
20972090
}
20982091

0 commit comments

Comments
 (0)