misc: tizen-inform-reboot: resolve sync failure about reboot parameter
authorJunghoon Kim <jhoon20.kim@samsung.com>
Tue, 17 Oct 2017 05:43:04 +0000 (14:43 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Thu, 3 Aug 2023 08:43:00 +0000 (17:43 +0900)
Currently, writing reboot paramter into INFORM partition fails
infrequently.

Resolve this issue by calling sync_filesystem function so that it writes
out and waits upon all dirty data associated with this superblock.

Change-Id: Ic62df0c3c4e565ca7211eb85661ead6979f0ad8d
Signed-off-by: Junghoon Kim <jhoon20.kim@samsung.com>
drivers/misc/tizen-inform-reboot.c

index 2e26186..08a0552 100644 (file)
@@ -33,6 +33,8 @@ static int inform_reboot_notifier(struct notifier_block *nb,
        if (fd >= 0) {
                file = fget(fd);
                if (file) {
+                       struct super_block *sb = file->f_path.dentry->d_sb;
+
                        if (cmd) {
                                if (!strncmp(cmd, "fota", 4))
                                        cmd = "upgr";
@@ -44,12 +46,14 @@ static int inform_reboot_notifier(struct notifier_block *nb,
                                cmd = "norm";
 
                        vfs_write(file, cmd, strlen(cmd), &pos);
-                       vfs_fsync(file, 0);
+
+                       down_read(&sb->s_umount);
+                       sync_filesystem(sb);
+                       up_read(&sb->s_umount);
+
                        fput(file);
                }
                sys_close(fd);
-               /* to guarantee all file data and metadata sync */
-               emergency_sync();
        } else {
                pr_err("Reboot parameter passing is failed.\n"
                                "Inform file path should be described correctly in config.\n");