First of all, sorry for the overly long series that this turned into. I'm currently doing a survey of all code using time_t/timeval/timespec to get an idea of what work needs to be done where, in particular in terms of user interface changes.
Lustre is by far the most pervasive user of time types and functions, and I could not even find my way through the code to see what needs to be done other than actually doing that work.
On most other subsystems, we try to use montonic times where possible for in-kernel uses. I did not do that here but kept using wall-clock times, in order to leave the debug output and procfs files untouched. A follow-up series could convert a lot of the ktime_get_real_*() to ktime_get_*() to change that if we don't care about the format.
There are a couple of things that I left unchanged:
- Socket timestamps in drivers/staging/lustre/lnet/lnet/lib-socket.c need to wait for the socket API to be changed first
- inode timestamps need to be changed in VFS, which is a larger work
- The conrpc selftest has a user interface based on timeval that is hard to change.
All patches are based on staging-testing and built-tested on 32-bit arm and x86 as well as 64-bit arm.
Arnd Bergmann (37): staging/lustre: use jiffies for lp_last_query times staging/lustre: use 64-bit inode timestamps internally staging/lustre: obd: remove unused data structures staging/lustre: tracefile: use 64-bit seconds staging/lustre: use 64-bit timestamps in procfs output staging/lustre: use time64_t for l_last_activity staging/lustre: use ktime_t for calculating elapsed time staging/lustre: change rq_at_index type staging/lustre: avoid unnecessary timeval conversion staging/lustre: use 64-bit time LNetCtl() staging/lustre: use 'long' return type for cfs_duration_sec() staging/lustre: use jiffies_to_timeval() instead of cfs_duration_usec staging/lustre: use 64-bit ibn_incarnation computation staging/lustre: use 64-bit times for lnet_shuffle_seed staging/lustre: use 64-bit computation in s2dhms() staging/lustre: use 64-bit timestamps for selftest staging/lustre: use 64-bit time for pl_recalc staging/lustre: use 64-bit time for obd eviction staging/lustre: use 64-bit time for procfs output staging/lustre: use 64-bit time for adaptive timeout staging/lustre: use 64-bit llite procfs timestamps staging/lustre: use 64-bit times for ksnd_connd staging/lustre: use 64-bit time for ni_last_alive staging/lustre: use 64-bit time for selftest staging/lustre: partially use time64_t for capa expiry staging/lustre: use 64-bit times in ptlrpc_enc_page_pool staging/lustre: use 64-bit times in debug print staging/lustre: use 64-bit times in another debug print staging/lustre: use 64-bit timestamps for mdc staging/lustre: use 64-bit times for ptlrpc sec expiry staging/lustre: use 64-bit times for ptlrpc_sec staging/lustre: use 64-bit times for exp_last_request_time staging/lustre: use 64-bit times for request times staging/lustre: remove a bit of dead code staging/lustre: remove wrappers for timer functions staging/lustre: remove unused time handling functions staging/lustre: remove CFS_TIME_T definition
.../lustre/include/linux/libcfs/libcfs_debug.h | 4 +- .../lustre/include/linux/libcfs/libcfs_prim.h | 13 -- .../lustre/include/linux/libcfs/libcfs_time.h | 49 -------- .../lustre/include/linux/libcfs/linux/linux-time.h | 35 +----- .../staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- .../staging/lustre/include/linux/lnet/lib-types.h | 2 +- .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +- .../staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +- .../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 +- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +- drivers/staging/lustre/lnet/lnet/config.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-eq.c | 9 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 4 +- drivers/staging/lustre/lnet/lnet/router.c | 10 +- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- drivers/staging/lustre/lnet/selftest/conctl.c | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 10 +- drivers/staging/lustre/lnet/selftest/console.c | 2 +- drivers/staging/lustre/lnet/selftest/console.h | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 5 +- drivers/staging/lustre/lnet/selftest/ping_test.c | 12 +- drivers/staging/lustre/lnet/selftest/rpc.c | 9 +- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 14 +-- drivers/staging/lustre/lnet/selftest/timer.h | 2 +- drivers/staging/lustre/lustre/include/cl_object.h | 6 +- .../staging/lustre/lustre/include/lprocfs_status.h | 6 +- .../lustre/lustre/include/lustre/lustre_idl.h | 1 + .../staging/lustre/lustre/include/lustre_capa.h | 16 ++- drivers/staging/lustre/lustre/include/lustre_dlm.h | 6 +- .../staging/lustre/lustre/include/lustre_export.h | 7 +- .../staging/lustre/lustre/include/lustre_import.h | 14 +-- drivers/staging/lustre/lustre/include/lustre_net.h | 24 ++-- drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +- drivers/staging/lustre/lustre/include/obd.h | 97 +-------------- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 30 ++--- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 29 ++--- drivers/staging/lustre/lustre/libcfs/debug.c | 4 +- .../lustre/lustre/libcfs/linux/linux-prim.c | 70 ----------- .../lustre/lustre/libcfs/linux/linux-tracefile.c | 8 +- drivers/staging/lustre/lustre/libcfs/module.c | 3 - drivers/staging/lustre/lustre/llite/file.c | 2 +- .../staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 8 +- drivers/staging/lustre/lustre/llite/lproc_llite.c | 24 ++-- drivers/staging/lustre/lustre/llite/super25.c | 6 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 4 +- drivers/staging/lustre/lustre/llite/vvp_object.c | 12 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/obdclass/genops.c | 6 +- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- .../lustre/lustre/obdclass/lprocfs_status.c | 27 ++--- .../lustre/lustre/obdclass/lustre_handles.c | 6 +- .../staging/lustre/lustre/obdclass/obd_config.c | 13 +- .../staging/lustre/lustre/obdecho/echo_client.c | 4 +- drivers/staging/lustre/lustre/osc/lproc_osc.c | 16 +-- drivers/staging/lustre/lustre/osc/osc_io.c | 6 +- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 48 ++++---- drivers/staging/lustre/lustre/ptlrpc/events.c | 8 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 14 +-- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 16 +-- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 10 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 29 +++-- drivers/staging/lustre/lustre/ptlrpc/sec.c | 28 ++--- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 29 +++-- drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 135 +++++++++++---------- 77 files changed, 380 insertions(+), 652 deletions(-)
The recently introduced lnet_peer_set_alive() function uses get_seconds() to read the current time into a shared variable, but all other uses of that variable compare it to jiffies values.
This changes the current use to jiffies as well for consistency.
This likely changes behavior, and should be reviewed by the folks that reviewed the original patch that introduced the unusual behavior and was itself a bug fix.
Signed-off-by: Arnd Bergmann arnd@arndb.de Fixes: af3fa7c71bf ("staging/lustre/lnet: peer aliveness status and NI status") Cc: Liang Zhen liang.zhen@intel.com Cc: James Simmons uja.ornl@gmail.com Cc: Isaac Huang he.huang@intel.com Cc: Oleg Drokin oleg.drokin@intel.com --- drivers/staging/lustre/include/linux/lnet/lib-lnet.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h index 22d54b209528..b61d5045a566 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h @@ -680,7 +680,7 @@ void lnet_debug_peer(lnet_nid_t nid); static inline void lnet_peer_set_alive(lnet_peer_t *lp) { - lp->lp_last_alive = lp->lp_last_query = get_seconds(); + lp->lp_last_alive = lp->lp_last_query = jiffies; if (!lp->lp_alive) lnet_notify_locked(lp, 0, 1, lp->lp_last_alive); }
Lustre has 64-bit timestamps in its network data structures, but on 32 bit systems, it converts them directly into time_t, which is 32 bit wide.
This changes the code to use 64-bit time stamps for files. The Linux VFS code still uses time_t though, and will be changed in a separate patch series.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/cl_object.h | 6 +++--- drivers/staging/lustre/lustre/llite/llite_internal.h | 2 +- drivers/staging/lustre/lustre/llite/vvp_io.c | 4 ++-- drivers/staging/lustre/lustre/llite/vvp_object.c | 12 ++++++------ drivers/staging/lustre/lustre/osc/osc_io.c | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/cl_object.h b/drivers/staging/lustre/lustre/include/cl_object.h index 04dcb5111756..90fbaa22e510 100644 --- a/drivers/staging/lustre/lustre/include/cl_object.h +++ b/drivers/staging/lustre/lustre/include/cl_object.h @@ -173,11 +173,11 @@ struct cl_attr { */ loff_t cat_kms; /** Modification time. Measured in seconds since epoch. */ - time_t cat_mtime; + time64_t cat_mtime; /** Access time. Measured in seconds since epoch. */ - time_t cat_atime; + time64_t cat_atime; /** Change time. Measured in seconds since epoch. */ - time_t cat_ctime; + time64_t cat_ctime; /** * Blocks allocated to this cl_object on the server file system. * diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h index 37bf331be5c2..fdd0a58286c1 100644 --- a/drivers/staging/lustre/lustre/llite/llite_internal.h +++ b/drivers/staging/lustre/lustre/llite/llite_internal.h @@ -851,7 +851,7 @@ struct vvp_io { * Inode modification time that is checked across DLM * lock request. */ - time_t ft_mtime; + time64_t ft_mtime; struct vm_area_struct *ft_vma; /** * locked page returned from vvp_io diff --git a/drivers/staging/lustre/lustre/llite/vvp_io.c b/drivers/staging/lustre/lustre/llite/vvp_io.c index 75a8ea21bc24..cf264de0e531 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_io.c +++ b/drivers/staging/lustre/lustre/llite/vvp_io.c @@ -109,7 +109,7 @@ static int vvp_io_fault_iter_init(const struct lu_env *env,
LASSERT(inode == file_inode(cl2ccc_io(env, ios)->cui_fd->fd_file)); - vio->u.fault.ft_mtime = LTIME_S(inode->i_mtime); + vio->u.fault.ft_mtime = inode->i_mtime.tv_sec; return 0; }
@@ -661,7 +661,7 @@ static int vvp_io_fault_start(const struct lu_env *env, pgoff_t last; /* last page in a file data region */
if (fio->ft_executable && - LTIME_S(inode->i_mtime) != vio->u.fault.ft_mtime) + inode->i_mtime.tv_sec != vio->u.fault.ft_mtime) CWARN("binary "DFID " changed while waiting for the page fault lock\n", PFID(lu_object_fid(&obj->co_lu))); diff --git a/drivers/staging/lustre/lustre/llite/vvp_object.c b/drivers/staging/lustre/lustre/llite/vvp_object.c index b6f6d4cb6e41..cb2811b9aae7 100644 --- a/drivers/staging/lustre/lustre/llite/vvp_object.c +++ b/drivers/staging/lustre/lustre/llite/vvp_object.c @@ -87,9 +87,9 @@ static int vvp_attr_get(const struct lu_env *env, struct cl_object *obj, */
attr->cat_size = i_size_read(inode); - attr->cat_mtime = LTIME_S(inode->i_mtime); - attr->cat_atime = LTIME_S(inode->i_atime); - attr->cat_ctime = LTIME_S(inode->i_ctime); + attr->cat_mtime = inode->i_mtime.tv_sec; + attr->cat_atime = inode->i_atime.tv_sec; + attr->cat_ctime = inode->i_ctime.tv_sec; attr->cat_blocks = inode->i_blocks; attr->cat_uid = from_kuid(&init_user_ns, inode->i_uid); attr->cat_gid = from_kgid(&init_user_ns, inode->i_gid); @@ -107,11 +107,11 @@ static int vvp_attr_set(const struct lu_env *env, struct cl_object *obj, if (valid & CAT_GID) inode->i_gid = make_kgid(&init_user_ns, attr->cat_gid); if (valid & CAT_ATIME) - LTIME_S(inode->i_atime) = attr->cat_atime; + inode->i_atime.tv_sec = attr->cat_atime; if (valid & CAT_MTIME) - LTIME_S(inode->i_mtime) = attr->cat_mtime; + inode->i_mtime.tv_sec = attr->cat_mtime; if (valid & CAT_CTIME) - LTIME_S(inode->i_ctime) = attr->cat_ctime; + inode->i_ctime.tv_sec = attr->cat_ctime; if (0 && valid & CAT_SIZE) cl_isize_write_nolock(inode, attr->cat_size); /* not currently necessary */ diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index fa24e9ed1831..be058c289d76 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -518,7 +518,7 @@ static int osc_io_read_start(const struct lu_env *env,
if (!slice->cis_io->ci_noatime) { cl_object_attr_lock(obj); - attr->cat_atime = LTIME_S(CURRENT_TIME); + attr->cat_atime = ktime_get_real_seconds(); rc = cl_object_attr_set(env, obj, attr, CAT_ATIME); cl_object_attr_unlock(obj); } @@ -534,7 +534,7 @@ static int osc_io_write_start(const struct lu_env *env,
OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_DELAY_SETTIME, 1); cl_object_attr_lock(obj); - attr->cat_mtime = attr->cat_ctime = LTIME_S(CURRENT_TIME); + attr->cat_mtime = attr->cat_ctime = ktime_get_real_seconds(); rc = cl_object_attr_set(env, obj, attr, CAT_MTIME | CAT_CTIME); cl_object_attr_unlock(obj);
We want to get rid of all uses of time_t, and it turns out that obd.h contains a bunch of them that are completely unused.
This removes those structures, along with a couple of other structures and functions in the same file that also turned out to be unused.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/obd.h | 33 ---------------------- drivers/staging/lustre/lustre/include/obd_class.h | 2 +- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/lov/lov_obd.c | 2 +- .../staging/lustre/lustre/obdclass/obd_config.c | 1 - .../staging/lustre/lustre/obdecho/echo_client.c | 4 +-- drivers/staging/lustre/lustre/osc/osc_io.c | 2 +- 8 files changed, 7 insertions(+), 41 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index bafef4e6fe94..0dbac3f53f01 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -144,10 +144,6 @@ typedef int (*obd_enqueue_update_f)(void *cookie, int rc);
/* obd info for a particular level (lov, osc). */ struct obd_info { - /* Lock policy. It keeps an extent which is specific for a particular - * OSC. (e.g. lov_prep_enqueue_set initialises extent of the policy, - * and osc_enqueue passes it into ldlm_lock_match & ldlm_cli_enqueue. */ - ldlm_policy_data_t oi_policy; /* Flags used for set request specific flags: - while lock handling, the flags obtained on the enqueue request are set here. @@ -155,8 +151,6 @@ struct obd_info { - while setattr, the flags used for distinguish punch operation */ __u64 oi_flags; - /* Lock handle specific for every OSC lock. */ - struct lustre_handle *oi_lockh; /* lsm data specific for every OSC. */ struct lov_stripe_md *oi_md; /* obdo data specific for every OSC, if needed at all. */ @@ -171,8 +165,6 @@ struct obd_info { /* oss capability, its type is obd_capa in client to avoid copy. * in contrary its type is lustre_capa in OSS. */ void *oi_capa; - /* transfer jobid from ost_sync() to filter_sync()... */ - char *oi_jobid; };
/* compare all relevant fields. */ @@ -455,25 +447,6 @@ struct echo_client_obd { __u64 ec_unique; };
-struct lov_qos_oss { - struct obd_uuid lqo_uuid; /* ptlrpc's c_remote_uuid */ - struct list_head lqo_oss_list; /* link to lov_qos */ - __u64 lqo_bavail; /* total bytes avail on OSS */ - __u64 lqo_penalty; /* current penalty */ - __u64 lqo_penalty_per_obj;/* penalty decrease every obj*/ - time_t lqo_used; /* last used time, seconds */ - __u32 lqo_ost_count; /* number of osts on this oss */ -}; - -struct ltd_qos { - struct lov_qos_oss *ltq_oss; /* oss info */ - __u64 ltq_penalty; /* current penalty */ - __u64 ltq_penalty_per_obj; /* penalty decrease every obj*/ - __u64 ltq_weight; /* net weighting */ - time_t ltq_used; /* last used time, seconds */ - unsigned int ltq_usable:1; /* usable for striping */ -}; - /* Generic subset of OSTs */ struct ost_pool { __u32 *op_array; /* array of index of @@ -524,7 +497,6 @@ struct lov_tgt_desc { struct obd_uuid ltd_uuid; struct obd_device *ltd_obd; struct obd_export *ltd_exp; - struct ltd_qos ltd_qos; /* qos info per target */ __u32 ltd_gen; __u32 ltd_index; /* index in lov_obd->tgts */ unsigned long ltd_active:1,/* is this target up for requests */ @@ -883,12 +855,7 @@ struct obd_device { int obd_requests_queued_for_recovery; wait_queue_head_t obd_next_transno_waitq; /* protected by obd_recovery_task_lock */ - struct timer_list obd_recovery_timer; - time_t obd_recovery_start; /* seconds */ - time_t obd_recovery_end; /* seconds, for lprocfs_status */ - int obd_recovery_time_hard; int obd_recovery_timeout; - int obd_recovery_ir_factor;
/* new recovery stuff from CMD2 */ struct target_recovery_data obd_recovery_data; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index ce6fa55aded7..7308cda6f5e6 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -1114,7 +1114,7 @@ static inline int obd_statfs_rqset(struct obd_export *exp, __u32 flags) { struct ptlrpc_request_set *set = NULL; - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { }; int rc = 0;
set = ptlrpc_prep_set(); diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 31ed2487377b..5627c0f6dca1 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -916,7 +916,7 @@ static int ll_lsm_getattr(struct lov_stripe_md *lsm, struct obd_export *exp, __u64 ioepoch, int sync) { struct ptlrpc_request_set *set; - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { }; int rc;
LASSERT(lsm != NULL); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index aa68608c3cbd..8dc3de11bb74 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1824,7 +1824,7 @@ int ll_iocontrol(struct inode *inode, struct file *file, } case FSFILT_IOC_SETFLAGS: { struct lov_stripe_md *lsm; - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { }; struct md_op_data *op_data;
if (get_user(flags, (int *)arg)) diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 906503b05979..d51311c9c753 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -1365,7 +1365,7 @@ static int lov_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { struct ptlrpc_request_set *set = NULL; - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { }; int rc = 0;
/* for obdclass we forbid using obd_statfs_rqset, but prefer using async diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index 32b40eab8d8e..b86a47c54029 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -393,7 +393,6 @@ int class_attach(struct lustre_cfg *lcfg) /* XXX belongs in setup not attach */ init_rwsem(&obd->obd_observer_link_sem); /* recovery data */ - cfs_init_timer(&obd->obd_recovery_timer); spin_lock_init(&obd->obd_recovery_task_lock); init_waitqueue_head(&obd->obd_next_transno_waitq); init_waitqueue_head(&obd->obd_evict_inprogress_waitq); diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c index 27bd170c3a28..81304e456dbd 100644 --- a/drivers/staging/lustre/lustre/obdecho/echo_client.c +++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c @@ -1917,7 +1917,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, case OBD_IOC_GETATTR: rc = echo_get_object(&eco, ed, oa); if (rc == 0) { - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { };
oinfo.oi_md = eco->eo_lsm; oinfo.oi_oa = oa; @@ -1934,7 +1934,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
rc = echo_get_object(&eco, ed, oa); if (rc == 0) { - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { };
oinfo.oi_oa = oa; oinfo.oi_md = eco->eo_lsm; diff --git a/drivers/staging/lustre/lustre/osc/osc_io.c b/drivers/staging/lustre/lustre/osc/osc_io.c index be058c289d76..67bf0bdeb853 100644 --- a/drivers/staging/lustre/lustre/osc/osc_io.c +++ b/drivers/staging/lustre/lustre/osc/osc_io.c @@ -402,7 +402,7 @@ static int osc_io_setattr_start(const struct lu_env *env, __u64 size = io->u.ci_setattr.sa_attr.lvb_size; unsigned int ia_valid = io->u.ci_setattr.sa_valid; int result = 0; - struct obd_info oinfo = { { { 0 } } }; + struct obd_info oinfo = { };
/* truncate cache dirty pages first */ if (cl_io_is_trunc(io))
The lustre tracefile has a timestamp defined as
__u32 ph_sec; __u64 ph_usec;
which seems completely backwards, as the microsecond portion of a time stamp will always fit into a __u32 value, while the second portion will overflow in 2038 or 2106 (in case of unsigned seconds).
This rectifies the situation by swapping out the types to have 64-bit seconds like everything else.
While this constitutes an ABI change, it seems to be reasonable for a debugging interface to change and is likely what was originally intended.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 4 ++-- drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index a3aa644154e2..dfb81022397d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -73,8 +73,8 @@ struct ptldebug_header { __u32 ph_mask; __u16 ph_cpu_id; __u16 ph_type; - __u32 ph_sec; - __u64 ph_usec; + __u64 ph_sec; + __u32 ph_nsec; __u32 ph_stack; __u32 ph_pid; __u32 ph_extern_pid; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 87d844953522..fad272d559c4 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -191,16 +191,16 @@ cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *msgdata, unsigned long stack) { - struct timeval tv; + struct timespec64 ts;
- do_gettimeofday(&tv); + ktime_get_real_ts64(&ts);
header->ph_subsys = msgdata->msg_subsys; header->ph_mask = msgdata->msg_mask; header->ph_cpu_id = smp_processor_id(); header->ph_type = cfs_trace_buf_idx_get(); - header->ph_sec = (__u32)tv.tv_sec; - header->ph_usec = tv.tv_usec; + header->ph_sec = ts.tv_sec; + header->ph_nsec = ts.tv_nsec; header->ph_stack = stack; header->ph_pid = current->pid; header->ph_line_num = msgdata->msg_line;
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The lustre tracefile has a timestamp defined as
__u32 ph_sec; __u64 ph_usec;
which seems completely backwards, as the microsecond portion of a time stamp will always fit into a __u32 value, while the second portion will overflow in 2038 or 2106 (in case of unsigned seconds).
This rectifies the situation by swapping out the types to have 64-bit seconds like everything else.
While this constitutes an ABI change, it seems to be reasonable for a debugging interface to change and is likely what was originally intended.
This is going to wreak some havoc as the old tools would obviously misrepresent this, but the new tools also cannot assume blindly this change is in place, since people tend to stick to old lustre modules for a long time in production for various reasons, while the tools might get upgraded. So I wonder if we should include some sort of a hint somewhere that the lctl could read and see which format it's going to convert from. Either that or we'd need to play with some heuristic in the tools to observe where the leading zeros are (in little ending) in one and the other case (if the year is not quite 2038 yet) and make a decision based on that.
Signed-off-by: Arnd Bergmann arnd@arndb.de
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 4 ++-- drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index a3aa644154e2..dfb81022397d 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -73,8 +73,8 @@ struct ptldebug_header { __u32 ph_mask; __u16 ph_cpu_id; __u16 ph_type;
- __u32 ph_sec;
- __u64 ph_usec;
- __u64 ph_sec;
- __u32 ph_nsec; __u32 ph_stack; __u32 ph_pid; __u32 ph_extern_pid;
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 87d844953522..fad272d559c4 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -191,16 +191,16 @@ cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *msgdata, unsigned long stack) {
- struct timeval tv;
- struct timespec64 ts;
- do_gettimeofday(&tv);
ktime_get_real_ts64(&ts);
header->ph_subsys = msgdata->msg_subsys; header->ph_mask = msgdata->msg_mask; header->ph_cpu_id = smp_processor_id(); header->ph_type = cfs_trace_buf_idx_get();
- header->ph_sec = (__u32)tv.tv_sec;
- header->ph_usec = tv.tv_usec;
- header->ph_sec = ts.tv_sec;
- header->ph_nsec = ts.tv_nsec; header->ph_stack = stack; header->ph_pid = current->pid; header->ph_line_num = msgdata->msg_line;
-- 2.1.0.rc2
On Thursday 24 September 2015 04:02:09 Drokin, Oleg wrote:
The lustre tracefile has a timestamp defined as
__u32 ph_sec; __u64 ph_usec;
which seems completely backwards, as the microsecond portion of a time stamp will always fit into a __u32 value, while the second portion will overflow in 2038 or 2106 (in case of unsigned seconds).
This rectifies the situation by swapping out the types to have 64-bit seconds like everything else.
While this constitutes an ABI change, it seems to be reasonable for a debugging interface to change and is likely what was originally intended.
This is going to wreak some havoc as the old tools would obviously misrepresent this, but the new tools also cannot assume blindly this change is in place, since people tend to stick to old lustre modules for a long time in production for various reasons, while the tools might get upgraded. So I wonder if we should include some sort of a hint somewhere that the lctl could read and see which format it's going to convert from. Either that or we'd need to play with some heuristic in the tools to observe where the leading zeros are (in little ending) in one and the other case (if the year is not quite 2038 yet) and make a decision based on that.
Ok, I see.
If you can prove that the user space tools interpret this value as a unsigned 32-bit number, that would work until 2106 and we could document it as a restriction that way.
Another option would be to change the code storing the times there to do:
header->ph_sec = (u32)ts.tv_sec; header->ph_usec = (ts.tv_sec & 0xffffffff00000000ull) | (ts.tv_nsec / NSEC_PER_USEC);
and do the reverse on the user space side. This would be both endian- safe and backwards compatible, although rather ugly.
Arnd
On Sep 24, 2015, at 3:46 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 04:02:09 Drokin, Oleg wrote:
The lustre tracefile has a timestamp defined as
__u32 ph_sec; __u64 ph_usec;
which seems completely backwards, as the microsecond portion of a time stamp will always fit into a __u32 value, while the second portion will overflow in 2038 or 2106 (in case of unsigned seconds).
This rectifies the situation by swapping out the types to have 64-bit seconds like everything else.
While this constitutes an ABI change, it seems to be reasonable for a debugging interface to change and is likely what was originally intended.
This is going to wreak some havoc as the old tools would obviously misrepresent this, but the new tools also cannot assume blindly this change is in place, since people tend to stick to old lustre modules for a long time in production for various reasons, while the tools might get upgraded. So I wonder if we should include some sort of a hint somewhere that the lctl could read and see which format it's going to convert from. Either that or we'd need to play with some heuristic in the tools to observe where the leading zeros are (in little ending) in one and the other case (if the year is not quite 2038 yet) and make a decision based on that.
Ok, I see.
If you can prove that the user space tools interpret this value as a unsigned 32-bit number, that would work until 2106 and we could document it as a restriction that way.
Well, let's see. The same structure definition is used as in the kernel (in fact it's the same header, just before it got adopted into the staging tree).
The users are in lnet/utils/debug.c in the same lustre tree I pointed you at (tools live there too):
static int cmp_rec(const void *p1, const void *p2) { struct dbg_line *d1 = *(struct dbg_line **)p1; struct dbg_line *d2 = *(struct dbg_line **)p2;
if (d1->hdr->ph_sec < d2->hdr->ph_sec) return -1; if (d1->hdr->ph_sec == d2->hdr->ph_sec && d1->hdr->ph_usec < d2->hdr->ph_usec) return -1; if (d1->hdr->ph_sec == d2->hdr->ph_sec && d1->hdr->ph_usec == d2->hdr->ph_usec) return 0; return 1; }
bytes = snprintf(out, sizeof(out), "%08x:%08x:%u.%u%s:%u.%06llu:%u:%u:%u:" "(%s:%u:%s()) %s", hdr->ph_subsys, hdr->ph_mask, hdr->ph_cpu_id, hdr->ph_type, hdr->ph_flags & PH_FLAG_FIRST_RECORD ? "F" : "", hdr->ph_sec, (unsigned long long)hdr->ph_usec, hdr->ph_stack, hdr->ph_pid, hdr->ph_extern_pid, line->file, hdr->ph_line_num, line->fn, line->text);
fprintf(stderr, " seconds = %u\n", hdr->ph_sec);
if (hdr->ph_len > 4094 || /* is this header bogus? */ hdr->ph_stack > 65536 || hdr->ph_sec < (1 << 30) || hdr->ph_usec > 1000000000 || hdr->ph_line_num > 65536) {
These are all the users. Seems to be pretty much u32 (or unsigned int when printing) everywhere.
Another option would be to change the code storing the times there to do:
header->ph_sec = (u32)ts.tv_sec; header->ph_usec = (ts.tv_sec & 0xffffffff00000000ull) | (ts.tv_nsec / NSEC_PER_USEC);
and do the reverse on the user space side. This would be both endian- safe and backwards compatible, although rather ugly.
Indeed, thats' quite ugly. I think in the next 90 years we will need some other adjustments to the log format and should be able to include this one with them (e.g. there are only 16 bits for the cpu, considering we have 260+ core CPUs on the market today, might as well overflow that quite soon).
On Friday 25 September 2015 01:52:37 Drokin, Oleg wrote:
On Sep 24, 2015, at 3:46 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 04:02:09 Drokin, Oleg wrote:
These are all the users. Seems to be pretty much u32 (or unsigned int when printing) everywhere.
Ok, I'll the patch then to clarify this and leave the format unchanged.
Another option would be to change the code storing the times there to do:
header->ph_sec = (u32)ts.tv_sec; header->ph_usec = (ts.tv_sec & 0xffffffff00000000ull) | (ts.tv_nsec / NSEC_PER_USEC);
and do the reverse on the user space side. This would be both endian- safe and backwards compatible, although rather ugly.
Indeed, thats' quite ugly. I think in the next 90 years we will need some other adjustments to the log format and should be able to include this one with them (e.g. there are only 16 bits for the cpu, considering we have 260+ core CPUs on the market today, might as well overflow that quite soon).
Ok.
Arnd
On Friday 25 September 2015 12:17:18 Arnd Bergmann wrote:
On Friday 25 September 2015 01:52:37 Drokin, Oleg wrote:
On Sep 24, 2015, at 3:46 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 04:02:09 Drokin, Oleg wrote:
These are all the users. Seems to be pretty much u32 (or unsigned int when printing) everywhere.
Ok, I'll the patch then to clarify this and leave the format unchanged.
This is what I have committed now:
From b56ff589e6a25a6b199c7f526d16281bbc5080a5 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann arnd@arndb.de Date: Fri, 18 Sep 2015 16:02:57 +0200 Subject: [PATCH] staging/lustre: tracefile: document seconds overflow
The lustre tracefile has a timestamp defined as
__u32 ph_sec; __u64 ph_usec;
which seems completely backwards, as the microsecond portion of a time stamp will always fit into a __u32 value, while the second portion will overflow in 2038 or 2106 (in case of unsigned seconds).
Changing this would unfortunately change the format in an incompatible way, breaking all existing user space tools that access the data.
This uses ktime_get_real_ts64() to replace the insufficient do_gettimeofday() and then truncates the seconds portion to an u32 type, along with comments to explain the result.
A possible alternative would be the use of ktime_get_ts64() to read a monotonic timestamp that never overflows, but this would trigger a check in user space 'hdr->ph_sec < (1 << 30)' that attempts to ensure that the values are within a reasonable range.
Signed-off-by: Arnd Bergmann arnd@arndb.de
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h index a3aa644154e2..a1787bb43483 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h @@ -73,6 +73,7 @@ struct ptldebug_header { __u32 ph_mask; __u16 ph_cpu_id; __u16 ph_type; + /* time_t overflow in 2106 */ __u32 ph_sec; __u64 ph_usec; __u32 ph_stack; diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c index 87d844953522..a1a361d1b040 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c @@ -191,16 +191,18 @@ cfs_set_ptldebug_header(struct ptldebug_header *header, struct libcfs_debug_msg_data *msgdata, unsigned long stack) { - struct timeval tv; + struct timespec64 ts;
- do_gettimeofday(&tv); + ktime_get_real_ts64(&ts);
header->ph_subsys = msgdata->msg_subsys; header->ph_mask = msgdata->msg_mask; header->ph_cpu_id = smp_processor_id(); header->ph_type = cfs_trace_buf_idx_get(); - header->ph_sec = (__u32)tv.tv_sec; - header->ph_usec = tv.tv_usec; + /* y2038 safe since all user space treats this as unsigned, but + will overflow in 2106 */ + header->ph_sec = (u32)ts.tv_sec; + header->ph_usec = ts.tv_nsec / NSEC_PER_USEC; header->ph_stack = stack; header->ph_pid = current->pid; header->ph_line_num = msgdata->msg_line;
Some lustre procfs files contain the current time. Make sure we use a format here that does not overflow in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/osc/lproc_osc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index c504d1503fda..515003d9602e 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -597,18 +597,18 @@ static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct obd_device *dev = seq->private; struct client_obd *cli = &dev->u.cli; unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum; int i;
- do_gettimeofday(&now); + ktime_get_real_ts64(&now);
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "read RPCs in flight: %d\n", cli->cl_r_in_flight); seq_printf(seq, "write RPCs in flight: %d\n", @@ -714,14 +714,14 @@ LPROC_SEQ_FOPS(osc_rpc_stats);
static int osc_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct obd_device *dev = seq->private; struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
- do_gettimeofday(&now); + ktime_get_real_ts64(&now);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%9lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "lockless_write_bytes\t\t%llu\n", stats->os_lockless_writes); seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
The l_last_activity struct member is used to keep track lock hold times, and it is printed for debugging purposes. For the elapsed time, we can use 'long' here, but it's better to use time64_t for storing the real time to avoid an overflow in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +- drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 29 +++++++++------------- 3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 92b24be7c21e..796a997ec94c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -749,7 +749,7 @@ struct ldlm_lock { * Seconds. It will be updated if there is any activity related to * the lock, e.g. enqueue the lock or send blocking AST. */ - unsigned long l_last_activity; + time64_t l_last_activity;
/** * Time last used by e.g. being matched by lock match. diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index cd340fc8ceab..12eb5ac3b3d8 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -1564,7 +1564,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns, ldlm_error_t rc = ELDLM_OK; struct ldlm_interval *node = NULL;
- lock->l_last_activity = get_seconds(); + lock->l_last_activity = ktime_get_real_seconds(); /* policies are not executed on the client or during replay */ if ((*flags & (LDLM_FL_HAS_INTENT|LDLM_FL_REPLAY)) == LDLM_FL_HAS_INTENT && !local && ns->ns_policy) { diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index b5ee9bd9875f..1eeb4af1134f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -97,15 +97,13 @@ int ldlm_expired_completion_wait(void *data) if (lock->l_conn_export == NULL) { static unsigned long next_dump, last_dump;
- LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", " - CFS_DURATION_T"s ago)\n", - lock->l_last_activity, - cfs_time_sub(get_seconds(), - lock->l_last_activity)); - LDLM_DEBUG(lock, "lock timed out (enqueued at " CFS_TIME_T ", " CFS_DURATION_T "s ago); not entering recovery in server code, just going back to sleep", - lock->l_last_activity, - cfs_time_sub(get_seconds(), - lock->l_last_activity)); + LCONSOLE_WARN("lock timed out (enqueued at %lld, %llds ago)\n", + (s64)lock->l_last_activity, + (s64)(ktime_get_real_seconds() - + lock->l_last_activity)); + LDLM_DEBUG(lock, "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep", + (s64)lock->l_last_activity, + (s64)(ktime_get_real_seconds() - lock->l_last_activity)); if (cfs_time_after(cfs_time_current(), next_dump)) { last_dump = next_dump; next_dump = cfs_time_shift(300); @@ -120,10 +118,9 @@ int ldlm_expired_completion_wait(void *data) obd = lock->l_conn_export->exp_obd; imp = obd->u.cli.cl_import; ptlrpc_fail_import(imp, lwd->lwd_conn_cnt); - LDLM_ERROR(lock, "lock timed out (enqueued at "CFS_TIME_T", " - CFS_DURATION_T"s ago), entering recovery for %s@%s", - lock->l_last_activity, - cfs_time_sub(get_seconds(), lock->l_last_activity), + LDLM_ERROR(lock, "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s", + (s64)lock->l_last_activity, + (s64)(ktime_get_real_seconds() - lock->l_last_activity), obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
return 0; @@ -159,10 +156,8 @@ static int ldlm_completion_tail(struct ldlm_lock *lock) LDLM_DEBUG(lock, "client-side enqueue: destroyed"); result = -EIO; } else { - delay = cfs_time_sub(get_seconds(), - lock->l_last_activity); - LDLM_DEBUG(lock, "client-side enqueue: granted after " - CFS_DURATION_T"s", delay); + delay = ktime_get_real_seconds() - lock->l_last_activity; + LDLM_DEBUG(lock, "client-side enqueue: granted after %lds", delay);
/* Update our time estimate */ at_measured(ldlm_lock_to_ns_at(lock),
process_param2_config() tries to print how much time has passed across a call_usermodehelper() function, and uses struct timeval for that.
We want to remove this structure, so this is better expressed in terms of ktime_t and ktime_us_delta().
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/obdclass/obd_config.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c index b86a47c54029..3bbc80623b3a 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c @@ -1021,8 +1021,8 @@ static int process_param2_config(struct lustre_cfg *lcfg) [2] = param, [3] = NULL }; - struct timeval start; - struct timeval end; + ktime_t start; + ktime_t end; int rc;
@@ -1032,19 +1032,19 @@ static int process_param2_config(struct lustre_cfg *lcfg) return -EINVAL; }
- do_gettimeofday(&start); + start = ktime_get(); rc = call_usermodehelper(argv[0], argv, NULL, 1); - do_gettimeofday(&end); + end = ktime_get();
if (rc < 0) { CERROR( "lctl: error invoking upcall %s %s %s: rc = %d; time %ldus\n", argv[0], argv[1], argv[2], rc, - cfs_timeval_sub(&end, &start, NULL)); + (long)ktime_us_delta(end, start)); } else { CDEBUG(D_HA, "lctl: invoked upcall %s %s %s, time %ldus\n", argv[0], argv[1], argv[2], - cfs_timeval_sub(&end, &start, NULL)); + (long)ktime_us_delta(end, start)); rc = 0; }
The rq_at_index member of ptlrpc_request is incorrectly declared as time_t, when it is only used as an index into an array, and assigned from a __u32 variable.
This changes the type to u32, so we can kill off another use of time_t.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index c9c21d289e92..44adee134563 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1292,7 +1292,7 @@ struct ptlrpc_request { struct ptlrpc_nrs_request rq_nrq; /** @} nrs */ /** the index of service's srv_at_array into which request is linked */ - time_t rq_at_index; + u32 rq_at_index; /** Lock to protect request flags and some other important bits, like * rq_list */
The lnet_eq_wait_locked tries to wait for time to pass or an event to wake up the wait queue. The entire logic seems to be a very elaborate reimplementation of wait_event().
I'm not trying to clean up the entire logic here, but this at least gets rid of the multi-way conversion between miliseconds, timeval and jiffies.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/lnet/lib-eq.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index f19ce9ae6a9a..8b843c5e71a5 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -341,12 +341,9 @@ __must_hold(&the_lnet.ln_eq_wait_lock) schedule();
} else { - struct timeval tv; - - now = cfs_time_current(); - schedule_timeout(cfs_time_seconds(tms) / 1000); - cfs_duration_usec(cfs_time_sub(cfs_time_current(), now), &tv); - tms -= (int)(tv.tv_sec * 1000 + tv.tv_usec / 1000); + now = jiffies; + schedule_timeout(msecs_to_jiffies(tms)); + tms -= jiffies_to_msecs(jiffies - now); if (tms < 0) /* no more wait but may have new event */ tms = 0; }
This ioctl function passes a 64-bit time argument but then performs a computation with a 32-bit get_seconds() value.
In order to avoid overflow here, this changes the code to use 64-bit math and ktime_get_real_seconds().
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/lnet/api-ni.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c index 7fab03bee1ea..c368cf561b9d 100644 --- a/drivers/staging/lustre/lnet/lnet/api-ni.c +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c @@ -1343,6 +1343,7 @@ LNetCtl(unsigned int cmd, void *arg) lnet_process_id_t id = {0}; lnet_ni_t *ni; int rc; + unsigned long secs_passed;
LASSERT(the_lnet.ln_init); LASSERT(the_lnet.ln_refcount > 0); @@ -1370,10 +1371,9 @@ LNetCtl(unsigned int cmd, void *arg) &data->ioc_nid, &data->ioc_flags, &data->ioc_priority); case IOC_LIBCFS_NOTIFY_ROUTER: + secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]); return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, - cfs_time_current() - - cfs_time_seconds(get_seconds() - - (time_t)data->ioc_u64[0])); + jiffies - secs_passed * HZ);
case IOC_LIBCFS_PORTALS_COMPATIBILITY: /* This can be removed once lustre stops calling it */
The cfs_duration_sec() converts a relative jiffies value into seconds, and returns that number as a time_t. We know that a 32-bit type is enough here, because the result is order of magnitudes smaller than the difference in jiffies that is also expressed as a 'long', so we can safely replace the time_t type with long as well.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 0fc490bac2b5..b0af90907020 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -90,7 +90,7 @@ static inline long cfs_time_seconds(int seconds) return ((long)seconds) * HZ; }
-static inline time_t cfs_duration_sec(long d) +static inline long cfs_duration_sec(long d) { return d / HZ; }
The cfs_duration_usec() function has a timeval as its output, which we want to avoid in general because of the y2038 problem.
There are only two locations remaining in lustre, so we can for now replace one with jiffies_to_timeval(), which is a generic kernel function that does the same thing, the other can just use jiffies_to_usecs() and completely avoid the timeval.
This is not a full solution yet, but it's a small step that lets use build a larger portion of lustre without this reference to timeval in a header file, and avoid triggering automated checking tools that want to warn about timeval.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../lustre/include/linux/libcfs/linux/linux-time.h | 15 --------------- drivers/staging/lustre/lnet/selftest/conrpc.c | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 6 +----- 3 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index b0af90907020..f193f8bdee6e 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -95,21 +95,6 @@ static inline long cfs_duration_sec(long d) return d / HZ; }
-static inline void cfs_duration_usec(long d, struct timeval *s) -{ -#if (BITS_PER_LONG == 32) && (HZ > 4096) - __u64 t; - - s->tv_sec = d / HZ; - t = (d - (long)s->tv_sec * HZ) * ONE_MILLION; - do_div(t, HZ); - s->tv_usec = t; -#else - s->tv_sec = d / HZ; - s->tv_usec = ((d - (long)s->tv_sec * HZ) * ONE_MILLION) / HZ; -#endif -} - #define cfs_time_current_64 get_jiffies_64
static inline __u64 cfs_time_add_64(__u64 t, __u64 d) diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index a1a4e08f7391..bf2968310516 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -505,7 +505,7 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
dur = (long)cfs_time_sub(crpc->crp_stamp, (unsigned long)console_session.ses_id.ses_stamp); - cfs_duration_usec(dur, &tv); + jiffies_to_timeval(dur, &tv);
if (copy_to_user(&ent->rpe_peer, &nd->nd_id, sizeof(lnet_process_id_t)) || diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index 257de3537671..c448037a3c9f 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -372,7 +372,6 @@ sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply) sfw_session_t *sn = sfw_data.fw_session; sfw_counters_t *cnt = &reply->str_fw; sfw_batch_t *bat; - struct timeval tv;
reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -391,10 +390,7 @@ sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
/* send over the msecs since the session was started - with 32 bits to send, this is ~49 days */ - cfs_duration_usec(cfs_time_sub(cfs_time_current(), - sn->sn_started), &tv); - - cnt->running_ms = (__u32)(tv.tv_sec * 1000 + tv.tv_usec / 1000); + cnt->running_ms = jiffies_to_msecs(jiffies - sn->sn_started); cnt->brw_errors = atomic_read(&sn->sn_brw_errors); cnt->ping_errors = atomic_read(&sn->sn_ping_errors); cnt->zombie_sessions = atomic_read(&sfw_data.fw_nzombies);
ibn_incarnation is a 64-bit value, but using timeval to compute it will cause an overflow in 2038. This changes it to use ktime_get_real_ts64() instead.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c index faa70f0b9b1e..5a157a744a7d 100644 --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c @@ -2749,7 +2749,7 @@ int kiblnd_startup(lnet_ni_t *ni) char *ifname; kib_dev_t *ibdev = NULL; kib_net_t *net; - struct timeval tv; + struct timespec64 tv; unsigned long flags; int rc; int newdev; @@ -2767,8 +2767,8 @@ int kiblnd_startup(lnet_ni_t *ni) if (net == NULL) goto net_failed;
- do_gettimeofday(&tv); - net->ibn_incarnation = (((__u64)tv.tv_sec) * 1000000) + tv.tv_usec; + ktime_get_real_ts64(&tv); + net->ibn_incarnation = tv.tv_sec * USEC_PER_SEC + tv.tv_nsec / NSEC_PER_USEC;
ni->ni_peertimeout = *kiblnd_tunables.kib_peertimeout; ni->ni_maxtxcredits = *kiblnd_tunables.kib_credits;
This function uses do_gettimeofday() to get a pseudo-random number. There is no bug here, but changing it to use ktime_get_ts64() gets us closer to deprecating do_gettimeofday() and makes slightly more random.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/lnet/router.c | 6 +++--- drivers/staging/lustre/lustre/llite/super25.c | 6 +++--- drivers/staging/lustre/lustre/obdclass/lustre_handles.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 75ff382b9342..2cdda3f0067e 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -237,7 +237,7 @@ static void lnet_shuffle_seed(void) { static int seeded; int lnd_type, seed[2]; - struct timeval tv; + struct timespec64 ts; lnet_ni_t *ni; struct list_head *tmp;
@@ -256,8 +256,8 @@ static void lnet_shuffle_seed(void) seed[0] ^= (LNET_NIDADDR(ni->ni_nid) | lnd_type); }
- do_gettimeofday(&tv); - cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + ktime_get_ts64(&ts); + cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]); seeded = 1; }
diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c index 4cf7af226ad7..a0de99f9e26c 100644 --- a/drivers/staging/lustre/lustre/llite/super25.c +++ b/drivers/staging/lustre/lustre/llite/super25.c @@ -90,7 +90,7 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg)); static int __init init_lustre_lite(void) { lnet_process_id_t lnet_id; - struct timeval tv; + struct timespec64 ts; int i, rc, seed[2];
CLASSERT(sizeof(LUSTRE_VOLATILE_HDR) == LUSTRE_VOLATILE_HDR_LEN + 1); @@ -152,8 +152,8 @@ static int __init init_lustre_lite(void) seed[0] ^= LNET_NIDADDR(lnet_id.nid); }
- do_gettimeofday(&tv); - cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + ktime_get_ts64(&ts); + cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]); setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0); rc = ll_capa_thread_start(); if (rc != 0) diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c index 35a94a8f4fd3..97d79dab2835 100644 --- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c +++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c @@ -193,7 +193,7 @@ EXPORT_SYMBOL(class_handle_free_cb); int class_handle_init(void) { struct handle_bucket *bucket; - struct timeval tv; + struct timespec64 ts; int seed[2];
LASSERT(handle_hash == NULL); @@ -212,8 +212,8 @@ int class_handle_init(void)
/** bug 21430: add randomness to the initial base */ cfs_get_random_bytes(seed, sizeof(seed)); - do_gettimeofday(&tv); - cfs_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]); + ktime_get_ts64(&ts); + cfs_srand(ts.tv_sec ^ seed[0], ts.tv_nsec ^ seed[1]);
cfs_get_random_bytes(&handle_base, sizeof(handle_base)); LASSERT(handle_base != 0ULL);
The s2dhms computes the day/hour/minute/second values from a time_t, which stops working in 2038. This changes the code to take a time64_t argument, and use div_u64_rem() to implement the first division.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 213666b03f7c..36c0690361fb 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -359,10 +359,10 @@ struct obd_histogram; struct dhms { int d, h, m, s; }; -static inline void s2dhms(struct dhms *ts, time_t secs) +static inline void s2dhms(struct dhms *ts, time64_t secs64) { - ts->d = secs / 86400; - secs = secs % 86400; + unsigned int secs; + ts->d = div_u64_rem(secs64, 86400, &secs); ts->h = secs / 3600; secs = secs % 3600; ts->m = secs / 60;
The wire protocol for the ping uses a 64-bit seconds/microseconds pair, but this won't work when one side uses a 32-bit timeval to look up the current time beyond 2038.
This changes the code to use ktime_get_real_ts64() to create a timestamp that has the right format on all machines.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/selftest/ping_test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c index 1dab9984c58e..3a342fded1ba 100644 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c @@ -92,7 +92,7 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu, srpc_ping_reqst_t *req; sfw_test_instance_t *tsi = tsu->tsu_instance; sfw_session_t *sn = tsi->tsi_batch->bat_session; - struct timeval tv; + struct timespec64 ts; int rc;
LASSERT(sn != NULL); @@ -110,9 +110,9 @@ ping_client_prep_rpc(sfw_test_unit_t *tsu, req->pnr_seq = lst_ping_data.pnd_counter++; spin_unlock(&lst_ping_data.pnd_lock);
- cfs_fs_timeval(&tv); - req->pnr_time_sec = tv.tv_sec; - req->pnr_time_usec = tv.tv_usec; + ktime_get_real_ts64(&ts); + req->pnr_time_sec = ts.tv_sec; + req->pnr_time_usec = ts.tv_nsec / NSEC_PER_USEC;
return rc; } @@ -124,7 +124,7 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) sfw_session_t *sn = tsi->tsi_batch->bat_session; srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst; srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply; - struct timeval tv; + struct timespec64 ts;
LASSERT(sn != NULL);
@@ -161,10 +161,10 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc) return; }
- cfs_fs_timeval(&tv); + ktime_get_real_ts64(&ts); CDEBUG(D_NET, "%d reply in %u usec\n", reply->pnr_seq, - (unsigned)((tv.tv_sec - (unsigned)reqst->pnr_time_sec) * 1000000 - + (tv.tv_usec - reqst->pnr_time_usec))); + (unsigned)((ts.tv_sec - reqst->pnr_time_sec) * 1000000 + + (ts.tv_nsec / NSEC_PER_USEC - reqst->pnr_time_usec))); return; }
The ldlm pool calculates elapsed time by comparing the previous and current get_seconds() values, which is unsafe on 32-bit machines after 2038.
This changes the code to use time64_t and ktime_get_real_seconds(), keeping the 'real' instead of 'monotonic' time because of the debug prints.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_dlm.h | 4 +-- drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 30 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h index 796a997ec94c..1ac08e1c0559 100644 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h @@ -256,9 +256,9 @@ struct ldlm_pool { * server_slv * lock_volume_factor. */ atomic_t pl_lock_volume_factor; /** Time when last SLV from server was obtained. */ - time_t pl_recalc_time; + time64_t pl_recalc_time; /** Recalculation period for pool. */ - time_t pl_recalc_period; + time64_t pl_recalc_period; /** Recalculation and shrink operations. */ const struct ldlm_pool_ops *pl_ops; /** Number of planned locks for next period. */ diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index c234acb85f10..6be7b8fc4a51 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -330,14 +330,14 @@ static void ldlm_srv_pool_push_slv(struct ldlm_pool *pl) */ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) { - time_t recalc_interval_sec; + time64_t recalc_interval_sec;
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) return 0;
spin_lock(&pl->pl_lock); - recalc_interval_sec = get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); return 0; @@ -358,7 +358,7 @@ static int ldlm_srv_pool_recalc(struct ldlm_pool *pl) */ ldlm_pool_recalc_grant_plan(pl);
- pl->pl_recalc_time = get_seconds(); + pl->pl_recalc_time = ktime_get_real_seconds(); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); @@ -467,10 +467,10 @@ static void ldlm_cli_pool_pop_slv(struct ldlm_pool *pl) */ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) { - time_t recalc_interval_sec; + time64_t recalc_interval_sec; int ret;
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) return 0;
@@ -478,7 +478,7 @@ static int ldlm_cli_pool_recalc(struct ldlm_pool *pl) /* * Check if we need to recalc lists now. */ - recalc_interval_sec = get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_real_seconds() - pl->pl_recalc_time; if (recalc_interval_sec < pl->pl_recalc_period) { spin_unlock(&pl->pl_lock); return 0; @@ -513,7 +513,7 @@ out: * Time of LRU resizing might be longer than period, * so update after LRU resizing rather than before it. */ - pl->pl_recalc_time = get_seconds(); + pl->pl_recalc_time = ktime_get_real_seconds(); lprocfs_counter_add(pl->pl_stats, LDLM_POOL_TIMING_STAT, recalc_interval_sec); spin_unlock(&pl->pl_lock); @@ -571,10 +571,10 @@ static const struct ldlm_pool_ops ldlm_cli_pool_ops = { */ int ldlm_pool_recalc(struct ldlm_pool *pl) { - time_t recalc_interval_sec; + u32 recalc_interval_sec; int count;
- recalc_interval_sec = get_seconds() - pl->pl_recalc_time; + recalc_interval_sec = ktime_get_seconds() - pl->pl_recalc_time; if (recalc_interval_sec <= 0) goto recalc;
@@ -599,14 +599,14 @@ int ldlm_pool_recalc(struct ldlm_pool *pl) lprocfs_counter_add(pl->pl_stats, LDLM_POOL_RECALC_STAT, count); } - recalc_interval_sec = pl->pl_recalc_time - get_seconds() + + recalc_interval_sec = pl->pl_recalc_time - ktime_get_seconds() + pl->pl_recalc_period; if (recalc_interval_sec <= 0) { /* Prevent too frequent recalculation. */ - CDEBUG(D_DLMTRACE, "Negative interval(%ld), " - "too short period(%ld)", + CDEBUG(D_DLMTRACE, "Negative interval(%d), " + "too short period(%lld)", recalc_interval_sec, - pl->pl_recalc_period); + (s64)pl->pl_recalc_period); recalc_interval_sec = 1; }
@@ -893,7 +893,7 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
spin_lock_init(&pl->pl_lock); atomic_set(&pl->pl_granted, 0); - pl->pl_recalc_time = get_seconds(); + pl->pl_recalc_time = ktime_get_seconds(); atomic_set(&pl->pl_lock_volume_factor, 1);
atomic_set(&pl->pl_grant_rate, 0);
The obd_eviction_timer will overflow in 2038 on 32-bit systems, so replace it with a 64-bit time and ktime_get_real_seconds().
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/obd.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 0dbac3f53f01..f09a0405ff97 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -841,7 +841,7 @@ struct obd_device { struct obd_export *obd_self_export; /* list of exports in LRU order, for ping evictor, with obd_dev_lock */ struct list_head obd_exports_timed; - time_t obd_eviction_timer; /* for ping evictor */ + time64_t obd_eviction_timer; /* for ping evictor */
int obd_max_recoverable_clients; atomic_t obd_connected_clients; diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 40de622450ee..c7c6cff80450 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1085,13 +1085,13 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) * other PING_INTERVAL (see note in ptlrpc_pinger_main), * we better wait for 3. */ exp->exp_obd->obd_eviction_timer = - get_seconds() + 3 * PING_INTERVAL; + ktime_get_real_seconds() + 3 * PING_INTERVAL; CDEBUG(D_HA, "%s: Think about evicting %s from "CFS_TIME_T"\n", exp->exp_obd->obd_name, obd_export_nid2str(oldest_exp), oldest_time); } } else { - if (get_seconds() > + if (ktime_get_real_seconds() > (exp->exp_obd->obd_eviction_timer + extra_delay)) { /* The evictor won't evict anyone who we've heard from * recently, so we don't have to check before we start
This time is only printed in procfs, and can be easily converted to 64-bit to avoid overflowing on 32-bit systems in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_import.h | 4 ++-- .../staging/lustre/lustre/obdclass/lprocfs_status.c | 19 +++++++++---------- drivers/staging/lustre/lustre/ptlrpc/events.c | 2 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index c8b89a359518..99606387f904 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -148,7 +148,7 @@ struct obd_import_conn { #define IMP_STATE_HIST_LEN 16 struct import_state_hist { enum lustre_imp_state ish_state; - time_t ish_time; + time64_t ish_time; };
/** @@ -307,7 +307,7 @@ struct obd_import { __u32 imp_msghdr_flags; /* adjusted based on server capability */
struct imp_at imp_at; /* adaptive timeout data */ - time_t imp_last_reply_time; /* for health check */ + time64_t imp_last_reply_time; /* for health check */ };
typedef void (*obd_import_callback)(struct obd_import *imp, void *closure, diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 8d2a523ea7cf..9887ce1d51e4 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -846,8 +846,7 @@ int lprocfs_rd_state(struct seq_file *m, void *data) &imp->imp_state_hist[(k + j) % IMP_STATE_HIST_LEN]; if (ish->ish_state == 0) continue; - seq_printf(m, " - ["CFS_TIME_T", %s]\n", - ish->ish_time, + seq_printf(m, " - [%lld, %s]\n", (s64)ish->ish_time, ptlrpc_import_state_name(ish->ish_state)); }
@@ -872,7 +871,7 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) struct obd_device *obd = (struct obd_device *)data; struct obd_import *imp; unsigned int cur, worst; - time_t now, worstt; + time64_t now, worstt; struct dhms ts; int i;
@@ -880,12 +879,12 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) LPROCFS_CLIMP_CHECK(obd); imp = obd->u.cli.cl_import;
- now = get_seconds(); + now = ktime_get_real_seconds();
/* Some network health info for kicks */ s2dhms(&ts, now - imp->imp_last_reply_time); - seq_printf(m, "%-10s : %ld, "DHMS_FMT" ago\n", - "last reply", imp->imp_last_reply_time, DHMS_VARS(&ts)); + seq_printf(m, "%-10s : %lld, "DHMS_FMT" ago\n", + "last reply", (s64)imp->imp_last_reply_time, DHMS_VARS(&ts));
cur = at_get(&imp->imp_at.iat_net_latency); worst = imp->imp_at.iat_net_latency.at_worst_ever; @@ -1190,11 +1189,11 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v) int idx = *(loff_t *)v;
if (idx == 0) { - struct timeval now; - do_gettimeofday(&now); - seq_printf(p, "%-25s %lu.%lu secs.usecs\n", + struct timespec64 now; + ktime_get_real_ts64(&now); + seq_printf(p, "%-25s %llu.%9lu secs.usecs\n", "snapshot_time", - now.tv_sec, (unsigned long)now.tv_usec); + (s64)now.tv_sec, (unsigned long)now.tv_nsec); }
hdr = &stats->ls_cnt_header[idx]; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index c8ef9e578263..53f6b6278403 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -158,7 +158,7 @@ void reply_in_callback(lnet_event_t *ev) ev->mlength, ev->offset, req->rq_replen); }
- req->rq_import->imp_last_reply_time = get_seconds(); + req->rq_import->imp_last_reply_time = ktime_get_real_seconds();
out_wake: /* NB don't unlock till after wakeup; req can disappear under us diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index c52ceef989d5..b6f38cbbc295 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -79,7 +79,7 @@ static void __import_set_state(struct obd_import *imp, imp->imp_state = state; imp->imp_state_hist[imp->imp_state_hist_idx].ish_state = state; imp->imp_state_hist[imp->imp_state_hist_idx].ish_time = - get_seconds(); + ktime_get_real_seconds(); imp->imp_state_hist_idx = (imp->imp_state_hist_idx + 1) % IMP_STATE_HIST_LEN; }
On Wed, Sep 23, 2015 at 09:13:42PM +0200, Arnd Bergmann wrote:
This time is only printed in procfs, and can be easily converted to 64-bit to avoid overflowing on 32-bit systems in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de
This introduces new build warnings:
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c: In function ‘lprocfs_rd_timeouts’: drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:894:10: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘time64_t’ [-Wformat=] "network", cur, worst, worstt, DHMS_VARS(&ts)); ^ drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:906:11: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘time64_t’ [-Wformat=] cur, worst, worstt, DHMS_VARS(&ts)); ^
regards sudip
On Thursday 24 September 2015 10:40:09 Sudip Mukherjee wrote:
On Wed, Sep 23, 2015 at 09:13:42PM +0200, Arnd Bergmann wrote:
This time is only printed in procfs, and can be easily converted to 64-bit to avoid overflowing on 32-bit systems in 2038.
Signed-off-by: Arnd Bergmann arnd@arndb.de
This introduces new build warnings:
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c: In function ‘lprocfs_rd_timeouts’: drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:894:10: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘time64_t’ [-Wformat=] "network", cur, worst, worstt, DHMS_VARS(&ts)); ^ drivers/staging/lustre/lustre/obdclass/lprocfs_status.c:906:11: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘time64_t’ [-Wformat=] cur, worst, worstt, DHMS_VARS(&ts)); ^
Sorry about that. I checked all the patches for new warnings but then only did a partial check after rebasing to staging-testing. I'll fix it up and run the full tests again.
Arnd
The adaptive timeout handling stores absolute times in 32-bit time_t quantities, which will overflow in 2038.
This changes it to use time64_t.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_import.h | 6 +++--- drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 8 ++++---- drivers/staging/lustre/lustre/ptlrpc/import.c | 8 ++++---- drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 8 ++++---- 4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 99606387f904..cd6244ecd0c7 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -61,12 +61,12 @@ #define AT_FLG_NOHIST 0x1 /* use last reported value only */
struct adaptive_timeout { - time_t at_binstart; /* bin start time */ + time64_t at_binstart; /* bin start time */ unsigned int at_hist[AT_BINS]; /* timeout history bins */ unsigned int at_flags; unsigned int at_current; /* current timeout value */ unsigned int at_worst_ever; /* worst-ever timeout value */ - time_t at_worst_time; /* worst-ever timeout timestamp */ + time64_t at_worst_time; /* worst-ever timeout timestamp */ spinlock_t at_lock; };
@@ -351,7 +351,7 @@ static inline void at_reset(struct adaptive_timeout *at, int val) spin_lock(&at->at_lock); at->at_current = val; at->at_worst_ever = val; - at->at_worst_time = get_seconds(); + at->at_worst_time = ktime_get_real_seconds(); spin_unlock(&at->at_lock); } static inline void at_init(struct adaptive_timeout *at, int val, int flags) diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index 9887ce1d51e4..7cc0f54f9cd4 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -890,8 +890,8 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) worst = imp->imp_at.iat_net_latency.at_worst_ever; worstt = imp->imp_at.iat_net_latency.at_worst_time; s2dhms(&ts, now - worstt); - seq_printf(m, "%-10s : cur %3u worst %3u (at %ld, "DHMS_FMT" ago) ", - "network", cur, worst, worstt, DHMS_VARS(&ts)); + seq_printf(m, "%-10s : cur %3u worst %3u (at %lld, "DHMS_FMT" ago) ", + "network", cur, worst, (s64)worstt, DHMS_VARS(&ts)); lprocfs_at_hist_helper(m, &imp->imp_at.iat_net_latency);
for (i = 0; i < IMP_AT_MAX_PORTALS; i++) { @@ -901,9 +901,9 @@ int lprocfs_rd_timeouts(struct seq_file *m, void *data) worst = imp->imp_at.iat_service_estimate[i].at_worst_ever; worstt = imp->imp_at.iat_service_estimate[i].at_worst_time; s2dhms(&ts, now - worstt); - seq_printf(m, "portal %-2d : cur %3u worst %3u (at %ld, " + seq_printf(m, "portal %-2d : cur %3u worst %3u (at %lld, " DHMS_FMT" ago) ", imp->imp_at.iat_portal[i], - cur, worst, worstt, DHMS_VARS(&ts)); + cur, worst, (s64)worstt, DHMS_VARS(&ts)); lprocfs_at_hist_helper(m, &imp->imp_at.iat_service_estimate[i]); }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index b6f38cbbc295..3fc49ee66d8b 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -1523,12 +1523,12 @@ extern unsigned int at_min, at_max, at_history; int at_measured(struct adaptive_timeout *at, unsigned int val) { unsigned int old = at->at_current; - time_t now = get_seconds(); - time_t binlimit = max_t(time_t, at_history / AT_BINS, 1); + time64_t now = ktime_get_real_seconds(); + long binlimit = max_t(long, at_history / AT_BINS, 1);
LASSERT(at); CDEBUG(D_OTHER, "add %u to %p time=%lu v=%u (%u %u %u %u)\n", - val, at, now - at->at_binstart, at->at_current, + val, at, (long)(now - at->at_binstart), at->at_current, at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]);
if (val == 0) @@ -1553,7 +1553,7 @@ int at_measured(struct adaptive_timeout *at, unsigned int val) int i, shift; unsigned int maxv = val; /* move bins over */ - shift = (now - at->at_binstart) / binlimit; + shift = (u32)(now - at->at_binstart) / binlimit; LASSERT(shift > 0); for (i = AT_BINS - 1; i >= 0; i--) { if (i >= shift) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 9a10baf711b0..477cc4da31a4 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -990,7 +990,7 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) struct ptlrpc_service *svc = m->private; struct ptlrpc_service_part *svcpt; struct dhms ts; - time_t worstt; + time64_t worstt; unsigned int cur; unsigned int worst; int i; @@ -1005,11 +1005,11 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n) cur = at_get(&svcpt->scp_at_estimate); worst = svcpt->scp_at_estimate.at_worst_ever; worstt = svcpt->scp_at_estimate.at_worst_time; - s2dhms(&ts, get_seconds() - worstt); + s2dhms(&ts, ktime_get_real_seconds() - worstt);
- seq_printf(m, "%10s : cur %3u worst %3u (at %ld, " + seq_printf(m, "%10s : cur %3u worst %3u (at %lld, " DHMS_FMT" ago) ", "service", - cur, worst, worstt, DHMS_VARS(&ts)); + cur, worst, (s64)worstt, DHMS_VARS(&ts));
lprocfs_at_hist_helper(m, &svcpt->scp_at_estimate); }
The llite procfs interface contains timestamps that are computed from timeval, which overflows in 2038 on 32-bit systems.
This changes the output to use a timespec64 type to avoid the overflow. I also change the format to print the sub-second portion as 9 digits (nanoseconds) for clarity, rather than printing six digits without leading zeroes.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/llite/lproc_llite.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c index 427a34b00e85..08d32027d7be 100644 --- a/drivers/staging/lustre/lustre/llite/lproc_llite.c +++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c @@ -1140,20 +1140,20 @@ static void ll_display_extents_info(struct ll_rw_extents_info *io_extents,
static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info; int k;
- do_gettimeofday(&now); + ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" "write anything in this file to activate, then 0 or "[D/d]isabled" to deactivate\n"); return 0; } - seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write"); seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", "extents", "calls", "%", "cum%", @@ -1219,19 +1219,19 @@ LPROC_SEQ_FOPS(ll_rw_extents_stats_pp);
static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct ll_sb_info *sbi = seq->private; struct ll_rw_extents_info *io_extents = &sbi->ll_rw_extents_info;
- do_gettimeofday(&now); + ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" "write anything in this file to activate, then 0 or "[D/d]isabled" to deactivate\n"); return 0; } - seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", + (u64)now.tv_sec, (unsigned long)now.tv_nsec);
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write"); seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n", @@ -1396,13 +1396,13 @@ void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) { - struct timeval now; + struct timespec64 now; struct ll_sb_info *sbi = seq->private; struct ll_rw_process_info *offset = sbi->ll_rw_offset_info; struct ll_rw_process_info *process = sbi->ll_rw_process_info; int i;
- do_gettimeofday(&now); + ktime_get_real_ts64(&now);
if (!sbi->ll_rw_stats_on) { seq_printf(seq, "disabled\n" @@ -1411,8 +1411,8 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v) } spin_lock(&sbi->ll_process_lock);
- seq_printf(seq, "snapshot_time: %lu.%lu (secs.usecs)\n", - now.tv_sec, (unsigned long)now.tv_usec); + seq_printf(seq, "snapshot_time: %llu.%09lu (secs.usecs)\n", + (s64)now.tv_sec, (unsigned long)now.tv_nsec); seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n", "R/W", "PID", "RANGE START", "RANGE END", "SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET");
The connection starting/failing time stamps will overflow in 2038 on 32-bit machines, so we need to use time64_t and ktime_get_real_seconds() instead.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +- drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h | 6 +++--- drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c index 22f4cd0173c1..904d15837cbb 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c @@ -2426,7 +2426,7 @@ ksocknal_base_startup(void)
ksocknal_data.ksnd_connd_starting = 0; ksocknal_data.ksnd_connd_failed_stamp = 0; - ksocknal_data.ksnd_connd_starting_stamp = get_seconds(); + ksocknal_data.ksnd_connd_starting_stamp = ktime_get_real_seconds(); /* must have at least 2 connds to remain responsive to accepts while * connecting */ if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1) diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h index a0fcbc39f86b..b349847f9cf9 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h @@ -216,13 +216,13 @@ typedef struct { wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */ int ksnd_connd_connecting; /* # connds connecting */ - long ksnd_connd_failed_stamp;/* time stamp of the + time64_t ksnd_connd_failed_stamp;/* time stamp of the * last failed * connecting attempt */ - unsigned ksnd_connd_starting; /* # starting connd */ - long ksnd_connd_starting_stamp;/* time stamp of the + time64_t ksnd_connd_starting_stamp;/* time stamp of the * last starting connd */ + unsigned ksnd_connd_starting; /* # starting connd */ unsigned ksnd_connd_running; /* # running connd */ spinlock_t ksnd_connd_lock; /* serialise */
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c index 6d87731c539d..354c8105f9a0 100644 --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c @@ -1998,7 +1998,7 @@ ksocknal_connect (ksock_route_t *route) * running out of resource. */ static int -ksocknal_connd_check_start(long sec, long *timeout) +ksocknal_connd_check_start(time64_t sec, long *timeout) { char name[16]; int rc; @@ -2048,7 +2048,7 @@ ksocknal_connd_check_start(long sec, long *timeout) /* we tried ... */ LASSERT(ksocknal_data.ksnd_connd_starting > 0); ksocknal_data.ksnd_connd_starting--; - ksocknal_data.ksnd_connd_failed_stamp = get_seconds(); + ksocknal_data.ksnd_connd_failed_stamp = ktime_get_real_seconds();
return 1; } @@ -2060,7 +2060,7 @@ ksocknal_connd_check_start(long sec, long *timeout) * again to recheck these conditions. */ static int -ksocknal_connd_check_stop(long sec, long *timeout) +ksocknal_connd_check_stop(time64_t sec, long *timeout) { int val;
@@ -2141,7 +2141,7 @@ ksocknal_connd (void *arg)
while (!ksocknal_data.ksnd_shuttingdown) { ksock_route_t *route = NULL; - long sec = get_seconds(); + time64_t sec = ktime_get_real_seconds(); long timeout = MAX_SCHEDULE_TIMEOUT; int dropped_lock = 0;
The ni_last_alive member of lnet_ni uses a 'long' to store a timestamp, which breaks on 32-bit systems in 2038.
This changes it to use time64_t and the respective functions for it.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/include/linux/lnet/lib-types.h | 2 +- drivers/staging/lustre/lnet/lnet/config.c | 2 +- drivers/staging/lustre/lnet/lnet/lib-move.c | 4 ++-- drivers/staging/lustre/lnet/lnet/router.c | 4 ++-- drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h index 81a63dbdea25..d792c4adb0ca 100644 --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h @@ -264,7 +264,7 @@ typedef struct lnet_ni { lnd_t *ni_lnd; /* procedural interface */ struct lnet_tx_queue **ni_tx_queues; /* percpt TX queues */ int **ni_refs; /* percpt reference count */ - long ni_last_alive;/* when I was last alive */ + time64_t ni_last_alive;/* when I was last alive */ lnet_ni_status_t *ni_status; /* my health status */ /* equivalent interfaces to use */ char *ni_interfaces[LNET_MAX_INTERFACES]; diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c index 9c576ce2f455..b09a438c49d6 100644 --- a/drivers/staging/lustre/lnet/lnet/config.c +++ b/drivers/staging/lustre/lnet/lnet/config.c @@ -166,7 +166,7 @@ lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
/* LND will fill in the address part of the NID */ ni->ni_nid = LNET_MKNID(net, 0); - ni->ni_last_alive = get_seconds(); + ni->ni_last_alive = ktime_get_real_seconds(); list_add_tail(&ni->ni_list, nilist); return ni; failed: diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c index 433faae9a2ff..6badfec4c6a0 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-move.c +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c @@ -1768,11 +1768,11 @@ lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid, }
if (the_lnet.ln_routing && - ni->ni_last_alive != get_seconds()) { + ni->ni_last_alive != ktime_get_real_seconds()) { lnet_ni_lock(ni);
/* NB: so far here is the only place to set NI status to "up */ - ni->ni_last_alive = get_seconds(); + ni->ni_last_alive = ktime_get_real_seconds(); if (ni->ni_status != NULL && ni->ni_status->ns_status == LNET_NI_STATUS_DOWN) ni->ni_status->ns_status = LNET_NI_STATUS_UP; diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c index 2cdda3f0067e..0357b051401f 100644 --- a/drivers/staging/lustre/lnet/lnet/router.c +++ b/drivers/staging/lustre/lnet/lnet/router.c @@ -789,7 +789,7 @@ static void lnet_update_ni_status_locked(void) { lnet_ni_t *ni; - long now; + time64_t now; int timeout;
LASSERT(the_lnet.ln_routing); @@ -797,7 +797,7 @@ lnet_update_ni_status_locked(void) timeout = router_ping_timeout + max(live_router_check_interval, dead_router_check_interval);
- now = get_seconds(); + now = ktime_get_real_seconds(); list_for_each_entry(ni, &the_lnet.ln_nis, ni_list) { if (ni->ni_lnd->lnd_type == LOLND) continue; diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c index a9f4cbf2fcfe..396c7c4e5c83 100644 --- a/drivers/staging/lustre/lnet/lnet/router_proc.c +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c @@ -692,7 +692,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write, if (ni != NULL) { struct lnet_tx_queue *tq; char *stat; - long now = get_seconds(); + time64_t now = ktime_get_real_seconds(); int last_alive = -1; int i; int j;
The lustre selftest code has multiple time stamps that are kept as 'time_t' or 'unsigned long' and can therefore overflow on 32-bit systems.
This changes the code to use time64_t instead.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lnet/selftest/brw_test.c | 6 +++--- drivers/staging/lustre/lnet/selftest/conctl.c | 2 +- drivers/staging/lustre/lnet/selftest/conrpc.c | 15 +++++++-------- drivers/staging/lustre/lnet/selftest/console.c | 2 +- drivers/staging/lustre/lnet/selftest/console.h | 2 +- drivers/staging/lustre/lnet/selftest/framework.c | 3 +-- drivers/staging/lustre/lnet/selftest/rpc.c | 9 ++++----- drivers/staging/lustre/lnet/selftest/selftest.h | 2 +- drivers/staging/lustre/lnet/selftest/timer.c | 14 +++++++------- drivers/staging/lustre/lnet/selftest/timer.h | 2 +- 10 files changed, 27 insertions(+), 30 deletions(-)
diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c index de11f1bc8be7..0605c651f797 100644 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c @@ -134,14 +134,14 @@ brw_client_init(sfw_test_instance_t *tsi) static int brw_inject_one_error(void) { - struct timeval tv; + struct timespec64 ts;
if (brw_inject_errors <= 0) return 0;
- do_gettimeofday(&tv); + ktime_get_ts64(&ts);
- if ((tv.tv_usec & 1) == 0) + if (((ts.tv_nsec / NSEC_PER_USEC) & 1) == 0) return 0;
return brw_inject_errors--; diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c index 1a7870e91f23..817396638652 100644 --- a/drivers/staging/lustre/lnet/selftest/conctl.c +++ b/drivers/staging/lustre/lnet/selftest/conctl.c @@ -837,7 +837,7 @@ lstcon_ioctl_entry(unsigned int cmd, struct libcfs_ioctl_data *data)
mutex_lock(&console_session.ses_mutex);
- console_session.ses_laststamp = get_seconds(); + console_session.ses_laststamp = ktime_get_real_seconds();
if (console_session.ses_shutdown) { rc = -ESHUTDOWN; diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c index bf2968310516..b70680b8bdbe 100644 --- a/drivers/staging/lustre/lnet/selftest/conrpc.c +++ b/drivers/staging/lustre/lnet/selftest/conrpc.c @@ -1176,7 +1176,7 @@ lstcon_rpc_pinger(void *arg) srpc_debug_reqst_t *drq; lstcon_ndlink_t *ndl; lstcon_node_t *nd; - time_t intv; + int intv; int count = 0; int rc;
@@ -1191,8 +1191,8 @@ lstcon_rpc_pinger(void *arg) }
if (!console_session.ses_expired && - get_seconds() - console_session.ses_laststamp > - (time_t)console_session.ses_timeout) + ktime_get_real_seconds() - console_session.ses_laststamp > + (time64_t)console_session.ses_timeout) console_session.ses_expired = 1;
trans = console_session.ses_ping; @@ -1248,9 +1248,8 @@ lstcon_rpc_pinger(void *arg) if (nd->nd_state != LST_NODE_ACTIVE) continue;
- intv = cfs_duration_sec(cfs_time_sub(cfs_time_current(), - nd->nd_stamp)); - if (intv < (time_t)nd->nd_timeout / 2) + intv = (jiffies - nd->nd_stamp) / HZ; + if (intv < nd->nd_timeout / 2) continue;
rc = lstcon_rpc_init(nd, SRPC_SERVICE_DEBUG, @@ -1278,7 +1277,7 @@ lstcon_rpc_pinger(void *arg)
CDEBUG(D_NET, "Ping %d nodes in session\n", count);
- ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL); + ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL; stt_add_timer(ptimer);
mutex_unlock(&console_session.ses_mutex); @@ -1301,7 +1300,7 @@ lstcon_rpc_pinger_start(void) }
ptimer = &console_session.ses_ping_timer; - ptimer->stt_expires = (unsigned long)(get_seconds() + LST_PING_INTERVAL); + ptimer->stt_expires = ktime_get_real_seconds() + LST_PING_INTERVAL;
stt_add_timer(ptimer);
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c index 5c624e19eaa1..024aaee76b7f 100644 --- a/drivers/staging/lustre/lnet/selftest/console.c +++ b/drivers/staging/lustre/lnet/selftest/console.c @@ -2004,7 +2004,7 @@ lstcon_console_init(void) console_session.ses_expired = 0; console_session.ses_feats_updated = 0; console_session.ses_features = LST_FEATS_MASK; - console_session.ses_laststamp = get_seconds(); + console_session.ses_laststamp = ktime_get_real_seconds();
mutex_init(&console_session.ses_mutex);
diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h index cdce2dd6be7c..acd131218dd9 100644 --- a/drivers/staging/lustre/lnet/selftest/console.h +++ b/drivers/staging/lustre/lnet/selftest/console.h @@ -142,7 +142,7 @@ typedef struct { int ses_key; /* local session key */ int ses_state; /* state of session */ int ses_timeout; /* timeout in seconds */ - time_t ses_laststamp; /* last operation stamp (seconds) + time64_t ses_laststamp; /* last operation stamp (seconds) */ unsigned ses_features; /* tests features of the session */ diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c index c448037a3c9f..177beaf496c4 100644 --- a/drivers/staging/lustre/lnet/selftest/framework.c +++ b/drivers/staging/lustre/lnet/selftest/framework.c @@ -170,8 +170,7 @@ sfw_add_session_timer(void) LASSERT(!sn->sn_timer_active);
sn->sn_timer_active = 1; - timer->stt_expires = cfs_time_add(sn->sn_timeout, - get_seconds()); + timer->stt_expires = ktime_get_real_seconds() + sn->sn_timeout; stt_add_timer(timer); return; } diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c index 6ae133138b17..5798a71ae30a 100644 --- a/drivers/staging/lustre/lnet/selftest/rpc.c +++ b/drivers/staging/lustre/lnet/selftest/rpc.c @@ -565,7 +565,7 @@ srpc_add_buffer(struct swi_workitem *wi) }
if (rc != 0) { - scd->scd_buf_err_stamp = get_seconds(); + scd->scd_buf_err_stamp = ktime_get_real_seconds(); scd->scd_buf_err = rc;
LASSERT(scd->scd_buf_posting > 0); @@ -1100,8 +1100,7 @@ srpc_add_client_rpc_timer(srpc_client_rpc_t *rpc) INIT_LIST_HEAD(&timer->stt_list); timer->stt_data = rpc; timer->stt_func = srpc_client_rpc_expired; - timer->stt_expires = cfs_time_add(rpc->crpc_timeout, - get_seconds()); + timer->stt_expires = ktime_get_real_seconds() + rpc->crpc_timeout; stt_add_timer(timer); return; } @@ -1488,7 +1487,7 @@ srpc_lnet_ev_handler(lnet_event_t *ev) }
if (scd->scd_buf_err_stamp != 0 && - scd->scd_buf_err_stamp < get_seconds()) { + scd->scd_buf_err_stamp < ktime_get_real_seconds()) { /* re-enable adding buffer */ scd->scd_buf_err_stamp = 0; scd->scd_buf_err = 0; @@ -1593,7 +1592,7 @@ srpc_startup(void) /* 1 second pause to avoid timestamp reuse */ set_current_state(TASK_UNINTERRUPTIBLE); schedule_timeout(cfs_time_seconds(1)); - srpc_data.rpc_matchbits = ((__u64) get_seconds()) << 48; + srpc_data.rpc_matchbits = ((__u64) ktime_get_real_seconds()) << 48;
srpc_data.rpc_state = SRPC_STATE_NONE;
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h index 160d68ce6ffd..48322539a3a3 100644 --- a/drivers/staging/lustre/lnet/selftest/selftest.h +++ b/drivers/staging/lustre/lnet/selftest/selftest.h @@ -279,7 +279,7 @@ struct srpc_service_cd { /** error code for scd_buf_wi */ int scd_buf_err; /** timestamp for scd_buf_err */ - unsigned long scd_buf_err_stamp; + time64_t scd_buf_err_stamp; /** total # request buffers */ int scd_buf_total; /** # posted request buffers */ diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c index 6133b54f4a82..ebd5f79126c9 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.c +++ b/drivers/staging/lustre/lnet/selftest/timer.c @@ -78,13 +78,13 @@ stt_add_timer(stt_timer_t *timer) LASSERT(!stt_data.stt_shuttingdown); LASSERT(timer->stt_func != NULL); LASSERT(list_empty(&timer->stt_list)); - LASSERT(cfs_time_after(timer->stt_expires, get_seconds())); + LASSERT(timer->stt_expires > ktime_get_real_seconds());
/* a simple insertion sort */ list_for_each_prev(pos, STTIMER_SLOT(timer->stt_expires)) { stt_timer_t *old = list_entry(pos, stt_timer_t, stt_list);
- if (cfs_time_aftereq(timer->stt_expires, old->stt_expires)) + if (timer->stt_expires >= old->stt_expires) break; } list_add(&timer->stt_list, pos); @@ -122,7 +122,7 @@ stt_del_timer(stt_timer_t *timer)
/* called with stt_data.stt_lock held */ static int -stt_expire_list(struct list_head *slot, unsigned long now) +stt_expire_list(struct list_head *slot, time64_t now) { int expired = 0; stt_timer_t *timer; @@ -130,7 +130,7 @@ stt_expire_list(struct list_head *slot, unsigned long now) while (!list_empty(slot)) { timer = list_entry(slot->next, stt_timer_t, stt_list);
- if (cfs_time_after(timer->stt_expires, now)) + if (timer->stt_expires > now) break;
list_del_init(&timer->stt_list); @@ -149,10 +149,10 @@ static int stt_check_timers(unsigned long *last) { int expired = 0; - unsigned long now; + time64_t now; unsigned long this_slot;
- now = get_seconds(); + now = ktime_get_real_seconds(); this_slot = now & STTIMER_SLOTTIMEMASK;
spin_lock(&stt_data.stt_lock); @@ -212,7 +212,7 @@ stt_startup(void) int i;
stt_data.stt_shuttingdown = 0; - stt_data.stt_prev_slot = get_seconds() & STTIMER_SLOTTIMEMASK; + stt_data.stt_prev_slot = ktime_get_real_seconds() & STTIMER_SLOTTIMEMASK;
spin_lock_init(&stt_data.stt_lock); for (i = 0; i < STTIMER_NSLOTS; i++) diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h index 2a8803d89de4..03e2ee294c1c 100644 --- a/drivers/staging/lustre/lnet/selftest/timer.h +++ b/drivers/staging/lustre/lnet/selftest/timer.h @@ -40,7 +40,7 @@
typedef struct { struct list_head stt_list; - unsigned long stt_expires; + time64_t stt_expires; void (*stt_func) (void *); void *stt_data; } stt_timer_t;
Here, we actually have a problem in 2038 or at the latest in 2106 when the lc_expiry variable on the wire protocol overflows, including on 64-bit architectures.
I'm changing the internal implementation so it only compares the lower 31 bits of the current time, using the algorithm from time_before(), which should work as long as nothing tries to directly access lc_expiry.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../staging/lustre/lustre/include/lustre/lustre_idl.h | 1 + drivers/staging/lustre/lustre/include/lustre_capa.h | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h index d20e199eb770..e0cec23e8344 100644 --- a/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h +++ b/drivers/staging/lustre/lustre/include/lustre/lustre_idl.h @@ -3478,6 +3478,7 @@ struct lustre_capa { __u32 lc_flags; /** HMAC algorithm & flags */ __u32 lc_keyid; /** key# used for the capability */ __u32 lc_timeout; /** capa timeout value (sec) */ +/* FIXME: y2038 time_t overflow: */ __u32 lc_expiry; /** expiry time (sec) */ __u8 lc_hmac[CAPA_HMAC_MAX_LEN]; /** HMAC */ } __attribute__((packed)); diff --git a/drivers/staging/lustre/lustre/include/lustre_capa.h b/drivers/staging/lustre/lustre/include/lustre_capa.h index 11bcdb935443..b75f7308d777 100644 --- a/drivers/staging/lustre/lustre/include/lustre_capa.h +++ b/drivers/staging/lustre/lustre/include/lustre_capa.h @@ -266,20 +266,24 @@ static inline __u64 capa_open_opc(int mode)
static inline void set_capa_expiry(struct obd_capa *ocapa) { - unsigned long expiry = cfs_time_sub((unsigned long)ocapa->c_capa.lc_expiry, - get_seconds()); - ocapa->c_expiry = cfs_time_add(cfs_time_current(), - cfs_time_seconds(expiry)); + u32 expiry = ocapa->c_capa.lc_expiry - (u32)ktime_get_real_seconds(); + ocapa->c_expiry = jiffies + expiry * HZ; }
static inline int capa_is_expired_sec(struct lustre_capa *capa) { - return (capa->lc_expiry - get_seconds() <= 0); + /* + * workaround for y2038 problem: do the same as time_before, but + * use 32-bit arithmetic, because lc_expiry is transmitted as a 32-bit + * variable on the wire + */ + s32 diff = capa->lc_expiry - (u32)ktime_get_real_seconds(); + return diff <= 0; }
static inline int capa_is_expired(struct obd_capa *ocapa) { - return time_before_eq(ocapa->c_expiry, cfs_time_current()); + return time_before_eq(ocapa->c_expiry, jiffies); }
static inline int capa_opc_supported(struct lustre_capa *capa, __u64 opc)
ptlrpc_enc_page_pool computes time deltas using 'long' values from get_seconds(). This is probably safe beyond y2038, but it's better to go use monotonic times and 64-bit here for consistency.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 2ee3e8b2e879..56dab9db4157 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -92,8 +92,8 @@ static struct ptlrpc_enc_page_pool { unsigned long epp_idle_idx;
/* last shrink time due to mem tight */ - long epp_last_shrink; - long epp_last_access; + time64_t epp_last_shrink; + time64_t epp_last_access;
/* * in-pool pages bookkeeping @@ -153,8 +153,8 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) page_pools.epp_total_pages, page_pools.epp_free_pages, page_pools.epp_idle_idx, - get_seconds() - page_pools.epp_last_shrink, - get_seconds() - page_pools.epp_last_access, + (long)(ktime_get_seconds() - page_pools.epp_last_shrink), + (long)(ktime_get_seconds() - page_pools.epp_last_access), page_pools.epp_st_max_pages, page_pools.epp_st_grows, page_pools.epp_st_grow_fails, @@ -226,7 +226,7 @@ static unsigned long enc_pools_shrink_count(struct shrinker *s, * if no pool access for a long time, we consider it's fully idle. * a little race here is fine. */ - if (unlikely(get_seconds() - page_pools.epp_last_access > + if (unlikely(ktime_get_seconds() - page_pools.epp_last_access > CACHE_QUIESCENT_PERIOD)) { spin_lock(&page_pools.epp_lock); page_pools.epp_idle_idx = IDLE_IDX_MAX; @@ -253,7 +253,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, (long)sc->nr_to_scan, page_pools.epp_free_pages);
page_pools.epp_st_shrinks++; - page_pools.epp_last_shrink = get_seconds(); + page_pools.epp_last_shrink = ktime_get_seconds(); } spin_unlock(&page_pools.epp_lock);
@@ -261,7 +261,7 @@ static unsigned long enc_pools_shrink_scan(struct shrinker *s, * if no pool access for a long time, we consider it's fully idle. * a little race here is fine. */ - if (unlikely(get_seconds() - page_pools.epp_last_access > + if (unlikely(ktime_get_seconds() - page_pools.epp_last_access > CACHE_QUIESCENT_PERIOD)) { spin_lock(&page_pools.epp_lock); page_pools.epp_idle_idx = IDLE_IDX_MAX; @@ -457,7 +457,7 @@ static inline void enc_pools_wakeup(void) } }
-static int enc_pools_should_grow(int page_needed, long now) +static int enc_pools_should_grow(int page_needed, time64_t now) { /* don't grow if someone else is growing the pools right now, * or the pools has reached its full capacity @@ -521,7 +521,7 @@ again: if (tick == 0) tick = cfs_time_current();
- now = get_seconds(); + now = ktime_get_seconds();
page_pools.epp_st_missings++; page_pools.epp_pages_short += desc->bd_iov_count; @@ -600,7 +600,7 @@ again: this_idle) / (IDLE_IDX_WEIGHT + 1);
- page_pools.epp_last_access = get_seconds(); + page_pools.epp_last_access = ktime_get_seconds();
spin_unlock(&page_pools.epp_lock); return 0; @@ -725,8 +725,8 @@ int sptlrpc_enc_pool_init(void) page_pools.epp_growing = 0;
page_pools.epp_idle_idx = 0; - page_pools.epp_last_shrink = get_seconds(); - page_pools.epp_last_access = get_seconds(); + page_pools.epp_last_shrink = ktime_get_seconds(); + page_pools.epp_last_access = ktime_get_seconds();
spin_lock_init(&page_pools.epp_lock); page_pools.epp_total_pages = 0;
This adapts the format string and get_seconds() call to not overflow in 2038 in the libcfs_debug_dumplog_internal() function.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/libcfs/debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index e93f556fac0d..ae325f750eeb 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -452,8 +452,8 @@ void libcfs_debug_dumplog_internal(void *arg)
if (strncmp(libcfs_debug_file_path_arr, "NONE", 4) != 0) { snprintf(debug_file_name, sizeof(debug_file_name) - 1, - "%s.%ld.%ld", libcfs_debug_file_path_arr, - get_seconds(), (long_ptr_t)arg); + "%s.%lld.%ld", libcfs_debug_file_path_arr, + (s64)ktime_get_real_seconds(), (long_ptr_t)arg); pr_alert("LustreError: dumping log to %s\n", debug_file_name); cfs_tracefile_dump_all_pages(debug_file_name);
The ll_setattr_raw() function prints the new inode timestamps along with the current time using '%lu', which overflows in 2106. This changes the printing of the current time for now, the other two will change when we migrate the VFS code to use 64-bit timestamps.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/llite/llite_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 8dc3de11bb74..524fcc9fc188 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -1324,9 +1324,9 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import) }
if (attr->ia_valid & (ATTR_MTIME | ATTR_CTIME)) - CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %lu\n", + CDEBUG(D_INODE, "setting mtime %lu, ctime %lu, now = %llu\n", LTIME_S(attr->ia_mtime), LTIME_S(attr->ia_ctime), - get_seconds()); + (s64)ktime_get_real_seconds());
/* If we are changing file size, file content is modified, flag it. */ if (attr->ia_valid & ATTR_SIZE) {
These three are timestamps that are sent over the wire in mdc_lib and the obd logging 64-bit values, but are generated using the 32-bit get_seconds() function, which will eventually overflow.
Changing them to use 64-bit ktime_get_real_seconds() solves the problem.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/llite/llite_lib.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_request.c | 2 +- drivers/staging/lustre/lustre/obdclass/llog.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 524fcc9fc188..a0ae892872f5 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -2218,7 +2218,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data, op_data->op_name = name; op_data->op_namelen = namelen; op_data->op_mode = mode; - op_data->op_mod_time = get_seconds(); + op_data->op_mod_time = ktime_get_real_seconds(); op_data->op_fsuid = from_kuid(&init_user_ns, current_fsuid()); op_data->op_fsgid = from_kgid(&init_user_ns, current_fsgid()); op_data->op_cap = cfs_curproc_cap_pack(); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index d32ae761c05f..fd6fc10349c3 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -402,7 +402,7 @@ static int mdc_xattr_common(struct obd_export *exp, rec->sx_suppgid2 = -1; rec->sx_fid = *fid; rec->sx_valid = valid | OBD_MD_FLCTIME; - rec->sx_time = get_seconds(); + rec->sx_time = ktime_get_real_seconds(); rec->sx_size = output_size; rec->sx_flags = flags;
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c index 78d92269aab6..8cad47080456 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog.c +++ b/drivers/staging/lustre/lustre/obdclass/llog.c @@ -188,7 +188,7 @@ static int llog_read_header(const struct lu_env *env, llh->llh_hdr.lrh_type = LLOG_HDR_MAGIC; llh->llh_hdr.lrh_len = llh->llh_tail.lrt_len = LLOG_CHUNK_SIZE; llh->llh_hdr.lrh_index = llh->llh_tail.lrt_index = 0; - llh->llh_timestamp = get_seconds(); + llh->llh_timestamp = ktime_get_real_seconds(); if (uuid) memcpy(&llh->llh_tgtuuid, uuid, sizeof(llh->llh_tgtuuid));
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: Arnd Bergmann arnd@arndb.de --- .../staging/lustre/lustre/include/lustre_export.h | 2 +- .../staging/lustre/lustre/include/lustre_import.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec.c | 28 ++++++++++------------ drivers/staging/lustre/lustre/ptlrpc/sec_config.c | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index 5189fad0b73c..e02a39a721d6 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -216,7 +216,7 @@ struct obd_export { enum lustre_sec_part exp_sp_peer; struct sptlrpc_flavor exp_flvr; /* current */ 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 */ spinlock_t exp_rpc_lock; diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index cd6244ecd0c7..3ae97e2ece1c 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -200,7 +200,7 @@ struct obd_import { */ struct ptlrpc_sec *imp_sec; 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 */ diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c index b9821db22904..5ee6641ea023 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c @@ -343,7 +343,7 @@ static int import_sec_check_expire(struct obd_import *imp)
spin_lock(&imp->imp_lock); if (imp->imp_sec_expire && - imp->imp_sec_expire < get_seconds()) { + imp->imp_sec_expire < ktime_get_real_seconds()) { adapt = 1; imp->imp_sec_expire = 0; } @@ -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_expire[1] = exp->exp_flvr_expire[0]; 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->exp_flvr = flavor;
@@ -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] >= get_seconds()) { + if (exp->exp_flvr_expire[0] >= ktime_get_real_seconds()) { 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_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, - exp->exp_flvr_expire[0] - - get_seconds()); + (s64)(exp->exp_flvr_expire[0] - + ktime_get_real_seconds())); spin_unlock(&exp->exp_lock); return 0; } @@ -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 * 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_expire[1] >= get_seconds()) { + if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) { 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_flvr.sf_rpc, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_old[1].sf_rpc, - exp->exp_flvr_expire[1] - - get_seconds()); + (s64)(exp->exp_flvr_expire[1] - + ktime_get_real_seconds())); spin_unlock(&exp->exp_lock); return 0; } @@ -1905,7 +1905,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
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, 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, @@ -1913,12 +1913,10 @@ int sptlrpc_target_export_check(struct obd_export *exp, exp->exp_flvr.sf_rpc, exp->exp_flvr_old[0].sf_rpc, exp->exp_flvr_expire[0] ? - (unsigned long) (exp->exp_flvr_expire[0] - - get_seconds()) : 0, + (s64)(exp->exp_flvr_expire[0] - ktime_get_real_seconds()) : 0, exp->exp_flvr_old[1].sf_rpc, exp->exp_flvr_expire[1] ? - (unsigned long) (exp->exp_flvr_expire[1] - - get_seconds()) : 0); + (s64)(exp->exp_flvr_expire[1] - ktime_get_real_seconds()) : 0); return -EACCES; } EXPORT_SYMBOL(sptlrpc_target_export_check); diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c index e7f2f333257d..7769ab225a2d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c @@ -871,7 +871,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd) if (imp) { spin_lock(&imp->imp_lock); if (imp->imp_sec) - imp->imp_sec_expire = get_seconds() + + imp->imp_sec_expire = ktime_get_real_seconds() + SEC_ADAPT_DELAY; spin_unlock(&imp->imp_lock); }
Here we use an unsigned long to store the timeout for gc, which is probably safe until 2106, but this patch converts it to use ktime_get_real_seconds() and time64_t for consistency.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/lustre_sec.h | 2 +- drivers/staging/lustre/lustre/ptlrpc/sec_gc.c | 6 +++--- drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h index 707ff69717c6..871185cd52b3 100644 --- a/drivers/staging/lustre/lustre/include/lustre_sec.h +++ b/drivers/staging/lustre/lustre/include/lustre_sec.h @@ -833,7 +833,7 @@ struct ptlrpc_sec { */ struct list_head ps_gc_list; unsigned long ps_gc_interval; /* in seconds */ - unsigned long ps_gc_next; /* in seconds */ + time64_t ps_gc_next; /* in seconds */ };
static inline int sec_is_reverse(struct ptlrpc_sec *sec) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c index cdad608bdb8d..c3ad1dabced8 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_gc.c @@ -69,7 +69,7 @@ void sptlrpc_gc_add_sec(struct ptlrpc_sec *sec) LASSERT(sec->ps_gc_interval > 0); LASSERT(list_empty(&sec->ps_gc_list));
- sec->ps_gc_next = get_seconds() + sec->ps_gc_interval; + sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval;
spin_lock(&sec_gc_list_lock); list_add_tail(&sec_gc_list, &sec->ps_gc_list); @@ -154,11 +154,11 @@ static void sec_do_gc(struct ptlrpc_sec *sec)
CDEBUG(D_SEC, "check on sec %p(%s)\n", sec, sec->ps_policy->sp_name);
- if (cfs_time_after(sec->ps_gc_next, get_seconds())) + if (sec->ps_gc_next > ktime_get_real_seconds()) return;
sec->ps_policy->sp_cops->gc_ctx(sec); - sec->ps_gc_next = get_seconds() + sec->ps_gc_interval; + sec->ps_gc_next = ktime_get_real_seconds() + sec->ps_gc_interval; }
static int sec_gc_main(void *arg) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c index 68fcac14b3ee..a74e2f01e5be 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c @@ -98,9 +98,9 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) atomic_read(&sec->ps_refcount)); seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx)); seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval); - seq_printf(seq, "gc next %ld\n", + seq_printf(seq, "gc next %lld\n", sec->ps_gc_interval ? - sec->ps_gc_next - get_seconds() : 0); + (s64)(sec->ps_gc_next - ktime_get_real_seconds()) : 0ll);
sptlrpc_sec_put(sec); out:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../staging/lustre/lustre/include/lustre_export.h | 5 ++--- drivers/staging/lustre/lustre/obdclass/genops.c | 6 +++--- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 22 +++++++++++----------- drivers/staging/lustre/lustre/ptlrpc/service.c | 10 +++++----- 4 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h index e02a39a721d6..b06ee9ff22ae 100644 --- a/drivers/staging/lustre/lustre/include/lustre_export.h +++ b/drivers/staging/lustre/lustre/include/lustre_export.h @@ -180,7 +180,7 @@ struct obd_export { /** Last committed transno for this export */ __u64 exp_last_committed; /** When was last request received */ - unsigned long exp_last_request_time; + time64_t exp_last_request_time; /** On replay all requests waiting for replay are linked here */ struct list_head exp_req_replay_queue; /** @@ -268,8 +268,7 @@ static inline int exp_connect_multibulk(struct obd_export *exp) static inline int exp_expired(struct obd_export *exp, long age) { LASSERT(exp->exp_delayed); - return time_before(cfs_time_add(exp->exp_last_request_time, age), - get_seconds()); + return exp->exp_last_request_time + age < ktime_get_real_seconds(); }
static inline int exp_connect_cancelset(struct obd_export *exp) diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 594955d359ec..a27932502f2a 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -846,7 +846,7 @@ struct obd_export *class_new_export(struct obd_device *obd, INIT_LIST_HEAD(&export->exp_handle.h_link); INIT_LIST_HEAD(&export->exp_hp_rpcs); class_handle_hash(&export->exp_handle, &export_handle_ops); - export->exp_last_request_time = get_seconds(); + export->exp_last_request_time = ktime_get_real_seconds(); spin_lock_init(&export->exp_lock); spin_lock_init(&export->exp_rpc_lock); INIT_HLIST_NODE(&export->exp_uuid_hash); @@ -1266,9 +1266,9 @@ static void class_disconnect_export_list(struct list_head *list, }
class_export_get(exp); - CDEBUG(D_HA, "%s: disconnecting export at %s (%p), last request at " CFS_TIME_T "\n", + CDEBUG(D_HA, "%s: disconnecting export at %s (%p), last request at %lld\n", exp->exp_obd->obd_name, obd_export_nid2str(exp), - exp, exp->exp_last_request_time); + exp, (s64)exp->exp_last_request_time); /* release one export reference anyway */ rc = obd_disconnect(exp);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 6cd4cfa58c27..76eecb02d1fc 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -572,7 +572,7 @@ static int ping_evictor_main(void *arg) struct obd_device *obd; struct obd_export *exp; struct l_wait_info lwi = { 0 }; - time_t expire_time; + time64_t expire_time;
unshare_fs_struct();
@@ -594,10 +594,10 @@ static int ping_evictor_main(void *arg) obd_evict_list); spin_unlock(&pet_lock);
- expire_time = get_seconds() - PING_EVICT_TIMEOUT; + expire_time = ktime_get_real_seconds() - PING_EVICT_TIMEOUT;
- CDEBUG(D_HA, "evicting all exports of obd %s older than %ld\n", - obd->obd_name, expire_time); + CDEBUG(D_HA, "evicting all exports of obd %s older than %lld\n", + obd->obd_name, (s64)expire_time);
/* Exports can't be deleted out of the list while we hold * the obd lock (class_unlink_export), which means we can't @@ -611,17 +611,17 @@ static int ping_evictor_main(void *arg) if (expire_time > exp->exp_last_request_time) { class_export_get(exp); spin_unlock(&obd->obd_dev_lock); - LCONSOLE_WARN("%s: haven't heard from client %s (at %s) in %ld seconds. I think it's dead, and I am evicting it. exp %p, cur %ld expire %ld last %ld\n", + LCONSOLE_WARN("%s: haven't heard from client %s (at %s) in %ld seconds. I think it's dead, and I am evicting it. exp %p, cur %lld expire %lld last %lld\n", obd->obd_name, obd_uuid2str(&exp->exp_client_uuid), obd_export_nid2str(exp), - (long)(get_seconds() - + (long)(ktime_get_real_seconds() - exp->exp_last_request_time), - exp, (long)get_seconds(), - (long)expire_time, - (long)exp->exp_last_request_time); - CDEBUG(D_HA, "Last request was at %ld\n", - exp->exp_last_request_time); + exp, (s64)ktime_get_real_seconds(), + (s64)expire_time, + (s64)exp->exp_last_request_time); + CDEBUG(D_HA, "Last request was at %lld\n", + (s64)exp->exp_last_request_time); class_fail_export(exp); class_export_put(exp); spin_lock(&obd->obd_dev_lock); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index c7c6cff80450..7766bb8b352a 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1034,7 +1034,7 @@ static void ptlrpc_server_finish_active_request( static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) { struct obd_export *oldest_exp; - time_t oldest_time, new_time; + time64_t oldest_time, new_time;
LASSERT(exp);
@@ -1045,7 +1045,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) will make it to the top of the list. */
/* Do not pay attention on 1sec or smaller renewals. */ - new_time = get_seconds() + extra_delay; + new_time = ktime_get_real_seconds() + extra_delay; if (exp->exp_last_request_time + 1 /*second */ >= new_time) return;
@@ -1078,7 +1078,7 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) /* Note - racing to start/reset the obd_eviction timer is safe */ if (exp->exp_obd->obd_eviction_timer == 0) { /* Check if the oldest entry is expired. */ - if (get_seconds() > (oldest_time + PING_EVICT_TIMEOUT + + if (ktime_get_real_seconds() > (oldest_time + PING_EVICT_TIMEOUT + extra_delay)) { /* We need a second timer, in case the net was down and * it just came back. Since the pinger may skip every @@ -1086,9 +1086,9 @@ static void ptlrpc_update_export_timer(struct obd_export *exp, long extra_delay) * we better wait for 3. */ exp->exp_obd->obd_eviction_timer = ktime_get_real_seconds() + 3 * PING_INTERVAL; - CDEBUG(D_HA, "%s: Think about evicting %s from "CFS_TIME_T"\n", + CDEBUG(D_HA, "%s: Think about evicting %s from %lld\n", exp->exp_obd->obd_name, - obd_export_nid2str(oldest_exp), oldest_time); + obd_export_nid2str(oldest_exp), (s64)oldest_time); } } else { if (ktime_get_real_seconds() >
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Hm… All this code is actually only making sense on server and is unused otherwise, so it's probably best to drop ping_evictor_start, ping_evictor_main, exp_expired, class_disconnect_export_list (and two places where it's called from) functions and exp_last_request_time field. And with ping evictor gone, we should also drop ptlrpc_update_export_timer.
While clients do retain the request handling code (to process server-originated requests like lock callbacks), they are not going to evict the servers because the server have not talked to us in a while or anything of the sort.
On Thursday 24 September 2015 03:55:20 Drokin, Oleg wrote:
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Hm… All this code is actually only making sense on server and is unused otherwise, so it's probably best to drop ping_evictor_start, ping_evictor_main, exp_expired, class_disconnect_export_list (and two places where it's called from) functions and exp_last_request_time field. And with ping evictor gone, we should also drop ptlrpc_update_export_timer.
While clients do retain the request handling code (to process server-originated requests like lock callbacks), they are not going to evict the servers because the server have not talked to us in a while or anything of the sort.
I tried doing this, but could not figure out how to get rid of class_disconnect_exports().
However, I started removing dead code and ended up with a huge patch that would not make it to mailing list servers and that I therefor pasted on http://pastebin.com/uncZQNh7 for reference.
Arnd
On Sep 24, 2015, at 11:18 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 03:55:20 Drokin, Oleg wrote:
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Hm… All this code is actually only making sense on server and is unused otherwise, so it's probably best to drop ping_evictor_start, ping_evictor_main, exp_expired, class_disconnect_export_list (and two places where it's called from) functions and exp_last_request_time field. And with ping evictor gone, we should also drop ptlrpc_update_export_timer.
While clients do retain the request handling code (to process server-originated requests like lock callbacks), they are not going to evict the servers because the server have not talked to us in a while or anything of the sort.
I tried doing this, but could not figure out how to get rid of class_disconnect_exports().
It's only called from class_cleanup like this:
/* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ if (atomic_read(&obd->obd_refcount) > 3) { /* refcount - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n", obd->obd_name, atomic_read(&obd->obd_refcount) - 3); dump_exports(obd, 0); class_disconnect_exports(obd); }
This is only true on the servers so we can replace it with a corresponding LASSERT, I imagine.
However, I started removing dead code and ended up with a huge patch that would not make it to mailing list servers and that I therefor pasted on http://pastebin.com/uncZQNh7 for reference.
Wow, this is a large patch indeed. Some parts of it I was contemplating on my own like whole dt_object.[ch] removal with all the ties in llog code, though it was somewhat tricky as some bits in mgc seems to be using that somehow.
I have not finished a detailed runthrough yet, but on the surface, why did you remove suppress_pings parameter 0 that is still valid on clients, to let them not ping servers. Also ptlrpc_ping_import_soon and friends - all that code is actually needed.
Only "ping evictor" is not needed on the client as it's only servers that are going to kick out clients that are silent for too long. Clients are still expected to send their "keep alive" pings in periodically (unless suppress_pings option is enabled).
Hm…. I now see it is not fully implemented, that's why you are removing it as it's really not called from anywhere.
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Thank you!
Bye, Oleg
On Thursday 24 September 2015 16:01:40 Drokin, Oleg wrote:
On Sep 24, 2015, at 11:18 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 03:55:20 Drokin, Oleg wrote:
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Hm… All this code is actually only making sense on server and is unused otherwise, so it's probably best to drop ping_evictor_start, ping_evictor_main, exp_expired, class_disconnect_export_list (and two places where it's called from) functions and exp_last_request_time field. And with ping evictor gone, we should also drop ptlrpc_update_export_timer.
While clients do retain the request handling code (to process server-originated requests like lock callbacks), they are not going to evict the servers because the server have not talked to us in a while or anything of the sort.
I tried doing this, but could not figure out how to get rid of class_disconnect_exports().
It's only called from class_cleanup like this:
/* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ if (atomic_read(&obd->obd_refcount) > 3) { /* refcount - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n", obd->obd_name, atomic_read(&obd->obd_refcount) - 3); dump_exports(obd, 0); class_disconnect_exports(obd); }
This is only true on the servers so we can replace it with a corresponding LASSERT, I imagine.
Ok, I see. This wasn't clear as I really know nothing about what lustre actually does. Just for my information, can you clarify where the server code sits? Is that a fork of the same code base running in user space, or is there another set of kernel modules on top of the common ones that implements the server?
However, I started removing dead code and ended up with a huge patch that would not make it to mailing list servers and that I therefor pasted on http://pastebin.com/uncZQNh7 for reference.
Wow, this is a large patch indeed. Some parts of it I was contemplating on my own like whole dt_object.[ch] removal with all the ties in llog code, though it was somewhat tricky as some bits in mgc seems to be using that somehow.
I first recursively removed all functions that 'nm' showed as globally defined but never referenced from another file (except those that should be marked static instead) and ended up with an empty dt_object.c, but dt_object.h was still being used. As this made no sense to me, I walked through the remaining references and found that
- in llog_cat_close(), "llh->llh_flags & LLOG_F_ZAP_WHEN_EMPTY" cannot be true, so llog_destroy() no longer gets called here. - in llog_read_header(), "rc == LLOG_PROC_BREAK" and "rc == LLOG_DEL_RECORD" can both never be true, as nothing ever returns those values.
After that, llog_cancel_rec and llog_write() become unused as well, and all the dt_object references can be removed.
I have not finished a detailed runthrough yet, but on the surface, why did you remove suppress_pings parameter 0 that is still valid on clients, to let them not ping servers. Also ptlrpc_ping_import_soon and friends - all that code is actually needed.
Only "ping evictor" is not needed on the client as it's only servers that are going to kick out clients that are silent for too long. Clients are still expected to send their "keep alive" pings in periodically (unless suppress_pings option is enabled).
Hm…. I now see it is not fully implemented, that's why you are removing it as it's really not called from anywhere.
Right, I obviously cannot tell the difference between code that is not needed on the client or that has been orphaned in a previous cleanup and code that has just been added in order to soon be used.
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
Arnd
On Sep 24, 2015, at 2:54 PM, Arnd Bergmann wrote:
On Thursday 24 September 2015 16:01:40 Drokin, Oleg wrote:
On Sep 24, 2015, at 11:18 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 03:55:20 Drokin, Oleg wrote:
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
The last request time is stored as an 'unsigned long', which is good enough until 2106, but it is then converted to 'long' in some places, which overflows in 2038.
This changes the type to time64_t to avoid those problems.
Hm… All this code is actually only making sense on server and is unused otherwise, so it's probably best to drop ping_evictor_start, ping_evictor_main, exp_expired, class_disconnect_export_list (and two places where it's called from) functions and exp_last_request_time field. And with ping evictor gone, we should also drop ptlrpc_update_export_timer.
While clients do retain the request handling code (to process server-originated requests like lock callbacks), they are not going to evict the servers because the server have not talked to us in a while or anything of the sort.
I tried doing this, but could not figure out how to get rid of class_disconnect_exports().
It's only called from class_cleanup like this:
/* The three references that should be remaining are the * obd_self_export and the attach and setup references. */ if (atomic_read(&obd->obd_refcount) > 3) { /* refcount - 3 might be the number of real exports (excluding self export). But class_incref is called by other things as well, so don't count on it. */ CDEBUG(D_IOCTL, "%s: forcing exports to disconnect: %d\n", obd->obd_name, atomic_read(&obd->obd_refcount) - 3); dump_exports(obd, 0); class_disconnect_exports(obd); }
This is only true on the servers so we can replace it with a corresponding LASSERT, I imagine.
Ok, I see. This wasn't clear as I really know nothing about what lustre actually does. Just for my information, can you clarify where the server code sits? Is that a fork of the same code base running in user space, or is there another set of kernel modules on top of the common ones that implements the server?
Lustre server (and out of tree client) live in http://git.whamcloud.com/fs/lustre-release.git/
Code in the staging tree is a snapshot from between 2.4 and 2.5 releases that undergoes cleanups in order to conform to kernel standards. It's only client too, so all server-side parts are being removed as they are identified.
However, I started removing dead code and ended up with a huge patch that would not make it to mailing list servers and that I therefor pasted on http://pastebin.com/uncZQNh7 for reference.
Wow, this is a large patch indeed. Some parts of it I was contemplating on my own like whole dt_object.[ch] removal with all the ties in llog code, though it was somewhat tricky as some bits in mgc seems to be using that somehow.
I first recursively removed all functions that 'nm' showed as globally defined but never referenced from another file (except those that should be marked
Ah, neat trick.
I have not finished a detailed runthrough yet, but on the surface, why did you remove suppress_pings parameter 0 that is still valid on clients, to let them not ping servers. Also ptlrpc_ping_import_soon and friends - all that code is actually needed.
Only "ping evictor" is not needed on the client as it's only servers that are going to kick out clients that are silent for too long. Clients are still expected to send their "keep alive" pings in periodically (unless suppress_pings option is enabled).
Hm…. I now see it is not fully implemented, that's why you are removing it as it's really not called from anywhere.
Right, I obviously cannot tell the difference between code that is not needed on the client or that has been orphaned in a previous cleanup and code that has just been added in order to soon be used.
This code is not "soon to be used", so it's ok to kill it now and we can spring it back to life when it actually becomes useful.
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Thanks!
Bye, Oleg
On Thursday 24 September 2015 19:03:12 Drokin, Oleg wrote:
On Sep 24, 2015, at 2:54 PM, Arnd Bergmann wrote:
On Thursday 24 September 2015 16:01:40 Drokin, Oleg wrote:
On Sep 24, 2015, at 11:18 AM, Arnd Bergmann wrote:
On Thursday 24 September 2015 03:55:20 Drokin, Oleg wrote:
On Sep 23, 2015, at 3:13 PM, Arnd Bergmann wrote:
This is only true on the servers so we can replace it with a corresponding LASSERT, I imagine.
Ok, I see. This wasn't clear as I really know nothing about what lustre actually does. Just for my information, can you clarify where the server code sits? Is that a fork of the same code base running in user space, or is there another set of kernel modules on top of the common ones that implements the server?
Lustre server (and out of tree client) live in http://git.whamcloud.com/fs/lustre-release.git/
Code in the staging tree is a snapshot from between 2.4 and 2.5 releases that undergoes cleanups in order to conform to kernel standards. It's only client too, so all server-side parts are being removed as they are identified.
Ok, I see.
I have not finished a detailed runthrough yet, but on the surface, why did you remove suppress_pings parameter 0 that is still valid on clients, to let them not ping servers. Also ptlrpc_ping_import_soon and friends - all that code is actually needed.
Only "ping evictor" is not needed on the client as it's only servers that are going to kick out clients that are silent for too long. Clients are still expected to send their "keep alive" pings in periodically (unless suppress_pings option is enabled).
Hm…. I now see it is not fully implemented, that's why you are removing it as it's really not called from anywhere.
Right, I obviously cannot tell the difference between code that is not needed on the client or that has been orphaned in a previous cleanup and code that has just been added in order to soon be used.
This code is not "soon to be used", so it's ok to kill it now and we can spring it back to life when it actually becomes useful.
Makes sense.
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Ok, I've pushed out the branch to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-lustre
This contains the latest version of the y2038 series (with the warning fixed that Sudip Mukherjee found) but no other changes, and the big code removal on top.
ARnd
On Sep 24, 2015, at 4:15 PM, Arnd Bergmann wrote:
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Ok, I've pushed out the branch to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-lustre
This contains the latest version of the y2038 series (with the warning fixed that Sudip Mukherjee found) but no other changes, and the big code removal on top.
These do seem to be working fine in my testing.
I also noticed we can remove some more stuff in at least fid/ dir so I created some patches on top of your tree: https://github.com/verygreen/linux/tree/fidcleanup
Also I've looked a bit into nm and I don't see a straight way of cross referencing which globally visible functions are not really used by anything. Do you have a handy recipe for that?
Thanks.
Bye, Oleg
On Sep 24, 2015, at 9:07 PM, Drokin, Oleg wrote:
On Sep 24, 2015, at 4:15 PM, Arnd Bergmann wrote:
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Ok, I've pushed out the branch to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-lustre
This contains the latest version of the y2038 series (with the warning fixed that Sudip Mukherjee found) but no other changes, and the big code removal on top.
These do seem to be working fine in my testing.
Ah, and I should mention that just as I suspected, the debug log decoding tool is very unhappy.
On Friday 25 September 2015 01:39:49 Drokin, Oleg wrote:
On Sep 24, 2015, at 9:07 PM, Drokin, Oleg wrote:
On Sep 24, 2015, at 4:15 PM, Arnd Bergmann wrote:
Anyway this does remove a lot of stuff that we don't really need in the client, I'll try to get it built and tested just to make sure it does not really break anything (unfortunately it does not seem to apply cleanly to the tip of staging-next tree).
Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Ok, I've pushed out the branch to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-lustre
This contains the latest version of the y2038 series (with the warning fixed that Sudip Mukherjee found) but no other changes, and the big code removal on top.
These do seem to be working fine in my testing.
Ah, and I should mention that just as I suspected, the debug log decoding tool is very unhappy.
I have updated the branch now to reflect our discussions so far. Can you handle forwarding the patches to Greg from there, or complain if there are still problems with them?
I still had problems with removing ptlrpc_update_export_timer(), so I left a small patch for that, which you probably want to do differently, and while I split out the nontrivial parts of the large removal patch, most of it still is in one chunk that contains purely removals of whole lines.
Arnd
On Sep 25, 2015, at 12:09 PM, Arnd Bergmann wrote:
On Friday 25 September 2015 01:39:49 Drokin, Oleg wrote:
On Sep 24, 2015, at 9:07 PM, Drokin, Oleg wrote:
On Sep 24, 2015, at 4:15 PM, Arnd Bergmann wrote:
> Anyway this does remove a lot of stuff that we don't really need in the client, > I'll try to get it built and tested just to make sure it does not really break anything > (unfortunately it does not seem to apply cleanly to the tip of staging-next tree). Ok. I based the patches on top of my 37 patch series, and if you want I can upload a git branch somewhere to make rebasing easier.
That would be great. Though in the end likely this huge patch would need to be split into smaller chunks. Like if all unused llog code removal is done, that would allow subsequent dt_object.[ch] removal and so on. But for testing a current snapshot would be great, then I can run it through my testbed to see how it fares there.
Ok, I've pushed out the branch to
git.kernel.org/pub/scm/linux/kernel/git/arnd/playground.git y2038-lustre
This contains the latest version of the y2038 series (with the warning fixed that Sudip Mukherjee found) but no other changes, and the big code removal on top.
These do seem to be working fine in my testing.
Ah, and I should mention that just as I suspected, the debug log decoding tool is very unhappy.
I have updated the branch now to reflect our discussions so far. Can you handle forwarding the patches to Greg from there, or complain if there are still problems with them?
Aha, sure. Do you want me to send the y2038 patches too?
I still had problems with removing ptlrpc_update_export_timer(), so I left a small patch for that, which you probably want to do differently, and while I split out the nontrivial parts of the large removal patch, most of it still is in one chunk that contains purely removals of whole lines.
Ok, I'll take care of this as well.
Thank you!
Bye, Oleg
On Friday 25 September 2015 16:53:14 Drokin, Oleg wrote:
On Sep 25, 2015, at 12:09 PM, Arnd Bergmann wrote:
I have updated the branch now to reflect our discussions so far. Can you handle forwarding the patches to Greg from there, or complain if there are still problems with them?
Aha, sure. Do you want me to send the y2038 patches too?
Yes, I meant both the y2038 patches and the code removal.
I still had problems with removing ptlrpc_update_export_timer(), so I left a small patch for that, which you probably want to do differently, and while I split out the nontrivial parts of the large removal patch, most of it still is in one chunk that contains purely removals of whole lines.
Ok, I'll take care of this as well.
Thank you!
Thanks!
Arnd
On Friday 25 September 2015 01:07:43 Drokin, Oleg wrote:
These do seem to be working fine in my testing.
I also noticed we can remove some more stuff in at least fid/ dir so I created some patches on top of your tree: https://github.com/verygreen/linux/tree/fidcleanup
Also I've looked a bit into nm and I don't see a straight way of cross referencing which globally visible functions are not really used by anything. Do you have a handy recipe for that?
I usually use ad-hoc shell commands. This time, my history has these commands:
find build/tmp/drivers/staging/lustre/ -name *.o | grep -v built-in | xargs nm | grep -w U | cut -f 11- -d\ | sort -u > refs find build/tmp/drivers/staging/lustre/lustre/obdclass/ -name *.o | grep -v built-in | xargs nm | grep -w [A-TV-Z] | grep -v __ksymtab | grep -v __crc | cut -f 3 -d \ | sort -u > defs diff -u defs refs | grep ^- | cut -f 2 -d- | while read i ; do echo ==== $i ==== ; git grep -w $i ; done | less
I'm sure this could be done in a more robust and cleaner way, and probably has been done before. If someone has a good way of doing this generically, we could add that to the scripts/ directory and get get more people to analyse the staging drivers (or their own code elsewhere) this way.
Note that I only did this for symbols defined in obdclass and ptlrpc, there are plenty more in the other modules. Also, most of the findings are for symbols that should be marked 'static', because they have only users in the file that they are defined in. Doing that would lead to better code generation.
Two related things I'd do when cleaning up a code base are to check all the EXPORT_SYMBOL statements and remove the ones that are not used in another module, and to check for global identifiers that are missing a proper prefix and should be renamed (e.g. dirty_cnt, dump_lsm, lock_handle_ops, our_vma, pool_hash_operations, target_send_reply, at_max, dump_exports, ...).
Arnd
All request timestamps and deadlines in lustre are recorded in time_t and timeval units, which overflow in 2038 on 32-bit systems.
In this patch, I'm converting them to time64_t and timespec64, respectively. Unfortunately, this makes a relatively large patch, but I could not find an obvious way to split it up some more without breaking atomicity of the change.
Also unfortunately, this introduces two instances of div_u64_rem() in the request path, which can be slow on 32-bit architectures. This can probably be avoided by a larger restructuring of the code, but it is unlikely that lustre is used in performance critical setups on 32-bit architectures, so it seems better to optimize for correctness rather than speed here.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../staging/lustre/lustre/include/lustre_import.h | 2 +- drivers/staging/lustre/lustre/include/lustre_net.h | 22 ++--- drivers/staging/lustre/lustre/mdc/mdc_locks.c | 2 +- drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 +- drivers/staging/lustre/lustre/osc/osc_request.c | 4 +- drivers/staging/lustre/lustre/ptlrpc/client.c | 48 ++++----- drivers/staging/lustre/lustre/ptlrpc/events.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/import.c | 4 +- .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 8 +- drivers/staging/lustre/lustre/ptlrpc/niobuf.c | 10 +- .../staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +- drivers/staging/lustre/lustre/ptlrpc/service.c | 110 +++++++++++---------- 12 files changed, 113 insertions(+), 111 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_import.h b/drivers/staging/lustre/lustre/include/lustre_import.h index 3ae97e2ece1c..079db528ba74 100644 --- a/drivers/staging/lustre/lustre/include/lustre_import.h +++ b/drivers/staging/lustre/lustre/include/lustre_import.h @@ -74,7 +74,7 @@ struct ptlrpc_at_array { struct list_head *paa_reqs_array; /** array to hold requests */ __u32 paa_size; /** the size of array */ __u32 paa_count; /** the total count of reqs */ - time_t paa_deadline; /** the earliest deadline of reqs */ + time64_t paa_deadline; /** the earliest deadline of reqs */ __u32 *paa_reqs_count; /** the count of reqs in each entry */ };
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h index 44adee134563..0db7810f7d6f 100644 --- a/drivers/staging/lustre/lustre/include/lustre_net.h +++ b/drivers/staging/lustre/lustre/include/lustre_net.h @@ -1440,7 +1440,7 @@ struct ptlrpc_request {
/* server-side... */ /** request arrival time */ - struct timeval rq_arrival_time; + struct timespec64 rq_arrival_time; /** separated reply state */ struct ptlrpc_reply_state *rq_reply_state; /** incoming request buffer */ @@ -1477,18 +1477,18 @@ struct ptlrpc_request { /** * when request/reply sent (secs), or time when request should be sent */ - time_t rq_sent; + time64_t rq_sent; /** time for request really sent out */ - time_t rq_real_sent; + time64_t rq_real_sent;
/** when request must finish. volatile * so that servers' early reply updates to the deadline aren't * kept in per-cpu cache */ - volatile time_t rq_deadline; + volatile time64_t rq_deadline; /** when req reply unlink must finish. */ - time_t rq_reply_deadline; + time64_t rq_reply_deadline; /** when req bulk unlink must finish. */ - time_t rq_bulk_deadline; + time64_t rq_bulk_deadline; /** * service time estimate (secs) * If the requestsis not served by this time, it is marked as timed out. @@ -2323,7 +2323,7 @@ static inline int ptlrpc_client_bulk_active(struct ptlrpc_request *req) desc = req->rq_bulk;
if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && - req->rq_bulk_deadline > get_seconds()) + req->rq_bulk_deadline > ktime_get_real_seconds()) return 1;
if (!desc) @@ -2727,7 +2727,7 @@ static inline int ptlrpc_client_early(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > get_seconds()) + req->rq_reply_deadline > ktime_get_real_seconds()) return 0; return req->rq_early; } @@ -2739,7 +2739,7 @@ static inline int ptlrpc_client_replied(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > get_seconds()) + req->rq_reply_deadline > ktime_get_real_seconds()) return 0; return req->rq_replied; } @@ -2749,7 +2749,7 @@ static inline int ptlrpc_client_recv(struct ptlrpc_request *req) { if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > get_seconds()) + req->rq_reply_deadline > ktime_get_real_seconds()) return 1; return req->rq_receiving_reply; } @@ -2761,7 +2761,7 @@ ptlrpc_client_recv_or_unlink(struct ptlrpc_request *req)
spin_lock(&req->rq_lock); if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && - req->rq_reply_deadline > get_seconds()) { + req->rq_reply_deadline > ktime_get_real_seconds()) { spin_unlock(&req->rq_lock); return 1; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 20da064c2c4a..ebd9f76825ee 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -864,7 +864,7 @@ resend: if (resends) { req->rq_generation_set = 1; req->rq_import_generation = generation; - req->rq_sent = get_seconds() + resends; + req->rq_sent = ktime_get_real_seconds() + resends; }
/* It is important to obtain rpc_lock first (if applicable), so that diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 5e9c6296c39d..47051c0799f8 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -271,7 +271,7 @@ rebuild: if (resends) { req->rq_generation_set = 1; req->rq_import_generation = generation; - req->rq_sent = get_seconds() + resends; + req->rq_sent = ktime_get_real_seconds() + resends; } level = LUSTRE_IMP_FULL; resend: diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 9f5362759f2f..5491a39e8ff7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -1690,9 +1690,9 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, /* cap resend delay to the current request timeout, this is similar to * what ptlrpc does (see after_reply()) */ if (aa->aa_resends > new_req->rq_timeout) - new_req->rq_sent = get_seconds() + new_req->rq_timeout; + new_req->rq_sent = ktime_get_real_seconds() + new_req->rq_timeout; else - new_req->rq_sent = get_seconds() + aa->aa_resends; + new_req->rq_sent = ktime_get_real_seconds() + aa->aa_resends; new_req->rq_generation_set = 1; new_req->rq_import_generation = request->rq_import_generation;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c index e1830fe4b2b3..d013d4b512ce 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/client.c @@ -282,7 +282,7 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req, { unsigned int nl, oldnl; struct imp_at *at; - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds();
LASSERT(req->rq_import);
@@ -298,7 +298,7 @@ static void ptlrpc_at_adj_net_latency(struct ptlrpc_request *req, D_ADAPTTO : D_WARNING, "Reported service time %u > total measured time " CFS_DURATION_T"\n", service_time, - cfs_time_sub(now, req->rq_sent)); + (long)(now - req->rq_sent)); return; }
@@ -343,7 +343,7 @@ static int unpack_reply(struct ptlrpc_request *req) static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) { struct ptlrpc_request *early_req; - time_t olddl; + time64_t olddl; int rc;
req->rq_early = 0; @@ -378,14 +378,14 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req) olddl = req->rq_deadline; /* server assumes it now has rq_timeout from when it sent the * early reply, so client should give it at least that long. */ - req->rq_deadline = get_seconds() + req->rq_timeout + + req->rq_deadline = ktime_get_real_seconds() + req->rq_timeout + ptlrpc_at_get_net_latency(req);
DEBUG_REQ(D_ADAPTTO, req, - "Early reply #%d, new deadline in " CFS_DURATION_T "s (" CFS_DURATION_T "s)", + "Early reply #%d, new deadline in %lds (%lds)", req->rq_early_count, - cfs_time_sub(req->rq_deadline, get_seconds()), - cfs_time_sub(req->rq_deadline, olddl)); + (long)(req->rq_deadline - ktime_get_real_seconds()), + (long)(req->rq_deadline - olddl));
return rc; } @@ -1203,7 +1203,7 @@ static int after_reply(struct ptlrpc_request *req) struct obd_import *imp = req->rq_import; struct obd_device *obd = req->rq_import->imp_obd; int rc; - struct timeval work_start; + struct timespec64 work_start; long timediff;
LASSERT(obd != NULL); @@ -1253,7 +1253,7 @@ static int after_reply(struct ptlrpc_request *req) /* retry indefinitely on EINPROGRESS */ if (lustre_msg_get_status(req->rq_repmsg) == -EINPROGRESS && ptlrpc_no_resend(req) == 0 && !req->rq_no_retry_einprogress) { - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds();
DEBUG_REQ(D_RPCTRACE, req, "Resending request on EINPROGRESS"); spin_lock(&req->rq_lock); @@ -1283,8 +1283,9 @@ static int after_reply(struct ptlrpc_request *req) return 0; }
- do_gettimeofday(&work_start); - timediff = cfs_timeval_sub(&work_start, &req->rq_arrival_time, NULL); + ktime_get_real_ts64(&work_start); + timediff = (work_start.tv_sec - req->rq_arrival_time.tv_sec) * USEC_PER_SEC + + (work_start.tv_nsec - req->rq_arrival_time.tv_nsec) / NSEC_PER_USEC; if (obd->obd_svc_stats != NULL) { lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQWAIT_CNTR, timediff); @@ -1401,7 +1402,7 @@ static int ptlrpc_send_new_req(struct ptlrpc_request *req) int rc;
LASSERT(req->rq_phase == RQ_PHASE_NEW); - if (req->rq_sent && (req->rq_sent > get_seconds()) && + if (req->rq_sent && (req->rq_sent > ktime_get_real_seconds()) && (!req->rq_generation_set || req->rq_import_generation == imp->imp_generation)) return 0; @@ -1541,7 +1542,7 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
/* delayed resend - skip */ if (req->rq_phase == RQ_PHASE_RPC && req->rq_resend && - req->rq_sent > get_seconds()) + req->rq_sent > ktime_get_real_seconds()) continue;
if (!(req->rq_phase == RQ_PHASE_RPC || @@ -1902,14 +1903,13 @@ int ptlrpc_expire_one_request(struct ptlrpc_request *req, int async_unlink) req->rq_timedout = 1; spin_unlock(&req->rq_lock);
- DEBUG_REQ(D_WARNING, req, "Request sent has %s: [sent "CFS_DURATION_T - "/real "CFS_DURATION_T"]", + DEBUG_REQ(D_WARNING, req, "Request sent has %s: [sent %lld/real %lld]", req->rq_net_err ? "failed due to network error" : ((req->rq_real_sent == 0 || - time_before((unsigned long)req->rq_real_sent, (unsigned long)req->rq_sent) || - cfs_time_aftereq(req->rq_real_sent, req->rq_deadline)) ? + req->rq_real_sent < req->rq_sent || + req->rq_real_sent >= req->rq_deadline) ? "timed out for sent delay" : "timed out for slow reply"), - req->rq_sent, req->rq_real_sent); + (s64)req->rq_sent, (s64)req->rq_real_sent);
if (imp != NULL && obd_debug_peer_on_timeout) LNetCtl(IOC_LIBCFS_DEBUG_PEER, &imp->imp_connection->c_peer); @@ -1967,7 +1967,7 @@ int ptlrpc_expired_set(void *data) { struct ptlrpc_request_set *set = data; struct list_head *tmp; - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds();
LASSERT(set != NULL);
@@ -2050,10 +2050,10 @@ EXPORT_SYMBOL(ptlrpc_interrupted_set); int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set) { struct list_head *tmp; - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds(); int timeout = 0; struct ptlrpc_request *req; - int deadline; + time64_t deadline;
list_for_each(tmp, &set->set_requests) { req = list_entry(tmp, struct ptlrpc_request, rq_set_chain); @@ -2364,7 +2364,7 @@ int ptlrpc_unregister_reply(struct ptlrpc_request *request, int async) */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_REPL_UNLINK) && async && request->rq_reply_deadline == 0) - request->rq_reply_deadline = get_seconds()+LONG_UNLINK; + request->rq_reply_deadline = ktime_get_real_seconds()+LONG_UNLINK;
/* * Nothing left to do. @@ -2939,7 +2939,7 @@ static spinlock_t ptlrpc_last_xid_lock; #define YEAR_2004 (1ULL << 30) void ptlrpc_init_xid(void) { - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds();
spin_lock_init(&ptlrpc_last_xid_lock); if (now < YEAR_2004) { @@ -3028,7 +3028,7 @@ static void ptlrpcd_add_work_req(struct ptlrpc_request *req) { /* re-initialize the req */ req->rq_timeout = obd_timeout; - req->rq_sent = get_seconds(); + req->rq_sent = ktime_get_real_seconds(); req->rq_deadline = req->rq_sent + req->rq_timeout; req->rq_reply_deadline = req->rq_deadline; req->rq_phase = RQ_PHASE_INTERPRET; diff --git a/drivers/staging/lustre/lustre/ptlrpc/events.c b/drivers/staging/lustre/lustre/ptlrpc/events.c index 53f6b6278403..afd869b205a5 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/events.c +++ b/drivers/staging/lustre/lustre/ptlrpc/events.c @@ -64,7 +64,7 @@ void request_out_callback(lnet_event_t *ev)
sptlrpc_request_out_callback(req); spin_lock(&req->rq_lock); - req->rq_real_sent = get_seconds(); + req->rq_real_sent = ktime_get_real_seconds(); if (ev->unlinked) req->rq_req_unlink = 0;
@@ -246,7 +246,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt, struct ptlrpc_request *req) { __u64 sec = req->rq_arrival_time.tv_sec; - __u32 usec = req->rq_arrival_time.tv_usec >> 4; /* usec / 16 */ + __u32 usec = req->rq_arrival_time.tv_nsec / NSEC_PER_USEC / 16; /* usec / 16 */ __u64 new_seq;
/* set sequence ID for request and add it to history list, @@ -327,7 +327,7 @@ void request_in_callback(lnet_event_t *ev) req->rq_reqbuf = ev->md.start + ev->offset; if (ev->type == LNET_EVENT_PUT && ev->status == 0) req->rq_reqdata_len = ev->mlength; - do_gettimeofday(&req->rq_arrival_time); + ktime_get_real_ts64(&req->rq_arrival_time); req->rq_peer = ev->initiator; req->rq_self = ev->target.nid; req->rq_rqbd = rqbd; diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c index 3fc49ee66d8b..9ff1a22b1b67 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/import.c +++ b/drivers/staging/lustre/lustre/ptlrpc/import.c @@ -219,7 +219,7 @@ void ptlrpc_deactivate_import(struct obd_import *imp) EXPORT_SYMBOL(ptlrpc_deactivate_import);
static unsigned int -ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now) +ptlrpc_inflight_deadline(struct ptlrpc_request *req, time64_t now) { long dl;
@@ -244,7 +244,7 @@ ptlrpc_inflight_deadline(struct ptlrpc_request *req, time_t now)
static unsigned int ptlrpc_inflight_timeout(struct obd_import *imp) { - time_t now = get_seconds(); + time64_t now = ktime_get_real_seconds(); struct list_head *tmp, *n; struct ptlrpc_request *req; unsigned int timeout = 0; diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 477cc4da31a4..500687d9071f 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -946,13 +946,13 @@ static int ptlrpc_lprocfs_svc_req_history_show(struct seq_file *s, void *iter) * must be just as careful as the service's request * parser. Currently I only print stuff here I know is OK * to look at coz it was set up in request_in_callback()!!! */ - seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%ld:%lds(%+lds) ", + seq_printf(s, "%lld:%s:%s:x%llu:%d:%s:%lld:%lds(%+lds) ", req->rq_history_seq, libcfs_nid2str(req->rq_self), libcfs_id2str(req->rq_peer), req->rq_xid, req->rq_reqlen, ptlrpc_rqphase2str(req), - req->rq_arrival_time.tv_sec, - req->rq_sent - req->rq_arrival_time.tv_sec, - req->rq_sent - req->rq_deadline); + (s64)req->rq_arrival_time.tv_sec, + (long)(req->rq_sent - req->rq_arrival_time.tv_sec), + (long)(req->rq_sent - req->rq_deadline)); if (svc->srv_ops.so_req_printer == NULL) seq_printf(s, "\n"); else diff --git a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c index 22194c0ab970..272f9f2bac3d 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/niobuf.c +++ b/drivers/staging/lustre/lustre/ptlrpc/niobuf.c @@ -252,7 +252,7 @@ int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async) /* Let's setup deadline for reply unlink. */ if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) && async && req->rq_bulk_deadline == 0) - req->rq_bulk_deadline = get_seconds() + LONG_UNLINK; + req->rq_bulk_deadline = ktime_get_real_seconds() + LONG_UNLINK;
if (ptlrpc_client_bulk_active(req) == 0) /* completed or */ return 1; /* never registered */ @@ -303,7 +303,7 @@ static void ptlrpc_at_set_reply(struct ptlrpc_request *req, int flags) { struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; struct ptlrpc_service *svc = svcpt->scp_service; - int service_time = max_t(int, get_seconds() - + int service_time = max_t(int, ktime_get_real_seconds() - req->rq_arrival_time.tv_sec, 1);
if (!(flags & PTLRPC_REPLY_EARLY) && @@ -421,7 +421,7 @@ int ptlrpc_send_reply(struct ptlrpc_request *req, int flags) if (unlikely(rc)) goto out;
- req->rq_sent = get_seconds(); + req->rq_sent = ktime_get_real_seconds();
rc = ptl_send_buf(&rs->rs_md_h, rs->rs_repbuf, rs->rs_repdata_len, (rs->rs_difficult && !rs->rs_no_ack) ? @@ -632,8 +632,8 @@ int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5);
- do_gettimeofday(&request->rq_arrival_time); - request->rq_sent = get_seconds(); + ktime_get_real_ts64(&request->rq_arrival_time); + request->rq_sent = ktime_get_real_seconds(); /* We give the server rq_timeout secs to process the req, and add the network latency for our local timeout. */ request->rq_deadline = request->rq_sent + request->rq_timeout + diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c index f1380613a4d1..1b30ac59ef62 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c @@ -2344,7 +2344,7 @@ void _debug_req(struct ptlrpc_request *req,
va_start(args, fmt); libcfs_debug_vmsg2(msgdata, fmt, args, - " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %d dl " CFS_TIME_T " ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", + " req@%p x%llu/t%lld(%lld) o%d->%s@%s:%d/%d lens %d/%d e %d to %lld dl %lld ref %d fl " REQ_FLAGS_FMT "/%x/%x rc %d/%d\n", req, req->rq_xid, req->rq_transno, req_ok ? lustre_msg_get_transno(req->rq_reqmsg) : 0, req_ok ? lustre_msg_get_opc(req->rq_reqmsg) : -1, @@ -2356,8 +2356,8 @@ void _debug_req(struct ptlrpc_request *req, libcfs_nid2str(nid), req->rq_request_portal, req->rq_reply_portal, req->rq_reqlen, req->rq_replen, - req->rq_early_count, req->rq_timedout, - req->rq_deadline, + req->rq_early_count, (s64)req->rq_timedout, + (s64)req->rq_deadline, atomic_read(&req->rq_refcount), DEBUG_REQ_FLAGS(req), req_ok ? lustre_msg_get_flags(req->rq_reqmsg) : -1, diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 7766bb8b352a..3fac9756dcc0 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -1160,7 +1160,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) }
/* Set timer for closest deadline */ - next = (__s32)(array->paa_deadline - get_seconds() - + next = (__s32)(array->paa_deadline - ktime_get_real_seconds() - at_early_margin); if (next <= 0) { ptlrpc_at_timer((unsigned long)svcpt); @@ -1191,7 +1191,7 @@ static int ptlrpc_at_add_timed(struct ptlrpc_request *req) spin_lock(&svcpt->scp_at_lock); LASSERT(list_empty(&req->rq_timed_list));
- index = (unsigned long)req->rq_deadline % array->paa_size; + div_u64_rem(req->rq_deadline, array->paa_size, &index); if (array->paa_reqs_count[index] > 0) { /* latest rpcs will have the latest deadlines in the list, * so search backward. */ @@ -1250,8 +1250,8 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) struct ptlrpc_service_part *svcpt = req->rq_rqbd->rqbd_svcpt; struct ptlrpc_request *reqcopy; struct lustre_msg *reqmsg; - long olddl = req->rq_deadline - get_seconds(); - time_t newdl; + long olddl = req->rq_deadline - ktime_get_real_seconds(); + time64_t newdl; int rc;
/* deadline is when the client expects us to reply, margin is the @@ -1293,21 +1293,21 @@ static int ptlrpc_at_send_early_reply(struct ptlrpc_request *req) /* Fake our processing time into the future to ask the clients * for some extra amount of time */ at_measured(&svcpt->scp_at_estimate, at_extra + - get_seconds() - + ktime_get_real_seconds() - req->rq_arrival_time.tv_sec);
/* Check to see if we've actually increased the deadline - * we may be past adaptive_max */ if (req->rq_deadline >= req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate)) { - DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%ld), not sending early reply\n", + DEBUG_REQ(D_WARNING, req, "Couldn't add any time (%ld/%lld), not sending early reply\n", olddl, req->rq_arrival_time.tv_sec + at_get(&svcpt->scp_at_estimate) - - get_seconds()); + ktime_get_real_seconds()); return -ETIMEDOUT; } } - newdl = get_seconds() + at_get(&svcpt->scp_at_estimate); + newdl = ktime_get_real_seconds() + at_get(&svcpt->scp_at_estimate);
reqcopy = ptlrpc_request_cache_alloc(GFP_NOFS); if (reqcopy == NULL) @@ -1390,8 +1390,8 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) struct ptlrpc_request *rq, *n; struct list_head work_list; __u32 index, count; - time_t deadline; - time_t now = get_seconds(); + time64_t deadline; + time64_t now = ktime_get_real_seconds(); long delay; int first, counter = 0;
@@ -1421,7 +1421,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) server will take. Send early replies to everyone expiring soon. */ INIT_LIST_HEAD(&work_list); deadline = -1; - index = (unsigned long)array->paa_deadline % array->paa_size; + div_u64_rem(array->paa_deadline, array->paa_size, &index); count = array->paa_count; while (count > 0) { count -= array->paa_reqs_count[index]; @@ -1463,7 +1463,7 @@ static int ptlrpc_at_check_timed(struct ptlrpc_service_part *svcpt) chance to send early replies */ LCONSOLE_WARN("%s: This server is not able to keep up with request traffic (cpu-bound).\n", svcpt->scp_service->srv_name); - CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=" CFS_DURATION_T "(jiff)\n", + CWARN("earlyQ=%d reqQ=%d recA=%d, svcEst=%d, delay=%ld(jiff)\n", counter, svcpt->scp_nreqs_incoming, svcpt->scp_nreqs_active, at_get(&svcpt->scp_at_estimate), delay); @@ -1834,10 +1834,9 @@ ptlrpc_server_handle_req_in(struct ptlrpc_service_part *svcpt, }
/* req_in handling should/must be fast */ - if (get_seconds() - req->rq_arrival_time.tv_sec > 5) + if (ktime_get_real_seconds() - req->rq_arrival_time.tv_sec > 5) DEBUG_REQ(D_WARNING, req, "Slow req_in handling "CFS_DURATION_T"s", - cfs_time_sub(get_seconds(), - req->rq_arrival_time.tv_sec)); + (long)(ktime_get_real_seconds() - req->rq_arrival_time.tv_sec));
/* Set rpc server deadline and add it to the timed list */ deadline = (lustre_msghdr_get_flags(req->rq_reqmsg) & @@ -1878,9 +1877,12 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, { struct ptlrpc_service *svc = svcpt->scp_service; struct ptlrpc_request *request; - struct timeval work_start; - struct timeval work_end; - long timediff; + struct timespec64 work_start; + struct timespec64 work_end; + struct timespec64 timediff; + struct timespec64 arrived; + unsigned long timediff_usecs; + unsigned long arrived_usecs; int rc; int fail_opc = 0;
@@ -1903,12 +1905,13 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_DUMP_LOG)) libcfs_debug_dumplog();
- do_gettimeofday(&work_start); - timediff = cfs_timeval_sub(&work_start, &request->rq_arrival_time, - NULL); + ktime_get_real_ts64(&work_start); + timediff = timespec64_sub(work_start, request->rq_arrival_time); + timediff_usecs = timediff.tv_sec * USEC_PER_SEC + + timediff.tv_nsec / NSEC_PER_USEC; if (likely(svc->srv_stats != NULL)) { lprocfs_counter_add(svc->srv_stats, PTLRPC_REQWAIT_CNTR, - timediff); + timediff_usecs); lprocfs_counter_add(svc->srv_stats, PTLRPC_REQQDEPTH_CNTR, svcpt->scp_nreqs_incoming); lprocfs_counter_add(svc->srv_stats, PTLRPC_REQACTIVE_CNTR, @@ -1935,18 +1938,16 @@ ptlrpc_server_handle_request(struct ptlrpc_service_part *svcpt, if (likely(request->rq_export)) { if (unlikely(ptlrpc_check_req(request))) goto put_conn; - ptlrpc_update_export_timer(request->rq_export, timediff >> 19); + ptlrpc_update_export_timer(request->rq_export, timediff_usecs >> 19); }
/* Discard requests queued for longer than the deadline. The deadline is increased if we send an early reply. */ - if (get_seconds() > request->rq_deadline) { + if (ktime_get_real_seconds() > request->rq_deadline) { DEBUG_REQ(D_ERROR, request, "Dropping timed-out request from %s: deadline " CFS_DURATION_T ":" CFS_DURATION_T "s ago\n", libcfs_id2str(request->rq_peer), - cfs_time_sub(request->rq_deadline, - request->rq_arrival_time.tv_sec), - cfs_time_sub(get_seconds(), - request->rq_deadline)); + (long)(request->rq_deadline - request->rq_arrival_time.tv_sec), + (long)(ktime_get_real_seconds() - request->rq_deadline)); goto put_conn; }
@@ -1971,19 +1972,21 @@ put_conn: lu_context_exit(&request->rq_session); lu_context_fini(&request->rq_session);
- if (unlikely(get_seconds() > request->rq_deadline)) { + if (unlikely(ktime_get_real_seconds() > request->rq_deadline)) { DEBUG_REQ(D_WARNING, request, - "Request took longer than estimated (" - CFS_DURATION_T":"CFS_DURATION_T - "s); client may timeout.", - cfs_time_sub(request->rq_deadline, - request->rq_arrival_time.tv_sec), - cfs_time_sub(get_seconds(), - request->rq_deadline)); - } - - do_gettimeofday(&work_end); - timediff = cfs_timeval_sub(&work_end, &work_start, NULL); + "Request took longer than estimated " + "(%lld:%llds); client may timeout.", + (s64)request->rq_deadline - request->rq_arrival_time.tv_sec, + (s64)ktime_get_real_seconds() - request->rq_deadline); + } + + ktime_get_real_ts64(&work_end); + timediff = timespec64_sub(work_end, work_start); + timediff_usecs = timediff.tv_sec * USEC_PER_SEC + + timediff.tv_nsec / NSEC_PER_USEC; + arrived = timespec64_sub(work_end, request->rq_arrival_time); + arrived_usecs = arrived.tv_sec * USEC_PER_SEC + + arrived.tv_nsec / NSEC_PER_USEC; CDEBUG(D_RPCTRACE, "Handled RPC pname:cluuid+ref:pid:xid:nid:opc %s:%s+%d:%d:x%llu:%s:%d Request processed in %ldus (%ldus total) trans %llu rc %d/%d\n", current_comm(), (request->rq_export ? @@ -1994,8 +1997,8 @@ put_conn: request->rq_xid, libcfs_id2str(request->rq_peer), lustre_msg_get_opc(request->rq_reqmsg), - timediff, - cfs_timeval_sub(&work_end, &request->rq_arrival_time, NULL), + timediff_usecs, + arrived_usecs, (request->rq_repmsg ? lustre_msg_get_transno(request->rq_repmsg) : request->rq_transno), @@ -2009,16 +2012,15 @@ put_conn: LASSERT(opc < LUSTRE_MAX_OPCODES); lprocfs_counter_add(svc->srv_stats, opc + EXTRA_MAX_OPCODES, - timediff); + timediff_usecs); } } if (unlikely(request->rq_early_count)) { DEBUG_REQ(D_ADAPTTO, request, - "sent %d early replies before finishing in " - CFS_DURATION_T"s", + "sent %d early replies before finishing in %llds", request->rq_early_count, - cfs_time_sub(work_end.tv_sec, - request->rq_arrival_time.tv_sec)); + (s64)work_end.tv_sec - + request->rq_arrival_time.tv_sec); }
out_req: @@ -3057,10 +3059,10 @@ EXPORT_SYMBOL(ptlrpc_unregister_service); static int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) { struct ptlrpc_request *request = NULL; - struct timeval right_now; - long timediff; + struct timespec64 right_now; + struct timespec64 timediff;
- do_gettimeofday(&right_now); + ktime_get_real_ts64(&right_now);
spin_lock(&svcpt->scp_req_lock); /* How long has the next entry been waiting? */ @@ -3074,13 +3076,13 @@ static int ptlrpc_svcpt_health_check(struct ptlrpc_service_part *svcpt) return 0; }
- timediff = cfs_timeval_sub(&right_now, &request->rq_arrival_time, NULL); + timediff = timespec64_sub(right_now, request->rq_arrival_time); spin_unlock(&svcpt->scp_req_lock);
- if ((timediff / ONE_MILLION) > + if ((timediff.tv_sec) > (AT_OFF ? obd_timeout * 3 / 2 : at_max)) { - CERROR("%s: unhealthy - request has been waiting %lds\n", - svcpt->scp_service->srv_name, timediff / ONE_MILLION); + CERROR("%s: unhealthy - request has been waiting %llds\n", + svcpt->scp_service->srv_name, (s64)timediff.tv_sec); return -1; }
These three functions have not been in used for a long time, so lets just remove them.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/lustre/include/obd.h | 62 ----------------------------- 1 file changed, 62 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index f09a0405ff97..57b5e1123b4f 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -167,68 +167,6 @@ struct obd_info { void *oi_capa; };
-/* compare all relevant fields. */ -static inline int lov_stripe_md_cmp(struct lov_stripe_md *m1, - struct lov_stripe_md *m2) -{ - /* - * ->lsm_wire contains padding, but it should be zeroed out during - * allocation. - */ - return memcmp(&m1->lsm_wire, &m2->lsm_wire, sizeof(m1->lsm_wire)); -} - -static inline int lov_lum_lsm_cmp(struct lov_user_md *lum, - struct lov_stripe_md *lsm) -{ - if (lsm->lsm_magic != lum->lmm_magic) - return 1; - if ((lsm->lsm_stripe_count != 0) && (lum->lmm_stripe_count != 0) && - (lsm->lsm_stripe_count != lum->lmm_stripe_count)) - return 2; - if ((lsm->lsm_stripe_size != 0) && (lum->lmm_stripe_size != 0) && - (lsm->lsm_stripe_size != lum->lmm_stripe_size)) - return 3; - if ((lsm->lsm_pattern != 0) && (lum->lmm_pattern != 0) && - (lsm->lsm_pattern != lum->lmm_pattern)) - return 4; - if ((lsm->lsm_magic == LOV_MAGIC_V3) && - (strncmp(lsm->lsm_pool_name, - ((struct lov_user_md_v3 *)lum)->lmm_pool_name, - LOV_MAXPOOLNAME) != 0)) - return 5; - return 0; -} - -static inline int lov_lum_swab_if_needed(struct lov_user_md_v3 *lumv3, - int *lmm_magic, - struct lov_user_md *lum) -{ - if (lum && copy_from_user(lumv3, lum, sizeof(struct lov_user_md_v1))) - return -EFAULT; - - *lmm_magic = lumv3->lmm_magic; - - if (*lmm_magic == __swab32(LOV_USER_MAGIC_V1)) { - lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lumv3); - *lmm_magic = LOV_USER_MAGIC_V1; - } else if (*lmm_magic == LOV_USER_MAGIC_V3) { - if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) - return -EFAULT; - } else if (*lmm_magic == __swab32(LOV_USER_MAGIC_V3)) { - if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) - return -EFAULT; - lustre_swab_lov_user_md_v3(lumv3); - *lmm_magic = LOV_USER_MAGIC_V3; - } else if (*lmm_magic != LOV_USER_MAGIC_V1) { - CDEBUG(D_IOCTL, - "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", - *lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); - return -EINVAL; - } - return 0; -} - void lov_stripe_lock(struct lov_stripe_md *md); void lov_stripe_unlock(struct lov_stripe_md *md);
This is a simple cleanup that I did after noticing that the abstraction for the timer functions in completely pointless, and the one user (ptlrpc) can just as well call the native Linux functions.
For good measure, this also removes the empty libcfs_arch_init() and libcfs_arch_cleanup() functions that are defined in the same file.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../staging/lustre/include/linux/libcfs/libcfs.h | 3 - .../lustre/include/linux/libcfs/libcfs_prim.h | 12 ---- .../lustre/lustre/libcfs/linux/linux-prim.c | 64 ---------------------- drivers/staging/lustre/lustre/libcfs/module.c | 3 - drivers/staging/lustre/lustre/ptlrpc/service.c | 11 ++-- 5 files changed, 6 insertions(+), 87 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h index 259a33658d3f..385ced15c742 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h @@ -62,9 +62,6 @@ static inline int __is_po2(unsigned long long val)
#include <linux/list.h>
-int libcfs_arch_init(void); -void libcfs_arch_cleanup(void); - /* need both kernel and user-land acceptor */ #define LNET_ACCEPTOR_MIN_RESERVED_PORT 512 #define LNET_ACCEPTOR_MAX_RESERVED_PORT 1023 diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h index 62ade0809264..082fe6de90e4 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_prim.h @@ -40,20 +40,8 @@ #ifndef __LIBCFS_PRIM_H__ #define __LIBCFS_PRIM_H__
-/* - * Timer - */ -typedef void (cfs_timer_func_t)(ulong_ptr_t); - void add_wait_queue_exclusive_head(wait_queue_head_t *, wait_queue_t *);
-void cfs_init_timer(struct timer_list *t); -void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg); -void cfs_timer_arm(struct timer_list *t, unsigned long deadline); -void cfs_timer_disarm(struct timer_list *t); -int cfs_timer_is_armed(struct timer_list *t); -unsigned long cfs_timer_deadline(struct timer_list *t); - /* * Memory */ diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c index 12b6af4cac3e..89084460231a 100644 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-prim.c @@ -70,55 +70,6 @@ add_wait_queue_exclusive_head(wait_queue_head_t *waitq, wait_queue_t *link) } EXPORT_SYMBOL(add_wait_queue_exclusive_head);
-void cfs_init_timer(struct timer_list *t) -{ - init_timer(t); -} -EXPORT_SYMBOL(cfs_init_timer); - -void cfs_timer_init(struct timer_list *t, cfs_timer_func_t *func, void *arg) -{ - init_timer(t); - t->function = func; - t->data = (unsigned long)arg; -} -EXPORT_SYMBOL(cfs_timer_init); - -void cfs_timer_arm(struct timer_list *t, unsigned long deadline) -{ - mod_timer(t, deadline); -} -EXPORT_SYMBOL(cfs_timer_arm); - -void cfs_timer_disarm(struct timer_list *t) -{ - del_timer(t); -} -EXPORT_SYMBOL(cfs_timer_disarm); - -int cfs_timer_is_armed(struct timer_list *t) -{ - return timer_pending(t); -} -EXPORT_SYMBOL(cfs_timer_is_armed); - -unsigned long cfs_timer_deadline(struct timer_list *t) -{ - return t->expires; -} -EXPORT_SYMBOL(cfs_timer_deadline); - -void cfs_enter_debugger(void) -{ -#if defined(CONFIG_KGDB) - /* BREAKPOINT(); */ -#else - /* nothing */ -#endif -} -EXPORT_SYMBOL(cfs_enter_debugger); - - sigset_t cfs_block_allsigs(void) { @@ -194,18 +145,3 @@ cfs_clear_sigpending(void) spin_unlock_irqrestore(¤t->sighand->siglock, flags); } EXPORT_SYMBOL(cfs_clear_sigpending); - -int -libcfs_arch_init(void) -{ - return 0; -} -EXPORT_SYMBOL(libcfs_arch_init); - -void -libcfs_arch_cleanup(void) -{ - return; -} -EXPORT_SYMBOL(libcfs_arch_cleanup); - diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index a19f5796b642..5e4262a2e6f3 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -701,7 +701,6 @@ static int init_libcfs_module(void) { int rc;
- libcfs_arch_init(); libcfs_init_nidstrings();
rc = libcfs_debug_init(5 * 1024 * 1024); @@ -777,8 +776,6 @@ static void exit_libcfs_module(void) rc = libcfs_debug_cleanup(); if (rc) pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc); - - libcfs_arch_cleanup(); }
MODULE_VERSION("1.0.0"); diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c index 3fac9756dcc0..623871beb5aa 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/service.c +++ b/drivers/staging/lustre/lustre/ptlrpc/service.c @@ -649,7 +649,8 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc, if (array->paa_reqs_count == NULL) goto free_reqs_array;
- cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt); + setup_timer(&svcpt->scp_at_timer, ptlrpc_at_timer, (unsigned long)svcpt); + /* At SOW, service time should be quick; 10s seems generous. If client * timeout is less than this, we'll be sending an early reply. */ at_init(&svcpt->scp_at_estimate, 10, 0); @@ -1155,7 +1156,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) __s32 next;
if (array->paa_count == 0) { - cfs_timer_disarm(&svcpt->scp_at_timer); + del_timer(&svcpt->scp_at_timer); return; }
@@ -1165,7 +1166,7 @@ static void ptlrpc_at_set_timer(struct ptlrpc_service_part *svcpt) if (next <= 0) { ptlrpc_at_timer((unsigned long)svcpt); } else { - cfs_timer_arm(&svcpt->scp_at_timer, cfs_time_shift(next)); + mod_timer(&svcpt->scp_at_timer, cfs_time_shift(next)); CDEBUG(D_INFO, "armed %s at %+ds\n", svcpt->scp_service->srv_name, next); } @@ -2866,7 +2867,7 @@ ptlrpc_service_del_atimer(struct ptlrpc_service *svc) /* early disarm AT timer... */ ptlrpc_service_for_each_part(svcpt, i, svc) { if (svcpt->scp_service != NULL) - cfs_timer_disarm(&svcpt->scp_at_timer); + del_timer(&svcpt->scp_at_timer); } }
@@ -3006,7 +3007,7 @@ ptlrpc_service_free(struct ptlrpc_service *svc) break;
/* In case somebody rearmed this in the meantime */ - cfs_timer_disarm(&svcpt->scp_at_timer); + del_timer(&svcpt->scp_at_timer); array = &svcpt->scp_at_array;
kfree(array->paa_reqs_array);
A bunch of API functions deal with time values but are now completely unused in lustre. This removes them in order to remove all references to time_t from the header files.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- .../lustre/include/linux/libcfs/libcfs_time.h | 49 ---------------------- .../lustre/include/linux/libcfs/linux/linux-time.h | 17 -------- 2 files changed, 66 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h index 5de6da085712..2c7ec2d28f38 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_time.h @@ -68,55 +68,6 @@ static inline unsigned long cfs_time_shift(int seconds) return cfs_time_add(cfs_time_current(), cfs_time_seconds(seconds)); }
-static inline long cfs_timeval_sub(struct timeval *large, struct timeval *small, - struct timeval *result) -{ - long r = (long)( - (large->tv_sec - small->tv_sec) * ONE_MILLION + - (large->tv_usec - small->tv_usec)); - if (result != NULL) { - result->tv_usec = r % ONE_MILLION; - result->tv_sec = r / ONE_MILLION; - } - return r; -} - -static inline void cfs_slow_warning(unsigned long now, int seconds, char *msg) -{ - if (cfs_time_after(cfs_time_current(), - cfs_time_add(now, cfs_time_seconds(15)))) - CERROR("slow %s "CFS_TIME_T" sec\n", msg, - cfs_duration_sec(cfs_time_sub(cfs_time_current(), now))); -} - -#define CFS_RATELIMIT(seconds) \ -({ \ - /* \ - * XXX nikita: non-portable initializer \ - */ \ - static time_t __next_message; \ - int result; \ - \ - if (cfs_time_after(cfs_time_current(), __next_message)) \ - result = 1; \ - else { \ - __next_message = cfs_time_shift(seconds); \ - result = 0; \ - } \ - result; \ -}) - -/* - * helper function similar to do_gettimeofday() of Linux kernel - */ -static inline void cfs_fs_timeval(struct timeval *tv) -{ - struct timespec time; - - cfs_fs_time_current(&time); - cfs_fs_time_usec(&time, tv); -} - /* * return valid time-out based on user supplied one. Currently we only check * that time-out is not shorted than allowed. diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index f193f8bdee6e..09c59f080ca3 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -59,13 +59,6 @@
#include <linux/jiffies.h>
- -static inline void cfs_fs_time_usec(struct timespec *t, struct timeval *v) -{ - v->tv_sec = t->tv_sec; - v->tv_usec = t->tv_nsec / 1000; -} - /* * Generic kernel stuff */ @@ -75,16 +68,6 @@ static inline unsigned long cfs_time_current(void) return jiffies; }
-static inline void cfs_fs_time_current(struct timespec *t) -{ - *t = CURRENT_TIME; -} - -static inline time_t cfs_fs_time_sec(struct timespec *t) -{ - return t->tv_sec; -} - static inline long cfs_time_seconds(int seconds) { return ((long)seconds) * HZ;
The CFS_TIME_T macro serves no real purpose as we stopped using time_t and changed over to time64_t, so we can remove the last remaining uses of this.
Two uses of this macro are incorrect and refer to jiffies values rather than time_t, and one refers to an inode timespec that gets changed separately.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h | 1 - drivers/staging/lustre/lustre/mdc/mdc_reint.c | 3 +-- drivers/staging/lustre/lustre/ptlrpc/pinger.c | 7 +++---- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 5 ++--- 4 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h index 09c59f080ca3..ed8764b11c80 100644 --- a/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h +++ b/drivers/staging/lustre/include/linux/libcfs/linux/linux-time.h @@ -106,7 +106,6 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2) */ #define CFS_TICK (1)
-#define CFS_TIME_T "%lu" #define CFS_DURATION_T "%ld"
#endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */ diff --git a/drivers/staging/lustre/lustre/mdc/mdc_reint.c b/drivers/staging/lustre/lustre/mdc/mdc_reint.c index 47051c0799f8..79e4fd48a96a 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_reint.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_reint.c @@ -144,8 +144,7 @@ int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, rpc_lock = obd->u.cli.cl_rpc_lock;
if (op_data->op_attr.ia_valid & (ATTR_MTIME | ATTR_CTIME)) - CDEBUG(D_INODE, "setting mtime "CFS_TIME_T - ", ctime "CFS_TIME_T"\n", + CDEBUG(D_INODE, "setting mtime %ld, ctime %ld\n", LTIME_S(op_data->op_attr.ia_mtime), LTIME_S(op_data->op_attr.ia_ctime)); mdc_setattr_pack(req, op_data, ea, ealen, ea2, ea2len); diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c index 76eecb02d1fc..b13aaa2660f7 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c +++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c @@ -275,10 +275,9 @@ static int ptlrpc_pinger_main(void *arg) next ping time to next_ping + .01 sec, which means we will SKIP the next ping at next_ping, and the ping will get sent 2 timeouts from now! Beware. */ - CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" (" - CFS_TIME_T")\n", time_to_next_wake, - cfs_time_add(this_ping, - cfs_time_seconds(PING_INTERVAL))); + CDEBUG(D_INFO, "next wakeup in "CFS_DURATION_T" (%ld)\n", + time_to_next_wake, cfs_time_add(this_ping, + cfs_time_seconds(PING_INTERVAL))); if (time_to_next_wake > 0) { lwi = LWI_TIMEOUT(max_t(long, time_to_next_wake, cfs_time_seconds(1)), diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index 56dab9db4157..c18b71c71181 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -145,7 +145,7 @@ int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v) "cache missing: %lu\n" "low free mark: %lu\n" "max waitqueue depth: %u\n" - "max wait time: " CFS_TIME_T "/%u\n", + "max wait time: %ld/%u\n", totalram_pages, PAGES_PER_POOL, page_pools.epp_max_pages, @@ -768,8 +768,7 @@ void sptlrpc_enc_pool_fini(void)
if (page_pools.epp_st_access > 0) { CDEBUG(D_SEC, - "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait " - CFS_TIME_T"/%d\n", + "max pages %lu, grows %u, grow fails %u, shrinks %u, access %lu, missing %lu, max qlen %u, max wait %ld/%d\n", page_pools.epp_st_max_pages, page_pools.epp_st_grows, page_pools.epp_st_grow_fails, page_pools.epp_st_shrinks, page_pools.epp_st_access,