Commit baab81fa518ecfac597402b462631f5593926623
Committed by
Dave Kleikamp
1 parent
0afc2edfad
Exists in
master
and in
7 other branches
BKL-removal: Use unlocked_ioctl for jfs
Convert jfs_ioctl over to not use the BKL. The only potential race I could see was with two ioctls in parallel changing the flags and losing the updates. Use the i_mutex to protect against this. Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Showing 4 changed files with 13 additions and 7 deletions Side-by-side Diff
fs/jfs/file.c
fs/jfs/ioctl.c
... | ... | @@ -51,9 +51,9 @@ |
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | -int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, | |
55 | - unsigned long arg) | |
54 | +long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |
56 | 55 | { |
56 | + struct inode *inode = filp->f_dentry->d_inode; | |
57 | 57 | struct jfs_inode_info *jfs_inode = JFS_IP(inode); |
58 | 58 | unsigned int flags; |
59 | 59 | |
... | ... | @@ -82,6 +82,10 @@ |
82 | 82 | /* Is it quota file? Do not allow user to mess with it */ |
83 | 83 | if (IS_NOQUOTA(inode)) |
84 | 84 | return -EPERM; |
85 | + | |
86 | + /* Lock against other parallel changes of flags */ | |
87 | + mutex_lock(&inode->i_mutex); | |
88 | + | |
85 | 89 | jfs_get_inode_flags(jfs_inode); |
86 | 90 | oldflags = jfs_inode->mode2; |
87 | 91 | |
88 | 92 | |
... | ... | @@ -92,8 +96,10 @@ |
92 | 96 | if ((oldflags & JFS_IMMUTABLE_FL) || |
93 | 97 | ((flags ^ oldflags) & |
94 | 98 | (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) { |
95 | - if (!capable(CAP_LINUX_IMMUTABLE)) | |
99 | + if (!capable(CAP_LINUX_IMMUTABLE)) { | |
100 | + mutex_unlock(&inode->i_mutex); | |
96 | 101 | return -EPERM; |
102 | + } | |
97 | 103 | } |
98 | 104 | |
99 | 105 | flags = flags & JFS_FL_USER_MODIFIABLE; |
... | ... | @@ -101,6 +107,7 @@ |
101 | 107 | jfs_inode->mode2 = flags; |
102 | 108 | |
103 | 109 | jfs_set_inode_flags(inode); |
110 | + mutex_unlock(&inode->i_mutex); | |
104 | 111 | inode->i_ctime = CURRENT_TIME_SEC; |
105 | 112 | mark_inode_dirty(inode); |
106 | 113 | return 0; |
fs/jfs/jfs_inode.h
... | ... | @@ -22,8 +22,7 @@ |
22 | 22 | |
23 | 23 | extern struct inode *ialloc(struct inode *, umode_t); |
24 | 24 | extern int jfs_fsync(struct file *, struct dentry *, int); |
25 | -extern int jfs_ioctl(struct inode *, struct file *, | |
26 | - unsigned int, unsigned long); | |
25 | +extern long jfs_ioctl(struct file *, unsigned int, unsigned long); | |
27 | 26 | extern struct inode *jfs_iget(struct super_block *, unsigned long); |
28 | 27 | extern int jfs_commit_inode(struct inode *, int); |
29 | 28 | extern int jfs_write_inode(struct inode*, int); |
fs/jfs/namei.c