Wait for releasing open files when BLOCK_UNMOUNT 88/225588/3 accepted/tizen/unified/20200225.224445 submit/tizen/20200225.024742
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:41:53 +0000 (19:41 +0900)
Change-Id: I1cb8d450c48e138ae8410c9b06b390da07102ec7
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
src/block/block.c

index 6fdc678..a11f3f5 100644 (file)
@@ -1369,7 +1369,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;
@@ -1396,33 +1395,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: