/* Used by fix_read_error() to decay the per rdev read_errors. We halve the read error count for every hour that has elapsed since the last recorded read error.  */
static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
/* Used by fix_read_error() to decay the per rdev read_errors. We halve the read error count for every hour that has elapsed since the last recorded read error.  */
static void check_decay_read_errors(mddev_t *mddev, mdk_rdev_t *rdev)
{
	struct timespec cur_time_mon;
	unsigned long hours_since_last;
	unsigned int read_errors = atomic_read(&rdev->read_errors);
	ktime_get_ts(&cur_time_mon);
	if (rdev->last_read_error.tv_sec == 0 &&
	    rdev->last_read_error.tv_nsec == 0) {
		rdev->last_read_error = cur_time_mon;
		return;
	}
	hours_since_last = (cur_time_mon.tv_sec -
			    rdev->last_read_error.tv_sec) / 3600;
	rdev->last_read_error = cur_time_mon;
	if (hours_since_last >= 8 * sizeof(read_errors))
		atomic_set(&rdev->read_errors, 0);
	else
		atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
}