From 9ca348e8769d2c613082eeaeaf2775e22625e970 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. Signed-off-by: Lai Siyao Change-Id: I96c1693d1b1da0856c925b9b22c1ab7f3181f0d8 Reviewed-on: https://review.whamcloud.com/47040 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yingjin Qian Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustreapi.h | 2 +- lustre/utils/liblustreapi.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lustre/include/lustre/lustreapi.h b/lustre/include/lustre/lustreapi.h index caaa780..84b01e3 100644 --- a/lustre/include/lustre/lustreapi.h +++ b/lustre/include/lustre/lustreapi.h @@ -341,7 +341,7 @@ struct find_param { fp_newerxy:1, fp_exclude_btime:1, fp_exclude_perm:1, - fp_unused_bit4:1, /* Once all unused fields */ + 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. */ diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 4d4b1f1..1cd3b5b 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -2269,9 +2269,12 @@ static int llapi_semantic_traverse(char *path, int size, int 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; @@ -2279,6 +2282,9 @@ static int llapi_semantic_traverse(char *path, int size, int 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; } } @@ -6076,6 +6082,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