dm mpath: pass IO start time to path selector
authorGabriel Krisman Bertazi <krisman@collabora.com>
Thu, 30 Apr 2020 20:48:29 +0000 (16:48 -0400)
committerMike Snitzer <snitzer@redhat.com>
Fri, 15 May 2020 14:29:36 +0000 (10:29 -0400)
The HST path selector needs this information to perform path
prediction. For request-based mpath, struct request's io_start_time_ns
is used, while for bio-based, use the start_time stored in dm_io.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-mpath.c
drivers/md/dm-path-selector.h
drivers/md/dm-queue-length.c
drivers/md/dm-service-time.c
drivers/md/dm.c
include/linux/device-mapper.h

index e0c800cf87a9bb69f9671d27494094fc8ddf2f99..74246d7c7d68ef4670f64013f194dbba35739c95 100644 (file)
@@ -567,7 +567,8 @@ static void multipath_release_clone(struct request *clone,
                if (pgpath && pgpath->pg->ps.type->end_io)
                        pgpath->pg->ps.type->end_io(&pgpath->pg->ps,
                                                    &pgpath->path,
-                                                   mpio->nr_bytes);
+                                                   mpio->nr_bytes,
+                                                   clone->io_start_time_ns);
        }
 
        blk_put_request(clone);
@@ -1617,7 +1618,8 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
                struct path_selector *ps = &pgpath->pg->ps;
 
                if (ps->type->end_io)
-                       ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
+                       ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes,
+                                        clone->io_start_time_ns);
        }
 
        return r;
@@ -1661,7 +1663,8 @@ done:
                struct path_selector *ps = &pgpath->pg->ps;
 
                if (ps->type->end_io)
-                       ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
+                       ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes,
+                                        dm_start_time_ns_from_clone(clone));
        }
 
        return r;
index b6eb5365b1a46bdfda5b6e45e8b820041f4666d4..c47bc0e20275beef92307f188a1dcacee03ab139 100644 (file)
@@ -74,7 +74,7 @@ struct path_selector_type {
        int (*start_io) (struct path_selector *ps, struct dm_path *path,
                         size_t nr_bytes);
        int (*end_io) (struct path_selector *ps, struct dm_path *path,
-                      size_t nr_bytes);
+                      size_t nr_bytes, u64 start_time);
 };
 
 /* Register a path selector */
index 969c4f1a3633636c1f5f49ad93057a2bf59a19d0..5fd018d184187ae0e0c07d7fa75e7f134b5bc8fb 100644 (file)
@@ -227,7 +227,7 @@ static int ql_start_io(struct path_selector *ps, struct dm_path *path,
 }
 
 static int ql_end_io(struct path_selector *ps, struct dm_path *path,
-                    size_t nr_bytes)
+                    size_t nr_bytes, u64 start_time)
 {
        struct path_info *pi = path->pscontext;
 
index f006a9005593baf301ea9bbf2e1dbeae062aecce..9cfda665e9ebd3db0431f55b5cdf221749eda0da 100644 (file)
@@ -309,7 +309,7 @@ static int st_start_io(struct path_selector *ps, struct dm_path *path,
 }
 
 static int st_end_io(struct path_selector *ps, struct dm_path *path,
-                    size_t nr_bytes)
+                    size_t nr_bytes, u64 start_time)
 {
        struct path_info *pi = path->pscontext;
 
index db9e46114653119abb57eb61fb72b0622c816329..2fcb932eb4bde969993e7ab63108c1a8fd8fad7a 100644 (file)
@@ -675,6 +675,15 @@ static bool md_in_flight(struct mapped_device *md)
                return md_in_flight_bios(md);
 }
 
+u64 dm_start_time_ns_from_clone(struct bio *bio)
+{
+       struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
+       struct dm_io *io = tio->io;
+
+       return jiffies_to_nsecs(io->start_time);
+}
+EXPORT_SYMBOL_GPL(dm_start_time_ns_from_clone);
+
 static void start_io_acct(struct dm_io *io)
 {
        struct mapped_device *md = io->md;
index af48d9da3916046921025dd89c858a996d8901b7..934037d938b9afb51709cac92e1a903d9959f0f2 100644 (file)
@@ -332,6 +332,8 @@ void *dm_per_bio_data(struct bio *bio, size_t data_size);
 struct bio *dm_bio_from_per_bio_data(void *data, size_t data_size);
 unsigned dm_bio_get_target_bio_nr(const struct bio *bio);
 
+u64 dm_start_time_ns_from_clone(struct bio *bio);
+
 int dm_register_target(struct target_type *t);
 void dm_unregister_target(struct target_type *t);