Merge tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[linux-2.6-block.git] / fs / ext4 / super.c
index 152d05d983f6e666be203a0a313625227ff06d38..421222ec350956ae3e0925d481b0c978b3b37b59 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  linux/fs/ext4/super.c
  *
@@ -40,6 +41,7 @@
 #include <linux/dax.h>
 #include <linux/cleancache.h>
 #include <linux/uaccess.h>
+#include <linux/iversion.h>
 
 #include <linux/kthread.h>
 #include <linux/freezer.h>
@@ -742,6 +744,7 @@ __acquires(bitlock)
        }
 
        ext4_unlock_group(sb, grp);
+       ext4_commit_super(sb, 1);
        ext4_handle_error(sb);
        /*
         * We only get here in the ERRORS_RO case; relocking the group
@@ -870,7 +873,6 @@ static void ext4_put_super(struct super_block *sb)
        ext4_unregister_li_request(sb);
        ext4_quota_off_umount(sb);
 
-       flush_workqueue(sbi->rsv_conversion_wq);
        destroy_workqueue(sbi->rsv_conversion_wq);
 
        if (sbi->s_journal) {
@@ -967,7 +969,7 @@ static struct inode *ext4_alloc_inode(struct super_block *sb)
        if (!ei)
                return NULL;
 
-       ei->vfs_inode.i_version = 1;
+       inode_set_iversion(&ei->vfs_inode, 1);
        spin_lock_init(&ei->i_raw_lock);
        INIT_LIST_HEAD(&ei->i_prealloc_list);
        spin_lock_init(&ei->i_prealloc_lock);
@@ -1036,11 +1038,13 @@ static void init_once(void *foo)
 
 static int __init init_inodecache(void)
 {
-       ext4_inode_cachep = kmem_cache_create("ext4_inode_cache",
-                                            sizeof(struct ext4_inode_info),
-                                            0, (SLAB_RECLAIM_ACCOUNT|
-                                               SLAB_MEM_SPREAD|SLAB_ACCOUNT),
-                                            init_once);
+       ext4_inode_cachep = kmem_cache_create_usercopy("ext4_inode_cache",
+                               sizeof(struct ext4_inode_info), 0,
+                               (SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
+                                       SLAB_ACCOUNT),
+                               offsetof(struct ext4_inode_info, i_data),
+                               sizeof_field(struct ext4_inode_info, i_data),
+                               init_once);
        if (ext4_inode_cachep == NULL)
                return -ENOMEM;
        return 0;
@@ -2674,7 +2678,7 @@ static ext4_fsblk_t descriptor_loc(struct super_block *sb,
         * compensate.
         */
        if (sb->s_blocksize == 1024 && nr == 0 &&
-           le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block) == 0)
+           le32_to_cpu(sbi->s_es->s_first_data_block) == 0)
                has_super++;
 
        return (has_super + ext4_group_first_block_no(sb, bg));
@@ -3119,7 +3123,7 @@ int ext4_register_li_request(struct super_block *sb,
 {
        struct ext4_sb_info *sbi = EXT4_SB(sb);
        struct ext4_li_request *elr = NULL;
-       ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
+       ext4_group_t ngroups = sbi->s_groups_count;
        int ret = 0;
 
        mutex_lock(&ext4_li_mtx);
@@ -4834,7 +4838,7 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
        bool needs_barrier = false;
        struct ext4_sb_info *sbi = EXT4_SB(sb);
 
-       if (unlikely(ext4_forced_shutdown(EXT4_SB(sb))))
+       if (unlikely(ext4_forced_shutdown(sbi)))
                return 0;
 
        trace_ext4_sync_fs(sb, wait);