HST is going to need this information to perform path prediction. For
request-based mpath, we use the struct request io_start_time, while for
bio based, use the DM layer start_time.

Signed-off-by: Gabriel Krisman Bertazi <kris...@collabora.com>
---
 drivers/md/dm-mpath.c         |  9 ++++++---
 drivers/md/dm-path-selector.h |  2 +-
 drivers/md/dm-queue-length.c  |  2 +-
 drivers/md/dm-service-time.c  |  2 +-
 drivers/md/dm.c               | 10 ++++++++++
 include/linux/device-mapper.h |  2 ++
 6 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index f5e7f8e88767..08b57964719b 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -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);
@@ -1620,7 +1621,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;
@@ -1664,7 +1666,8 @@ static int multipath_end_io_bio(struct dm_target *ti, 
struct bio *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,
+                                        dm_start_time_ns_from_clone(clone));
        }
 
        return r;
diff --git a/drivers/md/dm-path-selector.h b/drivers/md/dm-path-selector.h
index b6eb5365b1a4..c47bc0e20275 100644
--- a/drivers/md/dm-path-selector.h
+++ b/drivers/md/dm-path-selector.h
@@ -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 */
diff --git a/drivers/md/dm-queue-length.c b/drivers/md/dm-queue-length.c
index 969c4f1a3633..5fd018d18418 100644
--- a/drivers/md/dm-queue-length.c
+++ b/drivers/md/dm-queue-length.c
@@ -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;
 
diff --git a/drivers/md/dm-service-time.c b/drivers/md/dm-service-time.c
index f006a9005593..9cfda665e9eb 100644
--- a/drivers/md/dm-service-time.c
+++ b/drivers/md/dm-service-time.c
@@ -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;
 
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index df13fdebe21f..c5deee1bea67 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -674,6 +674,16 @@ 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;
+
+       /* FIXME: convert io->start_time from jiffies to nanoseconds */
+       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;
diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h
index 475668c69dbc..e2d506dd805e 100644
--- a/include/linux/device-mapper.h
+++ b/include/linux/device-mapper.h
@@ -329,6 +329,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);
 
-- 
2.26.2


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to