Wait for releasing open files when BLOCK_UNMOUNT 34/225634/1 accepted/tizen/5.5/unified/20200227.121136 submit/tizen_5.5/20200226.105102
authorHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 21 Feb 2020 06:23:04 +0000 (15:23 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Fri, 21 Feb 2020 10:42:27 +0000 (10:42 +0000)
Change-Id: I1cb8d450c48e138ae8410c9b06b390da07102ec7
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
(cherry picked from commit a59af752906449d9c2f6a8a8f4b9e3f0786a1639)

src/block/block.c

index 5aa182e..509c5a6 100644 (file)
@@ -1388,7 +1388,6 @@ static int block_unmount(struct block_device *bdev,
 {
        struct block_data *data;
        int r, retry = 0;
-       struct timespec time = {0,};
 
        if (!bdev || !bdev->data || !bdev->data->mount_point)
                return -EINVAL;
@@ -1415,33 +1414,38 @@ static int block_unmount(struct block_device *bdev,
        if ((data->block_type == BLOCK_MMC_DEV ||
                data->block_type == BLOCK_EXTENDEDSD_DEV) &&
                data->primary) {
-               /* At first, notify to other app
-                * who already access sdcard */
+               /* At first, notify to other app who already access sdcard */
                _I("Notify to other app who already access sdcard.");
                vconf_set_int(VCONFKEY_SYSMAN_MMC_STATUS,
                                VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED);
+
+               /* Wait for 700 msec to release open files */
+               usleep(700 * 1000);
        }
 
        sync();
+
        if (umount2(data->mount_point, MNT_DETACH) != 0) {
                _I("Failed to unmount with lazy option: %m");
                return -errno;
        }
 
-       time.tv_nsec = 500 * NANO_SECOND_MULTIPLIER;
-
        while (retry++ < UNMOUNT_RETRY) {
                _I("Kill app with SIGTERM.");
                terminate_process(data->devnode, false);
-               nanosleep(&time, NULL);
+               usleep(500 * 1000);
+
+               if (!is_in_use_partition(data->devnode))
+                       break;
 
                _I("Kill app with SIGKILL.");
                terminate_process(data->devnode, true);
-               nanosleep(&time, NULL);
+               usleep(500 * 1000);
 
                if (!is_in_use_partition(data->devnode))
                        break;
        }
+
        sync();
 
 out: