f2fs: introduce -o fastboot for reducing booting time only
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 31 Oct 2014 05:47:03 +0000 (22:47 -0700)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 5 Nov 2014 01:34:15 +0000 (17:34 -0800)
If a system wants to reduce the booting time as a top priority, now we can
use a mount option, -o fastboot.
With this option, f2fs conducts a little bit slow write_checkpoint, but
it can avoid the node page reads during the next mount time.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Documentation/filesystems/f2fs.txt
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/super.c

index 4bb9f278c031d1045a875b9721770ce6fdd5db01..e0950c483c2244e2fb5bdbe978130f71e37a227e 100644 (file)
@@ -135,6 +135,9 @@ nobarrier              This option can be used if underlying storage guarantees
                       If this option is set, no cache_flush commands are issued
                       but f2fs still guarantees the write ordering of all the
                       data writes.
+fastboot               This option is used when a system wants to reduce mount
+                       time as much as possible, even though normal performance
+                      can be sacrificed.
 
 ================================================================================
 DEBUGFS ENTRIES
index 5a9705842f10a24a21f8f87a10af633f465977ed..d45f3f4d7f9361142874dbba860cab37d720c0a7 100644 (file)
@@ -49,6 +49,7 @@
 #define F2FS_MOUNT_INLINE_DENTRY       0x00000200
 #define F2FS_MOUNT_FLUSH_MERGE         0x00000400
 #define F2FS_MOUNT_NOBARRIER           0x00000800
+#define F2FS_MOUNT_FASTBOOT            0x00001000
 
 #define clear_opt(sbi, option) (sbi->mount_opt.opt &= ~F2FS_MOUNT_##option)
 #define set_opt(sbi, option)   (sbi->mount_opt.opt |= F2FS_MOUNT_##option)
index 832bd91922b8057b5173907846a4cba1036f5dea..46311e7b388a3ae84e54cb7ffc5ca72e147c158d 100644 (file)
@@ -130,6 +130,8 @@ static inline bool need_do_checkpoint(struct inode *inode)
                need_cp = true;
        else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi)))
                need_cp = true;
+       else if (test_opt(sbi, FASTBOOT))
+               need_cp = true;
 
        return need_cp;
 }
index 7151d7de7d9580b2a852c72e042892424ebbbbb6..b197a2f2993a3f7c48e5d8e84c80ab7759101d8b 100644 (file)
@@ -695,9 +695,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi)
        int gc_type = BG_GC;
        int nfree = 0;
        int ret = -1;
-       struct cp_control cpc = {
-               .reason = CP_SYNC,
-       };
+       struct cp_control cpc;
+
+       cpc.reason = test_opt(sbi, FASTBOOT) ? CP_UMOUNT : CP_SYNC;
 
        INIT_LIST_HEAD(&ilist);
 gc_more:
index 6c5fc7605109579a73843a7c91c6828461297f4c..512ffd8e16242edf48a3526c62d1c3e9e2a713e2 100644 (file)
@@ -54,6 +54,7 @@ enum {
        Opt_inline_dentry,
        Opt_flush_merge,
        Opt_nobarrier,
+       Opt_fastboot,
        Opt_err,
 };
 
@@ -73,6 +74,7 @@ static match_table_t f2fs_tokens = {
        {Opt_inline_dentry, "inline_dentry"},
        {Opt_flush_merge, "flush_merge"},
        {Opt_nobarrier, "nobarrier"},
+       {Opt_fastboot, "fastboot"},
        {Opt_err, NULL},
 };
 
@@ -351,6 +353,9 @@ static int parse_options(struct super_block *sb, char *options)
                case Opt_nobarrier:
                        set_opt(sbi, NOBARRIER);
                        break;
+               case Opt_fastboot:
+                       set_opt(sbi, FASTBOOT);
+                       break;
                default:
                        f2fs_msg(sb, KERN_ERR,
                                "Unrecognized mount option \"%s\" or missing value",
@@ -479,9 +484,9 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
        trace_f2fs_sync_fs(sb, sync);
 
        if (sync) {
-               struct cp_control cpc = {
-                       .reason = CP_SYNC,
-               };
+               struct cp_control cpc;
+
+               cpc.reason = test_opt(sbi, FASTBOOT) ? CP_UMOUNT : CP_SYNC;
                mutex_lock(&sbi->gc_mutex);
                write_checkpoint(sbi, &cpc);
                mutex_unlock(&sbi->gc_mutex);
@@ -574,6 +579,8 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
                seq_puts(seq, ",flush_merge");
        if (test_opt(sbi, NOBARRIER))
                seq_puts(seq, ",nobarrier");
+       if (test_opt(sbi, FASTBOOT))
+               seq_puts(seq, ",fastboot");
        seq_printf(seq, ",active_logs=%u", sbi->active_logs);
 
        return 0;