From e0f839a99614c3eaedce0dc646376024af0d1bfc Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Sun, 2 Aug 2020 02:35:30 -0700 Subject: [PATCH] f2fs: Add support for reporting a fake kernel version to fsck fsck.f2fs forces a filesystem fix on boot if it detects that the current kernel version differs from the one saved in the superblock, which results in fsck blocking boot for a long time (~35 seconds). This commit provides a way to report a constant fake kernel version to fsck to avoid triggering the version check, which is useful if you boot new kernel builds frequently. Signed-off-by: Danny Lin Signed-off-by: UtsavBalar1231 --- fs/f2fs/Kconfig | 19 +++++++++++++++++++ kernel/sys.c | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig index 1c7c83e09..8fe195b6b 100755 --- a/fs/f2fs/Kconfig +++ b/fs/f2fs/Kconfig @@ -175,6 +175,25 @@ config F2FS_SEC_BLOCK_OPERATIONS_DEBUG If unsure, say N. +config F2FS_REPORT_FAKE_KERNEL_VERSION + bool "Report fake kernel version to fsck.f2fs" + depends on F2FS_FS + help + fsck.f2fs forces a filesystem fix on boot if it detects that the current + kernel version differs from the one saved in the superblock, which results in + fsck taking a long time to run. This option provides a way to report a + constant fake kernel version to fsck to avoid triggering the version check. + + If unsure, say N. + +config F2FS_FAKE_KERNEL_RELEASE + string "Kernel release for fsck.f2fs" + depends on F2FS_REPORT_FAKE_KERNEL_VERSION + +config F2FS_FAKE_KERNEL_VERSION + string "Kernel version for fsck.f2fs" + depends on F2FS_REPORT_FAKE_KERNEL_VERSION + config F2FS_SEC_SUPPORT_DNODE_RELOCATION bool "DNODE relocation support" depends on F2FS_FS_COMPRESSION diff --git a/kernel/sys.c b/kernel/sys.c index 4b0232713..15d16be5a 100755 --- a/kernel/sys.c +++ b/kernel/sys.c @@ -1271,6 +1271,28 @@ static int override_release(char __user *release, size_t len) return ret; } +static int override_version(struct new_utsname __user *name) +{ +#ifdef CONFIG_F2FS_REPORT_FAKE_KERNEL_VERSION + int ret; + + if (strcmp(current->comm, "fsck.f2fs")) + return 0; + + ret = copy_to_user(name->release, CONFIG_F2FS_FAKE_KERNEL_RELEASE, + strlen(CONFIG_F2FS_FAKE_KERNEL_RELEASE) + 1); + if (ret) + return ret; + + ret = copy_to_user(name->version, CONFIG_F2FS_FAKE_KERNEL_VERSION, + strlen(CONFIG_F2FS_FAKE_KERNEL_VERSION) + 1); + + return ret; +#else + return 0; +#endif +} + SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) { struct new_utsname tmp; @@ -1285,6 +1307,8 @@ SYSCALL_DEFINE1(newuname, struct new_utsname __user *, name) return -EFAULT; if (override_architecture(name)) return -EFAULT; + if (override_version(name)) + return -EFAULT; return 0; }