Whamcloud - gitweb
LU-9727 lustre: record if enable_audit is set on nodemap 14/28314/18
authorSebastien Buisson <sbuisson@ddn.com>
Wed, 2 Aug 2017 14:47:47 +0000 (23:47 +0900)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Feb 2018 03:46:02 +0000 (03:46 +0000)
Record changelogs from a client only if it pertains to a nodemap
on which enable_audit is set, and changelogs are activated.
If client is not explicitely assigned to a nodemap, enable_audit value
from default nodemap is used.

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: I31d361cfd8cc69db68b60298934cbbef4af0d75d
Reviewed-on: https://review.whamcloud.com/28314
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Li Xi <lixi@ddn.com>
lustre/include/md_object.h
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_object.c
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_lib.c

index 545a827..e46c05e 100644 (file)
@@ -676,6 +676,7 @@ struct lu_ucred {
        struct md_identity      *uc_identity;
        char                     uc_jobid[LUSTRE_JOBID_SIZE];
        lnet_nid_t               uc_nid;
+       bool                     uc_enable_audit;
 };
 
 struct lu_ucred *lu_ucred(const struct lu_env *env);
index f783798..a8554f7 100644 (file)
@@ -767,7 +767,7 @@ int mdd_declare_changelog_store(const struct lu_env *env,
        int                              rc;
 
        /* Not recording */
-       if (!(mdd->mdd_cl.mc_flags & CLM_ON))
+       if (!recording_changelog(env, mdd))
                return 0;
 
        reclen = mdd_llog_record_calc_size(env, tname, sname);
@@ -1109,7 +1109,7 @@ int mdd_changelog_ns_store(const struct lu_env *env,
        ENTRY;
 
        /* Not recording */
-       if (!(mdd->mdd_cl.mc_flags & CLM_ON))
+       if (!recording_changelog(env, mdd))
                RETURN(0);
 
        if ((mdd->mdd_cl.mc_mask & (1 << type)) == 0)
index a8befd5..cc43611 100644 (file)
@@ -742,4 +742,13 @@ int mdo_destroy(const struct lu_env *env, struct mdd_object *o,
         return dt_destroy(env, next, handle);
 }
 
+static inline int recording_changelog(const struct lu_env *env,
+                                     struct mdd_device *mdd)
+{
+       const struct lu_ucred *uc = lu_ucred_check(env);
+
+       return (mdd->mdd_cl.mc_flags & CLM_ON) &&
+               (uc ? uc->uc_enable_audit : 1);
+}
+
 #endif
index d0539fe..d55cfd7 100644 (file)
@@ -923,7 +923,7 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd,
        LASSERT(handle != NULL);
 
        /* Not recording */
-       if (!(mdd->mdd_cl.mc_flags & CLM_ON))
+       if (!recording_changelog(env, mdd))
                RETURN(0);
        if ((mdd->mdd_cl.mc_mask & (1 << type)) == 0)
                RETURN(0);
@@ -995,7 +995,7 @@ static int mdd_changelog(const struct lu_env *env, enum changelog_rec_type type,
        ENTRY;
 
        /* Not recording */
-       if (!(mdd->mdd_cl.mc_flags & CLM_ON))
+       if (!recording_changelog(env, mdd))
                RETURN(0);
        if (!(mdd->mdd_cl.mc_mask & (1 << type)))
                RETURN(0);
index 4c4fed3..6a7782e 100644 (file)
@@ -948,6 +948,8 @@ static int hsm_init_ucred(struct lu_ucred *uc)
        uc->uc_umask = 0777;
        uc->uc_ginfo = NULL;
        uc->uc_identity = NULL;
+       /* always record internal HSM activity if also enabled globally */
+       uc->uc_enable_audit = 1;
 
        RETURN(0);
 }
index 70935d0..aa0c25c 100644 (file)
@@ -149,6 +149,23 @@ static void ucred_set_nid(struct mdt_thread_info *info, struct lu_ucred *uc)
                uc->uc_nid = LNET_NID_ANY;
 }
 
+static void ucred_set_audit_enabled(struct mdt_thread_info *info,
+                                   struct lu_ucred *uc)
+{
+       struct lu_nodemap *nodemap = NULL;
+       bool audit = true;
+
+       if (info && info->mti_exp) {
+               nodemap = nodemap_get_from_exp(info->mti_exp);
+               if (nodemap && !IS_ERR(nodemap)) {
+                       audit = nodemap->nmf_enable_audit;
+                       nodemap_putref(nodemap);
+               }
+       }
+
+       uc->uc_enable_audit = audit;
+}
+
 static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
                          void *buf, bool drop_fs_cap)
 {
@@ -308,6 +325,7 @@ static int new_init_ucred(struct mdt_thread_info *info, ucred_init_type_t type,
        ucred->uc_valid = UCRED_NEW;
        ucred_set_jobid(info, ucred);
        ucred_set_nid(info, ucred);
+       ucred_set_audit_enabled(info, ucred);
 
        EXIT;
 
@@ -481,6 +499,7 @@ static int old_init_ucred_common(struct mdt_thread_info *info,
        uc->uc_valid = UCRED_OLD;
        ucred_set_jobid(info, uc);
        ucred_set_nid(info, uc);
+       ucred_set_audit_enabled(info, uc);
 
        EXIT;