From: James Simmons Date: Fri, 20 Mar 2020 23:49:06 +0000 (-0400) Subject: LU-13344 sec: remove time_t usage X-Git-Tag: 2.13.53~8 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7e0efa0f28b3401f75308b4d297639f6c2790873 LU-13344 sec: remove time_t usage In the latest kernels time_t has been removed since time_t has been a 64 bit value just like time64_t so no need for it anymore. Change ps_sepol_mtime to ktime_t which is the preferred time format in the linux kernel. For the case of the Lustre GGS code the fields marked as time_t are timestamps so just change it to time64_t. Change-Id: I9f40592d440cc8d68c7b73c0c31d88bcecb3723b Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/37942 Tested-by: jenkins Reviewed-by: Shaun Tancheff Tested-by: Maloo Reviewed-by: Neil Brown Reviewed-by: Sebastien Buisson Tested-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h index e67e994..14010d5 100644 --- a/lustre/include/lustre_sec.h +++ b/lustre/include/lustre_sec.h @@ -870,7 +870,7 @@ struct ptlrpc_sec { struct obd_import *ps_import; spinlock_t ps_lock; /** mtime of SELinux policy file */ - time_t ps_sepol_mtime; + ktime_t ps_sepol_mtime; /** next check time of SELinux policy file */ ktime_t ps_sepol_checknext; /** diff --git a/lustre/ptlrpc/gss/gss_svc_upcall.c b/lustre/ptlrpc/gss/gss_svc_upcall.c index bfbea7f..8a2e1de 100644 --- a/lustre/ptlrpc/gss/gss_svc_upcall.c +++ b/lustre/ptlrpc/gss/gss_svc_upcall.c @@ -281,7 +281,7 @@ static int rsi_parse(struct cache_detail *cd, char *mesg, int mlen) char *buf = mesg; int len; struct rsi rsii, *rsip = NULL; - time_t expiry; + time64_t expiry; int status = -EINVAL; ENTRY; @@ -524,7 +524,7 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen) char *buf = mesg; int len, rv, tmp_int; struct rsc rsci, *rscp = NULL; - time_t expiry; + time64_t expiry; int status = -EINVAL; struct gss_api_mech *gm = NULL; @@ -746,7 +746,7 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp, CERROR("unable to get expire time, drop it\n"); GOTO(out, rc = -EINVAL); } - rsci.h.expiry_time = (time_t) ctx_expiry; + rsci.h.expiry_time = ctx_expiry; switch (imp->imp_obd->u.cli.cl_sp_to) { case LUSTRE_SP_MDT: diff --git a/lustre/ptlrpc/gss/sec_gss.c b/lustre/ptlrpc/gss/sec_gss.c index 8ca6e2f..4c801a6 100644 --- a/lustre/ptlrpc/gss/sec_gss.c +++ b/lustre/ptlrpc/gss/sec_gss.c @@ -1102,7 +1102,7 @@ int gss_sec_create_common(struct gss_sec *gsec, sec->ps_import = class_import_get(imp); spin_lock_init(&sec->ps_lock); INIT_LIST_HEAD(&sec->ps_gc_list); - sec->ps_sepol_mtime = 0; + sec->ps_sepol_mtime = ktime_set(0, 0); sec->ps_sepol_checknext = ktime_set(0, 0); sec->ps_sepol[0] = '\0'; diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index dc68e0e..9c53ebe 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -1781,14 +1781,17 @@ static int sepol_helper(struct obd_import *imp) argv[2] = (char *)imp->imp_obd->obd_type->typ_name; argv[4] = imp->imp_obd->obd_name; spin_lock(&imp->imp_sec->ps_lock); - if (imp->imp_sec->ps_sepol_mtime == 0 && + if (ktime_to_ns(imp->imp_sec->ps_sepol_mtime) == 0 && imp->imp_sec->ps_sepol[0] == '\0') { /* ps_sepol has not been initialized */ argv[5] = NULL; argv[7] = NULL; } else { - snprintf(mtime_str, sizeof(mtime_str), "%lu", - imp->imp_sec->ps_sepol_mtime); + time64_t mtime_ms; + + mtime_ms = ktime_to_ms(imp->imp_sec->ps_sepol_mtime); + snprintf(mtime_str, sizeof(mtime_str), "%lld", + mtime_ms / MSEC_PER_SEC); mode_str[0] = imp->imp_sec->ps_sepol[0]; } spin_unlock(&imp->imp_sec->ps_lock); diff --git a/lustre/ptlrpc/sec_lproc.c b/lustre/ptlrpc/sec_lproc.c index 37fc578..4111644 100644 --- a/lustre/ptlrpc/sec_lproc.c +++ b/lustre/ptlrpc/sec_lproc.c @@ -194,7 +194,7 @@ lprocfs_sptlrpc_sepol_seq_write(struct file *file, const char __user *buffer, spin_lock(&imp->imp_sec->ps_lock); snprintf(imp->imp_sec->ps_sepol, param->sdd_sepol_len + 1, "%s", param->sdd_sepol); - imp->imp_sec->ps_sepol_mtime = param->sdd_sepol_mtime; + imp->imp_sec->ps_sepol_mtime = ktime_set(param->sdd_sepol_mtime, 0); spin_unlock(&imp->imp_sec->ps_lock); out: