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);
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);
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)
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
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);
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);
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);
}
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)
{
ucred->uc_valid = UCRED_NEW;
ucred_set_jobid(info, ucred);
ucred_set_nid(info, ucred);
+ ucred_set_audit_enabled(info, ucred);
EXIT;
uc->uc_valid = UCRED_OLD;
ucred_set_jobid(info, uc);
ucred_set_nid(info, uc);
+ ucred_set_audit_enabled(info, uc);
EXIT;