Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1496498 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2016-10-06 11:40 +0200 |
| Last post | 2016-10-06 12:00 +0200 |
| Articles | 20 on this page of 27 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
MD-RAID: Fine-tuning for several function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
[PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
[PATCH 34/54] md/raid5: Delete indentation for two jump labels SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
[PATCH 35/54] md/raid5: Adjust 13 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
[PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:40 +0200
[PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 48/54] md/raid10: Move a brace for a designated initialiser SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 41/54] md/raid10: Improve another size determination in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 45/54] md/raid10: Move assignments for the variable "err" in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 39/54] md/raid5: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in setup_conf() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces Joe Perches <coupons@perches.com> - 2016-10-06 18:40 +0200
Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 19:30 +0200
Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces Joe Perches <joe@perches.com> - 2016-10-06 19:40 +0200
Re: md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:10 +0200
Re: md/raid10: Replace printk() calls by the usage of higher level interfaces Joe Perches <joe@perches.com> - 2016-10-06 20:20 +0200
Re: md/raid10: Replace printk() calls by the usage of higher level interfaces SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 20:40 +0200
[PATCH 40/54] md/raid10: Use kcalloc() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 11:50 +0200
[PATCH 53/54] md/raid10: Delete two unwanted spaces behind asterisks SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
[PATCH 52/54] md/raid10: Replace a seq_printf() call by seq_puts() in raid10_status() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
[PATCH 50/54] md/raid10: Delete indentation for one jump label SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
[PATCH 54/54] md/raid10: Add some spaces for better code readability SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
[PATCH 51/54] md/raid10: Adjust 22 checks for null pointers SF Markus Elfring <elfring@users.sourceforge.net> - 2016-10-06 12:00 +0200
Page 1 of 2 [1] 2 Next page →
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:40 +0200 |
| Subject | MD-RAID: Fine-tuning for several function implementations |
| Message-ID | <spcH0-6dt-53@gated-at.bofh.it> |
From: Markus Elfring <elfring@users.sourceforge.net> Date: Wed, 6 Oct 2016 10:10:01 +0200 Several update suggestions were taken into account from static source code analysis. Markus Elfring (54): raid0: Use kcalloc() in create_strip_zones() raid0: Less function calls in create_strip_zones() after error detection raid0: Move a variable assignment in create_strip_zones() raid0: Replace printk() calls by the usage of higher level interfaces raid0: Move another variable assignment in create_strip_zones() raid0: Delete four unwanted spaces behind function names raid0: Move two misplaced braces raid0: Delete an unnecessary return statement in raid0_status() raid0: Add some spaces for better code readability raid1: Use kcalloc() in alloc_behind_pages() raid1: Use kcalloc() in raid1_reshape() raid1: Use kcalloc() in setup_conf() raid1: Return directly after a failed kzalloc() in setup_conf() raid1: Move assignments for the variable "err" in setup_conf() raid1: Less function calls in setup_conf() after error detection raid1: Delete an error message for a failed memory allocation raid1: Move a brace for a designated initialiser raid1: Adjust 12 checks for null pointers raid1: Replace printk() calls by the usage of higher level interfaces raid1: Add some spaces for better code readability raid1: Delete three unwanted spaces behind asterisks raid1: Delete three unwanted spaces before increment operators raid1: Replace a seq_printf() call by seq_puts() in raid1_status() raid1: Improve another size determination in setup_conf() raid5: Use kcalloc() in three functions raid5: Improve another size determination in setup_conf() raid5: Return directly after a failed kzalloc() in setup_conf() raid5: Rename a jump label in setup_conf() raid5: Return directly after a failed kcalloc() in alloc_thread_groups() raid5: Delete two error messages for a failed memory allocation raid5: Adjust two function calls together with a variable assignment raid5: Move a brace for three designated initialisers raid5: Replace printk() calls by the usage of higher level interfaces raid5: Delete indentation for two jump labels raid5: Adjust 13 checks for null pointers raid5: Delete four unwanted spaces behind function names raid5: Replace a seq_printf() call by seq_puts() in raid5_status() raid5: Move four asterisks raid5: Add some spaces for better code readability raid10: Use kcalloc() in two functions raid10: Improve another size determination in setup_conf() raid10: Delete an error message for a failed memory allocation raid10: Return directly after detection of unsupported settings in setup_conf() raid10: Return directly after a failed kzalloc() in setup_conf() raid10: Move assignments for the variable "err" in setup_conf() raid10: Less function calls in setup_conf() after error detection raid10: Improve another size determination in raid10_start_reshape() raid10: Move a brace for a designated initialiser raid10: Replace printk() calls by the usage of higher level interfaces raid10: Delete indentation for one jump label raid10: Adjust 22 checks for null pointers raid10: Replace a seq_printf() call by seq_puts() in raid10_status() raid10: Delete two unwanted spaces behind asterisks raid10: Add some spaces for better code readability drivers/md/raid0.c | 170 ++++++++--------- drivers/md/raid1.c | 285 ++++++++++++++-------------- drivers/md/raid10.c | 366 ++++++++++++++++++------------------ drivers/md/raid5.c | 523 ++++++++++++++++++++++++---------------------------- 4 files changed, 649 insertions(+), 695 deletions(-) -- 2.10.1
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:40 +0200 |
| Subject | [PATCH 33/54] md/raid5: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <spdjI-6HB-39@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:40 +0200 |
| Subject | [PATCH 34/54] md/raid5: Delete indentation for two jump labels |
| Message-ID | <spdjJ-6HB-59@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:40 +0200 |
| Subject | [PATCH 35/54] md/raid5: Adjust 13 checks for null pointers |
| Message-ID | <spdjJ-6HB-65@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:40 +0200 |
| Subject | [PATCH 36/54] md/raid5: Delete four unwanted spaces behind function names |
| Message-ID | <spdjJ-6HB-67@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 43/54] md/raid10: Return directly after detection of unsupported settings in setup_conf() |
| Message-ID | <spdto-6Li-7@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 42/54] md/raid10: Delete an error message for a failed memory allocation |
| Message-ID | <spdto-6Li-17@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 46/54] md/raid10: Less function calls in setup_conf() after error detection |
| Message-ID | <spdto-6Li-15@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 47/54] md/raid10: Improve another size determination in raid10_start_reshape() |
| Message-ID | <spdto-6Li-25@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 48/54] md/raid10: Move a brace for a designated initialiser |
| Message-ID | <spdto-6Li-27@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 41/54] md/raid10: Improve another size determination in setup_conf() |
| Message-ID | <spdto-6Li-29@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 45/54] md/raid10: Move assignments for the variable "err" in setup_conf() |
| Message-ID | <spdto-6Li-19@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 39/54] md/raid5: Add some spaces for better code readability |
| Message-ID | <spdto-6Li-23@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 44/54] md/raid10: Return directly after a failed kzalloc() in setup_conf() |
| Message-ID | <spdto-6Li-31@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 11:50 +0200 |
| Subject | [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <spdto-6Li-39@gated-at.bofh.it> |
| In reply to | #1496498 |
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
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <coupons@perches.com> |
|---|---|
| Date | 2016-10-06 18:40 +0200 |
| Subject | Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <spjSa-2Un-37@gated-at.bofh.it> |
| In reply to | #1496537 |
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.
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 19:30 +0200 |
| Subject | Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <spkEy-3Bo-23@gated-at.bofh.it> |
| In reply to | #1496757 |
>> 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
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-06 19:40 +0200 |
| Subject | Re: [PATCH 49/54] md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <spkOd-3Hh-27@gated-at.bofh.it> |
| In reply to | #1496777 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2016-10-06 20:10 +0200 |
| Subject | Re: md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <splhf-4du-5@gated-at.bofh.it> |
| In reply to | #1496783 |
>> 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
[toc] | [prev] | [next] | [standalone]
| From | Joe Perches <joe@perches.com> |
|---|---|
| Date | 2016-10-06 20:20 +0200 |
| Subject | Re: md/raid10: Replace printk() calls by the usage of higher level interfaces |
| Message-ID | <splqV-4mC-3@gated-at.bofh.it> |
| In reply to | #1496791 |
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.
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web