Commit 986ef135 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging/lustre: use 64-bit times for ptlrpc sec expiry

The exp_flvr_expire and imp_sec_expire are defined as 'unsigned long',
which doesn't overflow until 2106, but to be on the safe side, this
changes the code to use time64_t like we do everywhere else.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarOleg Drokin <green@linuxhacker.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 14e3f92a
...@@ -216,7 +216,7 @@ struct obd_export { ...@@ -216,7 +216,7 @@ struct obd_export {
enum lustre_sec_part exp_sp_peer; enum lustre_sec_part exp_sp_peer;
struct sptlrpc_flavor exp_flvr; /* current */ struct sptlrpc_flavor exp_flvr; /* current */
struct sptlrpc_flavor exp_flvr_old[2]; /* about-to-expire */ struct sptlrpc_flavor exp_flvr_old[2]; /* about-to-expire */
unsigned long exp_flvr_expire[2]; /* seconds */ time64_t exp_flvr_expire[2]; /* seconds */
/** protects exp_hp_rpcs */ /** protects exp_hp_rpcs */
spinlock_t exp_rpc_lock; spinlock_t exp_rpc_lock;
......
...@@ -200,7 +200,7 @@ struct obd_import { ...@@ -200,7 +200,7 @@ struct obd_import {
*/ */
struct ptlrpc_sec *imp_sec; struct ptlrpc_sec *imp_sec;
struct mutex imp_sec_mutex; struct mutex imp_sec_mutex;
unsigned long imp_sec_expire; time64_t imp_sec_expire;
/** @} */ /** @} */
/** Wait queue for those who need to wait for recovery completion */ /** Wait queue for those who need to wait for recovery completion */
......
...@@ -343,7 +343,7 @@ static int import_sec_check_expire(struct obd_import *imp) ...@@ -343,7 +343,7 @@ static int import_sec_check_expire(struct obd_import *imp)
spin_lock(&imp->imp_lock); spin_lock(&imp->imp_lock);
if (imp->imp_sec_expire && if (imp->imp_sec_expire &&
imp->imp_sec_expire < get_seconds()) { imp->imp_sec_expire < ktime_get_real_seconds()) {
adapt = 1; adapt = 1;
imp->imp_sec_expire = 0; imp->imp_sec_expire = 0;
} }
...@@ -1779,7 +1779,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, ...@@ -1779,7 +1779,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
exp->exp_flvr_old[1] = exp->exp_flvr_old[0]; exp->exp_flvr_old[1] = exp->exp_flvr_old[0];
exp->exp_flvr_expire[1] = exp->exp_flvr_expire[0]; exp->exp_flvr_expire[1] = exp->exp_flvr_expire[0];
exp->exp_flvr_old[0] = exp->exp_flvr; exp->exp_flvr_old[0] = exp->exp_flvr;
exp->exp_flvr_expire[0] = get_seconds() + exp->exp_flvr_expire[0] = ktime_get_real_seconds() +
EXP_FLVR_UPDATE_EXPIRE; EXP_FLVR_UPDATE_EXPIRE;
exp->exp_flvr = flavor; exp->exp_flvr = flavor;
...@@ -1853,14 +1853,14 @@ int sptlrpc_target_export_check(struct obd_export *exp, ...@@ -1853,14 +1853,14 @@ int sptlrpc_target_export_check(struct obd_export *exp,
} }
if (exp->exp_flvr_expire[0]) { if (exp->exp_flvr_expire[0]) {
if (exp->exp_flvr_expire[0] >= get_seconds()) { if (exp->exp_flvr_expire[0] >= ktime_get_real_seconds()) {
if (flavor_allowed(&exp->exp_flvr_old[0], req)) { if (flavor_allowed(&exp->exp_flvr_old[0], req)) {
CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (" CFS_DURATION_T ")\n", exp, CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (%lld)\n", exp,
exp->exp_flvr.sf_rpc, exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_old[1].sf_rpc,
exp->exp_flvr_expire[0] - (s64)(exp->exp_flvr_expire[0] -
get_seconds()); ktime_get_real_seconds()));
spin_unlock(&exp->exp_lock); spin_unlock(&exp->exp_lock);
return 0; return 0;
} }
...@@ -1877,15 +1877,15 @@ int sptlrpc_target_export_check(struct obd_export *exp, ...@@ -1877,15 +1877,15 @@ int sptlrpc_target_export_check(struct obd_export *exp,
/* now it doesn't match the current flavor, the only chance we can /* now it doesn't match the current flavor, the only chance we can
* accept it is match the old flavors which is not expired. */ * accept it is match the old flavors which is not expired. */
if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) { if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) {
if (exp->exp_flvr_expire[1] >= get_seconds()) { if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) {
if (flavor_allowed(&exp->exp_flvr_old[1], req)) { if (flavor_allowed(&exp->exp_flvr_old[1], req)) {
CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (" CFS_DURATION_T ")\n", CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (%lld)\n",
exp, exp,
exp->exp_flvr.sf_rpc, exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_old[1].sf_rpc,
exp->exp_flvr_expire[1] - (s64)(exp->exp_flvr_expire[1] -
get_seconds()); ktime_get_real_seconds()));
spin_unlock(&exp->exp_lock); spin_unlock(&exp->exp_lock);
return 0; return 0;
} }
...@@ -1905,7 +1905,7 @@ int sptlrpc_target_export_check(struct obd_export *exp, ...@@ -1905,7 +1905,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
spin_unlock(&exp->exp_lock); spin_unlock(&exp->exp_lock);
CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+ld)|%x(%+ld)\n", CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+lld)|%x(%+lld)\n",
exp, exp->exp_obd->obd_name, exp, exp->exp_obd->obd_name,
req, req->rq_auth_gss, req->rq_ctx_init, req->rq_ctx_fini, req, req->rq_auth_gss, req->rq_ctx_init, req->rq_ctx_fini,
req->rq_auth_usr_root, req->rq_auth_usr_mdt, req->rq_auth_usr_ost, req->rq_auth_usr_root, req->rq_auth_usr_mdt, req->rq_auth_usr_ost,
...@@ -1913,12 +1913,10 @@ int sptlrpc_target_export_check(struct obd_export *exp, ...@@ -1913,12 +1913,10 @@ int sptlrpc_target_export_check(struct obd_export *exp,
exp->exp_flvr.sf_rpc, exp->exp_flvr.sf_rpc,
exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[0].sf_rpc,
exp->exp_flvr_expire[0] ? exp->exp_flvr_expire[0] ?
(unsigned long) (exp->exp_flvr_expire[0] - (s64)(exp->exp_flvr_expire[0] - ktime_get_real_seconds()) : 0,
get_seconds()) : 0,
exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_old[1].sf_rpc,
exp->exp_flvr_expire[1] ? exp->exp_flvr_expire[1] ?
(unsigned long) (exp->exp_flvr_expire[1] - (s64)(exp->exp_flvr_expire[1] - ktime_get_real_seconds()) : 0);
get_seconds()) : 0);
return -EACCES; return -EACCES;
} }
EXPORT_SYMBOL(sptlrpc_target_export_check); EXPORT_SYMBOL(sptlrpc_target_export_check);
......
...@@ -871,7 +871,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) ...@@ -871,7 +871,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd)
if (imp) { if (imp) {
spin_lock(&imp->imp_lock); spin_lock(&imp->imp_lock);
if (imp->imp_sec) if (imp->imp_sec)
imp->imp_sec_expire = get_seconds() + imp->imp_sec_expire = ktime_get_real_seconds() +
SEC_ADAPT_DELAY; SEC_ADAPT_DELAY;
spin_unlock(&imp->imp_lock); spin_unlock(&imp->imp_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment