int rc = 0;
int rc1 = 0;
- if (likely(cfs_time_beforeq(cfs_time_current(),
- lfsck->li_time_next_checkpoint)))
+ if (likely(ktime_get_seconds() <= lfsck->li_time_next_checkpoint))
return 0;
lfsck_pos_fill(env, lfsck, &lfsck->li_pos_checkpoint, false);
rc1 = rc;
}
- lfsck->li_time_last_checkpoint = cfs_time_current();
+ lfsck->li_time_last_checkpoint = ktime_get_seconds();
lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
return rc1 != 0 ? rc1 : rc;
}
break;
}
- lfsck->li_time_last_checkpoint = cfs_time_current();
+ lfsck->li_time_last_checkpoint = ktime_get_seconds();
lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
return rc;
}
(__u32)com->lc_type, rc);
}
- lfsck->li_time_last_checkpoint = cfs_time_current();
+ lfsck->li_time_last_checkpoint = ktime_get_seconds();
lfsck->li_time_next_checkpoint = lfsck->li_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
/* Ignore some component post failure to make other can go ahead. */
return result;
com->lc_new_checked = 0;
com->lc_new_scanned = 0;
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint =
com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
CDEBUG(D_LFSCK, "%s: LFSCK assistant sync before "
"the second-stage scaning\n",
#include <md_object.h>
#include <lustre_linkea.h>
-#define HALF_SEC msecs_to_jiffies(MSEC_PER_SEC >> 1)
#define LFSCK_CHECKPOINT_INTERVAL 60
enum lfsck_flags {
__u32 ln_success_count;
/* How long the LFSCK phase1 has run in seconds. */
- __u32 ln_run_time_phase1;
+ time64_t ln_run_time_phase1;
/* How long the LFSCK phase2 has run in seconds. */
- __u32 ln_run_time_phase2;
+ time64_t ln_run_time_phase2;
/* Time for the last LFSCK completed in seconds since epoch. */
- __u64 ln_time_last_complete;
+ time64_t ln_time_last_complete;
/* Time for the latest LFSCK ran in seconds since epoch. */
- __u64 ln_time_latest_start;
+ time64_t ln_time_latest_start;
/* Time for the last LFSCK checkpoint in seconds since epoch. */
- __u64 ln_time_last_checkpoint;
+ time64_t ln_time_last_checkpoint;
/* Position for the latest LFSCK started from. */
struct lfsck_position ln_pos_latest_start;
* the MDTs that contain non-verified MDT-objects. */
__u32 ln_bitmap_size;
+ /* For further using. 256-bytes aligned now. */
+ __u32 ln_reserved_1;
+
/* Time for the latest LFSCK scan in seconds from the beginning. */
- __u32 ln_time_latest_reset;
+ time64_t ln_time_latest_reset;
/* How many linkEA overflow timestamp have been cleared. */
__u64 ln_linkea_overflow_cleared;
/* For further using. 256-bytes aligned now. */
- __u64 ln_reserved[14];
+ __u64 ln_reserved[12];
};
enum lfsck_layout_inconsistency_type {
__u32 ll_success_count;
/* How long the LFSCK phase1 has run in seconds. */
- __u32 ll_run_time_phase1;
+ time64_t ll_run_time_phase1;
/* How long the LFSCK phase2 has run in seconds. */
- __u32 ll_run_time_phase2;
+ time64_t ll_run_time_phase2;
/* Time for the last LFSCK completed in seconds since epoch. */
- __u64 ll_time_last_complete;
+ time64_t ll_time_last_complete;
/* Time for the latest LFSCK ran in seconds since epoch. */
- __u64 ll_time_latest_start;
+ time64_t ll_time_latest_start;
/* Time for the last LFSCK checkpoint in seconds since epoch. */
- __u64 ll_time_last_checkpoint;
+ time64_t ll_time_last_checkpoint;
/* Position for the latest LFSCK started from. */
__u64 ll_pos_latest_start;
/* The latest object has been processed (failed) during double scan. */
struct lfsck_layout_dangling_key ll_lldk_latest_scanned_phase2;
- __u64 ll_reserved_2[8];
+ /* For further using */
+ u64 ll_reserved_2[7];
/* The OST targets bitmap to record the OSTs that contain
* non-verified OST-objects. */
void *lc_data;
struct lu_fid lc_fid_latest_scanned_phase2;
- /* The time for last checkpoint, jiffies */
- cfs_time_t lc_time_last_checkpoint;
+ /* The time for last checkpoint, seconds */
+ time64_t lc_time_last_checkpoint;
- /* The time for next checkpoint, jiffies */
- cfs_time_t lc_time_next_checkpoint;
+ /* The time for next checkpoint, seconds */
+ time64_t lc_time_next_checkpoint;
__u32 lc_file_size;
atomic_t li_double_scan_count;
struct ptlrpc_thread li_thread;
- /* The time for last checkpoint, jiffies */
- cfs_time_t li_time_last_checkpoint;
+ /* The time for last checkpoint, seconds */
+ time64_t li_time_last_checkpoint;
- /* The time for next checkpoint, jiffies */
- cfs_time_t li_time_next_checkpoint;
+ /* The time for next checkpoint, seconds */
+ time64_t li_time_next_checkpoint;
lfsck_out_notify li_out_notify;
void *li_out_notify_data;
struct lfsck_instance *lfsck);
void lfsck_bits_dump(struct seq_file *m, int bits, const char *names[],
const char *prefix);
-void lfsck_time_dump(struct seq_file *m, __u64 time, const char *name);
+void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name);
void lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos,
const char *prefix);
void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck,
#define LFSCK_LAYOUT_MAGIC_V1 0xB173AE14
#define LFSCK_LAYOUT_MAGIC_V2 0xB1734D76
#define LFSCK_LAYOUT_MAGIC_V3 0xB17371B9
+#define LFSCK_LAYOUT_MAGIC_V4 0xB1732FED
-#define LFSCK_LAYOUT_MAGIC LFSCK_LAYOUT_MAGIC_V3
+#define LFSCK_LAYOUT_MAGIC LFSCK_LAYOUT_MAGIC_V4
struct lfsck_layout_seq {
struct list_head lls_list;
des->ll_status = le32_to_cpu(src->ll_status);
des->ll_flags = le32_to_cpu(src->ll_flags);
des->ll_success_count = le32_to_cpu(src->ll_success_count);
- des->ll_run_time_phase1 = le32_to_cpu(src->ll_run_time_phase1);
- des->ll_run_time_phase2 = le32_to_cpu(src->ll_run_time_phase2);
+ des->ll_run_time_phase1 = le64_to_cpu(src->ll_run_time_phase1);
+ des->ll_run_time_phase2 = le64_to_cpu(src->ll_run_time_phase2);
des->ll_time_last_complete = le64_to_cpu(src->ll_time_last_complete);
des->ll_time_latest_start = le64_to_cpu(src->ll_time_latest_start);
des->ll_time_last_checkpoint =
des->ll_status = cpu_to_le32(src->ll_status);
des->ll_flags = cpu_to_le32(src->ll_flags);
des->ll_success_count = cpu_to_le32(src->ll_success_count);
- des->ll_run_time_phase1 = cpu_to_le32(src->ll_run_time_phase1);
- des->ll_run_time_phase2 = cpu_to_le32(src->ll_run_time_phase2);
+ des->ll_run_time_phase1 = cpu_to_le64(src->ll_run_time_phase1);
+ des->ll_run_time_phase2 = cpu_to_le64(src->ll_run_time_phase2);
des->ll_time_last_complete = cpu_to_le64(src->ll_time_last_complete);
des->ll_time_latest_start = cpu_to_le64(src->ll_time_latest_start);
des->ll_time_last_checkpoint =
struct lfsck_layout *lo = com->lc_file_ram;
down_write(&com->lc_sem);
- lo->ll_run_time_phase2 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - com->lc_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase2 += ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase2 += com->lc_new_checked;
if (rc > 0) {
if (rc < 0 && bk->lb_param & LPF_FAILOUT)
GOTO(put, rc);
- if (unlikely(cfs_time_beforeq(com->lc_time_next_checkpoint,
- cfs_time_current())) &&
+ if (unlikely(com->lc_time_next_checkpoint <=
+ ktime_get_seconds()) &&
com->lc_new_checked != 0) {
down_write(&com->lc_sem);
- lo->ll_run_time_phase2 +=
- cfs_duration_sec(cfs_time_current() +
- HALF_SEC - com->lc_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase2 += ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase2 += com->lc_new_checked;
com->lc_new_checked = 0;
lfsck_layout_store(env, com);
up_write(&com->lc_sem);
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint =
com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
}
lfsck_control_speed_by_self(com);
com->lc_new_checked = 0;
com->lc_new_scanned = 0;
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
i = lfsck_sub_trace_file_fid2idx(
&lo->ll_lldk_latest_scanned_phase2.lldk_fid);
memset(lo, 0, com->lc_file_size);
} else {
__u32 count = lo->ll_success_count;
- __u64 last_time = lo->ll_time_last_complete;
+ time64_t last_time = lo->ll_time_last_complete;
memset(lo, 0, com->lc_file_size);
lo->ll_success_count = count;
} else {
lo->ll_pos_last_checkpoint =
lfsck->li_pos_checkpoint.lp_oit_cookie;
- lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase1 += com->lc_new_checked;
com->lc_new_checked = 0;
}
} else {
lo->ll_pos_last_checkpoint =
lfsck->li_pos_checkpoint.lp_oit_cookie;
- lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase1 += com->lc_new_checked;
com->lc_new_checked = 0;
}
}
down_write(&com->lc_sem);
- lo->ll_time_latest_start = cfs_time_current_sec();
+ lo->ll_time_latest_start = ktime_get_real_seconds();
spin_lock(&lfsck->li_lock);
if (lo->ll_flags & LF_SCANNED_ONCE) {
if (!lfsck->li_drop_dryrun ||
spin_unlock(&lfsck->li_lock);
if (!init) {
- lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase1 += com->lc_new_checked;
com->lc_new_checked = 0;
}
LE_LASTID_REBUILT);
if (!init) {
- lo->ll_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- lo->ll_time_last_checkpoint = cfs_time_current_sec();
+ lo->ll_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ lo->ll_time_last_checkpoint = ktime_get_real_seconds();
lo->ll_objs_checked_phase1 += com->lc_new_checked;
com->lc_new_checked = 0;
}
lo->ll_objs_failed_phase2);
if (lo->ll_status == LS_SCANNING_PHASE1) {
- __u64 pos;
- cfs_duration_t duration = cfs_time_current() -
- lfsck->li_time_last_checkpoint;
- __u64 checked = lo->ll_objs_checked_phase1 +
- com->lc_new_checked;
- __u64 speed = checked;
- __u64 new_checked = com->lc_new_checked *
- msecs_to_jiffies(MSEC_PER_SEC);
- __u32 rtime = lo->ll_run_time_phase1 +
- cfs_duration_sec(duration + HALF_SEC);
+ time64_t duration = ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ u64 checked = lo->ll_objs_checked_phase1 +
+ com->lc_new_checked;
+ u64 speed = checked;
+ u64 new_checked = com->lc_new_checked;
+ time64_t rtime = lo->ll_run_time_phase1 + duration;
+ u64 pos;
if (duration != 0)
- do_div(new_checked, duration);
+ div_u64(new_checked, duration);
if (rtime != 0)
- do_div(speed, rtime);
+ div_u64(speed, rtime);
seq_printf(m, "checked_phase1: %llu\n"
"checked_phase2: %llu\n"
- "run_time_phase1: %u seconds\n"
- "run_time_phase2: %u seconds\n"
+ "run_time_phase1: %lld seconds\n"
+ "run_time_phase2: %lld seconds\n"
"average_speed_phase1: %llu items/sec\n"
"average_speed_phase2: N/A\n"
"real-time_speed_phase1: %llu items/sec\n"
seq_printf(m, "current_position: %llu\n", pos);
} else if (lo->ll_status == LS_SCANNING_PHASE2) {
- cfs_duration_t duration = cfs_time_current() -
- com->lc_time_last_checkpoint;
- __u64 checked = lo->ll_objs_checked_phase2 +
- com->lc_new_checked;
- __u64 speed1 = lo->ll_objs_checked_phase1;
- __u64 speed2 = checked;
- __u64 new_checked = com->lc_new_checked *
- msecs_to_jiffies(MSEC_PER_SEC);
- __u32 rtime = lo->ll_run_time_phase2 +
- cfs_duration_sec(duration + HALF_SEC);
+ time64_t duration = ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
+ u64 checked = lo->ll_objs_checked_phase2 +
+ com->lc_new_checked;
+ u64 speed1 = lo->ll_objs_checked_phase1;
+ u64 speed2 = checked;
+ u64 new_checked = com->lc_new_checked;
+ time64_t rtime = lo->ll_run_time_phase2 + duration;
if (duration != 0)
- do_div(new_checked, duration);
+ div_u64(new_checked, duration);
if (lo->ll_run_time_phase1 != 0)
- do_div(speed1, lo->ll_run_time_phase1);
+ div_u64(speed1, lo->ll_run_time_phase1);
if (rtime != 0)
- do_div(speed2, rtime);
+ div_u64(speed2, rtime);
seq_printf(m, "checked_phase1: %llu\n"
"checked_phase2: %llu\n"
- "run_time_phase1: %u seconds\n"
- "run_time_phase2: %u seconds\n"
+ "run_time_phase1: %lld seconds\n"
+ "run_time_phase2: %lld seconds\n"
"average_speed_phase1: %llu items/sec\n"
"average_speed_phase2: %llu items/sec\n"
"real-time_speed_phase1: N/A\n"
__u64 speed2 = lo->ll_objs_checked_phase2;
if (lo->ll_run_time_phase1 != 0)
- do_div(speed1, lo->ll_run_time_phase1);
+ div_u64(speed1, lo->ll_run_time_phase1);
if (lo->ll_run_time_phase2 != 0)
- do_div(speed2, lo->ll_run_time_phase2);
+ div_u64(speed2, lo->ll_run_time_phase2);
seq_printf(m, "checked_phase1: %llu\n"
"checked_phase2: %llu\n"
- "run_time_phase1: %u seconds\n"
- "run_time_phase2: %u seconds\n"
+ "run_time_phase1: %lld seconds\n"
+ "run_time_phase2: %lld seconds\n"
"average_speed_phase1: %llu items/sec\n"
"average_speed_phase2: %llu objs/sec\n"
"real-time_speed_phase1: N/A\n"
com->lc_new_checked = 0;
com->lc_new_scanned = 0;
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
while (1) {
struct l_wait_info lwi = LWI_TIMEOUT(cfs_time_seconds(30),
}
memset(la, 0, sizeof(*la));
- la->la_atime = la->la_mtime = la->la_ctime = cfs_time_current_sec();
+ la->la_atime = la->la_mtime = la->la_ctime = ktime_get_real_seconds();
la->la_mode = S_IFDIR | S_IRWXU;
la->la_valid = LA_ATIME | LA_MTIME | LA_CTIME | LA_MODE |
LA_UID | LA_GID;
seq_putc(m, '\n');
}
-void lfsck_time_dump(struct seq_file *m, __u64 time, const char *name)
+void lfsck_time_dump(struct seq_file *m, time64_t time, const char *name)
{
if (time == 0) {
seq_printf(m, "%s_time: N/A\n", name);
seq_printf(m, "time_since_%s: N/A\n", name);
} else {
- seq_printf(m, "%s_time: %llu\n", name, time);
- seq_printf(m, "time_since_%s: %llu seconds\n",
- name, cfs_time_current_sec() - time);
+ seq_printf(m, "%s_time: %lld\n", name, time);
+ seq_printf(m, "time_since_%s: %lld seconds\n",
+ name, ktime_get_real_seconds() - time);
}
}
#define LFSCK_NAMESPACE_MAGIC_V1 0xA0629D03
#define LFSCK_NAMESPACE_MAGIC_V2 0xA0621A0B
+#define LFSCK_NAMESPACE_MAGIC_V3 0xA06249FF
/* For Lustre-2.x (x <= 6), the namespace LFSCK used LFSCK_NAMESPACE_MAGIC_V1
* as the trace file magic. When downgrade to such old release, the old LFSCK
* will not recognize the new LFSCK_NAMESPACE_MAGIC_V2 in the new trace file,
* then it will reset the whole LFSCK, and will not cause start failure. The
* similar case will happen when upgrade from such old release. */
-#define LFSCK_NAMESPACE_MAGIC LFSCK_NAMESPACE_MAGIC_V2
+#define LFSCK_NAMESPACE_MAGIC LFSCK_NAMESPACE_MAGIC_V3
enum lfsck_nameentry_check {
LFSCK_NAMEENTRY_DEAD = 1, /* The object has been unlinked. */
dst->ln_status = le32_to_cpu(src->ln_status);
dst->ln_flags = le32_to_cpu(src->ln_flags);
dst->ln_success_count = le32_to_cpu(src->ln_success_count);
- dst->ln_run_time_phase1 = le32_to_cpu(src->ln_run_time_phase1);
- dst->ln_run_time_phase2 = le32_to_cpu(src->ln_run_time_phase2);
+ dst->ln_run_time_phase1 = le64_to_cpu(src->ln_run_time_phase1);
+ dst->ln_run_time_phase2 = le64_to_cpu(src->ln_run_time_phase2);
dst->ln_time_last_complete = le64_to_cpu(src->ln_time_last_complete);
dst->ln_time_latest_start = le64_to_cpu(src->ln_time_latest_start);
dst->ln_time_last_checkpoint =
dst->ln_local_lpf_skipped = le64_to_cpu(src->ln_local_lpf_skipped);
dst->ln_local_lpf_failed = le64_to_cpu(src->ln_local_lpf_failed);
dst->ln_bitmap_size = le32_to_cpu(src->ln_bitmap_size);
- dst->ln_time_latest_reset = le32_to_cpu(src->ln_time_latest_reset);
+ dst->ln_time_latest_reset = le64_to_cpu(src->ln_time_latest_reset);
dst->ln_linkea_overflow_cleared =
le64_to_cpu(src->ln_linkea_overflow_cleared);
}
dst->ln_status = cpu_to_le32(src->ln_status);
dst->ln_flags = cpu_to_le32(src->ln_flags);
dst->ln_success_count = cpu_to_le32(src->ln_success_count);
- dst->ln_run_time_phase1 = cpu_to_le32(src->ln_run_time_phase1);
- dst->ln_run_time_phase2 = cpu_to_le32(src->ln_run_time_phase2);
+ dst->ln_run_time_phase1 = cpu_to_le64(src->ln_run_time_phase1);
+ dst->ln_run_time_phase2 = cpu_to_le64(src->ln_run_time_phase2);
dst->ln_time_last_complete = cpu_to_le64(src->ln_time_last_complete);
dst->ln_time_latest_start = cpu_to_le64(src->ln_time_latest_start);
dst->ln_time_last_checkpoint =
dst->ln_local_lpf_skipped = cpu_to_le64(src->ln_local_lpf_skipped);
dst->ln_local_lpf_failed = cpu_to_le64(src->ln_local_lpf_failed);
dst->ln_bitmap_size = cpu_to_le32(src->ln_bitmap_size);
- dst->ln_time_latest_reset = cpu_to_le32(src->ln_time_latest_reset);
+ dst->ln_time_latest_reset = cpu_to_le64(src->ln_time_latest_reset);
dst->ln_linkea_overflow_cleared =
cpu_to_le64(src->ln_linkea_overflow_cleared);
}
memset(ns, 0, sizeof(*ns));
ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
ns->ln_status = LS_INIT;
- ns->ln_time_latest_reset = cfs_time_current_sec();
+ ns->ln_time_latest_reset = ktime_get_real_seconds();
down_write(&com->lc_sem);
rc = lfsck_namespace_store(env, com);
if (rc == 0)
}
memset(la, 0, sizeof(*la));
- la->la_ctime = cfs_time_current_sec();
+ la->la_ctime = ktime_get_real_seconds();
la->la_valid = LA_CTIME;
rc = dt_declare_attr_set(env, orphan, la, th);
if (rc != 0)
}
memset(la, 0, sizeof(*la));
- la->la_ctime = cfs_time_current_sec();
+ la->la_ctime = ktime_get_real_seconds();
la->la_valid = LA_CTIME;
rc = dt_declare_attr_set(env, parent, la, th);
if (rc != 0)
GOTO(stop, rc);
}
- la->la_ctime = cfs_time_current_sec();
+ la->la_ctime = ktime_get_real_seconds();
rc = dt_attr_set(env, parent, la, th);
if (rc != 0)
GOTO(stop, rc);
return rc;
}
-#define lfsck_time_before(a, b) \
- (typecheck(__u32, a) && \
- typecheck(__u32, b) && \
- ((int)(a) - (int)(b) < 0))
-
static inline bool
lfsck_namespace_linkea_stale_overflow(struct linkea_data *ldata,
struct lfsck_namespace *ns)
* local time based, so need NOT to care about clock drift
* among the servers. */
return ldata->ld_leh->leh_overflow_time &&
- lfsck_time_before(ldata->ld_leh->leh_overflow_time,
- ns->ln_time_latest_reset);
+ ldata->ld_leh->leh_overflow_time < ns->ln_time_latest_reset;
}
/**
struct lfsck_namespace *ns,
__u64 checked_phase1,
__u64 checked_phase2,
- __u32 time_phase1,
- __u32 time_phase2, bool dryrun)
+ time64_t time_phase1,
+ time64_t time_phase2, bool dryrun)
{
const char *postfix = dryrun ? "inconsistent" : "repaired";
"name_hash_%s: %llu\n"
"linkea_overflow_%s: %llu\n"
"success_count: %u\n"
- "run_time_phase1: %u seconds\n"
- "run_time_phase2: %u seconds\n",
+ "run_time_phase1: %lld seconds\n"
+ "run_time_phase2: %lld seconds\n",
checked_phase1,
checked_phase2,
dryrun ? "inconsistent" : "updated",
memset(ns, 0, sizeof(*ns));
} else {
__u32 count = ns->ln_success_count;
- __u64 last_time = ns->ln_time_last_complete;
+ time64_t last_time = ns->ln_time_last_complete;
memset(ns, 0, sizeof(*ns));
ns->ln_success_count = count;
}
ns->ln_magic = LFSCK_NAMESPACE_MAGIC;
ns->ln_status = LS_INIT;
- ns->ln_time_latest_reset = cfs_time_current_sec();
+ ns->ln_time_latest_reset = ktime_get_real_seconds();
rc = lfsck_load_one_trace_file(env, com, root, &com->lc_obj,
&dt_lfsck_namespace_features,
ns->ln_pos_latest_start = lfsck->li_pos_checkpoint;
} else {
ns->ln_pos_last_checkpoint = lfsck->li_pos_checkpoint;
- ns->ln_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- ns->ln_time_last_checkpoint = cfs_time_current_sec();
+ ns->ln_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ ns->ln_time_last_checkpoint = ktime_get_real_seconds();
ns->ln_items_checked += com->lc_new_checked;
com->lc_new_checked = 0;
}
}
down_write(&com->lc_sem);
- ns->ln_time_latest_start = cfs_time_current_sec();
+ ns->ln_time_latest_start = ktime_get_real_seconds();
spin_lock(&lfsck->li_lock);
if (ns->ln_flags & LF_SCANNED_ONCE) {
spin_unlock(&lfsck->li_lock);
if (!init) {
- ns->ln_run_time_phase1 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - lfsck->li_time_last_checkpoint);
- ns->ln_time_last_checkpoint = cfs_time_current_sec();
+ ns->ln_run_time_phase1 += ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ ns->ln_time_last_checkpoint = ktime_get_real_seconds();
ns->ln_items_checked += com->lc_new_checked;
com->lc_new_checked = 0;
}
if (ns->ln_status == LS_SCANNING_PHASE1) {
struct lfsck_position pos;
- cfs_duration_t duration = cfs_time_current() -
- lfsck->li_time_last_checkpoint;
- __u64 checked = ns->ln_items_checked + com->lc_new_checked;
- __u64 speed = checked;
- __u64 new_checked = com->lc_new_checked *
- msecs_to_jiffies(MSEC_PER_SEC);
- __u32 rtime = ns->ln_run_time_phase1 +
- cfs_duration_sec(duration + HALF_SEC);
+ time64_t duration = ktime_get_seconds() -
+ lfsck->li_time_last_checkpoint;
+ u64 checked = ns->ln_items_checked + com->lc_new_checked;
+ u64 speed = checked;
+ u64 new_checked = com->lc_new_checked;
+ time64_t rtime = ns->ln_run_time_phase1 + duration;
if (duration != 0)
- do_div(new_checked, duration);
+ div_u64(new_checked, duration);
if (rtime != 0)
- do_div(speed, rtime);
+ div_u64(speed, rtime);
lfsck_namespace_dump_statistics(m, ns, checked, 0, rtime, 0,
bk->lb_param & LPF_DRYRUN);
lfsck_pos_dump(m, &pos, "current_position");
} else if (ns->ln_status == LS_SCANNING_PHASE2) {
- cfs_duration_t duration = cfs_time_current() -
- com->lc_time_last_checkpoint;
+ time64_t duration = ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
__u64 checked = ns->ln_objs_checked_phase2 +
com->lc_new_checked;
__u64 speed1 = ns->ln_items_checked;
__u64 speed2 = checked;
__u64 speed0 = speed1 + speed2;
- __u64 new_checked = com->lc_new_checked *
- msecs_to_jiffies(MSEC_PER_SEC);
- __u32 rtime = ns->ln_run_time_phase2 +
- cfs_duration_sec(duration + HALF_SEC);
- __u32 time0 = ns->ln_run_time_phase1 + rtime;
+ __u64 new_checked = com->lc_new_checked;
+ time64_t rtime = ns->ln_run_time_phase2 + duration;
+ time64_t time0 = ns->ln_run_time_phase1 + rtime;
if (duration != 0)
- do_div(new_checked, duration);
+ div_u64(new_checked, duration);
if (ns->ln_run_time_phase1 != 0)
- do_div(speed1, ns->ln_run_time_phase1);
+ div_u64(speed1, ns->ln_run_time_phase1);
else if (ns->ln_items_checked != 0)
time0++;
if (rtime != 0)
- do_div(speed2, rtime);
+ div_u64(speed2, rtime);
else if (checked != 0)
time0++;
if (time0 != 0)
- do_div(speed0, time0);
+ div_u64(speed0, time0);
lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
checked,
__u64 speed1 = ns->ln_items_checked;
__u64 speed2 = ns->ln_objs_checked_phase2;
__u64 speed0 = speed1 + speed2;
- __u32 time0 = ns->ln_run_time_phase1 + ns->ln_run_time_phase2;
+ time64_t time0 = ns->ln_run_time_phase1 + ns->ln_run_time_phase2;
if (ns->ln_run_time_phase1 != 0)
- do_div(speed1, ns->ln_run_time_phase1);
+ div_u64(speed1, ns->ln_run_time_phase1);
else if (ns->ln_items_checked != 0)
time0++;
if (ns->ln_run_time_phase2 != 0)
- do_div(speed2, ns->ln_run_time_phase2);
+ div_u64(speed2, ns->ln_run_time_phase2);
else if (ns->ln_objs_checked_phase2 != 0)
time0++;
if (time0 != 0)
- do_div(speed0, time0);
+ div_u64(speed0, time0);
lfsck_namespace_dump_statistics(m, ns, ns->ln_items_checked,
ns->ln_objs_checked_phase2,
if (rc < 0 && bk->lb_param & LPF_FAILOUT)
GOTO(put, rc);
- if (unlikely(cfs_time_beforeq(com->lc_time_next_checkpoint,
- cfs_time_current())) &&
+ if (unlikely(com->lc_time_next_checkpoint <=
+ ktime_get_seconds()) &&
com->lc_new_checked != 0) {
down_write(&com->lc_sem);
- ns->ln_run_time_phase2 +=
- cfs_duration_sec(cfs_time_current() +
- HALF_SEC - com->lc_time_last_checkpoint);
- ns->ln_time_last_checkpoint = cfs_time_current_sec();
+ ns->ln_run_time_phase2 += ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
+ ns->ln_time_last_checkpoint = ktime_get_real_seconds();
ns->ln_objs_checked_phase2 += com->lc_new_checked;
com->lc_new_checked = 0;
lfsck_namespace_store(env, com);
up_write(&com->lc_sem);
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint =
com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
}
lfsck_control_speed_by_self(com);
com->lc_new_checked = 0;
com->lc_new_scanned = 0;
- com->lc_time_last_checkpoint = cfs_time_current();
+ com->lc_time_last_checkpoint = ktime_get_seconds();
com->lc_time_next_checkpoint = com->lc_time_last_checkpoint +
- cfs_time_seconds(LFSCK_CHECKPOINT_INTERVAL);
+ LFSCK_CHECKPOINT_INTERVAL;
i = lfsck_sub_trace_file_fid2idx(&ns->ln_fid_latest_scanned_phase2);
rc = lfsck_namespace_double_scan_one_trace_file(env, com,
struct lfsck_namespace *ns = com->lc_file_ram;
down_write(&com->lc_sem);
- ns->ln_run_time_phase2 += cfs_duration_sec(cfs_time_current() +
- HALF_SEC - com->lc_time_last_checkpoint);
- ns->ln_time_last_checkpoint = cfs_time_current_sec();
+ ns->ln_run_time_phase2 += ktime_get_seconds() -
+ com->lc_time_last_checkpoint;
+ ns->ln_time_last_checkpoint = ktime_get_real_seconds();
ns->ln_objs_checked_phase2 += com->lc_new_checked;
com->lc_new_checked = 0;