From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Benjamin Marzinski <bmarzins@redhat.com>
Date: Thu, 14 Jan 2021 20:20:26 -0600
Subject: [PATCH] multipathd: combine free_io_err_stat_path and
destroy_directio_ctx
destroy_directio_ctx() is only called from free_io_err_stat_path(), and
free_io_err_stat_path() is very short, so combine them.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
libmultipath/io_err_stat.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/libmultipath/io_err_stat.c b/libmultipath/io_err_stat.c
index 3389d693..bf1d3910 100644
--- a/libmultipath/io_err_stat.c
+++ b/libmultipath/io_err_stat.c
@@ -163,12 +163,15 @@ fail_close:
return 1;
}
-static void destroy_directio_ctx(struct io_err_stat_path *p)
+static void free_io_err_stat_path(struct io_err_stat_path *p)
{
int i;
- if (!p || !p->dio_ctx_array)
+ if (!p)
return;
+ if (!p->dio_ctx_array)
+ goto free_path;
+
cancel_inflight_io(p);
for (i = 0; i < CONCUR_NR_EVENT; i++)
@@ -177,6 +180,8 @@ static void destroy_directio_ctx(struct io_err_stat_path *p)
if (p->fd > 0)
close(p->fd);
+free_path:
+ FREE(p);
}
static struct io_err_stat_path *alloc_io_err_stat_path(void)
@@ -199,11 +204,6 @@ static struct io_err_stat_path *alloc_io_err_stat_path(void)
return p;
}
-static void free_io_err_stat_path(struct io_err_stat_path *p)
-{
- FREE(p);
-}
-
static void free_io_err_pathvec(void)
{
struct io_err_stat_path *path;
@@ -213,10 +213,8 @@ static void free_io_err_pathvec(void)
pthread_cleanup_push(cleanup_mutex, &io_err_pathvec_lock);
if (!io_err_pathvec)
goto out;
- vector_foreach_slot(io_err_pathvec, path, i) {
- destroy_directio_ctx(path);
+ vector_foreach_slot(io_err_pathvec, path, i)
free_io_err_stat_path(path);
- }
vector_free(io_err_pathvec);
io_err_pathvec = NULL;
out:
@@ -252,7 +250,7 @@ static int enqueue_io_err_stat_by_path(struct path *path)
goto free_ioerr_path;
pthread_mutex_lock(&io_err_pathvec_lock);
if (!vector_alloc_slot(io_err_pathvec))
- goto unlock_destroy;
+ goto unlock_pathvec;
vector_set_slot(io_err_pathvec, p);
pthread_mutex_unlock(&io_err_pathvec_lock);
@@ -260,9 +258,8 @@ static int enqueue_io_err_stat_by_path(struct path *path)
path->mpp->alias, path->dev);
return 0;
-unlock_destroy:
+unlock_pathvec:
pthread_mutex_unlock(&io_err_pathvec_lock);
- destroy_directio_ctx(p);
free_ioerr_path:
free_io_err_stat_path(p);
@@ -647,7 +644,6 @@ static void service_paths(void)
vector_foreach_slot_backwards(tmp_pathvec, pp, i) {
end_io_err_stat(pp);
vector_del_slot(tmp_pathvec, i);
- destroy_directio_ctx(pp);
free_io_err_stat_path(pp);
}
vector_reset(tmp_pathvec);
--
2.17.2