#define SCRUB_CHECKPOINT_INTERVAL 60
#define SCRUB_WINDOW_SIZE 1024
-#define HALF_SEC msecs_to_jiffies(MSEC_PER_SEC >> 1)
-
enum scrub_next_status {
/* exit current loop and process next group */
SCRUB_NEXT_BREAK = 1,
__u16 sf_param;
/* The time for the last OI scrub completed. */
- __u64 sf_time_last_complete;
+ time64_t sf_time_last_complete;
- /* The time for the latest OI scrub ran. */
- __u64 sf_time_latest_start;
+ /* The ttime for the latest OI scrub ran. */
+ time64_t sf_time_latest_start;
/* The time for the last OI scrub checkpoint. */
- __u64 sf_time_last_checkpoint;
+ time64_t sf_time_last_checkpoint;
/* The position for the latest OI scrub started from. */
__u64 sf_pos_latest_start;
/* How many IGIF objects. */
__u64 sf_items_igif;
- /* How long the OI scrub has run. */
- __u32 sf_run_time;
+ /* How long the OI scrub has run in seconds. Do NOT change
+ * to time64_t since this breaks backwards compatibility.
+ * It shouldn't take more than 136 years to complete :-)
+ */
+ time_t sf_run_time;
/* How many completed OI scrub ran on the device. */
__u32 sf_success_count;
const char *os_name;
- /* The time for last checkpoint, jiffies */
- cfs_time_t os_time_last_checkpoint;
+ /* The time for last checkpoint, seconds */
+ time64_t os_time_last_checkpoint;
- /* The time for next checkpoint, jiffies */
- cfs_time_t os_time_next_checkpoint;
+ /* The time for next checkpoint, seconds */
+ time64_t os_time_next_checkpoint;
/* How many objects have been checked since last checkpoint. */
__u64 os_new_checked;
CDEBUG(D_LFSCK, "%s: store scrub file: rc = %d\n",
scrub->os_name, rc);
- scrub->os_time_last_checkpoint = cfs_time_current();
+ scrub->os_time_last_checkpoint = ktime_get_seconds();
scrub->os_time_next_checkpoint = scrub->os_time_last_checkpoint +
- cfs_time_seconds(SCRUB_CHECKPOINT_INTERVAL);
+ SCRUB_CHECKPOINT_INTERVAL;
return rc;
}
EXPORT_SYMBOL(scrub_file_store);
int scrub_checkpoint(const struct lu_env *env, struct lustre_scrub *scrub)
{
struct scrub_file *sf = &scrub->os_file;
+ time64_t now = ktime_get_seconds();
int rc;
- if (likely(cfs_time_before(cfs_time_current(),
- scrub->os_time_next_checkpoint) ||
+ if (likely(now < scrub->os_time_next_checkpoint ||
scrub->os_new_checked == 0))
return 0;
sf->sf_items_checked += scrub->os_new_checked;
scrub->os_new_checked = 0;
sf->sf_pos_last_checkpoint = scrub->os_pos_current;
- sf->sf_time_last_checkpoint = cfs_time_current_sec();
- sf->sf_run_time += cfs_duration_sec(cfs_time_current() + HALF_SEC -
- scrub->os_time_last_checkpoint);
+ sf->sf_time_last_checkpoint = ktime_get_real_seconds();
+ sf->sf_run_time += now - scrub->os_time_last_checkpoint;
rc = scrub_file_store(env, scrub);
up_write(&scrub->os_rwsem);
}
}
-static void scrub_time_dump(struct seq_file *m, __u64 time, const char *prefix)
+static void scrub_time_dump(struct seq_file *m, time64_t time,
+ const char *prefix)
{
if (time != 0)
seq_printf(m, "%s: %llu seconds\n", prefix,
- cfs_time_current_sec() - time);
+ ktime_get_real_seconds() - time);
else
seq_printf(m, "%s: N/A\n", prefix);
}
void scrub_dump(struct seq_file *m, struct lustre_scrub *scrub)
{
struct scrub_file *sf = &scrub->os_file;
- __u64 checked;
- __u64 speed;
+ u64 checked;
+ s64 speed;
down_read(&scrub->os_rwsem);
seq_printf(m, "name: OI_scrub\n"
speed = checked;
if (thread_is_running(&scrub->os_thread)) {
- cfs_duration_t duration = cfs_time_current() -
- scrub->os_time_last_checkpoint;
- __u64 new_checked = msecs_to_jiffies(scrub->os_new_checked *
- MSEC_PER_SEC);
- __u32 rtime = sf->sf_run_time +
- cfs_duration_sec(duration + HALF_SEC);
-
+ s64 new_checked = scrub->os_new_checked;
+ time64_t duration;
+ time64_t rtime;
+
+ /* Since the time resolution is in seconds for new system
+ * or small devices it ismore likely that duration will be
+ * zero which will lead to inaccurate results.
+ */
+ duration = ktime_get_seconds() -
+ scrub->os_time_last_checkpoint;
if (duration != 0)
- do_div(new_checked, duration);
+ new_checked = div_s64(new_checked, duration);
+
+ rtime = sf->sf_run_time + duration;
if (rtime != 0)
- do_div(speed, rtime);
- seq_printf(m, "run_time: %u seconds\n"
- "average_speed: %llu objects/sec\n"
- "real-time_speed: %llu objects/sec\n"
+ speed = div_s64(speed, rtime);
+
+ seq_printf(m, "run_time: %lld seconds\n"
+ "average_speed: %lld objects/sec\n"
+ "real-time_speed: %lld objects/sec\n"
"current_position: %llu\n"
"scrub_in_prior: %s\n"
"scrub_full_speed: %s\n"
"partial_scan: %s\n",
- rtime, speed, new_checked, scrub->os_pos_current,
+ rtime, speed, new_checked,
+ scrub->os_pos_current,
scrub->os_in_prior ? "yes" : "no",
scrub->os_full_speed ? "yes" : "no",
scrub->os_partial_scan ? "yes" : "no");
} else {
if (sf->sf_run_time != 0)
- do_div(speed, sf->sf_run_time);
- seq_printf(m, "run_time: %u seconds\n"
- "average_speed: %llu objects/sec\n"
+ speed = div_s64(speed, sf->sf_run_time);
+ seq_printf(m, "run_time: %ld seconds\n"
+ "average_speed: %lld objects/sec\n"
"real-time_speed: N/A\n"
"current_position: N/A\n",
sf->sf_run_time, speed);
RETURN(0);
if (dev->od_auto_scrub_interval == AS_NEVER ||
- cfs_time_before(ktime_get_real_seconds(),
- scrub->os_file.sf_time_last_complete +
- dev->od_auto_scrub_interval))
+ ktime_get_real_seconds() <
+ scrub->os_file.sf_time_last_complete + dev->od_auto_scrub_interval)
RETURN(0);
again:
struct page **dr_pages;
struct lu_buf dr_bl_buf;
sector_t *dr_blocks;
- unsigned long dr_start_time;
- unsigned long dr_elapsed; /* how long io took */
+ ktime_t dr_start_time;
+ ktime_t dr_elapsed; /* how long io took */
struct osd_device *dr_dev;
unsigned int dr_init_at; /* the line iobuf was initialized */
};
iobuf->dr_error = 0;
iobuf->dr_dev = d;
iobuf->dr_frags = 0;
- iobuf->dr_elapsed = 0;
+ iobuf->dr_elapsed = ktime_set(0, 0);
/* must be counted before, so assert */
iobuf->dr_rw = rw;
iobuf->dr_init_at = line;
lprocfs_oh_tally(&d->od_brw_stats.
hist[BRW_R_DIO_FRAGS+rw],
iobuf->dr_frags);
- lprocfs_oh_tally_log2(&d->od_brw_stats.hist[BRW_R_IO_TIME+rw],
- iobuf->dr_elapsed);
+ lprocfs_oh_tally_log2(&d->od_brw_stats.hist[BRW_R_IO_TIME+rw],
+ ktime_to_ms(iobuf->dr_elapsed));
}
}
* call to OSD.
*/
if (atomic_read(&iobuf->dr_numreqs) == 1) {
- iobuf->dr_elapsed = jiffies - iobuf->dr_start_time;
+ ktime_t now = ktime_get();
+
+ iobuf->dr_elapsed = ktime_sub(now, iobuf->dr_start_time);
iobuf->dr_elapsed_valid = 1;
}
if (atomic_dec_and_test(&iobuf->dr_numreqs))
LASSERT(iobuf->dr_npages == npages);
- osd_brw_stats_update(osd, iobuf);
- iobuf->dr_start_time = cfs_time_current();
+ osd_brw_stats_update(osd, iobuf);
+ iobuf->dr_start_time = ktime_get();
blk_start_plug(&plug);
for (page_idx = 0, block_idx = 0;
} else {
sf->sf_status = SS_FAILED;
}
- sf->sf_run_time += cfs_duration_sec(cfs_time_current() + HALF_SEC -
- scrub->os_time_last_checkpoint);
+ sf->sf_run_time += ktime_get_seconds() -
+ scrub->os_time_last_checkpoint;
+
rc = scrub_file_store(env, scrub);
up_write(&scrub->os_rwsem);
__u64 os_lf_failed;
__u64 os_bad_oimap_count;
- __u64 os_bad_oimap_time;
+ time64_t os_bad_oimap_time;
};
#endif /* _OSD_SCRUB_H */
} else if (osd->od_auto_scrub_interval == AS_NEVER) {
RETURN(0);
} else {
- if (cfs_time_before(cfs_time_current_sec(),
- scrub->os_file.sf_time_last_complete +
- osd->od_auto_scrub_interval))
+ if (ktime_get_real_seconds() <
+ scrub->os_file.sf_time_last_complete +
+ osd->od_auto_scrub_interval)
RETURN(0);
}
static ssize_t osd_read(const struct lu_env *env, struct dt_object *dt,
struct lu_buf *buf, loff_t *pos)
{
- struct osd_object *obj = osd_dt_obj(dt);
+ struct osd_object *obj = osd_dt_obj(dt);
struct osd_device *osd = osd_obj2dev(obj);
- uint64_t old_size;
- int size = buf->lb_len;
- int rc;
- unsigned long start;
+ int size = buf->lb_len;
+ uint64_t old_size;
+ ktime_t start;
+ s64 delta_ms;
+ int rc;
LASSERT(dt_object_exists(dt));
LASSERT(obj->oo_dn);
- start = cfs_time_current();
-
read_lock(&obj->oo_attr_lock);
old_size = obj->oo_attr.la_size;
read_unlock(&obj->oo_attr_lock);
size = old_size - *pos;
}
+ start = ktime_get();
record_start_io(osd, READ, 0);
rc = osd_dmu_read(osd, obj->oo_dn, *pos, size, buf->lb_buf,
DMU_READ_PREFETCH);
- record_end_io(osd, READ, cfs_time_current() - start, size,
- size >> PAGE_SHIFT);
+ delta_ms = ktime_ms_delta(ktime_get(), start);
+ record_end_io(osd, READ, delta_ms, size, size >> PAGE_SHIFT);
if (rc == 0) {
rc = size;
*pos += size;
loff_t off, ssize_t len, struct niobuf_local *lnb)
{
struct osd_device *osd = osd_obj2dev(obj);
- unsigned long start = cfs_time_current();
- int rc, i, numbufs, npages = 0;
- dmu_buf_t **dbp;
- ENTRY;
+ int rc, i, numbufs, npages = 0;
+ ktime_t start = ktime_get();
+ dmu_buf_t **dbp;
+ s64 delta_ms;
+ ENTRY;
record_start_io(osd, READ, 0);
/* grab buffers for read:
dmu_buf_rele_array(dbp, numbufs, osd_0copy_tag);
}
- record_end_io(osd, READ, cfs_time_current() - start,
- npages * PAGE_SIZE, npages);
+ delta_ms = ktime_ms_delta(ktime_get(), start);
+ record_end_io(osd, READ, delta_ms, npages * PAGE_SIZE, npages);
RETURN(npages);
scrub->os_pos_current = sf->sf_pos_latest_start;
sf->sf_status = SS_SCANNING;
- sf->sf_time_latest_start = cfs_time_current_sec();
+ sf->sf_time_latest_start = ktime_get_real_seconds();
sf->sf_time_last_checkpoint = sf->sf_time_latest_start;
sf->sf_pos_last_checkpoint = sf->sf_pos_latest_start - 1;
rc = scrub_file_store(env, scrub);
scrub->os_new_checked = 0;
sf->sf_pos_last_checkpoint = scrub->os_pos_current;
}
- sf->sf_time_last_checkpoint = cfs_time_current_sec();
+ sf->sf_time_last_checkpoint = ktime_get_real_seconds();
if (result > 0) {
sf->sf_status = SS_COMPLETED;
if (!(sf->sf_param & SP_DRYRUN)) {
} else {
sf->sf_status = SS_FAILED;
}
- sf->sf_run_time += cfs_duration_sec(cfs_time_current() + HALF_SEC -
- scrub->os_time_last_checkpoint);
+ sf->sf_run_time += ktime_get_seconds() -
+ scrub->os_time_last_checkpoint;
+
rc = scrub_file_store(env, scrub);
up_write(&scrub->os_rwsem);