Whamcloud - gitweb
LU-9404 mdt: set HSM xattr only when needed 67/26867/2
authorJohn L. Hammond <john.hammond@intel.com>
Thu, 27 Apr 2017 15:39:11 +0000 (10:39 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 May 2017 03:47:04 +0000 (03:47 +0000)
In mdt_hsm_add_hal() avoid setting the HSM xattr when the HSM
attributes have not changed.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I12570034127b9928e49ea329bf77b674aaa6ade8
Reviewed-on: https://review.whamcloud.com/26867
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Reviewed-by: Henri Doreau <henri.doreau@cea.fr>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_coordinator.c

index 7156c7d..c187fd3 100644 (file)
@@ -995,6 +995,32 @@ int mdt_hsm_cdt_stop(struct mdt_device *mdt)
        RETURN(0);
 }
 
        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
 /**
  * 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) {
                }
 
                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;
                                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);
                }
 
                                GOTO(out, rc);
                }