fixed size backend: Do not unmount subsession image when switching away from session 53/320553/2
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 4 Mar 2025 17:16:14 +0000 (18:16 +0100)
committerMichal Bloch <m.bloch@samsung.com>
Tue, 11 Mar 2025 17:54:42 +0000 (18:54 +0100)
There is no tangible benefit for unmounting the image.

Change-Id: Ic425cfee68b99fe3eef8f532676f77844229c833

src/service/src/dir_backend_fixed_size.cpp

index f20aeb49ffe8a80ed56ec3a675739f85149d1857..40fe4c9192c69a8be5d90105567aa75f982ab8d5 100644 (file)
@@ -190,6 +190,9 @@ void DirBackendAddFixedSize::AddSubsessionFinalize (const fs::path& tmpdir_path,
 
 void DirBackendFixedSize::RemoveSubsession (const fs::path& subsession_path) const
 {
+       if (OS::is_mountpoint(subsession_path))
+               do_umount(subsession_path);
+
        fs::remove(subsession_path);
 
        const auto image_path = GetImagePathFromSubsessionPath(subsession_path);
@@ -198,9 +201,13 @@ void DirBackendFixedSize::RemoveSubsession (const fs::path& subsession_path) con
 
 void DirBackendFixedSize::SwitchSubsessionAway (const fs::path& subsession_path) const
 {
-       /* Note, we cannot keep the subsession mounted permanently,
-        * from Add until Remove, because reboots happen. */
-       do_umount(subsession_path);
+       /* Keep session mounted during switch to reuse it if another switch happen.
+        * Addionally, it leaves subsession in same state as if sessiond would be restarted */
+       if (getenv("SESSIOND_NO_KEEP_SESSION_MOUNTS")) {
+               LOGI("Unmouting session image at %s", subsession_path.c_str());
+               do_umount(subsession_path);
+       } else
+               LOGI("Switching away from subsession but keeping image mounted at %s", subsession_path.c_str());
 }
 
 void DirBackendFixedSize::SwitchSubsessionInto (const fs::path& subsession_path) const
@@ -208,7 +215,7 @@ void DirBackendFixedSize::SwitchSubsessionInto (const fs::path& subsession_path)
        const auto image_path = GetImagePathFromSubsessionPath(subsession_path);
 
        if (OS::is_mountpoint(subsession_path)) {
-               LOGW("Session image already mounted (maybe earlier sessiond instance died?), reusing");
+               LOGI("Session image already mounted at %s, reusing", subsession_path.c_str());
                return;
        }