md: use seconds granularity for error logging
authorArnd Bergmann <arnd@arndb.de>
Fri, 17 Jun 2016 15:33:10 +0000 (17:33 +0200)
committerShaohua Li <shli@fb.com>
Tue, 19 Jul 2016 18:00:47 +0000 (11:00 -0700)
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>
drivers/md/md.c
drivers/md/md.h
drivers/md/raid10.c

index 2ed547f5c3b6dbc1a9f99af99e862cdd22cbea08..4b8a264e9777d2f5398bfb1b0b3f6207eab5fe08 100644 (file)
@@ -3173,8 +3173,7 @@ int md_rdev_init(struct md_rdev *rdev)
        rdev->data_offset = 0;
        rdev->new_data_offset = 0;
        rdev->sb_events = 0;
-       rdev->last_read_error.tv_sec  = 0;
-       rdev->last_read_error.tv_nsec = 0;
+       rdev->last_read_error = 0;
        rdev->sb_loaded = 0;
        rdev->bb_page = NULL;
        atomic_set(&rdev->nr_pending, 0);
index dc65ca65b26e03744b76ff10750fca6afa4689f7..fd56cfd8c368132d5a2d720a06c1f7cd0d4d4ba7 100644 (file)
@@ -99,7 +99,7 @@ struct md_rdev {
        atomic_t        read_errors;    /* number of consecutive read errors that
                                         * we have tried to ignore.
                                         */
-       struct timespec last_read_error;        /* monotonic time since our
+       time64_t        last_read_error;        /* monotonic time since our
                                                 * last read error
                                                 */
        atomic_t        corrected_errors; /* number of corrected read errors,
index 8ee5d96e6a2d88155e9a26e5b711ace69c4a82ba..f7f3c8a634195a7804e08fb887c0de51b763760c 100644 (file)
@@ -2174,21 +2174,20 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)
  */
 static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
 {
-       struct timespec cur_time_mon;
+       long cur_time_mon;
        unsigned long hours_since_last;
        unsigned int read_errors = atomic_read(&rdev->read_errors);
 
-       ktime_get_ts(&cur_time_mon);
+       cur_time_mon = ktime_get_seconds();
 
-       if (rdev->last_read_error.tv_sec == 0 &&
-           rdev->last_read_error.tv_nsec == 0) {
+       if (rdev->last_read_error == 0) {
                /* first time we've seen a read error */
                rdev->last_read_error = cur_time_mon;
                return;
        }
 
-       hours_since_last = (cur_time_mon.tv_sec -
-                           rdev->last_read_error.tv_sec) / 3600;
+       hours_since_last = (long)(cur_time_mon -
+                           rdev->last_read_error) / 3600;
 
        rdev->last_read_error = cur_time_mon;
 
This page took 0.029723 seconds and 5 git commands to generate.