fs: sdfat: Update to version 2.4.5
[GitHub/LineageOS/android_kernel_samsung_universal7580.git] / fs / super.c
index a33381b02ed4500fe7bb276acb39660047ccf81b..81cdbe57d2ec9dab081ba94c57ca3b8e1d5cdc75 100644 (file)
@@ -163,19 +163,6 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags)
                        s = NULL;
                        goto out;
                }
-#ifdef CONFIG_SMP
-               s->s_files = alloc_percpu(struct list_head);
-               if (!s->s_files)
-                       goto err_out;
-               else {
-                       int i;
-
-                       for_each_possible_cpu(i)
-                               INIT_LIST_HEAD(per_cpu_ptr(s->s_files, i));
-               }
-#else
-               INIT_LIST_HEAD(&s->s_files);
-#endif
                if (init_sb_writers(s, type))
                        goto err_out;
                s->s_flags = flags;
@@ -225,10 +212,6 @@ out:
        return s;
 err_out:
        security_sb_free(s);
-#ifdef CONFIG_SMP
-       if (s->s_files)
-               free_percpu(s->s_files);
-#endif
        destroy_sb_writers(s);
        kfree(s);
        s = NULL;
@@ -243,9 +226,6 @@ err_out:
  */
 static inline void destroy_super(struct super_block *s)
 {
-#ifdef CONFIG_SMP
-       free_percpu(s->s_files);
-#endif
        destroy_sb_writers(s);
        security_sb_free(s);
        WARN_ON(!list_empty(&s->s_mounts));
@@ -695,7 +675,8 @@ rescan:
 }
 
 /**
- *     do_remount_sb - asks filesystem to change mount options.
+ *     do_remount_sb2 - asks filesystem to change mount options.
+ *     @mnt:   mount we are looking at
  *     @sb:    superblock in question
  *     @flags: numeric part of options
  *     @data:  the rest of options
@@ -703,7 +684,7 @@ rescan:
  *
  *     Alters the mount options of a mounted file system.
  */
-int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
+int do_remount_sb2(struct vfsmount *mnt, struct super_block *sb, int flags, void *data, int force)
 {
        int retval;
        int remount_ro;
@@ -727,7 +708,8 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
           make sure there are no rw files opened */
        if (remount_ro) {
                if (force) {
-                       mark_files_ro(sb);
+                       sb->s_readonly_remount = 1;
+                       smp_wmb();
                } else {
                        retval = sb_prepare_remount_readonly(sb);
                        if (retval)
@@ -735,7 +717,16 @@ int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
                }
        }
 
-       if (sb->s_op->remount_fs) {
+       if (mnt && sb->s_op->remount_fs2) {
+               retval = sb->s_op->remount_fs2(mnt, sb, &flags, data);
+               if (retval) {
+                       if (!force)
+                               goto cancel_readonly;
+                       /* If forced remount, go ahead despite any errors */
+                       WARN(1, "forced remount of a %s fs returned %i\n",
+                            sb->s_type->name, retval);
+               }
+       } else if (sb->s_op->remount_fs) {
                retval = sb->s_op->remount_fs(sb, &flags, data);
                if (retval) {
                        if (!force)
@@ -767,6 +758,11 @@ cancel_readonly:
        return retval;
 }
 
+int do_remount_sb(struct super_block *sb, int flags, void *data, int force)
+{
+       return do_remount_sb2(NULL, sb, flags, data, force);
+}
+
 void do_emergency_remount(struct work_struct *work)
 {
        struct super_block *sb, *p = NULL;
@@ -1086,7 +1082,7 @@ struct dentry *mount_single(struct file_system_type *fs_type,
 EXPORT_SYMBOL(mount_single);
 
 struct dentry *
-mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
+mount_fs(struct file_system_type *type, int flags, const char *name, struct vfsmount *mnt, void *data)
 {
        struct dentry *root;
        struct super_block *sb;
@@ -1103,7 +1099,10 @@ mount_fs(struct file_system_type *type, int flags, const char *name, void *data)
                        goto out_free_secdata;
        }
 
-       root = type->mount(type, flags, name, data);
+       if (type->mount2)
+               root = type->mount2(mnt, type, flags, name, data);
+       else
+               root = type->mount(type, flags, name, data);
        if (IS_ERR(root)) {
                error = PTR_ERR(root);
                goto out_free_secdata;
@@ -1346,8 +1345,8 @@ int freeze_super(struct super_block *sb)
                }
        }
        /*
-        * This is just for debugging purposes so that fs can warn if it
-        * sees write activity when frozen is set to SB_FREEZE_COMPLETE.
+        * For debugging purposes so that fs can warn if it sees write activity
+        * when frozen is set to SB_FREEZE_COMPLETE, and for thaw_super().
         */
        sb->s_writers.frozen = SB_FREEZE_COMPLETE;
        up_write(&sb->s_umount);
@@ -1366,7 +1365,7 @@ int thaw_super(struct super_block *sb)
        int error;
 
        down_write(&sb->s_umount);
-       if (sb->s_writers.frozen == SB_UNFROZEN) {
+       if (sb->s_writers.frozen != SB_FREEZE_COMPLETE) {
                up_write(&sb->s_umount);
                return -EINVAL;
        }