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


Groups > linux.kernel > #1496498 > unrolled thread

MD-RAID: Fine-tuning for several function implementations

Started bySF Markus Elfring <elfring@users.sourceforge.net>
First post2016-10-06 11:40 +0200
Last post2016-10-06 12:00 +0200
Articles 7 on this page of 27 — 3 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

  MD-RAID: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
    [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher  level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
    [PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
    [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
    [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function  names SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
    [PATCH 43/54] md/raid10: Return directly after detection of  unsupported settings in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 42/54] md/raid10: Delete an error message for a failed memory  allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 46/54] md/raid10: Less function calls in setup_conf() after  error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 47/54] md/raid10: Improve another size determination in  raid10_start_reshape() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 41/54] md/raid10: Improve another size determination in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 45/54] md/raid10: Move assignments for the variable "err" in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in  setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
      Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces Joe Perches <coupons@perches.com> - 2016-10-06 18:40 +0200
        Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 19:30 +0200
          Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of  higher level interfaces Joe Perches <joe@perches.com> - 2016-10-06 19:40 +0200
            Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:10 +0200
              Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces Joe Perches <joe@perches.com> - 2016-10-06 20:20 +0200
                Re: md/raid10: Replace printk() calls by the usage of higher level  interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:40 +0200
    [PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
    [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
    [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in  raid10_status() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
    [PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
    [PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
    [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1496802 — Re: md/raid10: Replace printk() calls by the usage of higher level interfaces

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 20:40 +0200
SubjectRe: md/raid10: Replace printk() calls by the usage of higher level interfaces
Message-ID<splKi-4z5-13@gated-at.bofh.it>
In reply to#1496792
>> 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

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


#1496538 — [PATCH 40/54] md/raid10: Use kcalloc() in two functions

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 11:50 +0200
Subject[PATCH 40/54] md/raid10: Use kcalloc() in two functions
Message-ID<spdto-6Li-33@gated-at.bofh.it>
In reply to#1496498
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

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


#1496540 — [PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 12:00 +0200
Subject[PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks
Message-ID<spdD4-6OZ-5@gated-at.bofh.it>
In reply to#1496498
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

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


#1496541 — [PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status()

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 12:00 +0200
Subject[PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status()
Message-ID<spdD4-6OZ-7@gated-at.bofh.it>
In reply to#1496498
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

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


#1496542 — [PATCH 50/54] md/raid10: Delete indentation for one jump label

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 12:00 +0200
Subject[PATCH 50/54] md/raid10: Delete indentation for one jump label
Message-ID<spdD4-6OZ-9@gated-at.bofh.it>
In reply to#1496498
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

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


#1496543 — [PATCH 54/54] md/raid10: Add some spaces for better code readability

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 12:00 +0200
Subject[PATCH 54/54] md/raid10: Add some spaces for better code readability
Message-ID<spdD4-6OZ-15@gated-at.bofh.it>
In reply to#1496498
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

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


#1496551 — [PATCH 51/54] md/raid10: Adjust 22 checks for null pointers

FromSF Markus Elfring <elfring@users.sourceforge.net>
Date2016-10-06 12:00 +0200
Subject[PATCH 51/54] md/raid10: Adjust 22 checks for null pointers
Message-ID<spdD5-6OZ-37@gated-at.bofh.it>
In reply to#1496498
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

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web