Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=baab81fa518ecfac597402b462631f5593926623
Commit:     baab81fa518ecfac597402b462631f5593926623
Parent:     0afc2edfada50980bec999f94dcea26ebad3dda6
Author:     Andi Kleen <[EMAIL PROTECTED]>
AuthorDate: Sun Jan 27 16:58:51 2008 -0600
Committer:  Dave Kleikamp <[EMAIL PROTECTED]>
CommitDate: Thu Feb 7 13:33:58 2008 -0600

    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 <[EMAIL PROTECTED]>
    Signed-off-by: Dave Kleikamp <[EMAIL PROTECTED]>
---
 fs/jfs/file.c      |    2 +-
 fs/jfs/ioctl.c     |   13 ++++++++++---
 fs/jfs/jfs_inode.h |    3 +--
 fs/jfs/namei.c     |    2 +-
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 87eb936..713ff4c 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -112,5 +112,5 @@ const struct file_operations jfs_file_operations = {
        .splice_write   = generic_file_splice_write,
        .fsync          = jfs_fsync,
        .release        = jfs_release,
-       .ioctl          = jfs_ioctl,
+       .unlocked_ioctl = jfs_ioctl,
 };
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index dfda12a..fc82ecc 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -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,
-               unsigned long arg)
+long jfs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 {
+       struct inode *inode = filp->f_dentry->d_inode;
        struct jfs_inode_info *jfs_inode = JFS_IP(inode);
        unsigned int flags;
 
@@ -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 */
                if (IS_NOQUOTA(inode))
                        return -EPERM;
+
+               /* Lock against other parallel changes of flags */
+               mutex_lock(&inode->i_mutex);
+
                jfs_get_inode_flags(jfs_inode);
                oldflags = jfs_inode->mode2;
 
@@ -92,8 +96,10 @@ int jfs_ioctl(struct inode * inode, struct file * filp, 
unsigned int cmd,
                if ((oldflags & JFS_IMMUTABLE_FL) ||
                        ((flags ^ oldflags) &
                        (JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
-                       if (!capable(CAP_LINUX_IMMUTABLE))
+                       if (!capable(CAP_LINUX_IMMUTABLE)) {
+                               mutex_unlock(&inode->i_mutex);
                                return -EPERM;
+                       }
                }
 
                flags = flags & JFS_FL_USER_MODIFIABLE;
@@ -101,6 +107,7 @@ int jfs_ioctl(struct inode * inode, struct file * filp, 
unsigned int cmd,
                jfs_inode->mode2 = flags;
 
                jfs_set_inode_flags(inode);
+               mutex_unlock(&inode->i_mutex);
                inode->i_ctime = CURRENT_TIME_SEC;
                mark_inode_dirty(inode);
                return 0;
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index 95a6a11..570fd5e 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -22,8 +22,7 @@ struct fid;
 
 extern struct inode *ialloc(struct inode *, umode_t);
 extern int jfs_fsync(struct file *, struct dentry *, int);
-extern int jfs_ioctl(struct inode *, struct file *,
-                       unsigned int, unsigned long);
+extern long jfs_ioctl(struct file *, unsigned int, unsigned long);
 extern struct inode *jfs_iget(struct super_block *, unsigned long);
 extern int jfs_commit_inode(struct inode *, int);
 extern int jfs_write_inode(struct inode*, int);
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 403cfc2..6440904 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1556,7 +1556,7 @@ const struct file_operations jfs_dir_operations = {
        .read           = generic_read_dir,
        .readdir        = jfs_readdir,
        .fsync          = jfs_fsync,
-       .ioctl          = jfs_ioctl,
+       .unlocked_ioctl = jfs_ioctl,
 };
 
 static int jfs_ci_hash(struct dentry *dir, struct qstr *this)
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to