These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / fs / ufs / super.c
index dc33f94..f6390ee 100644 (file)
@@ -80,6 +80,7 @@
 #include <linux/stat.h>
 #include <linux/string.h>
 #include <linux/blkdev.h>
+#include <linux/backing-dev.h>
 #include <linux/init.h>
 #include <linux/parser.h>
 #include <linux/buffer_head.h>
 #include "swab.h"
 #include "util.h"
 
-void lock_ufs(struct super_block *sb)
-{
-       struct ufs_sb_info *sbi = UFS_SB(sb);
-
-       mutex_lock(&sbi->mutex);
-       sbi->mutex_owner = current;
-}
-
-void unlock_ufs(struct super_block *sb)
-{
-       struct ufs_sb_info *sbi = UFS_SB(sb);
-
-       sbi->mutex_owner = NULL;
-       mutex_unlock(&sbi->mutex);
-}
-
 static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
 {
        struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
@@ -693,7 +678,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
        struct ufs_super_block_third * usb3;
        unsigned flags;
 
-       lock_ufs(sb);
        mutex_lock(&UFS_SB(sb)->s_lock);
 
        UFSD("ENTER\n");
@@ -713,7 +697,6 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
 
        UFSD("EXIT\n");
        mutex_unlock(&UFS_SB(sb)->s_lock);
-       unlock_ufs(sb);
 
        return 0;
 }
@@ -757,7 +740,6 @@ static void ufs_put_super(struct super_block *sb)
 
        ubh_brelse_uspi (sbi->s_uspi);
        kfree (sbi->s_uspi);
-       mutex_destroy(&sbi->mutex);
        kfree (sbi);
        sb->s_fs_info = NULL;
        UFSD("EXIT\n");
@@ -800,7 +782,6 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
 
        UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY));
        
-       mutex_init(&sbi->mutex);
        mutex_init(&sbi->s_lock);
        spin_lock_init(&sbi->work_lock);
        INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs);
@@ -1256,7 +1237,6 @@ magic_found:
        return 0;
 
 failed:
-       mutex_destroy(&sbi->mutex);
        if (ubh)
                ubh_brelse_uspi (uspi);
        kfree (uspi);
@@ -1279,7 +1259,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        unsigned flags;
 
        sync_filesystem(sb);
-       lock_ufs(sb);
        mutex_lock(&UFS_SB(sb)->s_lock);
        uspi = UFS_SB(sb)->s_uspi;
        flags = UFS_SB(sb)->s_flags;
@@ -1295,7 +1274,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        ufs_set_opt (new_mount_opt, ONERROR_LOCK);
        if (!ufs_parse_options (data, &new_mount_opt)) {
                mutex_unlock(&UFS_SB(sb)->s_lock);
-               unlock_ufs(sb);
                return -EINVAL;
        }
        if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) {
@@ -1303,14 +1281,12 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) {
                pr_err("ufstype can't be changed during remount\n");
                mutex_unlock(&UFS_SB(sb)->s_lock);
-               unlock_ufs(sb);
                return -EINVAL;
        }
 
        if ((*mount_flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) {
                UFS_SB(sb)->s_mount_opt = new_mount_opt;
                mutex_unlock(&UFS_SB(sb)->s_lock);
-               unlock_ufs(sb);
                return 0;
        }
        
@@ -1334,7 +1310,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
 #ifndef CONFIG_UFS_FS_WRITE
                pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n");
                mutex_unlock(&UFS_SB(sb)->s_lock);
-               unlock_ufs(sb);
                return -EINVAL;
 #else
                if (ufstype != UFS_MOUNT_UFSTYPE_SUN && 
@@ -1344,13 +1319,11 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
                    ufstype != UFS_MOUNT_UFSTYPE_UFS2) {
                        pr_err("this ufstype is read-only supported\n");
                        mutex_unlock(&UFS_SB(sb)->s_lock);
-                       unlock_ufs(sb);
                        return -EINVAL;
                }
                if (!ufs_read_cylinder_structures(sb)) {
                        pr_err("failed during remounting\n");
                        mutex_unlock(&UFS_SB(sb)->s_lock);
-                       unlock_ufs(sb);
                        return -EPERM;
                }
                sb->s_flags &= ~MS_RDONLY;
@@ -1358,7 +1331,6 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
        }
        UFS_SB(sb)->s_mount_opt = new_mount_opt;
        mutex_unlock(&UFS_SB(sb)->s_lock);
-       unlock_ufs(sb);
        return 0;
 }
 
@@ -1390,8 +1362,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
        struct ufs_super_block_third *usb3;
        u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
 
-       lock_ufs(sb);
-
+       mutex_lock(&UFS_SB(sb)->s_lock);
        usb3 = ubh_get_usb_third(uspi);
        
        if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) {
@@ -1412,7 +1383,7 @@ static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_fsid.val[0] = (u32)id;
        buf->f_fsid.val[1] = (u32)(id >> 32);
 
-       unlock_ufs(sb);
+       mutex_unlock(&UFS_SB(sb)->s_lock);
 
        return 0;
 }
@@ -1428,6 +1399,8 @@ static struct inode *ufs_alloc_inode(struct super_block *sb)
                return NULL;
 
        ei->vfs_inode.i_version = 1;
+       seqlock_init(&ei->meta_lock);
+       mutex_init(&ei->truncate_mutex);
        return &ei->vfs_inode;
 }