Whamcloud - gitweb
LU-13344 sec: remove time_t usage 42/37942/4
authorJames Simmons <jsimmons@infradead.org>
Fri, 20 Mar 2020 23:49:06 +0000 (19:49 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 31 Mar 2020 07:01:16 +0000 (07:01 +0000)
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
lustre/ptlrpc/gss/gss_svc_upcall.c
lustre/ptlrpc/gss/sec_gss.c
lustre/ptlrpc/sec.c
lustre/ptlrpc/sec_lproc.c

index e67e994..14010d5 100644 (file)
@@ -870,7 +870,7 @@ struct ptlrpc_sec {
         struct obd_import              *ps_import;
        spinlock_t                      ps_lock;
        /** mtime of SELinux policy file */
         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;
        /**
        /** next check time of SELinux policy file */
        ktime_t                         ps_sepol_checknext;
        /**
index bfbea7f..8a2e1de 100644 (file)
@@ -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;
         char           *buf = mesg;
         int             len;
         struct rsi      rsii, *rsip = NULL;
-        time_t          expiry;
+       time64_t expiry;
         int             status = -EINVAL;
         ENTRY;
 
         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;
         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;
 
         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);
         }
                 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:
 
        switch (imp->imp_obd->u.cli.cl_sp_to) {
        case LUSTRE_SP_MDT:
index 8ca6e2f..4c801a6 100644 (file)
@@ -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_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';
 
        sec->ps_sepol_checknext = ktime_set(0, 0);
        sec->ps_sepol[0] = '\0';
 
index dc68e0e..9c53ebe 100644 (file)
@@ -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);
                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 {
                    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);
                        mode_str[0] = imp->imp_sec->ps_sepol[0];
                }
                spin_unlock(&imp->imp_sec->ps_lock);
index 37fc578..4111644 100644 (file)
@@ -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);
        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:
        spin_unlock(&imp->imp_sec->ps_lock);
 
 out: