Skip to content

Commit da8c828

Browse files
committed
Merge branch 'md-next' of git://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-5.4/block
Pull MD fixes from Song. * 'md-next' of git://git.kernel.org/pub/scm/linux/kernel/git/song/md: raid5 improve too many read errors msg by adding limits md: don't report active array_state until after revalidate_disk() completes. md: only call set_in_sync() when it is expected to succeed.
2 parents cecf5d8 + 0009fad commit da8c828

3 files changed

Lines changed: 22 additions & 9 deletions

File tree

‎drivers/md/md.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4179,7 +4179,7 @@ array_state_show(struct mddev *mddev, char *page)
41794179
{
41804180
enum array_state st = inactive;
41814181

4182-
if (mddev->pers)
4182+
if (mddev->pers && !test_bit(MD_NOT_READY, &mddev->flags))
41834183
switch(mddev->ro) {
41844184
case 1:
41854185
st = readonly;
@@ -5776,9 +5776,6 @@ int md_run(struct mddev *mddev)
57765776
md_update_sb(mddev, 0);
57775777

57785778
md_new_event(mddev);
5779-
sysfs_notify_dirent_safe(mddev->sysfs_state);
5780-
sysfs_notify_dirent_safe(mddev->sysfs_action);
5781-
sysfs_notify(&mddev->kobj, NULL, "degraded");
57825779
return 0;
57835780

57845781
bitmap_abort:
@@ -5799,6 +5796,7 @@ static int do_md_run(struct mddev *mddev)
57995796
{
58005797
int err;
58015798

5799+
set_bit(MD_NOT_READY, &mddev->flags);
58025800
err = md_run(mddev);
58035801
if (err)
58045802
goto out;
@@ -5819,9 +5817,14 @@ static int do_md_run(struct mddev *mddev)
58195817

58205818
set_capacity(mddev->gendisk, mddev->array_sectors);
58215819
revalidate_disk(mddev->gendisk);
5820+
clear_bit(MD_NOT_READY, &mddev->flags);
58225821
mddev->changed = 1;
58235822
kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE);
5823+
sysfs_notify_dirent_safe(mddev->sysfs_state);
5824+
sysfs_notify_dirent_safe(mddev->sysfs_action);
5825+
sysfs_notify(&mddev->kobj, NULL, "degraded");
58245826
out:
5827+
clear_bit(MD_NOT_READY, &mddev->flags);
58255828
return err;
58265829
}
58275830

@@ -8932,6 +8935,7 @@ void md_check_recovery(struct mddev *mddev)
89328935

89338936
if (mddev_trylock(mddev)) {
89348937
int spares = 0;
8938+
bool try_set_sync = mddev->safemode != 0;
89358939

89368940
if (!mddev->external && mddev->safemode == 1)
89378941
mddev->safemode = 0;
@@ -8977,7 +8981,7 @@ void md_check_recovery(struct mddev *mddev)
89778981
}
89788982
}
89798983

8980-
if (!mddev->external && !mddev->in_sync) {
8984+
if (try_set_sync && !mddev->external && !mddev->in_sync) {
89818985
spin_lock(&mddev->lock);
89828986
set_in_sync(mddev);
89838987
spin_unlock(&mddev->lock);

‎drivers/md/md.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ enum mddev_flags {
248248
MD_UPDATING_SB, /* md_check_recovery is updating the metadata
249249
* without explicitly holding reconfig_mutex.
250250
*/
251+
MD_NOT_READY, /* do_md_run() is active, so 'array_state'
252+
* must not report that array is ready yet
253+
*/
251254
};
252255

253256
enum mddev_sb_flags {

‎drivers/md/raid5.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,10 +2549,16 @@ static void raid5_end_read_request(struct bio * bi)
25492549
(unsigned long long)s,
25502550
bdn);
25512551
} else if (atomic_read(&rdev->read_errors)
2552-
> conf->max_nr_stripes)
2553-
pr_warn("md/raid:%s: Too many read errors, failing device %s.\n",
2554-
mdname(conf->mddev), bdn);
2555-
else
2552+
> conf->max_nr_stripes) {
2553+
if (!test_bit(Faulty, &rdev->flags)) {
2554+
pr_warn("md/raid:%s: %d read_errors > %d stripes\n",
2555+
mdname(conf->mddev),
2556+
atomic_read(&rdev->read_errors),
2557+
conf->max_nr_stripes);
2558+
pr_warn("md/raid:%s: Too many read errors, failing device %s.\n",
2559+
mdname(conf->mddev), bdn);
2560+
}
2561+
} else
25562562
retry = 1;
25572563
if (set_bad && test_bit(In_sync, &rdev->flags)
25582564
&& !test_bit(R5_ReadNoMerge, &sh->dev[i].flags))

0 commit comments

Comments
 (0)