aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2017-08-23 00:15:43 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2017-08-29 13:05:33 -0400
commit01983c715ad0e78842a885f361ad927a3a985994 (patch)
treedd8995b6626b9b423bcf2e7170f85d55879e65f7
parentadb6dc197187e2a5f5a7bed01e722f46a58676af (diff)
f2fs: wake up discard_thread iff there is a candidate
This patch fixes to avoid needless wake ups. Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fs/f2fs/segment.c3
-rw-r--r--fs/f2fs/segment.h25
-rw-r--r--fs/f2fs/sysfs.c6
3 files changed, 27 insertions, 7 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8306beace7cb..8375257b6b26 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1494,8 +1494,7 @@ skip:
1494 kmem_cache_free(discard_entry_slab, entry); 1494 kmem_cache_free(discard_entry_slab, entry);
1495 } 1495 }
1496 1496
1497 dcc->discard_wake = 1; 1497 wake_up_discard_thread(sbi, false);
1498 wake_up_interruptible_all(&dcc->discard_wait_queue);
1499} 1498}
1500 1499
1501static int create_discard_cmd_control(struct f2fs_sb_info *sbi) 1500static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index b9b4f85ffeb6..613b2fa7b1c1 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -798,3 +798,28 @@ static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
798 wbc->nr_to_write = desired; 798 wbc->nr_to_write = desired;
799 return desired - nr_to_write; 799 return desired - nr_to_write;
800} 800}
801
802static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
803{
804 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
805 bool wakeup = false;
806 int i;
807
808 if (force)
809 goto wake_up;
810
811 mutex_lock(&dcc->cmd_lock);
812 for (i = MAX_PLIST_NUM - 1;
813 i >= 0 && plist_issue(dcc->pend_list_tag[i]); i--) {
814 if (!list_empty(&dcc->pend_list[i])) {
815 wakeup = true;
816 break;
817 }
818 }
819 mutex_unlock(&dcc->cmd_lock);
820 if (!wakeup)
821 return;
822wake_up:
823 dcc->discard_wake = 1;
824 wake_up_interruptible_all(&dcc->discard_wait_queue);
825}
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index b9ad9041559f..962735dc9c63 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -178,13 +178,9 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
178 if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) 178 if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
179 f2fs_reset_iostat(sbi); 179 f2fs_reset_iostat(sbi);
180 if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) { 180 if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
181 struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
182
183 sbi->gc_thread->gc_wake = 1; 181 sbi->gc_thread->gc_wake = 1;
184 wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head); 182 wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
185 183 wake_up_discard_thread(sbi, true);
186 dcc->discard_wake = 1;
187 wake_up_interruptible_all(&dcc->discard_wait_queue);
188 } 184 }
189 185
190 return count; 186 return count;