diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-05-07 17:22:40 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2018-05-31 14:31:51 -0400 |
commit | 5b0e95398e2bcc18e871758221cc712be4a0a39a (patch) | |
tree | 742796c086e1192d1ec64c9c5c82b8ae59d50239 /fs/f2fs/sysfs.c | |
parent | 107a805de87ec071dab602071c14e67b98b0c519 (diff) |
f2fs: introduce sbi->gc_mode to determine the policy
This is to avoid sbi->gc_thread pointer access.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/sysfs.c')
-rw-r--r-- | fs/f2fs/sysfs.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 6d8d8f41e517..dd940d156af6 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c | |||
@@ -248,16 +248,33 @@ out: | |||
248 | if (!strcmp(a->attr.name, "trim_sections")) | 248 | if (!strcmp(a->attr.name, "trim_sections")) |
249 | return -EINVAL; | 249 | return -EINVAL; |
250 | 250 | ||
251 | if (!strcmp(a->attr.name, "gc_urgent")) { | ||
252 | if (t >= 1) { | ||
253 | sbi->gc_mode = GC_URGENT; | ||
254 | if (sbi->gc_thread) { | ||
255 | wake_up_interruptible_all( | ||
256 | &sbi->gc_thread->gc_wait_queue_head); | ||
257 | wake_up_discard_thread(sbi, true); | ||
258 | } | ||
259 | } else { | ||
260 | sbi->gc_mode = GC_NORMAL; | ||
261 | } | ||
262 | return count; | ||
263 | } | ||
264 | if (!strcmp(a->attr.name, "gc_idle")) { | ||
265 | if (t == GC_IDLE_CB) | ||
266 | sbi->gc_mode = GC_IDLE_CB; | ||
267 | else if (t == GC_IDLE_GREEDY) | ||
268 | sbi->gc_mode = GC_IDLE_GREEDY; | ||
269 | else | ||
270 | sbi->gc_mode = GC_NORMAL; | ||
271 | return count; | ||
272 | } | ||
273 | |||
251 | *ui = t; | 274 | *ui = t; |
252 | 275 | ||
253 | if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) | 276 | if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0) |
254 | f2fs_reset_iostat(sbi); | 277 | f2fs_reset_iostat(sbi); |
255 | if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) { | ||
256 | sbi->gc_thread->gc_wake = 1; | ||
257 | wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head); | ||
258 | wake_up_discard_thread(sbi, true); | ||
259 | } | ||
260 | |||
261 | return count; | 278 | return count; |
262 | } | 279 | } |
263 | 280 | ||
@@ -349,8 +366,8 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_urgent_sleep_time, | |||
349 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time); | 366 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time); |
350 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time); | 367 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time); |
351 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); | 368 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time); |
352 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle); | 369 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode); |
353 | F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_urgent, gc_urgent); | 370 | F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode); |
354 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); | 371 | F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments); |
355 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); | 372 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards); |
356 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity); | 373 | F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity); |