diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-06-17 11:33:10 -0400 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2016-07-19 14:00:47 -0400 |
commit | 0e3ef49eda5bae3aa75aa8c0276411bf0f27e03a (patch) | |
tree | 7c4a99c0ef5930b3380aa01bf754066d11b0ab2a /drivers/md | |
parent | d787be4092e27728cb4c012bee9762098ef3c662 (diff) |
md: use seconds granularity for error logging
The md code stores the exact time of the last error in the
last_read_error variable using a timespec structure. It only
ever uses the seconds portion of that though, so we can
use a scalar for it.
There won't be an overflow in 2038 here, because it already
used monotonic time and 32-bit is enough for that, but I've
decided to use time64_t for consistency in the conversion.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/md.c | 3 | ||||
-rw-r--r-- | drivers/md/md.h | 2 | ||||
-rw-r--r-- | drivers/md/raid10.c | 11 |
3 files changed, 7 insertions, 9 deletions
diff --git a/drivers/md/md.c b/drivers/md/md.c index 2ed547f5c3b6..4b8a264e9777 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -3173,8 +3173,7 @@ int md_rdev_init(struct md_rdev *rdev) | |||
3173 | rdev->data_offset = 0; | 3173 | rdev->data_offset = 0; |
3174 | rdev->new_data_offset = 0; | 3174 | rdev->new_data_offset = 0; |
3175 | rdev->sb_events = 0; | 3175 | rdev->sb_events = 0; |
3176 | rdev->last_read_error.tv_sec = 0; | 3176 | rdev->last_read_error = 0; |
3177 | rdev->last_read_error.tv_nsec = 0; | ||
3178 | rdev->sb_loaded = 0; | 3177 | rdev->sb_loaded = 0; |
3179 | rdev->bb_page = NULL; | 3178 | rdev->bb_page = NULL; |
3180 | atomic_set(&rdev->nr_pending, 0); | 3179 | atomic_set(&rdev->nr_pending, 0); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index dc65ca65b26e..fd56cfd8c368 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -99,7 +99,7 @@ struct md_rdev { | |||
99 | atomic_t read_errors; /* number of consecutive read errors that | 99 | atomic_t read_errors; /* number of consecutive read errors that |
100 | * we have tried to ignore. | 100 | * we have tried to ignore. |
101 | */ | 101 | */ |
102 | struct timespec last_read_error; /* monotonic time since our | 102 | time64_t last_read_error; /* monotonic time since our |
103 | * last read error | 103 | * last read error |
104 | */ | 104 | */ |
105 | atomic_t corrected_errors; /* number of corrected read errors, | 105 | atomic_t corrected_errors; /* number of corrected read errors, |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 8ee5d96e6a2d..f7f3c8a63419 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -2174,21 +2174,20 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) | |||
2174 | */ | 2174 | */ |
2175 | static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev) | 2175 | static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev) |
2176 | { | 2176 | { |
2177 | struct timespec cur_time_mon; | 2177 | long cur_time_mon; |
2178 | unsigned long hours_since_last; | 2178 | unsigned long hours_since_last; |
2179 | unsigned int read_errors = atomic_read(&rdev->read_errors); | 2179 | unsigned int read_errors = atomic_read(&rdev->read_errors); |
2180 | 2180 | ||
2181 | ktime_get_ts(&cur_time_mon); | 2181 | cur_time_mon = ktime_get_seconds(); |
2182 | 2182 | ||
2183 | if (rdev->last_read_error.tv_sec == 0 && | 2183 | if (rdev->last_read_error == 0) { |
2184 | rdev->last_read_error.tv_nsec == 0) { | ||
2185 | /* first time we've seen a read error */ | 2184 | /* first time we've seen a read error */ |
2186 | rdev->last_read_error = cur_time_mon; | 2185 | rdev->last_read_error = cur_time_mon; |
2187 | return; | 2186 | return; |
2188 | } | 2187 | } |
2189 | 2188 | ||
2190 | hours_since_last = (cur_time_mon.tv_sec - | 2189 | hours_since_last = (long)(cur_time_mon - |
2191 | rdev->last_read_error.tv_sec) / 3600; | 2190 | rdev->last_read_error) / 3600; |
2192 | 2191 | ||
2193 | rdev->last_read_error = cur_time_mon; | 2192 | rdev->last_read_error = cur_time_mon; |
2194 | 2193 | ||