* 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
* 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 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
* 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
* 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/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/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: 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-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: 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 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-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: [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
* 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-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: [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
* [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
* [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
* 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
* [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
* 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 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 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/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: [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
* [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: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
* 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
* [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
* 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 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 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: 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/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
* [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