From 489a3614a3c7a0cf0eb4ea0d8ed65d86a61edc05 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Tue, 29 Mar 2022 19:41:23 -0400 Subject: [PATCH] LU-14719 utils: dir migration stop on error Once directory migration fails, it should stop immediately since current migration won't succceed, and subsequent migration may fail on the same error. Lustre-change: https://review.whamcloud.com/47040/ Lustre-commit: 9ca348e8769d2c613082eeaeaf2775e22625e970 Signed-off-by: Lai Siyao Change-Id: I96c1693d1b1da0856c925b9b22c1ab7f3181f0d8 Reviewed-on: https://review.whamcloud.com/47868 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Qian Yingjin Reviewed-by: Andreas Dilger --- lustre/include/lustre/lustreapi.h | 9 ++++----- lustre/utils/liblustreapi.c | 9 ++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index 0b2de92..1ed37d1 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -322,11 +322,10 @@ struct find_param { fp_newerxy:1, fp_exclude_btime:1, fp_unused_bit3:1, /* All of these unused bit */ - fp_unused_bit4:1, /* fields available to use.*/ - fp_unused_bit5:1, /* Once all unused fields */ - fp_unused_bit6:1, /* are used we need to add */ - fp_unused_bit7:1; /* a separate flag field at*/ - /* the end of the struct. */ + fp_stop_on_error:1, /* stop iteration on error */ + fp_unused_bit5:1, /* are used we need to add */ + fp_unused_bit6:1, /* a separate flag field at*/ + fp_unused_bit7:1; /* the end of the struct. */ enum llapi_layout_verbose fp_verbose; int fp_quiet; diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 06fdae2..9f7a695 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2224,9 +2224,12 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent, break; case DT_DIR: rc = llapi_semantic_traverse(path, size, d, sem_init, - sem_fini, data, dent); + sem_fini, data, dent); if (rc != 0 && ret == 0) ret = rc; + if (rc < 0 && rc != -EALREADY && + param->fp_stop_on_error) + goto out; break; default: rc = 0; @@ -2234,6 +2237,9 @@ static int llapi_semantic_traverse(char *path, int size, DIR *parent, rc = sem_init(path, d, NULL, data, dent); if (rc < 0 && ret == 0) { ret = rc; + if (rc && rc != -EALREADY && + param->fp_stop_on_error) + goto out; break; } } @@ -6044,6 +6050,7 @@ out: int llapi_migrate_mdt(char *path, struct find_param *param) { + param->fp_stop_on_error = 1; return param_callback(path, cb_migrate_mdt_init, cb_migrate_mdt_fini, param); } -- 1.8.3.1