f2fs: finish previous checkpoints before returning from remount
authorDaeho Jeong <daehojeong@google.com>
Fri, 20 Oct 2023 16:36:45 +0000 (09:36 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 22 Oct 2023 13:42:02 +0000 (06:42 -0700)
commit1e7bef5f90ed69d903768d78369f251b77e5d2f5
tree080b21e66f928b7d90b3b50b35ee29a3d33a5dbb
parent9b4c8dd99fe48721410741651d426015e03a4b7a
f2fs: finish previous checkpoints before returning from remount

Flush remaining checkpoint requests at the end of remount, since a new
checkpoint would be triggered while remount and we need to take care of
it before returning from remount, in order to avoid the below race
condition.

  - Thread                          - checkpoint thread
  do_remount()
   down_write(&sb->s_umount);
   f2fs_remount()
    f2fs_disable_checkpoint(sbi) -> add checkpoints to the list
                                    block_operations()
                                     down_read_trylock(&sb->s_umount) = 0
   up_write(&sb->s_umount);
                                     f2fs_quota_sync()
                                      dquot_writeback_dquots()
                                       WARN_ON_ONCE(!rwsem_is_locked(&sb->s_umount));

Signed-off-by: Daeho Jeong <daehojeong@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/super.c