From 7648c1c905b0976fc789cfd9c6bac382389385ee Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Fri, 16 Jul 2021 02:20:54 +0800 Subject: [PATCH] LU-14854 mdd: proper handle error in mdd_swap_layouts() Only restore object's HSM xattr on error if it's for SWAP_LAYOUTS_MDS_HSM. Signed-off-by: Bobi Jam Change-Id: I9d4c58cd3107c3900e72a0946d0ec7d7286dd43f Reviewed-on: https://review.whamcloud.com/44319 Reviewed-by: Andreas Dilger Reviewed-by: Lai Siyao Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_object.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 3742191..e431fdf 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -2714,13 +2714,17 @@ out_restore: if (rc2 < 0) goto do_lbug; - ++steps; - rc2 = mdd_xattr_hsm_replace(env, fst_o, fst_hsm_buf, handle); - if (rc2 < 0) - goto do_lbug; + if (flags & SWAP_LAYOUTS_MDS_HSM) { + ++steps; + rc2 = mdd_xattr_hsm_replace(env, fst_o, fst_hsm_buf, + handle); + if (rc2 < 0) + goto do_lbug; - ++steps; - rc2 = mdd_xattr_hsm_replace(env, snd_o, snd_hsm_buf, handle); + ++steps; + rc2 = mdd_xattr_hsm_replace(env, snd_o, snd_hsm_buf, + handle); + } do_lbug: if (rc2 < 0) { -- 1.8.3.1