* [PATCH 05/15] md-cluster: Improve another size determination in recv_daemon()
From: SF Markus Elfring @ 2016-10-01 14:50 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 12:28:19 +0200
Replace the specification of a data structure by a variable name
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index c81eed4..adf9555 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -617,7 +617,7 @@ static void recv_daemon(struct md_thread *thread)
}
/* read lvb and wake up thread to process this message_lockres */
- memcpy(&msg, message_lockres->lksb.sb_lvbptr, sizeof(struct cluster_msg));
+ memcpy(&msg, message_lockres->lksb.sb_lvbptr, sizeof(msg));
ret = process_recvd_msg(thread->mddev, &msg);
if (ret)
goto out;
--
2.10.0
^ permalink raw reply related
* [PATCH 06/15] md-cluster: Rename a jump label in recv_daemon()
From: SF Markus Elfring @ 2016-10-01 14:51 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 12:36:30 +0200
Adjust a jump label according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index adf9555..94835b5 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -620,7 +620,7 @@ static void recv_daemon(struct md_thread *thread)
memcpy(&msg, message_lockres->lksb.sb_lvbptr, sizeof(msg));
ret = process_recvd_msg(thread->mddev, &msg);
if (ret)
- goto out;
+ goto unlock;
/*release CR on ack_lockres*/
ret = dlm_unlock_sync(ack_lockres);
@@ -634,7 +634,7 @@ static void recv_daemon(struct md_thread *thread)
ret = dlm_lock_sync(ack_lockres, DLM_LOCK_CR);
if (unlikely(ret != 0))
pr_info("lock CR on ack failed return %d\n", ret);
-out:
+unlock:
/*release CR on message_lockres*/
ret = dlm_unlock_sync(message_lockres);
if (unlikely(ret != 0))
--
2.10.0
^ permalink raw reply related
* [PATCH 07/15] md-cluster: Improve another size determination in process_suspend_info()
From: SF Markus Elfring @ 2016-10-01 14:52 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 12:42:50 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 94835b5..e965e78 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -482,8 +482,7 @@ static void process_suspend_info(struct mddev *mddev,
lo, hi);
cinfo->sync_low = lo;
cinfo->sync_hi = hi;
-
- s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
+ s = kzalloc(sizeof(*s), GFP_KERNEL);
if (!s)
return;
s->slot = slot;
--
2.10.0
^ permalink raw reply related
* [PATCH 08/15] md-cluster: Improve determination of sizes in read_resync_info()
From: SF Markus Elfring @ 2016-10-01 14:53 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 12:52:58 +0200
Replace the specification of data structures by either a pointer
dereference or a variable name as the parameter for the operator "sizeof"
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index e965e78..0918108 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -275,10 +275,10 @@ static struct suspend_info *read_resync_info(struct mddev *mddev, struct dlm_loc
sector_t hi = 0;
dlm_lock_sync(lockres, DLM_LOCK_CR);
- memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
+ memcpy(&ri, lockres->lksb.sb_lvbptr, sizeof(ri));
hi = le64_to_cpu(ri.hi);
if (hi > 0) {
- s = kzalloc(sizeof(struct suspend_info), GFP_KERNEL);
+ s = kzalloc(sizeof(*s), GFP_KERNEL);
if (!s)
goto out;
s->hi = hi;
--
2.10.0
^ permalink raw reply related
* [PATCH 09/15] md-cluster: Improve another size determination in lockres_init()
From: SF Markus Elfring @ 2016-10-01 14:54 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 13:02:18 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 0918108..bec8035 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -190,7 +190,7 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
int ret, namelen;
struct md_cluster_info *cinfo = mddev->cluster_info;
- res = kzalloc(sizeof(struct dlm_lock_resource), GFP_KERNEL);
+ res = kzalloc(sizeof(*res), GFP_KERNEL);
if (!res)
return NULL;
init_waitqueue_head(&res->sync_locking);
--
2.10.0
^ permalink raw reply related
* [PATCH 10/15] md-cluster: Delete an unnecessary variable initialisation in lockres_init()
From: SF Markus Elfring @ 2016-10-01 14:55 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 13:07:52 +0200
The local variable "res" will be set to an appropriate pointer a bit later.
Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index bec8035..b91b552 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -186,7 +186,7 @@ static int dlm_lock_sync_interruptible(struct dlm_lock_resource *res, int mode,
static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
char *name, void (*bastfn)(void *arg, int mode), int with_lvb)
{
- struct dlm_lock_resource *res = NULL;
+ struct dlm_lock_resource *res;
int ret, namelen;
struct md_cluster_info *cinfo = mddev->cluster_info;
--
2.10.0
^ permalink raw reply related
* [PATCH 11/15] md-cluster: Delete four error messages for a failed memory allocation
From: SF Markus Elfring @ 2016-10-01 14:56 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 13:46:20 +0200
Omit extra messages for a memory allocation failure in three functions.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index b91b552..7f82c6b 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -200,17 +200,13 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
res->mode = DLM_LOCK_IV;
namelen = strlen(name);
res->name = kzalloc(namelen + 1, GFP_KERNEL);
- if (!res->name) {
- pr_err("md-cluster: Unable to allocate resource name for resource %s\n", name);
+ if (!res->name)
goto out_err;
- }
strlcpy(res->name, name, namelen + 1);
if (with_lvb) {
res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL);
- if (!res->lksb.sb_lvbptr) {
- pr_err("md-cluster: Unable to allocate LVB for resource %s\n", name);
+ if (!res->lksb.sb_lvbptr)
goto out_err;
- }
res->flags = DLM_LKF_VALBLK;
}
@@ -852,10 +848,8 @@ static int join(struct mddev *mddev, int nodes)
/* Initiate the communication resources */
ret = -ENOMEM;
cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv");
- if (!cinfo->recv_thread) {
- pr_err("md-cluster: cannot allocate memory for recv_thread!\n");
+ if (!cinfo->recv_thread)
goto err;
- }
cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1);
if (!cinfo->message_lockres)
goto err;
@@ -1191,10 +1185,8 @@ static int lock_all_bitmaps(struct mddev *mddev)
sizeof(*cinfo
->other_bitmap_lockres),
GFP_KERNEL);
- if (!cinfo->other_bitmap_lockres) {
- pr_err("md: can't alloc mem for other bitmap locks\n");
+ if (!cinfo->other_bitmap_lockres)
return 0;
- }
my_slot = slot_number(mddev);
for (slot = 0; slot < mddev->bitmap_info.nodes; slot++) {
--
2.10.0
^ permalink raw reply related
* [PATCH 12/15] md-cluster: Rename a jump label in area_resyncing()
From: SF Markus Elfring @ 2016-10-01 14:57 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 14:38:12 +0200
Adjust a jump label according to the Linux coding style convention
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 7f82c6b..e1ebcc4 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1085,13 +1085,13 @@ static int area_resyncing(struct mddev *mddev, int direction,
spin_lock_irq(&cinfo->suspend_lock);
if (list_empty(&cinfo->suspend_list))
- goto out;
+ goto unlock;
list_for_each_entry(s, &cinfo->suspend_list, list)
if (hi > s->lo && lo < s->hi) {
ret = 1;
break;
}
-out:
+unlock:
spin_unlock_irq(&cinfo->suspend_lock);
return ret;
}
--
2.10.0
^ permalink raw reply related
* [PATCH 13/15] md-cluster: Less function calls in join() after error detection
From: SF Markus Elfring @ 2016-10-01 14:58 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 15:40:32 +0200
A few resource release functions were called in some cases
by the join() function during error handling
even if the passed data structure member contained a null pointer.
* Adjust jump targets according to the Linux coding style convention.
* Delete a repeated check which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index e1ebcc4..36bb962 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -837,39 +837,39 @@ static int join(struct mddev *mddev, int nodes)
DLM_LSFL_FS, LVB_SIZE,
&md_ls_ops, mddev, &ops_rv, &cinfo->lockspace);
if (ret)
- goto err;
+ goto free_cluster_info;
wait_for_completion(&cinfo->completion);
if (nodes < cinfo->slot_number) {
pr_err("md-cluster: Slot allotted(%d) is greater than available slots(%d).",
cinfo->slot_number, nodes);
ret = -ERANGE;
- goto err;
+ goto release_lockspace;
}
/* Initiate the communication resources */
ret = -ENOMEM;
cinfo->recv_thread = md_register_thread(recv_daemon, mddev, "cluster_recv");
if (!cinfo->recv_thread)
- goto err;
+ goto release_lockspace;
cinfo->message_lockres = lockres_init(mddev, "message", NULL, 1);
if (!cinfo->message_lockres)
- goto err;
+ goto unregister_recv;
cinfo->token_lockres = lockres_init(mddev, "token", NULL, 0);
if (!cinfo->token_lockres)
- goto err;
+ goto free_message;
cinfo->no_new_dev_lockres = lockres_init(mddev, "no-new-dev", NULL, 0);
if (!cinfo->no_new_dev_lockres)
- goto err;
+ goto free_token;
ret = dlm_lock_sync(cinfo->token_lockres, DLM_LOCK_EX);
if (ret) {
ret = -EAGAIN;
pr_err("md-cluster: can't join cluster to avoid lock issue\n");
- goto err;
+ goto free_no_new_dev;
}
cinfo->ack_lockres = lockres_init(mddev, "ack", ack_bast, 0);
if (!cinfo->ack_lockres) {
ret = -ENOMEM;
- goto err;
+ goto free_no_new_dev;
}
/* get sync CR lock on ACK. */
if (dlm_lock_sync(cinfo->ack_lockres, DLM_LOCK_CR))
@@ -886,34 +886,39 @@ static int join(struct mddev *mddev, int nodes)
cinfo->bitmap_lockres = lockres_init(mddev, str, NULL, 1);
if (!cinfo->bitmap_lockres) {
ret = -ENOMEM;
- goto err;
+ goto free_ack;
}
if (dlm_lock_sync(cinfo->bitmap_lockres, DLM_LOCK_PW)) {
pr_err("Failed to get bitmap lock\n");
ret = -EINVAL;
- goto err;
+ goto free_bitmap;
}
cinfo->resync_lockres = lockres_init(mddev, "resync", NULL, 0);
if (!cinfo->resync_lockres) {
ret = -ENOMEM;
- goto err;
+ goto free_bitmap;
}
return 0;
-err:
- md_unregister_thread(&cinfo->recovery_thread);
- md_unregister_thread(&cinfo->recv_thread);
- lockres_free(cinfo->message_lockres);
- lockres_free(cinfo->token_lockres);
+free_bitmap:
+ lockres_free(cinfo->bitmap_lockres);
+free_ack:
lockres_free(cinfo->ack_lockres);
+free_no_new_dev:
lockres_free(cinfo->no_new_dev_lockres);
- lockres_free(cinfo->resync_lockres);
- lockres_free(cinfo->bitmap_lockres);
- if (cinfo->lockspace)
- dlm_release_lockspace(cinfo->lockspace, 2);
- mddev->cluster_info = NULL;
+free_token:
+ lockres_free(cinfo->token_lockres);
+free_message:
+ lockres_free(cinfo->message_lockres);
+unregister_recv:
+ md_unregister_thread(&cinfo->recv_thread);
+release_lockspace:
+ dlm_release_lockspace(cinfo->lockspace, 2);
+free_cluster_info:
kfree(cinfo);
+ md_unregister_thread(&cinfo->recovery_thread);
+ mddev->cluster_info = NULL;
return ret;
}
--
2.10.0
^ permalink raw reply related
* [PATCH 14/15] md-cluster: Less function calls in lockres_init() after error detection
From: SF Markus Elfring @ 2016-10-01 14:59 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 16:01:05 +0200
The kfree() function was called in up to three cases
by the lockres_init() function during error handling even if
the passed data structure member (or variable) contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 36bb962..0cade1a 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -201,12 +201,12 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
namelen = strlen(name);
res->name = kzalloc(namelen + 1, GFP_KERNEL);
if (!res->name)
- goto out_err;
+ goto free_resource;
strlcpy(res->name, name, namelen + 1);
if (with_lvb) {
res->lksb.sb_lvbptr = kzalloc(LVB_SIZE, GFP_KERNEL);
if (!res->lksb.sb_lvbptr)
- goto out_err;
+ goto free_name;
res->flags = DLM_LKF_VALBLK;
}
@@ -218,15 +218,17 @@ static struct dlm_lock_resource *lockres_init(struct mddev *mddev,
ret = dlm_lock_sync(res, DLM_LOCK_NL);
if (ret) {
pr_err("md-cluster: Unable to lock NL on new lock resource %s\n", name);
- goto out_err;
+ goto free_lvb;
}
res->flags &= ~DLM_LKF_EXPEDITE;
res->flags |= DLM_LKF_CONVERT;
return res;
-out_err:
+free_lvb:
kfree(res->lksb.sb_lvbptr);
+free_name:
kfree(res->name);
+free_resource:
kfree(res);
return NULL;
}
--
2.10.0
^ permalink raw reply related
* [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps()
From: SF Markus Elfring @ 2016-10-01 15:00 UTC (permalink / raw)
To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <3a03df66-92ce-20fb-17f3-fb79b9d43c8e@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 16:15:55 +0200
Do not use curly brackets at one source code place
where a single statement should be sufficient.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/md-cluster.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 0cade1a..a9bf13d 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1223,11 +1223,10 @@ static void unlock_all_bitmaps(struct mddev *mddev)
/* release other node's bitmap lock if they are existed */
if (cinfo->other_bitmap_lockres) {
- for (i = 0; i < mddev->bitmap_info.nodes - 1; i++) {
- if (cinfo->other_bitmap_lockres[i]) {
+ for (i = 0; i < mddev->bitmap_info.nodes - 1; i++)
+ if (cinfo->other_bitmap_lockres[i])
lockres_free(cinfo->other_bitmap_lockres[i]);
- }
- }
+
kfree(cinfo->other_bitmap_lockres);
}
}
--
2.10.0
^ permalink raw reply related
* [PATCH 00/13] md/multipath: Fine-tuning for several function implementations
From: SF Markus Elfring @ 2016-10-02 11:54 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <566ABCD9.1060404@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 13:45:35 +0200
Several update suggestions were taken into account
from static source code analysis.
Markus Elfring (13):
Use kcalloc() in multipath_run()
Improve another size determination in multipath_run()
Delete four error messages for a failed memory allocation
Reduce indentation for four lines in multipath_run()
Less function calls in multipath_run() after error detection
Delete 13 unwanted spaces behind function names
Delete two unwanted spaces behind asterisks
Replace a seq_printf() call by seq_puts() in multipath_status()
Adjust two function calls together with a variable assignment
Add some spaces for better code readability
Move a brace for a designated initialiser
Delete an unnecessary return statement in multipath_make_request()
Replace printk() calls by the usage of higher level interfaces
drivers/md/multipath.c | 192 +++++++++++++++++++++++--------------------------
1 file changed, 88 insertions(+), 104 deletions(-)
--
2.10.0
^ permalink raw reply
* [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run()
From: SF Markus Elfring @ 2016-10-02 11:56 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 20:40:42 +0200
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus reuse the corresponding function "kcalloc".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data structure by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 673efbd..bd53451 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -408,7 +408,8 @@ static int multipath_run (struct mddev *mddev)
goto out;
}
- conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks,
+ conf->multipaths = kcalloc(mddev->raid_disks,
+ sizeof(*conf->multipaths),
GFP_KERNEL);
if (!conf->multipaths) {
printk(KERN_ERR
--
2.10.0
^ permalink raw reply related
* [PATCH 2/13] md/multipath: Improve another size determination in multipath_run()
From: SF Markus Elfring @ 2016-10-02 11:57 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 20:52:57 +0200
Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index bd53451..7fdabb1 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -399,7 +399,7 @@ static int multipath_run (struct mddev *mddev)
* should be freed in multipath_free()]
*/
- conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL);
+ conf = kzalloc(sizeof(*conf), GFP_KERNEL);
mddev->private = conf;
if (!conf) {
printk(KERN_ERR
--
2.10.0
^ permalink raw reply related
* [PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation
From: SF Markus Elfring @ 2016-10-02 11:59 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 21:15:45 +0200
Omit extra messages for a memory allocation failure in this function.
Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 7fdabb1..be7c0b9 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -401,22 +401,14 @@ static int multipath_run (struct mddev *mddev)
conf = kzalloc(sizeof(*conf), GFP_KERNEL);
mddev->private = conf;
- if (!conf) {
- printk(KERN_ERR
- "multipath: couldn't allocate memory for %s\n",
- mdname(mddev));
+ if (!conf)
goto out;
- }
conf->multipaths = kcalloc(mddev->raid_disks,
sizeof(*conf->multipaths),
GFP_KERNEL);
- if (!conf->multipaths) {
- printk(KERN_ERR
- "multipath: couldn't allocate memory for %s\n",
- mdname(mddev));
+ if (!conf->multipaths)
goto out_free_conf;
- }
working_disks = 0;
rdev_for_each(rdev, mddev) {
@@ -448,21 +440,14 @@ static int multipath_run (struct mddev *mddev)
conf->pool = mempool_create_kmalloc_pool(NR_RESERVED_BUFS,
sizeof(struct multipath_bh));
- if (conf->pool == NULL) {
- printk(KERN_ERR
- "multipath: couldn't allocate memory for %s\n",
- mdname(mddev));
+ if (!conf->pool)
goto out_free_conf;
- }
{
mddev->thread = md_register_thread(multipathd, mddev,
"multipath");
- if (!mddev->thread) {
- printk(KERN_ERR "multipath: couldn't allocate thread"
- " for %s\n", mdname(mddev));
+ if (!mddev->thread)
goto out_free_conf;
- }
}
printk(KERN_INFO
--
2.10.0
^ permalink raw reply related
* [PATCH 4/13] md/multipath: Reduce indentation for four lines in multipath_run()
From: SF Markus Elfring @ 2016-10-02 12:00 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 21:26:00 +0200
* Delete a pair of extra curly brackets.
* Reduce indentation one level for a few lines in this function.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index be7c0b9..7900426 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -443,12 +443,9 @@ static int multipath_run (struct mddev *mddev)
if (!conf->pool)
goto out_free_conf;
- {
- mddev->thread = md_register_thread(multipathd, mddev,
- "multipath");
- if (!mddev->thread)
- goto out_free_conf;
- }
+ mddev->thread = md_register_thread(multipathd, mddev, "multipath");
+ if (!mddev->thread)
+ goto out_free_conf;
printk(KERN_INFO
"multipath: array %s active with %d out of %d IO paths\n",
--
2.10.0
^ permalink raw reply related
* [PATCH 5/13] md/multipath: Less function calls in multipath_run() after error detection
From: SF Markus Elfring @ 2016-10-02 12:01 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 21:48:59 +0200
The functions "kfree" and "mempool_destroy" were called in a few cases
by the function "multipath_run" during error handling even if
the passed data structure member contained a null pointer.
Adjust jump targets according to the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 7900426..2e4ceb9 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -408,7 +408,7 @@ static int multipath_run (struct mddev *mddev)
sizeof(*conf->multipaths),
GFP_KERNEL);
if (!conf->multipaths)
- goto out_free_conf;
+ goto free_conf;
working_disks = 0;
rdev_for_each(rdev, mddev) {
@@ -434,18 +434,18 @@ static int multipath_run (struct mddev *mddev)
if (!working_disks) {
printk(KERN_ERR "multipath: no operational IO paths for %s\n",
mdname(mddev));
- goto out_free_conf;
+ goto free_multipaths;
}
mddev->degraded = conf->raid_disks - working_disks;
conf->pool = mempool_create_kmalloc_pool(NR_RESERVED_BUFS,
sizeof(struct multipath_bh));
if (!conf->pool)
- goto out_free_conf;
+ goto free_multipaths;
mddev->thread = md_register_thread(multipathd, mddev, "multipath");
if (!mddev->thread)
- goto out_free_conf;
+ goto destroy_pool;
printk(KERN_INFO
"multipath: array %s active with %d out of %d IO paths\n",
@@ -457,13 +457,14 @@ static int multipath_run (struct mddev *mddev)
md_set_array_sectors(mddev, multipath_size(mddev, 0, 0));
if (md_integrity_register(mddev))
- goto out_free_conf;
+ goto destroy_pool;
return 0;
-
-out_free_conf:
+destroy_pool:
mempool_destroy(conf->pool);
+free_multipaths:
kfree(conf->multipaths);
+free_conf:
kfree(conf);
mddev->private = NULL;
out:
--
2.10.0
^ permalink raw reply related
* [PATCH 6/13] md/multipath: Delete 13 unwanted spaces behind function names
From: SF Markus Elfring @ 2016-10-02 12:02 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 08:14:48 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: space prohibited between function name and open parenthesis '('
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 2e4ceb9..7e10603 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -31,7 +31,7 @@
#define NR_RESERVED_BUFS 32
-static int multipath_map (struct mpconf *conf)
+static int multipath_map(struct mpconf *conf)
{
int i, disks = conf->raid_disks;
@@ -56,7 +56,7 @@ static int multipath_map (struct mpconf *conf)
return (-1);
}
-static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
+static void multipath_reschedule_retry(struct multipath_bh *mp_bh)
{
unsigned long flags;
struct mddev *mddev = mp_bh->mddev;
@@ -73,7 +73,7 @@ static void multipath_reschedule_retry (struct multipath_bh *mp_bh)
* operation and are ready to return a success/failure code to the buffer
* cache layer.
*/
-static void multipath_end_bh_io (struct multipath_bh *mp_bh, int err)
+static void multipath_end_bh_io(struct multipath_bh *mp_bh, int err)
{
struct bio *bio = mp_bh->master_bio;
struct mpconf *conf = mp_bh->mddev->private;
@@ -96,7 +96,7 @@ static void multipath_end_request(struct bio *bio)
* oops, IO error:
*/
char b[BDEVNAME_SIZE];
- md_error (mp_bh->mddev, rdev);
+ md_error(mp_bh->mddev, rdev);
printk(KERN_ERR "multipath: %s: rescheduling sector %llu\n",
bdevname(rdev->bdev,b),
(unsigned long long)bio->bi_iter.bi_sector);
@@ -147,12 +147,14 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
struct mpconf *conf = mddev->private;
int i;
- seq_printf (seq, " [%d/%d] [", conf->raid_disks,
- conf->raid_disks - mddev->degraded);
+ seq_printf(seq, " [%d/%d] [", conf->raid_disks,
+ conf->raid_disks - mddev->degraded);
rcu_read_lock();
for (i = 0; i < conf->raid_disks; i++) {
struct md_rdev *rdev = rcu_dereference(conf->multipaths[i].rdev);
- seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
+ seq_printf(seq,
+ "%s",
+ rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
}
rcu_read_unlock();
seq_printf (seq, "]");
@@ -183,7 +185,7 @@ static int multipath_congested(struct mddev *mddev, int bits)
/*
* Careful, this can execute in IRQ contexts as well!
*/
-static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
+static void multipath_error(struct mddev *mddev, struct md_rdev *rdev)
{
struct mpconf *conf = mddev->private;
char b[BDEVNAME_SIZE];
@@ -218,7 +220,7 @@ static void multipath_error (struct mddev *mddev, struct md_rdev *rdev)
conf->raid_disks - mddev->degraded);
}
-static void print_multipath_conf (struct mpconf *conf)
+static void print_multipath_conf(struct mpconf *conf)
{
int i;
struct multipath_info *tmp;
@@ -377,7 +379,7 @@ static sector_t multipath_size(struct mddev *mddev, sector_t sectors, int raid_d
return mddev->dev_sectors;
}
-static int multipath_run (struct mddev *mddev)
+static int multipath_run(struct mddev *mddev)
{
struct mpconf *conf;
int disk_idx;
@@ -496,14 +498,14 @@ static struct md_personality multipath_personality =
.congested = multipath_congested,
};
-static int __init multipath_init (void)
+static int __init multipath_init(void)
{
- return register_md_personality (&multipath_personality);
+ return register_md_personality(&multipath_personality);
}
-static void __exit multipath_exit (void)
+static void __exit multipath_exit(void)
{
- unregister_md_personality (&multipath_personality);
+ unregister_md_personality(&multipath_personality);
}
module_init(multipath_init);
--
2.10.0
^ permalink raw reply related
* [PATCH 7/13] md/multipath: Delete two unwanted spaces behind asterisks
From: SF Markus Elfring @ 2016-10-02 12:03 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 09:39:39 +0200
The script "checkpatch.pl" pointed information out like the following.
ERROR: "foo * bar" should be "foo *bar"
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 7e10603..cb5141f 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -106,10 +106,10 @@ static void multipath_end_request(struct bio *bio)
rdev_dec_pending(rdev, conf->mddev);
}
-static void multipath_make_request(struct mddev *mddev, struct bio * bio)
+static void multipath_make_request(struct mddev *mddev, struct bio *bio)
{
struct mpconf *conf = mddev->private;
- struct multipath_bh * mp_bh;
+ struct multipath_bh *mp_bh;
struct multipath_info *multipath;
if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
--
2.10.0
^ permalink raw reply related
* [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status()
From: SF Markus Elfring @ 2016-10-02 12:04 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 10:00:15 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: Prefer seq_puts to seq_printf
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index cb5141f..0e8939f 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -157,7 +157,7 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
}
rcu_read_unlock();
- seq_printf (seq, "]");
+ seq_puts(seq, "]");
}
static int multipath_congested(struct mddev *mddev, int bits)
--
2.10.0
^ permalink raw reply related
* [PATCH 9/13] md/multipath: Adjust two function calls together with a variable assignment
From: SF Markus Elfring @ 2016-10-02 12:05 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 10:05:43 +0200
The script "checkpatch.pl" pointed information out like the following.
ERROR: do not use assignment in if condition
Thus fix the affected source code places.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 0e8939f..a5a639d 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -258,8 +258,9 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev)
print_multipath_conf(conf);
- for (path = first; path <= last; path++)
- if ((p=conf->multipaths+path)->rdev == NULL) {
+ for (path = first; path <= last; path++) {
+ p = conf->multipaths + path;
+ if (!p->rdev) {
q = rdev->bdev->bd_disk->queue;
disk_stack_limits(mddev->gendisk, rdev->bdev,
rdev->data_offset << 9);
@@ -276,6 +277,7 @@ static int multipath_add_disk(struct mddev *mddev, struct md_rdev *rdev)
err = 0;
break;
}
+ }
print_multipath_conf(conf);
@@ -347,7 +349,8 @@ static void multipathd(struct md_thread *thread)
bio = &mp_bh->bio;
bio->bi_iter.bi_sector = mp_bh->master_bio->bi_iter.bi_sector;
- if ((mp_bh->path = multipath_map (conf))<0) {
+ mp_bh->path = multipath_map(conf);
+ if (mp_bh->path < 0) {
printk(KERN_ALERT "multipath: %s: unrecoverable IO read"
" error for block %llu\n",
bdevname(bio->bi_bdev,b),
--
2.10.0
^ permalink raw reply related
* [PATCH 10/13] md/multipath: Add some spaces for better code readability
From: SF Markus Elfring @ 2016-10-02 12:06 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 10:20:52 +0200
Use space characters at some source code places according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index a5a639d..23c7c29 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -98,7 +98,7 @@ static void multipath_end_request(struct bio *bio)
char b[BDEVNAME_SIZE];
md_error(mp_bh->mddev, rdev);
printk(KERN_ERR "multipath: %s: rescheduling sector %llu\n",
- bdevname(rdev->bdev,b),
+ bdevname(rdev->bdev, b),
(unsigned long long)bio->bi_iter.bi_sector);
multipath_reschedule_retry(mp_bh);
} else
@@ -238,8 +238,8 @@ static void print_multipath_conf(struct mpconf *conf)
tmp = conf->multipaths + i;
if (tmp->rdev)
printk(" disk%d, o:%d, dev:%s\n",
- i,!test_bit(Faulty, &tmp->rdev->flags),
- bdevname(tmp->rdev->bdev,b));
+ i, !test_bit(Faulty, &tmp->rdev->flags),
+ bdevname(tmp->rdev->bdev, b));
}
}
@@ -353,13 +353,13 @@ static void multipathd(struct md_thread *thread)
if (mp_bh->path < 0) {
printk(KERN_ALERT "multipath: %s: unrecoverable IO read"
" error for block %llu\n",
- bdevname(bio->bi_bdev,b),
+ bdevname(bio->bi_bdev, b),
(unsigned long long)bio->bi_iter.bi_sector);
multipath_end_bh_io(mp_bh, -EIO);
} else {
printk(KERN_ERR "multipath: %s: redirecting sector %llu"
" to another IO path\n",
- bdevname(bio->bi_bdev,b),
+ bdevname(bio->bi_bdev, b),
(unsigned long long)bio->bi_iter.bi_sector);
*bio = *(mp_bh->master_bio);
bio->bi_iter.bi_sector +=
@@ -487,18 +487,18 @@ static void multipath_free(struct mddev *mddev, void *priv)
static struct md_personality multipath_personality =
{
- .name = "multipath",
- .level = LEVEL_MULTIPATH,
- .owner = THIS_MODULE,
- .make_request = multipath_make_request,
- .run = multipath_run,
- .free = multipath_free,
- .status = multipath_status,
- .error_handler = multipath_error,
- .hot_add_disk = multipath_add_disk,
- .hot_remove_disk= multipath_remove_disk,
- .size = multipath_size,
- .congested = multipath_congested,
+ .name = "multipath",
+ .level = LEVEL_MULTIPATH,
+ .owner = THIS_MODULE,
+ .make_request = multipath_make_request,
+ .run = multipath_run,
+ .free = multipath_free,
+ .status = multipath_status,
+ .error_handler = multipath_error,
+ .hot_add_disk = multipath_add_disk,
+ .hot_remove_disk = multipath_remove_disk,
+ .size = multipath_size,
+ .congested = multipath_congested,
};
static int __init multipath_init(void)
--
2.10.0
^ permalink raw reply related
* [PATCH 11/13] md/multipath: Move a brace for a designated initialiser
From: SF Markus Elfring @ 2016-10-02 12:08 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 10:43:28 +0200
The script "checkpatch.pl" pointed information out like the following.
ERROR: that open brace { should be on the previous line
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 23c7c29..ab6487c 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -485,8 +485,7 @@ static void multipath_free(struct mddev *mddev, void *priv)
kfree(conf);
}
-static struct md_personality multipath_personality =
-{
+static struct md_personality multipath_personality = {
.name = "multipath",
.level = LEVEL_MULTIPATH,
.owner = THIS_MODULE,
--
2.10.0
^ permalink raw reply related
* [PATCH 12/13] md/multipath: Delete an unnecessary return statement in multipath_make_request()
From: SF Markus Elfring @ 2016-10-02 12:09 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 10:55:06 +0200
The script "checkpatch.pl" pointed information out like the following.
WARNING: void function return statements are not generally useful
Thus remove such a statement here.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index ab6487c..85f6c85 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -139,7 +139,6 @@ static void multipath_make_request(struct mddev *mddev, struct bio *bio)
mp_bh->bio.bi_end_io = multipath_end_request;
mp_bh->bio.bi_private = mp_bh;
generic_make_request(&mp_bh->bio);
- return;
}
static void multipath_status(struct seq_file *seq, struct mddev *mddev)
--
2.10.0
^ permalink raw reply related
* [PATCH 13/13] md/multipath: Replace printk() calls by the usage of higher level interfaces
From: SF Markus Elfring @ 2016-10-02 12:10 UTC (permalink / raw)
To: linux-raid, Jens Axboe, NeilBrown, Shaohua Li
Cc: LKML, kernel-janitors, Julia Lawall
In-Reply-To: <4a31d7a7-f70c-12f7-202f-963bd8706066@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 2 Oct 2016 12:42:46 +0200
1. Add a definition for the macros "MY_LOG_PREFIX" and "pr_fmt"
so that their information can be used for consistent message output.
2. Prefer usage of some higher level macros over calling "printk" directly
in this software module.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/md/multipath.c | 69 ++++++++++++++++++++++++--------------------------
1 file changed, 33 insertions(+), 36 deletions(-)
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 85f6c85..045b866 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -19,6 +19,8 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#define MY_LOG_PREFIX KBUILD_MODNAME ": "
+#define pr_fmt(fmt) MY_LOG_PREFIX fmt
#include <linux/blkdev.h>
#include <linux/module.h>
#include <linux/raid/md_u.h>
@@ -51,8 +53,7 @@ static int multipath_map(struct mpconf *conf)
}
}
rcu_read_unlock();
-
- printk(KERN_ERR "multipath_map(): no more operational IO paths?\n");
+ pr_err("map: no more operational IO paths?\n");
return (-1);
}
@@ -97,7 +98,8 @@ static void multipath_end_request(struct bio *bio)
*/
char b[BDEVNAME_SIZE];
md_error(mp_bh->mddev, rdev);
- printk(KERN_ERR "multipath: %s: rescheduling sector %llu\n",
+
+ pr_err("%s: rescheduling sector %llu\n",
bdevname(rdev->bdev, b),
(unsigned long long)bio->bi_iter.bi_sector);
multipath_reschedule_retry(mp_bh);
@@ -195,8 +197,7 @@ static void multipath_error(struct mddev *mddev, struct md_rdev *rdev)
* first check if this is a queued request for a device
* which has just failed.
*/
- printk(KERN_ALERT
- "multipath: only one IO path left and IO error.\n");
+ pr_alert("only one IO path left and IO error.\n");
/* leave it active... it's all we have */
return;
}
@@ -211,12 +212,10 @@ static void multipath_error(struct mddev *mddev, struct md_rdev *rdev)
}
set_bit(Faulty, &rdev->flags);
set_bit(MD_CHANGE_DEVS, &mddev->flags);
- printk(KERN_ALERT "multipath: IO failure on %s,"
- " disabling IO path.\n"
- "multipath: Operation continuing"
- " on %d IO paths.\n",
- bdevname(rdev->bdev, b),
- conf->raid_disks - mddev->degraded);
+ pr_alert("IO failure on %s, disabling IO path.\n"
+ MY_LOG_PREFIX "Operation continuing on %d IO paths.\n",
+ bdevname(rdev->bdev, b),
+ conf->raid_disks - mddev->degraded);
}
static void print_multipath_conf(struct mpconf *conf)
@@ -224,21 +223,22 @@ static void print_multipath_conf(struct mpconf *conf)
int i;
struct multipath_info *tmp;
- printk("MULTIPATH conf printout:\n");
+ pr_info("conf printout:\n");
if (!conf) {
- printk("(conf==NULL)\n");
+ pr_info("(conf==NULL)\n");
return;
}
- printk(" --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded,
- conf->raid_disks);
+ pr_info("--- wd:%d rd:%d\n",
+ conf->raid_disks - conf->mddev->degraded,
+ conf->raid_disks);
for (i = 0; i < conf->raid_disks; i++) {
char b[BDEVNAME_SIZE];
tmp = conf->multipaths + i;
if (tmp->rdev)
- printk(" disk%d, o:%d, dev:%s\n",
- i, !test_bit(Faulty, &tmp->rdev->flags),
- bdevname(tmp->rdev->bdev, b));
+ pr_info("disk%d, o:%d, dev:%s\n",
+ i, !test_bit(Faulty, &tmp->rdev->flags),
+ bdevname(tmp->rdev->bdev, b));
}
}
@@ -295,8 +295,8 @@ static int multipath_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
if (rdev == p->rdev) {
if (test_bit(In_sync, &rdev->flags) ||
atomic_read(&rdev->nr_pending)) {
- printk(KERN_ERR "hot-remove-disk, slot %d is identified"
- " but is still operational!\n", number);
+ pr_err("hot-remove-disk, slot %d is identified but is still operational!\n",
+ number);
err = -EBUSY;
goto abort;
}
@@ -350,16 +350,14 @@ static void multipathd(struct md_thread *thread)
mp_bh->path = multipath_map(conf);
if (mp_bh->path < 0) {
- printk(KERN_ALERT "multipath: %s: unrecoverable IO read"
- " error for block %llu\n",
- bdevname(bio->bi_bdev, b),
- (unsigned long long)bio->bi_iter.bi_sector);
+ pr_alert("%s: unrecoverable IO read error for block %llu\n",
+ bdevname(bio->bi_bdev, b),
+ (unsigned long long)bio->bi_iter.bi_sector);
multipath_end_bh_io(mp_bh, -EIO);
} else {
- printk(KERN_ERR "multipath: %s: redirecting sector %llu"
- " to another IO path\n",
- bdevname(bio->bi_bdev, b),
- (unsigned long long)bio->bi_iter.bi_sector);
+ pr_err("%s: redirecting sector %llu to another IO path\n",
+ bdevname(bio->bi_bdev, b),
+ (unsigned long long)bio->bi_iter.bi_sector);
*bio = *(mp_bh->master_bio);
bio->bi_iter.bi_sector +=
conf->multipaths[mp_bh->path].rdev->data_offset;
@@ -393,8 +391,8 @@ static int multipath_run(struct mddev *mddev)
return -EINVAL;
if (mddev->level != LEVEL_MULTIPATH) {
- printk("multipath: %s: raid level not set to multipath IO (%d)\n",
- mdname(mddev), mddev->level);
+ pr_notice("%s: raid level not set to multipath IO (%d)\n",
+ mdname(mddev), mddev->level);
goto out;
}
/*
@@ -436,8 +434,7 @@ static int multipath_run(struct mddev *mddev)
INIT_LIST_HEAD(&conf->retry_list);
if (!working_disks) {
- printk(KERN_ERR "multipath: no operational IO paths for %s\n",
- mdname(mddev));
+ pr_err("no operational IO paths for %s\n", mdname(mddev));
goto free_multipaths;
}
mddev->degraded = conf->raid_disks - working_disks;
@@ -451,10 +448,10 @@ static int multipath_run(struct mddev *mddev)
if (!mddev->thread)
goto destroy_pool;
- printk(KERN_INFO
- "multipath: array %s active with %d out of %d IO paths\n",
- mdname(mddev), conf->raid_disks - mddev->degraded,
- mddev->raid_disks);
+ pr_info("array %s active with %d out of %d IO paths\n",
+ mdname(mddev),
+ conf->raid_disks - mddev->degraded,
+ mddev->raid_disks);
/*
* Ok, everything is just fine now
*/
--
2.10.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox