From 77a60b06f4538e8dc88897f8703d2f242f215990 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 27 Apr 2017 10:39:11 -0500 Subject: [PATCH] LU-9404 mdt: set HSM xattr only when needed In mdt_hsm_add_hal() avoid setting the HSM xattr when the HSM attributes have not changed. Signed-off-by: John L. Hammond Change-Id: I12570034127b9928e49ea329bf77b674aaa6ade8 Reviewed-on: https://review.whamcloud.com/26867 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Frank Zago Reviewed-by: Faccini Bruno Reviewed-by: Henri Doreau Reviewed-by: Quentin Bouget Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_coordinator.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index 7156c7d..c187fd3 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -995,6 +995,32 @@ int mdt_hsm_cdt_stop(struct mdt_device *mdt) RETURN(0); } +static int mdt_hsm_set_exists(struct mdt_thread_info *mti, + const struct lu_fid *fid, + u32 archive_id) +{ + struct mdt_object *obj; + struct md_hsm mh; + int rc; + + obj = mdt_hsm_get_md_hsm(mti, fid, &mh); + if (IS_ERR(obj)) + GOTO(out, rc = PTR_ERR(obj)); + + if (mh.mh_flags & HS_EXISTS && + mh.mh_arch_id == archive_id) + GOTO(out_obj, rc = 0); + + mh.mh_flags |= HS_EXISTS; + mh.mh_arch_id = archive_id; + rc = mdt_hsm_attr_set(mti, obj, &mh); + +out_obj: + mdt_object_put(mti->mti_env, obj); +out: + return rc; +} + /** * register all requests from an hal in the memory list * \param mti [IN] context @@ -1054,20 +1080,11 @@ int mdt_hsm_add_hal(struct mdt_thread_info *mti, } if (hai->hai_action == HSMA_ARCHIVE) { - struct mdt_object *obj; - struct md_hsm hsm; - - obj = mdt_hsm_get_md_hsm(mti, &hai->hai_fid, &hsm); - if (IS_ERR(obj) && (PTR_ERR(obj) == -ENOENT)) + rc = mdt_hsm_set_exists(mti, &hai->hai_fid, + hal->hal_archive_id); + if (rc == -ENOENT) continue; - if (IS_ERR(obj)) - GOTO(out, rc = PTR_ERR(obj)); - - hsm.mh_flags |= HS_EXISTS; - hsm.mh_arch_id = hal->hal_archive_id; - rc = mdt_hsm_attr_set(mti, obj, &hsm); - mdt_object_put(mti->mti_env, obj); - if (rc) + else if (rc < 0) GOTO(out, rc); } -- 1.8.3.1