linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
@ 2016-09-27 16:44 ` SF Markus Elfring
  2016-09-27 16:45   ` [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() SF Markus Elfring
                     ` (15 more replies)
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                   ` (4 subsequent siblings)
  5 siblings, 16 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:44 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 18:29:08 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (16):
  Use kmalloc_array() in bitmap_storage_alloc()
  Move an assignment for the variable "offset" in bitmap_storage_alloc()
  Delete an unnecessary variable initialisation in bitmap_storage_alloc()
  Improve another size determination in bitmap_storage_alloc()
  Return directly after a failed bitmap_storage_alloc() in bitmap_resize()
  Return directly after a failed kzalloc() in bitmap_resize()
  Replace a kzalloc() call by kcalloc() in bitmap_resize()
  Rename a jump label in location_store()
  Rename a jump label in bitmap_copy_from_slot()
  Rename a jump label in bitmap_create()
  Rename a jump label in bitmap_init_from_disk()
  One check less in read_page() at the end
  Adjust checks for null pointers in 11 functions
  Delete unnecessary braces in bitmap_resize()
  Add spaces around three comparison operators
  Delete an unwanted space in read_sb_page()

 drivers/md/bitmap.c | 110 +++++++++++++++++++++++++---------------------------
 1 file changed, 52 insertions(+), 58 deletions(-)

-- 
2.10.0


^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-27 16:45   ` SF Markus Elfring
  2016-09-28 19:51     ` Jes Sorensen
  2016-09-27 16:48   ` [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" " SF Markus Elfring
                     ` (14 subsequent siblings)
  15 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:45 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 13:01:07 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type 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/bitmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 13041ee..8cfb02c 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -760,9 +760,9 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 
 	num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
 	offset = slot_number * num_pages;
-
-	store->filemap = kmalloc(sizeof(struct page *)
-				 * num_pages, GFP_KERNEL);
+	store->filemap = kmalloc_array(num_pages,
+				       sizeof(*store->filemap),
+				       GFP_KERNEL);
 	if (!store->filemap)
 		return -ENOMEM;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" in bitmap_storage_alloc()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-27 16:45   ` [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() SF Markus Elfring
@ 2016-09-27 16:48   ` SF Markus Elfring
  2016-09-27 16:49   ` [PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation " SF Markus Elfring
                     ` (13 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:48 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 13:10:05 +0200

Move the assignment for the local variable "offset" behind
the source code for memory allocations by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 8cfb02c..78512c6 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -759,7 +759,6 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 		bytes += sizeof(bitmap_super_t);
 
 	num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
-	offset = slot_number * num_pages;
 	store->filemap = kmalloc_array(num_pages,
 				       sizeof(*store->filemap),
 				       GFP_KERNEL);
@@ -772,6 +771,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 			return -ENOMEM;
 	}
 
+	offset = slot_number * num_pages;
 	pnum = 0;
 	if (store->sb_page) {
 		store->filemap[0] = store->sb_page;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation in bitmap_storage_alloc()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-27 16:45   ` [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() SF Markus Elfring
  2016-09-27 16:48   ` [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" " SF Markus Elfring
@ 2016-09-27 16:49   ` SF Markus Elfring
  2016-09-27 16:50   ` [PATCH 04/16] md/bitmap: Improve another size determination " SF Markus Elfring
                     ` (12 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:49 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 13:20:23 +0200

The local variable "offset" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 78512c6..9b3f723 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -750,7 +750,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 				unsigned long chunks, int with_super,
 				int slot_number)
 {
-	int pnum, offset = 0;
+	int pnum, offset;
 	unsigned long num_pages;
 	unsigned long bytes;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 04/16] md/bitmap: Improve another size determination in bitmap_storage_alloc()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-27 16:49   ` [PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2016-09-27 16:50   ` SF Markus Elfring
  2016-09-27 16:51   ` [PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize() SF Markus Elfring
                     ` (11 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:50 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 14:19:00 +0200

Replace the specification of a data type 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/bitmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 9b3f723..c278865 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -791,9 +791,9 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 
 	/* We need 4 bits per page, rounded up to a multiple
 	 * of sizeof(unsigned long) */
-	store->filemap_attr = kzalloc(
-		roundup(DIV_ROUND_UP(num_pages*4, 8), sizeof(unsigned long)),
-		GFP_KERNEL);
+	store->filemap_attr = kzalloc(roundup(DIV_ROUND_UP(num_pages * 4, 8),
+					      sizeof(*store->filemap_attr)),
+				      GFP_KERNEL);
 	if (!store->filemap_attr)
 		return -ENOMEM;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-27 16:50   ` [PATCH 04/16] md/bitmap: Improve another size determination " SF Markus Elfring
@ 2016-09-27 16:51   ` SF Markus Elfring
  2016-09-27 16:53   ` [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() " SF Markus Elfring
                     ` (10 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:51 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 14:47:29 +0200

Return directly after a memory allocation failed in this function
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index c278865..5092bc0 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2032,7 +2032,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 					   mddev_is_clustered(bitmap->mddev)
 					   ? bitmap->cluster_slot : 0);
 	if (ret)
-		goto err;
+		return ret;
 
 	pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() in bitmap_resize()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-27 16:51   ` [PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize() SF Markus Elfring
@ 2016-09-27 16:53   ` SF Markus Elfring
  2016-09-27 16:54   ` [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
                     ` (9 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:53 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 15:21:23 +0200

* Return directly after a call of the function "kzalloc" failed here.

* Delete two assignments for the local variable "ret" and the jump
  target "err" which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5092bc0..2d30c83 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2037,10 +2037,9 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 	pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
 
 	new_bp = kzalloc(pages * sizeof(*new_bp), GFP_KERNEL);
-	ret = -ENOMEM;
 	if (!new_bp) {
 		bitmap_file_unmap(&store);
-		goto err;
+		return -ENOMEM;
 	}
 
 	if (!init)
@@ -2160,8 +2159,6 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 		bitmap_unplug(bitmap);
 		bitmap->mddev->pers->quiesce(bitmap->mddev, 0);
 	}
-	ret = 0;
-err:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(bitmap_resize);
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() in bitmap_resize()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-27 16:53   ` [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() " SF Markus Elfring
@ 2016-09-27 16:54   ` SF Markus Elfring
  2016-09-27 16:55   ` [PATCH 08/16] md/bitmap: Rename a jump label in location_store() SF Markus Elfring
                     ` (8 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:54 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 15:26:51 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 2d30c83..41d99fd 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2035,8 +2035,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 		return ret;
 
 	pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
-
-	new_bp = kzalloc(pages * sizeof(*new_bp), GFP_KERNEL);
+	new_bp = kcalloc(pages, sizeof(*new_bp), GFP_KERNEL);
 	if (!new_bp) {
 		bitmap_file_unmap(&store);
 		return -ENOMEM;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 08/16] md/bitmap: Rename a jump label in location_store()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-27 16:54   ` [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
@ 2016-09-27 16:55   ` SF Markus Elfring
  2016-09-28 19:55     ` Jes Sorensen
  2016-09-27 16:56   ` [PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot() SF Markus Elfring
                     ` (7 subsequent siblings)
  15 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:55 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 15:46:22 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 41d99fd..22fa09a 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2187,11 +2187,11 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 	if (mddev->pers) {
 		if (!mddev->pers->quiesce) {
 			rv = -EBUSY;
-			goto out;
+			goto unlock;
 		}
 		if (mddev->recovery || mddev->sync_thread) {
 			rv = -EBUSY;
-			goto out;
+			goto unlock;
 		}
 	}
 
@@ -2200,7 +2200,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 		/* bitmap already configured.  Only option is to clear it */
 		if (strncmp(buf, "none", 4) != 0) {
 			rv = -EBUSY;
-			goto out;
+			goto unlock;
 		}
 		if (mddev->pers) {
 			mddev->pers->quiesce(mddev, 1);
@@ -2221,23 +2221,23 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 		else if (strncmp(buf, "file:", 5) == 0) {
 			/* Not supported yet */
 			rv = -EINVAL;
-			goto out;
+			goto unlock;
 		} else {
 			if (buf[0] == '+')
 				rv = kstrtoll(buf+1, 10, &offset);
 			else
 				rv = kstrtoll(buf, 10, &offset);
 			if (rv)
-				goto out;
+				goto unlock;
 			if (offset == 0) {
 				rv = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 			if (mddev->bitmap_info.external == 0 &&
 			    mddev->major_version == 0 &&
 			    offset != mddev->bitmap_info.default_offset) {
 				rv = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 			mddev->bitmap_info.offset = offset;
 			if (mddev->pers) {
@@ -2255,7 +2255,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 				mddev->pers->quiesce(mddev, 0);
 				if (rv) {
 					bitmap_destroy(mddev);
-					goto out;
+					goto unlock;
 				}
 			}
 		}
@@ -2268,7 +2268,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
 		md_wakeup_thread(mddev->thread);
 	}
 	rv = 0;
-out:
+unlock:
 	mddev_unlock(mddev);
 	if (rv)
 		return rv;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-27 16:55   ` [PATCH 08/16] md/bitmap: Rename a jump label in location_store() SF Markus Elfring
@ 2016-09-27 16:56   ` SF Markus Elfring
  2016-09-27 16:57   ` [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create() SF Markus Elfring
                     ` (6 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:56 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 15:55:01 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 22fa09a..5125186 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1910,7 +1910,7 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
 
 	rv = bitmap_init_from_disk(bitmap, 0);
 	if (rv)
-		goto err;
+		goto free_bitmap;
 
 	counts = &bitmap->counts;
 	for (j = 0; j < counts->chunks; j++) {
@@ -1937,7 +1937,7 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
 	bitmap_unplug(mddev->bitmap);
 	*low = lo;
 	*high = hi;
-err:
+free_bitmap:
 	bitmap_free(bitmap);
 	return rv;
 }
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-27 16:56   ` [PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot() SF Markus Elfring
@ 2016-09-27 16:57   ` SF Markus Elfring
  2016-09-27 16:58   ` [PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk() SF Markus Elfring
                     ` (5 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:57 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 16:06:35 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 5125186..1f7f1e1 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1818,22 +1818,22 @@ struct bitmap *bitmap_create(struct mddev *mddev, int slot)
 			err = -EINVAL;
 	}
 	if (err)
-		goto error;
+		goto free_bitmap;
 
 	bitmap->daemon_lastrun = jiffies;
 	err = bitmap_resize(bitmap, blocks, mddev->bitmap_info.chunksize, 1);
 	if (err)
-		goto error;
+		goto free_bitmap;
 
 	printk(KERN_INFO "created bitmap (%lu pages) for device %s\n",
 	       bitmap->counts.pages, bmname(bitmap));
 
 	err = test_bit(BITMAP_WRITE_ERROR, &bitmap->flags) ? -EIO : 0;
 	if (err)
-		goto error;
+		goto free_bitmap;
 
 	return bitmap;
- error:
+free_bitmap:
 	bitmap_free(bitmap);
 	return ERR_PTR(err);
 }
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-27 16:57   ` [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create() SF Markus Elfring
@ 2016-09-27 16:58   ` SF Markus Elfring
  2016-09-27 16:59   ` [PATCH 12/16] md/bitmap: One check less in read_page() at the end SF Markus Elfring
                     ` (4 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:58 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 16:12:47 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 1f7f1e1..c186e5d 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1064,7 +1064,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 		       bmname(bitmap),
 		       (unsigned long) i_size_read(file->f_mapping->host),
 		       store->bytes);
-		goto err;
+		goto report_failure;
 	}
 
 	oldindex = ~0L;
@@ -1098,7 +1098,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 					index + node_offset, count);
 
 			if (ret)
-				goto err;
+				goto report_failure;
 
 			oldindex = index;
 
@@ -1116,7 +1116,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 				ret = -EIO;
 				if (test_bit(BITMAP_WRITE_ERROR,
 					     &bitmap->flags))
-					goto err;
+					goto report_failure;
 			}
 		}
 		paddr = kmap_atomic(page);
@@ -1143,8 +1143,7 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
 	       bit_cnt, chunks);
 
 	return 0;
-
- err:
+report_failure:
 	printk(KERN_INFO "%s: bitmap initialisation failed: %d\n",
 	       bmname(bitmap), ret);
 	return ret;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 12/16] md/bitmap: One check less in read_page() at the end
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-27 16:58   ` [PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk() SF Markus Elfring
@ 2016-09-27 16:59   ` SF Markus Elfring
  2016-09-28  7:33     ` Dan Carpenter
  2016-09-27 17:00   ` [PATCH 13/16] md/bitmap: Adjust checks for null pointers in 11 functions SF Markus Elfring
                     ` (3 subsequent siblings)
  15 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 16:59 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 16:30:25 +0200

* Adjust a jump target.

* Delete a repeated check which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index c186e5d..e7a7fc8 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -367,7 +367,7 @@ static int read_page(struct file *file, unsigned long index,
 	bh = alloc_page_buffers(page, 1<<inode->i_blkbits, 0);
 	if (!bh) {
 		ret = -ENOMEM;
-		goto out;
+		goto report_failure;
 	}
 	attach_page_buffers(page, bh);
 	block = index << (PAGE_SHIFT - inode->i_blkbits);
@@ -379,7 +379,7 @@ static int read_page(struct file *file, unsigned long index,
 			if (bh->b_blocknr == 0) {
 				/* Cannot use this file! */
 				ret = -EINVAL;
-				goto out;
+				goto report_failure;
 			}
 			bh->b_bdev = inode->i_sb->s_bdev;
 			if (count < (1<<inode->i_blkbits))
@@ -401,14 +401,14 @@ static int read_page(struct file *file, unsigned long index,
 
 	wait_event(bitmap->write_wait,
 		   atomic_read(&bitmap->pending_writes)==0);
-	if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
+	if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) {
 		ret = -EIO;
-out:
-	if (ret)
+report_failure:
 		printk(KERN_ALERT "md: bitmap read error: (%dB @ %llu): %d\n",
 			(int)PAGE_SIZE,
 			(unsigned long long)index << PAGE_SHIFT,
 			ret);
+	}
 	return ret;
 }
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 13/16] md/bitmap: Adjust checks for null pointers in 11 functions
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-27 16:59   ` [PATCH 12/16] md/bitmap: One check less in read_page() at the end SF Markus Elfring
@ 2016-09-27 17:00   ` SF Markus Elfring
  2016-09-27 17:02   ` [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize() SF Markus Elfring
                     ` (2 subsequent siblings)
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 17:00 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 17:40:12 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index e7a7fc8..f8900cc 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -88,7 +88,7 @@ __acquires(bitmap->lock)
 	mappage = kzalloc(PAGE_SIZE, GFP_NOIO);
 	spin_lock_irq(&bitmap->lock);
 
-	if (mappage == NULL) {
+	if (!mappage) {
 		pr_debug("md/bitmap: map page allocation failed, hijacking\n");
 		/* We don't support hijack for cluster raid */
 		if (no_hijack)
@@ -186,7 +186,7 @@ static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mdde
 	 * list_for_each_entry_continue_rcu() to find the first entry.
 	 */
 	rcu_read_lock();
-	if (rdev == NULL)
+	if (!rdev)
 		/* start at the beginning */
 		rdev = list_entry(&mddev->disks, struct md_rdev, same_set);
 	else {
@@ -284,7 +284,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
 {
 	struct buffer_head *bh;
 
-	if (bitmap->storage.file == NULL) {
+	if (!bitmap->storage.file) {
 		switch (write_sb_page(bitmap, page, wait)) {
 		case -EINVAL:
 			set_bit(BITMAP_WRITE_ERROR, &bitmap->flags);
@@ -493,7 +493,7 @@ static int bitmap_new_disk_sb(struct bitmap *bitmap)
 	unsigned long chunksize, daemon_sleep, write_behind;
 
 	bitmap->storage.sb_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
-	if (bitmap->storage.sb_page == NULL)
+	if (!bitmap->storage.sb_page)
 		return -ENOMEM;
 	bitmap->storage.sb_page->index = 0;
 
@@ -767,7 +767,7 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
 
 	if (with_super && !store->sb_page) {
 		store->sb_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
-		if (store->sb_page == NULL)
+		if (!store->sb_page)
 			return -ENOMEM;
 	}
 
@@ -1209,7 +1209,7 @@ void bitmap_daemon_work(struct mddev *mddev)
 	 */
 	mutex_lock(&mddev->bitmap_info.mutex);
 	bitmap = mddev->bitmap;
-	if (bitmap == NULL) {
+	if (!bitmap) {
 		mutex_unlock(&mddev->bitmap_info.mutex);
 		return;
 	}
@@ -1336,7 +1336,7 @@ __acquires(bitmap->lock)
 	err = bitmap_checkpage(bitmap, page, create, 0);
 
 	if (bitmap->bp[page].hijacked ||
-	    bitmap->bp[page].map == NULL)
+	    !bitmap->bp[page].map)
 		csize = ((sector_t)1) << (bitmap->chunkshift +
 					  PAGE_COUNTER_SHIFT - 1);
 	else
@@ -1481,7 +1481,7 @@ static int __bitmap_start_sync(struct bitmap *bitmap, sector_t offset, sector_t
 {
 	bitmap_counter_t *bmc;
 	int rv;
-	if (bitmap == NULL) {/* FIXME or bitmap set as 'failed' */
+	if (!bitmap) {/* FIXME or bitmap set as 'failed' */
 		*blocks = 1024;
 		return 1; /* always resync if no bitmap */
 	}
@@ -1533,13 +1533,13 @@ void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, sector_t *blocks, i
 	bitmap_counter_t *bmc;
 	unsigned long flags;
 
-	if (bitmap == NULL) {
+	if (!bitmap) {
 		*blocks = 1024;
 		return;
 	}
 	spin_lock_irqsave(&bitmap->counts.lock, flags);
 	bmc = bitmap_get_counter(&bitmap->counts, offset, blocks, 0);
-	if (bmc == NULL)
+	if (!bmc)
 		goto unlock;
 	/* locked */
 	if (RESYNC(*bmc)) {
@@ -2455,7 +2455,7 @@ static ssize_t can_clear_show(struct mddev *mddev, char *page)
 
 static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len)
 {
-	if (mddev->bitmap == NULL)
+	if (!mddev->bitmap)
 		return -ENOENT;
 	if (strncmp(buf, "false", 5) == 0)
 		mddev->bitmap->need_sync = 1;
@@ -2476,7 +2476,7 @@ behind_writes_used_show(struct mddev *mddev, char *page)
 {
 	ssize_t ret;
 	spin_lock(&mddev->lock);
-	if (mddev->bitmap == NULL)
+	if (!mddev->bitmap)
 		ret = sprintf(page, "0\n");
 	else
 		ret = sprintf(page, "%lu\n",
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-27 17:00   ` [PATCH 13/16] md/bitmap: Adjust checks for null pointers in 11 functions SF Markus Elfring
@ 2016-09-27 17:02   ` SF Markus Elfring
  2016-09-27 17:03   ` [PATCH 15/16] md/bitmap: Add spaces around three comparison operators SF Markus Elfring
  2016-09-27 17:04   ` [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page() SF Markus Elfring
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 17:02 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 17:53:07 +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/bitmap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index f8900cc..9d77f16 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2075,9 +2075,8 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 				unsigned long k;
 
 				/* deallocate the page memory */
-				for (k = 0; k < page; k++) {
+				for (k = 0; k < page; k++)
 					kfree(new_bp[k].map);
-				}
 
 				/* restore some fields from old_counts */
 				bitmap->counts.bp = old_counts.bp;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 15/16] md/bitmap: Add spaces around three comparison operators
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-27 17:02   ` [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize() SF Markus Elfring
@ 2016-09-27 17:03   ` SF Markus Elfring
  2016-09-27 17:04   ` [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page() SF Markus Elfring
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 17:03 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 18:08:04 +0200

The script "checkpatch.pl" can point information out like the following.

ERROR: spaces required around that '==' (ctx:VxV)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 9d77f16..d029576 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -303,7 +303,7 @@ static void write_page(struct bitmap *bitmap, struct page *page, int wait)
 
 		if (wait)
 			wait_event(bitmap->write_wait,
-				   atomic_read(&bitmap->pending_writes)==0);
+				   atomic_read(&bitmap->pending_writes) == 0);
 	}
 	if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags))
 		bitmap_file_kick(bitmap);
@@ -400,7 +400,7 @@ static int read_page(struct file *file, unsigned long index,
 	page->index = index;
 
 	wait_event(bitmap->write_wait,
-		   atomic_read(&bitmap->pending_writes)==0);
+		   atomic_read(&bitmap->pending_writes) == 0);
 	if (test_bit(BITMAP_WRITE_ERROR, &bitmap->flags)) {
 		ret = -EIO;
 report_failure:
@@ -1003,7 +1003,7 @@ void bitmap_unplug(struct bitmap *bitmap)
 	}
 	if (bitmap->storage.file)
 		wait_event(bitmap->write_wait,
-			   atomic_read(&bitmap->pending_writes)==0);
+			   atomic_read(&bitmap->pending_writes) == 0);
 	else
 		md_super_wait(bitmap->mddev);
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page()
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-27 17:03   ` [PATCH 15/16] md/bitmap: Add spaces around three comparison operators SF Markus Elfring
@ 2016-09-27 17:04   ` SF Markus Elfring
  15 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-27 17:04 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 27 Sep 2016 18:18:16 +0200

The script "checkpatch.pl" can point information out like the following.

ERROR: space prohibited after that '!' (ctx:BxW)

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index d029576..c6a6d59 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -154,7 +154,7 @@ static int read_sb_page(struct mddev *mddev, loff_t offset,
 	sector_t target;
 
 	rdev_for_each(rdev, mddev) {
-		if (! test_bit(In_sync, &rdev->flags)
+		if (!test_bit(In_sync, &rdev->flags)
 		    || test_bit(Faulty, &rdev->flags))
 			continue;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 12/16] md/bitmap: One check less in read_page() at the end
  2016-09-27 16:59   ` [PATCH 12/16] md/bitmap: One check less in read_page() at the end SF Markus Elfring
@ 2016-09-28  7:33     ` Dan Carpenter
  0 siblings, 0 replies; 221+ messages in thread
From: Dan Carpenter @ 2016-09-28  7:33 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Shaohua Li, LKML, kernel-janitors, Julia Lawall

This makes the code ugly.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-28 15:34 ` SF Markus Elfring
  2016-09-28 15:36   ` [PATCH 01/10] md/dm-crypt: Use kcalloc() in crypt_alloc_tfms() SF Markus Elfring
                     ` (10 more replies)
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                   ` (3 subsequent siblings)
  5 siblings, 11 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:34 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 17:25:17 +0200

Some update suggestions were taken into account
from static source code analysis.

Markus Elfring (10):
  Use kcalloc() in crypt_alloc_tfms()
  Reduce the scope for a variable in crypt_alloc_tfms()
  Rename a jump label in crypt_message()
  Delete an unnecessary variable initialisation in crypt_message()
  Rename a jump label in crypt_set_key()
  Delete an unnecessary variable initialisation in crypt_set_key()
  Rename a jump label in crypt_iv_tcw_whitening()
  Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr()
  Two checks and one function call less in crypt_iv_essiv_ctr() after error detection
  Delete unnecessary variable initialisations in crypt_iv_essiv_ctr()

 drivers/md/dm-crypt.c | 51 ++++++++++++++++++++++-----------------------------
 1 file changed, 22 insertions(+), 29 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 01/10] md/dm-crypt: Use kcalloc() in crypt_alloc_tfms()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
@ 2016-09-28 15:36   ` SF Markus Elfring
  2016-09-28 15:38   ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations Mike Snitzer
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:36 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 13:26:22 +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 type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Fixes: 5d0be84ec0cacfc7a6d6ea548afdd07d481324cd ("dm crypt: fix free of bad values after tfm allocation failure")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index a276883..68971a2 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1454,8 +1454,7 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
 	unsigned i;
 	int err;
 
-	cc->tfms = kzalloc(cc->tfms_count * sizeof(struct crypto_skcipher *),
-			   GFP_KERNEL);
+	cc->tfms = kcalloc(cc->tfms_count, sizeof(*cc->tfms), GFP_KERNEL);
 	if (!cc->tfms)
 		return -ENOMEM;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
  2016-09-28 15:36   ` [PATCH 01/10] md/dm-crypt: Use kcalloc() in crypt_alloc_tfms() SF Markus Elfring
@ 2016-09-28 15:38   ` Mike Snitzer
  2016-09-28 15:38   ` [PATCH 02/10] md/dm-crypt: Reduce the scope for a variable in crypt_alloc_tfms() SF Markus Elfring
                     ` (8 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: Mike Snitzer @ 2016-09-28 15:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dm-devel, linux-raid, Alasdair Kergon, Shaohua Li, LKML,
	kernel-janitors, Julia Lawall

On Wed, Sep 28 2016 at 11:34am -0400,
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 28 Sep 2016 17:25:17 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (10):
>   Use kcalloc() in crypt_alloc_tfms()
>   Reduce the scope for a variable in crypt_alloc_tfms()
>   Rename a jump label in crypt_message()
>   Delete an unnecessary variable initialisation in crypt_message()
>   Rename a jump label in crypt_set_key()
>   Delete an unnecessary variable initialisation in crypt_set_key()
>   Rename a jump label in crypt_iv_tcw_whitening()
>   Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr()
>   Two checks and one function call less in crypt_iv_essiv_ctr() after error detection
>   Delete unnecessary variable initialisations in crypt_iv_essiv_ctr()
> 
>  drivers/md/dm-crypt.c | 51 ++++++++++++++++++++++-----------------------------
>  1 file changed, 22 insertions(+), 29 deletions(-)

These are _not_ the kind of changes I want to be seeing.  Churn in the
name of "fine-tuning".

Nack.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 02/10] md/dm-crypt: Reduce the scope for a variable in crypt_alloc_tfms()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
  2016-09-28 15:36   ` [PATCH 01/10] md/dm-crypt: Use kcalloc() in crypt_alloc_tfms() SF Markus Elfring
  2016-09-28 15:38   ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations Mike Snitzer
@ 2016-09-28 15:38   ` SF Markus Elfring
  2016-09-28 15:40   ` [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message() SF Markus Elfring
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:38 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 14:05:25 +0200

Move the definition for the variable "err" (including its declaration)
into an if branch (so that the corresponding setting will only be performed
if a call of the function "crypto_alloc_skcipher" failed as before
this refactoring).

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 68971a2..88a3b62 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1452,7 +1452,6 @@ static void crypt_free_tfms(struct crypt_config *cc)
 static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
 {
 	unsigned i;
-	int err;
 
 	cc->tfms = kcalloc(cc->tfms_count, sizeof(*cc->tfms), GFP_KERNEL);
 	if (!cc->tfms)
@@ -1461,7 +1460,8 @@ static int crypt_alloc_tfms(struct crypt_config *cc, char *ciphermode)
 	for (i = 0; i < cc->tfms_count; i++) {
 		cc->tfms[i] = crypto_alloc_skcipher(ciphermode, 0, 0);
 		if (IS_ERR(cc->tfms[i])) {
-			err = PTR_ERR(cc->tfms[i]);
+			int err = PTR_ERR(cc->tfms[i]);
+
 			crypt_free_tfms(cc);
 			return err;
 		}
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-28 15:38   ` [PATCH 02/10] md/dm-crypt: Reduce the scope for a variable in crypt_alloc_tfms() SF Markus Elfring
@ 2016-09-28 15:40   ` SF Markus Elfring
  2016-09-29 12:55     ` [dm-devel] " Theodore Ts'o
  2016-09-28 15:41   ` [PATCH 04/10] md/dm-crypt: Delete an unnecessary variable initialisation in crypt_message() SF Markus Elfring
                     ` (6 subsequent siblings)
  10 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:40 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 14:54:39 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 88a3b62..08e3de2 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2016,7 +2016,7 @@ static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
 	int ret = -EINVAL;
 
 	if (argc < 2)
-		goto error;
+		goto show_warning;
 
 	if (!strcasecmp(argv[0], "key")) {
 		if (!test_bit(DM_CRYPT_SUSPENDED, &cc->flags)) {
@@ -2040,8 +2040,7 @@ static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
 			return crypt_wipe_key(cc);
 		}
 	}
-
-error:
+show_warning:
 	DMWARN("unrecognised message received.");
 	return -EINVAL;
 }
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 04/10] md/dm-crypt: Delete an unnecessary variable initialisation in crypt_message()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-28 15:40   ` [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message() SF Markus Elfring
@ 2016-09-28 15:41   ` SF Markus Elfring
  2016-09-28 15:42   ` [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key() SF Markus Elfring
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:41 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 15:06:05 +0200

The local variable "ret" will be set to an appropriate value in if branches.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 08e3de2..7778e9b 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -2013,7 +2013,7 @@ static void crypt_resume(struct dm_target *ti)
 static int crypt_message(struct dm_target *ti, unsigned argc, char **argv)
 {
 	struct crypt_config *cc = ti->private;
-	int ret = -EINVAL;
+	int ret;
 
 	if (argc < 2)
 		goto show_warning;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-28 15:41   ` [PATCH 04/10] md/dm-crypt: Delete an unnecessary variable initialisation in crypt_message() SF Markus Elfring
@ 2016-09-28 15:42   ` SF Markus Elfring
  2016-09-29 12:56     ` [dm-devel] " Theodore Ts'o
  2016-09-28 15:43   ` [PATCH 06/10] md/dm-crypt: Delete an unnecessary variable initialisation " SF Markus Elfring
                     ` (4 subsequent siblings)
  10 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:42 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 15:21:18 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 7778e9b..7e0fd82 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1496,20 +1496,19 @@ static int crypt_set_key(struct crypt_config *cc, char *key)
 
 	/* The key size may not be changed. */
 	if (cc->key_size != (key_string_len >> 1))
-		goto out;
+		goto set_memory;
 
 	/* Hyphen (which gives a key_size of zero) means there is no key. */
 	if (!cc->key_size && strcmp(key, "-"))
-		goto out;
+		goto set_memory;
 
 	if (cc->key_size && crypt_decode_key(cc->key, key, cc->key_size) < 0)
-		goto out;
+		goto set_memory;
 
 	set_bit(DM_CRYPT_KEY_VALID, &cc->flags);
 
 	r = crypt_setkey_allcpus(cc);
-
-out:
+set_memory:
 	/* Hex key string not needed after here, so wipe it. */
 	memset(key, '0', key_string_len);
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 06/10] md/dm-crypt: Delete an unnecessary variable initialisation in crypt_set_key()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-28 15:42   ` [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key() SF Markus Elfring
@ 2016-09-28 15:43   ` SF Markus Elfring
  2016-09-28 15:44   ` [PATCH 07/10] md/dm-crypt: Rename a jump label in crypt_iv_tcw_whitening() SF Markus Elfring
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:43 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 15:24:13 +0200

The local variable "r" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 7e0fd82..3bc54c1 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -1491,7 +1491,7 @@ static int crypt_setkey_allcpus(struct crypt_config *cc)
 
 static int crypt_set_key(struct crypt_config *cc, char *key)
 {
-	int r = -EINVAL;
+	int r;
 	int key_string_len = strlen(key);
 
 	/* The key size may not be changed. */
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 07/10] md/dm-crypt: Rename a jump label in crypt_iv_tcw_whitening()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-28 15:43   ` [PATCH 06/10] md/dm-crypt: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2016-09-28 15:44   ` SF Markus Elfring
  2016-09-28 15:45   ` [PATCH 08/10] md/dm-crypt: Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr() SF Markus Elfring
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:44 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 15:32:15 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 3bc54c1..c457b5e 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -698,13 +698,13 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc,
 	for (i = 0; i < 4; i++) {
 		r = crypto_shash_init(desc);
 		if (r)
-			goto out;
+			goto zero_memory;
 		r = crypto_shash_update(desc, &buf[i * 4], 4);
 		if (r)
-			goto out;
+			goto zero_memory;
 		r = crypto_shash_final(desc, &buf[i * 4]);
 		if (r)
-			goto out;
+			goto zero_memory;
 	}
 	crypto_xor(&buf[0], &buf[12], 4);
 	crypto_xor(&buf[4], &buf[8], 4);
@@ -712,7 +712,7 @@ static int crypt_iv_tcw_whitening(struct crypt_config *cc,
 	/* apply whitening (8 bytes) to whole sector */
 	for (i = 0; i < ((1 << SECTOR_SHIFT) / 8); i++)
 		crypto_xor(data + i * 8, buf, 8);
-out:
+zero_memory:
 	memzero_explicit(buf, sizeof(buf));
 	return r;
 }
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 08/10] md/dm-crypt: Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-28 15:44   ` [PATCH 07/10] md/dm-crypt: Rename a jump label in crypt_iv_tcw_whitening() SF Markus Elfring
@ 2016-09-28 15:45   ` SF Markus Elfring
  2016-09-28 15:46   ` [PATCH 09/10] md/dm-crypt: Two checks and one function call less in crypt_iv_essiv_ctr() after error detection SF Markus Elfring
  2016-09-28 15:47   ` [PATCH 10/10] md/dm-crypt: Delete unnecessary variable initialisations in crypt_iv_essiv_ctr() SF Markus Elfring
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:45 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 15:55:47 +0200

Return directly after a call of the function "crypto_alloc_ahash"
failed here.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index c457b5e..47f6265 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -375,8 +375,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
 	hash_tfm = crypto_alloc_ahash(opts, 0, CRYPTO_ALG_ASYNC);
 	if (IS_ERR(hash_tfm)) {
 		ti->error = "Error initializing ESSIV hash";
-		err = PTR_ERR(hash_tfm);
-		goto bad;
+		return PTR_ERR(hash_tfm);
 	}
 
 	salt = kzalloc(crypto_ahash_digestsize(hash_tfm), GFP_KERNEL);
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 09/10] md/dm-crypt: Two checks and one function call less in crypt_iv_essiv_ctr() after error detection
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-28 15:45   ` [PATCH 08/10] md/dm-crypt: Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr() SF Markus Elfring
@ 2016-09-28 15:46   ` SF Markus Elfring
  2016-09-28 15:47   ` [PATCH 10/10] md/dm-crypt: Delete unnecessary variable initialisations in crypt_iv_essiv_ctr() SF Markus Elfring
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:46 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 16:38:37 +0200

The kfree() function was called in one case by the crypt_iv_essiv_ctr()
function during error handling even if the passed variable "salt"
contained a null pointer.

* Adjust a jump target according to the Linux coding style convention.

* Delete this function call and a condition check which became unnecessary
  with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 47f6265..53a9155 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -382,7 +382,7 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
 	if (!salt) {
 		ti->error = "Error kmallocing salt storage in ESSIV";
 		err = -ENOMEM;
-		goto bad;
+		goto free_hash;
 	}
 
 	cc->iv_gen_private.essiv.salt = salt;
@@ -397,11 +397,8 @@ static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
 	cc->iv_private = essiv_tfm;
 
 	return 0;
-
-bad:
-	if (hash_tfm && !IS_ERR(hash_tfm))
-		crypto_free_ahash(hash_tfm);
-	kfree(salt);
+free_hash:
+	crypto_free_ahash(hash_tfm);
 	return err;
 }
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 10/10] md/dm-crypt: Delete unnecessary variable initialisations in crypt_iv_essiv_ctr()
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-28 15:46   ` [PATCH 09/10] md/dm-crypt: Two checks and one function call less in crypt_iv_essiv_ctr() after error detection SF Markus Elfring
@ 2016-09-28 15:47   ` SF Markus Elfring
  10 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-28 15:47 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 16:44:32 +0200

Three local variables will be set to an appropriate pointer a bit later.
Thus omit the explicit initialisation which became unnecessary with
a previous update step.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-crypt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 53a9155..d27716e 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -361,9 +361,9 @@ static void crypt_iv_essiv_dtr(struct crypt_config *cc)
 static int crypt_iv_essiv_ctr(struct crypt_config *cc, struct dm_target *ti,
 			      const char *opts)
 {
-	struct crypto_cipher *essiv_tfm = NULL;
-	struct crypto_ahash *hash_tfm = NULL;
-	u8 *salt = NULL;
+	struct crypto_cipher *essiv_tfm;
+	struct crypto_ahash *hash_tfm;
+	u8 *salt;
 	int err;
 
 	if (!opts) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()
  2016-09-27 16:45   ` [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() SF Markus Elfring
@ 2016-09-28 19:51     ` Jes Sorensen
  0 siblings, 0 replies; 221+ messages in thread
From: Jes Sorensen @ 2016-09-28 19:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Shaohua Li, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 27 Sep 2016 13:01:07 +0200
>
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
>
>   This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data type 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/bitmap.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index 13041ee..8cfb02c 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -760,9 +760,9 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
>  
>  	num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
>  	offset = slot_number * num_pages;
> -
> -	store->filemap = kmalloc(sizeof(struct page *)
> -				 * num_pages, GFP_KERNEL);
> +	store->filemap = kmalloc_array(num_pages,
> +				       sizeof(*store->filemap),
> +				       GFP_KERNEL);

If you have to make cosmetic changes for the sake of it, then at least
use the 80 characters per line that you have available.

This one makes the code uglier.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()
  2016-09-27 16:55   ` [PATCH 08/16] md/bitmap: Rename a jump label in location_store() SF Markus Elfring
@ 2016-09-28 19:55     ` Jes Sorensen
  2016-09-29  3:16       ` Guoqing Jiang
  0 siblings, 1 reply; 221+ messages in thread
From: Jes Sorensen @ 2016-09-28 19:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Shaohua Li, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 27 Sep 2016 15:46:22 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/md/bitmap.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

Sorry but this patch is just plain ridiculous. It does not improve the
code in any shape or form.

'out' as a label is perfectly legitimate and just as good as 'unlock'.

Jes

> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index 41d99fd..22fa09a 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -2187,11 +2187,11 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
>  	if (mddev->pers) {
>  		if (!mddev->pers->quiesce) {
>  			rv = -EBUSY;
> -			goto out;
> +			goto unlock;
>  		}
>  		if (mddev->recovery || mddev->sync_thread) {
>  			rv = -EBUSY;
> -			goto out;
> +			goto unlock;
>  		}
>  	}
>  
> @@ -2200,7 +2200,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
>  		/* bitmap already configured.  Only option is to clear it */
>  		if (strncmp(buf, "none", 4) != 0) {
>  			rv = -EBUSY;
> -			goto out;
> +			goto unlock;
>  		}
>  		if (mddev->pers) {
>  			mddev->pers->quiesce(mddev, 1);
> @@ -2221,23 +2221,23 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
>  		else if (strncmp(buf, "file:", 5) == 0) {
>  			/* Not supported yet */
>  			rv = -EINVAL;
> -			goto out;
> +			goto unlock;
>  		} else {
>  			if (buf[0] == '+')
>  				rv = kstrtoll(buf+1, 10, &offset);
>  			else
>  				rv = kstrtoll(buf, 10, &offset);
>  			if (rv)
> -				goto out;
> +				goto unlock;
>  			if (offset == 0) {
>  				rv = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  			if (mddev->bitmap_info.external == 0 &&
>  			    mddev->major_version == 0 &&
>  			    offset != mddev->bitmap_info.default_offset) {
>  				rv = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  			mddev->bitmap_info.offset = offset;
>  			if (mddev->pers) {
> @@ -2255,7 +2255,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
>  				mddev->pers->quiesce(mddev, 0);
>  				if (rv) {
>  					bitmap_destroy(mddev);
> -					goto out;
> +					goto unlock;
>  				}
>  			}
>  		}
> @@ -2268,7 +2268,7 @@ location_store(struct mddev *mddev, const char *buf, size_t len)
>  		md_wakeup_thread(mddev->thread);
>  	}
>  	rv = 0;
> -out:
> +unlock:
>  	mddev_unlock(mddev);
>  	if (rv)
>  		return rv;

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()
  2016-09-28 19:55     ` Jes Sorensen
@ 2016-09-29  3:16       ` Guoqing Jiang
  0 siblings, 0 replies; 221+ messages in thread
From: Guoqing Jiang @ 2016-09-29  3:16 UTC (permalink / raw)
  To: Jes Sorensen, SF Markus Elfring
  Cc: linux-raid, Shaohua Li, LKML, kernel-janitors, Julia Lawall



On 09/28/2016 03:55 PM, Jes Sorensen wrote:
> SF Markus Elfring <elfring@users.sourceforge.net> writes:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Tue, 27 Sep 2016 15:46:22 +0200
>>
>> Adjust jump labels according to the current Linux coding style convention.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>   drivers/md/bitmap.c | 18 +++++++++---------
>>   1 file changed, 9 insertions(+), 9 deletions(-)
> Sorry but this patch is just plain ridiculous. It does not improve the
> code in any shape or form.
>
> 'out' as a label is perfectly legitimate and just as good as 'unlock'.

Agree, I also curious which document recorded the coding style convention.

Thanks,
Guoqing


^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
  2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
@ 2016-09-29  9:02 ` SF Markus Elfring
  2016-09-29  9:07   ` [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
                     ` (9 more replies)
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                   ` (2 subsequent siblings)
  5 siblings, 10 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:02 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 10:35:43 +0200

Some update suggestions were taken into account
from static source code analysis.

Markus Elfring (10):
  Use kmalloc_array() in init_origin_hash()
  Delete two error messages for a failed memory allocation
  Delete an unnecessary variable initialisation in snapshot_map()
  Rename a jump label in pending_complete()
  Delete unnecessary variable initialisations in pending_complete()
  Delete an unnecessary variable initialisation in snapshot_ctr()
  Delete an unnecessary variable initialisation in merge_callback()
  Delete an unnecessary variable initialisation in remove_single_exception_chunk()
  Combine substrings for seven error messages
  Delete five unwanted spaces behind "list_for_each_entry"

 drivers/md/dm-snap.c | 69 +++++++++++++++++++++++-----------------------------
 1 file changed, 30 insertions(+), 39 deletions(-)

-- 
2.10.0


^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-29  9:07   ` SF Markus Elfring
  2016-09-29  9:54     ` Paul Bolle
  2016-09-29  9:10   ` [PATCH 02/10] dm snapshot: Delete two error messages for a failed memory allocation SF Markus Elfring
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:07 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 22:20:08 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  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/dm-snap.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index c65feea..f262f7e 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -326,8 +326,9 @@ static int init_origin_hash(void)
 {
 	int i;
 
-	_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
-			   GFP_KERNEL);
+	_origins = kmalloc_array(ORIGIN_HASH_SIZE,
+				 sizeof(*_origins),
+				 GFP_KERNEL);
 	if (!_origins) {
 		DMERR("unable to allocate memory for _origins");
 		return -ENOMEM;
@@ -335,8 +336,9 @@ static int init_origin_hash(void)
 	for (i = 0; i < ORIGIN_HASH_SIZE; i++)
 		INIT_LIST_HEAD(_origins + i);
 
-	_dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
-			      GFP_KERNEL);
+	_dm_origins = kmalloc_array(ORIGIN_HASH_SIZE,
+				    sizeof(*_dm_origins),
+				    GFP_KERNEL);
 	if (!_dm_origins) {
 		DMERR("unable to allocate memory for _dm_origins");
 		kfree(_origins);
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 02/10] dm snapshot: Delete two error messages for a failed memory allocation
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-29  9:07   ` [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
@ 2016-09-29  9:10   ` SF Markus Elfring
  2016-09-29  9:11   ` [PATCH 03/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_map() SF Markus Elfring
                     ` (7 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:10 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 28 Sep 2016 22:33:09 +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/dm-snap.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index f262f7e..7d81390 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -329,10 +329,8 @@ static int init_origin_hash(void)
 	_origins = kmalloc_array(ORIGIN_HASH_SIZE,
 				 sizeof(*_origins),
 				 GFP_KERNEL);
-	if (!_origins) {
-		DMERR("unable to allocate memory for _origins");
+	if (!_origins)
 		return -ENOMEM;
-	}
 	for (i = 0; i < ORIGIN_HASH_SIZE; i++)
 		INIT_LIST_HEAD(_origins + i);
 
@@ -340,7 +338,6 @@ static int init_origin_hash(void)
 				    sizeof(*_dm_origins),
 				    GFP_KERNEL);
 	if (!_dm_origins) {
-		DMERR("unable to allocate memory for _dm_origins");
 		kfree(_origins);
 		return -ENOMEM;
 	}
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 03/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_map()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-29  9:07   ` [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
  2016-09-29  9:10   ` [PATCH 02/10] dm snapshot: Delete two error messages for a failed memory allocation SF Markus Elfring
@ 2016-09-29  9:11   ` SF Markus Elfring
  2016-09-29  9:12   ` [PATCH 04/10] dm snapshot: Rename a jump label in pending_complete() SF Markus Elfring
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:11 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 08:00:29 +0200

The local variable "pe" 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/dm-snap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7d81390..82b7604 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1675,7 +1675,7 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio)
 	struct dm_snapshot *s = ti->private;
 	int r = DM_MAPIO_REMAPPED;
 	chunk_t chunk;
-	struct dm_snap_pending_exception *pe = NULL;
+	struct dm_snap_pending_exception *pe;
 
 	init_tracked_chunk(bio);
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 04/10] dm snapshot: Rename a jump label in pending_complete()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-29  9:11   ` [PATCH 03/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_map() SF Markus Elfring
@ 2016-09-29  9:12   ` SF Markus Elfring
  2016-09-29  9:13   ` [PATCH 05/10] dm snapshot: Delete unnecessary variable initialisations " SF Markus Elfring
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:12 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 08:18:51 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-snap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 82b7604..a6b797f 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1460,7 +1460,7 @@ static void pending_complete(void *context, int success)
 		down_write(&s->lock);
 		__invalidate_snapshot(s, -EIO);
 		error = 1;
-		goto out;
+		goto remove_exception;
 	}
 
 	e = alloc_completed_exception(GFP_NOIO);
@@ -1468,7 +1468,7 @@ static void pending_complete(void *context, int success)
 		down_write(&s->lock);
 		__invalidate_snapshot(s, -ENOMEM);
 		error = 1;
-		goto out;
+		goto remove_exception;
 	}
 	*e = pe->e;
 
@@ -1476,7 +1476,7 @@ static void pending_complete(void *context, int success)
 	if (!s->valid) {
 		free_completed_exception(e);
 		error = 1;
-		goto out;
+		goto remove_exception;
 	}
 
 	/* Check for conflicting reads */
@@ -1487,8 +1487,7 @@ static void pending_complete(void *context, int success)
 	 * in-flight exception from the list.
 	 */
 	dm_insert_exception(&s->complete, e);
-
-out:
+remove_exception:
 	dm_remove_exception(&pe->e);
 	snapshot_bios = bio_list_get(&pe->snapshot_bios);
 	origin_bios = bio_list_get(&pe->origin_bios);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 05/10] dm snapshot: Delete unnecessary variable initialisations in pending_complete()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-29  9:12   ` [PATCH 04/10] dm snapshot: Rename a jump label in pending_complete() SF Markus Elfring
@ 2016-09-29  9:13   ` SF Markus Elfring
  2016-09-29  9:14   ` [PATCH 06/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_ctr() SF Markus Elfring
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:13 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 08:25:47 +0200

Three local variables 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/dm-snap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index a6b797f..7bbd3c4 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1450,9 +1450,9 @@ static void pending_complete(void *context, int success)
 	struct dm_snap_pending_exception *pe = context;
 	struct dm_exception *e;
 	struct dm_snapshot *s = pe->snap;
-	struct bio *origin_bios = NULL;
-	struct bio *snapshot_bios = NULL;
-	struct bio *full_bio = NULL;
+	struct bio *origin_bios;
+	struct bio *snapshot_bios;
+	struct bio *full_bio;
 	int error = 0;
 
 	if (!success) {
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 06/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_ctr()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-29  9:13   ` [PATCH 05/10] dm snapshot: Delete unnecessary variable initialisations " SF Markus Elfring
@ 2016-09-29  9:14   ` SF Markus Elfring
  2016-09-29  9:15   ` [PATCH 07/10] dm snapshot: Delete an unnecessary variable initialisation in merge_callback() SF Markus Elfring
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:14 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 08:38:29 +0200

The local variable "r" will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-snap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7bbd3c4..06b1b69 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1102,7 +1102,7 @@ static int snapshot_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 {
 	struct dm_snapshot *s;
 	int i;
-	int r = -EINVAL;
+	int r;
 	char *origin_path, *cow_path;
 	dev_t origin_dev, cow_dev;
 	unsigned args_used, num_flush_bios = 1;
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 07/10] dm snapshot: Delete an unnecessary variable initialisation in merge_callback()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-29  9:14   ` [PATCH 06/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_ctr() SF Markus Elfring
@ 2016-09-29  9:15   ` SF Markus Elfring
  2016-09-29  9:16   ` [PATCH 08/10] dm snapshot: Delete an unnecessary variable initialisation in remove_single_exception_chunk() SF Markus Elfring
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:15 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 09:00:06 +0200

The local variable "b" 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/dm-snap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 06b1b69..1d90131 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -1046,7 +1046,7 @@ static void error_bios(struct bio *bio);
 static void merge_callback(int read_err, unsigned long write_err, void *context)
 {
 	struct dm_snapshot *s = context;
-	struct bio *b = NULL;
+	struct bio *b;
 
 	if (read_err || write_err) {
 		if (read_err)
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 08/10] dm snapshot: Delete an unnecessary variable initialisation in remove_single_exception_chunk()
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-29  9:15   ` [PATCH 07/10] dm snapshot: Delete an unnecessary variable initialisation in merge_callback() SF Markus Elfring
@ 2016-09-29  9:16   ` SF Markus Elfring
  2016-09-29  9:17   ` [PATCH 09/10] dm snapshot: Combine substrings for seven error messages SF Markus Elfring
  2016-09-29  9:18   ` [PATCH 10/10] dm snapshot: Delete five unwanted spaces behind "list_for_each_entry" SF Markus Elfring
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:16 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 09:06:37 +0200

The local variable "b" 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/dm-snap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 1d90131..4966584 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -904,7 +904,7 @@ static void flush_bios(struct bio *bio);
 
 static int remove_single_exception_chunk(struct dm_snapshot *s)
 {
-	struct bio *b = NULL;
+	struct bio *b;
 	int r;
 	chunk_t old_chunk = s->first_merging_chunk + s->num_merging_chunks - 1;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 09/10] dm snapshot: Combine substrings for seven error messages
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-29  9:16   ` [PATCH 08/10] dm snapshot: Delete an unnecessary variable initialisation in remove_single_exception_chunk() SF Markus Elfring
@ 2016-09-29  9:17   ` SF Markus Elfring
  2016-09-29  9:18   ` [PATCH 10/10] dm snapshot: Delete five unwanted spaces behind "list_for_each_entry" SF Markus Elfring
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:17 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 09:46:32 +0200

The script "checkpatch.pl" can point information out like the following.

WARNING: quoted string split across lines

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/dm-snap.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 4966584..7593986 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -468,8 +468,7 @@ static int __validate_exception_handover(struct dm_snapshot *snap)
 	if ((__find_snapshots_sharing_cow(snap, &snap_src, &snap_dest,
 					  &snap_merge) == 2) ||
 	    snap_dest) {
-		snap->ti->error = "Snapshot cow pairing for exception "
-				  "table handover failed";
+		snap->ti->error = "Snapshot cow pairing for exception table handover failed";
 		return -EINVAL;
 	}
 
@@ -496,8 +495,7 @@ static int __validate_exception_handover(struct dm_snapshot *snap)
 
 	if (!snap_src->store->type->prepare_merge ||
 	    !snap_src->store->type->commit_merge) {
-		snap->ti->error = "Snapshot exception store does not "
-				  "support snapshot-merge.";
+		snap->ti->error = "Snapshot exception store does not support snapshot-merge.";
 		return -EINVAL;
 	}
 
@@ -858,8 +856,7 @@ static int __remove_single_exception_chunk(struct dm_snapshot *s,
 
 	e = dm_lookup_exception(&s->complete, old_chunk);
 	if (!e) {
-		DMERR("Corruption detected: exception for block %llu is "
-		      "on disk but not in memory",
+		DMERR("Corruption detected: exception for block %llu is on disk but not in memory",
 		      (unsigned long long)old_chunk);
 		return -EINVAL;
 	}
@@ -886,8 +883,7 @@ static int __remove_single_exception_chunk(struct dm_snapshot *s,
 		e->new_chunk++;
 	} else if (old_chunk != e->old_chunk +
 		   dm_consecutive_chunk_count(e)) {
-		DMERR("Attempt to merge block %llu from the "
-		      "middle of a chunk range [%llu - %llu]",
+		DMERR("Attempt to merge block %llu from the middle of a chunk range [%llu - %llu]",
 		      (unsigned long long)old_chunk,
 		      (unsigned long long)e->old_chunk,
 		      (unsigned long long)
@@ -980,8 +976,7 @@ static void snapshot_merge_next_chunks(struct dm_snapshot *s)
 						      &new_chunk);
 	if (linear_chunks <= 0) {
 		if (linear_chunks < 0) {
-			DMERR("Read error in exception store: "
-			      "shutting down merge");
+			DMERR("Read error in exception store: shutting down merge");
 			down_write(&s->lock);
 			s->merge_failed = 1;
 			up_write(&s->lock);
@@ -1877,12 +1872,10 @@ static int snapshot_preresume(struct dm_target *ti)
 	if (snap_src && snap_dest) {
 		down_read(&snap_src->lock);
 		if (s == snap_src) {
-			DMERR("Unable to resume snapshot source until "
-			      "handover completes.");
+			DMERR("Unable to resume snapshot source until handover completes.");
 			r = -EINVAL;
 		} else if (!dm_suspended(snap_src->ti)) {
-			DMERR("Unable to perform snapshot handover until "
-			      "source is suspended.");
+			DMERR("Unable to perform snapshot handover until source is suspended.");
 			r = -EINVAL;
 		}
 		up_read(&snap_src->lock);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 10/10] dm snapshot: Delete five unwanted spaces behind "list_for_each_entry"
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-29  9:17   ` [PATCH 09/10] dm snapshot: Combine substrings for seven error messages SF Markus Elfring
@ 2016-09-29  9:18   ` SF Markus Elfring
  9 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29  9:18 UTC (permalink / raw)
  To: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 29 Sep 2016 10:14:32 +0200

The script "checkpatch.pl" can point 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/dm-snap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c
index 7593986..1310652 100644
--- a/drivers/md/dm-snap.c
+++ b/drivers/md/dm-snap.c
@@ -366,7 +366,7 @@ static struct origin *__lookup_origin(struct block_device *origin)
 	struct origin *o;
 
 	ol = &_origins[origin_hash(origin)];
-	list_for_each_entry (o, ol, hash_list)
+	list_for_each_entry(o, ol, hash_list)
 		if (bdev_equal(o->bdev, origin))
 			return o;
 
@@ -385,7 +385,7 @@ static struct dm_origin *__lookup_dm_origin(struct block_device *origin)
 	struct dm_origin *o;
 
 	ol = &_dm_origins[origin_hash(origin)];
-	list_for_each_entry (o, ol, hash_list)
+	list_for_each_entry(o, ol, hash_list)
 		if (bdev_equal(o->dev->bdev, origin))
 			return o;
 
@@ -625,7 +625,7 @@ static void dm_exception_table_exit(struct dm_exception_table *et,
 	for (i = 0; i < size; i++) {
 		slot = et->table + i;
 
-		list_for_each_entry_safe (ex, next, slot, hash_list)
+		list_for_each_entry_safe(ex, next, slot, hash_list)
 			kmem_cache_free(mem, ex);
 	}
 
@@ -653,7 +653,7 @@ static struct dm_exception *dm_lookup_exception(struct dm_exception_table *et,
 	struct dm_exception *e;
 
 	slot = &et->table[exception_hash(et, chunk)];
-	list_for_each_entry (e, slot, hash_list)
+	list_for_each_entry(e, slot, hash_list)
 		if (chunk >= e->old_chunk &&
 		    chunk <= e->old_chunk + dm_consecutive_chunk_count(e))
 			return e;
@@ -2068,7 +2068,7 @@ static int __origin_write(struct list_head *snapshots, sector_t sector,
 	chunk_t chunk;
 
 	/* Do all the snapshots on this origin */
-	list_for_each_entry (snap, snapshots, list) {
+	list_for_each_entry(snap, snapshots, list) {
 		/*
 		 * Don't make new exceptions in a merging snapshot
 		 * because it has effectively been deleted
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29  9:07   ` [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
@ 2016-09-29  9:54     ` Paul Bolle
  2016-09-29 10:02       ` Joe Perches
  2016-09-29 11:45       ` dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
  0 siblings, 2 replies; 221+ messages in thread
From: Paul Bolle @ 2016-09-29  9:54 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

Andy, Joe,

On Thu, 2016-09-29 at 11:07 +0200, SF Markus Elfring wrote:
> * Multiplications for the size determination of memory allocations
>   indicated that array data structures should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.

We have no hope of fixing Markus' homegrown coccinelle script. But we
could try to fix the checkpatch false positive here. Something like:

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 206a6b3..b47201d 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5693,7 +5693,7 @@ sub process {
 				$r2 = $a1;
 			}
 			if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ &&
-			    !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) {
+			    !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*\b/)) {
 				if (WARN("ALLOC_WITH_MULTIPLY",
 					 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) &&
 				    $fix) {

Does that work for you too?

> --- a/drivers/md/dm-snap.c
> +++ b/drivers/md/dm-snap.c
> @@ -326,8 +326,9 @@ static int init_origin_hash(void)
>  {
>  	int i;
>  
> -	_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
> -			   GFP_KERNEL);
> +	_origins = kmalloc_array(ORIGIN_HASH_SIZE,
> +				 sizeof(*_origins),
> +				 GFP_KERNEL);
>  	if (!_origins) {
>  		DMERR("unable to allocate memory for _origins");
>  		return -ENOMEM;
> @@ -335,8 +336,9 @@ static int init_origin_hash(void)
>  	for (i = 0; i < ORIGIN_HASH_SIZE; i++)
>  		INIT_LIST_HEAD(_origins + i);
>  
> -	_dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
> -			      GFP_KERNEL);
> +	_dm_origins = kmalloc_array(ORIGIN_HASH_SIZE,
> +				    sizeof(*_dm_origins),
> +				    GFP_KERNEL);
>  	if (!_dm_origins) {
>  		DMERR("unable to allocate memory for _dm_origins");
>  		kfree(_origins);

Thanks,


Paul Bolle

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29  9:54     ` Paul Bolle
@ 2016-09-29 10:02       ` Joe Perches
  2016-09-29 11:12         ` Paul Bolle
  2016-09-29 11:45       ` dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
  1 sibling, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-09-29 10:02 UTC (permalink / raw)
  To: Paul Bolle, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 11:54 +0200, Paul Bolle wrote:
> Andy, Joe,
> 
> On Thu, 2016-09-29 at 11:07 +0200, SF Markus Elfring wrote:
> > * Multiplications for the size determination of memory allocations
> >   indicated that array data structures should be processed.
> >   Thus use the corresponding function "kmalloc_array".
> > 
> >   This issue was detected by using the Coccinelle software.
> 
> 
> We have no hope of fixing Markus' homegrown coccinelle script. But we
> could try to fix the checkpatch false positive here.

What's the false positive?

I get:

$ ./scripts/checkpatch.pl -f drivers/md/dm-snap.c --show-types --types=alloc_with_multiply
WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
#329: FILE: drivers/md/dm-snap.c:329:
+	_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),

WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
#338: FILE: drivers/md/dm-snap.c:338:
+	_dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),

total: 0 errors, 2 warnings, 2490 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

drivers/md/dm-snap.c has style problems, please review.

NOTE: Used message types: ALLOC_WITH_MULTIPLY

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 10:02       ` Joe Perches
@ 2016-09-29 11:12         ` Paul Bolle
  2016-09-29 11:45           ` Paul Bolle
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 11:12 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 03:02 -0700, Joe Perches wrote:
> What's the false positive?
> 
> I get:
> 
> $ ./scripts/checkpatch.pl -f drivers/md/dm-snap.c --show-types --types=alloc_with_multiply
> WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
> #329: FILE: drivers/md/dm-snap.c:329:
> +	_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
> 
> WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
> #338: FILE: drivers/md/dm-snap.c:338:
> +	_dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
> 
> total: 0 errors, 2 warnings, 2490 lines checked
> 
> NOTE: For some of the reported defects, checkpatch may be able to
>       mechanically convert to the typical style using --fix or --fix-inplace.
> 
> drivers/md/dm-snap.c has style problems, please review.
> 
> NOTE: Used message types: ALLOC_WITH_MULTIPLY
> 
> NOTE: If any of the errors are false positives, please report
>       them to the maintainer, see CHECKPATCH in MAINTAINERS.

It seems it was intended to be silent about multiplying with constants,
where things that look like preprocessor defines are also considered
constants. Or did I misread that test?


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 11:12         ` Paul Bolle
@ 2016-09-29 11:45           ` Paul Bolle
  2016-09-29 15:01             ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 11:45 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 13:12 +0200, Paul Bolle wrote:
> Or did I misread that test?

I finally did some digging: commit e367455a9f25 ("checkpatch: emit
fewer kmalloc_array/kcalloc conversion warnings") shows I didn't.


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29  9:54     ` Paul Bolle
  2016-09-29 10:02       ` Joe Perches
@ 2016-09-29 11:45       ` SF Markus Elfring
  2016-09-29 12:59         ` Theodore Ts'o
  1 sibling, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29 11:45 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Andy Whitcroft, Joe Perches, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

> We have no hope of fixing Markus' homegrown coccinelle script.

I have got an other impression. I see further possibilities
to clarify involved communication and software development challenges
for a few source code search patterns.

How do you think about to discuss the corresponding collateral evolution
a bit more?

Are there any more constraints to consider?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [dm-devel] [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message()
  2016-09-28 15:40   ` [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message() SF Markus Elfring
@ 2016-09-29 12:55     ` Theodore Ts'o
  2016-09-29 15:43       ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Theodore Ts'o @ 2016-09-29 12:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li,
	Julia Lawall, kernel-janitors, LKML

On Wed, Sep 28, 2016 at 05:40:14PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 28 Sep 2016 14:54:39 +0200
> 
> Adjust a jump label according to the current Linux coding style convention.

In what bizzaro world is the "current Linux coding style convention"

> -
> -error:
> +show_warning:
>  	DMWARN("unrecognised message received.");
>  	return -EINVAL;
>  }

"show_warning" is better than "error" when the net result of the goto
is that the function returns -EINVAL?!?

Please give it up with these drive-by shooting of auto-generated
patches.  You're just embarassing yourself.

							- Ted

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [dm-devel] [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key()
  2016-09-28 15:42   ` [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key() SF Markus Elfring
@ 2016-09-29 12:56     ` Theodore Ts'o
  0 siblings, 0 replies; 221+ messages in thread
From: Theodore Ts'o @ 2016-09-29 12:56 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li,
	Julia Lawall, kernel-janitors, LKML

On Wed, Sep 28, 2016 at 05:42:28PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 28 Sep 2016 15:21:18 +0200
> 
> Adjust jump labels according to the current Linux coding style convention.
> 
> -
> -out:
> +set_memory:
>  	/* Hex key string not needed after here, so wipe it. */
>  	memset(key, '0', key_string_len);

Also not "current Linux coding style convetion".

							- Ted


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 11:45       ` dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
@ 2016-09-29 12:59         ` Theodore Ts'o
  0 siblings, 0 replies; 221+ messages in thread
From: Theodore Ts'o @ 2016-09-29 12:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Paul Bolle, Andy Whitcroft, Joe Perches, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

On Thu, Sep 29, 2016 at 01:45:41PM +0200, SF Markus Elfring wrote:
> > We have no hope of fixing Markus' homegrown coccinelle script.
> 
> I have got an other impression. I see further possibilities
> to clarify involved communication and software development challenges
> for a few source code search patterns.
> 
> How do you think about to discuss the corresponding collateral evolution
> a bit more?

Here's my suggestion:

	https://www.youtube.com/watch?v=xAnVNXaa5oA

Regards,

					- Ted

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 11:45           ` Paul Bolle
@ 2016-09-29 15:01             ` Joe Perches
  2016-09-29 19:43               ` Paul Bolle
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-09-29 15:01 UTC (permalink / raw)
  To: Paul Bolle, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 13:45 +0200, Paul Bolle wrote:
> On Thu, 2016-09-29 at 13:12 +0200, Paul Bolle wrote:
> > Or did I misread that test?
> I finally did some digging: commit e367455a9f25 ("checkpatch: emit
> fewer kmalloc_array/kcalloc conversion warnings") shows I didn't.

You still misread it a little.
I think it's fine as-is.

$Constant there is any number and the match regex is
any upper case variable.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [dm-devel] [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message()
  2016-09-29 12:55     ` [dm-devel] " Theodore Ts'o
@ 2016-09-29 15:43       ` SF Markus Elfring
  2016-09-30 10:06         ` Dan Carpenter
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-29 15:43 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: dm-devel, linux-raid, Alasdair Kergon, Mike Snitzer, Shaohua Li,
	Julia Lawall, kernel-janitors, LKML

> In what bizzaro world is the "current Linux coding style convention"

Do you look at the evolution for a document like "CodingStyle"?


>> -
>> -error:
>> +show_warning:
>>  	DMWARN("unrecognised message received.");
>>  	return -EINVAL;
>>  }
> 
> "show_warning" is better than "error"

I got such an impression.


> when the net result of the goto is that the function returns -EINVAL?!?

Do other identifiers fit better for the desired description of "what" and "why"
by jump labels?


> Please give it up with these drive-by shooting of auto-generated patches.

This update step was not auto-generated.

There are further change possibilities where special analysis tools
can help in the corresponding software development.


> You're just embarassing yourself.

Do you find any of my update suggestions worth for further considerations?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 15:01             ` Joe Perches
@ 2016-09-29 19:43               ` Paul Bolle
  2016-09-29 20:24                 ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 19:43 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 08:01 -0700, Joe Perches wrote:
> $Constant there is any number and the match regex is
> any upper case variable.

Why doesn't that regex match on "ORIGIN_HASH_SIZE"?


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 19:43               ` Paul Bolle
@ 2016-09-29 20:24                 ` Joe Perches
  2016-09-29 20:39                   ` Paul Bolle
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-09-29 20:24 UTC (permalink / raw)
  To: Paul Bolle, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 21:43 +0200, Paul Bolle wrote:
> On Thu, 2016-09-29 at 08:01 -0700, Joe Perches wrote:
> > $Constant there is any number and the match regex is
> > any upper case variable.
> Why doesn't that regex match on "ORIGIN_HASH_SIZE"?

It does match.

Did you see my earlier email?

$ ./scripts/checkpatch.pl -f drivers/md/dm-snap.c --show-types --types=alloc_with_multiply
WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
#329: FILE: drivers/md/dm-snap.c:329:
+       _origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),

WARNING:ALLOC_WITH_MULTIPLY: Prefer kmalloc_array over kmalloc with multiply
#338: FILE: drivers/md/dm-snap.c:338:
+       _dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),

total: 0 errors, 2 warnings, 2490 lines checked

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 20:24                 ` Joe Perches
@ 2016-09-29 20:39                   ` Paul Bolle
  2016-09-29 20:56                     ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 20:39 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 13:24 -0700, Joe Perches wrote:
> On Thu, 2016-09-29 at 21:43 +0200, Paul Bolle wrote:
> > Why doesn't that regex match on "ORIGIN_HASH_SIZE"?
> 
> It does match.

If that regex does match, it being part of a negative test, the
specific checkpatch rule should be silent, shouldn't it?


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 20:39                   ` Paul Bolle
@ 2016-09-29 20:56                     ` Joe Perches
  2016-09-29 21:14                       ` Paul Bolle
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-09-29 20:56 UTC (permalink / raw)
  To: Paul Bolle, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 22:39 +0200, Paul Bolle wrote:
> On Thu, 2016-09-29 at 13:24 -0700, Joe Perches wrote:
> > On Thu, 2016-09-29 at 21:43 +0200, Paul Bolle wrote:
> > > Why doesn't that regex match on "ORIGIN_HASH_SIZE"?
> > It does match.
> If that regex does match, it being part of a negative test, the
> specific checkpatch rule should be silent, shouldn't it?

'cause I forgot to trim() the original $4 and $10 matches.

Oh well.

It doesn't matter match either way to me.

The case for the unnecessary multiply with <= gcc 4.8 was
removed with:

commit 91c6a05f72a996bee5133e76374ab3ad7d3b9b72
Author: Alexey Dobriyan <adobriyan@gmail.com>
Date:   Tue Jul 26 15:22:08 2016 -0700

    mm: faster kmalloc_array(), kcalloc()
    
    When both arguments to kmalloc_array() or kcalloc() are known at compile
    time then their product is known at compile time but search for kmalloc
    cache happens at runtime not at compile time.
    
    Link: http://lkml.kernel.org/r/20160627213454.GA2440@p183.telecom.by
    Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
    Cc: Christoph Lameter <cl@linux.com>
    Cc: Pekka Enberg <penberg@kernel.org>
    Cc: David Rientjes <rientjes@google.com>
    Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 20:56                     ` Joe Perches
@ 2016-09-29 21:14                       ` Paul Bolle
  2016-09-29 21:21                         ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 21:14 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 13:56 -0700, Joe Perches wrote:
> It doesn't matter match either way to me.
> 
> The case for the unnecessary multiply with <= gcc 4.8 was
> removed with:
> 
> commit 91c6a05f72a996bee5133e76374ab3ad7d3b9b72
> Author: Alexey Dobriyan <adobriyan@gmail.com>
> Date:   Tue Jul 26 15:22:08 2016 -0700
> 
>     mm: faster kmalloc_array(), kcalloc()
>     
>     When both arguments to kmalloc_array() or kcalloc() are known at compile
>     time then their product is known at compile time but search for kmalloc
>     cache happens at runtime not at compile time.
>     
>     Link: http://lkml.kernel.org/r/20160627213454.GA2440@p183.telecom.by
>     Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
>     Cc: Christoph Lameter <cl@linux.com>
>     Cc: Pekka Enberg <penberg@kernel.org>
>     Cc: David Rientjes <rientjes@google.com>
>     Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
>     Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>     Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

You've lost me.

Why does this stop you fixing an apparently wrong checkpatch rule,
crude as parts of it are (ie, uppercase identifier must be a constant)?


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 21:14                       ` Paul Bolle
@ 2016-09-29 21:21                         ` Joe Perches
  2016-09-29 21:42                           ` Paul Bolle
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-09-29 21:21 UTC (permalink / raw)
  To: Paul Bolle, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 23:14 +0200, Paul Bolle wrote:
> On Thu, 2016-09-29 at 13:56 -0700, Joe Perches wrote:
> > It doesn't matter match either way to me.
> Why does this stop you fixing an apparently wrong checkpatch rule,
> crude as parts of it are (ie, uppercase identifier must be a constant)?

It doesn't.  It just doesn't matter much (match) to me.
Here:
---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 3373c65fef1c..fc931d89152e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5835,8 +5835,8 @@ sub process {
 		if ($^V && $^V ge 5.10.0 &&
 		    $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)\s*,/) {
 			my $oldfunc = $3;
-			my $a1 = $4;
-			my $a2 = $10;
+			my $a1 = trim($4);
+			my $a2 = trim($10);
 			my $newfunc = "kmalloc_array";
 			$newfunc = "kcalloc" if ($oldfunc eq "kzalloc");
 			my $r1 = $a1;
@@ -5850,7 +5850,7 @@ sub process {
 				if (WARN("ALLOC_WITH_MULTIPLY",
 					 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) &&
 				    $fix) {
-					$fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
+					$fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . $r1 . ', ' . $r2/e;
 
 				}
 			}


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash()
  2016-09-29 21:21                         ` Joe Perches
@ 2016-09-29 21:42                           ` Paul Bolle
  2016-09-30  7:14                             ` dm snapshot: Use kmalloc_array() in init_origin_hash() ? SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Paul Bolle @ 2016-09-29 21:42 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft
  Cc: SF Markus Elfring, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-29 at 14:21 -0700, Joe Perches wrote:
> > > It doesn't matter match either way to me.
> > Why does this stop you fixing an apparently wrong checkpatch rule,
> > crude as parts of it are (ie, uppercase identifier must be a
> > constant)?
> 
> It doesn't.  It just doesn't matter much (match) to me.

Joe, please.

I've recently ping-ponged with the kernel's "resident wrong bot of the
day" over this very rule (kmalloc_array() is safer than kmalloc(), so
change your driver now!). Could we just give wrong bots a bit less
ammunition whenever that's feasible?

Even if you don't care about my ping-pong experiences: this checkpatch
test is broken, please just fix it!


Paul Bolle

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: dm snapshot: Use kmalloc_array() in init_origin_hash() ?
  2016-09-29 21:42                           ` Paul Bolle
@ 2016-09-30  7:14                             ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-30  7:14 UTC (permalink / raw)
  To: Paul Bolle
  Cc: Joe Perches, Andy Whitcroft, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, LKML, kernel-janitors,
	Julia Lawall

> I've recently ping-ponged with the kernel's "resident wrong bot of the
> day" over this very rule (kmalloc_array() is safer than kmalloc(), so
> change your driver now!).

Your bot of the day is going to point more update candidates out
in various source files that can "accidentally" belong also to Linux. ;-)


> Could we just give wrong bots a bit less ammunition whenever that's feasible?

How do you think about to clarify constraints any further so that
the probability for false positives can be reduced as desired for
the involved source code analysis tools?


> Even if you don't care about my ping-pong experiences: this checkpatch
> test is broken, please just fix it!

I am curious how collateral software evolution will be continued.

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [dm-devel] [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message()
  2016-09-29 15:43       ` SF Markus Elfring
@ 2016-09-30 10:06         ` Dan Carpenter
  2016-09-30 11:32           ` md/dm-crypt: Rename a jump label in crypt_message() ? SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Dan Carpenter @ 2016-09-30 10:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Theodore Ts'o, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, Julia Lawall, kernel-janitors, LKML

On Thu, Sep 29, 2016 at 05:43:57PM +0200, SF Markus Elfring wrote:
> > In what bizzaro world is the "current Linux coding style convention"
> 
> Do you look at the evolution for a document like "CodingStyle"?
> 

Again, I wrote the paragraph in CodingStyle.  I just said that it's a
good idea to think about label names instead of using GW-BASIC style
numbered labels, I didn't say go around bothering everyone with waste
of time cleanup patches.

I specifically did not say that "out:" or "error:" labels are bad names.
Those are common style in the kernel.

Please stop sending these patches.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 10:06         ` Dan Carpenter
@ 2016-09-30 11:32           ` SF Markus Elfring
  2016-09-30 11:39             ` Bjørn Mork
  2016-09-30 12:02             ` Dan Carpenter
  0 siblings, 2 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-30 11:32 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Theodore Ts'o, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, Julia Lawall, kernel-janitors, LKML,
	linux-doc

> Again, I wrote the paragraph in CodingStyle.

This is obvious from the corresponding commit "add some more error
handling guidelines" (ea04036032edda6f771c1381d03832d2ed0f6c31
on 2014-12-02).


> I just said that it's a good idea to think about label names

I agree also to such a desire.


> instead of using GW-BASIC style numbered labels,

Is this kind of wording another weakness in the discussed document?
How many guidance do programmers get from such a software specification?

I came a few source code places along where I proposed corresponding changes.


> I didn't say

You did not say anything about some details as it is often easier to express
several aspects in vague and general terms.


> go around bothering everyone with waste of time cleanup patches.

I find it still debatable if the shown software development efforts
are really "wasted".

It seems that also the Linux development community is mixed about
related interpretations.


> I specifically did not say that "out:" or "error:" labels are bad names.

Did you inform me once that you had also a special opinion about an identifier
like "out"?

The C compiler will accept them as usual. But do we occasionally prefer
to express implementation details a bit better there?


> Those are common style in the kernel.

* Which impressions can you get from a statement like "goto fail;"
  or "goto error;"?

* Do any exception handling implementations should be reconsidered
  at such places?


> Please stop sending these patches.

Could it happen that the change acceptance will increase also for
the suggested renaming of jump labels if maintainers from other subsystems
would dare to respond once more in a positive way for such a software refactoring?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 11:32           ` md/dm-crypt: Rename a jump label in crypt_message() ? SF Markus Elfring
@ 2016-09-30 11:39             ` Bjørn Mork
  2016-09-30 11:53               ` SF Markus Elfring
  2016-09-30 12:02             ` Dan Carpenter
  1 sibling, 1 reply; 221+ messages in thread
From: Bjørn Mork @ 2016-09-30 11:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Theodore Ts'o, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, Julia Lawall,
	kernel-janitors, LKML, linux-doc

SF Markus Elfring <elfring@users.sourceforge.net> writes:

>> go around bothering everyone with waste of time cleanup patches.
>
> I find it still debatable if the shown software development efforts
> are really "wasted".

When someone tells you that you are wasting their time, then that is not
a subject for further discussion.


Bjørn

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 11:39             ` Bjørn Mork
@ 2016-09-30 11:53               ` SF Markus Elfring
  2016-09-30 12:06                 ` Bjørn Mork
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-30 11:53 UTC (permalink / raw)
  To: Bjørn Mork
  Cc: Dan Carpenter, Theodore Ts'o, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, Julia Lawall,
	kernel-janitors, LKML, linux-doc

> When someone tells you that you are wasting their time,

This information can be useful to some degree


> then that is not a subject for further discussion.

I got an other impression. I guess that there are constraints for such a response
which can become interesting for further considerations.

Is it just usual that other software changes are more welcome?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 11:32           ` md/dm-crypt: Rename a jump label in crypt_message() ? SF Markus Elfring
  2016-09-30 11:39             ` Bjørn Mork
@ 2016-09-30 12:02             ` Dan Carpenter
  2016-09-30 12:19               ` SF Markus Elfring
  1 sibling, 1 reply; 221+ messages in thread
From: Dan Carpenter @ 2016-09-30 12:02 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Theodore Ts'o, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, Julia Lawall, kernel-janitors, LKML,
	linux-doc

On Fri, Sep 30, 2016 at 01:32:23PM +0200, SF Markus Elfring wrote:
> > I specifically did not say that "out:" or "error:" labels are bad names.
> 
> Did you inform me once that you had also a special opinion about an identifier
> like "out"?

I don't like out labels, but that's my opinion.  There is nothing in
CodingStyle which says you can't do it.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 11:53               ` SF Markus Elfring
@ 2016-09-30 12:06                 ` Bjørn Mork
  2016-09-30 12:54                   ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Bjørn Mork @ 2016-09-30 12:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Theodore Ts'o, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, Julia Lawall,
	kernel-janitors, LKML, linux-doc

SF Markus Elfring <elfring@users.sourceforge.net> writes:

>> When someone tells you that you are wasting their time,
>
> This information can be useful to some degree

Yes.  If you continue discussing after that point, then you make a clear
statement that it isn't an accident.  You are deliberately wasting their
time.

A lot of people already know this.  But you're right that it would be
useful to make it even clearer.  Maybe you could add a note about it to
each patch?  Something along "I will not listen.  I will not change.
Nothing you tell me will ever make it worth your time to do so"?

Just an idea...



Bjørn

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 12:02             ` Dan Carpenter
@ 2016-09-30 12:19               ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-30 12:19 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Theodore Ts'o, dm-devel, linux-raid, Alasdair Kergon,
	Mike Snitzer, Shaohua Li, Julia Lawall, kernel-janitors, LKML,
	linux-doc

> I don't like out labels, but that's my opinion.

Thanks for this acknowledgement that you have still got a special opinion
about such an identifier.

 
> There is nothing in CodingStyle which says you can't do it.

Does the terse description there try to suggest also to choose
better identifiers for source code places?

Does the meaning of such a coding style specification include also
the selection of a more pleasing identifier than "error"
for this software module?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/dm-crypt: Rename a jump label in crypt_message() ?
  2016-09-30 12:06                 ` Bjørn Mork
@ 2016-09-30 12:54                   ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-09-30 12:54 UTC (permalink / raw)
  To: Bjørn Mork
  Cc: Dan Carpenter, Theodore Ts'o, dm-devel, linux-raid,
	Alasdair Kergon, Mike Snitzer, Shaohua Li, Julia Lawall,
	kernel-janitors, LKML, linux-doc

> If you continue discussing after that point,

I guess that such a condition is not needed.


> then you make a clear statement that it isn't an accident.

I hope that most of my software development activities are not "an accident".
Is the intent for any update suggestion (like the renaming of a jump label
in this case) reasonable to some degree?


> You are deliberately wasting their time.

I imagine that I do not really try to "waste" others time. But I am trying
also to change some "things".
There are circumstances when these contributions are interpreted as "wasted efforts".
Is the change acceptance usually higher for other update patterns?


> Something along "I will not listen.

I am listening while my responses might not fit to your current expectations.


> I will not change.

I have got also some personal change opportunities.


> Nothing you tell me will ever make it worth your time to do so"?

While you can be so clear about a rejection for this software module at the moment,
other contributors showed occasionally more positive information.

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
                   ` (2 preceding siblings ...)
  2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-10-01 14:44 ` SF Markus Elfring
  2016-10-01 14:46   ` [PATCH 01/15] md-cluster: Use kcalloc() in lock_all_bitmaps() SF Markus Elfring
                     ` (14 more replies)
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
  5 siblings, 15 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-01 14:44 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 16:38:17 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (15):
  Use kcalloc() in lock_all_bitmaps()
  Improve another size determination in resync_info_update()
  Improve another size determination in join()
  Improve another size determination in __sendmsg()
  Improve another size determination in recv_daemon()
  Rename a jump label in recv_daemon()
  Improve another size determination in process_suspend_info()
  Improve determination of sizes in read_resync_info()
  Improve another size determination in lockres_init()
  Delete an unnecessary variable initialisation in lockres_init()
  Delete four error messages for a failed memory allocation
  Rename a jump label in area_resyncing()
  Less function calls in join() after error detection
  Less function calls in lockres_init() after error detection
  Delete unnecessary braces in unlock_all_bitmaps()

 drivers/md/md-cluster.c | 114 ++++++++++++++++++++++++------------------------
 1 file changed, 56 insertions(+), 58 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 01/15] md-cluster: Use kcalloc() in lock_all_bitmaps()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
@ 2016-10-01 14:46   ` SF Markus Elfring
  2016-10-01 14:47   ` [PATCH 02/15] md-cluster: Improve another size determination in resync_info_update() SF Markus Elfring
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-01 14:46 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 11:18:40 +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 type 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/md-cluster.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 2b13117..0000e3a 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1188,9 +1188,10 @@ static int lock_all_bitmaps(struct mddev *mddev)
 	char str[64];
 	struct md_cluster_info *cinfo = mddev->cluster_info;
 
-	cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) *
-					     sizeof(struct dlm_lock_resource *),
-					     GFP_KERNEL);
+	cinfo->other_bitmap_lockres = kcalloc(mddev->bitmap_info.nodes - 1,
+					      sizeof(*cinfo
+						     ->other_bitmap_lockres),
+					      GFP_KERNEL);
 	if (!cinfo->other_bitmap_lockres) {
 		pr_err("md: can't alloc mem for other bitmap locks\n");
 		return 0;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 02/15] md-cluster: Improve another size determination in resync_info_update()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
  2016-10-01 14:46   ` [PATCH 01/15] md-cluster: Use kcalloc() in lock_all_bitmaps() SF Markus Elfring
@ 2016-10-01 14:47   ` SF Markus Elfring
  2016-10-01 14:48   ` [PATCH 03/15] md-cluster: Improve another size determination in join() SF Markus Elfring
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-01 14:47 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 11:37:24 +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 0000e3a..c28f596 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1057,7 +1057,7 @@ static int resync_info_update(struct mddev *mddev, sector_t lo, sector_t hi)
 
 	/* do not send zero again, if we have sent before */
 	if (hi == 0) {
-		memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(struct resync_info));
+		memcpy(&ri, cinfo->bitmap_lockres->lksb.sb_lvbptr, sizeof(ri));
 		if (le64_to_cpu(ri.hi) == 0)
 			return 0;
 	}
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 03/15] md-cluster: Improve another size determination in join()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
  2016-10-01 14:46   ` [PATCH 01/15] md-cluster: Use kcalloc() in lock_all_bitmaps() SF Markus Elfring
  2016-10-01 14:47   ` [PATCH 02/15] md-cluster: Improve another size determination in resync_info_update() SF Markus Elfring
@ 2016-10-01 14:48   ` SF Markus Elfring
  2016-10-01 14:49   ` [PATCH 04/15] md-cluster: Improve another size determination in __sendmsg() SF Markus Elfring
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-01 14:48 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 11:42:47 +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 c28f596..7af27dd 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -823,7 +823,7 @@ static int join(struct mddev *mddev, int nodes)
 	int ret, ops_rv;
 	char str[64];
 
-	cinfo = kzalloc(sizeof(struct md_cluster_info), GFP_KERNEL);
+	cinfo = kzalloc(sizeof(*cinfo), GFP_KERNEL);
 	if (!cinfo)
 		return -ENOMEM;
 
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 04/15] md-cluster: Improve another size determination in __sendmsg()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-10-01 14:48   ` [PATCH 03/15] md-cluster: Improve another size determination in join() SF Markus Elfring
@ 2016-10-01 14:49   ` SF Markus Elfring
  2016-10-01 14:50   ` [PATCH 05/15] md-cluster: Improve another size determination in recv_daemon() SF Markus Elfring
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-01 14:49 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 1 Oct 2016 12:21:48 +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 7af27dd..c81eed4 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -706,7 +706,7 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
 	}
 
 	memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg,
-			sizeof(struct cluster_msg));
+	       sizeof(*cmsg));
 	/*down-convert EX to CW on Message*/
 	error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW);
 	if (error) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 05/15] md-cluster: Improve another size determination in recv_daemon()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-10-01 14:49   ` [PATCH 04/15] md-cluster: Improve another size determination in __sendmsg() SF Markus Elfring
@ 2016-10-01 14:50   ` SF Markus Elfring
  2016-10-01 14:51   ` [PATCH 06/15] md-cluster: Rename a jump label " SF Markus Elfring
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 06/15] md-cluster: Rename a jump label in recv_daemon()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-10-01 14:50   ` [PATCH 05/15] md-cluster: Improve another size determination in recv_daemon() SF Markus Elfring
@ 2016-10-01 14:51   ` SF Markus Elfring
  2016-10-01 14:52   ` [PATCH 07/15] md-cluster: Improve another size determination in process_suspend_info() SF Markus Elfring
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 07/15] md-cluster: Improve another size determination in process_suspend_info()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-10-01 14:51   ` [PATCH 06/15] md-cluster: Rename a jump label " SF Markus Elfring
@ 2016-10-01 14:52   ` SF Markus Elfring
  2016-10-01 14:53   ` [PATCH 08/15] md-cluster: Improve determination of sizes in read_resync_info() SF Markus Elfring
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 08/15] md-cluster: Improve determination of sizes in read_resync_info()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-10-01 14:52   ` [PATCH 07/15] md-cluster: Improve another size determination in process_suspend_info() SF Markus Elfring
@ 2016-10-01 14:53   ` SF Markus Elfring
  2016-10-01 14:54   ` [PATCH 09/15] md-cluster: Improve another size determination in lockres_init() SF Markus Elfring
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 09/15] md-cluster: Improve another size determination in lockres_init()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-10-01 14:53   ` [PATCH 08/15] md-cluster: Improve determination of sizes in read_resync_info() SF Markus Elfring
@ 2016-10-01 14:54   ` SF Markus Elfring
  2016-10-01 14:55   ` [PATCH 10/15] md-cluster: Delete an unnecessary variable initialisation " SF Markus Elfring
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 10/15] md-cluster: Delete an unnecessary variable initialisation in lockres_init()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-10-01 14:54   ` [PATCH 09/15] md-cluster: Improve another size determination in lockres_init() SF Markus Elfring
@ 2016-10-01 14:55   ` SF Markus Elfring
  2016-10-01 14:56   ` [PATCH 11/15] md-cluster: Delete four error messages for a failed memory allocation SF Markus Elfring
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 11/15] md-cluster: Delete four error messages for a failed memory allocation
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-10-01 14:55   ` [PATCH 10/15] md-cluster: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2016-10-01 14:56   ` SF Markus Elfring
  2016-10-01 14:57   ` [PATCH 12/15] md-cluster: Rename a jump label in area_resyncing() SF Markus Elfring
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 12/15] md-cluster: Rename a jump label in area_resyncing()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-10-01 14:56   ` [PATCH 11/15] md-cluster: Delete four error messages for a failed memory allocation SF Markus Elfring
@ 2016-10-01 14:57   ` SF Markus Elfring
  2016-10-01 14:58   ` [PATCH 13/15] md-cluster: Less function calls in join() after error detection SF Markus Elfring
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 13/15] md-cluster: Less function calls in join() after error detection
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-10-01 14:57   ` [PATCH 12/15] md-cluster: Rename a jump label in area_resyncing() SF Markus Elfring
@ 2016-10-01 14:58   ` SF Markus Elfring
  2016-10-06 15:16     ` [PATCH v2 " SF Markus Elfring
  2016-10-01 14:59   ` [PATCH 14/15] md-cluster: Less function calls in lockres_init() " SF Markus Elfring
  2016-10-01 15:00   ` [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps() SF Markus Elfring
  14 siblings, 1 reply; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 14/15] md-cluster: Less function calls in lockres_init() after error detection
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-10-01 14:58   ` [PATCH 13/15] md-cluster: Less function calls in join() after error detection SF Markus Elfring
@ 2016-10-01 14:59   ` SF Markus Elfring
  2016-10-01 15:00   ` [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps() SF Markus Elfring
  14 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps()
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-10-01 14:59   ` [PATCH 14/15] md-cluster: Less function calls in lockres_init() " SF Markus Elfring
@ 2016-10-01 15:00   ` SF Markus Elfring
  2016-10-07  7:46     ` Dan Carpenter
  14 siblings, 1 reply; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 00/13] md/multipath: Fine-tuning for several function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
                   ` (3 preceding siblings ...)
  2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
@ 2016-10-02 11:54 ` SF Markus Elfring
  2016-10-02 11:56   ` [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run() SF Markus Elfring
                     ` (12 more replies)
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
  5 siblings, 13 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run()
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-10-02 11:56   ` SF Markus Elfring
  2016-10-02 11:57   ` [PATCH 2/13] md/multipath: Improve another size determination " SF Markus Elfring
                     ` (11 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 2/13] md/multipath: Improve another size determination in multipath_run()
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
  2016-10-02 11:56   ` [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run() SF Markus Elfring
@ 2016-10-02 11:57   ` SF Markus Elfring
  2016-10-02 11:59   ` [PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation SF Markus Elfring
                     ` (10 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
  2016-10-02 11:56   ` [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run() SF Markus Elfring
  2016-10-02 11:57   ` [PATCH 2/13] md/multipath: Improve another size determination " SF Markus Elfring
@ 2016-10-02 11:59   ` SF Markus Elfring
  2016-10-02 12:00   ` [PATCH 4/13] md/multipath: Reduce indentation for four lines in multipath_run() SF Markus Elfring
                     ` (9 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 4/13] md/multipath: Reduce indentation for four lines in multipath_run()
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-10-02 11:59   ` [PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation SF Markus Elfring
@ 2016-10-02 12:00   ` SF Markus Elfring
  2016-10-02 12:01   ` [PATCH 5/13] md/multipath: Less function calls in multipath_run() after error detection SF Markus Elfring
                     ` (8 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 5/13] md/multipath: Less function calls in multipath_run() after error detection
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-10-02 12:00   ` [PATCH 4/13] md/multipath: Reduce indentation for four lines in multipath_run() SF Markus Elfring
@ 2016-10-02 12:01   ` SF Markus Elfring
  2016-10-02 12:02   ` [PATCH 6/13] md/multipath: Delete 13 unwanted spaces behind function names SF Markus Elfring
                     ` (7 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 6/13] md/multipath: Delete 13 unwanted spaces behind function names
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-10-02 12:01   ` [PATCH 5/13] md/multipath: Less function calls in multipath_run() after error detection SF Markus Elfring
@ 2016-10-02 12:02   ` SF Markus Elfring
  2016-10-02 12:03   ` [PATCH 7/13] md/multipath: Delete two unwanted spaces behind asterisks SF Markus Elfring
                     ` (6 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 7/13] md/multipath: Delete two unwanted spaces behind asterisks
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-10-02 12:02   ` [PATCH 6/13] md/multipath: Delete 13 unwanted spaces behind function names SF Markus Elfring
@ 2016-10-02 12:03   ` SF Markus Elfring
  2016-10-02 12:04   ` [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status() SF Markus Elfring
                     ` (5 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status()
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-10-02 12:03   ` [PATCH 7/13] md/multipath: Delete two unwanted spaces behind asterisks SF Markus Elfring
@ 2016-10-02 12:04   ` SF Markus Elfring
  2018-01-13  8:55     ` [PATCH v2] md-multipath: Use seq_putc() " SF Markus Elfring
  2016-10-02 12:05   ` [PATCH 9/13] md/multipath: Adjust two function calls together with a variable assignment SF Markus Elfring
                     ` (4 subsequent siblings)
  12 siblings, 1 reply; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 9/13] md/multipath: Adjust two function calls together with a variable assignment
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-10-02 12:04   ` [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status() SF Markus Elfring
@ 2016-10-02 12:05   ` SF Markus Elfring
  2016-10-02 12:06   ` [PATCH 10/13] md/multipath: Add some spaces for better code readability SF Markus Elfring
                     ` (3 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 10/13] md/multipath: Add some spaces for better code readability
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-10-02 12:05   ` [PATCH 9/13] md/multipath: Adjust two function calls together with a variable assignment SF Markus Elfring
@ 2016-10-02 12:06   ` SF Markus Elfring
  2016-10-02 12:08   ` [PATCH 11/13] md/multipath: Move a brace for a designated initialiser SF Markus Elfring
                     ` (2 subsequent siblings)
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 11/13] md/multipath: Move a brace for a designated initialiser
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-10-02 12:06   ` [PATCH 10/13] md/multipath: Add some spaces for better code readability SF Markus Elfring
@ 2016-10-02 12:08   ` SF Markus Elfring
  2016-10-02 12:09   ` [PATCH 12/13] md/multipath: Delete an unnecessary return statement in multipath_make_request() SF Markus Elfring
  2016-10-02 12:10   ` [PATCH 13/13] md/multipath: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 12/13] md/multipath: Delete an unnecessary return statement in multipath_make_request()
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-10-02 12:08   ` [PATCH 11/13] md/multipath: Move a brace for a designated initialiser SF Markus Elfring
@ 2016-10-02 12:09   ` SF Markus Elfring
  2016-10-02 12:10   ` [PATCH 13/13] md/multipath: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* [PATCH 13/13] md/multipath: Replace printk() calls by the usage of higher level interfaces
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-10-02 12:09   ` [PATCH 12/13] md/multipath: Delete an unnecessary return statement in multipath_make_request() SF Markus Elfring
@ 2016-10-02 12:10   ` SF Markus Elfring
  12 siblings, 0 replies; 221+ messages in thread
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

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	[flat|nested] 221+ messages in thread

* MD-RAID: Fine-tuning for several function implementations
       [not found] <566ABCD9.1060404@users.sourceforge.net>
                   ` (4 preceding siblings ...)
  2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-10-06  8:46 ` SF Markus Elfring
  2016-10-06  8:49   ` Christoph Hellwig
                     ` (54 more replies)
  5 siblings, 55 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:46 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Oct 2016 10:10:01 +0200

Several update suggestions were taken into account
from static source code analysis.

Markus Elfring (54):
  raid0: Use kcalloc() in create_strip_zones()
  raid0: Less function calls in create_strip_zones() after error detection
  raid0: Move a variable assignment in create_strip_zones()
  raid0: Replace printk() calls by the usage of higher level interfaces
  raid0: Move another variable assignment in create_strip_zones()
  raid0: Delete four unwanted spaces behind function names
  raid0: Move two misplaced braces
  raid0: Delete an unnecessary return statement in raid0_status()
  raid0: Add some spaces for better code readability
  raid1: Use kcalloc() in alloc_behind_pages()
  raid1: Use kcalloc() in raid1_reshape()
  raid1: Use kcalloc() in setup_conf()
  raid1: Return directly after a failed kzalloc() in setup_conf()
  raid1: Move assignments for the variable "err" in setup_conf()
  raid1: Less function calls in setup_conf() after error detection
  raid1: Delete an error message for a failed memory allocation
  raid1: Move a brace for a designated initialiser
  raid1: Adjust 12 checks for null pointers
  raid1: Replace printk() calls by the usage of higher level interfaces
  raid1: Add some spaces for better code readability
  raid1: Delete three unwanted spaces behind asterisks
  raid1: Delete three unwanted spaces before increment operators
  raid1: Replace a seq_printf() call by seq_puts() in raid1_status()
  raid1: Improve another size determination in setup_conf()
  raid5: Use kcalloc() in three functions
  raid5: Improve another size determination in setup_conf()
  raid5: Return directly after a failed kzalloc() in setup_conf()
  raid5: Rename a jump label in setup_conf()
  raid5: Return directly after a failed kcalloc() in alloc_thread_groups()
  raid5: Delete two error messages for a failed memory allocation
  raid5: Adjust two function calls together with a variable assignment
  raid5: Move a brace for three designated initialisers
  raid5: Replace printk() calls by the usage of higher level interfaces
  raid5: Delete indentation for two jump labels
  raid5: Adjust 13 checks for null pointers
  raid5: Delete four unwanted spaces behind function names
  raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  raid5: Move four asterisks
  raid5: Add some spaces for better code readability
  raid10: Use kcalloc() in two functions
  raid10: Improve another size determination in setup_conf()
  raid10: Delete an error message for a failed memory allocation
  raid10: Return directly after detection of unsupported settings in setup_conf()
  raid10: Return directly after a failed kzalloc() in setup_conf()
  raid10: Move assignments for the variable "err" in setup_conf()
  raid10: Less function calls in setup_conf() after error detection
  raid10: Improve another size determination in raid10_start_reshape()
  raid10: Move a brace for a designated initialiser
  raid10: Replace printk() calls by the usage of higher level interfaces
  raid10: Delete indentation for one jump label
  raid10: Adjust 22 checks for null pointers
  raid10: Replace a seq_printf() call by seq_puts() in raid10_status()
  raid10: Delete two unwanted spaces behind asterisks
  raid10: Add some spaces for better code readability

 drivers/md/raid0.c  | 170 ++++++++---------
 drivers/md/raid1.c  | 285 ++++++++++++++--------------
 drivers/md/raid10.c | 366 ++++++++++++++++++------------------
 drivers/md/raid5.c  | 523 ++++++++++++++++++++++++----------------------------
 4 files changed, 649 insertions(+), 695 deletions(-)

-- 
2.10.1

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Fine-tuning for several function implementations
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-10-06  8:49   ` Christoph Hellwig
  2016-10-06 10:07     ` SF Markus Elfring
  2016-10-06  8:51   ` [PATCH 01/54] md/raid0: Use kcalloc() in create_strip_zones() SF Markus Elfring
                     ` (53 subsequent siblings)
  54 siblings, 1 reply; 221+ messages in thread
From: Christoph Hellwig @ 2016-10-06  8:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

Please stop it NOW.  This is not fine tuning but a waste of everyones
time.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 01/54] md/raid0: Use kcalloc() in create_strip_zones()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
  2016-10-06  8:49   ` Christoph Hellwig
@ 2016-10-06  8:51   ` SF Markus Elfring
  2016-10-06  8:53   ` [PATCH 02/54] md/raid0: Less function calls in create_strip_zones() after error detection SF Markus Elfring
                     ` (52 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:51 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 10:10:52 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  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/raid0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 258986a..50e8a63 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -150,12 +150,13 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	}
 
 	err = -ENOMEM;
-	conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
-				conf->nr_strip_zones, GFP_KERNEL);
+	conf->strip_zone = kcalloc(conf->nr_strip_zones,
+				   sizeof(*conf->strip_zone),
+				   GFP_KERNEL);
 	if (!conf->strip_zone)
 		goto abort;
-	conf->devlist = kzalloc(sizeof(struct md_rdev*)*
-				conf->nr_strip_zones*mddev->raid_disks,
+	conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks,
+				sizeof(*conf->devlist),
 				GFP_KERNEL);
 	if (!conf->devlist)
 		goto abort;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 02/54] md/raid0: Less function calls in create_strip_zones() after error detection
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
  2016-10-06  8:49   ` Christoph Hellwig
  2016-10-06  8:51   ` [PATCH 01/54] md/raid0: Use kcalloc() in create_strip_zones() SF Markus Elfring
@ 2016-10-06  8:53   ` SF Markus Elfring
  2016-10-06  8:54   ` [PATCH 03/54] md/raid0: Move a variable assignment in create_strip_zones() SF Markus Elfring
                     ` (51 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:53 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 10:43:33 +0200

The kfree() function was called in up to two cases
by the create_strip_zones() 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/raid0.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 50e8a63..3c76451 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -146,7 +146,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		       mdname(mddev),
 		       mddev->chunk_sectors << 9, blksize);
 		err = -EINVAL;
-		goto abort;
+		goto free_conf;
 	}
 
 	err = -ENOMEM;
@@ -154,12 +154,12 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				   sizeof(*conf->strip_zone),
 				   GFP_KERNEL);
 	if (!conf->strip_zone)
-		goto abort;
+		goto free_conf;
 	conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks,
 				sizeof(*conf->devlist),
 				GFP_KERNEL);
 	if (!conf->devlist)
-		goto abort;
+		goto free_zone;
 
 	/* The first zone must contain all devices, so here we check that
 	 * there is a proper alignment of slots to devices and find them all
@@ -190,17 +190,17 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 			printk(KERN_ERR
 			       "md/raid0:%s: remove inactive devices before converting to RAID0\n",
 			       mdname(mddev));
-			goto abort;
+			goto free_device_list;
 		}
 		if (j >= mddev->raid_disks) {
 			printk(KERN_ERR "md/raid0:%s: bad disk number %d - "
 			       "aborting!\n", mdname(mddev), j);
-			goto abort;
+			goto free_device_list;
 		}
 		if (dev[j]) {
 			printk(KERN_ERR "md/raid0:%s: multiple devices for %d - "
 			       "aborting!\n", mdname(mddev), j);
-			goto abort;
+			goto free_device_list;
 		}
 		dev[j] = rdev1;
 
@@ -211,7 +211,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (cnt != mddev->raid_disks) {
 		printk(KERN_ERR "md/raid0:%s: too few disks (%d of %d) - "
 		       "aborting!\n", mdname(mddev), cnt, mddev->raid_disks);
-		goto abort;
+		goto free_device_list;
 	}
 	zone->nb_dev = cnt;
 	zone->zone_end = smallest->sectors * cnt;
@@ -271,9 +271,11 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	*private_conf = conf;
 
 	return 0;
-abort:
-	kfree(conf->strip_zone);
+free_device_list:
 	kfree(conf->devlist);
+free_zone:
+	kfree(conf->strip_zone);
+free_conf:
 	kfree(conf);
 	*private_conf = ERR_PTR(err);
 	return err;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 03/54] md/raid0: Move a variable assignment in create_strip_zones()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-10-06  8:53   ` [PATCH 02/54] md/raid0: Less function calls in create_strip_zones() after error detection SF Markus Elfring
@ 2016-10-06  8:54   ` SF Markus Elfring
  2016-10-06  8:56   ` [PATCH 04/54] md/raid0: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
                     ` (50 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:54 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 12:02:29 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignment into
two if branches to indicate a memory allocation failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid0.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 3c76451..71bd398 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -149,17 +149,21 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		goto free_conf;
 	}
 
-	err = -ENOMEM;
 	conf->strip_zone = kcalloc(conf->nr_strip_zones,
 				   sizeof(*conf->strip_zone),
 				   GFP_KERNEL);
-	if (!conf->strip_zone)
+	if (!conf->strip_zone) {
+		err = -ENOMEM;
 		goto free_conf;
+	}
+
 	conf->devlist = kcalloc(conf->nr_strip_zones * mddev->raid_disks,
 				sizeof(*conf->devlist),
 				GFP_KERNEL);
-	if (!conf->devlist)
+	if (!conf->devlist) {
+		err = -ENOMEM;
 		goto free_zone;
+	}
 
 	/* The first zone must contain all devices, so here we check that
 	 * there is a proper alignment of slots to devices and find them all
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 04/54] md/raid0: Replace printk() calls by the usage of higher level interfaces
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-10-06  8:54   ` [PATCH 03/54] md/raid0: Move a variable assignment in create_strip_zones() SF Markus Elfring
@ 2016-10-06  8:56   ` SF Markus Elfring
  2016-10-06  8:57   ` [PATCH 05/54] md/raid0: Move another variable assignment in create_strip_zones() SF Markus Elfring
                     ` (49 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:56 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 13:30:39 +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.

3. Remove prefixes from strings which were passed to some function
   and macro calls.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid0.c | 100 +++++++++++++++++++++++++----------------------------
 1 file changed, 47 insertions(+), 53 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 71bd398..3079c3e 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -17,6 +17,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/seq_file.h>
 #include <linux/module.h>
@@ -51,20 +53,20 @@ static void dump_zones(struct mddev *mddev)
 	char b[BDEVNAME_SIZE];
 	struct r0conf *conf = mddev->private;
 	int raid_disks = conf->strip_zone[0].nb_dev;
-	printk(KERN_INFO "md: RAID0 configuration for %s - %d zone%s\n",
+	pr_info("configuration for %s - %d zone%s\n",
 	       mdname(mddev),
 	       conf->nr_strip_zones, conf->nr_strip_zones==1?"":"s");
 	for (j = 0; j < conf->nr_strip_zones; j++) {
-		printk(KERN_INFO "md: zone%d=[", j);
+		pr_info("zone%d=[", j);
 		for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
-			printk(KERN_CONT "%s%s", k?"/":"",
-			bdevname(conf->devlist[j*raid_disks
-						+ k]->bdev, b));
-		printk(KERN_CONT "]\n");
-
+			pr_cont("%s%s",
+				k ? "/" : "",
+				bdevname(conf->devlist[j * raid_disks + k]
+					 ->bdev,
+					 b));
+		pr_cont("]\n");
 		zone_size  = conf->strip_zone[j].zone_end - zone_start;
-		printk(KERN_INFO "      zone-offset=%10lluKB, "
-				"device-offset=%10lluKB, size=%10lluKB\n",
+		pr_info("      zone-offset=%10lluKB, device-offset=%10lluKB, size=%10lluKB\n",
 			(unsigned long long)zone_start>>1,
 			(unsigned long long)conf->strip_zone[j].dev_start>>1,
 			(unsigned long long)zone_size>>1);
@@ -88,7 +90,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (!conf)
 		return -ENOMEM;
 	rdev_for_each(rdev1, mddev) {
-		pr_debug("md/raid0:%s: looking at %s\n",
+		pr_debug("%s: looking at %s\n",
 			 mdname(mddev),
 			 bdevname(rdev1->bdev, b));
 		c = 0;
@@ -102,15 +104,14 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				      rdev1->bdev->bd_disk->queue));
 
 		rdev_for_each(rdev2, mddev) {
-			pr_debug("md/raid0:%s:   comparing %s(%llu)"
-				 " with %s(%llu)\n",
+			pr_debug("%s:   comparing %s(%llu) with %s(%llu)\n",
 				 mdname(mddev),
 				 bdevname(rdev1->bdev,b),
 				 (unsigned long long)rdev1->sectors,
 				 bdevname(rdev2->bdev,b2),
 				 (unsigned long long)rdev2->sectors);
 			if (rdev2 == rdev1) {
-				pr_debug("md/raid0:%s:   END\n",
+				pr_debug("%s:   END\n",
 					 mdname(mddev));
 				break;
 			}
@@ -119,30 +120,30 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 				 * Not unique, don't count it as a new
 				 * group
 				 */
-				pr_debug("md/raid0:%s:   EQUAL\n",
+				pr_debug("%s:   EQUAL\n",
 					 mdname(mddev));
 				c = 1;
 				break;
 			}
-			pr_debug("md/raid0:%s:   NOT EQUAL\n",
+			pr_debug("%s:   NOT EQUAL\n",
 				 mdname(mddev));
 		}
 		if (!c) {
-			pr_debug("md/raid0:%s:   ==> UNIQUE\n",
+			pr_debug("%s:   ==> UNIQUE\n",
 				 mdname(mddev));
 			conf->nr_strip_zones++;
-			pr_debug("md/raid0:%s: %d zones\n",
+			pr_debug("%s: %d zones\n",
 				 mdname(mddev), conf->nr_strip_zones);
 		}
 	}
-	pr_debug("md/raid0:%s: FINAL %d zones\n",
+	pr_debug("%s: FINAL %d zones\n",
 		 mdname(mddev), conf->nr_strip_zones);
 	/*
 	 * now since we have the hard sector sizes, we can make sure
 	 * chunk size is a multiple of that sector size
 	 */
 	if ((mddev->chunk_sectors << 9) % blksize) {
-		printk(KERN_ERR "md/raid0:%s: chunk_size of %d not multiple of block size %d\n",
+		pr_err("%s: chunk_size of %d not multiple of block size %d\n",
 		       mdname(mddev),
 		       mddev->chunk_sectors << 9, blksize);
 		err = -EINVAL;
@@ -191,19 +192,18 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		}
 
 		if (j < 0) {
-			printk(KERN_ERR
-			       "md/raid0:%s: remove inactive devices before converting to RAID0\n",
+			pr_err("%s: remove inactive devices before converting to RAID0\n",
 			       mdname(mddev));
 			goto free_device_list;
 		}
 		if (j >= mddev->raid_disks) {
-			printk(KERN_ERR "md/raid0:%s: bad disk number %d - "
-			       "aborting!\n", mdname(mddev), j);
+			pr_err("%s: bad disk number %d%s",
+			       mdname(mddev), j, " - aborting!\n");
 			goto free_device_list;
 		}
 		if (dev[j]) {
-			printk(KERN_ERR "md/raid0:%s: multiple devices for %d - "
-			       "aborting!\n", mdname(mddev), j);
+			pr_err("%s: multiple devices for %d%s",
+			       mdname(mddev), j, " - aborting!\n");
 			goto free_device_list;
 		}
 		dev[j] = rdev1;
@@ -213,8 +213,8 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		cnt++;
 	}
 	if (cnt != mddev->raid_disks) {
-		printk(KERN_ERR "md/raid0:%s: too few disks (%d of %d) - "
-		       "aborting!\n", mdname(mddev), cnt, mddev->raid_disks);
+		pr_err("%s: too few disks (%d of %d)%s",
+		       mdname(mddev), cnt, mddev->raid_disks, " - aborting!\n");
 		goto free_device_list;
 	}
 	zone->nb_dev = cnt;
@@ -229,8 +229,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 
 		zone = conf->strip_zone + i;
 		dev = conf->devlist + i * mddev->raid_disks;
-
-		pr_debug("md/raid0:%s: zone %d\n", mdname(mddev), i);
+		pr_debug("%s: zone %d\n", mdname(mddev), i);
 		zone->dev_start = smallest->sectors;
 		smallest = NULL;
 		c = 0;
@@ -238,20 +237,19 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		for (j=0; j<cnt; j++) {
 			rdev = conf->devlist[j];
 			if (rdev->sectors <= zone->dev_start) {
-				pr_debug("md/raid0:%s: checking %s ... nope\n",
+				pr_debug("%s: checking %s ... nope\n",
 					 mdname(mddev),
 					 bdevname(rdev->bdev, b));
 				continue;
 			}
-			pr_debug("md/raid0:%s: checking %s ..."
-				 " contained as device %d\n",
+			pr_debug("%s: checking %s ... contained as device %d\n",
 				 mdname(mddev),
 				 bdevname(rdev->bdev, b), c);
 			dev[c] = rdev;
 			c++;
 			if (!smallest || rdev->sectors < smallest->sectors) {
 				smallest = rdev;
-				pr_debug("md/raid0:%s:  (%llu) is smallest!.\n",
+				pr_debug("%s: (%llu) is smallest!.\n",
 					 mdname(mddev),
 					 (unsigned long long)rdev->sectors);
 			}
@@ -259,19 +257,18 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 
 		zone->nb_dev = c;
 		sectors = (smallest->sectors - zone->dev_start) * c;
-		pr_debug("md/raid0:%s: zone->nb_dev: %d, sectors: %llu\n",
+		pr_debug("%s: zone->nb_dev: %d, sectors: %llu\n",
 			 mdname(mddev),
 			 zone->nb_dev, (unsigned long long)sectors);
 
 		curr_zone_end += sectors;
 		zone->zone_end = curr_zone_end;
-
-		pr_debug("md/raid0:%s: current zone start: %llu\n",
+		pr_debug("%s: current zone start: %llu\n",
 			 mdname(mddev),
 			 (unsigned long long)smallest->sectors);
 	}
 
-	pr_debug("md/raid0:%s: done.\n", mdname(mddev));
+	pr_debug("%s: done.\n", mdname(mddev));
 	*private_conf = conf;
 
 	return 0;
@@ -364,8 +361,7 @@ static int raid0_run(struct mddev *mddev)
 	int ret;
 
 	if (mddev->chunk_sectors == 0) {
-		printk(KERN_ERR "md/raid0:%s: chunk size must be set.\n",
-		       mdname(mddev));
+		pr_err("%s: chunk size must be set.\n", mdname(mddev));
 		return -EINVAL;
 	}
 	if (md_check_no_bitmap(mddev))
@@ -405,10 +401,9 @@ static int raid0_run(struct mddev *mddev)
 
 	/* calculate array device size */
 	md_set_array_sectors(mddev, raid0_size(mddev, 0, 0));
-
-	printk(KERN_INFO "md/raid0:%s: md_size is %llu sectors.\n",
-	       mdname(mddev),
-	       (unsigned long long)mddev->array_sectors);
+	pr_info("%s: md_size is %llu sectors.\n",
+		mdname(mddev),
+		(unsigned long long)mddev->array_sectors);
 
 	if (mddev->queue) {
 		/* calculate the max read-ahead size.
@@ -516,7 +511,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
 	struct r0conf *priv_conf;
 
 	if (mddev->degraded != 1) {
-		printk(KERN_ERR "md/raid0:%s: raid5 must be degraded! Degraded disks: %d\n",
+		pr_err("%s: raid5 must be degraded! Degraded disks: %d\n",
 		       mdname(mddev),
 		       mddev->degraded);
 		return ERR_PTR(-EINVAL);
@@ -525,7 +520,7 @@ static void *raid0_takeover_raid45(struct mddev *mddev)
 	rdev_for_each(rdev, mddev) {
 		/* check slot number for a disk */
 		if (rdev->raid_disk == mddev->raid_disks-1) {
-			printk(KERN_ERR "md/raid0:%s: raid5 must have missing parity disk!\n",
+			pr_err("%s: raid5 must have missing parity disk!\n",
 			       mdname(mddev));
 			return ERR_PTR(-EINVAL);
 		}
@@ -556,18 +551,18 @@ static void *raid0_takeover_raid10(struct mddev *mddev)
 	 *  - all mirrors must be already degraded
 	 */
 	if (mddev->layout != ((1 << 8) + 2)) {
-		printk(KERN_ERR "md/raid0:%s:: Raid0 cannot takeover layout: 0x%x\n",
+		pr_err("%s: Raid0 cannot takeover layout: 0x%x\n",
 		       mdname(mddev),
 		       mddev->layout);
 		return ERR_PTR(-EINVAL);
 	}
 	if (mddev->raid_disks & 1) {
-		printk(KERN_ERR "md/raid0:%s: Raid0 cannot takeover Raid10 with odd disk number.\n",
+		pr_err("%s: Raid0 cannot takeover Raid10 with odd disk number.\n",
 		       mdname(mddev));
 		return ERR_PTR(-EINVAL);
 	}
 	if (mddev->degraded != (mddev->raid_disks>>1)) {
-		printk(KERN_ERR "md/raid0:%s: All mirrors must be already degraded!\n",
+		pr_err("%s: All mirrors must be already degraded!\n",
 		       mdname(mddev));
 		return ERR_PTR(-EINVAL);
 	}
@@ -595,7 +590,7 @@ static void *raid0_takeover_raid1(struct mddev *mddev)
 	 *  - (N - 1) mirror drives must be already faulty
 	 */
 	if ((mddev->raid_disks - 1) != mddev->degraded) {
-		printk(KERN_ERR "md/raid0:%s: (N - 1) mirrors drives must be already faulty!\n",
+		pr_err("%s: (N - 1) mirrors drives must be already faulty!\n",
 		       mdname(mddev));
 		return ERR_PTR(-EINVAL);
 	}
@@ -638,7 +633,7 @@ static void *raid0_takeover(struct mddev *mddev)
 	 */
 
 	if (mddev->bitmap) {
-		printk(KERN_ERR "md/raid0: %s: cannot takeover array with bitmap\n",
+		pr_err("%s: cannot takeover array with bitmap\n",
 		       mdname(mddev));
 		return ERR_PTR(-EBUSY);
 	}
@@ -649,7 +644,7 @@ static void *raid0_takeover(struct mddev *mddev)
 		if (mddev->layout == ALGORITHM_PARITY_N)
 			return raid0_takeover_raid45(mddev);
 
-		printk(KERN_ERR "md/raid0:%s: Raid can only takeover Raid5 with layout: %d\n",
+		pr_err("%s: Raid can only takeover Raid5 with layout: %d\n",
 		       mdname(mddev), ALGORITHM_PARITY_N);
 	}
 
@@ -659,9 +654,8 @@ static void *raid0_takeover(struct mddev *mddev)
 	if (mddev->level == 1)
 		return raid0_takeover_raid1(mddev);
 
-	printk(KERN_ERR "Takeover from raid%i to raid0 not supported\n",
+	pr_err("Takeover from raid%i to raid0 not supported\n",
 		mddev->level);
-
 	return ERR_PTR(-EINVAL);
 }
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 05/54] md/raid0: Move another variable assignment in create_strip_zones()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-10-06  8:56   ` [PATCH 04/54] md/raid0: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
@ 2016-10-06  8:57   ` SF Markus Elfring
  2016-10-06  8:59   ` [PATCH 06/54] md/raid0: Delete four unwanted spaces behind function names SF Markus Elfring
                     ` (48 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:57 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 13:54:36 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignment
to the end to indicate a software failure there.
Use it finally in four if branches for exception handling.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid0.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 3079c3e..0315f1e 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -173,7 +173,6 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	cnt = 0;
 	smallest = NULL;
 	dev = conf->devlist;
-	err = -EINVAL;
 	rdev_for_each(rdev1, mddev) {
 		int j = rdev1->raid_disk;
 
@@ -194,17 +193,17 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		if (j < 0) {
 			pr_err("%s: remove inactive devices before converting to RAID0\n",
 			       mdname(mddev));
-			goto free_device_list;
+			goto e_inval;
 		}
 		if (j >= mddev->raid_disks) {
 			pr_err("%s: bad disk number %d%s",
 			       mdname(mddev), j, " - aborting!\n");
-			goto free_device_list;
+			goto e_inval;
 		}
 		if (dev[j]) {
 			pr_err("%s: multiple devices for %d%s",
 			       mdname(mddev), j, " - aborting!\n");
-			goto free_device_list;
+			goto e_inval;
 		}
 		dev[j] = rdev1;
 
@@ -215,7 +214,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	if (cnt != mddev->raid_disks) {
 		pr_err("%s: too few disks (%d of %d)%s",
 		       mdname(mddev), cnt, mddev->raid_disks, " - aborting!\n");
-		goto free_device_list;
+		goto e_inval;
 	}
 	zone->nb_dev = cnt;
 	zone->zone_end = smallest->sectors * cnt;
@@ -280,6 +279,9 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	kfree(conf);
 	*private_conf = ERR_PTR(err);
 	return err;
+e_inval:
+	err = -EINVAL;
+	goto free_device_list;
 }
 
 /* Find the zone which holds a particular offset
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 06/54] md/raid0: Delete four unwanted spaces behind function names
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-10-06  8:57   ` [PATCH 05/54] md/raid0: Move another variable assignment in create_strip_zones() SF Markus Elfring
@ 2016-10-06  8:59   ` SF Markus Elfring
  2016-10-06  9:00   ` [PATCH 07/54] md/raid0: Move two misplaced braces SF Markus Elfring
                     ` (47 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  8:59 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 14:21:21 +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/raid0.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 0315f1e..06cb172 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -680,14 +680,14 @@ static struct md_personality raid0_personality=
 	.congested	= raid0_congested,
 };
 
-static int __init raid0_init (void)
+static int __init raid0_init(void)
 {
-	return register_md_personality (&raid0_personality);
+	return register_md_personality(&raid0_personality);
 }
 
-static void raid0_exit (void)
+static void raid0_exit(void)
 {
-	unregister_md_personality (&raid0_personality);
+	unregister_md_personality(&raid0_personality);
 }
 
 module_init(raid0_init);
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 07/54] md/raid0: Move two misplaced braces
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-10-06  8:59   ` [PATCH 06/54] md/raid0: Delete four unwanted spaces behind function names SF Markus Elfring
@ 2016-10-06  9:00   ` SF Markus Elfring
  2016-10-06  9:01   ` [PATCH 08/54] md/raid0: Delete an unnecessary return statement in raid0_status() SF Markus Elfring
                     ` (46 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:00 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 14:25:01 +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/raid0.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 06cb172..9b76eae 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -222,8 +222,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 	curr_zone_end = zone->zone_end;
 
 	/* now do the other zones */
-	for (i = 1; i < conf->nr_strip_zones; i++)
-	{
+	for (i = 1; i < conf->nr_strip_zones; i++) {
 		int j;
 
 		zone = conf->strip_zone + i;
@@ -665,8 +664,7 @@ static void raid0_quiesce(struct mddev *mddev, int state)
 {
 }
 
-static struct md_personality raid0_personality=
-{
+static struct md_personality raid0_personality = {
 	.name		= "raid0",
 	.level		= 0,
 	.owner		= THIS_MODULE,
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 08/54] md/raid0: Delete an unnecessary return statement in raid0_status()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-10-06  9:00   ` [PATCH 07/54] md/raid0: Move two misplaced braces SF Markus Elfring
@ 2016-10-06  9:01   ` SF Markus Elfring
  2016-10-06  9:03   ` [PATCH 09/54] md/raid0: Add some spaces for better code readability SF Markus Elfring
                     ` (45 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:01 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 14:34:33 +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/raid0.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 9b76eae..1abe1ee 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -503,7 +503,6 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
 static void raid0_status(struct seq_file *seq, struct mddev *mddev)
 {
 	seq_printf(seq, " %dk chunks", mddev->chunk_sectors / 2);
-	return;
 }
 
 static void *raid0_takeover_raid45(struct mddev *mddev)
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 09/54] md/raid0: Add some spaces for better code readability
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-10-06  9:01   ` [PATCH 08/54] md/raid0: Delete an unnecessary return statement in raid0_status() SF Markus Elfring
@ 2016-10-06  9:03   ` SF Markus Elfring
  2016-10-06  9:05   ` [PATCH 10/54] md/raid1: Use kcalloc() in alloc_behind_pages() SF Markus Elfring
                     ` (44 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:03 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 14:48:34 +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/raid0.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 1abe1ee..39d407c 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -55,7 +55,7 @@ static void dump_zones(struct mddev *mddev)
 	int raid_disks = conf->strip_zone[0].nb_dev;
 	pr_info("configuration for %s - %d zone%s\n",
 	       mdname(mddev),
-	       conf->nr_strip_zones, conf->nr_strip_zones==1?"":"s");
+	       conf->nr_strip_zones, conf->nr_strip_zones == 1 ? "" : "s");
 	for (j = 0; j < conf->nr_strip_zones; j++) {
 		pr_info("zone%d=[", j);
 		for (k = 0; k < conf->strip_zone[j].nb_dev; k++)
@@ -106,9 +106,9 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		rdev_for_each(rdev2, mddev) {
 			pr_debug("%s:   comparing %s(%llu) with %s(%llu)\n",
 				 mdname(mddev),
-				 bdevname(rdev1->bdev,b),
+				 bdevname(rdev1->bdev, b),
 				 (unsigned long long)rdev1->sectors,
-				 bdevname(rdev2->bdev,b2),
+				 bdevname(rdev2->bdev, b2),
 				 (unsigned long long)rdev2->sectors);
 			if (rdev2 == rdev1) {
 				pr_debug("%s:   END\n",
@@ -232,7 +232,7 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
 		smallest = NULL;
 		c = 0;
 
-		for (j=0; j<cnt; j++) {
+		for (j = 0; j < cnt; j++) {
 			rdev = conf->devlist[j];
 			if (rdev->sectors <= zone->dev_start) {
 				pr_debug("%s: checking %s ... nope\n",
@@ -418,8 +418,8 @@ static int raid0_run(struct mddev *mddev)
 		 */
 		int stripe = mddev->raid_disks *
 			(mddev->chunk_sectors << 9) / PAGE_SIZE;
-		if (mddev->queue->backing_dev_info.ra_pages < 2* stripe)
-			mddev->queue->backing_dev_info.ra_pages = 2* stripe;
+		if (mddev->queue->backing_dev_info.ra_pages < 2 * stripe)
+			mddev->queue->backing_dev_info.ra_pages = 2 * stripe;
 	}
 
 	dump_zones(mddev);
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 10/54] md/raid1: Use kcalloc() in alloc_behind_pages()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-10-06  9:03   ` [PATCH 09/54] md/raid0: Add some spaces for better code readability SF Markus Elfring
@ 2016-10-06  9:05   ` SF Markus Elfring
  2016-10-06  9:06   ` [PATCH 11/54] md/raid1: Use kcalloc() in raid1_reshape() SF Markus Elfring
                     ` (43 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:05 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 15:01:04 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use 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/raid1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1961d82..d2759f8 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -955,8 +955,7 @@ static void alloc_behind_pages(struct bio *bio, struct r1bio *r1_bio)
 {
 	int i;
 	struct bio_vec *bvec;
-	struct bio_vec *bvecs = kzalloc(bio->bi_vcnt * sizeof(struct bio_vec),
-					GFP_NOIO);
+	struct bio_vec *bvecs = kcalloc(bio->bi_vcnt, sizeof(*bvecs), GFP_NOIO);
 	if (unlikely(!bvecs))
 		return;
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 11/54] md/raid1: Use kcalloc() in raid1_reshape()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-10-06  9:05   ` [PATCH 10/54] md/raid1: Use kcalloc() in alloc_behind_pages() SF Markus Elfring
@ 2016-10-06  9:06   ` SF Markus Elfring
  2016-10-06  9:07   ` [PATCH 12/54] md/raid1: Use kcalloc() in setup_conf() SF Markus Elfring
                     ` (42 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:06 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 15:17:13 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

* 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/raid1.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index d2759f8..e75ae87 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3081,8 +3081,8 @@ static int raid1_reshape(struct mddev *mddev)
 		kfree(newpoolinfo);
 		return -ENOMEM;
 	}
-	newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2,
-			     GFP_KERNEL);
+
+	newmirrors = kcalloc(raid_disks * 2, sizeof(*newmirrors), GFP_KERNEL);
 	if (!newmirrors) {
 		kfree(newpoolinfo);
 		mempool_destroy(newpool);
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 12/54] md/raid1: Use kcalloc() in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-10-06  9:06   ` [PATCH 11/54] md/raid1: Use kcalloc() in raid1_reshape() SF Markus Elfring
@ 2016-10-06  9:07   ` SF Markus Elfring
  2016-10-06  9:09   ` [PATCH 13/54] md/raid1: Return directly after a failed kzalloc() " SF Markus Elfring
                     ` (41 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:07 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 15:30:28 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

* 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/raid1.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index e75ae87..5969711 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2781,9 +2781,9 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	if (!conf)
 		goto abort;
 
-	conf->mirrors = kzalloc(sizeof(struct raid1_info)
-				* mddev->raid_disks * 2,
-				 GFP_KERNEL);
+	conf->mirrors = kcalloc(mddev->raid_disks * 2,
+				sizeof(*conf->mirrors),
+				GFP_KERNEL);
 	if (!conf->mirrors)
 		goto abort;
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 13/54] md/raid1: Return directly after a failed kzalloc() in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-10-06  9:07   ` [PATCH 12/54] md/raid1: Use kcalloc() in setup_conf() SF Markus Elfring
@ 2016-10-06  9:09   ` SF Markus Elfring
  2016-10-06  9:10   ` [PATCH 14/54] md/raid1: Move assignments for the variable "err" " SF Markus Elfring
                     ` (40 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:09 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 15:56:41 +0200

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Delete a repeated check for the local variable "conf"
  which became unnecessary with this refactoring.

* Reorder two calls for the function "kfree" at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 5969711..74346f5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2779,7 +2779,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 
 	conf = kzalloc(sizeof(struct r1conf), GFP_KERNEL);
 	if (!conf)
-		goto abort;
+		return ERR_PTR(-ENOMEM);
 
 	conf->mirrors = kcalloc(mddev->raid_disks * 2,
 				sizeof(*conf->mirrors),
@@ -2880,13 +2880,11 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	return conf;
 
  abort:
-	if (conf) {
-		mempool_destroy(conf->r1bio_pool);
-		kfree(conf->mirrors);
-		safe_put_page(conf->tmppage);
-		kfree(conf->poolinfo);
-		kfree(conf);
-	}
+	mempool_destroy(conf->r1bio_pool);
+	kfree(conf->poolinfo);
+	safe_put_page(conf->tmppage);
+	kfree(conf->mirrors);
+	kfree(conf);
 	return ERR_PTR(err);
 }
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 14/54] md/raid1: Move assignments for the variable "err" in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-10-06  9:09   ` [PATCH 13/54] md/raid1: Return directly after a failed kzalloc() " SF Markus Elfring
@ 2016-10-06  9:10   ` SF Markus Elfring
  2016-10-06  9:11   ` [PATCH 15/54] md/raid1: Less function calls in setup_conf() after error detection SF Markus Elfring
                     ` (39 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:10 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 17:34:10 +0200

One local variable was set to an error code in a few cases before
a concrete error situation was detected. Thus move the corresponding
assignments into if branches to indicate a software failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 74346f5..4d2fcbc 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2775,7 +2775,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	int i;
 	struct raid1_info *disk;
 	struct md_rdev *rdev;
-	int err = -ENOMEM;
+	int err;
 
 	conf = kzalloc(sizeof(struct r1conf), GFP_KERNEL);
 	if (!conf)
@@ -2784,26 +2784,33 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	conf->mirrors = kcalloc(mddev->raid_disks * 2,
 				sizeof(*conf->mirrors),
 				GFP_KERNEL);
-	if (!conf->mirrors)
+	if (!conf->mirrors) {
+		err = -ENOMEM;
 		goto abort;
+	}
 
 	conf->tmppage = alloc_page(GFP_KERNEL);
-	if (!conf->tmppage)
+	if (!conf->tmppage) {
+		err = -ENOMEM;
 		goto abort;
+	}
 
 	conf->poolinfo = kzalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
-	if (!conf->poolinfo)
+	if (!conf->poolinfo) {
+		err = -ENOMEM;
 		goto abort;
+	}
+
 	conf->poolinfo->raid_disks = mddev->raid_disks * 2;
 	conf->r1bio_pool = mempool_create(NR_RAID1_BIOS, r1bio_pool_alloc,
 					  r1bio_pool_free,
 					  conf->poolinfo);
-	if (!conf->r1bio_pool)
+	if (!conf->r1bio_pool) {
+		err = -ENOMEM;
 		goto abort;
+	}
 
 	conf->poolinfo->mddev = mddev;
-
-	err = -EINVAL;
 	spin_lock_init(&conf->device_lock);
 	rdev_for_each(rdev, mddev) {
 		struct request_queue *q;
@@ -2816,8 +2823,11 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 		else
 			disk = conf->mirrors + disk_idx;
 
-		if (disk->rdev)
+		if (disk->rdev) {
+			err = -EINVAL;
 			goto abort;
+		}
+
 		disk->rdev = rdev;
 		q = bdev_get_queue(rdev->bdev);
 
@@ -2838,8 +2848,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 
 	conf->start_next_window = MaxSector;
 	conf->current_window_requests = conf->next_window_requests = 0;
-
-	err = -EIO;
 	for (i = 0; i < conf->raid_disks * 2; i++) {
 
 		disk = conf->mirrors + i;
@@ -2854,9 +2862,13 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 				disk->rdev =
 					disk[conf->raid_disks].rdev;
 				disk[conf->raid_disks].rdev = NULL;
-			} else if (!test_bit(In_sync, &disk->rdev->flags))
-				/* Original is not in_sync - bad */
-				goto abort;
+			} else {
+				if (!test_bit(In_sync, &disk->rdev->flags)) {
+					/* Original is not in_sync - bad */
+					err = -EIO;
+					goto abort;
+				}
+			}
 		}
 
 		if (!disk->rdev ||
@@ -2868,12 +2880,12 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 		}
 	}
 
-	err = -ENOMEM;
 	conf->thread = md_register_thread(raid1d, mddev, "raid1");
 	if (!conf->thread) {
 		printk(KERN_ERR
 		       "md/raid1:%s: couldn't allocate thread\n",
 		       mdname(mddev));
+		err = -ENOMEM;
 		goto abort;
 	}
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 15/54] md/raid1: Less function calls in setup_conf() after error detection
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-10-06  9:10   ` [PATCH 14/54] md/raid1: Move assignments for the variable "err" " SF Markus Elfring
@ 2016-10-06  9:11   ` SF Markus Elfring
  2016-10-06  9:12   ` [PATCH 16/54] md/raid1: Delete an error message for a failed memory allocation SF Markus Elfring
                     ` (38 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:11 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 18:01:02 +0200

Resource release functions were called in up to four cases
by the setup_conf() function during error handling even if
the passed data structure members 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/raid1.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 4d2fcbc..7dc45ba 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2786,19 +2786,19 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 				GFP_KERNEL);
 	if (!conf->mirrors) {
 		err = -ENOMEM;
-		goto abort;
+		goto free_conf;
 	}
 
 	conf->tmppage = alloc_page(GFP_KERNEL);
 	if (!conf->tmppage) {
 		err = -ENOMEM;
-		goto abort;
+		goto free_mirrors;
 	}
 
 	conf->poolinfo = kzalloc(sizeof(*conf->poolinfo), GFP_KERNEL);
 	if (!conf->poolinfo) {
 		err = -ENOMEM;
-		goto abort;
+		goto put_page;
 	}
 
 	conf->poolinfo->raid_disks = mddev->raid_disks * 2;
@@ -2807,7 +2807,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 					  conf->poolinfo);
 	if (!conf->r1bio_pool) {
 		err = -ENOMEM;
-		goto abort;
+		goto free_poolinfo;
 	}
 
 	conf->poolinfo->mddev = mddev;
@@ -2825,7 +2825,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 
 		if (disk->rdev) {
 			err = -EINVAL;
-			goto abort;
+			goto destroy_pool;
 		}
 
 		disk->rdev = rdev;
@@ -2866,7 +2866,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 				if (!test_bit(In_sync, &disk->rdev->flags)) {
 					/* Original is not in_sync - bad */
 					err = -EIO;
-					goto abort;
+					goto destroy_pool;
 				}
 			}
 		}
@@ -2886,16 +2886,19 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 		       "md/raid1:%s: couldn't allocate thread\n",
 		       mdname(mddev));
 		err = -ENOMEM;
-		goto abort;
+		goto destroy_pool;
 	}
 
 	return conf;
-
- abort:
+destroy_pool:
 	mempool_destroy(conf->r1bio_pool);
+free_poolinfo:
 	kfree(conf->poolinfo);
+put_page:
 	safe_put_page(conf->tmppage);
+free_mirrors:
 	kfree(conf->mirrors);
+free_conf:
 	kfree(conf);
 	return ERR_PTR(err);
 }
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 16/54] md/raid1: Delete an error message for a failed memory allocation
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (15 preceding siblings ...)
  2016-10-06  9:11   ` [PATCH 15/54] md/raid1: Less function calls in setup_conf() after error detection SF Markus Elfring
@ 2016-10-06  9:12   ` SF Markus Elfring
  2016-10-06  9:14   ` [PATCH 17/54] md/raid1: Move a brace for a designated initialiser SF Markus Elfring
                     ` (37 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:12 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 18:15:20 +0200

Omit an extra message 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/raid1.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 7dc45ba..15b9652 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2882,9 +2882,6 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 
 	conf->thread = md_register_thread(raid1d, mddev, "raid1");
 	if (!conf->thread) {
-		printk(KERN_ERR
-		       "md/raid1:%s: couldn't allocate thread\n",
-		       mdname(mddev));
 		err = -ENOMEM;
 		goto destroy_pool;
 	}
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 17/54] md/raid1: Move a brace for a designated initialiser
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (16 preceding siblings ...)
  2016-10-06  9:12   ` [PATCH 16/54] md/raid1: Delete an error message for a failed memory allocation SF Markus Elfring
@ 2016-10-06  9:14   ` SF Markus Elfring
  2016-10-06  9:15   ` [PATCH 18/54] md/raid1: Adjust 12 checks for null pointers SF Markus Elfring
                     ` (36 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:14 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 18:25:05 +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/raid1.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 15b9652..958bf41 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3176,8 +3176,7 @@ static void *raid1_takeover(struct mddev *mddev)
 	return ERR_PTR(-EINVAL);
 }
 
-static struct md_personality raid1_personality =
-{
+static struct md_personality raid1_personality = {
 	.name		= "raid1",
 	.level		= 1,
 	.owner		= THIS_MODULE,
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 18/54] md/raid1: Adjust 12 checks for null pointers
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (17 preceding siblings ...)
  2016-10-06  9:14   ` [PATCH 17/54] md/raid1: Move a brace for a designated initialiser SF Markus Elfring
@ 2016-10-06  9:15   ` SF Markus Elfring
  2016-10-06  9:16   ` [PATCH 19/54] md/raid1: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
                     ` (35 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:15 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 18:55:42 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 958bf41..3a1194e 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -474,7 +474,7 @@ static void raid1_end_write_request(struct bio *bio)
 			}
 		}
 	}
-	if (r1_bio->bios[mirror] == NULL)
+	if (!r1_bio->bios[mirror])
 		rdev_dec_pending(rdev, conf->mddev);
 
 	/*
@@ -549,7 +549,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect
 
 		rdev = rcu_dereference(conf->mirrors[disk].rdev);
 		if (r1_bio->bios[disk] == IO_BLOCKED
-		    || rdev == NULL
+		    || !rdev
 		    || test_bit(Faulty, &rdev->flags))
 			continue;
 		if (!test_bit(In_sync, &rdev->flags) &&
@@ -1582,7 +1582,7 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 	 */
 	if (rdev->saved_raid_disk >= 0 &&
 	    rdev->saved_raid_disk >= first &&
-	    conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
+	    !conf->mirrors[rdev->saved_raid_disk].rdev)
 		first = last = rdev->saved_raid_disk;
 
 	for (mirror = first; mirror <= last; mirror++) {
@@ -1605,7 +1605,7 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 			break;
 		}
 		if (test_bit(WantReplacement, &p->rdev->flags) &&
-		    p[conf->raid_disks].rdev == NULL) {
+		    !p[conf->raid_disks].rdev) {
 			/* Add this device as a replacement */
 			clear_bit(In_sync, &rdev->flags);
 			set_bit(Replacement, &rdev->flags);
@@ -2002,7 +2002,7 @@ static void sync_request_write(struct mddev *mddev, struct r1bio *r1_bio)
 	atomic_set(&r1_bio->remaining, 1);
 	for (i = 0; i < disks ; i++) {
 		wbio = r1_bio->bios[i];
-		if (wbio->bi_end_io == NULL ||
+		if (!wbio->bi_end_io ||
 		    (wbio->bi_end_io == end_sync_read &&
 		     (i == r1_bio->read_disk ||
 		      !test_bit(MD_RECOVERY_SYNC, &mddev->recovery))))
@@ -2220,7 +2220,7 @@ static void handle_sync_write_finished(struct r1conf *conf, struct r1bio *r1_bio
 	for (m = 0; m < conf->raid_disks * 2 ; m++) {
 		struct md_rdev *rdev = conf->mirrors[m].rdev;
 		struct bio *bio = r1_bio->bios[m];
-		if (bio->bi_end_io == NULL)
+		if (!bio->bi_end_io)
 			continue;
 		if (!bio->bi_error &&
 		    test_bit(R1BIO_MadeGood, &r1_bio->state)) {
@@ -2247,7 +2247,7 @@ static void handle_write_finished(struct r1conf *conf, struct r1bio *r1_bio)
 					     r1_bio->sector,
 					     r1_bio->sectors, 0);
 			rdev_dec_pending(rdev, conf->mddev);
-		} else if (r1_bio->bios[m] != NULL) {
+		} else if (r1_bio->bios[m]) {
 			/* This drive got a write error.  We need to
 			 * narrow down and record precise write
 			 * errors.
@@ -2509,7 +2509,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
 		return 0;
 	}
 
-	if (mddev->bitmap == NULL &&
+	if (!mddev->bitmap &&
 	    mddev->recovery_cp == MaxSector &&
 	    !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) &&
 	    conf->fullsync == 0) {
@@ -2564,7 +2564,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
 		bio_reset(bio);
 
 		rdev = rcu_dereference(conf->mirrors[i].rdev);
-		if (rdev == NULL ||
+		if (!rdev ||
 		    test_bit(Faulty, &rdev->flags)) {
 			if (i < conf->raid_disks)
 				still_degraded = 1;
@@ -2710,7 +2710,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
 					while (i > 0) {
 						i--;
 						bio = r1_bio->bios[i];
-						if (bio->bi_end_io==NULL)
+						if (!bio->bi_end_io)
 							continue;
 						/* remove last page from this bio */
 						bio->bi_vcnt--;
@@ -2924,7 +2924,7 @@ static int raid1_run(struct mddev *mddev)
 	 * bookkeeping area. [whatever we allocate in run(),
 	 * should be freed in raid1_free()]
 	 */
-	if (mddev->private == NULL)
+	if (!mddev->private)
 		conf = setup_conf(mddev);
 	else
 		conf = mddev->private;
@@ -2946,7 +2946,7 @@ static int raid1_run(struct mddev *mddev)
 
 	mddev->degraded = 0;
 	for (i=0; i < conf->raid_disks; i++)
-		if (conf->mirrors[i].rdev == NULL ||
+		if (!conf->mirrors[i].rdev ||
 		    !test_bit(In_sync, &conf->mirrors[i].rdev->flags) ||
 		    test_bit(Faulty, &conf->mirrors[i].rdev->flags))
 			mddev->degraded++;
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 19/54] md/raid1: Replace printk() calls by the usage of higher level interfaces
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (18 preceding siblings ...)
  2016-10-06  9:15   ` [PATCH 18/54] md/raid1: Adjust 12 checks for null pointers SF Markus Elfring
@ 2016-10-06  9:16   ` SF Markus Elfring
  2016-10-06  9:18   ` [PATCH 20/54] md/raid1: Add some spaces for better code readability SF Markus Elfring
                     ` (34 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:16 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 20:30:07 +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/raid1.c | 91 ++++++++++++++++++++++++++----------------------------
 1 file changed, 43 insertions(+), 48 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3a1194e..9754b7d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -31,6 +31,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/slab.h>
 #include <linux/delay.h>
 #include <linux/blkdev.h>
@@ -347,13 +349,11 @@ static void raid1_end_read_request(struct bio *bio)
 		 * oops, read error:
 		 */
 		char b[BDEVNAME_SIZE];
-		printk_ratelimited(
-			KERN_ERR "md/raid1:%s: %s: "
-			"rescheduling sector %llu\n",
-			mdname(conf->mddev),
-			bdevname(rdev->bdev,
-				 b),
-			(unsigned long long)r1_bio->sector);
+
+		pr_err_ratelimited("%s: %s: rescheduling sector %llu\n",
+				   mdname(conf->mddev),
+				   bdevname(rdev->bdev, b),
+				   (unsigned long long)r1_bio->sector);
 		set_bit(R1BIO_ReadError, &r1_bio->state);
 		reschedule_retry(r1_bio);
 		/* don't drop the reference on read_disk yet */
@@ -1457,34 +1457,34 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(MD_RECOVERY_INTR, &mddev->recovery);
 	set_mask_bits(&mddev->flags, 0,
 		      BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING));
-	printk(KERN_ALERT
-	       "md/raid1:%s: Disk failure on %s, disabling device.\n"
-	       "md/raid1:%s: Operation continuing on %d devices.\n",
-	       mdname(mddev), bdevname(rdev->bdev, b),
-	       mdname(mddev), conf->raid_disks - mddev->degraded);
+	pr_alert("%s: Disk failure on %s, disabling device.\n"
+		 MY_LOG_PREFIX "%s: Operation continuing on %d devices.\n",
+		 mdname(mddev), bdevname(rdev->bdev, b),
+		 mdname(mddev), conf->raid_disks - mddev->degraded);
 }
 
 static void print_conf(struct r1conf *conf)
 {
 	int i;
 
-	printk(KERN_DEBUG "RAID1 conf printout:\n");
+	pr_debug("conf printout:\n");
 	if (!conf) {
-		printk(KERN_DEBUG "(!conf)\n");
+		pr_debug("(!conf)\n");
 		return;
 	}
-	printk(KERN_DEBUG " --- wd:%d rd:%d\n", conf->raid_disks - conf->mddev->degraded,
-		conf->raid_disks);
+	pr_debug("--- wd:%d rd:%d\n",
+		 conf->raid_disks - conf->mddev->degraded,
+		 conf->raid_disks);
 
 	rcu_read_lock();
 	for (i = 0; i < conf->raid_disks; i++) {
 		char b[BDEVNAME_SIZE];
 		struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev);
 		if (rdev)
-			printk(KERN_DEBUG " disk %d, wo:%d, o:%d, dev:%s\n",
-			       i, !test_bit(In_sync, &rdev->flags),
-			       !test_bit(Faulty, &rdev->flags),
-			       bdevname(rdev->bdev,b));
+			pr_debug("disk %d, wo:%d, o:%d, dev:%s\n",
+				 i, !test_bit(In_sync, &rdev->flags),
+				 !test_bit(Faulty, &rdev->flags),
+				 bdevname(rdev->bdev, b));
 	}
 	rcu_read_unlock();
 }
@@ -1821,11 +1821,10 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
 			 * work just disable and interrupt the recovery.
 			 * Don't fail devices as that won't really help.
 			 */
-			printk(KERN_ALERT "md/raid1:%s: %s: unrecoverable I/O read error"
-			       " for block %llu\n",
-			       mdname(mddev),
-			       bdevname(bio->bi_bdev, b),
-			       (unsigned long long)r1_bio->sector);
+			pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n",
+				 mdname(mddev),
+				 bdevname(bio->bi_bdev, b),
+				 (unsigned long long)r1_bio->sector);
 			for (d = 0; d < conf->raid_disks * 2; d++) {
 				rdev = conf->mirrors[d].rdev;
 				if (!rdev || test_bit(Faulty, &rdev->flags))
@@ -2118,13 +2117,13 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 				if (r1_sync_page_io(rdev, sect, s,
 						    conf->tmppage, READ)) {
 					atomic_add(s, &rdev->corrected_errors);
-					printk(KERN_INFO
-					       "md/raid1:%s: read error corrected "
-					       "(%d sectors at %llu on %s)\n",
-					       mdname(mddev), s,
-					       (unsigned long long)(sect +
-								    rdev->data_offset),
-					       bdevname(rdev->bdev, b));
+					pr_info("%s: read error corrected "
+						"(%d sectors at %llu on %s)\n",
+						mdname(mddev),
+						s,
+						(unsigned long long)(sect +
+								     rdev->data_offset),
+						bdevname(rdev->bdev, b));
 				}
 				rdev_dec_pending(rdev, mddev);
 			} else
@@ -2307,9 +2306,8 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
 read_more:
 	disk = read_balance(conf, r1_bio, &max_sectors);
 	if (disk == -1) {
-		printk(KERN_ALERT "md/raid1:%s: %s: unrecoverable I/O"
-		       " read error for block %llu\n",
-		       mdname(mddev), b, (unsigned long long)r1_bio->sector);
+		pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n",
+			 mdname(mddev), b, (unsigned long long)r1_bio->sector);
 		raid_end_bio_io(r1_bio);
 	} else {
 		const unsigned long do_sync
@@ -2325,8 +2323,7 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
 			 max_sectors);
 		r1_bio->bios[r1_bio->read_disk] = bio;
 		rdev = conf->mirrors[disk].rdev;
-		printk_ratelimited(KERN_ERR
-				   "md/raid1:%s: redirecting sector %llu"
+		pr_err_ratelimited("%s: redirecting sector %llu"
 				   " to other mirror: %s\n",
 				   mdname(mddev),
 				   (unsigned long long)r1_bio->sector,
@@ -2910,12 +2907,12 @@ static int raid1_run(struct mddev *mddev)
 	bool discard_supported = false;
 
 	if (mddev->level != 1) {
-		printk(KERN_ERR "md/raid1:%s: raid level not set to mirroring (%d)\n",
+		pr_err("%s: raid level not set to mirroring (%d)\n",
 		       mdname(mddev), mddev->level);
 		return -EIO;
 	}
 	if (mddev->reshape_position != MaxSector) {
-		printk(KERN_ERR "md/raid1:%s: reshape_position set but not supported\n",
+		pr_err("%s: reshape_position set but not supported\n",
 		       mdname(mddev));
 		return -EIO;
 	}
@@ -2955,12 +2952,11 @@ static int raid1_run(struct mddev *mddev)
 		mddev->recovery_cp = MaxSector;
 
 	if (mddev->recovery_cp != MaxSector)
-		printk(KERN_NOTICE "md/raid1:%s: not clean"
-		       " -- starting background reconstruction\n",
-		       mdname(mddev));
-	printk(KERN_INFO
-		"md/raid1:%s: active with %d out of %d mirrors\n",
-		mdname(mddev), mddev->raid_disks - mddev->degraded,
+		pr_notice("%s: not clean -- starting background reconstruction\n",
+			  mdname(mddev));
+	pr_info("%s: active with %d out of %d mirrors\n",
+		mdname(mddev),
+		mddev->raid_disks - mddev->degraded,
 		mddev->raid_disks);
 
 	/*
@@ -3112,9 +3108,8 @@ static int raid1_reshape(struct mddev *mddev)
 			rdev->raid_disk = d2;
 			sysfs_unlink_rdev(mddev, rdev);
 			if (sysfs_link_rdev(mddev, rdev))
-				printk(KERN_WARNING
-				       "md/raid1:%s: cannot register rd%d\n",
-				       mdname(mddev), rdev->raid_disk);
+				pr_warn("%s: cannot register rd%d\n",
+					mdname(mddev), rdev->raid_disk);
 		}
 		if (rdev)
 			newmirrors[d2++].rdev = rdev;
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 20/54] md/raid1: Add some spaces for better code readability
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (19 preceding siblings ...)
  2016-10-06  9:16   ` [PATCH 19/54] md/raid1: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
@ 2016-10-06  9:18   ` SF Markus Elfring
  2016-10-06  9:19   ` [PATCH 21/54] md/raid1: Delete three unwanted spaces behind asterisks SF Markus Elfring
                     ` (33 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:18 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 20:42:25 +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/raid1.c | 62 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 9754b7d..3a03d19 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -136,8 +136,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
 	}
 	/* If not user-requests, copy the page pointers to all bios */
 	if (!test_bit(MD_RECOVERY_REQUESTED, &pi->mddev->recovery)) {
-		for (i=0; i<RESYNC_PAGES ; i++)
-			for (j=1; j<pi->raid_disks; j++)
+		for (i = 0; i < RESYNC_PAGES ; i++)
+			for (j = 1; j < pi->raid_disks; j++)
 				r1_bio->bios[j]->bi_io_vec[i].bv_page =
 					r1_bio->bios[0]->bi_io_vec[i].bv_page;
 	}
@@ -160,7 +160,7 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
 static void r1buf_pool_free(void *__r1_bio, void *data)
 {
 	struct pool_info *pi = data;
-	int i,j;
+	int i, j;
 	struct r1bio *r1bio = __r1_bio;
 
 	for (i = 0; i < RESYNC_PAGES; i++)
@@ -170,7 +170,7 @@ static void r1buf_pool_free(void *__r1_bio, void *data)
 			    r1bio->bios[0]->bi_io_vec[i].bv_page)
 				safe_put_page(r1bio->bios[j]->bi_io_vec[i].bv_page);
 		}
-	for (i=0 ; i < pi->raid_disks; i++)
+	for (i = 0 ; i < pi->raid_disks; i++)
 		bio_put(r1bio->bios[i]);
 
 	r1bio_pool_free(r1bio, data);
@@ -1785,7 +1785,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
 	int sectors = r1_bio->sectors;
 	int idx = 0;
 
-	while(sectors) {
+	while (sectors) {
 		int s = sectors;
 		int d = r1_bio->read_disk;
 		int success = 0;
@@ -2040,7 +2040,8 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 			   sector_t sect, int sectors)
 {
 	struct mddev *mddev = conf->mddev;
-	while(sectors) {
+
+	while (sectors) {
 		int s = sectors;
 		int d = read_disk;
 		int success = 0;
@@ -2087,7 +2088,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 		/* write it back and re-read */
 		start = d;
 		while (d != read_disk) {
-			if (d==0)
+			if (d == 0)
 				d = conf->raid_disks * 2;
 			d--;
 			rcu_read_lock();
@@ -2105,7 +2106,8 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
 		d = start;
 		while (d != read_disk) {
 			char b[BDEVNAME_SIZE];
-			if (d==0)
+
+			if (d == 0)
 				d = conf->raid_disks * 2;
 			d--;
 			rcu_read_lock();
@@ -2942,7 +2944,7 @@ static int raid1_run(struct mddev *mddev)
 	}
 
 	mddev->degraded = 0;
-	for (i=0; i < conf->raid_disks; i++)
+	for (i = 0; i < conf->raid_disks; i++)
 		if (!conf->mirrors[i].rdev ||
 		    !test_bit(In_sync, &conf->mirrors[i].rdev->flags) ||
 		    test_bit(Faulty, &conf->mirrors[i].rdev->flags))
@@ -3067,8 +3069,8 @@ static int raid1_reshape(struct mddev *mddev)
 	raid_disks = mddev->raid_disks + mddev->delta_disks;
 
 	if (raid_disks < conf->raid_disks) {
-		cnt=0;
-		for (d= 0; d < conf->raid_disks; d++)
+		cnt = 0;
+		for (d = 0; d < conf->raid_disks; d++)
 			if (conf->mirrors[d].rdev)
 				cnt++;
 		if (cnt > raid_disks)
@@ -3139,7 +3141,7 @@ static void raid1_quiesce(struct mddev *mddev, int state)
 {
 	struct r1conf *conf = mddev->private;
 
-	switch(state) {
+	switch (state) {
 	case 2: /* wake for suspend */
 		wake_up(&conf->wait_barrier);
 		break;
@@ -3172,24 +3174,24 @@ static void *raid1_takeover(struct mddev *mddev)
 }
 
 static struct md_personality raid1_personality = {
-	.name		= "raid1",
-	.level		= 1,
-	.owner		= THIS_MODULE,
-	.make_request	= raid1_make_request,
-	.run		= raid1_run,
-	.free		= raid1_free,
-	.status		= raid1_status,
-	.error_handler	= raid1_error,
-	.hot_add_disk	= raid1_add_disk,
-	.hot_remove_disk= raid1_remove_disk,
-	.spare_active	= raid1_spare_active,
-	.sync_request	= raid1_sync_request,
-	.resize		= raid1_resize,
-	.size		= raid1_size,
-	.check_reshape	= raid1_reshape,
-	.quiesce	= raid1_quiesce,
-	.takeover	= raid1_takeover,
-	.congested	= raid1_congested,
+	.name            = "raid1",
+	.level           = 1,
+	.owner           = THIS_MODULE,
+	.make_request    = raid1_make_request,
+	.run             = raid1_run,
+	.free            = raid1_free,
+	.status          = raid1_status,
+	.error_handler   = raid1_error,
+	.hot_add_disk    = raid1_add_disk,
+	.hot_remove_disk = raid1_remove_disk,
+	.spare_active    = raid1_spare_active,
+	.sync_request    = raid1_sync_request,
+	.resize          = raid1_resize,
+	.size            = raid1_size,
+	.check_reshape   = raid1_reshape,
+	.quiesce         = raid1_quiesce,
+	.takeover        = raid1_takeover,
+	.congested       = raid1_congested,
 };
 
 static int __init raid_init(void)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 21/54] md/raid1: Delete three unwanted spaces behind asterisks
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (20 preceding siblings ...)
  2016-10-06  9:18   ` [PATCH 20/54] md/raid1: Add some spaces for better code readability SF Markus Elfring
@ 2016-10-06  9:19   ` SF Markus Elfring
  2016-10-06  9:20   ` [PATCH 22/54] md/raid1: Delete three unwanted spaces before increment operators SF Markus Elfring
                     ` (32 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:19 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 21:01:34 +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/raid1.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 3a03d19..fc9d600 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -72,7 +72,7 @@ static void allow_barrier(struct r1conf *conf, sector_t start_next_window,
 			  sector_t bi_sector);
 static void lower_barrier(struct r1conf *conf);
 
-static void * r1bio_pool_alloc(gfp_t gfp_flags, void *data)
+static void *r1bio_pool_alloc(gfp_t gfp_flags, void *data)
 {
 	struct pool_info *pi = data;
 	int size = offsetof(struct r1bio, bios[pi->raid_disks]);
@@ -96,7 +96,7 @@ static void r1bio_pool_free(void *r1_bio, void *data)
 #define CLUSTER_RESYNC_WINDOW_SECTORS (CLUSTER_RESYNC_WINDOW >> 9)
 #define NEXT_NORMALIO_DISTANCE (3 * RESYNC_WINDOW_SECTORS)
 
-static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
+static void *r1buf_pool_alloc(gfp_t gfp_flags, void *data)
 {
 	struct pool_info *pi = data;
 	struct r1bio *r1_bio;
@@ -1027,7 +1027,7 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
 	kfree(plug);
 }
 
-static void raid1_make_request(struct mddev *mddev, struct bio * bio)
+static void raid1_make_request(struct mddev *mddev, struct bio *bio)
 {
 	struct r1conf *conf = mddev->private;
 	struct raid1_info *mirror;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 22/54] md/raid1: Delete three unwanted spaces before increment operators
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (21 preceding siblings ...)
  2016-10-06  9:19   ` [PATCH 21/54] md/raid1: Delete three unwanted spaces behind asterisks SF Markus Elfring
@ 2016-10-06  9:20   ` SF Markus Elfring
  2016-10-06  9:21   ` [PATCH 23/54] md/raid1: Replace a seq_printf() call by seq_puts() in raid1_status() SF Markus Elfring
                     ` (31 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:20 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 21:10:37 +0200

The script "checkpatch.pl" pointed information out like the following.

ERROR: space prohibited before that '++' (ctx:WxO)

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index fc9d600..95f6098 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -220,7 +220,7 @@ static void reschedule_retry(struct r1bio *r1_bio)
 
 	spin_lock_irqsave(&conf->device_lock, flags);
 	list_add(&r1_bio->retry_list, &conf->retry_list);
-	conf->nr_queued ++;
+	conf->nr_queued++;
 	spin_unlock_irqrestore(&conf->device_lock, flags);
 
 	wake_up(&conf->wait_barrier);
@@ -1878,7 +1878,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
 		}
 		sectors -= s;
 		sect += s;
-		idx ++;
+		idx++;
 	}
 	set_bit(R1BIO_Uptodate, &r1_bio->state);
 	bio->bi_error = 0;
@@ -2570,7 +2570,7 @@ static sector_t raid1_sync_request(struct mddev *mddev, sector_t sector_nr,
 		} else if (!test_bit(In_sync, &rdev->flags)) {
 			bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
 			bio->bi_end_io = end_sync_write;
-			write_targets ++;
+			write_targets++;
 		} else {
 			/* may need to read from here */
 			sector_t first_bad = MaxSector;
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 23/54] md/raid1: Replace a seq_printf() call by seq_puts() in raid1_status()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (22 preceding siblings ...)
  2016-10-06  9:20   ` [PATCH 22/54] md/raid1: Delete three unwanted spaces before increment operators SF Markus Elfring
@ 2016-10-06  9:21   ` SF Markus Elfring
  2016-10-06  9:22   ` [PATCH 24/54] md/raid1: Improve another size determination in setup_conf() SF Markus Elfring
                     ` (30 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:21 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 21:16:13 +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/raid1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 95f6098..ec6aafb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1417,7 +1417,7 @@ static void raid1_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 void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (23 preceding siblings ...)
  2016-10-06  9:21   ` [PATCH 23/54] md/raid1: Replace a seq_printf() call by seq_puts() in raid1_status() SF Markus Elfring
@ 2016-10-06  9:22   ` SF Markus Elfring
  2016-10-06  9:29     ` Richard Weinberger
  2016-10-06  9:23   ` [PATCH 25/54] md/raid5: Use kcalloc() in three functions SF Markus Elfring
                     ` (29 subsequent siblings)
  54 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:22 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 21:46: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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ec6aafb..5e1a427 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2776,7 +2776,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
 	struct md_rdev *rdev;
 	int err;
 
-	conf = kzalloc(sizeof(struct r1conf), GFP_KERNEL);
+	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (!conf)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 25/54] md/raid5: Use kcalloc() in three functions
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (24 preceding siblings ...)
  2016-10-06  9:22   ` [PATCH 24/54] md/raid1: Improve another size determination in setup_conf() SF Markus Elfring
@ 2016-10-06  9:23   ` SF Markus Elfring
  2016-10-06  9:25   ` [PATCH 26/54] md/raid5: Improve another size determination in setup_conf() SF Markus Elfring
                     ` (28 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:23 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 22:30:12 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 92ac251..9a43006 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2243,7 +2243,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 	 * is completely stalled, so now is a good time to resize
 	 * conf->disks and the scribble region
 	 */
-	ndisks = kzalloc(newsize * sizeof(struct disk_info), GFP_NOIO);
+	ndisks = kcalloc(newsize, sizeof(*ndisks), GFP_NOIO);
 	if (ndisks) {
 		for (i=0; i<conf->raid_disks; i++)
 			ndisks[i] = conf->disks[i];
@@ -6255,7 +6255,6 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt,
 			       struct r5worker_group **worker_groups)
 {
 	int i, j, k;
-	ssize_t size;
 	struct r5worker *workers;
 
 	*worker_cnt_per_group = cnt;
@@ -6265,10 +6264,8 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt,
 		return 0;
 	}
 	*group_cnt = num_possible_nodes();
-	size = sizeof(struct r5worker) * cnt;
-	workers = kzalloc(size * *group_cnt, GFP_NOIO);
-	*worker_groups = kzalloc(sizeof(struct r5worker_group) *
-				*group_cnt, GFP_NOIO);
+	workers = kcalloc(cnt * *group_cnt, sizeof(*workers), GFP_NOIO);
+	*worker_groups = kcalloc(*group_cnt, sizeof(**worker_groups), GFP_NOIO);
 	if (!*worker_groups || !workers) {
 		kfree(workers);
 		kfree(*worker_groups);
@@ -6519,9 +6516,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	else
 		conf->previous_raid_disks = mddev->raid_disks - mddev->delta_disks;
 	max_disks = max(conf->raid_disks, conf->previous_raid_disks);
-
-	conf->disks = kzalloc(max_disks * sizeof(struct disk_info),
-			      GFP_KERNEL);
+	conf->disks = kcalloc(max_disks, sizeof(*conf->disks), GFP_KERNEL);
 	if (!conf->disks)
 		goto abort;
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 26/54] md/raid5: Improve another size determination in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (25 preceding siblings ...)
  2016-10-06  9:23   ` [PATCH 25/54] md/raid5: Use kcalloc() in three functions SF Markus Elfring
@ 2016-10-06  9:25   ` SF Markus Elfring
  2016-10-06  9:26   ` [PATCH 27/54] md/raid5: Return directly after a failed kzalloc() " SF Markus Elfring
                     ` (27 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:25 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 22:35:06 +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/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 9a43006..562138f 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6481,7 +6481,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		return ERR_PTR(-EINVAL);
 	}
 
-	conf = kzalloc(sizeof(struct r5conf), GFP_KERNEL);
+	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (conf == NULL)
 		goto abort;
 	/* Don't enable multi-threading by default*/
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 27/54] md/raid5: Return directly after a failed kzalloc() in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (26 preceding siblings ...)
  2016-10-06  9:25   ` [PATCH 26/54] md/raid5: Improve another size determination in setup_conf() SF Markus Elfring
@ 2016-10-06  9:26   ` SF Markus Elfring
  2016-10-06  9:28   ` [PATCH 28/54] md/raid5: Rename a jump label " SF Markus Elfring
                     ` (26 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:26 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 4 Oct 2016 22:44:59 +0200

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Delete a repeated check for the local variable "conf"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 562138f..17f50a6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6482,8 +6482,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	}
 
 	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
-	if (conf == NULL)
-		goto abort;
+	if (!conf)
+		return ERR_PTR(-ENOMEM);
 	/* Don't enable multi-threading by default*/
 	if (!alloc_thread_groups(conf, 0, &group_cnt, &worker_cnt_per_group,
 				 &new_group)) {
@@ -6646,11 +6646,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	return conf;
 
  abort:
-	if (conf) {
-		free_conf(conf);
-		return ERR_PTR(-EIO);
-	} else
-		return ERR_PTR(-ENOMEM);
+	free_conf(conf);
+	return ERR_PTR(-EIO);
 }
 
 static int only_parity(int raid_disk, int algo, int raid_disks, int max_degraded)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 28/54] md/raid5: Rename a jump label in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (27 preceding siblings ...)
  2016-10-06  9:26   ` [PATCH 27/54] md/raid5: Return directly after a failed kzalloc() " SF Markus Elfring
@ 2016-10-06  9:28   ` SF Markus Elfring
  2016-10-06  9:29   ` [PATCH 29/54] md/raid5: Return directly after a failed kcalloc() in alloc_thread_groups() SF Markus Elfring
                     ` (25 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:28 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 08:18:38 +0200

Adjust jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 17f50a6..b624ba6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6490,8 +6490,10 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		conf->group_cnt = group_cnt;
 		conf->worker_cnt_per_group = worker_cnt_per_group;
 		conf->worker_groups = new_group;
-	} else
-		goto abort;
+	} else {
+		goto free_conf;
+	}
+
 	spin_lock_init(&conf->device_lock);
 	seqcount_init(&conf->gen_lock);
 	mutex_init(&conf->cache_size_mutex);
@@ -6518,12 +6520,12 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	max_disks = max(conf->raid_disks, conf->previous_raid_disks);
 	conf->disks = kcalloc(max_disks, sizeof(*conf->disks), GFP_KERNEL);
 	if (!conf->disks)
-		goto abort;
+		goto free_conf;
 
 	conf->mddev = mddev;
 
 	if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
-		goto abort;
+		goto free_conf;
 
 	/* We init hash_locks[0] separately to that it can be used
 	 * as the reference lock in the spin_lock_nest_lock() call
@@ -6543,7 +6545,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	conf->level = mddev->new_level;
 	conf->chunk_sectors = mddev->new_chunk_sectors;
 	if (raid5_alloc_percpu(conf) != 0)
-		goto abort;
+		goto free_conf;
 
 	pr_debug("raid456: run(%s) called.\n", mdname(mddev));
 
@@ -6556,11 +6558,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 
 		if (test_bit(Replacement, &rdev->flags)) {
 			if (disk->replacement)
-				goto abort;
+				goto free_conf;
 			disk->replacement = rdev;
 		} else {
 			if (disk->rdev)
-				goto abort;
+				goto free_conf;
 			disk->rdev = rdev;
 		}
 
@@ -6613,7 +6615,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		printk(KERN_ERR
 		       "md/raid:%s: couldn't allocate %dkB for buffers\n",
 		       mdname(mddev), memory);
-		goto abort;
+		goto free_conf;
 	} else
 		printk(KERN_INFO "md/raid:%s: allocated %dkB\n",
 		       mdname(mddev), memory);
@@ -6631,7 +6633,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		printk(KERN_ERR
 		       "md/raid:%s: couldn't register shrinker.\n",
 		       mdname(mddev));
-		goto abort;
+		goto free_conf;
 	}
 
 	sprintf(pers_name, "raid%d", mddev->new_level);
@@ -6640,12 +6642,11 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		printk(KERN_ERR
 		       "md/raid:%s: couldn't allocate thread.\n",
 		       mdname(mddev));
-		goto abort;
+		goto free_conf;
 	}
 
 	return conf;
-
- abort:
+free_conf:
 	free_conf(conf);
 	return ERR_PTR(-EIO);
 }
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 29/54] md/raid5: Return directly after a failed kcalloc() in alloc_thread_groups()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (28 preceding siblings ...)
  2016-10-06  9:28   ` [PATCH 28/54] md/raid5: Rename a jump label " SF Markus Elfring
@ 2016-10-06  9:29   ` SF Markus Elfring
  2016-10-06  9:30   ` [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation SF Markus Elfring
                     ` (24 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:29 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 08:54:40 +0200

The kfree() function was called in up to two cases
by the alloc_thread_groups() function during error handling
even if the passed variable contained a null pointer.

* Return directly after a call of the kcalloc() function failed
  at the beginning.

* Simplify a condition check for memory allocation failures.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index b624ba6..d864871 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6265,10 +6265,12 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt,
 	}
 	*group_cnt = num_possible_nodes();
 	workers = kcalloc(cnt * *group_cnt, sizeof(*workers), GFP_NOIO);
+	if (!workers)
+		return -ENOMEM;
+
 	*worker_groups = kcalloc(*group_cnt, sizeof(**worker_groups), GFP_NOIO);
-	if (!*worker_groups || !workers) {
+	if (!*worker_groups) {
 		kfree(workers);
-		kfree(*worker_groups);
 		return -ENOMEM;
 	}
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-06  9:22   ` [PATCH 24/54] md/raid1: Improve another size determination in setup_conf() SF Markus Elfring
@ 2016-10-06  9:29     ` Richard Weinberger
  2016-10-07  7:53       ` Dan Carpenter
  2016-10-10 11:12       ` Dan Carpenter
  0 siblings, 2 replies; 221+ messages in thread
From: Richard Weinberger @ 2016-10-06  9:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid@vger.kernel.org, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On Thu, Oct 6, 2016 at 11:22 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 4 Oct 2016 21:46: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.

Isn't this pure matter of taste?
Some developers prefer sizeof(*ptr) because it is easier to type, other
developers prefer sizeof(struct foo) because you can determine the type
at first sight and makes review more easy.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (29 preceding siblings ...)
  2016-10-06  9:29   ` [PATCH 29/54] md/raid5: Return directly after a failed kcalloc() in alloc_thread_groups() SF Markus Elfring
@ 2016-10-06  9:30   ` SF Markus Elfring
  2016-10-07  5:51     ` Hannes Reinecke
  2016-10-06  9:31   ` [PATCH 31/54] md/raid5: Adjust two function calls together with a variable assignment SF Markus Elfring
                     ` (23 subsequent siblings)
  54 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:30 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 09:43:40 +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/raid5.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d864871..ef180c0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6613,12 +6613,9 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	memory = conf->min_nr_stripes * (sizeof(struct stripe_head) +
 		 max_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024;
 	atomic_set(&conf->empty_inactive_list_nr, NR_STRIPE_HASH_LOCKS);
-	if (grow_stripes(conf, conf->min_nr_stripes)) {
-		printk(KERN_ERR
-		       "md/raid:%s: couldn't allocate %dkB for buffers\n",
-		       mdname(mddev), memory);
+	if (grow_stripes(conf, conf->min_nr_stripes))
 		goto free_conf;
-	} else
+	else
 		printk(KERN_INFO "md/raid:%s: allocated %dkB\n",
 		       mdname(mddev), memory);
 	/*
@@ -6640,12 +6637,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 
 	sprintf(pers_name, "raid%d", mddev->new_level);
 	conf->thread = md_register_thread(raid5d, mddev, pers_name);
-	if (!conf->thread) {
-		printk(KERN_ERR
-		       "md/raid:%s: couldn't allocate thread.\n",
-		       mdname(mddev));
+	if (!conf->thread)
 		goto free_conf;
-	}
 
 	return conf;
 free_conf:
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 31/54] md/raid5: Adjust two function calls together with a variable assignment
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (30 preceding siblings ...)
  2016-10-06  9:30   ` [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation SF Markus Elfring
@ 2016-10-06  9:31   ` SF Markus Elfring
  2016-10-06  9:32   ` [PATCH 32/54] md/raid5: Move a brace for three designated initialisers SF Markus Elfring
                     ` (22 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:31 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 10:00:07 +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/raid5.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ef180c0..a37f1f9 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -501,11 +501,10 @@ static int grow_buffers(struct stripe_head *sh, gfp_t gfp)
 	int num = sh->raid_conf->pool_size;
 
 	for (i = 0; i < num; i++) {
-		struct page *page;
+		struct page *page = alloc_page(gfp);
 
-		if (!(page = alloc_page(gfp))) {
+		if (!page)
 			return 1;
-		}
 		sh->dev[i].page = page;
 		sh->dev[i].orig_page = page;
 	}
@@ -6525,8 +6524,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 		goto free_conf;
 
 	conf->mddev = mddev;
-
-	if ((conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL)) == NULL)
+	conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL);
+	if (!conf->stripe_hashtbl)
 		goto free_conf;
 
 	/* We init hash_locks[0] separately to that it can be used
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 32/54] md/raid5: Move a brace for three designated initialisers
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (31 preceding siblings ...)
  2016-10-06  9:31   ` [PATCH 31/54] md/raid5: Adjust two function calls together with a variable assignment SF Markus Elfring
@ 2016-10-06  9:32   ` SF Markus Elfring
  2016-10-06  9:33   ` [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
                     ` (21 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:32 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 10:20:05 +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/raid5.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index a37f1f9..f2473fa0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7868,8 +7868,7 @@ static void *raid6_takeover(struct mddev *mddev)
 	return setup_conf(mddev);
 }
 
-static struct md_personality raid6_personality =
-{
+static struct md_personality raid6_personality = {
 	.name		= "raid6",
 	.level		= 6,
 	.owner		= THIS_MODULE,
@@ -7891,8 +7890,7 @@ static struct md_personality raid6_personality =
 	.takeover	= raid6_takeover,
 	.congested	= raid5_congested,
 };
-static struct md_personality raid5_personality =
-{
+static struct md_personality raid5_personality = {
 	.name		= "raid5",
 	.level		= 5,
 	.owner		= THIS_MODULE,
@@ -7914,9 +7912,7 @@ static struct md_personality raid5_personality =
 	.takeover	= raid5_takeover,
 	.congested	= raid5_congested,
 };
-
-static struct md_personality raid4_personality =
-{
+static struct md_personality raid4_personality = {
 	.name		= "raid4",
 	.level		= 4,
 	.owner		= THIS_MODULE,
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (32 preceding siblings ...)
  2016-10-06  9:32   ` [PATCH 32/54] md/raid5: Move a brace for three designated initialisers SF Markus Elfring
@ 2016-10-06  9:33   ` SF Markus Elfring
  2016-10-06  9:34   ` [PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring
                     ` (20 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:33 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 13:40:03 +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/raid5.c | 215 ++++++++++++++++++++++++-----------------------------
 1 file changed, 96 insertions(+), 119 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f2473fa0..b0a14a6 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -43,6 +43,8 @@
  * miss any bits.
  */
 
+#define MY_LOG_PREFIX KBUILD_MODNAME ": "
+#define pr_fmt(fmt) MY_LOG_PREFIX fmt
 #include <linux/blkdev.h>
 #include <linux/kthread.h>
 #include <linux/raid/pq.h>
@@ -540,7 +542,7 @@ static void init_stripe(struct stripe_head *sh, sector_t sector, int previous)
 
 		if (dev->toread || dev->read || dev->towrite || dev->written ||
 		    test_bit(R5_LOCKED, &dev->flags)) {
-			printk(KERN_ERR "sector=%llx i=%d %p %p %p %p %d\n",
+			pr_err("sector=%llx i=%d %p %p %p %p %d\n",
 			       (unsigned long long)sh->sector, i, dev->toread,
 			       dev->read, dev->towrite, dev->written,
 			       test_bit(R5_LOCKED, &dev->flags));
@@ -2346,13 +2348,12 @@ static void raid5_end_read_request(struct bio * bi)
 			 * replacement device.  We just fail those on
 			 * any error
 			 */
-			printk_ratelimited(
-				KERN_INFO
-				"md/raid:%s: read error corrected"
-				" (%lu sectors at %llu on %s)\n",
-				mdname(conf->mddev), STRIPE_SECTORS,
-				(unsigned long long)s,
-				bdevname(rdev->bdev, b));
+			pr_info_ratelimited("%s: read error corrected ("
+					    "%lu sectors at %llu on %s)\n",
+					    mdname(conf->mddev),
+					    STRIPE_SECTORS,
+					    (unsigned long long)s,
+					    bdevname(rdev->bdev, b));
 			atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
 			clear_bit(R5_ReadError, &sh->dev[i].flags);
 			clear_bit(R5_ReWrite, &sh->dev[i].flags);
@@ -2369,37 +2370,27 @@ static void raid5_end_read_request(struct bio * bi)
 		clear_bit(R5_UPTODATE, &sh->dev[i].flags);
 		atomic_inc(&rdev->read_errors);
 		if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
-			printk_ratelimited(
-				KERN_WARNING
-				"md/raid:%s: read error on replacement device "
-				"(sector %llu on %s).\n",
-				mdname(conf->mddev),
-				(unsigned long long)s,
-				bdn);
+			pr_warn_ratelimited("%s: read error on replacement device (sector %llu on %s).\n",
+					    mdname(conf->mddev),
+					    (unsigned long long)s,
+					    bdn);
 		else if (conf->mddev->degraded >= conf->max_degraded) {
 			set_bad = 1;
-			printk_ratelimited(
-				KERN_WARNING
-				"md/raid:%s: read error not correctable "
-				"(sector %llu on %s).\n",
-				mdname(conf->mddev),
-				(unsigned long long)s,
-				bdn);
+			pr_warn_ratelimited("%s: read error not correctable (sector %llu on %s).\n",
+					    mdname(conf->mddev),
+					    (unsigned long long)s,
+					    bdn);
 		} else if (test_bit(R5_ReWrite, &sh->dev[i].flags)) {
 			/* Oh, no!!! */
 			set_bad = 1;
-			printk_ratelimited(
-				KERN_WARNING
-				"md/raid:%s: read error NOT corrected!! "
-				"(sector %llu on %s).\n",
-				mdname(conf->mddev),
-				(unsigned long long)s,
-				bdn);
+			pr_warn_ratelimited("%s: read error NOT corrected! (sector %llu on %s).\n",
+					    mdname(conf->mddev),
+					    (unsigned long long)s,
+					    bdn);
 		} else if (atomic_read(&rdev->read_errors)
 			 > conf->max_nr_stripes)
-			printk(KERN_WARNING
-			       "md/raid:%s: Too many read errors, failing device %s.\n",
-			       mdname(conf->mddev), bdn);
+			pr_warn("%s: Too many read errors, failing device %s.\n",
+				mdname(conf->mddev), bdn);
 		else
 			retry = 1;
 		if (set_bad && test_bit(In_sync, &rdev->flags)
@@ -2532,13 +2523,12 @@ static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_bit(Faulty, &rdev->flags);
 	set_mask_bits(&mddev->flags, 0,
 		      BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING));
-	printk(KERN_ALERT
-	       "md/raid:%s: Disk failure on %s, disabling device.\n"
-	       "md/raid:%s: Operation continuing on %d devices.\n",
-	       mdname(mddev),
-	       bdevname(rdev->bdev, b),
-	       mdname(mddev),
-	       conf->raid_disks - mddev->degraded);
+	pr_alert("%s: Disk failure on %s, disabling device.\n"
+		 MY_LOG_PREFIX "%s: Operation continuing on %d devices.\n",
+		 mdname(mddev),
+		 bdevname(rdev->bdev, b),
+		 mdname(mddev),
+		 conf->raid_disks - mddev->degraded);
 }
 
 /*
@@ -2860,7 +2850,7 @@ sector_t raid5_compute_blocknr(struct stripe_head *sh, int i, int previous)
 				     previous, &dummy1, &sh2);
 	if (check != sh->sector || dummy1 != dd_idx || sh2.pd_idx != sh->pd_idx
 		|| sh2.qd_idx != sh->qd_idx) {
-		printk(KERN_ERR "md/raid:%s: compute_blocknr: map not correct\n",
+		pr_err("%s: compute_blocknr: map not correct\n",
 		       mdname(conf->mddev));
 		return 0;
 	}
@@ -3781,7 +3771,7 @@ static void handle_parity_checks5(struct r5conf *conf, struct stripe_head *sh,
 	case check_state_compute_run:
 		break;
 	default:
-		printk(KERN_ERR "%s: unknown check_state: %d sector: %llu\n",
+		pr_err("%s: unknown check_state: %d sector: %llu\n",
 		       __func__, sh->check_state,
 		       (unsigned long long) sh->sector);
 		BUG();
@@ -3945,7 +3935,7 @@ static void handle_parity_checks6(struct r5conf *conf, struct stripe_head *sh,
 	case check_state_compute_run:
 		break;
 	default:
-		printk(KERN_ERR "%s: unknown check_state: %d sector: %llu\n",
+		pr_err("%s: unknown check_state: %d sector: %llu\n",
 		       __func__, sh->check_state,
 		       (unsigned long long) sh->sector);
 		BUG();
@@ -6456,7 +6446,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	if (mddev->new_level != 5
 	    && mddev->new_level != 4
 	    && mddev->new_level != 6) {
-		printk(KERN_ERR "md/raid:%s: raid level not set to 4/5/6 (%d)\n",
+		pr_err("%s: raid level not set to 4/5/6 (%d)\n",
 		       mdname(mddev), mddev->new_level);
 		return ERR_PTR(-EIO);
 	}
@@ -6464,12 +6454,12 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	     && !algorithm_valid_raid5(mddev->new_layout)) ||
 	    (mddev->new_level == 6
 	     && !algorithm_valid_raid6(mddev->new_layout))) {
-		printk(KERN_ERR "md/raid:%s: layout %d not supported\n",
+		pr_err("%s: layout %d not supported\n",
 		       mdname(mddev), mddev->new_layout);
 		return ERR_PTR(-EIO);
 	}
 	if (mddev->new_level == 6 && mddev->raid_disks < 4) {
-		printk(KERN_ERR "md/raid:%s: not enough configured devices (%d, minimum 4)\n",
+		pr_err("%s: not enough configured devices (%d, minimum 4)\n",
 		       mdname(mddev), mddev->raid_disks);
 		return ERR_PTR(-EINVAL);
 	}
@@ -6477,7 +6467,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	if (!mddev->new_chunk_sectors ||
 	    (mddev->new_chunk_sectors << 9) % PAGE_SIZE ||
 	    !is_power_of_2(mddev->new_chunk_sectors)) {
-		printk(KERN_ERR "md/raid:%s: invalid chunk size %d\n",
+		pr_err("%s: invalid chunk size %d\n",
 		       mdname(mddev), mddev->new_chunk_sectors << 9);
 		return ERR_PTR(-EINVAL);
 	}
@@ -6569,8 +6559,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 
 		if (test_bit(In_sync, &rdev->flags)) {
 			char b[BDEVNAME_SIZE];
-			printk(KERN_INFO "md/raid:%s: device %s operational as raid"
-			       " disk %d\n",
+			pr_info("%s: device %s operational as raid disk %d\n",
 			       mdname(mddev), bdevname(rdev->bdev, b), raid_disk);
 		} else if (rdev->saved_raid_disk != raid_disk)
 			/* Cannot rely on bitmap to complete recovery */
@@ -6605,8 +6594,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 			((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4);
 		conf->min_nr_stripes = max(NR_STRIPES, stripes);
 		if (conf->min_nr_stripes != NR_STRIPES)
-			printk(KERN_INFO
-				"md/raid:%s: force stripe size %d for reshape\n",
+			pr_info("%s: force stripe size %d for reshape\n",
 				mdname(mddev), conf->min_nr_stripes);
 	}
 	memory = conf->min_nr_stripes * (sizeof(struct stripe_head) +
@@ -6615,8 +6603,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	if (grow_stripes(conf, conf->min_nr_stripes))
 		goto free_conf;
 	else
-		printk(KERN_INFO "md/raid:%s: allocated %dkB\n",
-		       mdname(mddev), memory);
+		pr_info("%s: allocated %dkB\n", mdname(mddev), memory);
 	/*
 	 * Losing a stripe head costs more than the time to refill it,
 	 * it reduces the queue depth and so can hurt throughput.
@@ -6628,9 +6615,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
 	conf->shrinker.batch = 128;
 	conf->shrinker.flags = 0;
 	if (register_shrinker(&conf->shrinker)) {
-		printk(KERN_ERR
-		       "md/raid:%s: couldn't register shrinker.\n",
-		       mdname(mddev));
+		pr_err("%s: couldn't register shrinker.\n", mdname(mddev));
 		goto free_conf;
 	}
 
@@ -6684,9 +6669,8 @@ static int raid5_run(struct mddev *mddev)
 	int first = 1;
 
 	if (mddev->recovery_cp != MaxSector)
-		printk(KERN_NOTICE "md/raid:%s: not clean"
-		       " -- starting background reconstruction\n",
-		       mdname(mddev));
+		pr_notice("%s: not clean - starting background reconstruction\n",
+			  mdname(mddev));
 
 	rdev_for_each(rdev, mddev) {
 		long long diff;
@@ -6729,15 +6713,14 @@ static int raid5_run(struct mddev *mddev)
 		int new_data_disks;
 
 		if (journal_dev) {
-			printk(KERN_ERR "md/raid:%s: don't support reshape with journal - aborting.\n",
-			       mdname(mddev));
+			pr_err("%s: don't support reshape with journal%s",
+			       mdname(mddev), " - aborting.\n");
 			return -EINVAL;
 		}
 
 		if (mddev->new_level != mddev->level) {
-			printk(KERN_ERR "md/raid:%s: unsupported reshape "
-			       "required - aborting.\n",
-			       mdname(mddev));
+			pr_err("%s: unsupported reshape required%s",
+			       mdname(mddev), " - aborting.\n");
 			return -EINVAL;
 		}
 		old_disks = mddev->raid_disks - mddev->delta_disks;
@@ -6752,8 +6735,8 @@ static int raid5_run(struct mddev *mddev)
 		chunk_sectors = max(mddev->chunk_sectors, mddev->new_chunk_sectors);
 		new_data_disks = mddev->raid_disks - max_degraded;
 		if (sector_div(here_new, chunk_sectors * new_data_disks)) {
-			printk(KERN_ERR "md/raid:%s: reshape_position not "
-			       "on a stripe boundary\n", mdname(mddev));
+			pr_err("%s: reshape_position not on a stripe boundary\n",
+			       mdname(mddev));
 			return -EINVAL;
 		}
 		reshape_offset = here_new * chunk_sectors;
@@ -6774,10 +6757,8 @@ static int raid5_run(struct mddev *mddev)
 			    abs(min_offset_diff) >= mddev->new_chunk_sectors)
 				/* not really in-place - so OK */;
 			else if (mddev->ro == 0) {
-				printk(KERN_ERR "md/raid:%s: in-place reshape "
-				       "must be started in read-only mode "
-				       "- aborting\n",
-				       mdname(mddev));
+				pr_err("%s: in-place reshape must be started in read-only mode%s",
+				       mdname(mddev), " - aborting.\n");
 				return -EINVAL;
 			}
 		} else if (mddev->reshape_backwards
@@ -6786,13 +6767,11 @@ static int raid5_run(struct mddev *mddev)
 		    : (here_new * chunk_sectors >=
 		       here_old * chunk_sectors + (-min_offset_diff))) {
 			/* Reading from the same stripe as writing to - bad */
-			printk(KERN_ERR "md/raid:%s: reshape_position too early for "
-			       "auto-recovery - aborting.\n",
-			       mdname(mddev));
+			pr_err("%s: reshape_position too early for auto-recovery%s",
+			       mdname(mddev), " - aborting.\n");
 			return -EINVAL;
 		}
-		printk(KERN_INFO "md/raid:%s: reshape will continue\n",
-		       mdname(mddev));
+		pr_info("%s: reshape will continue\n", mdname(mddev));
 		/* OK, we should be able to continue; */
 	} else {
 		BUG_ON(mddev->level != mddev->new_level);
@@ -6811,7 +6790,7 @@ static int raid5_run(struct mddev *mddev)
 
 	if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
 		if (!journal_dev) {
-			pr_err("md/raid:%s: journal disk is missing, force array readonly\n",
+			pr_err("%s: journal disk is missing, force array readonly\n",
 			       mdname(mddev));
 			mddev->ro = 1;
 			set_disk_ro(mddev->gendisk, 1);
@@ -6839,8 +6818,7 @@ static int raid5_run(struct mddev *mddev)
 		if (conf->disks[i].replacement &&
 		    conf->reshape_progress != MaxSector) {
 			/* replacements and reshape simply do not mix. */
-			printk(KERN_ERR "md: cannot handle concurrent "
-			       "replacement and reshape.\n");
+			pr_err("cannot handle concurrent replacement and reshape.\n");
 			goto abort;
 		}
 		if (test_bit(In_sync, &rdev->flags)) {
@@ -6882,9 +6860,8 @@ static int raid5_run(struct mddev *mddev)
 	mddev->degraded = calc_degraded(conf);
 
 	if (has_failed(conf)) {
-		printk(KERN_ERR "md/raid:%s: not enough operational devices"
-			" (%d/%d failed)\n",
-			mdname(mddev), mddev->degraded, conf->raid_disks);
+		pr_err("%s: not enough operational devices (%d/%d failed)\n",
+		       mdname(mddev), mddev->degraded, conf->raid_disks);
 		goto abort;
 	}
 
@@ -6894,30 +6871,30 @@ static int raid5_run(struct mddev *mddev)
 
 	if (mddev->degraded > dirty_parity_disks &&
 	    mddev->recovery_cp != MaxSector) {
-		if (mddev->ok_start_degraded)
-			printk(KERN_WARNING
-			       "md/raid:%s: starting dirty degraded array"
-			       " - data corruption possible.\n",
-			       mdname(mddev));
-		else {
-			printk(KERN_ERR
-			       "md/raid:%s: cannot start dirty degraded array.\n",
+		if (mddev->ok_start_degraded) {
+			pr_warn("%s: starting dirty degraded array - data corruption possible.\n",
+				mdname(mddev));
+		} else {
+			pr_err("%s: cannot start dirty degraded array.\n",
 			       mdname(mddev));
 			goto abort;
 		}
 	}
 
 	if (mddev->degraded == 0)
-		printk(KERN_INFO "md/raid:%s: raid level %d active with %d out of %d"
-		       " devices, algorithm %d\n", mdname(mddev), conf->level,
-		       mddev->raid_disks-mddev->degraded, mddev->raid_disks,
-		       mddev->new_layout);
+		pr_info("%s: raid level %d active with %d out of %d devices, algorithm %d\n",
+			mdname(mddev),
+			conf->level,
+			mddev->raid_disks-mddev->degraded,
+			mddev->raid_disks,
+			mddev->new_layout);
 	else
-		printk(KERN_ALERT "md/raid:%s: raid level %d active with %d"
-		       " out of %d devices, algorithm %d\n",
-		       mdname(mddev), conf->level,
-		       mddev->raid_disks - mddev->degraded,
-		       mddev->raid_disks, mddev->new_layout);
+		pr_alert("%s: raid level %d active with %d out of %d devices, algorithm %d\n",
+			 mdname(mddev),
+			 conf->level,
+			 mddev->raid_disks - mddev->degraded,
+			 mddev->raid_disks,
+			 mddev->new_layout);
 
 	print_raid5_conf(conf);
 
@@ -6937,9 +6914,8 @@ static int raid5_run(struct mddev *mddev)
 		mddev->to_remove = NULL;
 	else if (mddev->kobj.sd &&
 	    sysfs_create_group(&mddev->kobj, &raid5_attrs_group))
-		printk(KERN_WARNING
-		       "raid5: failed to create sysfs attributes for %s\n",
-		       mdname(mddev));
+		pr_warn("failed to create sysfs attributes for %s\n",
+			mdname(mddev));
 	md_set_array_sectors(mddev, raid5_size(mddev, 0, 0));
 
 	if (mddev->queue) {
@@ -7027,8 +7003,8 @@ static int raid5_run(struct mddev *mddev)
 	if (journal_dev) {
 		char b[BDEVNAME_SIZE];
 
-		printk(KERN_INFO"md/raid:%s: using device %s as journal\n",
-		       mdname(mddev), bdevname(journal_dev->bdev, b));
+		pr_info("%s: using device %s as journal\n",
+			mdname(mddev), bdevname(journal_dev->bdev, b));
 		r5l_init_log(conf, journal_dev);
 	}
 
@@ -7038,7 +7014,7 @@ static int raid5_run(struct mddev *mddev)
 	print_raid5_conf(conf);
 	free_conf(conf);
 	mddev->private = NULL;
-	printk(KERN_ALERT "md/raid:%s: failed to run raid set.\n", mdname(mddev));
+	pr_alert("%s: failed to run raid set.\n", mdname(mddev));
 	return -EIO;
 }
 
@@ -7072,22 +7048,23 @@ static void print_raid5_conf (struct r5conf *conf)
 	int i;
 	struct disk_info *tmp;
 
-	printk(KERN_DEBUG "RAID conf printout:\n");
+	pr_debug("conf printout:\n");
 	if (!conf) {
-		printk("(conf==NULL)\n");
+		pr_debug("(conf==NULL)\n");
 		return;
 	}
-	printk(KERN_DEBUG " --- level:%d rd:%d wd:%d\n", conf->level,
-	       conf->raid_disks,
-	       conf->raid_disks - conf->mddev->degraded);
+	pr_debug("--- level:%d rd:%d wd:%d\n",
+		 conf->level,
+		 conf->raid_disks,
+		 conf->raid_disks - conf->mddev->degraded);
 
 	for (i = 0; i < conf->raid_disks; i++) {
 		char b[BDEVNAME_SIZE];
 		tmp = conf->disks + i;
 		if (tmp->rdev)
-			printk(KERN_DEBUG " disk %d, o:%d, dev:%s\n",
-			       i, !test_bit(Faulty, &tmp->rdev->flags),
-			       bdevname(tmp->rdev->bdev, b));
+			pr_debug("disk %d, o:%d, dev:%s\n",
+				 i, !test_bit(Faulty, &tmp->rdev->flags),
+				 bdevname(tmp->rdev->bdev, b));
 	}
 }
 
@@ -7233,8 +7210,8 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 		 * write requests running. We should be safe
 		 */
 		r5l_init_log(conf, rdev);
-		printk(KERN_INFO"md/raid:%s: using device %s as journal\n",
-		       mdname(mddev), bdevname(rdev->bdev, b));
+		pr_info("%s: using device %s as journal\n",
+			mdname(mddev), bdevname(rdev->bdev, b));
 		return 0;
 	}
 	if (mddev->recovery_disabled == conf->recovery_disabled)
@@ -7338,9 +7315,9 @@ static int check_stripe_cache(struct mddev *mddev)
 	    > conf->min_nr_stripes ||
 	    ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4
 	    > conf->min_nr_stripes) {
-		printk(KERN_WARNING "md/raid:%s: reshape: not enough stripes.  Needed %lu\n",
-		       mdname(mddev),
-		       ((max(mddev->chunk_sectors, mddev->new_chunk_sectors) << 9)
+		pr_warn("%s: reshape: not enough stripes.  Needed %lu\n",
+			mdname(mddev),
+			((max(mddev->chunk_sectors, mddev->new_chunk_sectors) << 9)
 			/ STRIPE_SIZE)*4);
 		return 0;
 	}
@@ -7422,8 +7399,8 @@ static int raid5_start_reshape(struct mddev *mddev)
 	 */
 	if (raid5_size(mddev, 0, conf->raid_disks + mddev->delta_disks)
 	    < mddev->array_sectors) {
-		printk(KERN_ERR "md/raid:%s: array size must be reduced "
-		       "before number of disks\n", mdname(mddev));
+		pr_err("%s: array size must be reduced before number of disks\n",
+		       mdname(mddev));
 		return -EINVAL;
 	}
 
@@ -7641,7 +7618,7 @@ static void *raid45_takeover_raid0(struct mddev *mddev, int level)
 
 	/* for raid0 takeover only one zone is supported */
 	if (raid0_conf->nr_strip_zones > 1) {
-		printk(KERN_ERR "md/raid:%s: cannot takeover raid0 with more than one zone.\n",
+		pr_err("%s: cannot takeover raid0 with more than one zone.\n",
 		       mdname(mddev));
 		return ERR_PTR(-EINVAL);
 	}
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 34/54] md/raid5: Delete indentation for two jump labels
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (33 preceding siblings ...)
  2016-10-06  9:33   ` [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
@ 2016-10-06  9:34   ` SF Markus Elfring
  2016-10-06  9:35   ` [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring
                     ` (19 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:34 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 13:45:18 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: labels should not be indented

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index b0a14a6..4debd86 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5089,7 +5089,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
 	     logical_sector += STRIPE_SECTORS) {
 		DEFINE_WAIT(w);
 		int d;
-	again:
+again:
 		sh = raid5_get_active_stripe(conf, logical_sector, 0, 0, 0);
 		prepare_to_wait(&conf->wait_for_overlap, &w,
 				TASK_UNINTERRUPTIBLE);
@@ -5204,7 +5204,7 @@ static void raid5_make_request(struct mddev *mddev, struct bio * bi)
 		int seq;
 
 		do_prepare = false;
-	retry:
+retry:
 		seq = read_seqcount_begin(&conf->gen_lock);
 		previous = 0;
 		if (do_prepare)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (34 preceding siblings ...)
  2016-10-06  9:34   ` [PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring
@ 2016-10-06  9:35   ` SF Markus Elfring
  2016-10-06  9:36   ` [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names SF Markus Elfring
                     ` (18 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:35 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 14:07:49 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid5.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 4debd86..f7a3369 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -679,7 +679,7 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector,
 					set_bit(R5_ALLOC_MORE,
 						&conf->cache_state);
 			}
-			if (noblock && sh == NULL)
+			if (noblock && !sh)
 				break;
 			if (!sh) {
 				set_bit(R5_INACTIVE_BLOCKED,
@@ -719,7 +719,7 @@ raid5_get_active_stripe(struct r5conf *conf, sector_t sector,
 			atomic_inc(&sh->count);
 			spin_unlock(&conf->device_lock);
 		}
-	} while (sh == NULL);
+	} while (!sh);
 
 	spin_unlock_irq(conf->hash_locks + hash);
 	return sh;
@@ -2260,7 +2260,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 		list_del_init(&nsh->lru);
 
 		for (i=conf->raid_disks; i < newsize; i++)
-			if (nsh->dev[i].page == NULL) {
+			if (!nsh->dev[i].page) {
 				struct page *p = alloc_page(GFP_NOIO);
 				nsh->dev[i].page = p;
 				nsh->dev[i].orig_page = p;
@@ -2977,7 +2977,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
 		goto overlap;
 	if (forwrite) {
 		bip = &sh->dev[dd_idx].towrite;
-		if (*bip == NULL)
+		if (!*bip)
 			firstwrite = 1;
 	} else
 		bip = &sh->dev[dd_idx].toread;
@@ -3962,7 +3962,7 @@ static void handle_stripe_expansion(struct r5conf *conf, struct stripe_head *sh)
 			sector_t s = raid5_compute_sector(conf, bn, 0,
 							  &dd_idx, NULL);
 			sh2 = raid5_get_active_stripe(conf, s, 0, 1, 1);
-			if (sh2 == NULL)
+			if (!sh2)
 				/* so far only the early blocks of this stripe
 				 * have been requested.  When later blocks
 				 * get requested, we will try again
@@ -4094,7 +4094,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 		if (rdev) {
 			is_bad = is_badblock(rdev, sh->sector, STRIPE_SECTORS,
 					     &first_bad, &bad_sectors);
-			if (s->blocked_rdev == NULL
+			if (!s->blocked_rdev
 			    && (test_bit(Blocked, &rdev->flags)
 				|| is_bad < 0)) {
 				if (is_bad < 0)
@@ -5044,8 +5044,7 @@ static void release_stripe_plug(struct mddev *mddev,
 	}
 
 	cb = container_of(blk_cb, struct raid5_plug_cb, cb);
-
-	if (cb->list.next == NULL) {
+	if (!cb->list.next) {
 		int i;
 		INIT_LIST_HEAD(&cb->list);
 		for (i = 0; i < NR_STRIPE_HASH_LOCKS; i++)
@@ -5653,7 +5652,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
 	bitmap_cond_end_sync(mddev->bitmap, sector_nr, false);
 
 	sh = raid5_get_active_stripe(conf, sector_nr, 0, 1, 0);
-	if (sh == NULL) {
+	if (!sh) {
 		sh = raid5_get_active_stripe(conf, sector_nr, 0, 0, 0);
 		/* make sure we don't swamp the stripe cache if someone else
 		 * is trying to get access
@@ -5668,7 +5667,7 @@ static inline sector_t raid5_sync_request(struct mddev *mddev, sector_t sector_n
 	for (i = 0; i < conf->raid_disks; i++) {
 		struct md_rdev *rdev = ACCESS_ONCE(conf->disks[i].rdev);
 
-		if (rdev == NULL || test_bit(Faulty, &rdev->flags))
+		if (!rdev || test_bit(Faulty, &rdev->flags))
 			still_degraded = 1;
 	}
 	rcu_read_unlock();
@@ -6780,7 +6779,7 @@ static int raid5_run(struct mddev *mddev)
 		BUG_ON(mddev->delta_disks != 0);
 	}
 
-	if (mddev->private == NULL)
+	if (!mddev->private)
 		conf = setup_conf(mddev);
 	else
 		conf = mddev->private;
@@ -7230,12 +7229,12 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 	 */
 	if (rdev->saved_raid_disk >= 0 &&
 	    rdev->saved_raid_disk >= first &&
-	    conf->disks[rdev->saved_raid_disk].rdev == NULL)
+	    !conf->disks[rdev->saved_raid_disk].rdev)
 		first = rdev->saved_raid_disk;
 
 	for (disk = first; disk <= last; disk++) {
 		p = conf->disks + disk;
-		if (p->rdev == NULL) {
+		if (!p->rdev) {
 			clear_bit(In_sync, &rdev->flags);
 			rdev->raid_disk = disk;
 			err = 0;
@@ -7248,7 +7247,7 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 	for (disk = first; disk <= last; disk++) {
 		p = conf->disks + disk;
 		if (test_bit(WantReplacement, &p->rdev->flags) &&
-		    p->replacement == NULL) {
+		    !p->replacement) {
 			clear_bit(In_sync, &rdev->flags);
 			set_bit(Replacement, &rdev->flags);
 			rdev->raid_disk = disk;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (35 preceding siblings ...)
  2016-10-06  9:35   ` [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring
@ 2016-10-06  9:36   ` SF Markus Elfring
  2016-10-06  9:37   ` [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status() SF Markus Elfring
                     ` (17 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:36 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 14:37:17 +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/raid5.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index f7a3369..ebcd692 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -236,7 +236,7 @@ static void return_io(struct bio_list *return_bi)
 	}
 }
 
-static void print_raid5_conf (struct r5conf *conf);
+static void print_raid5_conf(struct r5conf *conf);
 
 static int stripe_operations_active(struct stripe_head *sh)
 {
@@ -7032,17 +7032,22 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
 
 	seq_printf(seq, " level %d, %dk chunk, algorithm %d", mddev->level,
 		conf->chunk_sectors / 2, mddev->layout);
-	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->disks[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, "]");
 }
 
-static void print_raid5_conf (struct r5conf *conf)
+static void print_raid5_conf(struct r5conf *conf)
 {
 	int i;
 	struct disk_info *tmp;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (36 preceding siblings ...)
  2016-10-06  9:36   ` [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names SF Markus Elfring
@ 2016-10-06  9:37   ` SF Markus Elfring
  2016-10-06 16:34     ` Joe Perches
  2016-10-06  9:38   ` [PATCH 38/54] md/raid5: Move four asterisks SF Markus Elfring
                     ` (16 subsequent siblings)
  54 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:37 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 14:40:27 +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/raid5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index ebcd692..7a825c0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7044,7 +7044,7 @@ static void raid5_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 void print_raid5_conf(struct r5conf *conf)
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 38/54] md/raid5: Move four asterisks
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (37 preceding siblings ...)
  2016-10-06  9:37   ` [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status() SF Markus Elfring
@ 2016-10-06  9:38   ` SF Markus Elfring
  2016-10-06  9:39   ` [PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring
                     ` (15 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:38 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 15:00:23 +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/raid5.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 7a825c0..5bcc1ff 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2306,7 +2306,7 @@ static void shrink_stripes(struct r5conf *conf)
 	conf->slab_cache = NULL;
 }
 
-static void raid5_end_read_request(struct bio * bi)
+static void raid5_end_read_request(struct bio *bi)
 {
 	struct stripe_head *sh = bi->bi_private;
 	struct r5conf *conf = sh->raid_conf;
@@ -4760,7 +4760,7 @@ static struct bio *remove_bio_from_retry(struct r5conf *conf)
  */
 static void raid5_align_endio(struct bio *bi)
 {
-	struct bio* raid_bi  = bi->bi_private;
+	struct bio *raid_bi = bi->bi_private;
 	struct mddev *mddev;
 	struct r5conf *conf;
 	struct md_rdev *rdev;
@@ -4793,7 +4793,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 {
 	struct r5conf *conf = mddev->private;
 	int dd_idx;
-	struct bio* align_bi;
+	struct bio *align_bi;
 	struct md_rdev *rdev;
 	sector_t end_sector;
 
@@ -5149,7 +5149,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
 	}
 }
 
-static void raid5_make_request(struct mddev *mddev, struct bio * bi)
+static void raid5_make_request(struct mddev *mddev, struct bio *bi)
 {
 	struct r5conf *conf = mddev->private;
 	int dd_idx;
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 39/54] md/raid5: Add some spaces for better code readability
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (38 preceding siblings ...)
  2016-10-06  9:38   ` [PATCH 38/54] md/raid5: Move four asterisks SF Markus Elfring
@ 2016-10-06  9:39   ` SF Markus Elfring
  2016-10-06  9:40   ` [PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring
                     ` (14 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:39 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 16:00:32 +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/raid5.c | 165 +++++++++++++++++++++++++++--------------------------
 1 file changed, 83 insertions(+), 82 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 5bcc1ff..e29c198 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -292,7 +292,7 @@ static void do_release_stripe(struct r5conf *conf, struct stripe_head *sh,
 			      struct list_head *temp_inactive_list)
 {
 	BUG_ON(!list_empty(&sh->lru));
-	BUG_ON(atomic_read(&conf->active_stripes)==0);
+	BUG_ON(atomic_read(&conf->active_stripes) == 0);
 	if (test_bit(STRIPE_HANDLE, &sh->state)) {
 		if (test_bit(STRIPE_DELAYED, &sh->state) &&
 		    !test_bit(STRIPE_PREREAD_ACTIVE, &sh->state))
@@ -2224,7 +2224,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 		osh = get_free_stripe(conf, hash);
 		unlock_device_hash_lock(conf, hash);
 
-		for(i=0; i<conf->pool_size; i++) {
+		for (i = 0; i < conf->pool_size; i++) {
 			nsh->dev[i].page = osh->dev[i].page;
 			nsh->dev[i].orig_page = osh->dev[i].page;
 		}
@@ -2246,7 +2246,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 	 */
 	ndisks = kcalloc(newsize, sizeof(*ndisks), GFP_NOIO);
 	if (ndisks) {
-		for (i=0; i<conf->raid_disks; i++)
+		for (i = 0; i < conf->raid_disks; i++)
 			ndisks[i] = conf->disks[i];
 		kfree(conf->disks);
 		conf->disks = ndisks;
@@ -2255,11 +2255,11 @@ static int resize_stripes(struct r5conf *conf, int newsize)
 
 	mutex_unlock(&conf->cache_size_mutex);
 	/* Step 4, return new stripes to service */
-	while(!list_empty(&newstripes)) {
+	while (!list_empty(&newstripes)) {
 		nsh = list_entry(newstripes.next, struct stripe_head, lru);
 		list_del_init(&nsh->lru);
 
-		for (i=conf->raid_disks; i < newsize; i++)
+		for (i = conf->raid_disks; i < newsize; i++)
 			if (!nsh->dev[i].page) {
 				struct page *p = alloc_page(GFP_NOIO);
 				nsh->dev[i].page = p;
@@ -2315,7 +2315,7 @@ static void raid5_end_read_request(struct bio *bi)
 	struct md_rdev *rdev = NULL;
 	sector_t s;
 
-	for (i=0 ; i<disks; i++)
+	for (i = 0 ; i < disks; i++)
 		if (bi == &sh->dev[i].req)
 			break;
 
@@ -2571,7 +2571,7 @@ sector_t raid5_compute_sector(struct r5conf *conf, sector_t r_sector,
 	 * Select the parity disk based on the user selected algorithm.
 	 */
 	pd_idx = qd_idx = -1;
-	switch(conf->level) {
+	switch (conf->level) {
 	case 4:
 		pd_idx = data_disks;
 		break;
@@ -2759,7 +2759,7 @@ sector_t raid5_compute_blocknr(struct stripe_head *sh, int i, int previous)
 
 	if (i == sh->pd_idx)
 		return 0;
-	switch(conf->level) {
+	switch (conf->level) {
 	case 4: break;
 	case 5:
 		switch (algorithm) {
@@ -2957,7 +2957,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
 {
 	struct bio **bip;
 	struct r5conf *conf = sh->raid_conf;
-	int firstwrite=0;
+	int firstwrite = 0;
 
 	pr_debug("adding bi b#%llu to stripe s#%llu\n",
 		(unsigned long long)bi->bi_iter.bi_sector,
@@ -3001,7 +3001,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
 	if (forwrite) {
 		/* check if page is covered */
 		sector_t sector = sh->dev[dd_idx].sector;
-		for (bi=sh->dev[dd_idx].towrite;
+		for (bi = sh->dev[dd_idx].towrite;
 		     sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
 			     bi && bi->bi_iter.bi_sector <= sector;
 		     bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) {
@@ -3639,7 +3639,8 @@ static void handle_stripe_dirtying(struct r5conf *conf,
 	}
 	if ((rcw < rmw || (rcw == rmw && conf->rmw_level != PARITY_PREFER_RMW)) && rcw > 0) {
 		/* want reconstruct write, but need to get some data */
-		int qread =0;
+		int qread = 0;
+
 		rcw = 0;
 		for (i = disks; i--; ) {
 			struct r5dev *dev = &sh->dev[i];
@@ -4031,7 +4032,7 @@ static void analyse_stripe(struct stripe_head *sh, struct stripe_head_state *s)
 
 	/* Now to look around and see what can be done */
 	rcu_read_lock();
-	for (i=disks; i--; ) {
+	for (i = disks; i--; ) {
 		struct md_rdev *rdev;
 		sector_t first_bad;
 		int bad_sectors;
@@ -4716,7 +4717,7 @@ static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
  *  add bio to the retry LIFO  ( in O(1) ... we are in interrupt )
  *  later sampled by raid5d.
  */
-static void add_bio_to_retry(struct bio *bi,struct r5conf *conf)
+static void add_bio_to_retry(struct bio *bi, struct r5conf *conf)
 {
 	unsigned long flags;
 
@@ -4739,7 +4740,7 @@ static struct bio *remove_bio_from_retry(struct r5conf *conf)
 		return bi;
 	}
 	bi = conf->retry_read_aligned_list;
-	if(bi) {
+	if (bi) {
 		conf->retry_read_aligned_list = bi->bi_next;
 		bi->bi_next = NULL;
 		/*
@@ -4768,7 +4769,7 @@ static void raid5_align_endio(struct bio *bi)
 
 	bio_put(bi);
 
-	rdev = (void*)raid_bi->bi_next;
+	rdev = (void *)raid_bi->bi_next;
 	raid_bi->bi_next = NULL;
 	mddev = rdev->mddev;
 	conf = mddev->private;
@@ -4838,7 +4839,7 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
 
 		atomic_inc(&rdev->nr_pending);
 		rcu_read_unlock();
-		raid_bio->bi_next = (void*)rdev;
+		raid_bio->bi_next = (void *)rdev;
 		align_bi->bi_bdev =  rdev->bdev;
 		bio_clear_flag(align_bi, BIO_SEG_VALID);
 
@@ -5198,7 +5199,7 @@ static void raid5_make_request(struct mddev *mddev, struct bio *bi)
 	bi->bi_phys_segments = 1;	/* over-loaded to count active stripes */
 
 	prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
-	for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
+	for (; logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
 		int previous;
 		int seq;
 
@@ -5464,10 +5465,10 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *sk
 	if ((mddev->reshape_backwards
 	     ? (safepos > writepos && readpos < writepos)
 	     : (safepos < writepos && readpos > writepos)) ||
-	    time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) {
+	    time_after(jiffies, conf->reshape_checkpoint + 10 * HZ)) {
 		/* Cannot proceed until we've updated the superblock... */
 		wait_event(conf->wait_for_overlap,
-			   atomic_read(&conf->reshape_stripes)==0
+			   atomic_read(&conf->reshape_stripes) == 0
 			   || test_bit(MD_RECOVERY_INTR, &mddev->recovery));
 		if (atomic_read(&conf->reshape_stripes) != 0)
 			return 0;
@@ -5497,7 +5498,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, int *sk
 		/* If any of this stripe is beyond the end of the old
 		 * array, then we need to zero those blocks
 		 */
-		for (j=sh->disks; j--;) {
+		for (j = sh->disks; j--;) {
 			sector_t s;
 			if (j == sh->pd_idx)
 				continue;
@@ -6406,7 +6407,7 @@ static unsigned long raid5_cache_scan(struct shrinker *shrink,
 	unsigned long ret = SHRINK_STOP;
 
 	if (mutex_trylock(&conf->cache_size_mutex)) {
-		ret= 0;
+		ret = 0;
 		while (ret < sc->nr_to_scan &&
 		       conf->max_nr_stripes > conf->min_nr_stripes) {
 			if (drop_one_stripe(conf) == 0) {
@@ -7582,7 +7583,7 @@ static void raid5_quiesce(struct mddev *mddev, int state)
 {
 	struct r5conf *conf = mddev->private;
 
-	switch(state) {
+	switch (state) {
 	case 2: /* resume for a suspend */
 		wake_up(&conf->wait_for_overlap);
 		break;
@@ -7850,70 +7851,70 @@ static void *raid6_takeover(struct mddev *mddev)
 }
 
 static struct md_personality raid6_personality = {
-	.name		= "raid6",
-	.level		= 6,
-	.owner		= THIS_MODULE,
-	.make_request	= raid5_make_request,
-	.run		= raid5_run,
-	.free		= raid5_free,
-	.status		= raid5_status,
-	.error_handler	= raid5_error,
-	.hot_add_disk	= raid5_add_disk,
-	.hot_remove_disk= raid5_remove_disk,
-	.spare_active	= raid5_spare_active,
-	.sync_request	= raid5_sync_request,
-	.resize		= raid5_resize,
-	.size		= raid5_size,
-	.check_reshape	= raid6_check_reshape,
-	.start_reshape  = raid5_start_reshape,
-	.finish_reshape = raid5_finish_reshape,
-	.quiesce	= raid5_quiesce,
-	.takeover	= raid6_takeover,
-	.congested	= raid5_congested,
+	.name            = "raid6",
+	.level           = 6,
+	.owner           = THIS_MODULE,
+	.make_request    = raid5_make_request,
+	.run             = raid5_run,
+	.free            = raid5_free,
+	.status          = raid5_status,
+	.error_handler   = raid5_error,
+	.hot_add_disk    = raid5_add_disk,
+	.hot_remove_disk = raid5_remove_disk,
+	.spare_active    = raid5_spare_active,
+	.sync_request    = raid5_sync_request,
+	.resize          = raid5_resize,
+	.size            = raid5_size,
+	.check_reshape   = raid6_check_reshape,
+	.start_reshape   = raid5_start_reshape,
+	.finish_reshape  = raid5_finish_reshape,
+	.quiesce         = raid5_quiesce,
+	.takeover        = raid6_takeover,
+	.congested       = raid5_congested,
 };
 static struct md_personality raid5_personality = {
-	.name		= "raid5",
-	.level		= 5,
-	.owner		= THIS_MODULE,
-	.make_request	= raid5_make_request,
-	.run		= raid5_run,
-	.free		= raid5_free,
-	.status		= raid5_status,
-	.error_handler	= raid5_error,
-	.hot_add_disk	= raid5_add_disk,
-	.hot_remove_disk= raid5_remove_disk,
-	.spare_active	= raid5_spare_active,
-	.sync_request	= raid5_sync_request,
-	.resize		= raid5_resize,
-	.size		= raid5_size,
-	.check_reshape	= raid5_check_reshape,
-	.start_reshape  = raid5_start_reshape,
-	.finish_reshape = raid5_finish_reshape,
-	.quiesce	= raid5_quiesce,
-	.takeover	= raid5_takeover,
-	.congested	= raid5_congested,
+	.name            = "raid5",
+	.level           = 5,
+	.owner           = THIS_MODULE,
+	.make_request    = raid5_make_request,
+	.run             = raid5_run,
+	.free            = raid5_free,
+	.status          = raid5_status,
+	.error_handler   = raid5_error,
+	.hot_add_disk    = raid5_add_disk,
+	.hot_remove_disk = raid5_remove_disk,
+	.spare_active    = raid5_spare_active,
+	.sync_request    = raid5_sync_request,
+	.resize          = raid5_resize,
+	.size            = raid5_size,
+	.check_reshape   = raid5_check_reshape,
+	.start_reshape   = raid5_start_reshape,
+	.finish_reshape  = raid5_finish_reshape,
+	.quiesce         = raid5_quiesce,
+	.takeover        = raid5_takeover,
+	.congested       = raid5_congested,
 };
 static struct md_personality raid4_personality = {
-	.name		= "raid4",
-	.level		= 4,
-	.owner		= THIS_MODULE,
-	.make_request	= raid5_make_request,
-	.run		= raid5_run,
-	.free		= raid5_free,
-	.status		= raid5_status,
-	.error_handler	= raid5_error,
-	.hot_add_disk	= raid5_add_disk,
-	.hot_remove_disk= raid5_remove_disk,
-	.spare_active	= raid5_spare_active,
-	.sync_request	= raid5_sync_request,
-	.resize		= raid5_resize,
-	.size		= raid5_size,
-	.check_reshape	= raid5_check_reshape,
-	.start_reshape  = raid5_start_reshape,
-	.finish_reshape = raid5_finish_reshape,
-	.quiesce	= raid5_quiesce,
-	.takeover	= raid4_takeover,
-	.congested	= raid5_congested,
+	.name            = "raid4",
+	.level           = 4,
+	.owner           = THIS_MODULE,
+	.make_request    = raid5_make_request,
+	.run             = raid5_run,
+	.free            = raid5_free,
+	.status          = raid5_status,
+	.error_handler   = raid5_error,
+	.hot_add_disk    = raid5_add_disk,
+	.hot_remove_disk = raid5_remove_disk,
+	.spare_active    = raid5_spare_active,
+	.sync_request    = raid5_sync_request,
+	.resize          = raid5_resize,
+	.size            = raid5_size,
+	.check_reshape   = raid5_check_reshape,
+	.start_reshape   = raid5_start_reshape,
+	.finish_reshape  = raid5_finish_reshape,
+	.quiesce         = raid5_quiesce,
+	.takeover        = raid4_takeover,
+	.congested       = raid5_congested,
 };
 
 static int __init raid5_init(void)
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 40/54] md/raid10: Use kcalloc() in two functions
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (39 preceding siblings ...)
  2016-10-06  9:39   ` [PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring
@ 2016-10-06  9:40   ` SF Markus Elfring
  2016-10-06  9:41   ` [PATCH 41/54] md/raid10: Improve another size determination in setup_conf() SF Markus Elfring
                     ` (13 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:40 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 16:45:05 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kcalloc".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data structures by pointer dereferences
  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/raid10.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index be1a9fc..17352a9 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3504,8 +3504,8 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 		goto out;
 
 	/* FIXME calc properly */
-	conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks +
-							    max(0,-mddev->delta_disks)),
+	conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
+				sizeof(*conf->mirrors),
 				GFP_KERNEL);
 	if (!conf->mirrors)
 		goto out;
@@ -3936,11 +3936,10 @@ static int raid10_check_reshape(struct mddev *mddev)
 	conf->mirrors_new = NULL;
 	if (mddev->delta_disks > 0) {
 		/* allocate new 'mirrors' list */
-		conf->mirrors_new = kzalloc(
-			sizeof(struct raid10_info)
-			*(mddev->raid_disks +
-			  mddev->delta_disks),
-			GFP_KERNEL);
+		conf->mirrors_new = kcalloc(mddev->raid_disks
+					    + mddev->delta_disks,
+					    sizeof(*conf->mirrors_new),
+					    GFP_KERNEL);
 		if (!conf->mirrors_new)
 			return -ENOMEM;
 	}
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 41/54] md/raid10: Improve another size determination in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (40 preceding siblings ...)
  2016-10-06  9:40   ` [PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring
@ 2016-10-06  9:41   ` SF Markus Elfring
  2016-10-06  9:42   ` [PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation SF Markus Elfring
                     ` (12 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:41 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 16:51:52 +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/raid10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 17352a9..04e8f78 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3499,7 +3499,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	}
 
 	err = -ENOMEM;
-	conf = kzalloc(sizeof(struct r10conf), GFP_KERNEL);
+	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (!conf)
 		goto out;
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (41 preceding siblings ...)
  2016-10-06  9:41   ` [PATCH 41/54] md/raid10: Improve another size determination in setup_conf() SF Markus Elfring
@ 2016-10-06  9:42   ` SF Markus Elfring
  2016-10-06  9:43   ` [PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf() SF Markus Elfring
                     ` (11 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:42 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 16:57:19 +0200

Omit an extra message for a memory allocation failure
(and another corresponding condition check) 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/raid10.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 04e8f78..1f712f7 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3554,9 +3554,6 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	return conf;
 
  out:
-	if (err == -ENOMEM)
-		printk(KERN_ERR "md/raid10:%s: couldn't allocate memory.\n",
-		       mdname(mddev));
 	if (conf) {
 		mempool_destroy(conf->r10bio_pool);
 		kfree(conf->mirrors);
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (42 preceding siblings ...)
  2016-10-06  9:42   ` [PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation SF Markus Elfring
@ 2016-10-06  9:43   ` SF Markus Elfring
  2016-10-06  9:44   ` [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() " SF Markus Elfring
                     ` (10 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:43 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 17:32:49 +0200

* Return directly after unsupported system settings were detected
  at the beginning.

* Delete the explicit initialisation for the local variables "conf"
  and "err" which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1f712f7..8326e68 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3478,8 +3478,8 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)
 
 static struct r10conf *setup_conf(struct mddev *mddev)
 {
-	struct r10conf *conf = NULL;
-	int err = -EINVAL;
+	struct r10conf *conf;
+	int err;
 	struct geom geo;
 	int copies;
 
@@ -3489,13 +3489,13 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 		printk(KERN_ERR "md/raid10:%s: chunk size must be "
 		       "at least PAGE_SIZE(%ld) and be a power of 2.\n",
 		       mdname(mddev), PAGE_SIZE);
-		goto out;
+		return ERR_PTR(-EINVAL);
 	}
 
 	if (copies < 2 || copies > mddev->raid_disks) {
 		printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",
 		       mdname(mddev), mddev->new_layout);
-		goto out;
+		return ERR_PTR(-EINVAL);
 	}
 
 	err = -ENOMEM;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (43 preceding siblings ...)
  2016-10-06  9:43   ` [PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf() SF Markus Elfring
@ 2016-10-06  9:44   ` SF Markus Elfring
  2016-10-06  9:45   ` [PATCH 45/54] md/raid10: Move assignments for the variable "err" " SF Markus Elfring
                     ` (9 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:44 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 17:46:02 +0200

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Delete a repeated check for the local variable "conf"
  which became unnecessary with this refactoring.

* Reorder calls for the functions "kfree" and "safe_put_page"
  at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 8326e68..abe75c2 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3501,7 +3501,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	err = -ENOMEM;
 	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (!conf)
-		goto out;
+		return ERR_PTR(-ENOMEM);
 
 	/* FIXME calc properly */
 	conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
@@ -3554,12 +3554,10 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	return conf;
 
  out:
-	if (conf) {
-		mempool_destroy(conf->r10bio_pool);
-		kfree(conf->mirrors);
-		safe_put_page(conf->tmppage);
-		kfree(conf);
-	}
+	mempool_destroy(conf->r10bio_pool);
+	safe_put_page(conf->tmppage);
+	kfree(conf->mirrors);
+	kfree(conf);
 	return ERR_PTR(err);
 }
 
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 45/54] md/raid10: Move assignments for the variable "err" in setup_conf()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (44 preceding siblings ...)
  2016-10-06  9:44   ` [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() " SF Markus Elfring
@ 2016-10-06  9:45   ` SF Markus Elfring
  2016-10-06  9:46   ` [PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection SF Markus Elfring
                     ` (8 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:45 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 18:26:45 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignments
into if branches to indicate a memory allocation failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index abe75c2..7e512d4 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3498,7 +3498,6 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 		return ERR_PTR(-EINVAL);
 	}
 
-	err = -ENOMEM;
 	conf = kzalloc(sizeof(*conf), GFP_KERNEL);
 	if (!conf)
 		return ERR_PTR(-ENOMEM);
@@ -3507,19 +3506,25 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
 				sizeof(*conf->mirrors),
 				GFP_KERNEL);
-	if (!conf->mirrors)
+	if (!conf->mirrors) {
+		err = -ENOMEM;
 		goto out;
+	}
 
 	conf->tmppage = alloc_page(GFP_KERNEL);
-	if (!conf->tmppage)
+	if (!conf->tmppage) {
+		err = -ENOMEM;
 		goto out;
+	}
 
 	conf->geo = geo;
 	conf->copies = copies;
 	conf->r10bio_pool = mempool_create(NR_RAID10_BIOS, r10bio_pool_alloc,
 					   r10bio_pool_free, conf);
-	if (!conf->r10bio_pool)
+	if (!conf->r10bio_pool) {
+		err = -ENOMEM;
 		goto out;
+	}
 
 	calc_sectors(conf, mddev->dev_sectors);
 	if (mddev->reshape_position == MaxSector) {
@@ -3547,8 +3552,10 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	atomic_set(&conf->nr_pending, 0);
 
 	conf->thread = md_register_thread(raid10d, mddev, "raid10");
-	if (!conf->thread)
+	if (!conf->thread) {
+		err = -ENOMEM;
 		goto out;
+	}
 
 	conf->mddev = mddev;
 	return conf;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (45 preceding siblings ...)
  2016-10-06  9:45   ` [PATCH 45/54] md/raid10: Move assignments for the variable "err" " SF Markus Elfring
@ 2016-10-06  9:46   ` SF Markus Elfring
  2016-10-06  9:47   ` [PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape() SF Markus Elfring
                     ` (7 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:46 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 18:32:30 +0200

Resource release functions were called in up to three cases
by the setup_conf() function during error handling even if
the passed data structure members 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/raid10.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 7e512d4..9b8d11f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3508,13 +3508,13 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 				GFP_KERNEL);
 	if (!conf->mirrors) {
 		err = -ENOMEM;
-		goto out;
+		goto free_conf;
 	}
 
 	conf->tmppage = alloc_page(GFP_KERNEL);
 	if (!conf->tmppage) {
 		err = -ENOMEM;
-		goto out;
+		goto kfree_mirrors;
 	}
 
 	conf->geo = geo;
@@ -3523,7 +3523,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 					   r10bio_pool_free, conf);
 	if (!conf->r10bio_pool) {
 		err = -ENOMEM;
-		goto out;
+		goto put_page;
 	}
 
 	calc_sectors(conf, mddev->dev_sectors);
@@ -3533,7 +3533,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	} else {
 		if (setup_geo(&conf->prev, mddev, geo_old) != conf->copies) {
 			err = -EINVAL;
-			goto out;
+			goto destroy_pool;
 		}
 		conf->reshape_progress = mddev->reshape_position;
 		if (conf->prev.far_offset)
@@ -3554,16 +3554,18 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	conf->thread = md_register_thread(raid10d, mddev, "raid10");
 	if (!conf->thread) {
 		err = -ENOMEM;
-		goto out;
+		goto destroy_pool;
 	}
 
 	conf->mddev = mddev;
 	return conf;
-
- out:
+destroy_pool:
 	mempool_destroy(conf->r10bio_pool);
+put_page:
 	safe_put_page(conf->tmppage);
+kfree_mirrors:
 	kfree(conf->mirrors);
+free_conf:
 	kfree(conf);
 	return ERR_PTR(err);
 }
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (46 preceding siblings ...)
  2016-10-06  9:46   ` [PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection SF Markus Elfring
@ 2016-10-06  9:47   ` SF Markus Elfring
  2016-10-06  9:48   ` [PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring
                     ` (6 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:47 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 18:48:17 +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/raid10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 9b8d11f..62cd159 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4065,7 +4065,7 @@ static int raid10_start_reshape(struct mddev *mddev)
 	spin_lock_irq(&conf->device_lock);
 	if (conf->mirrors_new) {
 		memcpy(conf->mirrors_new, conf->mirrors,
-		       sizeof(struct raid10_info)*conf->prev.raid_disks);
+		       sizeof(*conf->mirrors_new) * conf->prev.raid_disks);
 		smp_mb();
 		kfree(conf->mirrors_old);
 		conf->mirrors_old = conf->mirrors;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 48/54] md/raid10: Move a brace for a designated initialiser
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (47 preceding siblings ...)
  2016-10-06  9:47   ` [PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape() SF Markus Elfring
@ 2016-10-06  9:48   ` SF Markus Elfring
  2016-10-06  9:49   ` [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
                     ` (5 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:48 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 20:03:32 +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/raid10.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 62cd159..5119846 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4676,8 +4676,7 @@ static void raid10_finish_reshape(struct mddev *mddev)
 	mddev->reshape_backwards = 0;
 }
 
-static struct md_personality raid10_personality =
-{
+static struct md_personality raid10_personality = {
 	.name		= "raid10",
 	.level		= 10,
 	.owner		= THIS_MODULE,
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (48 preceding siblings ...)
  2016-10-06  9:48   ` [PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring
@ 2016-10-06  9:49   ` SF Markus Elfring
  2016-10-06 16:33     ` Joe Perches
  2016-10-06  9:50   ` [PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring
                     ` (4 subsequent siblings)
  54 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:49 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 21:00:05 +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/raid10.c | 168 +++++++++++++++++++++++-----------------------------
 1 file changed, 74 insertions(+), 94 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 5119846..0f2cb20 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -18,6 +18,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/slab.h>
 #include <linux/delay.h>
 #include <linux/blkdev.h>
@@ -404,8 +406,8 @@ static void raid10_end_read_request(struct bio *bio)
 		 * oops, read error - keep the refcount on the rdev
 		 */
 		char b[BDEVNAME_SIZE];
-		printk_ratelimited(KERN_ERR
-				   "md/raid10:%s: %s: rescheduling sector %llu\n",
+
+		pr_err_ratelimited("%s: %s: rescheduling sector %llu\n",
 				   mdname(conf->mddev),
 				   bdevname(rdev->bdev, b),
 				   (unsigned long long)r10_bio->sector);
@@ -1586,11 +1588,10 @@ static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
 	set_mask_bits(&mddev->flags, 0,
 		      BIT(MD_CHANGE_DEVS) | BIT(MD_CHANGE_PENDING));
 	spin_unlock_irqrestore(&conf->device_lock, flags);
-	printk(KERN_ALERT
-	       "md/raid10:%s: Disk failure on %s, disabling device.\n"
-	       "md/raid10:%s: Operation continuing on %d devices.\n",
-	       mdname(mddev), bdevname(rdev->bdev, b),
-	       mdname(mddev), conf->geo.raid_disks - mddev->degraded);
+	pr_alert("%s: Disk failure on %s, disabling device.\n"
+		 MY_LOG_PREFIX "%s: Operation continuing on %d devices.\n",
+		 mdname(mddev), bdevname(rdev->bdev, b),
+		 mdname(mddev), conf->geo.raid_disks - mddev->degraded);
 }
 
 static void print_conf(struct r10conf *conf)
@@ -1598,13 +1599,14 @@ static void print_conf(struct r10conf *conf)
 	int i;
 	struct md_rdev *rdev;
 
-	printk(KERN_DEBUG "RAID10 conf printout:\n");
+	pr_debug("conf printout:\n");
 	if (!conf) {
-		printk(KERN_DEBUG "(!conf)\n");
+		pr_debug("(!conf)\n");
 		return;
 	}
-	printk(KERN_DEBUG " --- wd:%d rd:%d\n", conf->geo.raid_disks - conf->mddev->degraded,
-		conf->geo.raid_disks);
+	pr_debug("--- wd:%d rd:%d\n",
+		 conf->geo.raid_disks - conf->mddev->degraded,
+		 conf->geo.raid_disks);
 
 	/* This is only called with ->reconfix_mutex held, so
 	 * rcu protection of rdev is not needed */
@@ -1612,10 +1614,10 @@ static void print_conf(struct r10conf *conf)
 		char b[BDEVNAME_SIZE];
 		rdev = conf->mirrors[i].rdev;
 		if (rdev)
-			printk(KERN_DEBUG " disk %d, wo:%d, o:%d, dev:%s\n",
-				i, !test_bit(In_sync, &rdev->flags),
-			        !test_bit(Faulty, &rdev->flags),
-				bdevname(rdev->bdev,b));
+			pr_debug("disk %d, wo:%d, o:%d, dev:%s\n",
+				 i, !test_bit(In_sync, &rdev->flags),
+				 !test_bit(Faulty, &rdev->flags),
+				 bdevname(rdev->bdev, b));
 	}
 }
 
@@ -2106,11 +2108,8 @@ static void fix_recovery_read_error(struct r10bio *r10_bio)
 				ok = rdev_set_badblocks(rdev2, addr, s, 0);
 				if (!ok) {
 					/* just abort the recovery */
-					printk(KERN_NOTICE
-					       "md/raid10:%s: recovery aborted"
-					       " due to read error\n",
-					       mdname(mddev));
-
+					pr_notice("%s: recovery aborted due to read error\n",
+						  mdname(mddev));
 					conf->mirrors[dw].recovery_disabled
 						= mddev->recovery_disabled;
 					set_bit(MD_RECOVERY_INTR,
@@ -2256,14 +2255,10 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		char b[BDEVNAME_SIZE];
 		bdevname(rdev->bdev, b);
 
-		printk(KERN_NOTICE
-		       "md/raid10:%s: %s: Raid device exceeded "
-		       "read_error threshold [cur %d:max %d]\n",
-		       mdname(mddev), b,
-		       atomic_read(&rdev->read_errors), max_read_errors);
-		printk(KERN_NOTICE
-		       "md/raid10:%s: %s: Failing raid device\n",
-		       mdname(mddev), b);
+		pr_notice("%s: %s: Raid device exceeded read_error threshold [cur %d:max %d]\n",
+			  mdname(mddev), b,
+			  atomic_read(&rdev->read_errors), max_read_errors);
+		pr_notice("%s: %s: Failing raid device\n", mdname(mddev), b);
 		md_error(mddev, rdev);
 		r10_bio->devs[r10_bio->read_slot].bio = IO_BLOCKED;
 		return;
@@ -2353,20 +2348,17 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 					     s, conf->tmppage, WRITE)
 			    == 0) {
 				/* Well, this device is dead */
-				printk(KERN_NOTICE
-				       "md/raid10:%s: read correction "
-				       "write failed"
-				       " (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio,
-								  rdev)),
-				       bdevname(rdev->bdev, b));
-				printk(KERN_NOTICE "md/raid10:%s: %s: failing "
-				       "drive\n",
-				       mdname(mddev),
-				       bdevname(rdev->bdev, b));
+				pr_notice("%s: read correction write failed ("
+					  "%d sectors at %llu on %s)\n",
+					  mdname(mddev),
+					  s,
+					  (unsigned long long)
+					  (sect
+					  + choose_data_offset(r10_bio, rdev)),
+					  bdevname(rdev->bdev, b));
+				pr_notice("%s: %s: failing drive\n",
+					  mdname(mddev),
+					  bdevname(rdev->bdev, b));
 			}
 			rdev_dec_pending(rdev, mddev);
 			rcu_read_lock();
@@ -2394,29 +2386,27 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 						 READ)) {
 			case 0:
 				/* Well, this device is dead */
-				printk(KERN_NOTICE
-				       "md/raid10:%s: unable to read back "
-				       "corrected sectors"
-				       " (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
-				printk(KERN_NOTICE "md/raid10:%s: %s: failing "
-				       "drive\n",
-				       mdname(mddev),
-				       bdevname(rdev->bdev, b));
+				pr_notice("%s: unable to read back corrected sectors ("
+					  "%d sectors at %llu on %s)\n",
+					  mdname(mddev),
+					  s,
+					  (unsigned long long)
+					  (sect
+					  + choose_data_offset(r10_bio, rdev)),
+					  bdevname(rdev->bdev, b));
+				pr_notice("%s: %s: failing drive\n",
+					  mdname(mddev),
+					  bdevname(rdev->bdev, b));
 				break;
 			case 1:
-				printk(KERN_INFO
-				       "md/raid10:%s: read error corrected"
-				       " (%d sectors at %llu on %s)\n",
-				       mdname(mddev), s,
-				       (unsigned long long)(
-					       sect +
-					       choose_data_offset(r10_bio, rdev)),
-				       bdevname(rdev->bdev, b));
+				pr_info("%s: read error corrected ("
+					"%d sectors at %llu on %s)\n",
+					mdname(mddev),
+					s,
+					(unsigned long long)
+					(sect
+					+ choose_data_offset(r10_bio, rdev)),
+					bdevname(rdev->bdev, b));
 				atomic_add(s, &rdev->corrected_errors);
 			}
 
@@ -2526,23 +2516,19 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
 read_more:
 	rdev = read_balance(conf, r10_bio, &max_sectors);
 	if (rdev == NULL) {
-		printk(KERN_ALERT "md/raid10:%s: %s: unrecoverable I/O"
-		       " read error for block %llu\n",
-		       mdname(mddev), b,
-		       (unsigned long long)r10_bio->sector);
+		pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n",
+			 mdname(mddev), b,
+			 (unsigned long long)r10_bio->sector);
 		raid_end_bio_io(r10_bio);
 		return;
 	}
 
 	do_sync = (r10_bio->master_bio->bi_opf & REQ_SYNC);
 	slot = r10_bio->read_slot;
-	printk_ratelimited(
-		KERN_ERR
-		"md/raid10:%s: %s: redirecting "
-		"sector %llu to another mirror\n",
-		mdname(mddev),
-		bdevname(rdev->bdev, b),
-		(unsigned long long)r10_bio->sector);
+	pr_err_ratelimited("%s: %s: redirecting sector %llu to another mirror\n",
+			   mdname(mddev),
+			   bdevname(rdev->bdev, b),
+			   (unsigned long long)r10_bio->sector);
 	bio = bio_clone_mddev(r10_bio->master_bio,
 			      GFP_NOIO, mddev);
 	bio_trim(bio, r10_bio->sector - bio->bi_iter.bi_sector, max_sectors);
@@ -3157,9 +3143,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 				if (!any_working)  {
 					if (!test_and_set_bit(MD_RECOVERY_INTR,
 							      &mddev->recovery))
-						printk(KERN_INFO "md/raid10:%s: insufficient "
-						       "working devices for recovery.\n",
-						       mdname(mddev));
+						pr_info("%s: insufficient working devices for recovery.\n",
+							mdname(mddev));
 					mirror->recovery_disabled
 						= mddev->recovery_disabled;
 				}
@@ -3486,14 +3471,13 @@ static struct r10conf *setup_conf(struct mddev *mddev)
 	copies = setup_geo(&geo, mddev, geo_new);
 
 	if (copies == -2) {
-		printk(KERN_ERR "md/raid10:%s: chunk size must be "
-		       "at least PAGE_SIZE(%ld) and be a power of 2.\n",
+		pr_err("%s: chunk size must be at least PAGE_SIZE(%ld) and be a power of 2.\n",
 		       mdname(mddev), PAGE_SIZE);
 		return ERR_PTR(-EINVAL);
 	}
 
 	if (copies < 2 || copies > mddev->raid_disks) {
-		printk(KERN_ERR "md/raid10:%s: unsupported raid10 layout: 0x%8x\n",
+		pr_err("%s: unsupported raid10 layout: 0x%8x\n",
 		       mdname(mddev), mddev->new_layout);
 		return ERR_PTR(-EINVAL);
 	}
@@ -3657,8 +3641,7 @@ static int raid10_run(struct mddev *mddev)
 	}
 	/* need to check that every block has at least one working mirror */
 	if (!enough(conf, -1)) {
-		printk(KERN_ERR "md/raid10:%s: not enough operational mirrors.\n",
-		       mdname(mddev));
+		pr_err("%s: not enough operational mirrors.\n", mdname(mddev));
 		goto out_free_conf;
 	}
 
@@ -3699,12 +3682,11 @@ static int raid10_run(struct mddev *mddev)
 	}
 
 	if (mddev->recovery_cp != MaxSector)
-		printk(KERN_NOTICE "md/raid10:%s: not clean"
-		       " -- starting background reconstruction\n",
-		       mdname(mddev));
-	printk(KERN_INFO
-		"md/raid10:%s: active with %d out of %d devices\n",
-		mdname(mddev), conf->geo.raid_disks - mddev->degraded,
+		pr_notice("%s: not clean - starting background reconstruction\n",
+			  mdname(mddev));
+	pr_info("%s: active with %d out of %d devices\n",
+		mdname(mddev),
+		conf->geo.raid_disks - mddev->degraded,
 		conf->geo.raid_disks);
 	/*
 	 * Ok, everything is just fine now
@@ -3740,7 +3722,7 @@ static int raid10_run(struct mddev *mddev)
 
 		if (max(before_length, after_length) > min_offset_diff) {
 			/* This cannot work */
-			printk("md/raid10: offset difference not enough to continue reshape\n");
+			pr_notice("offset difference not enough to continue reshape\n");
 			goto out_free_conf;
 		}
 		conf->offset_diff = min_offset_diff;
@@ -3847,8 +3829,7 @@ static void *raid10_takeover_raid0(struct mddev *mddev, sector_t size, int devs)
 	struct r10conf *conf;
 
 	if (mddev->degraded > 0) {
-		printk(KERN_ERR "md/raid10:%s: Error: degraded raid0!\n",
-		       mdname(mddev));
+		pr_err("%s: Error: degraded raid0!\n", mdname(mddev));
 		return ERR_PTR(-EINVAL);
 	}
 	sector_div(size, devs);
@@ -3888,8 +3869,7 @@ static void *raid10_takeover(struct mddev *mddev)
 		/* for raid0 takeover only one zone is supported */
 		raid0_conf = mddev->private;
 		if (raid0_conf->nr_strip_zones > 1) {
-			printk(KERN_ERR "md/raid10:%s: cannot takeover raid 0"
-			       " with more than one zone.\n",
+			pr_err("%s: cannot takeover raid 0 with more than one zone.\n",
 			       mdname(mddev));
 			return ERR_PTR(-EINVAL);
 		}
@@ -4078,7 +4058,7 @@ static int raid10_start_reshape(struct mddev *mddev)
 		sector_t size = raid10_size(mddev, 0, 0);
 		if (size < mddev->array_sectors) {
 			spin_unlock_irq(&conf->device_lock);
-			printk(KERN_ERR "md/raid10:%s: array size must be reduce before number of disks\n",
+			pr_err("%s: array size must be reduced before number of disks\n",
 			       mdname(mddev));
 			return -EINVAL;
 		}
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 50/54] md/raid10: Delete indentation for one jump label
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (49 preceding siblings ...)
  2016-10-06  9:49   ` [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
@ 2016-10-06  9:50   ` SF Markus Elfring
  2016-10-06  9:51   ` [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring
                     ` (3 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:50 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 21:07:35 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: labels should not be indented

Thus fix the affected source code place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 0f2cb20..2181f53 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4559,7 +4559,7 @@ static int handle_reshape_read_error(struct mddev *mddev,
 			rcu_read_lock();
 			if (success)
 				break;
-		failed:
+failed:
 			slot++;
 			if (slot >= conf->copies)
 				slot = 0;
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (50 preceding siblings ...)
  2016-10-06  9:50   ` [PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring
@ 2016-10-06  9:51   ` SF Markus Elfring
  2016-10-06  9:52   ` [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status() SF Markus Elfring
                     ` (2 subsequent siblings)
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:51 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 21:36:43 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid10.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 2181f53..82d79f5 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -734,10 +734,10 @@ static struct md_rdev *read_balance(struct r10conf *conf,
 			continue;
 		disk = r10_bio->devs[slot].devnum;
 		rdev = rcu_dereference(conf->mirrors[disk].replacement);
-		if (rdev == NULL || test_bit(Faulty, &rdev->flags) ||
+		if (!rdev || test_bit(Faulty, &rdev->flags) ||
 		    r10_bio->devs[slot].addr + sectors > rdev->recovery_offset)
 			rdev = rcu_dereference(conf->mirrors[disk].rdev);
-		if (rdev == NULL ||
+		if (!rdev ||
 		    test_bit(Faulty, &rdev->flags))
 			continue;
 		if (!test_bit(In_sync, &rdev->flags) &&
@@ -1386,7 +1386,8 @@ static void __make_request(struct mddev *mddev, struct bio *bio)
 
 		if (r10_bio->devs[i].repl_bio) {
 			struct md_rdev *rdev = conf->mirrors[d].replacement;
-			if (rdev == NULL) {
+
+			if (!rdev) {
 				/* Replacement just got moved to main 'rdev' */
 				smp_mb();
 				rdev = conf->mirrors[d].rdev;
@@ -1701,7 +1702,7 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 		first = last = rdev->raid_disk;
 
 	if (rdev->saved_raid_disk >= first &&
-	    conf->mirrors[rdev->saved_raid_disk].rdev == NULL)
+	    !conf->mirrors[rdev->saved_raid_disk].rdev)
 		mirror = rdev->saved_raid_disk;
 	else
 		mirror = first;
@@ -1711,7 +1712,7 @@ static int raid10_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 			continue;
 		if (p->rdev) {
 			if (!test_bit(WantReplacement, &p->rdev->flags) ||
-			    p->replacement != NULL)
+			    p->replacement)
 				continue;
 			clear_bit(In_sync, &rdev->flags);
 			set_bit(Replacement, &rdev->flags);
@@ -1849,7 +1850,7 @@ static void end_sync_request(struct r10bio *r10_bio)
 	struct mddev *mddev = r10_bio->mddev;
 
 	while (atomic_dec_and_test(&r10_bio->remaining)) {
-		if (r10_bio->master_bio == NULL) {
+		if (!r10_bio->master_bio) {
 			/* the primary of several recovery bios */
 			sector_t s = r10_bio->sectors;
 			if (test_bit(R10BIO_MadeGood, &r10_bio->state) ||
@@ -2515,7 +2516,7 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)
 
 read_more:
 	rdev = read_balance(conf, r10_bio, &max_sectors);
-	if (rdev == NULL) {
+	if (!rdev) {
 		pr_alert("%s: %s: unrecoverable I/O read error for block %llu\n",
 			 mdname(mddev), b,
 			 (unsigned long long)r10_bio->sector);
@@ -2587,7 +2588,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 		for (m = 0; m < conf->copies; m++) {
 			int dev = r10_bio->devs[m].devnum;
 			rdev = conf->mirrors[dev].rdev;
-			if (r10_bio->devs[m].bio == NULL)
+			if (!r10_bio->devs[m].bio)
 				continue;
 			if (!r10_bio->devs[m].bio->bi_error) {
 				rdev_clear_badblocks(
@@ -2602,7 +2603,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 					md_error(conf->mddev, rdev);
 			}
 			rdev = conf->mirrors[dev].replacement;
-			if (r10_bio->devs[m].repl_bio == NULL)
+			if (!r10_bio->devs[m].repl_bio)
 				continue;
 
 			if (!r10_bio->devs[m].repl_bio->bi_error) {
@@ -2631,7 +2632,7 @@ static void handle_write_completed(struct r10conf *conf, struct r10bio *r10_bio)
 					r10_bio->devs[m].addr,
 					r10_bio->sectors, 0);
 				rdev_dec_pending(rdev, conf->mddev);
-			} else if (bio != NULL && bio->bi_error) {
+			} else if (bio && bio->bi_error) {
 				fail = true;
 				if (!narrow_write_error(r10_bio, m)) {
 					md_error(conf->mddev, rdev);
@@ -2816,7 +2817,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 	 * Allow skipping a full rebuild for incremental assembly
 	 * of a clean array, like RAID1 does.
 	 */
-	if (mddev->bitmap == NULL &&
+	if (!mddev->bitmap &&
 	    mddev->recovery_cp == MaxSector &&
 	    mddev->reshape_position == MaxSector &&
 	    !test_bit(MD_RECOVERY_SYNC, &mddev->recovery) &&
@@ -2945,10 +2946,10 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			mrdev = rcu_dereference(mirror->rdev);
 			mreplace = rcu_dereference(mirror->replacement);
 
-			if ((mrdev == NULL ||
+			if ((!mrdev ||
 			     test_bit(Faulty, &mrdev->flags) ||
 			     test_bit(In_sync, &mrdev->flags)) &&
-			    (mreplace == NULL ||
+			    (!mreplace ||
 			     test_bit(Faulty, &mreplace->flags))) {
 				rcu_read_unlock();
 				continue;
@@ -2976,7 +2977,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			if (sync_blocks < max_sync)
 				max_sync = sync_blocks;
 			if (!must_sync &&
-			    mreplace == NULL &&
+			    !mreplace &&
 			    !conf->fullsync) {
 				/* yep, skip the sync_blocks here, but don't assume
 				 * that there will never be anything to do here
@@ -3011,7 +3012,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			for (j = 0; j < conf->geo.raid_disks; j++) {
 				struct md_rdev *rdev = rcu_dereference(
 					conf->mirrors[j].rdev);
-				if (rdev == NULL || test_bit(Faulty, &rdev->flags)) {
+				if (!rdev || test_bit(Faulty, &rdev->flags)) {
 					still_degraded = 1;
 					break;
 				}
@@ -3099,7 +3100,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 				 * this comment keeps human reviewers
 				 * happy.
 				 */
-				if (mreplace == NULL || bio == NULL ||
+				if (!mreplace || !bio ||
 				    test_bit(Faulty, &mreplace->flags))
 					break;
 				bio_reset(bio);
@@ -3161,7 +3162,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			if (mreplace)
 				rdev_dec_pending(mreplace, mddev);
 		}
-		if (biolist == NULL) {
+		if (!biolist) {
 			while (r10_bio) {
 				struct r10bio *rb2 = r10_bio;
 				r10_bio = (struct r10bio*) rb2->master_bio;
@@ -3214,7 +3215,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			bio->bi_error = -EIO;
 			rcu_read_lock();
 			rdev = rcu_dereference(conf->mirrors[d].rdev);
-			if (rdev == NULL || test_bit(Faulty, &rdev->flags)) {
+			if (!rdev || test_bit(Faulty, &rdev->flags)) {
 				rcu_read_unlock();
 				continue;
 			}
@@ -3243,7 +3244,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			count++;
 
 			rdev = rcu_dereference(conf->mirrors[d].replacement);
-			if (rdev == NULL || test_bit(Faulty, &rdev->flags)) {
+			if (!rdev || test_bit(Faulty, &rdev->flags)) {
 				rcu_read_unlock();
 				continue;
 			}
@@ -3565,7 +3566,7 @@ static int raid10_run(struct mddev *mddev)
 	int first = 1;
 	bool discard_supported = false;
 
-	if (mddev->private == NULL) {
+	if (!mddev->private) {
 		conf = setup_conf(mddev);
 		if (IS_ERR(conf))
 			return PTR_ERR(conf);
@@ -4542,7 +4543,7 @@ static int handle_reshape_read_error(struct mddev *mddev,
 			int d = r10b->devs[slot].devnum;
 			struct md_rdev *rdev = rcu_dereference(conf->mirrors[d].rdev);
 			sector_t addr;
-			if (rdev == NULL ||
+			if (!rdev ||
 			    test_bit(Faulty, &rdev->flags) ||
 			    !test_bit(In_sync, &rdev->flags))
 				goto failed;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status()
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (51 preceding siblings ...)
  2016-10-06  9:51   ` [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring
@ 2016-10-06  9:52   ` SF Markus Elfring
  2016-10-06  9:53   ` [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring
  2016-10-06  9:54   ` [PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:52 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 21:41:09 +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/raid10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 82d79f5..554b6d2 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1502,7 +1502,7 @@ static void raid10_status(struct seq_file *seq, struct mddev *mddev)
 		seq_printf(seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
 	}
 	rcu_read_unlock();
-	seq_printf(seq, "]");
+	seq_puts(seq, "]");
 }
 
 /* check if there are enough drives for
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (52 preceding siblings ...)
  2016-10-06  9:52   ` [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status() SF Markus Elfring
@ 2016-10-06  9:53   ` SF Markus Elfring
  2016-10-06  9:54   ` [PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:53 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 22:02:18 +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/raid10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 554b6d2..09c0e2f 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -107,7 +107,7 @@ static void reshape_request_write(struct mddev *mddev, struct r10bio *r10_bio);
 static void end_reshape_write(struct bio *bio);
 static void end_reshape(struct r10conf *conf);
 
-static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
+static void *r10bio_pool_alloc(gfp_t gfp_flags, void *data)
 {
 	struct r10conf *conf = data;
 	int size = offsetof(struct r10bio, devs[conf->copies]);
@@ -137,7 +137,7 @@ static void r10bio_pool_free(void *r10_bio, void *data)
  * one for write (we recover only one drive per r10buf)
  *
  */
-static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
+static void *r10buf_pool_alloc(gfp_t gfp_flags, void *data)
 {
 	struct r10conf *conf = data;
 	struct page *page;
-- 
2.10.1

^ permalink raw reply related	[flat|nested] 221+ messages in thread

* [PATCH 54/54] md/raid10: Add some spaces for better code readability
  2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
                     ` (53 preceding siblings ...)
  2016-10-06  9:53   ` [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring
@ 2016-10-06  9:54   ` SF Markus Elfring
  54 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06  9:54 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Oct 2016 22:22:14 +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/raid10.c | 71 +++++++++++++++++++++++++++--------------------------
 1 file changed, 36 insertions(+), 35 deletions(-)

diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 09c0e2f..786992c 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -224,7 +224,7 @@ static void r10buf_pool_free(void *__r10_bio, void *data)
 	struct r10bio *r10bio = __r10_bio;
 	int j;
 
-	for (j=0; j < conf->copies; j++) {
+	for (j = 0; j < conf->copies; j++) {
 		struct bio *bio = r10bio->devs[j].bio;
 		if (bio) {
 			for (i = 0; i < RESYNC_PAGES; i++) {
@@ -553,7 +553,7 @@ static void raid10_end_write_request(struct bio *bio)
 
 static void __raid10_find_phys(struct geom *geo, struct r10bio *r10bio)
 {
-	int n,f;
+	int n, f;
 	sector_t sector;
 	sector_t chunk;
 	sector_t stripe;
@@ -1937,7 +1937,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
 	atomic_set(&r10_bio->remaining, 1);
 
 	/* find the first device with a block */
-	for (i=0; i<conf->copies; i++)
+	for (i = 0; i < conf->copies; i++)
 		if (!r10_bio->devs[i].bio->bi_error)
 			break;
 
@@ -1951,7 +1951,7 @@ static void sync_request_write(struct mddev *mddev, struct r10bio *r10_bio)
 
 	vcnt = (r10_bio->sectors + (PAGE_SIZE >> 9) - 1) >> (PAGE_SHIFT - 9);
 	/* now find blocks with errors */
-	for (i=0 ; i < conf->copies ; i++) {
+	for (i = 0; i < conf->copies; i++) {
 		int  j, d;
 
 		tbio = r10_bio->devs[i].bio;
@@ -2236,7 +2236,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 {
 	int sect = 0; /* Offset from r10_bio->sector */
 	int sectors = r10_bio->sectors;
-	struct md_rdev*rdev;
+	struct md_rdev *rdev;
 	int max_read_errors = atomic_read(&mddev->max_corr_read_errors);
 	int d = r10_bio->devs[r10_bio->read_slot].devnum;
 
@@ -2265,7 +2265,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		return;
 	}
 
-	while(sectors) {
+	while (sectors) {
 		int s = sectors;
 		int sl = r10_bio->read_slot;
 		int success = 0;
@@ -2331,7 +2331,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		while (sl != r10_bio->read_slot) {
 			char b[BDEVNAME_SIZE];
 
-			if (sl==0)
+			if (sl == 0)
 				sl = conf->copies;
 			sl--;
 			d = r10_bio->devs[sl].devnum;
@@ -2368,7 +2368,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
 		while (sl != r10_bio->read_slot) {
 			char b[BDEVNAME_SIZE];
 
-			if (sl==0)
+			if (sl == 0)
 				sl = conf->copies;
 			sl--;
 			d = r10_bio->devs[sl].devnum;
@@ -2996,7 +2996,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			raise_barrier(conf, rb2 != NULL);
 			atomic_set(&r10_bio->remaining, 0);
 
-			r10_bio->master_bio = (struct bio*)rb2;
+			r10_bio->master_bio = (struct bio *)rb2;
 			if (rb2)
 				atomic_inc(&rb2->remaining);
 			r10_bio->mddev = mddev;
@@ -3022,7 +3022,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 						      &sync_blocks, still_degraded);
 
 			any_working = 0;
-			for (j=0; j<conf->copies;j++) {
+			for (j = 0; j < conf->copies; j++) {
 				int k;
 				int d = r10_bio->devs[j].devnum;
 				sector_t from_addr, to_addr;
@@ -3063,7 +3063,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 				atomic_inc(&rdev->nr_pending);
 				/* and we write to 'i' (if not in_sync) */
 
-				for (k=0; k<conf->copies; k++)
+				for (k = 0; k < conf->copies; k++)
 					if (r10_bio->devs[k].devnum == i)
 						break;
 				BUG_ON(k == conf->copies);
@@ -3165,7 +3165,8 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 		if (!biolist) {
 			while (r10_bio) {
 				struct r10bio *rb2 = r10_bio;
-				r10_bio = (struct r10bio*) rb2->master_bio;
+
+				r10_bio = (struct r10bio *) rb2->master_bio;
 				rb2->master_bio = NULL;
 				put_buf(rb2);
 			}
@@ -3268,7 +3269,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 		}
 
 		if (count < 2) {
-			for (i=0; i<conf->copies; i++) {
+			for (i = 0; i < conf->copies; i++) {
 				int d = r10_bio->devs[i].devnum;
 				if (r10_bio->devs[i].bio->bi_end_io)
 					rdev_dec_pending(conf->mirrors[d].rdev,
@@ -3295,7 +3296,7 @@ static sector_t raid10_sync_request(struct mddev *mddev, sector_t sector_nr,
 			len = (max_sector - sector_nr) << 9;
 		if (len == 0)
 			break;
-		for (bio= biolist ; bio ; bio=bio->bi_next) {
+		for (bio = biolist; bio; bio = bio->bi_next) {
 			struct bio *bio2;
 			page = bio->bi_io_vec[bio->bi_vcnt].bv_page;
 			if (bio_add_page(bio, page, len, 0))
@@ -3765,7 +3766,7 @@ static void raid10_quiesce(struct mddev *mddev, int state)
 {
 	struct r10conf *conf = mddev->private;
 
-	switch(state) {
+	switch (state) {
 	case 1:
 		raise_barrier(conf, 0);
 		break;
@@ -4658,26 +4659,26 @@ static void raid10_finish_reshape(struct mddev *mddev)
 }
 
 static struct md_personality raid10_personality = {
-	.name		= "raid10",
-	.level		= 10,
-	.owner		= THIS_MODULE,
-	.make_request	= raid10_make_request,
-	.run		= raid10_run,
-	.free		= raid10_free,
-	.status		= raid10_status,
-	.error_handler	= raid10_error,
-	.hot_add_disk	= raid10_add_disk,
-	.hot_remove_disk= raid10_remove_disk,
-	.spare_active	= raid10_spare_active,
-	.sync_request	= raid10_sync_request,
-	.quiesce	= raid10_quiesce,
-	.size		= raid10_size,
-	.resize		= raid10_resize,
-	.takeover	= raid10_takeover,
-	.check_reshape	= raid10_check_reshape,
-	.start_reshape	= raid10_start_reshape,
-	.finish_reshape	= raid10_finish_reshape,
-	.congested	= raid10_congested,
+	.name            = "raid10",
+	.level           = 10,
+	.owner           = THIS_MODULE,
+	.make_request    = raid10_make_request,
+	.run             = raid10_run,
+	.free            = raid10_free,
+	.status          = raid10_status,
+	.error_handler   = raid10_error,
+	.hot_add_disk    = raid10_add_disk,
+	.hot_remove_disk = raid10_remove_disk,
+	.spare_active    = raid10_spare_active,
+	.sync_request    = raid10_sync_request,
+	.quiesce         = raid10_quiesce,
+	.size            = raid10_size,
+	.resize          = raid10_resize,
+	.takeover        = raid10_takeover,
+	.check_reshape   = raid10_check_reshape,
+	.start_reshape   = raid10_start_reshape,
+	.finish_reshape  = raid10_finish_reshape,
+	.congested       = raid10_congested,
 };
 
 static int __init raid_init(void)
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Fine-tuning for several function implementations
  2016-10-06  8:49   ` Christoph Hellwig
@ 2016-10-06 10:07     ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 10:07 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: linux-raid, Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown,
	Shaohua Li, Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

> This is not fine tuning but a waste of everyones time.

Does any of the published 54 update steps contain changes
which you might find also worthwhile for the affected source files
so that the shown software situation can be improved further?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH v2 13/15] md-cluster: Less function calls in join() after error detection
  2016-10-01 14:58   ` [PATCH 13/15] md-cluster: Less function calls in join() after error detection SF Markus Elfring
@ 2016-10-06 15:16     ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 15:16 UTC (permalink / raw)
  To: linux-raid, Guoqing Jiang, Shaohua Li; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 6 Oct 2016 16:48:51 +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>
---

v2: Julia Lawall wrote on 2016-10-01 at 19:07:
> Please check lines 919 and 920.
> 
> julia
> 
> ---------- Forwarded message ----------
> Date: Sun, 2 Oct 2016 01:03:19 +0800
> From: kbuild test robot <fengguang.wu@intel.com>
> To: kbuild@01.org
> Cc: Julia Lawall <julia.lawall@lip6.fr>
> Subject:
>     [linux-review:SF-Markus-Elfring/md-cluster-Fine-tuning-for-ten-function-impl
>     ementations/20161001-230311 13/15] drivers/md/md-cluster.c:920:23-28: ERROR:
>      reference preceded by free on line 919
> 
> CC: kbuild-all@01.org
> TO: Markus Elfring <elfring@users.sourceforge.net>
> CC: 0day robot <fengguang.wu@intel.com>
> 
> tree:   https://github.com/0day-ci/linux SF-Markus-Elfring/md-cluster-Fine-tuning-for-ten-function-implementations/20161001-230311
> head:   7b2084c76eb1c60f2ae5c2778470124b5b68e9fb
> commit: 6955234a0083a739f595e753e89ba7b5b3962f50 [13/15] md-cluster: Less function calls in join() after error detection
> :::::: branch date: 2 hours ago
> :::::: commit date: 2 hours ago
> 
>>> drivers/md/md-cluster.c:920:23-28: ERROR: reference preceded by free on line 919
> 
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 6955234a0083a739f595e753e89ba7b5b3962f50
> vim +920 drivers/md/md-cluster.c
> 
> 6955234a Markus Elfring    2016-10-01  913  	lockres_free(cinfo->message_lockres);
> 6955234a Markus Elfring    2016-10-01  914  unregister_recv:
> 6955234a Markus Elfring    2016-10-01  915  	md_unregister_thread(&cinfo->recv_thread);
> 6955234a Markus Elfring    2016-10-01  916  release_lockspace:
> c4ce867f Goldwyn Rodrigues 2014-03-29  917  	dlm_release_lockspace(cinfo->lockspace, 2);
> 6955234a Markus Elfring    2016-10-01  918  free_cluster_info:
> c4ce867f Goldwyn Rodrigues 2014-03-29 @919  	kfree(cinfo);
> 6955234a Markus Elfring    2016-10-01 @920  	md_unregister_thread(&cinfo->recovery_thread);
> 6955234a Markus Elfring    2016-10-01  921  	mddev->cluster_info = NULL;
> c4ce867f Goldwyn Rodrigues 2014-03-29  922  	return ret;
> edb39c9d Goldwyn Rodrigues 2014-03-29  923  }
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


This automatic notification pointed out that I should have switched the order
of calls for the functions "kfree" and "md_unregister_thread".
I hope that my second approach could be integrated into another
source code repository.


 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..e60511a 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 unregister_recovery_thread;
 	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);
+unregister_recovery_thread:
+	md_unregister_thread(&cinfo->recovery_thread);
 	kfree(cinfo);
+	mddev->cluster_info = NULL;
 	return ret;
 }
 
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06  9:49   ` [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
@ 2016-10-06 16:33     ` Joe Perches
  2016-10-06 17:20       ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-10-06 16:33 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 11:49 +0200, SF Markus Elfring wrote:
[]
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index 5119846..0f2cb20 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -18,6 +18,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

Please just use

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

like the more than thousand other uses in the kernel.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06  9:37   ` [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status() SF Markus Elfring
@ 2016-10-06 16:34     ` Joe Perches
  2016-10-06 17:09       ` SF Markus Elfring
  2016-10-16  8:20       ` [PATCH] MD-RAID: Use seq_putc() in three status functions SF Markus Elfring
  0 siblings, 2 replies; 221+ messages in thread
From: Joe Perches @ 2016-10-06 16:34 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 11:37 +0200, SF Markus Elfring wrote:
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
[]
> @@ -7044,7 +7044,7 @@ static void raid5_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, "]");

seq_putc

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 16:34     ` Joe Perches
@ 2016-10-06 17:09       ` SF Markus Elfring
  2016-10-06 17:36         ` Joe Perches
  2016-10-16  8:20       ` [PATCH] MD-RAID: Use seq_putc() in three status functions SF Markus Elfring
  1 sibling, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 17:09 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> []
>> @@ -7044,7 +7044,7 @@ static void raid5_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, "]");
> 
> seq_putc

Thanks for your update suggestion.

How do you think about the possibility that the script "checkpatch.pl" can also point
such a source code transformation out directly?
Would an additional check for the length of the passed string be useful in similar
use cases?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06 16:33     ` Joe Perches
@ 2016-10-06 17:20       ` SF Markus Elfring
  2016-10-06 17:39         ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 17:20 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
>> index 5119846..0f2cb20 100644
>> --- a/drivers/md/raid10.c
>> +++ b/drivers/md/raid10.c
>> @@ -18,6 +18,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
> 
> Please just use
> 
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> 
> like the more than thousand other uses in the kernel.

Thanks for your suggestion.

I got the impression that the omission of a macro like "MY_LOG_PREFIX"
would not really work for the suggested source code transformation so far.

How should a multiline log message be achieved as it was constructed
in the function "raid10_error" (for example)?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/md/raid10.c?id=c802e87fbe2d4dd58982d01b3c39bc5a781223aa#n1589

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 17:09       ` SF Markus Elfring
@ 2016-10-06 17:36         ` Joe Perches
  2016-10-06 17:49           ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-10-06 17:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 19:09 +0200, SF Markus Elfring wrote:
> > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> > []
> > > @@ -7044,7 +7044,7 @@ static void raid5_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, "]");
> > seq_putc
> How do you think about the possibility that the script "checkpatch.pl" can also point
> such a source code transformation out directly?

Why don't _you_ try to implement that in checkpatch instead?


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06 17:20       ` SF Markus Elfring
@ 2016-10-06 17:39         ` Joe Perches
  2016-10-06 18:04           ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-10-06 17:39 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 19:20 +0200, SF Markus Elfring wrote:
> How should a multiline log message be achieved as it was constructed
> in the function "raid10_error" (for example)?
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/md/raid10.c?id=c802e87fbe2d4dd58982d01b3c39bc5a781223aa#n1589

As two individual calls to pr_alert

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 17:36         ` Joe Perches
@ 2016-10-06 17:49           ` SF Markus Elfring
  2016-10-06 17:51             ` Joe Perches
  2016-10-06 18:33             ` [PATCH 37/54] " Bernd Petrovitsch
  0 siblings, 2 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 17:49 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>>>> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
>>> []
>>>> @@ -7044,7 +7044,7 @@ static void raid5_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, "]");
>>> seq_putc
>> How do you think about the possibility that the script "checkpatch.pl" can also point
>> such a source code transformation out directly?
> 
> Why don't _you_ try to implement that in checkpatch instead?

How are the chances that any other software developer would be quicker (than me) for such
an addition because of more practical knowledge for the programming language "Perl"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 17:49           ` SF Markus Elfring
@ 2016-10-06 17:51             ` Joe Perches
  2016-10-06 18:22               ` SF Markus Elfring
  2016-10-06 18:33             ` [PATCH 37/54] " Bernd Petrovitsch
  1 sibling, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-10-06 17:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 19:49 +0200, SF Markus Elfring wrote:
> > Why don't _you_ try to implement that in checkpatch instead?
> How are the chances that any other software developer would be quicker (than me) for such
> an addition because of more practical knowledge for the programming language "Perl"?

Extremely high.

What are the chances you can add useful attributes to your skilz?


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06 17:39         ` Joe Perches
@ 2016-10-06 18:04           ` SF Markus Elfring
  2016-10-06 18:18             ` Joe Perches
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 18:04 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>> How should a multiline log message be achieved as it was constructed
>> in the function "raid10_error" (for example)?
>> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/md/raid10.c?id=c802e87fbe2d4dd58982d01b3c39bc5a781223aa#n1589
> 
> As two individual calls to pr_alert

I know also such an approach.

Would it be nicer if a single call will be sufficient for such a log message?

Can an idea picked up which was discussed for the update suggestion
"[PATCH 4/4] Input-gameport: Replace some printk() calls by pr_info() in joydump_connect()"
for a moment (on 2016-09-24)?
https://lkml.kernel.org/r/<1474735656.23838.6.camel@perches.com>
https://lkml.org/lkml/2016/9/24/149

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06 18:04           ` SF Markus Elfring
@ 2016-10-06 18:18             ` Joe Perches
  2016-10-06 18:32               ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Joe Perches @ 2016-10-06 18:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-10-06 at 20:04 +0200, SF Markus Elfring wrote:
> Would it be nicer if a single call will be sufficient for such a log message?
> 
> Can an idea picked up which was discussed for the update suggestion
> "[PATCH 4/4] Input-gameport: Replace some printk() calls by pr_info() in joydump_connect()"
> for a moment (on 2016-09-24)?
> https://lkml.kernel.org/r/<1474735656.23838.6.camel@perches.com>;
> https://lkml.org/lkml/2016/9/24/149

That'd be great.
Pease come back only after you've implemented that.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 17:51             ` Joe Perches
@ 2016-10-06 18:22               ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 18:22 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>>> Why don't _you_ try to implement that in checkpatch instead?
>> How are the chances that any other software developer would be quicker (than me) for such
>> an addition because of more practical knowledge for the programming language "Perl"?
> 
> Extremely high.

Thanks for this feedback.


> What are the chances you can add useful attributes to your skilz?

Unfortunately, "Perl" does not belong to a favourite in my current collection
of programming languages I learned through my software development activities.
I imagine that I would prefer to improve other Linux software modules
for a while instead?

Would it be interesting if the Coccinelle software could help a bit more with
corresponding semantic patches?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid10: Replace printk() calls by the usage of higher level interfaces
  2016-10-06 18:18             ` Joe Perches
@ 2016-10-06 18:32               ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-06 18:32 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>> Would it be nicer if a single call will be sufficient for such a log message?
>>
>> Can an idea picked up which was discussed for the update suggestion
>> "[PATCH 4/4] Input-gameport: Replace some printk() calls by pr_info() in joydump_connect()"
>> for a moment (on 2016-09-24)?
>> https://lkml.kernel.org/r/<1474735656.23838.6.camel@perches.com>;
>> https://lkml.org/lkml/2016/9/24/149
> 
> That'd be great.
> Pease come back only after you've implemented that.

Does this use case show another improvement opportunity for involved
software developers (besides me)?

Are there any more contributors around who would like to tackle such a challenge?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status()
  2016-10-06 17:49           ` SF Markus Elfring
  2016-10-06 17:51             ` Joe Perches
@ 2016-10-06 18:33             ` Bernd Petrovitsch
  1 sibling, 0 replies; 221+ messages in thread
From: Bernd Petrovitsch @ 2016-10-06 18:33 UTC (permalink / raw)
  To: SF Markus Elfring, Joe Perches
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

Hi all!

On Thu, 2016-10-06 at 19:49 +0200, SF Markus Elfring wrote:
> > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> > > > []
> > > > > 
> > > > > @@ -7044,7 +7044,7 @@ static void raid5_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, "]");
> > > > seq_putc
> > > How do you think about the possibility that the script
> > > "checkpatch.pl" can also point
> > > such a source code transformation out directly?
> > 
> > Why don't _you_ try to implement that in checkpatch instead?
> 
> How are the chances that any other software developer would be
> quicker (than me) for such
> an addition because of more practical knowledge for the programming
> language "Perl"?

The above is BTW a pretty simple thing and thus good for a learning
experience for regular expressions and copy-pasting a few lines in that
perl-script and editing them.

MfG,
	Bernd

PS: Sry for the noise - it's somewhat OT here ....
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation
  2016-10-06  9:30   ` [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation SF Markus Elfring
@ 2016-10-07  5:51     ` Hannes Reinecke
  0 siblings, 0 replies; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-07  5:51 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

On 10/06/2016 11:30 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 5 Oct 2016 09:43:40 +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/raid5.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index d864871..ef180c0 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -6613,12 +6613,9 @@ static struct r5conf *setup_conf(struct mddev *mddev)
>  	memory = conf->min_nr_stripes * (sizeof(struct stripe_head) +
>  		 max_disks * ((sizeof(struct bio) + PAGE_SIZE))) / 1024;
>  	atomic_set(&conf->empty_inactive_list_nr, NR_STRIPE_HASH_LOCKS);
> -	if (grow_stripes(conf, conf->min_nr_stripes)) {
> -		printk(KERN_ERR
> -		       "md/raid:%s: couldn't allocate %dkB for buffers\n",
> -		       mdname(mddev), memory);
> +	if (grow_stripes(conf, conf->min_nr_stripes))
>  		goto free_conf;
> -	} else
> +	else
>  		printk(KERN_INFO "md/raid:%s: allocated %dkB\n",
>  		       mdname(mddev), memory);
>  	/*
> @@ -6640,12 +6637,8 @@ static struct r5conf *setup_conf(struct mddev *mddev)
>
>  	sprintf(pers_name, "raid%d", mddev->new_level);
>  	conf->thread = md_register_thread(raid5d, mddev, pers_name);
> -	if (!conf->thread) {
> -		printk(KERN_ERR
> -		       "md/raid:%s: couldn't allocate thread.\n",
> -		       mdname(mddev));
> +	if (!conf->thread)
>  		goto free_conf;
> -	}
>
>  	return conf;
>  free_conf:
>
Actually I prefer having error messages, especially if you have several 
possible failures all leading to the same return value.
Without it debugging becomes really hard.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps()
  2016-10-01 15:00   ` [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps() SF Markus Elfring
@ 2016-10-07  7:46     ` Dan Carpenter
  2016-10-07  8:37       ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Dan Carpenter @ 2016-10-07  7:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Guoqing Jiang, Shaohua Li, LKML, kernel-janitors,
	Julia Lawall

On Sat, Oct 01, 2016 at 05:00:07PM +0200, SF Markus Elfring wrote:
> 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.
> 

The original style was correct and this is wrong.  I have explained this
before.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-06  9:29     ` Richard Weinberger
@ 2016-10-07  7:53       ` Dan Carpenter
  2016-10-07  8:15         ` Richard Weinberger
                           ` (2 more replies)
  2016-10-10 11:12       ` Dan Carpenter
  1 sibling, 3 replies; 221+ messages in thread
From: Dan Carpenter @ 2016-10-07  7:53 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: SF Markus Elfring, linux-raid@vger.kernel.org, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On Thu, Oct 06, 2016 at 11:29:20AM +0200, Richard Weinberger wrote:
> On Thu, Oct 6, 2016 at 11:22 AM, SF Markus Elfring
> <elfring@users.sourceforge.net> wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 4 Oct 2016 21:46: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.
> 
> Isn't this pure matter of taste?
> Some developers prefer sizeof(*ptr) because it is easier to type, other
> developers prefer sizeof(struct foo) because you can determine the type
> at first sight and makes review more easy.

sizeof(*ptr) is more future proof and normally more obvious and easier
to review.  That said, I've tried to tell Markus to only send bugfix
patches because these are a waste of time and regularly introduce bugs.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-07  7:53       ` Dan Carpenter
@ 2016-10-07  8:15         ` Richard Weinberger
  2016-10-07  8:53         ` SF Markus Elfring
  2016-10-10 13:09         ` [PATCH 24/54] " Jes Sorensen
  2 siblings, 0 replies; 221+ messages in thread
From: Richard Weinberger @ 2016-10-07  8:15 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, linux-raid@vger.kernel.org, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On 07.10.2016 09:53, Dan Carpenter wrote:
> On Thu, Oct 06, 2016 at 11:29:20AM +0200, Richard Weinberger wrote:
>> On Thu, Oct 6, 2016 at 11:22 AM, SF Markus Elfring
>> <elfring@users.sourceforge.net> wrote:
>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>> Date: Tue, 4 Oct 2016 21:46: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.
>>
>> Isn't this pure matter of taste?
>> Some developers prefer sizeof(*ptr) because it is easier to type, other
>> developers prefer sizeof(struct foo) because you can determine the type
>> at first sight and makes review more easy.
> 
> sizeof(*ptr) is more future proof and normally more obvious and easier
> to review.

Also a matter of taste.
See http://yarchive.net/comp/linux/struct_init.html

Thanks,
//richard

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md-cluster: Delete unnecessary braces in unlock_all_bitmaps()
  2016-10-07  7:46     ` Dan Carpenter
@ 2016-10-07  8:37       ` SF Markus Elfring
  2016-10-07 13:21         ` walter harms
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-07  8:37 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-raid, Guoqing Jiang, Shaohua Li, LKML, kernel-janitors,
	Julia Lawall

>> Do not use curly brackets at one source code place
>> where a single statement should be sufficient.
> 
> The original style was correct and this is wrong.  I have explained this before.

Did I change a bit too much in the proposed step according to the following
update suggestion?

elfring@Sonne:~/Projekte/Linux/next-patched> git checkout d6385db94196b253ae5eb3678fa95cdf1f839fcc && scripts/checkpatch.pl --types BRACES -f drivers/md/md-cluster.c
…
WARNING: braces {} are not necessary for single statement blocks
#1228: FILE: drivers/md/md-cluster.c:1228:
+			if (cinfo->other_bitmap_lockres[i]) {
+				lockres_free(cinfo->other_bitmap_lockres[i]);
+			}
…


How do you think about to adjust this source code place a bit?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07  7:53       ` Dan Carpenter
  2016-10-07  8:15         ` Richard Weinberger
@ 2016-10-07  8:53         ` SF Markus Elfring
  2016-10-07  9:06           ` Richard Weinberger
  2016-10-10 13:06           ` Jes Sorensen
  2016-10-10 13:09         ` [PATCH 24/54] " Jes Sorensen
  2 siblings, 2 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-07  8:53 UTC (permalink / raw)
  To: Dan Carpenter, Richard Weinberger
  Cc: linux-raid@vger.kernel.org, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

>>> 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.
>>
>> Isn't this pure matter of taste?
>> Some developers prefer sizeof(*ptr) because it is easier to type, other
>> developers prefer sizeof(struct foo) because you can determine the type
>> at first sight and makes review more easy.
> 
> sizeof(*ptr) is more future proof and normally more obvious and easier
> to review.

Is it interesting to see how different the software development opinions
can be for such an implementation detail?


> That said, I've tried to tell Markus to only send bugfix patches

Can any deviations from the Linux coding style become "bugs" also in
your view of the software situation?


> because these are a waste of time

How do you value compliance with coding styles?


> and regularly introduce bugs.

Really?

Would you like to discuss concrete incidents any further?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07  8:53         ` SF Markus Elfring
@ 2016-10-07  9:06           ` Richard Weinberger
  2016-10-07 10:50             ` SF Markus Elfring
  2016-10-10 13:06           ` Jes Sorensen
  1 sibling, 1 reply; 221+ messages in thread
From: Richard Weinberger @ 2016-10-07  9:06 UTC (permalink / raw)
  To: SF Markus Elfring, Dan Carpenter
  Cc: linux-raid@vger.kernel.org, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On 07.10.2016 10:53, SF Markus Elfring wrote:
>>>> 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.
>>>
>>> Isn't this pure matter of taste?
>>> Some developers prefer sizeof(*ptr) because it is easier to type, other
>>> developers prefer sizeof(struct foo) because you can determine the type
>>> at first sight and makes review more easy.
>>
>> sizeof(*ptr) is more future proof and normally more obvious and easier
>> to review.
> 
> Is it interesting to see how different the software development opinions
> can be for such an implementation detail?
> 
> 
>> That said, I've tried to tell Markus to only send bugfix patches
> 
> Can any deviations from the Linux coding style become "bugs" also in
> your view of the software situation?
> 
> 
>> because these are a waste of time
> 
> How do you value compliance with coding styles?

Just stop sending these kind of patches, *please*.
Linux has tons of issues, fixes for real problems are very welcome.
But coding style bike shedding is just a waste of time.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07  9:06           ` Richard Weinberger
@ 2016-10-07 10:50             ` SF Markus Elfring
  2016-10-07 11:52               ` Austin S. Hemmelgarn
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-07 10:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, linux-raid@vger.kernel.org, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

> Linux has tons of issues, fixes for real problems are very welcome.

Is a spectrum of software improvements to reconsider there?


> But coding style bike shedding is just a waste of time.

Why do various software developers bother about coding style specifications
at all then?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07 10:50             ` SF Markus Elfring
@ 2016-10-07 11:52               ` Austin S. Hemmelgarn
  2016-10-07 15:27                 ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Austin S. Hemmelgarn @ 2016-10-07 11:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Richard Weinberger, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

On 2016-10-07 06:50, SF Markus Elfring wrote:
>> Linux has tons of issues, fixes for real problems are very welcome.
>
> Is a spectrum of software improvements to reconsider there?
>
>
>> But coding style bike shedding is just a waste of time.
>
> Why do various software developers bother about coding style specifications
> at all then?
Coding style is important, but patches that just fix coding style are a 
bad thing because they break things like `git blame` and run the risk of 
introducing new bugs without any net benefit to end users.  This goes 
double for code you don't actually work on regularly or don't completely 
understand.

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md-cluster: Delete unnecessary braces in unlock_all_bitmaps()
  2016-10-07  8:37       ` SF Markus Elfring
@ 2016-10-07 13:21         ` walter harms
  0 siblings, 0 replies; 221+ messages in thread
From: walter harms @ 2016-10-07 13:21 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Dan Carpenter, linux-raid, Guoqing Jiang, Shaohua Li, LKML,
	Julia Lawall



Am 07.10.2016 10:37, schrieb SF Markus Elfring:
>>> Do not use curly brackets at one source code place
>>> where a single statement should be sufficient.
>>
>> The original style was correct and this is wrong.  I have explained this before.
> 
> Did I change a bit too much in the proposed step according to the following
> update suggestion?
> 
> elfring@Sonne:~/Projekte/Linux/next-patched> git checkout d6385db94196b253ae5eb3678fa95cdf1f839fcc && scripts/checkpatch.pl --types BRACES -f drivers/md/md-cluster.c
> …
> WARNING: braces {} are not necessary for single statement blocks
> #1228: FILE: drivers/md/md-cluster.c:1228:
> +			if (cinfo->other_bitmap_lockres[i]) {
> +				lockres_free(cinfo->other_bitmap_lockres[i]);
> +			}
> …
> 
> 
> How do you think about to adjust this source code place a bit?
> 

perhaps we can agree to delete the if() block ?

static void lockres_free(struct dlm_lock_resource *res)
{
        int ret;

       if (!res)
                return;

....


@marcus: is can not send mail to you sf.net adresse because sf.net
         mark my domain als spam (note: nobody else does)

re,
 wh

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07 11:52               ` Austin S. Hemmelgarn
@ 2016-10-07 15:27                 ` SF Markus Elfring
  2016-10-07 15:35                   ` Jiri Kosina
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-07 15:27 UTC (permalink / raw)
  To: Austin S. Hemmelgarn
  Cc: Dan Carpenter, Richard Weinberger, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

>> Why do various software developers bother about coding style specifications
>> at all then?
> Coding style is important,

Thanks that you "dare" to express also such an opinion.


> but patches that just fix coding style are a bad thing

When you find such a change opportunity so "bad", are there any circumstances
left over where you would dare to touch the corresponding source code line.


> because they break things like `git blame`

I follow your concern to some degree.

But can this argument evolve against a lot of changes generally?


> and run the risk of introducing new bugs

Did this really "happen" because of an update suggestion for this software module?


> without any net benefit to end users.

Can the proposed adjustment help to make a function like "setup_conf"
a bit more robust (together with related update steps) so that an improved
coding style compliance will hopefully influence the error probability
in positive ways?


> This goes double for code you don't actually work on regularly
> or don't completely understand.

How does such a kind of general feedback fit to the shown change
possibilities in this patch series?

Do you reject this update step?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07 15:27                 ` SF Markus Elfring
@ 2016-10-07 15:35                   ` Jiri Kosina
  2016-10-07 16:38                     ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Jiri Kosina @ 2016-10-07 15:35 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Austin S. Hemmelgarn, Dan Carpenter, Richard Weinberger,
	linux-raid@vger.kernel.org, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On Fri, 7 Oct 2016, SF Markus Elfring wrote:

> > but patches that just fix coding style are a bad thing
> 
> When you find such a change opportunity so "bad", are there any 
> circumstances left over where you would dare to touch the corresponding 
> source code line.

If you actually rewrite the code or fix some real bug there.

> > because they break things like `git blame`
> 
> I follow your concern to some degree.
> 
> But can this argument evolve against a lot of changes generally?

If I have to reiterate git blame multiple times just because of whitespace 
or codingstyle changes, it's a pure waste of my time.

If I have to reiterate git blame multiple times to skip actual real 
changes, I have no other option than to live with that (because there was 
an actual functional reason for the change).

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07 15:35                   ` Jiri Kosina
@ 2016-10-07 16:38                     ` SF Markus Elfring
  2016-10-10 13:11                       ` Jes Sorensen
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-07 16:38 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Austin S. Hemmelgarn, Dan Carpenter, Richard Weinberger,
	linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, Julia Lawall

>>> but patches that just fix coding style are a bad thing
>>
>> When you find such a change opportunity so "bad", are there any 
>> circumstances left over where you would dare to touch the corresponding 
>> source code line.
> 
> If you actually rewrite the code or fix some real bug there.

Do the proposed update steps 12 - 16 for the function "setup_conf"
(in this software module) fit to your condition?

Do you reject this update step?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-06  9:29     ` Richard Weinberger
  2016-10-07  7:53       ` Dan Carpenter
@ 2016-10-10 11:12       ` Dan Carpenter
  2016-10-10 12:28         ` SF Markus Elfring
                           ` (2 more replies)
  1 sibling, 3 replies; 221+ messages in thread
From: Dan Carpenter @ 2016-10-10 11:12 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: SF Markus Elfring, linux-raid@vger.kernel.org, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

On Thu, Oct 06, 2016 at 11:29:20AM +0200, Richard Weinberger wrote:
> On Thu, Oct 6, 2016 at 11:22 AM, SF Markus Elfring
> <elfring@users.sourceforge.net> wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 4 Oct 2016 21:46: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.
> 
> Isn't this pure matter of taste?
> Some developers prefer sizeof(*ptr) because it is easier to type, other
> developers prefer sizeof(struct foo) because you can determine the type
> at first sight and makes review more easy.
> 

I am ignoring Markus patches and have told him that he should focus on
bug fixes.  These patches don't add any value and regularly introduce
bugs.

That said, "sizeof(*ptr)" is sort of official style.  It's slightly
more obvious and easier to review because all the information you need
is on that one line.  Also if we change the datatype of ptr then that
format is slightly more future proof.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-10 11:12       ` Dan Carpenter
@ 2016-10-10 12:28         ` SF Markus Elfring
  2016-10-10 13:23           ` Adam Goryachev
  2016-10-10 13:57         ` [PATCH 24/54] " Bjørn Mork
  2016-10-11  6:20         ` Dan Carpenter
  2 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-10 12:28 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

> I am ignoring Markus patches

It's a pity that you chose such a reaction.


> and have told him that he should focus on bug fixes.

I find that I suggest to improve something. Could you admit a few times
that I found a "bug" you care also about at other source code places?


> These patches don't add any value

Can it be that you express a lower value for the Linux coding style here
than desired as there might be other concerns behind such negative feedback?


> and regularly introduce bugs.

How do you think about to discuss corresponding facts further?

 
> That said, "sizeof(*ptr)" is sort of official style.

When this implementation detail is so official, I wonder then why some
software developers can become "special" about the proposed update step
like for this module.

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07  8:53         ` SF Markus Elfring
  2016-10-07  9:06           ` Richard Weinberger
@ 2016-10-10 13:06           ` Jes Sorensen
  2016-10-10 13:20             ` SF Markus Elfring
  1 sibling, 1 reply; 221+ messages in thread
From: Jes Sorensen @ 2016-10-10 13:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Richard Weinberger, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:
>>>> 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.
>>>
>>> Isn't this pure matter of taste?
>>> Some developers prefer sizeof(*ptr) because it is easier to type, other
>>> developers prefer sizeof(struct foo) because you can determine the type
>>> at first sight and makes review more easy.
>> 
>> sizeof(*ptr) is more future proof and normally more obvious and easier
>> to review.
>
> Is it interesting to see how different the software development opinions
> can be for such an implementation detail?
>
>> That said, I've tried to tell Markus to only send bugfix patches
>
> Can any deviations from the Linux coding style become "bugs" also in
> your view of the software situation?
>
>> because these are a waste of time
>
> How do you value compliance with coding styles?

The Linux Coding Style is not a law, nor is it at all perfect. You
clearly misunderstood how Linux development work and you are doing a
great job wasting everyone's time with this patchset.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-07  7:53       ` Dan Carpenter
  2016-10-07  8:15         ` Richard Weinberger
  2016-10-07  8:53         ` SF Markus Elfring
@ 2016-10-10 13:09         ` Jes Sorensen
  2016-10-12  8:28           ` Dan Carpenter
  2 siblings, 1 reply; 221+ messages in thread
From: Jes Sorensen @ 2016-10-10 13:09 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, SF Markus Elfring, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

Dan Carpenter <dan.carpenter@oracle.com> writes:
> On Thu, Oct 06, 2016 at 11:29:20AM +0200, Richard Weinberger wrote:
>> On Thu, Oct 6, 2016 at 11:22 AM, SF Markus Elfring
>> <elfring@users.sourceforge.net> wrote:
>> > From: Markus Elfring <elfring@users.sourceforge.net>
>> > Date: Tue, 4 Oct 2016 21:46: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.
>> 
>> Isn't this pure matter of taste?
>> Some developers prefer sizeof(*ptr) because it is easier to type, other
>> developers prefer sizeof(struct foo) because you can determine the type
>> at first sight and makes review more easy.
>
> sizeof(*ptr) is more future proof and normally more obvious and easier
> to review.  That said, I've tried to tell Markus to only send bugfix
> patches because these are a waste of time and regularly introduce bugs.

This is totally a matter of taste. I for one find it way easier to
review something which says 'sizeof(struct ....)' because it stands out
more. I am curious what you mean by it being more future proof - if the
code says 'struct foo' in the sizeof argument, what is the problem?

The one area where there is a higher risk is if the type is changed, but
that is outweighed by the fact the spelled out version is easier to
review.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-07 16:38                     ` SF Markus Elfring
@ 2016-10-10 13:11                       ` Jes Sorensen
  0 siblings, 0 replies; 221+ messages in thread
From: Jes Sorensen @ 2016-10-10 13:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jiri Kosina, Austin S. Hemmelgarn, Dan Carpenter,
	Richard Weinberger, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:
>>>> but patches that just fix coding style are a bad thing
>>>
>>> When you find such a change opportunity so "bad", are there any 
>>> circumstances left over where you would dare to touch the corresponding 
>>> source code line.
>> 
>> If you actually rewrite the code or fix some real bug there.
>
> Do the proposed update steps 12 - 16 for the function "setup_conf"
> (in this software module) fit to your condition?
>
> Do you reject this update step?

I do - those changes do nothing to improve the code and simply hides a
lot of history.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-10 13:06           ` Jes Sorensen
@ 2016-10-10 13:20             ` SF Markus Elfring
  2016-10-10 14:01               ` Jes Sorensen
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-10 13:20 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Dan Carpenter, Richard Weinberger, linux-raid, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

>> How do you value compliance with coding styles?
>
> The Linux Coding Style is not a law,

How serious can such guidelines become for software developers?


> nor is it at all perfect.

I got a similar impression. But are there enough items where a mostly clear
guidance is specified?


> You clearly misunderstood how Linux development work

I got an other impression.


> and you are doing a great job wasting everyone's time with this patchset.

Would you like to reject any update steps for the affected source files
from this patch series?

Can it "accidentally" happen that some of them will be really worth
also for your precious software development attention?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-10 12:28         ` SF Markus Elfring
@ 2016-10-10 13:23           ` Adam Goryachev
  0 siblings, 0 replies; 221+ messages in thread
From: Adam Goryachev @ 2016-10-10 13:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-raid

Hi Markus,

I'm mostly a lurker on this, sometimes trying to help out other users 
when I can. Either way, I'm not a kernel coder, so take my comments with 
a grain of salt...

On 10/10/2016 23:28, SF Markus Elfring wrote:
>> I am ignoring Markus patches
> It's a pity that you chose such a reaction.
Different people will have different priorities, and that's OK.
>> and have told him that he should focus on bug fixes.
> I find that I suggest to improve something. Could you admit a few times
> that I found a "bug" you care also about at other source code places?
Different people will describe a bug differently. Has *any* of your 
patches been accepted on this list yet? Has *any* of them fixed a 
problem that a user encountered?
>> These patches don't add any value
> Can it be that you express a lower value for the Linux coding style here
> than desired as there might be other concerns behind such negative feedback?
Desired by who? Everyone is different. Sure, the coding style is there, 
and if you see a proposed patch which doesn't comply with the coding 
style, then advise everyone involved, and let's fix it before the patch 
goes in.
After the code is already in, most people are more concerned with other 
things (different priorities and all)...
>> and regularly introduce bugs.
> How do you think about to discuss corresponding facts further?
You haven't proposed any facts.... These are just different priorities 
from different people...

>> That said, "sizeof(*ptr)" is sort of official style.
> When this implementation detail is so official, I wonder then why some
> software developers can become "special" about the proposed update step
> like for this module.
It's not special, like I said above, if there is a new patch proposed by 
someone which doesn't meet the coding guidelines, then speak up.....

The problem here is that you don't have a history of providing "useful" 
patches (ie, where other kernel developers can see that you have fixed 
something that was broken/not working). Currently, all they see is that 
you have run some tool over the code, and then thrown together 50 
patches to change a bunch of code that doesn't really make any 
difference....

So, in short, I would guess you are beating a dead horse.Trying to 
create arguments over what is or is not right, better, or whatever is 
also nothing short of divisive and plain rude (whether intended or not). 
I would guess that if you had found one small style issue, and brought 
it up, explained that you were just starting out and found this code 
which doesn't meet the guidelines, you were confused about how it works, 
you think you understand now, but could it be changed to this which is 
easier to understand and matches the guidelines. Then it would probably 
have been accepted.
You would probably then be tempted to go and find the other 200 similar 
patches, and we would be back at this spot, but hopefully, you might 
move onto finding and fixing "harder" problems rather than another 100 
easy ones, and progressively your skills would improve, and everyone on 
the list would be delighted to receive your patches, and discuss them in 
detail.
Leave the other 100 easy patches to the next 100 people who come after 
you and need to start with an easy patch, before they progress toward 
the harder code/logic issues.

Like I said, I don't speak for anyone, and I myself don't like to see 
code with spelling/grammar mistakes, but with open source, while we can 
all help by submitting patches, "someone" needs to verify those patches, 
and so they must meet a certain usefulness criteria for them to "waste" 
their time on them.

PPS, deleted a bunch of CC's that didn't seem relevant, both lists and 
individuals....

Regards,
Adam

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-10 11:12       ` Dan Carpenter
  2016-10-10 12:28         ` SF Markus Elfring
@ 2016-10-10 13:57         ` Bjørn Mork
  2016-10-11  6:20         ` Dan Carpenter
  2 siblings, 0 replies; 221+ messages in thread
From: Bjørn Mork @ 2016-10-10 13:57 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, SF Markus Elfring, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

Dan Carpenter <dan.carpenter@oracle.com> writes:

> I am ignoring Markus patches and have told him that he should focus on
> bug fixes.  These patches don't add any value and regularly introduce
> bugs.

I think there should be a big fat warning in CodingStyle:

 THIS DOCUMENT DOES NOT APPLY TO ANY EXISTING KERNEL CODE.


Preserving existing style is more important than any minor style issue
anyway.  Style changes for the only purpose of style change should be
considered harmful and destructive behaviour. You'd think that is bloody
obvious, but evidently it isn't.  Not only are the untested, buggy,
churning patches still being submitted - some of them are even applied!

Adding such a statement will not prevent style changes, even changes
to bring code more in line with CodingStyle, as long as the patches are
part of some work of substance.  E.g. cleaning up before fixing bugs. If
you submit new code, then you can of course fix the style of any touched
context.

Oh well, I can dream..


Bjørn


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-10 13:20             ` SF Markus Elfring
@ 2016-10-10 14:01               ` Jes Sorensen
  2016-10-10 14:20                 ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Jes Sorensen @ 2016-10-10 14:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Richard Weinberger, linux-raid, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:
>>> How do you value compliance with coding styles?
>>
>> The Linux Coding Style is not a law,
>
> How serious can such guidelines become for software developers?
>
>> nor is it at all perfect.
>
> I got a similar impression. But are there enough items where a mostly clear
> guidance is specified?
>
>> You clearly misunderstood how Linux development work
>
> I got an other impression.
>
>> and you are doing a great job wasting everyone's time with this patchset.
>
> Would you like to reject any update steps for the affected source files
> from this patch series?
>
> Can it "accidentally" happen that some of them will be really worth
> also for your precious software development attention?

Given that none of your patches fix any real bugs and you do your best
to ignore any guidance you have been given, I do reject your entire
patchset and you can consider this a NACK for this entire series.

I get the impression you obtain your response to any email from M-x
doctor.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: md/raid1: Improve another size determination in setup_conf()
  2016-10-10 14:01               ` Jes Sorensen
@ 2016-10-10 14:20                 ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-10 14:20 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Dan Carpenter, Richard Weinberger, linux-raid, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, Julia Lawall

>> Can it "accidentally" happen that some of them will be really worth
>> also for your precious software development attention?
> 
> Given that none of your patches fix any real bugs

Are there any ones which would eventually become "real" also for you?


> and you do your best to ignore any guidance you have been given,

I dare occasionally to find reasons out for a specific disagreement.


> I do reject your entire patchset and you can consider this a NACK for this entire series.

Thanks for your feedback.

I am still curious if any other software developers or source code reviewers
would dare to express an other opinion for one of the shown update possibilities.

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-10 11:12       ` Dan Carpenter
  2016-10-10 12:28         ` SF Markus Elfring
  2016-10-10 13:57         ` [PATCH 24/54] " Bjørn Mork
@ 2016-10-11  6:20         ` Dan Carpenter
  2 siblings, 0 replies; 221+ messages in thread
From: Dan Carpenter @ 2016-10-11  6:20 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: SF Markus Elfring, linux-raid@vger.kernel.org, Christoph Hellwig,
	Guoqing Jiang, Jens Axboe, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors@vger.kernel.org,
	Julia Lawall

Oops.  I sent this email twice.  Sorry, about that.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-10 13:09         ` [PATCH 24/54] " Jes Sorensen
@ 2016-10-12  8:28           ` Dan Carpenter
  2016-10-12 12:18             ` Jes Sorensen
  0 siblings, 1 reply; 221+ messages in thread
From: Dan Carpenter @ 2016-10-12  8:28 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Richard Weinberger, SF Markus Elfring, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

Compare:

	foo = kmalloc(sizeof(*foo), GFP_KERNEL);

This says you are allocating enough space for foo.  It can be reviewed
by looking at one line.  If you change the type of foo it will still
work.

	foo = kmalloc(sizeof(struct whatever), GFP_KERNEL);

There isn't enough information to say if this is correct.  If you change
the type of foo then you have to update the allocation as well.

It's not a super common type of bug, but I see it occasionally.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: [PATCH 24/54] md/raid1: Improve another size determination in setup_conf()
  2016-10-12  8:28           ` Dan Carpenter
@ 2016-10-12 12:18             ` Jes Sorensen
  0 siblings, 0 replies; 221+ messages in thread
From: Jes Sorensen @ 2016-10-12 12:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, SF Markus Elfring, linux-raid@vger.kernel.org,
	Christoph Hellwig, Guoqing Jiang, Jens Axboe, Mike Christie,
	Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors@vger.kernel.org, Julia Lawall

Dan Carpenter <dan.carpenter@oracle.com> writes:
> Compare:
>
> 	foo = kmalloc(sizeof(*foo), GFP_KERNEL);
>
> This says you are allocating enough space for foo.  It can be reviewed
> by looking at one line.  If you change the type of foo it will still
> work.
>
> 	foo = kmalloc(sizeof(struct whatever), GFP_KERNEL);
>
> There isn't enough information to say if this is correct.  If you change
> the type of foo then you have to update the allocation as well.
>
> It's not a super common type of bug, but I see it occasionally.

I know what you are saying, but the latter in my book is easier to read
and reminds you what the type is when you review the code.

Point being this comes down to personal preference and stating that the
former is the right way or making that a rule and using checkpatch to
harrass people with patches to change it is bogus.

Jes

^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH] MD-RAID: Use seq_putc() in three status functions
  2016-10-06 16:34     ` Joe Perches
  2016-10-06 17:09       ` SF Markus Elfring
@ 2016-10-16  8:20       ` SF Markus Elfring
  2016-10-16 16:58         ` Hannes Reinecke
  1 sibling, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-16  8:20 UTC (permalink / raw)
  To: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 16 Oct 2016 10:10:28 +0200

A single character (a closing square bracket) should be put into a sequence
at the end in these functions.
Thus use the corresponding function "seq_putc".

This issue was detected also by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/raid1.c  | 2 +-
 drivers/md/raid10.c | 2 +-
 drivers/md/raid5.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1961d82..fd97f65 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1418,7 +1418,7 @@ static void raid1_status(struct seq_file *seq, struct mddev *mddev)
 			   rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
 	}
 	rcu_read_unlock();
-	seq_printf(seq, "]");
+	seq_putc(seq, ']');
 }
 
 static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index be1a9fc..7490b28 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1499,7 +1499,7 @@ static void raid10_status(struct seq_file *seq, struct mddev *mddev)
 		seq_printf(seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
 	}
 	rcu_read_unlock();
-	seq_printf(seq, "]");
+	seq_putc(seq, ']');
 }
 
 /* check if there are enough drives for
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 92ac251..9eb45c4 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7077,7 +7077,7 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
 		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
 	}
 	rcu_read_unlock();
-	seq_printf (seq, "]");
+	seq_putc(seq, ']');
 }
 
 static void print_raid5_conf (struct r5conf *conf)
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH] MD-RAID: Use seq_putc() in three status functions
  2016-10-16  8:20       ` [PATCH] MD-RAID: Use seq_putc() in three status functions SF Markus Elfring
@ 2016-10-16 16:58         ` Hannes Reinecke
  2016-10-16 17:10           ` MD-RAID: Use seq_putc() in three status functions? SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-16 16:58 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid, Christoph Hellwig, Guoqing Jiang,
	Jens Axboe, Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak
  Cc: LKML, kernel-janitors

On 10/16/2016 10:20 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 16 Oct 2016 10:10:28 +0200
>
> A single character (a closing square bracket) should be put into a sequence
> at the end in these functions.
> Thus use the corresponding function "seq_putc".
>
> This issue was detected also by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/md/raid1.c  | 2 +-
>  drivers/md/raid10.c | 2 +-
>  drivers/md/raid5.c  | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 1961d82..fd97f65 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1418,7 +1418,7 @@ static void raid1_status(struct seq_file *seq, struct mddev *mddev)
>  			   rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
>  	}
>  	rcu_read_unlock();
> -	seq_printf(seq, "]");
> +	seq_putc(seq, ']');
>  }
>
>  static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
> diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
> index be1a9fc..7490b28 100644
> --- a/drivers/md/raid10.c
> +++ b/drivers/md/raid10.c
> @@ -1499,7 +1499,7 @@ static void raid10_status(struct seq_file *seq, struct mddev *mddev)
>  		seq_printf(seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
>  	}
>  	rcu_read_unlock();
> -	seq_printf(seq, "]");
> +	seq_putc(seq, ']');
>  }
>
>  /* check if there are enough drives for
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 92ac251..9eb45c4 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -7077,7 +7077,7 @@ static void raid5_status(struct seq_file *seq, struct mddev *mddev)
>  		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
>  	}
>  	rcu_read_unlock();
> -	seq_printf (seq, "]");
> +	seq_putc(seq, ']');
>  }
>
>  static void print_raid5_conf (struct r5conf *conf)
>
The point of this patch being ... what?
Does it improve code? Does it improve anything?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-16 16:58         ` Hannes Reinecke
@ 2016-10-16 17:10           ` SF Markus Elfring
  2016-10-16 17:18             ` SF Markus Elfring
  2016-10-17  5:58             ` Hannes Reinecke
  0 siblings, 2 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-16 17:10 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors

> Does it improve code? Does it improve anything?

Yes. - I got such an impression.

* Is it more efficient to call the function "seq_printf" for the desired data processing
  for a single character than to pass it to the function "" in a string?

* Will the required data transfer shrink a bit for the affected functions because of
  such a change?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-16 17:10           ` MD-RAID: Use seq_putc() in three status functions? SF Markus Elfring
@ 2016-10-16 17:18             ` SF Markus Elfring
  2016-10-17  5:58             ` Hannes Reinecke
  1 sibling, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-16 17:18 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors

> Yes. - I got such an impression.

Correction:

* Is it more efficient to call the function "seq_putc" for the desired data processing
  for a single character than to pass it to the function "seq_printf" in a string?

* Will the required data transfer shrink a bit for the affected functions because of
  such a change?
  How do you think about to reduce the transmission for such tiny strings
  containing delimiters?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-16 17:10           ` MD-RAID: Use seq_putc() in three status functions? SF Markus Elfring
  2016-10-16 17:18             ` SF Markus Elfring
@ 2016-10-17  5:58             ` Hannes Reinecke
  2016-10-17  7:39               ` SF Markus Elfring
  1 sibling, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17  5:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors

On 10/16/2016 07:10 PM, SF Markus Elfring wrote:
>> Does it improve code? Does it improve anything?
> 
> Yes. - I got such an impression.
> 
> * Is it more efficient to call the function "seq_printf" for the desired data processing
>   for a single character than to pass it to the function "" in a string?
> 
> * Will the required data transfer shrink a bit for the affected functions because of
>   such a change?
> 
Which are questions _you_ should be able to answer.
It's your patch, after all.
Once you do (and prove that the answer is 'yes' to the above two
questions) the patch will be applied.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17  5:58             ` Hannes Reinecke
@ 2016-10-17  7:39               ` SF Markus Elfring
  2016-10-17  8:09                 ` Hannes Reinecke
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17  7:39 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors

>>> Does it improve code? Does it improve anything?
>>
>> Yes. - I got such an impression.
>>
>> * Is it more efficient to call the function "seq_printf" for the desired data processing
>>   for a single character than to pass it to the function "" in a string?
>>
>> * Will the required data transfer shrink a bit for the affected functions because of
>>   such a change?
>>
> Which are questions _you_ should be able to answer.

I wonder that the answers are not obvious for you already.

Calling the function "seq_putc" will be more efficient than "seq_printf"
in this case because of the following reasons.

1. How does the distribution look like for supported processor architectures
   where the data transfer for bytes (as a function call parameter)
   is faster than for (string) pointers?

2. Did anybody measure already how many the execution times can vary
   for these functions?

3. seq_printf() provides more functionality as this kind of programming
   interface was designed for a bigger purpose.
   How much do you care for consequences when such general functions
   are called with input data they were not designed for mainly?

4. The seq_putc() implementation is so simple.
   http://lxr.free-electrons.com/source/fs/seq_file.c?v=4.8#L657

   Where do you get doubts about its efficiency for the data processing
   of a single character?


> It's your patch, after all.

Yes. - I published a special update suggestion once again.


> Once you do (and prove that the answer is 'yes' to the above two
> questions) the patch will be applied.

How do you think about to share a bit more from your software development
and testing experience?
Which call frequencies do you observe for the affected functions?

1. raid1_status
2. raid10_status
3. raid5_status

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17  7:39               ` SF Markus Elfring
@ 2016-10-17  8:09                 ` Hannes Reinecke
  2016-10-17  9:00                   ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17  8:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors

On 10/17/2016 09:39 AM, SF Markus Elfring wrote:
>>>> Does it improve code? Does it improve anything?
>>>
>>> Yes. - I got such an impression.
>>>
>>> * Is it more efficient to call the function "seq_printf" for the desired data processing
>>>   for a single character than to pass it to the function "" in a string?
>>>
>>> * Will the required data transfer shrink a bit for the affected functions because of
>>>   such a change?
>>>
>> Which are questions _you_ should be able to answer.
> 
> I wonder that the answers are not obvious for you already.
> 
> Calling the function "seq_putc" will be more efficient than "seq_printf"
> in this case because of the following reasons.
> 
> 1. How does the distribution look like for supported processor architectures
>    where the data transfer for bytes (as a function call parameter)
>    is faster than for (string) pointers?
> 
How would I know? I would assume that _you_ did some measurements here;
after all, _you_ are trying to push this patch.
I could easily claim that seq_printf() is more efficient than
seq_putc(), and won't apply your patch.
So _you_ have to prove that your patch is more efficient.

> 2. Did anybody measure already how many the execution times can vary
>    for these functions?
> 
Probably not.
But referring to the previous topic:
Unless _you_ prove that _your_ patch is more efficient it won't get
applied. _You_ want us to apply your patch, so the burden is on _you_ to
provide the required data.


>    Where do you get doubts about its efficiency for the data processing
>    of a single character?
> 
Because it's being called at the end of a function calling seq_printf()
already. So exchanging a single call is probably not helping anything,
as the compiler will optimize it anyway.
Case in point: with your patch the x86_64 compiler generates nearly
identical code for driver/md/raid1.c, but with one instruction _more_
after your patch has been applied.

So it's not immediately obvious that your patch is an improvement.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17  8:09                 ` Hannes Reinecke
@ 2016-10-17  9:00                   ` SF Markus Elfring
  2016-10-17  9:50                     ` Hannes Reinecke
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17  9:00 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>> Calling the function "seq_putc" will be more efficient than "seq_printf"
>> in this case because of the following reasons.
>>
>> 1. How does the distribution look like for supported processor architectures
>>    where the data transfer for bytes (as a function call parameter)
>>    is faster than for (string) pointers?
>>
> How would I know?

How many processor architecture characteristics do you know already?

* Is a string pointer often longer than a byte?

* I imagine that it can become also interesting to check byte level data access
  under constraints of machine word sizes and alignment.


> I would assume that _you_ did some measurements here;

How much would you trust in any concrete numbers I could present
for this use case?

Do you give more trust to a reference testing platform?


> I could easily claim that seq_printf() is more efficient than
> seq_putc(), and won't apply your patch.

This is also possible in principle.


> So _you_ have to prove that your patch is more efficient.

How many results would we like to clarify from various hardware
and software combinations?


>> 2. Did anybody measure already how many the execution times can vary
>>    for these functions?
>>
> Probably not.

Thanks for this information.

How important are the mentioned functions for you within the Linux
programming interface so far?


> Unless _you_ prove that _your_ patch is more efficient it won't get applied.

Which data would you accept as a "prove" in this case?


>>    Where do you get doubts about its efficiency for the data processing
>>    of a single character?
>>
> Because it's being called at the end of a function calling seq_printf() already.

Interesting view …


> So exchanging a single call is probably not helping anything,
> as the compiler will optimize it anyway.

How common is the discussed software transformation between implementations
for optimising compilers?


> Case in point: with your patch the x86_64 compiler generates nearly
> identical code for driver/md/raid1.c, but with one instruction _more_
> after your patch has been applied.

Which software versions and command parameters did you try out
for this information (from an unspecified run time environment)?


> So it's not immediately obvious that your patch is an improvement.

I agree that there are system properties and constraints which can be
considered further.

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17  9:00                   ` SF Markus Elfring
@ 2016-10-17  9:50                     ` Hannes Reinecke
  2016-10-17 11:10                       ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17  9:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-raid, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

On 10/17/2016 11:00 AM, SF Markus Elfring wrote:
>>> Calling the function "seq_putc" will be more efficient than "seq_printf"
>>> in this case because of the following reasons.
>>>
>>> 1. How does the distribution look like for supported processor architectures
>>>    where the data transfer for bytes (as a function call parameter)
>>>    is faster than for (string) pointers?
>>>
>> How would I know?
> 
> How many processor architecture characteristics do you know already?
> 
x86, s390x, ppc/ppc64.

> * Is a string pointer often longer than a byte?
> 
Always.

(Which up to now I thought was basic programming knowledge...)

> * I imagine that it can become also interesting to check byte level data access
>   under constraints of machine word sizes and alignment.
> 
So, another test for you to do.

> 
>> I would assume that _you_ did some measurements here;
> 
> How much would you trust in any concrete numbers I could present
> for this use case?
> 
> Do you give more trust to a reference testing platform?
> 
At the moment _any_ test would do.
With every response from your side you just keep on asking further
questions. But so far you haven't delivered any answers nor measurements.

> 
>> I could easily claim that seq_printf() is more efficient than
>> seq_putc(), and won't apply your patch.
> 
> This is also possible in principle.
> 
No, this is what's going to happen if you don't show any measurements.

> 
>> So _you_ have to prove that your patch is more efficient.
> 
> How many results would we like to clarify from various hardware
> and software combinations?
> 
See above. At the moment _any_ test result from your side would do.

> 
>>> 2. Did anybody measure already how many the execution times can vary
>>>    for these functions?
>>>
>> Probably not.
> 
> Thanks for this information.
> 
> How important are the mentioned functions for you within the Linux
> programming interface so far?
> 
Not very. The interface is only used in a slow path, and the execution
time doesn't affect I/O performance in any way.

> 
>> Unless _you_ prove that _your_ patch is more efficient it won't get applied.
> 
> Which data would you accept as a "prove" in this case?
> 
Again: You want something from us. We don't have to prove anything, you
need to convince us. And it is really hard to convince anyone by asking
questions.

> 
>>>    Where do you get doubts about its efficiency for the data processing
>>>    of a single character?
>>>
>> Because it's being called at the end of a function calling seq_printf() already.
> 
> Interesting view …
> 
> 
>> So exchanging a single call is probably not helping anything,
>> as the compiler will optimize it anyway.
> 
> How common is the discussed software transformation between implementations
> for optimising compilers?
> 
> 
>> Case in point: with your patch the x86_64 compiler generates nearly
>> identical code for driver/md/raid1.c, but with one instruction _more_
>> after your patch has been applied.
> 
> Which software versions and command parameters did you try out
> for this information (from an unspecified run time environment)?
> 
> 
# gcc --version
gcc (SUSE Linux) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

git tree from git.kernel.org/mkp/u/4.10/scsi-queue

_I_ did some measurements.
I'm still waiting from results from your side.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17  9:50                     ` Hannes Reinecke
@ 2016-10-17 11:10                       ` SF Markus Elfring
  2016-10-17 11:32                         ` Bernd Petrovitsch
  2016-10-17 14:00                         ` Hannes Reinecke
  0 siblings, 2 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17 11:10 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Christoph Hellwig, Guoqing Jiang, Jens Axboe, Joe Perches,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, kbuild-all, ltp

>> * Is a string pointer often longer than a byte?
>>
> Always.

I have got doubts for this specific information.


> (Which up to now I thought was basic programming knowledge...)

By the way:
Run time environments still exist where the size of a pointer can be also
just one byte, don't they?


>> How many results would we like to clarify from various hardware
>> and software combinations?
>>
> See above. At the moment _any_ test result from your side would do.

I imagine that another single result might not be representative.
How many lessons from test statistics will usually be also relevant here?


>> How important are the mentioned functions for you within the Linux
>> programming interface so far?
>>
> Not very. The interface is only used in a slow path, and the execution
> time doesn't affect I/O performance in any way.

Thanks for another interesting information.


>>> Case in point: with your patch the x86_64 compiler generates nearly
>>> identical code for driver/md/raid1.c, but with one instruction _more_
>>> after your patch has been applied.
>>
>> Which software versions and command parameters did you try out
>> for this information (from an unspecified run time environment)?
>>
> # gcc --version
> gcc (SUSE Linux) 4.8.5

Thanks for this detail.

* Did you choose any special optimisation settings for your quick check?

* Will any compilation results matter if "optimisation" would be
  switched off there?


> I'm still waiting from results from your side.

Would any other software developers or testers dare to add related information?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 11:10                       ` SF Markus Elfring
@ 2016-10-17 11:32                         ` Bernd Petrovitsch
  2016-10-17 11:43                           ` SF Markus Elfring
  2016-10-17 14:00                         ` Hannes Reinecke
  1 sibling, 1 reply; 221+ messages in thread
From: Bernd Petrovitsch @ 2016-10-17 11:32 UTC (permalink / raw)
  To: SF Markus Elfring, Hannes Reinecke, linux-raid
  Cc: Christoph Hellwig, Guoqing Jiang, Jens Axboe, Joe Perches,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, kbuild-all, ltp

On Mon, 2016-10-17 at 13:10 +0200, SF Markus Elfring wrote:
[...]
> > (Which up to now I thought was basic programming knowledge...)
> 
> By the way:
> Run time environments still exist where the size of a pointer can
> be also just one byte, don't they?

In the context of the Linux kernel: No.

[ Side note: there might be some DSP out there with a running Linux
kernel which cannot really address a "byte" (meaning 8bits) but only in
register sized quantities (and also aligned for that). But no one cares
here really deeply as that is a so fundamental difference that the C-
compiler must cope with that anyways in the first place. ]

[...]
> > See above. At the moment _any_ test result from your side would do.
> 
> I imagine that another single result might not be representative.

Publish not only results but also everything (complete!) so that anyone
can *easily* follow it to check and reproduce the results - especially
if you want people with knowledge of other architectures to comment
(otherwise they probably won't bother).

Kind regards,
	Bernd
-- 
Bernd Petrovitsch                  Email : bernd@petrovitsch.priv.at
                     LUGA : http://www.luga.at

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 11:32                         ` Bernd Petrovitsch
@ 2016-10-17 11:43                           ` SF Markus Elfring
  2016-10-17 14:01                             ` Hannes Reinecke
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17 11:43 UTC (permalink / raw)
  To: Bernd Petrovitsch, linux-raid
  Cc: Hannes Reinecke, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>>> See above. At the moment _any_ test result from your side would do.
>>
>> I imagine that another single result might not be representative.
> 
> Publish not only results but also everything (complete!) so that anyone
> can *easily* follow it to check and reproduce the results - especially
> if you want people with knowledge of other architectures to comment
> (otherwise they probably won't bother).

Am I the only software developer so far who would dare to reconsider
implementation details from three status functions?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 11:10                       ` SF Markus Elfring
  2016-10-17 11:32                         ` Bernd Petrovitsch
@ 2016-10-17 14:00                         ` Hannes Reinecke
  1 sibling, 0 replies; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17 14:00 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid
  Cc: Christoph Hellwig, Guoqing Jiang, Jens Axboe, Joe Perches,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, kbuild-all, ltp

On 10/17/2016 01:10 PM, SF Markus Elfring wrote:
>>> * Is a string pointer often longer than a byte?
>>>
>> Always.
> 
> I have got doubts for this specific information.
> 
> 
>> (Which up to now I thought was basic programming knowledge...)
> 
> By the way:
> Run time environments still exist where the size of a pointer can be also
> just one byte, don't they?
> 
Really? Name one.
You can only fit a point in one byte if you are on an 8-bit system.
Which I don't think linux is running on.

>>> How many results would we like to clarify from various hardware
>>> and software combinations?
>>>
>> See above. At the moment _any_ test result from your side would do.
> 
> I imagine that another single result might not be representative.
> How many lessons from test statistics will usually be also relevant here?
> 
> 
As said above, _any_ statistic will do at this point.

>>> How important are the mentioned functions for you within the Linux
>>> programming interface so far?
>>>
>> Not very. The interface is only used in a slow path, and the execution
>> time doesn't affect I/O performance in any way.
> 
> Thanks for another interesting information.
> 
> 
>>>> Case in point: with your patch the x86_64 compiler generates nearly
>>>> identical code for driver/md/raid1.c, but with one instruction _more_
>>>> after your patch has been applied.
>>>
>>> Which software versions and command parameters did you try out
>>> for this information (from an unspecified run time environment)?
>>>
>> # gcc --version
>> gcc (SUSE Linux) 4.8.5
> 
> Thanks for this detail.
> 
> * Did you choose any special optimisation settings for your quick check?
> 
> * Will any compilation results matter if "optimisation" would be
>   switched off there?
> 
> 
These were the results when calling 'make' in the kernel source tree.
With all applicable options.

>> I'm still waiting from results from your side.
> 
> Would any other software developers or testers dare to add related information?
> 
No. It's your patch, _you_ have to do it.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 11:43                           ` SF Markus Elfring
@ 2016-10-17 14:01                             ` Hannes Reinecke
  2016-10-17 14:30                               ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17 14:01 UTC (permalink / raw)
  To: SF Markus Elfring, Bernd Petrovitsch, linux-raid
  Cc: Christoph Hellwig, Guoqing Jiang, Jens Axboe, Joe Perches,
	Mike Christie, Neil Brown, Shaohua Li, Tomasz Majchrzak, LKML,
	kernel-janitors, kbuild-all, ltp

On 10/17/2016 01:43 PM, SF Markus Elfring wrote:
>>>> See above. At the moment _any_ test result from your side would do.
>>>
>>> I imagine that another single result might not be representative.
>>
>> Publish not only results but also everything (complete!) so that anyone
>> can *easily* follow it to check and reproduce the results - especially
>> if you want people with knowledge of other architectures to comment
>> (otherwise they probably won't bother).
> 
> Am I the only software developer so far who would dare to reconsider
> implementation details from three status functions?
> 
No.
But we're waiting for you showing is that it is an improvement.
Which at the moment we don't see.
Hence we're waiting from a proof or validation from your side.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		   Teamlead Storage & Networking
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 14:01                             ` Hannes Reinecke
@ 2016-10-17 14:30                               ` SF Markus Elfring
  2016-10-17 15:33                                 ` Hannes Reinecke
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17 14:30 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>> Am I the only software developer so far who would dare to reconsider
>> implementation details from three status functions?
>>
> No.

Thanks for this kind of promising feedback.


> But we're waiting for you showing is that it is an improvement.

Can this aspect also be clarified to some degree from a logical point of view?

* Would you really like to know under which circumstances data processing
  will be faster for a single character instead of using a string pointer
  and corresponding two characters?

* Do you care for a changed memory allocation characteristic?

* Will it occasionally be useful to avoid the storage for another string literal?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 14:30                               ` SF Markus Elfring
@ 2016-10-17 15:33                                 ` Hannes Reinecke
  2016-10-17 16:08                                   ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17 15:33 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

On 10/17/2016 04:30 PM, SF Markus Elfring wrote:
>>> Am I the only software developer so far who would dare to reconsider
>>> implementation details from three status functions?
>>>
>> No.
>
> Thanks for this kind of promising feedback.
>
>
>> But we're waiting for you showing is that it is an improvement.
>
> Can this aspect also be clarified to some degree from a logical point of view?
>
I sincerely doubt that.
We've discussed the logical implications already, and failed to come to 
a consensus. So we need some proof (as in: on this architecture I'm 
seeing this and that performance improvements).
Which you have to deliver.

> * Would you really like to know under which circumstances data processing
>   will be faster for a single character instead of using a string pointer
>   and corresponding two characters?
>
It's not a problem of the interface, it's a problem of the resulting 
code (ie assembler output). We can discuss all we like, if the compiler 
decides to throw in an optimisation none of the arguments even apply.

> * Do you care for a changed memory allocation characteristic?
>
> * Will it occasionally be useful to avoid the storage for another string literal?
>
Occasionally: yes.
In this particular case: hardly.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 15:33                                 ` Hannes Reinecke
@ 2016-10-17 16:08                                   ` SF Markus Elfring
  2016-10-17 17:18                                     ` Hannes Reinecke
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-17 16:08 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>> * Would you really like to know under which circumstances data processing
>>   will be faster for a single character instead of using a string pointer
>>   and corresponding two characters?
>>
> It's not a problem of the interface, it's a problem of the resulting code
> (ie assembler output).

How do you think about to discuss concrete generated code any further?


> We can discuss all we like, if the compiler decides to throw in
> an optimisation none of the arguments even apply.

Would it make sense to clarify assembler output with optimisation switched off?

Do you eventually care for code from non-optimising compilers?


>> * Will it occasionally be useful to avoid the storage for another string literal?
>>
> Occasionally: yes.
> In this particular case: hardly.

I am curious when such a software design aspect can become more relevant.
Would it be nice to get rid of three questionable string terminators (null bytes)
for example?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 16:08                                   ` SF Markus Elfring
@ 2016-10-17 17:18                                     ` Hannes Reinecke
  2016-10-18 18:20                                       ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: Hannes Reinecke @ 2016-10-17 17:18 UTC (permalink / raw)
  To: SF Markus Elfring, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

On 10/17/2016 06:08 PM, SF Markus Elfring wrote:
>>> * Would you really like to know under which circumstances data processing
>>>   will be faster for a single character instead of using a string pointer
>>>   and corresponding two characters?
>>>
>> It's not a problem of the interface, it's a problem of the resulting code
>> (ie assembler output).
>
> How do you think about to discuss concrete generated code any further?
>
Sure. Show me the generated code and point out where the benefits are.

>> We can discuss all we like, if the compiler decides to throw in
>> an optimisation none of the arguments even apply.
>
> Would it make sense to clarify assembler output with optimisation switched off?
>
> Do you eventually care for code from non-optimising compilers?
>
No. This is the linux kernel. There is a very, _very_ limited benefit of 
trying to use a non-standard compiler.

>
>>> * Will it occasionally be useful to avoid the storage for another string literal?
>>>
>> Occasionally: yes.
>> In this particular case: hardly.
>
> I am curious when such a software design aspect can become more relevant.
> Would it be nice to get rid of three questionable string terminators (null bytes)
> for example?
>
Again, all this does it trying to out-guess what the compiler might be 
doing during compilation. For which the easiest method is checking.
So back to the original task for you: Show me in the generated output 
where the benefits are.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-17 17:18                                     ` Hannes Reinecke
@ 2016-10-18 18:20                                       ` SF Markus Elfring
  2016-10-20 12:24                                         ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-18 18:20 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

> So back to the original task for you: Show me in the generated output where the benefits are.

I can offer a bit more information for this software development discussion.


The afffected source files can be compiled for the processor architecture "x86_64"
by a tool like "GCC 6.2.1+r239849-1.3" from the software distribution
"openSUSE Tumbleweed" with the following command examples.

git checkout next-20161014 && my_cc=/usr/bin/gcc-6 && make HOSTCC="${my_cc}" allmodconfig && make -j6 HOSTCC="${my_cc}" drivers/md/
git checkout next_usage_of_seq_putc_in_md_raid_1 && my_cc=/usr/bin/gcc-6 && make HOSTCC="${my_cc}" allmodconfig && make -j6 HOSTCC="${my_cc}" drivers/md/


The tool "objdump" from the software package "binutils 2.27-1.3" can be used
to get corresponding disassemblies for a file like "drivers/md/raid1.obj"
which can then be compared as follows.


--- ../disassembly-md-raid1-next-20161014-1.txt	2016-10-18 18:00:12.341222741 +0200
+++ ../disassembly-md-raid1-seq_putc-1.txt	2016-10-18 18:03:54.135887333 +0200
@@ -3349,7 +3349,7 @@
     37ad:	85 c0                	test   %eax,%eax
     37af:	74 0d                	je     37be <raid1_status+0x9e>
     37b1:	80 3d 00 00 00 00 00 	cmpb   $0x0,0x0(%rip)        # 37b8 <raid1_status+0x98>
-    37b8:	0f 84 1d 01 00 00    	je     38db <raid1_status+0x1bb>
+    37b8:	0f 84 1b 01 00 00    	je     38d9 <raid1_status+0x1b9>
     37be:	4c 89 ff             	mov    %r15,%rdi
     37c1:	31 db                	xor    %ebx,%ebx
     37c3:	e8 00 00 00 00       	callq  37c8 <raid1_status+0xa8>
@@ -3404,42 +3404,43 @@
     3891:	85 c0                	test   %eax,%eax
     3893:	74 09                	je     389e <raid1_status+0x17e>
     3895:	80 3d 00 00 00 00 00 	cmpb   $0x0,0x0(%rip)        # 389c <raid1_status+0x17c>
-    389c:	74 6e                	je     390c <raid1_status+0x1ec>
+    389c:	74 6c                	je     390a <raid1_status+0x1ea>
     389e:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx
     38a5:	be 01 00 00 00       	mov    $0x1,%esi
     38aa:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
     38b1:	65 ff 0d 00 00 00 00 	decl   %gs:0x0(%rip)        # 38b8 <raid1_status+0x198>
     38b8:	e8 00 00 00 00       	callq  38bd <raid1_status+0x19d>
     38bd:	4c 89 f7             	mov    %r14,%rdi
-    38c0:	48 c7 c6 00 00 00 00 	mov    $0x0,%rsi
-    38c7:	e8 00 00 00 00       	callq  38cc <raid1_status+0x1ac>
-    38cc:	48 83 c4 10          	add    $0x10,%rsp
-    38d0:	5b                   	pop    %rbx
-    38d1:	41 5c                	pop    %r12
-    38d3:	41 5d                	pop    %r13
-    38d5:	41 5e                	pop    %r14
-    38d7:	41 5f                	pop    %r15
-    38d9:	5d                   	pop    %rbp
-    38da:	c3                   	retq   
-    38db:	e8 00 00 00 00       	callq  38e0 <raid1_status+0x1c0>
-    38e0:	84 c0                	test   %al,%al
-    38e2:	0f 85 d6 fe ff ff    	jne    37be <raid1_status+0x9e>
-    38e8:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx
-    38ef:	be 69 03 00 00       	mov    $0x369,%esi
-    38f4:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
-    38fb:	c6 05 00 00 00 00 01 	movb   $0x1,0x0(%rip)        # 3902 <raid1_status+0x1e2>
-    3902:	e8 00 00 00 00       	callq  3907 <raid1_status+0x1e7>
-    3907:	e9 b2 fe ff ff       	jmpq   37be <raid1_status+0x9e>
-    390c:	e8 00 00 00 00       	callq  3911 <raid1_status+0x1f1>
-    3911:	84 c0                	test   %al,%al
-    3913:	75 89                	jne    389e <raid1_status+0x17e>
-    3915:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx
-    391c:	be 9c 03 00 00       	mov    $0x39c,%esi
-    3921:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
-    3928:	c6 05 00 00 00 00 01 	movb   $0x1,0x0(%rip)        # 392f <raid1_status+0x20f>
-    392f:	e8 00 00 00 00       	callq  3934 <raid1_status+0x214>
-    3934:	e9 65 ff ff ff       	jmpq   389e <raid1_status+0x17e>
-    3939:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
+    38c0:	be 5d 00 00 00       	mov    $0x5d,%esi
+    38c5:	e8 00 00 00 00       	callq  38ca <raid1_status+0x1aa>
+    38ca:	48 83 c4 10          	add    $0x10,%rsp
+    38ce:	5b                   	pop    %rbx
+    38cf:	41 5c                	pop    %r12
+    38d1:	41 5d                	pop    %r13
+    38d3:	41 5e                	pop    %r14
+    38d5:	41 5f                	pop    %r15
+    38d7:	5d                   	pop    %rbp
+    38d8:	c3                   	retq   
+    38d9:	e8 00 00 00 00       	callq  38de <raid1_status+0x1be>
+    38de:	84 c0                	test   %al,%al
+    38e0:	0f 85 d8 fe ff ff    	jne    37be <raid1_status+0x9e>
+    38e6:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx
+    38ed:	be 69 03 00 00       	mov    $0x369,%esi
+    38f2:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
+    38f9:	c6 05 00 00 00 00 01 	movb   $0x1,0x0(%rip)        # 3900 <raid1_status+0x1e0>
+    3900:	e8 00 00 00 00       	callq  3905 <raid1_status+0x1e5>
+    3905:	e9 b4 fe ff ff       	jmpq   37be <raid1_status+0x9e>
+    390a:	e8 00 00 00 00       	callq  390f <raid1_status+0x1ef>
+    390f:	84 c0                	test   %al,%al
+    3911:	75 8b                	jne    389e <raid1_status+0x17e>
+    3913:	48 c7 c2 00 00 00 00 	mov    $0x0,%rdx
+    391a:	be 9c 03 00 00       	mov    $0x39c,%esi
+    391f:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
+    3926:	c6 05 00 00 00 00 01 	movb   $0x1,0x0(%rip)        # 392d <raid1_status+0x20d>
+    392d:	e8 00 00 00 00       	callq  3932 <raid1_status+0x212>
+    3932:	e9 67 ff ff ff       	jmpq   389e <raid1_status+0x17e>
+    3937:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
+    393e:	00 00 
 
 0000000000003940 <print_conf>:
     3940:	e8 00 00 00 00       	callq  3945 <print_conf+0x5>
@@ -11134,7 +11135,7 @@
 
 0000000000000000 <_GLOBAL__sub_D_65535_0_raid1.c>:
    0:	55                   	push   %rbp
-   1:	be 35 00 00 00       	mov    $0x35,%esi
+   1:	be 34 00 00 00       	mov    $0x34,%esi
    6:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
    d:	48 89 e5             	mov    %rsp,%rbp
   10:	e8 00 00 00 00       	callq  15 <_GLOBAL__sub_D_65535_0_raid1.c+0x15>
@@ -11145,7 +11146,7 @@
 
 0000000000000000 <_GLOBAL__sub_I_65535_1_raid1.c>:
    0:	55                   	push   %rbp
-   1:	be 35 00 00 00       	mov    $0x35,%esi
+   1:	be 34 00 00 00       	mov    $0x34,%esi
    6:	48 c7 c7 00 00 00 00 	mov    $0x0,%rdi
    d:	48 89 e5             	mov    %rsp,%rbp
   10:	e8 00 00 00 00       	callq  15 <_GLOBAL__sub_I_65535_1_raid1.c+0x15>


Does this kind of data display contain differences which are worth for further considerations?

Regards,
Markus

^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-18 18:20                                       ` SF Markus Elfring
@ 2016-10-20 12:24                                         ` SF Markus Elfring
  2016-10-28 20:04                                           ` SF Markus Elfring
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-20 12:24 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>> So back to the original task for you: Show me in the generated output where the benefits are.

I can offer another bit of information for this software development discussion.

The following build settings were active in my "Makefile" for this Linux test case.

…
HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O0 -fomit-frame-pointer -std=gnu89
…


The afffected source files can be compiled for the processor architecture "x86_64"
by a tool like "GCC 6.2.1+r239849-1.4" from the software distribution
"openSUSE Tumbleweed" with the following command example.

my_original=${my_build_dir}unchanged/test/ \
&& my_fixing=${my_build_dir}patched/test/ \
&& mkdir -p ${my_original} ${my_fixing} \
&& my_cc=/usr/bin/gcc-6 \
&& my_module=drivers/md/raid1.s \
&& git checkout next-20161014 \
&& make -j6 O="${my_original}" HOSTCC="${my_cc}" allmodconfig ${my_module} \
&& git checkout next_usage_of_seq_putc_in_md_raid_1 \
&& make -j6 O="${my_fixing}" HOSTCC="${my_cc}" allmodconfig ${my_module} \
&& diff -u "${my_original}${my_module}" "${my_fixing}${my_module}" > "${my_build_dir}assembler_code_comparison_$(date -I)_1.diff"


Unfortunately, the generated file got the size "311 KiB". I guess that
this is too big to send such a file around on the Linux mailing list.

Is this kind of assembler code comparison still useful to clarify relevant
differences further?

Regards,
Markus


^ permalink raw reply	[flat|nested] 221+ messages in thread

* Re: MD-RAID: Use seq_putc() in three status functions?
  2016-10-20 12:24                                         ` SF Markus Elfring
@ 2016-10-28 20:04                                           ` SF Markus Elfring
  0 siblings, 0 replies; 221+ messages in thread
From: SF Markus Elfring @ 2016-10-28 20:04 UTC (permalink / raw)
  To: Hannes Reinecke, linux-raid
  Cc: Bernd Petrovitsch, Christoph Hellwig, Guoqing Jiang, Jens Axboe,
	Joe Perches, Mike Christie, Neil Brown, Shaohua Li,
	Tomasz Majchrzak, LKML, kernel-janitors, kbuild-all, ltp

>>> So back to the original task for you: Show me in the generated output where the benefits are.

I can offer another bit of information for this software development discussion.

The following build settings were active in my "Makefile" for this Linux test case.

…
HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O0 -fomit-frame-pointer -std=gnu89
…


The afffected source files can be compiled for the processor architecture "x86_64"
by a tool like "GCC 6.2.1+r239849-1.5" from the software distribution
"openSUSE Tumbleweed" with the following command example.

my_original=${my_build_dir}unchanged/test/ \
&& my_fixing=${my_build_dir}patched/test/ \
&& mkdir -p ${my_original} ${my_fixing} \
&& my_cc=/usr/bin/gcc-6 \
&& my_module=drivers/md/raid1.s \
&& git checkout next-20161014 \
&& make -j6 O="${my_original}" CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
&& git checkout next_usage_of_seq_putc_in_md_raid_1 \
&& make -j6 O="${my_fixing}" CC="${my_cc}" HOSTCC="${my_cc}" allmodconfig "${my_module}" \
&& diff -u "${my_original}${my_module}" "${my_fixing}${my_module}" > "${my_build_dir}assembler_code_comparison_$(date -I)_3.diff"


The generated file got the size "25.4 KiB" this time. I guess that only
the following two diff hunks are interesting then to show desired effects
for the suggested software refactoring around data output of a single character
(instead of a similar string).


…
@@ -4402,10 +4402,6 @@
 .LC19:
 	.string	"%s"
 	.zero	61
-	.align 32
-.LC20:
-	.string	"]"
-	.zero	62
 	.text
 	.p2align 4,,15
 	.type	raid1_status, @function
@@ -4564,8 +4560,8 @@
 	movq	$rcu_lock_map, %rdi	#,
 	call	lock_release	#
 	movq	%r14, %rdi	# seq,
-	movq	$.LC20, %rsi	#,
-	call	seq_printf	#
+	movl	$93, %esi	#,
+	call	seq_putc	#
 	addq	$16, %rsp	#,
 	popq	%rbx	#
 	popq	%r12	#
…


* Is this kind of assembler code comparison useful to clarify relevant
  differences further?

* Are any software development concerns left over for such a transformation?

Regards,
Markus


^ permalink raw reply	[flat|nested] 221+ messages in thread

* [PATCH v2] md-multipath: Use seq_putc() in multipath_status()
  2016-10-02 12:04   ` [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status() SF Markus Elfring
@ 2018-01-13  8:55     ` SF Markus Elfring
  2018-02-17 21:01       ` Shaohua Li
  0 siblings, 1 reply; 221+ messages in thread
From: SF Markus Elfring @ 2018-01-13  8:55 UTC (permalink / raw)
  To: linux-raid, Shaohua Li; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 13 Jan 2018 09:49:03 +0100

A single character (closing square bracket) should be put into a sequence.
Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/md/md-multipath.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
index e40065bdbfc8..0a7e99d62c69 100644
--- a/drivers/md/md-multipath.c
+++ b/drivers/md/md-multipath.c
@@ -157,7 +157,7 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
 		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
 	}
 	rcu_read_unlock();
-	seq_printf (seq, "]");
+	seq_putc(seq, ']');
 }
 
 static int multipath_congested(struct mddev *mddev, int bits)
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 221+ messages in thread

* Re: [PATCH v2] md-multipath: Use seq_putc() in multipath_status()
  2018-01-13  8:55     ` [PATCH v2] md-multipath: Use seq_putc() " SF Markus Elfring
@ 2018-02-17 21:01       ` Shaohua Li
  0 siblings, 0 replies; 221+ messages in thread
From: Shaohua Li @ 2018-02-17 21:01 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-raid, LKML, kernel-janitors

On Sat, Jan 13, 2018 at 09:55:08AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 13 Jan 2018 09:49:03 +0100
> 
> A single character (closing square bracket) should be put into a sequence.
> Thus use the corresponding function "seq_putc".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
applied, thanks
> ---
>  drivers/md/md-multipath.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c
> index e40065bdbfc8..0a7e99d62c69 100644
> --- a/drivers/md/md-multipath.c
> +++ b/drivers/md/md-multipath.c
> @@ -157,7 +157,7 @@ static void multipath_status(struct seq_file *seq, struct mddev *mddev)
>  		seq_printf (seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_");
>  	}
>  	rcu_read_unlock();
> -	seq_printf (seq, "]");
> +	seq_putc(seq, ']');
>  }
>  
>  static int multipath_congested(struct mddev *mddev, int bits)
> -- 
> 2.15.1
> 

^ permalink raw reply	[flat|nested] 221+ messages in thread

end of thread, other threads:[~2018-02-17 21:01 UTC | newest]

Thread overview: 221+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <566ABCD9.1060404@users.sourceforge.net>
2016-09-27 16:44 ` [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations SF Markus Elfring
2016-09-27 16:45   ` [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() SF Markus Elfring
2016-09-28 19:51     ` Jes Sorensen
2016-09-27 16:48   ` [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" " SF Markus Elfring
2016-09-27 16:49   ` [PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-09-27 16:50   ` [PATCH 04/16] md/bitmap: Improve another size determination " SF Markus Elfring
2016-09-27 16:51   ` [PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize() SF Markus Elfring
2016-09-27 16:53   ` [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() " SF Markus Elfring
2016-09-27 16:54   ` [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
2016-09-27 16:55   ` [PATCH 08/16] md/bitmap: Rename a jump label in location_store() SF Markus Elfring
2016-09-28 19:55     ` Jes Sorensen
2016-09-29  3:16       ` Guoqing Jiang
2016-09-27 16:56   ` [PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot() SF Markus Elfring
2016-09-27 16:57   ` [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create() SF Markus Elfring
2016-09-27 16:58   ` [PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk() SF Markus Elfring
2016-09-27 16:59   ` [PATCH 12/16] md/bitmap: One check less in read_page() at the end SF Markus Elfring
2016-09-28  7:33     ` Dan Carpenter
2016-09-27 17:00   ` [PATCH 13/16] md/bitmap: Adjust checks for null pointers in 11 functions SF Markus Elfring
2016-09-27 17:02   ` [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize() SF Markus Elfring
2016-09-27 17:03   ` [PATCH 15/16] md/bitmap: Add spaces around three comparison operators SF Markus Elfring
2016-09-27 17:04   ` [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page() SF Markus Elfring
2016-09-28 15:34 ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations SF Markus Elfring
2016-09-28 15:36   ` [PATCH 01/10] md/dm-crypt: Use kcalloc() in crypt_alloc_tfms() SF Markus Elfring
2016-09-28 15:38   ` [PATCH 00/10] md/dm-crypt: Fine-tuning for five function implementations Mike Snitzer
2016-09-28 15:38   ` [PATCH 02/10] md/dm-crypt: Reduce the scope for a variable in crypt_alloc_tfms() SF Markus Elfring
2016-09-28 15:40   ` [PATCH 03/10] md/dm-crypt: Rename a jump label in crypt_message() SF Markus Elfring
2016-09-29 12:55     ` [dm-devel] " Theodore Ts'o
2016-09-29 15:43       ` SF Markus Elfring
2016-09-30 10:06         ` Dan Carpenter
2016-09-30 11:32           ` md/dm-crypt: Rename a jump label in crypt_message() ? SF Markus Elfring
2016-09-30 11:39             ` Bjørn Mork
2016-09-30 11:53               ` SF Markus Elfring
2016-09-30 12:06                 ` Bjørn Mork
2016-09-30 12:54                   ` SF Markus Elfring
2016-09-30 12:02             ` Dan Carpenter
2016-09-30 12:19               ` SF Markus Elfring
2016-09-28 15:41   ` [PATCH 04/10] md/dm-crypt: Delete an unnecessary variable initialisation in crypt_message() SF Markus Elfring
2016-09-28 15:42   ` [PATCH 05/10] md/dm-crypt: Rename a jump label in crypt_set_key() SF Markus Elfring
2016-09-29 12:56     ` [dm-devel] " Theodore Ts'o
2016-09-28 15:43   ` [PATCH 06/10] md/dm-crypt: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-09-28 15:44   ` [PATCH 07/10] md/dm-crypt: Rename a jump label in crypt_iv_tcw_whitening() SF Markus Elfring
2016-09-28 15:45   ` [PATCH 08/10] md/dm-crypt: Return directly after a failed crypto_alloc_ahash() in crypt_iv_essiv_ctr() SF Markus Elfring
2016-09-28 15:46   ` [PATCH 09/10] md/dm-crypt: Two checks and one function call less in crypt_iv_essiv_ctr() after error detection SF Markus Elfring
2016-09-28 15:47   ` [PATCH 10/10] md/dm-crypt: Delete unnecessary variable initialisations in crypt_iv_essiv_ctr() SF Markus Elfring
2016-09-29  9:02 ` [PATCH 00/10] dm snapshot: Fine-tuning for several function implementations SF Markus Elfring
2016-09-29  9:07   ` [PATCH 01/10] dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
2016-09-29  9:54     ` Paul Bolle
2016-09-29 10:02       ` Joe Perches
2016-09-29 11:12         ` Paul Bolle
2016-09-29 11:45           ` Paul Bolle
2016-09-29 15:01             ` Joe Perches
2016-09-29 19:43               ` Paul Bolle
2016-09-29 20:24                 ` Joe Perches
2016-09-29 20:39                   ` Paul Bolle
2016-09-29 20:56                     ` Joe Perches
2016-09-29 21:14                       ` Paul Bolle
2016-09-29 21:21                         ` Joe Perches
2016-09-29 21:42                           ` Paul Bolle
2016-09-30  7:14                             ` dm snapshot: Use kmalloc_array() in init_origin_hash() ? SF Markus Elfring
2016-09-29 11:45       ` dm snapshot: Use kmalloc_array() in init_origin_hash() SF Markus Elfring
2016-09-29 12:59         ` Theodore Ts'o
2016-09-29  9:10   ` [PATCH 02/10] dm snapshot: Delete two error messages for a failed memory allocation SF Markus Elfring
2016-09-29  9:11   ` [PATCH 03/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_map() SF Markus Elfring
2016-09-29  9:12   ` [PATCH 04/10] dm snapshot: Rename a jump label in pending_complete() SF Markus Elfring
2016-09-29  9:13   ` [PATCH 05/10] dm snapshot: Delete unnecessary variable initialisations " SF Markus Elfring
2016-09-29  9:14   ` [PATCH 06/10] dm snapshot: Delete an unnecessary variable initialisation in snapshot_ctr() SF Markus Elfring
2016-09-29  9:15   ` [PATCH 07/10] dm snapshot: Delete an unnecessary variable initialisation in merge_callback() SF Markus Elfring
2016-09-29  9:16   ` [PATCH 08/10] dm snapshot: Delete an unnecessary variable initialisation in remove_single_exception_chunk() SF Markus Elfring
2016-09-29  9:17   ` [PATCH 09/10] dm snapshot: Combine substrings for seven error messages SF Markus Elfring
2016-09-29  9:18   ` [PATCH 10/10] dm snapshot: Delete five unwanted spaces behind "list_for_each_entry" SF Markus Elfring
2016-10-01 14:44 ` [PATCH 00/15] md-cluster: Fine-tuning for ten function implementations SF Markus Elfring
2016-10-01 14:46   ` [PATCH 01/15] md-cluster: Use kcalloc() in lock_all_bitmaps() SF Markus Elfring
2016-10-01 14:47   ` [PATCH 02/15] md-cluster: Improve another size determination in resync_info_update() SF Markus Elfring
2016-10-01 14:48   ` [PATCH 03/15] md-cluster: Improve another size determination in join() SF Markus Elfring
2016-10-01 14:49   ` [PATCH 04/15] md-cluster: Improve another size determination in __sendmsg() SF Markus Elfring
2016-10-01 14:50   ` [PATCH 05/15] md-cluster: Improve another size determination in recv_daemon() SF Markus Elfring
2016-10-01 14:51   ` [PATCH 06/15] md-cluster: Rename a jump label " SF Markus Elfring
2016-10-01 14:52   ` [PATCH 07/15] md-cluster: Improve another size determination in process_suspend_info() SF Markus Elfring
2016-10-01 14:53   ` [PATCH 08/15] md-cluster: Improve determination of sizes in read_resync_info() SF Markus Elfring
2016-10-01 14:54   ` [PATCH 09/15] md-cluster: Improve another size determination in lockres_init() SF Markus Elfring
2016-10-01 14:55   ` [PATCH 10/15] md-cluster: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-10-01 14:56   ` [PATCH 11/15] md-cluster: Delete four error messages for a failed memory allocation SF Markus Elfring
2016-10-01 14:57   ` [PATCH 12/15] md-cluster: Rename a jump label in area_resyncing() SF Markus Elfring
2016-10-01 14:58   ` [PATCH 13/15] md-cluster: Less function calls in join() after error detection SF Markus Elfring
2016-10-06 15:16     ` [PATCH v2 " SF Markus Elfring
2016-10-01 14:59   ` [PATCH 14/15] md-cluster: Less function calls in lockres_init() " SF Markus Elfring
2016-10-01 15:00   ` [PATCH 15/15] md-cluster: Delete unnecessary braces in unlock_all_bitmaps() SF Markus Elfring
2016-10-07  7:46     ` Dan Carpenter
2016-10-07  8:37       ` SF Markus Elfring
2016-10-07 13:21         ` walter harms
2016-10-02 11:54 ` [PATCH 00/13] md/multipath: Fine-tuning for several function implementations SF Markus Elfring
2016-10-02 11:56   ` [PATCH 1/13] md/multipath: Use kcalloc() in multipath_run() SF Markus Elfring
2016-10-02 11:57   ` [PATCH 2/13] md/multipath: Improve another size determination " SF Markus Elfring
2016-10-02 11:59   ` [PATCH 3/13] md/multipath: Delete four error messages for a failed memory allocation SF Markus Elfring
2016-10-02 12:00   ` [PATCH 4/13] md/multipath: Reduce indentation for four lines in multipath_run() SF Markus Elfring
2016-10-02 12:01   ` [PATCH 5/13] md/multipath: Less function calls in multipath_run() after error detection SF Markus Elfring
2016-10-02 12:02   ` [PATCH 6/13] md/multipath: Delete 13 unwanted spaces behind function names SF Markus Elfring
2016-10-02 12:03   ` [PATCH 7/13] md/multipath: Delete two unwanted spaces behind asterisks SF Markus Elfring
2016-10-02 12:04   ` [PATCH 8/13] md/multipath: Replace a seq_printf() call by seq_puts() in multipath_status() SF Markus Elfring
2018-01-13  8:55     ` [PATCH v2] md-multipath: Use seq_putc() " SF Markus Elfring
2018-02-17 21:01       ` Shaohua Li
2016-10-02 12:05   ` [PATCH 9/13] md/multipath: Adjust two function calls together with a variable assignment SF Markus Elfring
2016-10-02 12:06   ` [PATCH 10/13] md/multipath: Add some spaces for better code readability SF Markus Elfring
2016-10-02 12:08   ` [PATCH 11/13] md/multipath: Move a brace for a designated initialiser SF Markus Elfring
2016-10-02 12:09   ` [PATCH 12/13] md/multipath: Delete an unnecessary return statement in multipath_make_request() SF Markus Elfring
2016-10-02 12:10   ` [PATCH 13/13] md/multipath: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
2016-10-06  8:46 ` MD-RAID: Fine-tuning for several function implementations SF Markus Elfring
2016-10-06  8:49   ` Christoph Hellwig
2016-10-06 10:07     ` SF Markus Elfring
2016-10-06  8:51   ` [PATCH 01/54] md/raid0: Use kcalloc() in create_strip_zones() SF Markus Elfring
2016-10-06  8:53   ` [PATCH 02/54] md/raid0: Less function calls in create_strip_zones() after error detection SF Markus Elfring
2016-10-06  8:54   ` [PATCH 03/54] md/raid0: Move a variable assignment in create_strip_zones() SF Markus Elfring
2016-10-06  8:56   ` [PATCH 04/54] md/raid0: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
2016-10-06  8:57   ` [PATCH 05/54] md/raid0: Move another variable assignment in create_strip_zones() SF Markus Elfring
2016-10-06  8:59   ` [PATCH 06/54] md/raid0: Delete four unwanted spaces behind function names SF Markus Elfring
2016-10-06  9:00   ` [PATCH 07/54] md/raid0: Move two misplaced braces SF Markus Elfring
2016-10-06  9:01   ` [PATCH 08/54] md/raid0: Delete an unnecessary return statement in raid0_status() SF Markus Elfring
2016-10-06  9:03   ` [PATCH 09/54] md/raid0: Add some spaces for better code readability SF Markus Elfring
2016-10-06  9:05   ` [PATCH 10/54] md/raid1: Use kcalloc() in alloc_behind_pages() SF Markus Elfring
2016-10-06  9:06   ` [PATCH 11/54] md/raid1: Use kcalloc() in raid1_reshape() SF Markus Elfring
2016-10-06  9:07   ` [PATCH 12/54] md/raid1: Use kcalloc() in setup_conf() SF Markus Elfring
2016-10-06  9:09   ` [PATCH 13/54] md/raid1: Return directly after a failed kzalloc() " SF Markus Elfring
2016-10-06  9:10   ` [PATCH 14/54] md/raid1: Move assignments for the variable "err" " SF Markus Elfring
2016-10-06  9:11   ` [PATCH 15/54] md/raid1: Less function calls in setup_conf() after error detection SF Markus Elfring
2016-10-06  9:12   ` [PATCH 16/54] md/raid1: Delete an error message for a failed memory allocation SF Markus Elfring
2016-10-06  9:14   ` [PATCH 17/54] md/raid1: Move a brace for a designated initialiser SF Markus Elfring
2016-10-06  9:15   ` [PATCH 18/54] md/raid1: Adjust 12 checks for null pointers SF Markus Elfring
2016-10-06  9:16   ` [PATCH 19/54] md/raid1: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
2016-10-06  9:18   ` [PATCH 20/54] md/raid1: Add some spaces for better code readability SF Markus Elfring
2016-10-06  9:19   ` [PATCH 21/54] md/raid1: Delete three unwanted spaces behind asterisks SF Markus Elfring
2016-10-06  9:20   ` [PATCH 22/54] md/raid1: Delete three unwanted spaces before increment operators SF Markus Elfring
2016-10-06  9:21   ` [PATCH 23/54] md/raid1: Replace a seq_printf() call by seq_puts() in raid1_status() SF Markus Elfring
2016-10-06  9:22   ` [PATCH 24/54] md/raid1: Improve another size determination in setup_conf() SF Markus Elfring
2016-10-06  9:29     ` Richard Weinberger
2016-10-07  7:53       ` Dan Carpenter
2016-10-07  8:15         ` Richard Weinberger
2016-10-07  8:53         ` SF Markus Elfring
2016-10-07  9:06           ` Richard Weinberger
2016-10-07 10:50             ` SF Markus Elfring
2016-10-07 11:52               ` Austin S. Hemmelgarn
2016-10-07 15:27                 ` SF Markus Elfring
2016-10-07 15:35                   ` Jiri Kosina
2016-10-07 16:38                     ` SF Markus Elfring
2016-10-10 13:11                       ` Jes Sorensen
2016-10-10 13:06           ` Jes Sorensen
2016-10-10 13:20             ` SF Markus Elfring
2016-10-10 14:01               ` Jes Sorensen
2016-10-10 14:20                 ` SF Markus Elfring
2016-10-10 13:09         ` [PATCH 24/54] " Jes Sorensen
2016-10-12  8:28           ` Dan Carpenter
2016-10-12 12:18             ` Jes Sorensen
2016-10-10 11:12       ` Dan Carpenter
2016-10-10 12:28         ` SF Markus Elfring
2016-10-10 13:23           ` Adam Goryachev
2016-10-10 13:57         ` [PATCH 24/54] " Bjørn Mork
2016-10-11  6:20         ` Dan Carpenter
2016-10-06  9:23   ` [PATCH 25/54] md/raid5: Use kcalloc() in three functions SF Markus Elfring
2016-10-06  9:25   ` [PATCH 26/54] md/raid5: Improve another size determination in setup_conf() SF Markus Elfring
2016-10-06  9:26   ` [PATCH 27/54] md/raid5: Return directly after a failed kzalloc() " SF Markus Elfring
2016-10-06  9:28   ` [PATCH 28/54] md/raid5: Rename a jump label " SF Markus Elfring
2016-10-06  9:29   ` [PATCH 29/54] md/raid5: Return directly after a failed kcalloc() in alloc_thread_groups() SF Markus Elfring
2016-10-06  9:30   ` [PATCH 30/54] md/raid5: Delete two error messages for a failed memory allocation SF Markus Elfring
2016-10-07  5:51     ` Hannes Reinecke
2016-10-06  9:31   ` [PATCH 31/54] md/raid5: Adjust two function calls together with a variable assignment SF Markus Elfring
2016-10-06  9:32   ` [PATCH 32/54] md/raid5: Move a brace for three designated initialisers SF Markus Elfring
2016-10-06  9:33   ` [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
2016-10-06  9:34   ` [PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring
2016-10-06  9:35   ` [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring
2016-10-06  9:36   ` [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names SF Markus Elfring
2016-10-06  9:37   ` [PATCH 37/54] md/raid5: Replace a seq_printf() call by seq_puts() in raid5_status() SF Markus Elfring
2016-10-06 16:34     ` Joe Perches
2016-10-06 17:09       ` SF Markus Elfring
2016-10-06 17:36         ` Joe Perches
2016-10-06 17:49           ` SF Markus Elfring
2016-10-06 17:51             ` Joe Perches
2016-10-06 18:22               ` SF Markus Elfring
2016-10-06 18:33             ` [PATCH 37/54] " Bernd Petrovitsch
2016-10-16  8:20       ` [PATCH] MD-RAID: Use seq_putc() in three status functions SF Markus Elfring
2016-10-16 16:58         ` Hannes Reinecke
2016-10-16 17:10           ` MD-RAID: Use seq_putc() in three status functions? SF Markus Elfring
2016-10-16 17:18             ` SF Markus Elfring
2016-10-17  5:58             ` Hannes Reinecke
2016-10-17  7:39               ` SF Markus Elfring
2016-10-17  8:09                 ` Hannes Reinecke
2016-10-17  9:00                   ` SF Markus Elfring
2016-10-17  9:50                     ` Hannes Reinecke
2016-10-17 11:10                       ` SF Markus Elfring
2016-10-17 11:32                         ` Bernd Petrovitsch
2016-10-17 11:43                           ` SF Markus Elfring
2016-10-17 14:01                             ` Hannes Reinecke
2016-10-17 14:30                               ` SF Markus Elfring
2016-10-17 15:33                                 ` Hannes Reinecke
2016-10-17 16:08                                   ` SF Markus Elfring
2016-10-17 17:18                                     ` Hannes Reinecke
2016-10-18 18:20                                       ` SF Markus Elfring
2016-10-20 12:24                                         ` SF Markus Elfring
2016-10-28 20:04                                           ` SF Markus Elfring
2016-10-17 14:00                         ` Hannes Reinecke
2016-10-06  9:38   ` [PATCH 38/54] md/raid5: Move four asterisks SF Markus Elfring
2016-10-06  9:39   ` [PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring
2016-10-06  9:40   ` [PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring
2016-10-06  9:41   ` [PATCH 41/54] md/raid10: Improve another size determination in setup_conf() SF Markus Elfring
2016-10-06  9:42   ` [PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation SF Markus Elfring
2016-10-06  9:43   ` [PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf() SF Markus Elfring
2016-10-06  9:44   ` [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() " SF Markus Elfring
2016-10-06  9:45   ` [PATCH 45/54] md/raid10: Move assignments for the variable "err" " SF Markus Elfring
2016-10-06  9:46   ` [PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection SF Markus Elfring
2016-10-06  9:47   ` [PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape() SF Markus Elfring
2016-10-06  9:48   ` [PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring
2016-10-06  9:49   ` [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring
2016-10-06 16:33     ` Joe Perches
2016-10-06 17:20       ` SF Markus Elfring
2016-10-06 17:39         ` Joe Perches
2016-10-06 18:04           ` SF Markus Elfring
2016-10-06 18:18             ` Joe Perches
2016-10-06 18:32               ` SF Markus Elfring
2016-10-06  9:50   ` [PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring
2016-10-06  9:51   ` [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring
2016-10-06  9:52   ` [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status() SF Markus Elfring
2016-10-06  9:53   ` [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring
2016-10-06  9:54   ` [PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).