diff --git a/src/f2fs-tools/fsck/fsck.c b/src/f2fs-tools/fsck/fsck.c index df7c12a657ac341efead51b8651ef67b92ac82e3..347f96cfc9e417b79276d708dab6f75ce8d5f8bc 100644 --- a/src/f2fs-tools/fsck/fsck.c +++ b/src/f2fs-tools/fsck/fsck.c @@ -3840,19 +3840,20 @@ void fsck_free(struct f2fs_sb_info *sbi) } void fsck_thpool_init(struct f2fs_sb_info *sbi){ - - struct f2fs_fsck *fsck = F2FS_FSCK(sbi); - fsck->max_threads = c.free_thread; //todo + struct f2fs_fsck *fsck = F2FS_FSCK(sbi); fsck->thread_number = c.thread_number; + fsck->threadpool = thpool_init(c.thread_number); + + if(c.feature_no_scheduler){ + fsck->max_threads = 0; + }else{ + fsck->max_threads = c.free_thread; + fsck->threadpool_idle = thpool_init(fsck->max_threads); + pthread_create(&fsck->scheduleThread, NULL, (void *)scheduler_thread, sbi); + fsck->core_budget = fsck->thread_number; + } setup_thread_contexts(sbi); - - fsck->core_budget = fsck->thread_number; - - fsck->threadpool = thpool_init(c.thread_number); - - fsck->threadpool_idle = thpool_init(fsck->max_threads); - pthread_create(&fsck->scheduleThread, NULL, (void *)scheduler_thread, sbi); } //1. 将其ä¸å¯¹fsck_chk_node_blkçš„é€’å½’è°ƒç”¨æ”¹ä¸ºæ·»åŠ ä»»åŠ¡ diff --git a/src/f2fs-tools/fsck/main.c b/src/f2fs-tools/fsck/main.c index 87c54cc210bf8c02d2c41e67eb6a7277c12d7a53..38861874f36b687cad9acb5f24f94e1dd266f120 100644 --- a/src/f2fs-tools/fsck/main.c +++ b/src/f2fs-tools/fsck/main.c @@ -84,6 +84,7 @@ void fsck_usage() MSG(0, " --debug-cache to debug cache when -c is used\n"); MSG(0, " --thread-number [number]. Indicate the thread number [default:1]\n"); MSG(0, " --free-thread [number]. Indicate the thread number in free pool. [default:1]\n"); + MSG(0, " --no-scheduler. Disabled feature: dynamic adjust thread number. [default:1]\n"); exit(1); } @@ -242,6 +243,7 @@ void f2fs_parse_options(int argc, char *argv[]) {"debug-cache", no_argument, 0, 4}, {"thread-number", required_argument, 0, 5}, {"free-thread", required_argument, 0, 6}, + {"no-scheduler", no_argument, 0, 7}, {0, 0, 0, 0} }; @@ -272,6 +274,9 @@ void f2fs_parse_options(int argc, char *argv[]) case 6: c.free_thread = atoi(optarg); break; + case 7: + c.feature_no_scheduler = true; + break; case 'a': c.auto_fix = 1; MSG(0, "Info: Fix the reported corruption.\n"); diff --git a/src/f2fs-tools/fsck/mount.c b/src/f2fs-tools/fsck/mount.c index 09523c2842d9506b7f6ea5a855f86b6da0712e70..879dd8deabbe5b74199f114dd0aa326fc0c28981 100644 --- a/src/f2fs-tools/fsck/mount.c +++ b/src/f2fs-tools/fsck/mount.c @@ -1017,8 +1017,8 @@ int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr) if (!sanity_check_raw_super(sbi->raw_super, sb_addr)) { /* get kernel version */ - if (c.kd >= 0) { // c.kd 指å‘待检查设备的fd - dev_read_version(c.version, 0, VERSION_NAME_LEN); // 设备的å‰252个å—节竟然ä¿å˜äº†kernel版本 + if (c.kd >= 0) { // c.kd æŒ‡å‘ /proc/version + dev_read_version(c.version, 0, VERSION_NAME_LEN); get_kernel_version(c.version); } else { get_kernel_uname_version(c.version); diff --git a/src/f2fs-tools/include/f2fs_fs.h b/src/f2fs-tools/include/f2fs_fs.h index 37035d3703ed4598c6d5281764766f030dd11a8f..ce4301556ddcffedb0995bff8329dd2570aa84ad 100644 --- a/src/f2fs-tools/include/f2fs_fs.h +++ b/src/f2fs-tools/include/f2fs_fs.h @@ -462,6 +462,7 @@ typedef struct { struct f2fs_configuration { uint32_t thread_number; // how many thread do you want to make? default is 1 uint32_t free_thread; // how many thread in the free pool? default is 1 + bool feature_no_scheduler; // disabled feature: dynamic adjust thread number uint32_t reserved_segments; uint32_t new_reserved_segments; int sparse_mode; @@ -1272,7 +1273,7 @@ enum { NAT_JOURNAL = 0, SIT_JOURNAL }; - +// 4+9=13 bytes struct nat_journal_entry { __le32 nid; struct f2fs_nat_entry ne; @@ -1615,8 +1616,8 @@ int f2fs_reset_zone(int, void *); extern int f2fs_reset_zones(int); extern uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb); -#define SIZE_ALIGN(val, size) (((val) + (size) - 1) / (size)) -#define SEG_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg) +#define SIZE_ALIGN(val, size) (((val) + (size) - 1) / (size)) // val对sizeå‘上å–æ•´ +#define SEG_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg) // blks对segment(512个block)å‘上å–æ•´ #define ZONE_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg * \ c.segs_per_zone) diff --git a/src/f2fs-tools/lib/libf2fs.c b/src/f2fs-tools/lib/libf2fs.c index 28ab0062310ea55df90c04578928e79d7a584e15..aceb2f3e473165fd8e4db216702fdf1a00e7f769 100644 --- a/src/f2fs-tools/lib/libf2fs.c +++ b/src/f2fs-tools/lib/libf2fs.c @@ -706,6 +706,7 @@ void f2fs_init_configuration(void) /* thread management */ c.thread_number = 1; c.free_thread = 1; + c.feature_no_scheduler = false; } int f2fs_dev_is_writable(void)