mirror of https://github.com/schoebel/mars
all: adapt to removal of current_kernel_time64()
This commit is contained in:
parent
2bf49d5a64
commit
b85bc0f576
|
@ -113,7 +113,7 @@ void _get_lamport(struct lamport_clock *clock,
|
|||
* Lamport timestamps, respectively, in relation to pseudo-parallel
|
||||
* calls to get_lamport().
|
||||
*/
|
||||
_real_now = get_real_lamport();
|
||||
get_real_lamport(&_real_now);
|
||||
|
||||
up_read(&clock->lamport_sem);
|
||||
|
||||
|
@ -180,7 +180,7 @@ void _set_get_lamport(struct lamport_clock *clock,
|
|||
*lamport_now = lamport_time_add(clock->lamport_stamp,
|
||||
(struct lamport_time){0, 1});
|
||||
clock->lamport_stamp = *lamport_now;
|
||||
_real_now = get_real_lamport();
|
||||
get_real_lamport(&_real_now);
|
||||
up_write(&clock->lamport_sem);
|
||||
|
||||
if (real_now)
|
||||
|
@ -199,9 +199,10 @@ int max_lamport_future = 30 * 24 * 3600;
|
|||
bool _protect_lamport_time(struct lamport_clock *clock,
|
||||
struct lamport_time *check)
|
||||
{
|
||||
struct lamport_time limit = get_real_lamport();
|
||||
struct lamport_time limit;
|
||||
bool res = false;
|
||||
|
||||
get_real_lamport(&limit);
|
||||
limit.tv_sec += max_lamport_future;
|
||||
if (unlikely(check->tv_sec >= limit.tv_sec)) {
|
||||
down_write(&clock->lamport_sem);
|
||||
|
|
|
@ -26,7 +26,8 @@
|
|||
|
||||
#include <linux/time.h>
|
||||
#include <linux/ktime.h>
|
||||
#ifndef CURRENT_TIME
|
||||
/* adapt to 8b094cd03b4a3793220d8d8d86a173bfea8c285b */
|
||||
#ifndef ktime_get_real_ts
|
||||
#include <linux/timekeeping.h>
|
||||
#endif
|
||||
|
||||
|
@ -43,7 +44,7 @@
|
|||
# define lamport_time_add timespec64_add
|
||||
# define lamport_time_add_ns timespec64_add_ns
|
||||
# define lamport_time_sub timespec64_sub
|
||||
# define get_real_lamport current_kernel_time64
|
||||
# define __get_real_lamport current_kernel_time64
|
||||
#else /* deprecated */
|
||||
# define lamport_time timespec
|
||||
# define lamport_time_to_ns timespec_to_ns
|
||||
|
@ -52,7 +53,16 @@
|
|||
# define lamport_time_add timespec_add
|
||||
# define lamport_time_add_ns timespec_add_ns
|
||||
# define lamport_time_sub timespec_sub
|
||||
# define get_real_lamport() CURRENT_TIME
|
||||
# define __get_real_lamport() CURRENT_TIME
|
||||
#endif
|
||||
|
||||
/* Compat: adapt to old code before e4b92b108c6cd6b311e4b6e85d6a87a34599a6e3
|
||||
* obeying edca71fecb77e2697337d192cbfe96f513407761
|
||||
* and the previously mentioned commits regarding CURRENT_TIME
|
||||
*/
|
||||
#if defined(getnstimeofday64) || defined(ktime_get_real_ts64) || defined(CURRENT_TIME)
|
||||
#define ktime_get_coarse_real_ts64(real_now) \
|
||||
*(real_now) = __get_real_lamport()
|
||||
#endif
|
||||
|
||||
#include <linux/rwsem.h>
|
||||
|
@ -81,6 +91,10 @@ extern void _get_lamport(struct lamport_clock *clock,
|
|||
struct lamport_time *real_now,
|
||||
struct lamport_time *lamport_now);
|
||||
|
||||
/* This version gets only the real time */
|
||||
#define get_real_lamport(real_now) \
|
||||
ktime_get_coarse_real_ts64(real_now)
|
||||
|
||||
/* This ensures _strict_ monotonicity of the Lamport clock */
|
||||
extern void _set_lamport(struct lamport_clock *clock,
|
||||
struct lamport_time *lamport_advance);
|
||||
|
@ -155,7 +169,7 @@ void __lamport_op(struct lamport_time *clock,
|
|||
|
||||
/* Get and handle realtime */
|
||||
if (real_now) {
|
||||
*real_now = get_real_lamport();
|
||||
get_real_lamport(real_now);
|
||||
if (lamport_time_compare(real_now, clock) > 0)
|
||||
*clock = *real_now;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ int mars_limit(struct mars_limiter *lim, int amount)
|
|||
if (unlikely(amount < 0))
|
||||
amount = 0;
|
||||
|
||||
now = get_real_lamport();
|
||||
get_real_lamport(&now);
|
||||
|
||||
/* Compute the maximum delay along the path
|
||||
* down to the root of the hierarchy tree.
|
||||
|
|
|
@ -45,11 +45,11 @@ struct timing_stats {
|
|||
({ \
|
||||
struct lamport_time __tmp_diff; \
|
||||
\
|
||||
(_stamp1) = get_real_lamport(); \
|
||||
get_real_lamport(&(_stamp1)); \
|
||||
\
|
||||
_CODE; \
|
||||
\
|
||||
(_stamp2) = get_real_lamport(); \
|
||||
get_real_lamport(&(_stamp2)); \
|
||||
__tmp_diff = lamport_time_sub((_stamp2), (_stamp1)); \
|
||||
lamport_time_to_ns(&__tmp_diff); \
|
||||
})
|
||||
|
@ -95,7 +95,7 @@ extern int report_timing(struct timing_stats *tim, char *str, int maxlen);
|
|||
#else // CONFIG_MARS_DEBUG
|
||||
|
||||
#define _TIME_STATS(_timing, _stamp1, _stamp2, _CODE) \
|
||||
((void)_timing, (_stamp1) = (_stamp2) = get_real_lamport(), _CODE, 0)
|
||||
((void)_timing, get_real_lamport(&(_stamp1)), (_stamp1) = (_stamp2), _CODE, 0)
|
||||
|
||||
#define TIME_STATS(_timing, _CODE) \
|
||||
((void)_timing, _CODE, 0)
|
||||
|
@ -128,10 +128,13 @@ struct banning {
|
|||
static inline
|
||||
bool banning_hit(struct banning *ban, long long duration)
|
||||
{
|
||||
struct lamport_time now = get_real_lamport();
|
||||
struct lamport_time new_hit = now;
|
||||
bool hit = lamport_time_compare(&ban->ban_last_hit, &now) >= 0;
|
||||
struct lamport_time now;
|
||||
struct lamport_time new_hit;
|
||||
bool hit;
|
||||
|
||||
get_real_lamport(&now);
|
||||
hit = lamport_time_compare(&ban->ban_last_hit, &now) >= 0;
|
||||
new_hit = now;
|
||||
lamport_time_add_ns(&new_hit, duration);
|
||||
ban->ban_renew_count++;
|
||||
ban->ban_hit = true;
|
||||
|
@ -146,7 +149,7 @@ bool banning_hit(struct banning *ban, long long duration)
|
|||
static inline
|
||||
bool banning_is_hit(struct banning *ban)
|
||||
{
|
||||
struct lamport_time now = get_real_lamport();
|
||||
struct lamport_time now;
|
||||
|
||||
/* always report at least once after a hit */
|
||||
if (ban->ban_hit) {
|
||||
|
@ -154,6 +157,7 @@ bool banning_is_hit(struct banning *ban)
|
|||
return true;
|
||||
}
|
||||
|
||||
get_real_lamport(&now);
|
||||
return lamport_time_compare(&ban->ban_last_hit, &now) >= 0 &&
|
||||
lamport_time_to_ns(&ban->ban_last_hit);
|
||||
}
|
||||
|
|
|
@ -803,7 +803,7 @@ bool _is_done(struct copy_brick *brick)
|
|||
static int _copy_thread(void *data)
|
||||
{
|
||||
struct copy_brick *brick = data;
|
||||
struct lamport_time last_progress = get_real_lamport();
|
||||
struct lamport_time last_progress;
|
||||
int i;
|
||||
|
||||
MARS_DBG("--------------- copy_thread %p starting\n", brick);
|
||||
|
@ -814,6 +814,8 @@ static int _copy_thread(void *data)
|
|||
for (i = 0; i < COPY_INPUT_NR; i++)
|
||||
brick->inputs[i]->check_hint = 0;
|
||||
|
||||
get_real_lamport(&last_progress);
|
||||
|
||||
if (brick->copy_limiter)
|
||||
mars_limit_reset(brick->copy_limiter);
|
||||
_update_percent(brick, true);
|
||||
|
@ -847,10 +849,11 @@ static int _copy_thread(void *data)
|
|||
progress += _run_copy(brick, old_dirty);
|
||||
/* abort when no progress is made for a longer time */
|
||||
if (progress > 0) {
|
||||
last_progress = get_real_lamport();
|
||||
get_real_lamport(&last_progress);
|
||||
} else {
|
||||
struct lamport_time next_progress = get_real_lamport();
|
||||
struct lamport_time next_progress;
|
||||
|
||||
get_real_lamport(&next_progress);
|
||||
next_progress.tv_sec -= mars_copy_timeout;
|
||||
if (lamport_time_compare(&next_progress, &last_progress) > 0)
|
||||
brick->is_aborting = true;
|
||||
|
|
|
@ -206,7 +206,7 @@ void _call_bio_endio(struct if_brick *brick, struct bio *bio, int error)
|
|||
#endif
|
||||
#endif
|
||||
/* Just a hint for userspace, no strictness needed */
|
||||
brick->completion_stamp = get_real_lamport();
|
||||
get_real_lamport(&brick->completion_stamp);
|
||||
}
|
||||
|
||||
/* callback
|
||||
|
|
|
@ -1452,7 +1452,7 @@ static
|
|||
int _update_link_when_necessary(struct mars_rotate *rot, const char *type, const char *old, const char *new)
|
||||
{
|
||||
char *check = NULL;
|
||||
struct lamport_time limit = get_real_lamport();
|
||||
struct lamport_time limit;
|
||||
struct lamport_time stamp = {};
|
||||
int status = -EINVAL;
|
||||
bool res = false;
|
||||
|
@ -1460,6 +1460,8 @@ int _update_link_when_necessary(struct mars_rotate *rot, const char *type, const
|
|||
if (unlikely(!old || !new))
|
||||
goto out;
|
||||
|
||||
get_real_lamport(&limit);
|
||||
|
||||
/* Check whether something really has changed (avoid
|
||||
* useless/disturbing timestamp updates)
|
||||
* However, some minimum update frequency should not be
|
||||
|
@ -2601,12 +2603,14 @@ void touch_systemd_trigger(const char *filename)
|
|||
struct file *f;
|
||||
const int flags = O_CREAT | O_NOFOLLOW | O_RDWR;
|
||||
const int prot = 0600;
|
||||
struct lamport_time now = get_real_lamport();
|
||||
struct lamport_time now;
|
||||
int len;
|
||||
loff_t dummy_pos = 0;
|
||||
mm_segment_t oldfs;
|
||||
char str[32];
|
||||
|
||||
get_real_lamport(&now);
|
||||
|
||||
len = snprintf(str, sizeof(str),
|
||||
"%lld.%09ld\n",
|
||||
(s64)now.tv_sec, now.tv_nsec);
|
||||
|
@ -3085,10 +3089,12 @@ int peer_thread(void *data)
|
|||
old_transl = mars_translate_hostname(peer->peer);
|
||||
if (!old_transl || !strcmp(old_transl, peer->peer)) {
|
||||
static struct lamport_time full_fetch_stamp;
|
||||
struct lamport_time now = get_real_lamport();
|
||||
struct lamport_time now;
|
||||
|
||||
get_real_lamport(&now);
|
||||
MARS_ERR("unknown peer '%s'\n",
|
||||
peer->peer);
|
||||
|
||||
/* desperate: try to fetch /mars/ips/ not too frequently */
|
||||
if (!full_fetch_stamp.tv_sec ||
|
||||
now.tv_sec - full_fetch_stamp.tv_sec > 60) {
|
||||
|
|
|
@ -708,7 +708,7 @@ int mars_symlink(const char *oldpath, const char *newpath,
|
|||
* CMOS hardware clock value, until ntpd
|
||||
* corrected the system clock, fortunately.
|
||||
*/
|
||||
real_now = get_real_lamport();
|
||||
get_real_lamport(&real_now);
|
||||
status = 1;
|
||||
if (likely(stat.mtime.tv_sec <
|
||||
real_now.tv_sec + max_lamport_future))
|
||||
|
@ -2978,7 +2978,7 @@ restart:
|
|||
if (brick->power.button != brick->power.led_on ||
|
||||
brick->power.button == brick->power.led_off) {
|
||||
if (!brick->kill_stamp.tv_sec) {
|
||||
brick->kill_stamp = get_real_lamport();
|
||||
get_real_lamport(&brick->kill_stamp);
|
||||
brick->kill_stamp.tv_sec += 10;
|
||||
}
|
||||
}
|
||||
|
@ -2990,10 +2990,10 @@ restart:
|
|||
* CHECK: how to avoid too frequent switching by other means?
|
||||
*/
|
||||
if (!brick->kill_stamp.tv_sec) {
|
||||
brick->kill_stamp = get_real_lamport();
|
||||
get_real_lamport(&brick->kill_stamp);
|
||||
brick->kill_stamp.tv_sec += 3;
|
||||
}
|
||||
now = get_real_lamport();
|
||||
get_real_lamport(&now);
|
||||
if (lamport_time_compare(&now, &brick->kill_stamp) <= 0 &&
|
||||
global &&
|
||||
global->global_power.button) {
|
||||
|
|
Loading…
Reference in New Issue