File 0011-LU-13344-sec-remove-time_t-usage.patch of Package lustre_2_12
From 9d4d300444633f3fe9beb71238124ebe78cd793b Mon Sep 17 00:00:00 2001
From: James Simmons <jsimmons@infradead.org>
Date: Fri, 20 Mar 2020 19:49:06 -0400
Subject: [PATCH 11/35] 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 <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/37942
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Neil Brown <neilb@suse.de>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Tested-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
lustre/include/lustre_sec.h | 2 +-
lustre/ptlrpc/gss/gss_svc_upcall.c | 6 +++---
lustre/ptlrpc/gss/sec_gss.c | 2 +-
lustre/ptlrpc/sec.c | 9 ++++++---
lustre/ptlrpc/sec_lproc.c | 2 +-
5 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h
index cef4bd5c7e34..6a69d01150aa 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 bbb4a0b424b1..2202e3f56f8c 100644
--- a/lustre/ptlrpc/gss/gss_svc_upcall.c
+++ b/lustre/ptlrpc/gss/gss_svc_upcall.c
@@ -315,7 +315,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;
@@ -560,7 +560,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;
@@ -782,7 +782,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 ab59c841a441..845bfbca44d5 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 100990eae4c7..3f061761e2fd 100644
--- a/lustre/ptlrpc/sec.c
+++ b/lustre/ptlrpc/sec.c
@@ -1807,14 +1807,17 @@ static int sepol_helper(struct obd_import *imp)
argv[2] = 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 37bca072d1f4..95dbf2062495 100644
--- a/lustre/ptlrpc/sec_lproc.c
+++ b/lustre/ptlrpc/sec_lproc.c
@@ -198,7 +198,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:
--
2.41.0