Commit baab81fa authored by Andi Kleen's avatar Andi Kleen Committed by Dave Kleikamp

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: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarDave Kleikamp <shaggy@linux.vnet.ibm.com>
parent 0afc2edf
...@@ -112,5 +112,5 @@ const struct file_operations jfs_file_operations = { ...@@ -112,5 +112,5 @@ const struct file_operations jfs_file_operations = {
.splice_write = generic_file_splice_write, .splice_write = generic_file_splice_write,
.fsync = jfs_fsync, .fsync = jfs_fsync,
.release = jfs_release, .release = jfs_release,
.ioctl = jfs_ioctl, .unlocked_ioctl = jfs_ioctl,
}; };
...@@ -51,9 +51,9 @@ static long jfs_map_ext2(unsigned long flags, int from) ...@@ -51,9 +51,9 @@ static long jfs_map_ext2(unsigned long flags, int from)
} }
int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
unsigned long arg)
{ {
struct inode *inode = filp->f_dentry->d_inode;
struct jfs_inode_info *jfs_inode = JFS_IP(inode); struct jfs_inode_info *jfs_inode = JFS_IP(inode);
unsigned int flags; unsigned int flags;
...@@ -82,6 +82,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -82,6 +82,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
/* Is it quota file? Do not allow user to mess with it */ /* Is it quota file? Do not allow user to mess with it */
if (IS_NOQUOTA(inode)) if (IS_NOQUOTA(inode))
return -EPERM; return -EPERM;
/* Lock against other parallel changes of flags */
mutex_lock(&inode->i_mutex);
jfs_get_inode_flags(jfs_inode); jfs_get_inode_flags(jfs_inode);
oldflags = jfs_inode->mode2; oldflags = jfs_inode->mode2;
...@@ -92,8 +96,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -92,8 +96,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
if ((oldflags & JFS_IMMUTABLE_FL) || if ((oldflags & JFS_IMMUTABLE_FL) ||
((flags ^ oldflags) & ((flags ^ oldflags) &
(JFS_APPEND_FL | JFS_IMMUTABLE_FL))) { (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
if (!capable(CAP_LINUX_IMMUTABLE)) if (!capable(CAP_LINUX_IMMUTABLE)) {
mutex_unlock(&inode->i_mutex);
return -EPERM; return -EPERM;
}
} }
flags = flags & JFS_FL_USER_MODIFIABLE; flags = flags & JFS_FL_USER_MODIFIABLE;
...@@ -101,6 +107,7 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd, ...@@ -101,6 +107,7 @@ int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
jfs_inode->mode2 = flags; jfs_inode->mode2 = flags;
jfs_set_inode_flags(inode); jfs_set_inode_flags(inode);
mutex_unlock(&inode->i_mutex);
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
return 0; return 0;
......
...@@ -22,8 +22,7 @@ struct fid; ...@@ -22,8 +22,7 @@ struct fid;
extern struct inode *ialloc(struct inode *, umode_t); extern struct inode *ialloc(struct inode *, umode_t);
extern int jfs_fsync(struct file *, struct dentry *, int); extern int jfs_fsync(struct file *, struct dentry *, int);
extern int jfs_ioctl(struct inode *, struct file *, extern long jfs_ioctl(struct file *, unsigned int, unsigned long);
unsigned int, unsigned long);
extern struct inode *jfs_iget(struct super_block *, unsigned long); extern struct inode *jfs_iget(struct super_block *, unsigned long);
extern int jfs_commit_inode(struct inode *, int); extern int jfs_commit_inode(struct inode *, int);
extern int jfs_write_inode(struct inode*, int); extern int jfs_write_inode(struct inode*, int);
......
...@@ -1556,7 +1556,7 @@ const struct file_operations jfs_dir_operations = { ...@@ -1556,7 +1556,7 @@ const struct file_operations jfs_dir_operations = {
.read = generic_read_dir, .read = generic_read_dir,
.readdir = jfs_readdir, .readdir = jfs_readdir,
.fsync = jfs_fsync, .fsync = jfs_fsync,
.ioctl = jfs_ioctl, .unlocked_ioctl = jfs_ioctl,
}; };
static int jfs_ci_hash(struct dentry *dir, struct qstr *this) static int jfs_ci_hash(struct dentry *dir, struct qstr *this)
......
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