From cd58a3bf6f66feff79728a65e7a416818b23c204 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 27 Apr 2017 10:23:26 -0500 Subject: [PATCH] LU-9403 mdt: prevent HSM leak on re-archive In mdt_hsm_is_action_compat() if the file to be archived already exists in some backend archive then ensure that the re-archive uses the same backend archive. Signed-off-by: John L. Hammond Change-Id: Ifc0ef03264a20557c31df7add9e34a1dc1f0c814 Reviewed-on: https://review.whamcloud.com/26866 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Henri Doreau Reviewed-by: Faccini Bruno Reviewed-by: Quentin Bouget Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_coordinator.c | 10 ++++++++-- lustre/mdt/mdt_internal.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 5637ffb..7156c7d 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -1660,13 +1660,13 @@ out_env: /** * check if a request is compatible with file status * \param hai [IN] request description - * \param hal_an [IN] request archive number (not used) + * \param archive_id [IN] request archive id * \param rq_flags [IN] request flags * \param hsm [IN] file HSM metadata * \retval boolean */ bool mdt_hsm_is_action_compat(const struct hsm_action_item *hai, - const int hal_an, const __u64 rq_flags, + u32 archive_id, u64 rq_flags, const struct md_hsm *hsm) { int is_compat = false; @@ -1679,6 +1679,12 @@ bool mdt_hsm_is_action_compat(const struct hsm_action_item *hai, if (!(hsm_flags & HS_NOARCHIVE) && (hsm_flags & HS_DIRTY || !(hsm_flags & HS_ARCHIVED))) is_compat = true; + + if (hsm_flags & HS_EXISTS && + archive_id != 0 && + archive_id != hsm->mh_arch_id) + is_compat = false; + break; case HSMA_RESTORE: if (!(hsm_flags & HS_DIRTY) && (hsm_flags & HS_RELEASED) && diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 89d89ac..9ddf663 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -876,7 +876,7 @@ struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti, int mdt_hsm_add_hal(struct mdt_thread_info *mti, struct hsm_action_list *hal, struct obd_uuid *uuid); bool mdt_hsm_is_action_compat(const struct hsm_action_item *hai, - const int hal_an, const __u64 rq_flags, + u32 archive_id, u64 rq_flags, const struct md_hsm *hsm); int mdt_hsm_update_request_state(struct mdt_thread_info *mti, struct hsm_progress_kernel *pgs, -- 1.8.3.1