Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f0a08e41 authored by Sayali Lokhande's avatar Sayali Lokhande
Browse files

f2fs: avoid race between gc and checkpoint in unmount path



During shutdown/unmount path, there is chance that
f2fs_umount_end gets called without or before kill_sb()
can stop gc thread. This results in assert as part of
do_checkpoint() in unmount path as gc_thread is not stopped
and dirtied some dentry (F2FS_DIRTY_DENTS is set).

unmount path :
f2fs_umount_end()
  f2fs_write_checkpoint()
    do_checkpoint()
      f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_DENTS));

This change avoids race condition between f2fs_gc() and
f2fs_write_checkpoint() in unmount path using gc_mutex.

Change-Id: I98fd87792b2385422eeb5011ff57b427376f139d
Signed-off-by: default avatarSayali Lokhande <sayalil@codeaurora.org>
parent f94ba33e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -1040,10 +1040,13 @@ static void f2fs_umount_end(struct super_block *sb, int flags)
	if ((flags & MNT_FORCE) || atomic_read(&sb->s_active) > 1) {
		/* to write the latest kbytes_written */
		if (!(sb->s_flags & MS_RDONLY)) {
			struct f2fs_sb_info *sbi = F2FS_SB(sb);
			struct cp_control cpc = {
				.reason = CP_UMOUNT,
			};
			mutex_lock(&sbi->gc_mutex);
			f2fs_write_checkpoint(F2FS_SB(sb), &cpc);
			mutex_unlock(&sbi->gc_mutex);
		}
	}
}