Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1492025 > unrolled thread

[PATCH 00/16] md/bitmap: Fine-tuning for several function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-09-27 18:50 +0200
Last post2016-09-27 19:10 +0200
Articles 20 on this page of 21 — 4 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 00/16] md/bitmap: Fine-tuning for several function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 18:50 +0200
    [PATCH 03/16] md/bitmap: Delete an unnecessary variable  initialisation in bitmap_storage_alloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 18:50 +0200
    [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset"  in bitmap_storage_alloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 18:50 +0200
    [PATCH 01/16] md/bitmap: Use kmalloc_array() in  bitmap_storage_alloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 18:50 +0200
      Re: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc() Jes Sorensen <Jes.Sorensen@redhat.com> - 2016-09-28 22:00 +0200
    [PATCH 09/16] md/bitmap: Rename a jump label in  bitmap_copy_from_slot() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 08/16] md/bitmap: Rename a jump label in location_store() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
      Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store() Jes Sorensen <Jes.Sorensen@redhat.com> - 2016-09-28 22:00 +0200
        Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store() Guoqing Jiang <gqjiang@suse.com> - 2016-09-29 05:20 +0200
    [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() in  bitmap_resize() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 11/16] md/bitmap: Rename a jump label in  bitmap_init_from_disk() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 04/16] md/bitmap: Improve another size determination in  bitmap_storage_alloc() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 05/16] md/bitmap: Return directly after a failed  bitmap_storage_alloc() in bitmap_resize() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() in  bitmap_resize() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:00 +0200
    [PATCH 15/16] md/bitmap: Add spaces around three comparison operators SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:10 +0200
    [PATCH 12/16] md/bitmap: One check less in read_page() at the end SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:10 +0200
      Re: [PATCH 12/16] md/bitmap: One check less in read_page() at the end Dan Carpenter <dan.carpenter@oracle.com> - 2016-09-28 09:40 +0200
    [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:10 +0200
    [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:10 +0200
    [PATCH 13/16] md/bitmap: Adjust checks for null pointers in 11  functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-09-27 19:10 +0200

Page 1 of 2  [1] 2  Next page →


#1492025 — [PATCH 00/16] md/bitmap: Fine-tuning for several function implementations

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 18:50 +0200
Subject[PATCH 00/16] md/bitmap: Fine-tuning for several function implementations
Message-ID<sm3JT-3si-3@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1492026 — [PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation in bitmap_storage_alloc()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 18:50 +0200
Subject[PATCH 03/16] md/bitmap: Delete an unnecessary variable initialisation in bitmap_storage_alloc()
Message-ID<sm3JT-3si-11@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492029 — [PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" in bitmap_storage_alloc()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 18:50 +0200
Subject[PATCH 02/16] md/bitmap: Move an assignment for the variable "offset" in bitmap_storage_alloc()
Message-ID<sm3JU-3si-27@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492030 — [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 18:50 +0200
Subject[PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()
Message-ID<sm3JU-3si-41@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492939 — Re: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()

FromJes Sorensen <Jes.Sorensen@redhat.com>
Date2016-09-28 22:00 +0200
SubjectRe: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()
Message-ID<smtbj-2Ad-7@gated-at.bofh.it>
In reply to#1492030
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

[toc] | [prev] | [next] | [standalone]


#1492033 — [PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 09/16] md/bitmap: Rename a jump label in bitmap_copy_from_slot()
Message-ID<sm3Tz-3vI-1@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492034 — [PATCH 08/16] md/bitmap: Rename a jump label in location_store()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 08/16] md/bitmap: Rename a jump label in location_store()
Message-ID<sm3Tz-3vI-11@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492938 — Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()

FromJes Sorensen <Jes.Sorensen@redhat.com>
Date2016-09-28 22:00 +0200
SubjectRe: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()
Message-ID<smtbj-2Ad-5@gated-at.bofh.it>
In reply to#1492034
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;

[toc] | [prev] | [next] | [standalone]


#1493122 — Re: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()

FromGuoqing Jiang <gqjiang@suse.com>
Date2016-09-29 05:20 +0200
SubjectRe: [PATCH 08/16] md/bitmap: Rename a jump label in location_store()
Message-ID<smA37-74h-5@gated-at.bofh.it>
In reply to#1492938

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

[toc] | [prev] | [next] | [standalone]


#1492035 — [PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() in bitmap_resize()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 06/16] md/bitmap: Return directly after a failed kzalloc() in bitmap_resize()
Message-ID<sm3Tz-3vI-9@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492036 — [PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 11/16] md/bitmap: Rename a jump label in bitmap_init_from_disk()
Message-ID<sm3TA-3vI-13@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492038 — [PATCH 04/16] md/bitmap: Improve another size determination in bitmap_storage_alloc()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 04/16] md/bitmap: Improve another size determination in bitmap_storage_alloc()
Message-ID<sm3TA-3vI-21@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492040 — [PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 05/16] md/bitmap: Return directly after a failed bitmap_storage_alloc() in bitmap_resize()
Message-ID<sm3TA-3vI-25@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492041 — [PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() in bitmap_resize()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 07/16] md/bitmap: Replace a kzalloc() call by kcalloc() in bitmap_resize()
Message-ID<sm3TA-3vI-29@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492042 — [PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:00 +0200
Subject[PATCH 10/16] md/bitmap: Rename a jump label in bitmap_create()
Message-ID<sm3TA-3vI-31@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492046 — [PATCH 15/16] md/bitmap: Add spaces around three comparison operators

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:10 +0200
Subject[PATCH 15/16] md/bitmap: Add spaces around three comparison operators
Message-ID<sm43f-3O7-19@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492047 — [PATCH 12/16] md/bitmap: One check less in read_page() at the end

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:10 +0200
Subject[PATCH 12/16] md/bitmap: One check less in read_page() at the end
Message-ID<sm43g-3O7-29@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492298 — Re: [PATCH 12/16] md/bitmap: One check less in read_page() at the end

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-09-28 09:40 +0200
SubjectRe: [PATCH 12/16] md/bitmap: One check less in read_page() at the end
Message-ID<smhDb-3Ox-7@gated-at.bofh.it>
In reply to#1492047
This makes the code ugly.

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1492048 — [PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:10 +0200
Subject[PATCH 16/16] md/bitmap: Delete an unwanted space in read_sb_page()
Message-ID<sm43g-3O7-43@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


#1492049 — [PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-09-27 19:10 +0200
Subject[PATCH 14/16] md/bitmap: Delete unnecessary braces in bitmap_resize()
Message-ID<sm43g-3O7-37@gated-at.bofh.it>
In reply to#1492025
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

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.kernel


csiph-web