From: Fan Yong Date: Sat, 5 Apr 2014 02:26:00 +0000 (+0800) Subject: LU-4955 lfsck: reset param when the LFSCK is reset X-Git-Tag: 2.5.59~25 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=cb22837bcded8f95461c0d4760b2b9add0956e71 LU-4955 lfsck: reset param when the LFSCK is reset If "--reset" or "-r" is specified when start the LFSCK manually, then all non-specified parameters will be set as default values. If the former LFSCK instance completed, then when re-trigger the LFSCK, it will restart from the beginning, and all non-specified parameters will be set as default values. Change the "window" option in lfsck_start to "window_size". Update the lctl manpage for LFSCK. Signed-off-by: James Nunez Signed-off-by: Fan Yong Change-Id: I5b1d7dd2507ab2f50e152f5a839bf9544a9dc255 Reviewed-on: http://review.whamcloud.com/10091 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Lai Siyao --- diff --git a/lustre/doc/lctl.8 b/lustre/doc/lctl.8 index a9bc9a0..466ad3c 100644 --- a/lustre/doc/lctl.8 +++ b/lustre/doc/lctl.8 @@ -299,21 +299,27 @@ next minimum. An on-line Lustre consistency check and repair tool. .TP .B lfsck_start \fR<-M | --device [MDT,OST]_device> - \fR[-e | --error ] - \fR[-h | --help] - \fR[-n | --dryrun ] - \fR[-r | --reset] - \fR[-s | --speed ] - \fR[-A | --all] - \fR[-t | --type ] - \fR[-w | --windows ] - \fR[-o | --orphan] + \fR[-A | --all] [-c | --create_ostobj [on | off]] + \fR[-e | --error ] [-h | --help] + \fR[-n | --dryrun [on | off]] [-o | --orphan] + \fR[-r | --reset] [-s | --speed speed_limit] + \fR[-t | --type lfsck_type[,lfsck_type...]] + \fR[-w | --window_size size] .br Start LFSCK on the specified MDT or OST device with specified parameters. .TP -M, --device The MDT or OST device to start LFSCK/scrub on. .TP + -A, --all +Start LFSCK on all MDT devices. +.TP + -c, --create_ostobj [on | off] +Create the lost OST-object for dangling LOV EA: 'off'(default) or 'on'. Under +default mode, when the LFSCK find some MDT-object with dangling reference, it +will report the inconsistency but without repairing. Otherwise the LFSCK will +re-create the missed OST-object. +.TP -e, --error With error_handle as 'abort' LFSCK will stop if a repair is impossible. If no value is specified, the saved value will be used if resuming from a checkpoint. @@ -322,22 +328,23 @@ Otherwise the default behavior is to 'continue' if a repair is impossible. -h, --help Show this help. .TP - -n, --dryrun + -n, --dryrun [on | off] Perform a trial run with no changes made. Default is 'off' .TP + -o, --orphan +Handle orphan objects, such as orphan OST-objects for layout LFSCK. +.TP -r, --reset Set the current position of object iteration to the beginning of the specified -MDT. By default the iterator will resume scanning from the last checkpoint -(saved periodically by LFSCK) provided it is available. +device. The non-specified parameters will also be reset as default. By default +the iterator will resume the scanning from the last checkpoint (position), and +other non-specified parameters will be the same as former non-completed run. .TP -s, --speed Set the upper limit of LFSCK processing in objects per second. If no value is specified the saved value is used (if resuming from a check point). Otherwise the default value of 0 is used. 0 means run as fast as possible. .TP - -A, --all -Start LFSCK on all devices. -.TP -t, --type The type of LFSCK checking/repair to execute. By default, the LFSCK component(s) which ran last time and did not finish or the component(s) @@ -346,15 +353,10 @@ LFSCK is triggered on an ldiskfs MDT or OST, the OI Scrub is executed. Alternative types include FID-in-dirent and linkEA (namespace) and MDT-OST inconsistency (layout). .TP - -w, --windows + -w, --window_size The window size for async requests pipeline. .TP - -o, --orphan -Handle orphan objects, such as orphan OST-objects for layout LFSCK. -.TP -.B lfsck_stop \fR<-M | --device [MDT,OST]_device> - \fR[-A | --all] - \fR[-h | --help] +.B lfsck_stop \fR<-M | --device [MDT,OST]_device> [-A | --all] [-h | --help] Stop LFSCK on the specified MDT or OST device. .TP -M, --device <[MDT,OST]_device> diff --git a/lustre/lfsck/lfsck_bookmark.c b/lustre/lfsck/lfsck_bookmark.c index cf0e552..cf31418 100644 --- a/lustre/lfsck/lfsck_bookmark.c +++ b/lustre/lfsck/lfsck_bookmark.c @@ -196,3 +196,130 @@ int lfsck_bookmark_setup(const struct lu_env *env, RETURN(rc); } + +int lfsck_set_param(const struct lu_env *env, struct lfsck_instance *lfsck, + struct lfsck_start *start, bool reset) +{ + struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram; + int rc = 0; + bool dirty = false; + + if (start == NULL) { + LASSERT(reset); + + if (bk->lb_param & LPF_ALL_TGT) { + bk->lb_param &= ~LPF_ALL_TGT; + dirty = true; + } + + if (bk->lb_param & LPF_CREATE_OSTOBJ) { + bk->lb_param &= ~LPF_CREATE_OSTOBJ; + dirty = true; + } + + if (bk->lb_param & LPF_FAILOUT) { + bk->lb_param &= ~LPF_FAILOUT; + dirty = true; + } + + if (bk->lb_param & LPF_DRYRUN) { + bk->lb_param &= ~LPF_DRYRUN; + dirty = true; + } + + if (bk->lb_param & LPF_ORPHAN) { + bk->lb_param &= ~LPF_ORPHAN; + dirty = true; + } + + if (__lfsck_set_speed(lfsck, LFSCK_SPEED_NO_LIMIT)) + dirty = true; + + if (bk->lb_async_windows != LFSCK_ASYNC_WIN_DEFAULT) { + bk->lb_async_windows = LFSCK_ASYNC_WIN_DEFAULT; + dirty = true; + } + } else { + if ((bk->lb_param & LPF_ALL_TGT) && + !(start->ls_flags & LPF_ALL_TGT)) { + bk->lb_param &= ~LPF_ALL_TGT; + dirty = true; + } else if (!(bk->lb_param & LPF_ALL_TGT) && + (start->ls_flags & LPF_ALL_TGT)) { + bk->lb_param |= LPF_ALL_TGT; + dirty = true; + } + + if ((start->ls_valid & LSV_CREATE_OSTOBJ) || reset) { + if ((bk->lb_param & LPF_CREATE_OSTOBJ) && + !(start->ls_valid & LSV_CREATE_OSTOBJ)) { + bk->lb_param &= ~LPF_CREATE_OSTOBJ; + dirty = true; + } else if (!(bk->lb_param & LPF_CREATE_OSTOBJ) && + (start->ls_flags & LPF_CREATE_OSTOBJ)) { + bk->lb_param |= LPF_CREATE_OSTOBJ; + dirty = true; + } + } + + if ((start->ls_valid & LSV_ERROR_HANDLE) || reset) { + if ((bk->lb_param & LPF_FAILOUT) && + !(start->ls_valid & LSV_ERROR_HANDLE)) { + bk->lb_param &= ~LPF_FAILOUT; + dirty = true; + } else if (!(start->ls_flags & LPF_FAILOUT) && + (bk->lb_param & LPF_FAILOUT)) { + bk->lb_param &= ~LPF_FAILOUT; + dirty = true; + } + } + + if ((start->ls_valid & LSV_DRYRUN) || reset) { + if ((bk->lb_param & LPF_DRYRUN) && + !(start->ls_valid & LSV_DRYRUN)) { + bk->lb_param &= ~LPF_DRYRUN; + dirty = true; + } else if (!(start->ls_flags & LPF_DRYRUN) && + (bk->lb_param & LPF_DRYRUN)) { + bk->lb_param &= ~LPF_DRYRUN; + lfsck->li_drop_dryrun = 1; + dirty = true; + } + } + + if ((bk->lb_param & LPF_ORPHAN) && + !(start->ls_flags & LPF_ORPHAN)) { + bk->lb_param &= ~LPF_ORPHAN; + dirty = true; + } else if (!(bk->lb_param & LPF_ORPHAN) && + (start->ls_flags & LPF_ORPHAN)) { + bk->lb_param |= LPF_ORPHAN; + dirty = true; + } + + if (start->ls_valid & LSV_SPEED_LIMIT) { + if (__lfsck_set_speed(lfsck, start->ls_speed_limit)) + dirty = true; + } else if (reset) { + if (__lfsck_set_speed(lfsck, LFSCK_SPEED_NO_LIMIT)) + dirty = true; + } + + if (start->ls_valid & LSV_ASYNC_WINDOWS) { + if (bk->lb_async_windows != start->ls_async_windows) { + bk->lb_async_windows = start->ls_async_windows; + dirty = true; + } + } else if (reset && + bk->lb_async_windows != LFSCK_ASYNC_WIN_DEFAULT) { + bk->lb_async_windows = LFSCK_ASYNC_WIN_DEFAULT; + dirty = true; + } + } + + if (dirty) + rc = lfsck_bookmark_store(env, lfsck); + + return rc; +} + diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h index 46ebe84..24b84ae 100644 --- a/lustre/lfsck/lfsck_internal.h +++ b/lustre/lfsck/lfsck_internal.h @@ -597,6 +597,7 @@ int lfsck_pos_dump(char **buf, int *len, struct lfsck_position *pos, const char *prefix); void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck, struct lfsck_position *pos, bool init); +bool __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit); void lfsck_control_speed(struct lfsck_instance *lfsck); void lfsck_control_speed_by_self(struct lfsck_component *com); int lfsck_reset(const struct lu_env *env, struct lfsck_instance *lfsck, @@ -634,6 +635,8 @@ int lfsck_bookmark_store(const struct lu_env *env, struct lfsck_instance *lfsck); int lfsck_bookmark_setup(const struct lu_env *env, struct lfsck_instance *lfsck); +int lfsck_set_param(const struct lu_env *env, struct lfsck_instance *lfsck, + struct lfsck_start *start, bool reset); /* lfsck_namespace.c */ int lfsck_namespace_setup(const struct lu_env *env, diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 9cc0192..f4153e8 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -4218,6 +4218,9 @@ static int lfsck_layout_prep(const struct lu_env *env, int rc; rc = lfsck_layout_reset(env, com, false); + if (rc == 0) + rc = lfsck_set_param(env, lfsck, start, true); + if (rc != 0) return rc; } diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c index 85d3928..1f85e1a 100644 --- a/lustre/lfsck/lfsck_lib.c +++ b/lustre/lfsck/lfsck_lib.c @@ -1021,9 +1021,10 @@ void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck, } } -static void __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit) +bool __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit) { - lfsck->li_bookmark_ram.lb_speed_limit = limit; + bool dirty = false; + if (limit != LFSCK_SPEED_NO_LIMIT) { if (limit > HZ) { lfsck->li_sleep_rate = limit / HZ; @@ -1036,6 +1037,13 @@ static void __lfsck_set_speed(struct lfsck_instance *lfsck, __u32 limit) lfsck->li_sleep_jif = 0; lfsck->li_sleep_rate = 0; } + + if (lfsck->li_bookmark_ram.lb_speed_limit != limit) { + lfsck->li_bookmark_ram.lb_speed_limit = limit; + dirty = true; + } + + return dirty; } void lfsck_control_speed(struct lfsck_instance *lfsck) @@ -1696,8 +1704,8 @@ int lfsck_set_speed(struct dt_device *key, int val) lfsck = lfsck_instance_find(key, true, false); if (likely(lfsck != NULL)) { mutex_lock(&lfsck->li_mutex); - __lfsck_set_speed(lfsck, val); - rc = lfsck_bookmark_store(&env, lfsck); + if (__lfsck_set_speed(lfsck, val)) + rc = lfsck_bookmark_store(&env, lfsck); mutex_unlock(&lfsck->li_mutex); lfsck_instance_put(&env, lfsck); } else { @@ -1750,12 +1758,12 @@ int lfsck_set_windows(struct dt_device *key, int val) lfsck = lfsck_instance_find(key, true, false); if (likely(lfsck != NULL)) { if (val > LFSCK_ASYNC_WIN_MAX) { - CERROR("%s: Too large async windows size, which " - "may cause memory issues. The valid range " - "is [0 - %u]. If you do not want to restrict " - "the windows size for async requests pipeline, " - "just set it as 0.\n", - lfsck_lfsck2name(lfsck), LFSCK_ASYNC_WIN_MAX); + CWARN("%s: Too large async window size, which " + "may cause memory issues. The valid range " + "is [0 - %u]. If you do not want to restrict " + "the window size for async requests pipeline, " + "just set it as 0.\n", + lfsck_lfsck2name(lfsck), LFSCK_ASYNC_WIN_MAX); rc = -EINVAL; } else if (lfsck->li_bookmark_ram.lb_async_windows != val) { mutex_lock(&lfsck->li_mutex); @@ -2006,7 +2014,6 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, struct lfsck_component *com; struct l_wait_info lwi = { 0 }; struct lfsck_thread_args *lta; - bool dirty = false; long rc = 0; __u16 valid = 0; __u16 flags = 0; @@ -2080,90 +2087,6 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, } start->ls_version = bk->lb_version; - if (start->ls_valid & LSV_SPEED_LIMIT) { - __lfsck_set_speed(lfsck, start->ls_speed_limit); - dirty = true; - } - - if (start->ls_valid & LSV_ASYNC_WINDOWS && - bk->lb_async_windows != start->ls_async_windows) { - bk->lb_async_windows = start->ls_async_windows; - dirty = true; - } - - if (start->ls_valid & LSV_ERROR_HANDLE) { - valid |= DOIV_ERROR_HANDLE; - if (start->ls_flags & LPF_FAILOUT) - flags |= DOIF_FAILOUT; - - if ((start->ls_flags & LPF_FAILOUT) && - !(bk->lb_param & LPF_FAILOUT)) { - bk->lb_param |= LPF_FAILOUT; - dirty = true; - } else if (!(start->ls_flags & LPF_FAILOUT) && - (bk->lb_param & LPF_FAILOUT)) { - bk->lb_param &= ~LPF_FAILOUT; - dirty = true; - } - } - - if (start->ls_valid & LSV_DRYRUN) { - valid |= DOIV_DRYRUN; - if (start->ls_flags & LPF_DRYRUN) - flags |= DOIF_DRYRUN; - - if ((start->ls_flags & LPF_DRYRUN) && - !(bk->lb_param & LPF_DRYRUN)) { - bk->lb_param |= LPF_DRYRUN; - dirty = true; - } else if (!(start->ls_flags & LPF_DRYRUN) && - (bk->lb_param & LPF_DRYRUN)) { - bk->lb_param &= ~LPF_DRYRUN; - lfsck->li_drop_dryrun = 1; - dirty = true; - } - } - - if (bk->lb_param & LPF_ALL_TGT && - !(start->ls_flags & LPF_ALL_TGT)) { - bk->lb_param &= ~LPF_ALL_TGT; - dirty = true; - } else if (!(bk->lb_param & LPF_ALL_TGT) && - start->ls_flags & LPF_ALL_TGT) { - bk->lb_param |= LPF_ALL_TGT; - dirty = true; - } - - if (bk->lb_param & LPF_ORPHAN && - !(start->ls_flags & LPF_ORPHAN)) { - bk->lb_param &= ~LPF_ORPHAN; - dirty = true; - } else if (!(bk->lb_param & LPF_ORPHAN) && - start->ls_flags & LPF_ORPHAN) { - bk->lb_param |= LPF_ORPHAN; - dirty = true; - } - - if (start->ls_valid & LSV_CREATE_OSTOBJ) { - if (bk->lb_param & LPF_CREATE_OSTOBJ && - !(start->ls_flags & LPF_CREATE_OSTOBJ)) { - bk->lb_param &= ~LPF_CREATE_OSTOBJ; - dirty = true; - } else if (!(bk->lb_param & LPF_CREATE_OSTOBJ) && - start->ls_flags & LPF_CREATE_OSTOBJ) { - bk->lb_param |= LPF_CREATE_OSTOBJ; - dirty = true; - } - } - - if (dirty) { - rc = lfsck_bookmark_store(env, lfsck); - if (rc != 0) - GOTO(out, rc); - } - - if (start->ls_flags & LPF_RESET) - flags |= DOIF_RESET; if (start->ls_active != 0) { struct lfsck_component *next; @@ -2176,8 +2099,8 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, GOTO(out, rc = -ENOTSUPP); } - cfs_list_for_each_entry_safe(com, next, - &lfsck->li_list_scan, lc_link) { + list_for_each_entry_safe(com, next, + &lfsck->li_list_scan, lc_link) { if (!(com->lc_type & start->ls_active)) { rc = com->lc_ops->lfsck_post(env, com, 0, false); @@ -2194,9 +2117,9 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, /* The component status will be updated * when its prep() is called later by * the LFSCK main engine. */ - cfs_list_del_init(&com->lc_link); - cfs_list_add_tail(&com->lc_link, - &lfsck->li_list_scan); + list_del_init(&com->lc_link); + list_add_tail(&com->lc_link, + &lfsck->li_list_scan); } start->ls_active &= ~type; } @@ -2204,7 +2127,28 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, } } - cfs_list_for_each_entry(com, &lfsck->li_list_scan, lc_link) { + if (list_empty(&lfsck->li_list_scan)) { + /* The speed limit will be used to control both the LFSCK and + * low layer scrub (if applied), need to be handled firstly. */ + if (start->ls_valid & LSV_SPEED_LIMIT) { + if (__lfsck_set_speed(lfsck, start->ls_speed_limit)) { + rc = lfsck_bookmark_store(env, lfsck); + if (rc != 0) + GOTO(out, rc); + } + } + + goto trigger; + } + + if (start->ls_flags & LPF_RESET) + flags |= DOIF_RESET; + + rc = lfsck_set_param(env, lfsck, start, !!(flags & DOIF_RESET)); + if (rc != 0) + GOTO(out, rc); + + list_for_each_entry(com, &lfsck->li_list_scan, lc_link) { start->ls_active |= com->lc_type; if (flags & DOIF_RESET) { rc = com->lc_ops->lfsck_reset(env, com, false); @@ -2215,18 +2159,22 @@ int lfsck_start(const struct lu_env *env, struct dt_device *key, trigger: lfsck->li_args_dir = LUDA_64BITHASH | LUDA_VERIFY; - if (bk->lb_param & LPF_DRYRUN) { + if (bk->lb_param & LPF_DRYRUN) lfsck->li_args_dir |= LUDA_VERIFY_DRYRUN; - valid |= DOIV_DRYRUN; - flags |= DOIF_DRYRUN; - } - if (bk->lb_param & LPF_FAILOUT) { + if (start != NULL && start->ls_valid & LSV_ERROR_HANDLE) { valid |= DOIV_ERROR_HANDLE; - flags |= DOIF_FAILOUT; + if (start->ls_flags & LPF_FAILOUT) + flags |= DOIF_FAILOUT; + } + + if (start != NULL && start->ls_valid & LSV_DRYRUN) { + valid |= DOIV_DRYRUN; + if (start->ls_flags & LPF_DRYRUN) + flags |= DOIF_DRYRUN; } - if (!cfs_list_empty(&lfsck->li_list_scan)) + if (!list_empty(&lfsck->li_list_scan)) flags |= DOIF_OUTUSED; lfsck->li_args_oit = (flags << DT_OTABLE_IT_FLAGS_SHIFT) | valid; @@ -2235,6 +2183,7 @@ trigger: if (IS_ERR(lta)) GOTO(out, rc = PTR_ERR(lta)); + __lfsck_set_speed(lfsck, bk->lb_speed_limit); rc = PTR_ERR(kthread_run(lfsck_master_engine, lta, "lfsck")); if (IS_ERR_VALUE(rc)) { CERROR("%s: cannot start LFSCK thread: rc = %ld\n", diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c index 92e77cb..74a6cfc 100644 --- a/lustre/lfsck/lfsck_namespace.c +++ b/lustre/lfsck/lfsck_namespace.c @@ -767,6 +767,9 @@ static int lfsck_namespace_prep(const struct lu_env *env, int rc; rc = lfsck_namespace_reset(env, com, false); + if (rc == 0) + rc = lfsck_set_param(env, lfsck, lsp->lsp_start, true); + if (rc != 0) return rc; } diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c index d830e22..cc0d8b7 100644 --- a/lustre/osd-ldiskfs/osd_scrub.c +++ b/lustre/osd-ldiskfs/osd_scrub.c @@ -2013,8 +2013,15 @@ again: } spin_unlock(&scrub->os_lock); - if (scrub->os_file.sf_status == SS_COMPLETED) + if (scrub->os_file.sf_status == SS_COMPLETED) { + if (!(flags & SS_SET_FAILOUT)) + flags |= SS_CLEAR_FAILOUT; + + if (!(flags & SS_SET_DRYRUN)) + flags |= SS_CLEAR_DRYRUN; + flags |= SS_RESET; + } scrub->os_start_flags = flags; thread_set_flags(thread, 0); diff --git a/lustre/tests/sanity-scrub.sh b/lustre/tests/sanity-scrub.sh index 62f3779..a3db966 100644 --- a/lustre/tests/sanity-scrub.sh +++ b/lustre/tests/sanity-scrub.sh @@ -909,16 +909,16 @@ test_15() { # run under normal mode # # Lustre-2.x (x <= 5) used "-n off" to disable dryrun which does not - # work under Lustre-2.y (y >=6), the test scripts should be fixed as - # "-noff" or "--dryrun=off". - scrub_start 15 --dryrun=off + # work under Lustre-2.y (y >= 6), the test script should be fixed as + # "-noff" or "--dryrun=off" or nothing by default. + scrub_start 15 scrub_check_status 16 completed scrub_check_flags 17 "" scrub_check_params 18 "" scrub_check_repaired 19 20 # run under normal mode again - scrub_start 20 --dryrun=off + scrub_start 20 scrub_check_status 21 completed scrub_check_flags 22 "" scrub_check_params 23 "" diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index 5c6892c..261da54 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -383,12 +383,12 @@ command_t cmdlist[] = { {"==== LFSCK ====", jt_noop, 0, "LFSCK"}, {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n" "usage: lfsck_start <-M | --device [MDT,OST]_device>\n" - " [-A | --all] [-c | --create_ostobj [swtich]]\n" - " [-e | --error error_handle] [-h | --help]\n" - " [-n | --dryrun [switch]] [-o | --orphan]\n" + " [-A | --all] [-c | --create_ostobj [on | off]]\n" + " [-e | --error {continue | abort}] [-h | --help]\n" + " [-n | --dryrun [on | off]] [-o | --orphan]\n" " [-r | --reset] [-s | --speed speed_limit]\n" " [-t | --type lfsck_type[,lfsck_type...]]\n" - " [-w | --windows win_size]"}, + " [-w | --window_size size]"}, {"lfsck_stop", jt_lfsck_stop, 0, "stop lfsck(s)\n" "usage: lfsck_stop <-M | --device [MDT,OST]_device>\n" " [-A | --all] [-h | --help]"}, diff --git a/lustre/utils/lustre_lfsck.c b/lustre/utils/lustre_lfsck.c index 4f04f02..b698a08 100644 --- a/lustre/utils/lustre_lfsck.c +++ b/lustre/utils/lustre_lfsck.c @@ -56,7 +56,7 @@ static struct option long_opt_start[] = { {"reset", no_argument, 0, 'r'}, {"speed", required_argument, 0, 's'}, {"type", required_argument, 0, 't'}, - {"windows", required_argument, 0, 'w'}, + {"window_size", required_argument, 0, 'w'}, {0, 0, 0, 0 } }; @@ -97,26 +97,27 @@ static void usage_start(void) fprintf(stderr, "Start LFSCK.\n" "SYNOPSIS:\n" "lfsck_start <-M | --device [MDT,OST]_device>\n" - " [-A | --all] [-c | --create_ostobj [swtich]]\n" - " [-e | --error error_handle] [-h | --help]\n" - " [-n | --dryrun [switch]] [-o | --orphan]\n" + " [-A | --all] [-c | --create_ostobj [on | off]]\n" + " [-e | --error {continue | abort}] [-h | --help]\n" + " [-n | --dryrun [on | off]] [-o | --orphan]\n" " [-r | --reset] [-s | --speed speed_limit]\n" " [-t | --type lfsck_type[,lfsck_type...]]\n" - " [-w | --windows win_size]\n" + " [-w | --window_size size]\n" "OPTIONS:\n" "-M: The device to start LFSCK/scrub on.\n" "-A: Start LFSCK on all MDT devices.\n" - "-c: create the lost OST-object for dangling LOV EA. " + "-c: Create the lost OST-object for dangling LOV EA: " "'off'(default) or 'on'.\n" "-e: Error handle, 'continue'(default) or 'abort'.\n" "-h: Help information.\n" "-n: Check without modification. 'off'(default) or 'on'.\n" - "-o: handle orphan objects.\n" + "-o: Handle orphan objects.\n" "-r: Reset scanning start position to the device beginning.\n" + " The non-specified parameters will be reset as default.\n" "-s: How many items can be scanned at most per second. " "'%d' means no limit (default).\n" "-t: The LFSCK type(s) to be started.\n" - "-w: The windows size for async requests pipeline.\n", + "-w: The window size for async requests pipeline.\n", LFSCK_SPEED_NO_LIMIT); } @@ -155,7 +156,7 @@ int jt_lfsck_start(int argc, char **argv) char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; char device[MAX_OBD_NAME]; struct lfsck_start start; - char *optstring = "M:Ac::e:hn::ors:t:w:"; + char *optstring = "Ac::e:hM:n::ors:t:w:"; int opt, index, rc, val, i, type; memset(&data, 0, sizeof(data)); @@ -170,11 +171,6 @@ int jt_lfsck_start(int argc, char **argv) while ((opt = getopt_long(argc, argv, optstring, long_opt_start, &index)) != EOF) { switch (opt) { - case 'M': - rc = lfsck_pack_dev(&data, device, optarg); - if (rc != 0) - return rc; - break; case 'A': start.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST; break; @@ -205,6 +201,11 @@ int jt_lfsck_start(int argc, char **argv) case 'h': usage_start(); return 0; + case 'M': + rc = lfsck_pack_dev(&data, device, optarg); + if (rc != 0) + return rc; + break; case 'n': if (optarg == NULL || strcmp(optarg, "on") == 0) { start.ls_flags |= LPF_DRYRUN; @@ -274,11 +275,11 @@ int jt_lfsck_start(int argc, char **argv) val = atoi(optarg); if (val < 0 || val > LFSCK_ASYNC_WIN_MAX) { fprintf(stderr, - "Too large async windows size, " + "Too large async window size, " "which may cause memory issues. " "The valid range is [0 - %u]. " "If you do not want to restrict " - "the windows size for async reqeusts " + "the window size for async reqeusts " "pipeline, just set it as 0.\n", LFSCK_ASYNC_WIN_MAX); return -EINVAL; @@ -346,7 +347,7 @@ int jt_lfsck_stop(int argc, char **argv) char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf; char device[MAX_OBD_NAME]; struct lfsck_stop stop; - char *optstring = "M:Ah"; + char *optstring = "AhM:"; int opt, index, rc; memset(&data, 0, sizeof(data)); @@ -359,17 +360,17 @@ int jt_lfsck_stop(int argc, char **argv) while ((opt = getopt_long(argc, argv, optstring, long_opt_stop, &index)) != EOF) { switch (opt) { - case 'M': - rc = lfsck_pack_dev(&data, device, optarg); - if (rc != 0) - return rc; - break; case 'A': stop.ls_flags |= LPF_ALL_TGT | LPF_BROADCAST; break; case 'h': usage_stop(); return 0; + case 'M': + rc = lfsck_pack_dev(&data, device, optarg); + if (rc != 0) + return rc; + break; default: fprintf(stderr, "Invalid option, '-h' for help.\n"); return -EINVAL;