f2fs: convert discard_wake and gc_wake to bool type
authorYangtao Li <frank.li@vivo.com>
Mon, 12 Dec 2022 13:36:44 +0000 (21:36 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 11 Jan 2023 19:15:19 +0000 (11:15 -0800)
discard_wake and gc_wake have only two values, 0 or 1.
So there is no need to use int type to store them.

BTW, move discard_wake to the end of the
discard_cmd_control structure.

Before:

  - sizeof(struct discard_cmd_control): 8392

After move:

  - sizeof(struct discard_cmd_control): 8384

Signed-off-by: Yangtao Li <frank.li@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/gc.c
fs/f2fs/gc.h
fs/f2fs/segment.c
fs/f2fs/segment.h
fs/f2fs/sysfs.c

index 53d7ca9..c9c6ae9 100644 (file)
@@ -402,7 +402,6 @@ struct discard_cmd_control {
        struct list_head wait_list;             /* store on-flushing entries */
        struct list_head fstrim_list;           /* in-flight discard from fstrim */
        wait_queue_head_t discard_wait_queue;   /* waiting queue for wake-up */
-       unsigned int discard_wake;              /* to wake up discard thread */
        struct mutex cmd_lock;
        unsigned int nr_discards;               /* # of discards in the list */
        unsigned int max_discards;              /* max. discards to be issued */
@@ -420,6 +419,7 @@ struct discard_cmd_control {
        atomic_t discard_cmd_cnt;               /* # of cached cmd count */
        struct rb_root_cached root;             /* root of discard rb-tree */
        bool rbtree_check;                      /* config for consistence check */
+       bool discard_wake;                      /* to wake up discard thread */
 };
 
 /* for the list of fsync inodes, used only during recovery */
index e59c006..97e8462 100644 (file)
@@ -57,7 +57,7 @@ static int gc_thread_func(void *data)
 
                /* give it a try one time */
                if (gc_th->gc_wake)
-                       gc_th->gc_wake = 0;
+                       gc_th->gc_wake = false;
 
                if (try_to_freeze()) {
                        stat_other_skip_bggc_count(sbi);
@@ -183,7 +183,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
        gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
        gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
 
-       gc_th->gc_wake = 0;
+       gc_th->gc_wake = false;
 
        sbi->gc_thread = gc_th;
        init_waitqueue_head(&sbi->gc_thread->gc_wait_queue_head);
index 19b956c..15bd1d6 100644 (file)
@@ -41,7 +41,7 @@ struct f2fs_gc_kthread {
        unsigned int no_gc_sleep_time;
 
        /* for changing gc mode */
-       unsigned int gc_wake;
+       bool gc_wake;
 
        /* for GC_MERGE mount option */
        wait_queue_head_t fggc_wq;              /*
index f8e0ccf..8aafa1f 100644 (file)
@@ -1696,7 +1696,7 @@ static int issue_discard_thread(void *data)
                                                dcc->discard_granularity);
 
                if (dcc->discard_wake)
-                       dcc->discard_wake = 0;
+                       dcc->discard_wake = false;
 
                /* clean up pending candidates before going to sleep */
                if (atomic_read(&dcc->queued_discard))
index e77518c..ad6a9c1 100644 (file)
@@ -939,6 +939,6 @@ static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
        if (!wakeup || !is_idle(sbi, DISCARD_TIME))
                return;
 wake_up:
-       dcc->discard_wake = 1;
+       dcc->discard_wake = true;
        wake_up_interruptible_all(&dcc->discard_wait_queue);
 }
index 83a366f..805b632 100644 (file)
@@ -511,7 +511,7 @@ out:
                } else if (t == 1) {
                        sbi->gc_mode = GC_URGENT_HIGH;
                        if (sbi->gc_thread) {
-                               sbi->gc_thread->gc_wake = 1;
+                               sbi->gc_thread->gc_wake = true;
                                wake_up_interruptible_all(
                                        &sbi->gc_thread->gc_wait_queue_head);
                                wake_up_discard_thread(sbi, true);
@@ -521,7 +521,7 @@ out:
                } else if (t == 3) {
                        sbi->gc_mode = GC_URGENT_MID;
                        if (sbi->gc_thread) {
-                               sbi->gc_thread->gc_wake = 1;
+                               sbi->gc_thread->gc_wake = true;
                                wake_up_interruptible_all(
                                        &sbi->gc_thread->gc_wait_queue_head);
                        }