Merge git://git.infradead.org/users/dwmw2/mtd-2.6.32
[firefly-linux-kernel-4.4.55.git] / fs / ubifs / super.c
index c4af069df1adbc30e05798815ddfdc5a2395a92c..333e181ee9877ed4b992967b268ea193cf9ee894 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/mount.h>
 #include <linux/math64.h>
 #include <linux/writeback.h>
-#include <linux/smp_lock.h>
 #include "ubifs.h"
 
 /*
@@ -318,6 +317,8 @@ static int ubifs_write_inode(struct inode *inode, int wait)
                if (err)
                        ubifs_err("can't write inode %lu, error %d",
                                  inode->i_ino, err);
+               else
+                       err = dbg_check_inode_size(c, inode, ui->ui_size);
        }
 
        ui->dirty = 0;
@@ -447,17 +448,6 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
        if (!wait)
                return 0;
 
-       /*
-        * VFS calls '->sync_fs()' before synchronizing all dirty inodes and
-        * pages, so synchronize them first, then commit the journal. Strictly
-        * speaking, it is not necessary to commit the journal here,
-        * synchronizing write-buffers would be enough. But committing makes
-        * UBIFS free space predictions much more accurate, so we want to let
-        * the user be able to get more accurate results of 'statfs()' after
-        * they synchronize the file system.
-        */
-       sync_inodes_sb(sb);
-
        /*
         * Synchronize write buffers, because 'ubifs_run_commit()' does not
         * do this if it waits for an already running commit.
@@ -468,6 +458,13 @@ static int ubifs_sync_fs(struct super_block *sb, int wait)
                        return err;
        }
 
+       /*
+        * Strictly speaking, it is not necessary to commit the journal here,
+        * synchronizing write-buffers would be enough. But committing makes
+        * UBIFS free space predictions much more accurate, so we want to let
+        * the user be able to get more accurate results of 'statfs()' after
+        * they synchronize the file system.
+        */
        err = ubifs_run_commit(c);
        if (err)
                return err;
@@ -1720,8 +1717,6 @@ static void ubifs_put_super(struct super_block *sb)
        ubifs_msg("un-mount UBI device %d, volume %d", c->vi.ubi_num,
                  c->vi.vol_id);
 
-       lock_kernel();
-
        /*
         * The following asserts are only valid if there has not been a failure
         * of the media. For example, there will be dirty inodes if we failed
@@ -1786,8 +1781,6 @@ static void ubifs_put_super(struct super_block *sb)
        ubi_close_volume(c->ubi);
        mutex_unlock(&c->umount_mutex);
        kfree(c);
-
-       unlock_kernel();
 }
 
 static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
@@ -1803,22 +1796,17 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
                return err;
        }
 
-       lock_kernel();
        if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
                if (c->ro_media) {
                        ubifs_msg("cannot re-mount due to prior errors");
-                       unlock_kernel();
                        return -EROFS;
                }
                err = ubifs_remount_rw(c);
-               if (err) {
-                       unlock_kernel();
+               if (err)
                        return err;
-               }
        } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) {
                if (c->ro_media) {
                        ubifs_msg("cannot re-mount due to prior errors");
-                       unlock_kernel();
                        return -EROFS;
                }
                ubifs_remount_ro(c);
@@ -1833,7 +1821,6 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data)
        }
 
        ubifs_assert(c->lst.taken_empty_lebs > 0);
-       unlock_kernel();
        return 0;
 }