lkml.org 
[lkml]   [2020]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2] md: Expose struct request to path selector
Date
From: Khazhismel Kumykov <khazhy@google.com>

This allows a path selector to access metadata such as request start and
end time. nr_bytes is retained for end_io, as blk_rq_bytes represents
the number of bytes *left* in a request, and is 0 after a request is
finished.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
Co-developed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
---
drivers/md/dm-mpath.c | 12 ++++++++++--
drivers/md/dm-path-selector.h | 6 ++++++
2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 2bc18c9c3abc..0cdd3a939d41 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -546,7 +546,12 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
clone->cmd_flags |= REQ_FAILFAST_TRANSPORT;
*__clone = clone;

- if (pgpath->pg->ps.type->start_io)
+ if (pgpath->pg->ps.type->start_io_rq)
+ pgpath->pg->ps.type->start_io_rq(&pgpath->pg->ps,
+ &pgpath->path,
+ clone ?: rq,
+ nr_bytes);
+ else if (pgpath->pg->ps.type->start_io)
pgpath->pg->ps.type->start_io(&pgpath->pg->ps,
&pgpath->path,
nr_bytes);
@@ -1614,7 +1619,10 @@ static int multipath_end_io(struct dm_target *ti, struct request *clone,
if (pgpath) {
struct path_selector *ps = &pgpath->pg->ps;

- if (ps->type->end_io)
+ if (ps->type->end_io_rq)
+ ps->type->end_io_rq(ps, &pgpath->path,
+ clone, mpio->nr_bytes);
+ else if (ps->type->end_io)
ps->type->end_io(ps, &pgpath->path, mpio->nr_bytes);
}

diff --git a/drivers/md/dm-path-selector.h b/drivers/md/dm-path-selector.h
index b6eb5365b1a4..98b6c9d4e21f 100644
--- a/drivers/md/dm-path-selector.h
+++ b/drivers/md/dm-path-selector.h
@@ -12,6 +12,7 @@
#ifndef DM_PATH_SELECTOR_H
#define DM_PATH_SELECTOR_H

+#include <linux/blkdev.h>
#include <linux/device-mapper.h>

#include "dm-mpath.h"
@@ -75,6 +76,11 @@ struct path_selector_type {
size_t nr_bytes);
int (*end_io) (struct path_selector *ps, struct dm_path *path,
size_t nr_bytes);
+
+ int (*start_io_rq)(struct path_selector *ps, struct dm_path *path,
+ const struct request *rq, size_t nr_bytes);
+ int (*end_io_rq)(struct path_selector *ps, struct dm_path *path,
+ const struct request *rq, size_t nr_bytes);
};

/* Register a path selector */
--
2.26.0
\
 
 \ /
  Last update: 2020-04-16 23:14    [W:0.056 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site