Skip to content

Commit 22c3f2f

Browse files
committed
Merge tag 'md-3.9-fixes' of git://neil.brown.name/md
Pull md fixes from NeilBrown: "A few bugfixes for md - recent regressions in raid5 - recent regressions in dmraid - a few instances of CONFIG_MULTICORE_RAID456 linger Several tagged for -stable" * tag 'md-3.9-fixes' of git://neil.brown.name/md: md: remove CONFIG_MULTICORE_RAID456 entirely md/raid5: ensure sync and DISCARD don't happen at the same time. MD: Prevent sysfs operations on uninitialized kobjects MD RAID5: Avoid accessing gendisk or queue structs when not available md/raid5: schedule_construction should abort if nothing to do.
2 parents c8c1f16 + 238f590 commit 22c3f2f

6 files changed

Lines changed: 86 additions & 47 deletions

File tree

‎arch/tile/configs/tilegx_defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ CONFIG_MD_RAID0=m
330330
CONFIG_MD_RAID1=m
331331
CONFIG_MD_RAID10=m
332332
CONFIG_MD_RAID456=m
333-
CONFIG_MULTICORE_RAID456=y
334333
CONFIG_MD_FAULTY=m
335334
CONFIG_BLK_DEV_DM=m
336335
CONFIG_DM_DEBUG=y

‎arch/tile/configs/tilepro_defconfig‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ CONFIG_MD_RAID0=m
324324
CONFIG_MD_RAID1=m
325325
CONFIG_MD_RAID10=m
326326
CONFIG_MD_RAID456=m
327-
CONFIG_MULTICORE_RAID456=y
328327
CONFIG_MD_FAULTY=m
329328
CONFIG_BLK_DEV_DM=m
330329
CONFIG_DM_DEBUG=y

‎drivers/md/md.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7663,10 +7663,8 @@ static int remove_and_add_spares(struct mddev *mddev)
76637663
removed++;
76647664
}
76657665
}
7666-
if (removed)
7667-
sysfs_notify(&mddev->kobj, NULL,
7668-
"degraded");
7669-
7666+
if (removed && mddev->kobj.sd)
7667+
sysfs_notify(&mddev->kobj, NULL, "degraded");
76707668

76717669
rdev_for_each(rdev, mddev) {
76727670
if (rdev->raid_disk >= 0 &&

‎drivers/md/md.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ static inline char * mdname (struct mddev * mddev)
506506
static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev)
507507
{
508508
char nm[20];
509-
if (!test_bit(Replacement, &rdev->flags)) {
509+
if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) {
510510
sprintf(nm, "rd%d", rdev->raid_disk);
511511
return sysfs_create_link(&mddev->kobj, &rdev->kobj, nm);
512512
} else
@@ -516,7 +516,7 @@ static inline int sysfs_link_rdev(struct mddev *mddev, struct md_rdev *rdev)
516516
static inline void sysfs_unlink_rdev(struct mddev *mddev, struct md_rdev *rdev)
517517
{
518518
char nm[20];
519-
if (!test_bit(Replacement, &rdev->flags)) {
519+
if (!test_bit(Replacement, &rdev->flags) && mddev->kobj.sd) {
520520
sprintf(nm, "rd%d", rdev->raid_disk);
521521
sysfs_remove_link(&mddev->kobj, nm);
522522
}

‎drivers/md/raid5.c‎

Lines changed: 81 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,11 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
671671
bi->bi_next = NULL;
672672
if (rrdev)
673673
set_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags);
674-
trace_block_bio_remap(bdev_get_queue(bi->bi_bdev),
675-
bi, disk_devt(conf->mddev->gendisk),
676-
sh->dev[i].sector);
674+
675+
if (conf->mddev->gendisk)
676+
trace_block_bio_remap(bdev_get_queue(bi->bi_bdev),
677+
bi, disk_devt(conf->mddev->gendisk),
678+
sh->dev[i].sector);
677679
generic_make_request(bi);
678680
}
679681
if (rrdev) {
@@ -701,9 +703,10 @@ static void ops_run_io(struct stripe_head *sh, struct stripe_head_state *s)
701703
rbi->bi_io_vec[0].bv_offset = 0;
702704
rbi->bi_size = STRIPE_SIZE;
703705
rbi->bi_next = NULL;
704-
trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev),
705-
rbi, disk_devt(conf->mddev->gendisk),
706-
sh->dev[i].sector);
706+
if (conf->mddev->gendisk)
707+
trace_block_bio_remap(bdev_get_queue(rbi->bi_bdev),
708+
rbi, disk_devt(conf->mddev->gendisk),
709+
sh->dev[i].sector);
707710
generic_make_request(rbi);
708711
}
709712
if (!rdev && !rrdev) {
@@ -2280,17 +2283,6 @@ schedule_reconstruction(struct stripe_head *sh, struct stripe_head_state *s,
22802283
int level = conf->level;
22812284

22822285
if (rcw) {
2283-
/* if we are not expanding this is a proper write request, and
2284-
* there will be bios with new data to be drained into the
2285-
* stripe cache
2286-
*/
2287-
if (!expand) {
2288-
sh->reconstruct_state = reconstruct_state_drain_run;
2289-
set_bit(STRIPE_OP_BIODRAIN, &s->ops_request);
2290-
} else
2291-
sh->reconstruct_state = reconstruct_state_run;
2292-
2293-
set_bit(STRIPE_OP_RECONSTRUCT, &s->ops_request);
22942286

22952287
for (i = disks; i--; ) {
22962288
struct r5dev *dev = &sh->dev[i];
@@ -2303,6 +2295,21 @@ schedule_reconstruction(struct stripe_head *sh, struct stripe_head_state *s,
23032295
s->locked++;
23042296
}
23052297
}
2298+
/* if we are not expanding this is a proper write request, and
2299+
* there will be bios with new data to be drained into the
2300+
* stripe cache
2301+
*/
2302+
if (!expand) {
2303+
if (!s->locked)
2304+
/* False alarm, nothing to do */
2305+
return;
2306+
sh->reconstruct_state = reconstruct_state_drain_run;
2307+
set_bit(STRIPE_OP_BIODRAIN, &s->ops_request);
2308+
} else
2309+
sh->reconstruct_state = reconstruct_state_run;
2310+
2311+
set_bit(STRIPE_OP_RECONSTRUCT, &s->ops_request);
2312+
23062313
if (s->locked + conf->max_degraded == disks)
23072314
if (!test_and_set_bit(STRIPE_FULL_WRITE, &sh->state))
23082315
atomic_inc(&conf->pending_full_writes);
@@ -2311,11 +2318,6 @@ schedule_reconstruction(struct stripe_head *sh, struct stripe_head_state *s,
23112318
BUG_ON(!(test_bit(R5_UPTODATE, &sh->dev[pd_idx].flags) ||
23122319
test_bit(R5_Wantcompute, &sh->dev[pd_idx].flags)));
23132320

2314-
sh->reconstruct_state = reconstruct_state_prexor_drain_run;
2315-
set_bit(STRIPE_OP_PREXOR, &s->ops_request);
2316-
set_bit(STRIPE_OP_BIODRAIN, &s->ops_request);
2317-
set_bit(STRIPE_OP_RECONSTRUCT, &s->ops_request);
2318-
23192321
for (i = disks; i--; ) {
23202322
struct r5dev *dev = &sh->dev[i];
23212323
if (i == pd_idx)
@@ -2330,6 +2332,13 @@ schedule_reconstruction(struct stripe_head *sh, struct stripe_head_state *s,
23302332
s->locked++;
23312333
}
23322334
}
2335+
if (!s->locked)
2336+
/* False alarm - nothing to do */
2337+
return;
2338+
sh->reconstruct_state = reconstruct_state_prexor_drain_run;
2339+
set_bit(STRIPE_OP_PREXOR, &s->ops_request);
2340+
set_bit(STRIPE_OP_BIODRAIN, &s->ops_request);
2341+
set_bit(STRIPE_OP_RECONSTRUCT, &s->ops_request);
23332342
}
23342343

23352344
/* keep the parity disk(s) locked while asynchronous operations
@@ -2564,6 +2573,8 @@ handle_failed_sync(struct r5conf *conf, struct stripe_head *sh,
25642573
int i;
25652574

25662575
clear_bit(STRIPE_SYNCING, &sh->state);
2576+
if (test_and_clear_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags))
2577+
wake_up(&conf->wait_for_overlap);
25672578
s->syncing = 0;
25682579
s->replacing = 0;
25692580
/* There is nothing more to do for sync/check/repair.
@@ -2737,6 +2748,7 @@ static void handle_stripe_clean_event(struct r5conf *conf,
27372748
{
27382749
int i;
27392750
struct r5dev *dev;
2751+
int discard_pending = 0;
27402752

27412753
for (i = disks; i--; )
27422754
if (sh->dev[i].written) {
@@ -2765,9 +2777,23 @@ static void handle_stripe_clean_event(struct r5conf *conf,
27652777
STRIPE_SECTORS,
27662778
!test_bit(STRIPE_DEGRADED, &sh->state),
27672779
0);
2768-
}
2769-
} else if (test_bit(R5_Discard, &sh->dev[i].flags))
2770-
clear_bit(R5_Discard, &sh->dev[i].flags);
2780+
} else if (test_bit(R5_Discard, &dev->flags))
2781+
discard_pending = 1;
2782+
}
2783+
if (!discard_pending &&
2784+
test_bit(R5_Discard, &sh->dev[sh->pd_idx].flags)) {
2785+
clear_bit(R5_Discard, &sh->dev[sh->pd_idx].flags);
2786+
clear_bit(R5_UPTODATE, &sh->dev[sh->pd_idx].flags);
2787+
if (sh->qd_idx >= 0) {
2788+
clear_bit(R5_Discard, &sh->dev[sh->qd_idx].flags);
2789+
clear_bit(R5_UPTODATE, &sh->dev[sh->qd_idx].flags);
2790+
}
2791+
/* now that discard is done we can proceed with any sync */
2792+
clear_bit(STRIPE_DISCARD, &sh->state);
2793+
if (test_bit(STRIPE_SYNC_REQUESTED, &sh->state))
2794+
set_bit(STRIPE_HANDLE, &sh->state);
2795+
2796+
}
27712797

27722798
if (test_and_clear_bit(STRIPE_FULL_WRITE, &sh->state))
27732799
if (atomic_dec_and_test(&conf->pending_full_writes))
@@ -2826,8 +2852,10 @@ static void handle_stripe_dirtying(struct r5conf *conf,
28262852
set_bit(STRIPE_HANDLE, &sh->state);
28272853
if (rmw < rcw && rmw > 0) {
28282854
/* prefer read-modify-write, but need to get some data */
2829-
blk_add_trace_msg(conf->mddev->queue, "raid5 rmw %llu %d",
2830-
(unsigned long long)sh->sector, rmw);
2855+
if (conf->mddev->queue)
2856+
blk_add_trace_msg(conf->mddev->queue,
2857+
"raid5 rmw %llu %d",
2858+
(unsigned long long)sh->sector, rmw);
28312859
for (i = disks; i--; ) {
28322860
struct r5dev *dev = &sh->dev[i];
28332861
if ((dev->towrite || i == sh->pd_idx) &&
@@ -2877,7 +2905,7 @@ static void handle_stripe_dirtying(struct r5conf *conf,
28772905
}
28782906
}
28792907
}
2880-
if (rcw)
2908+
if (rcw && conf->mddev->queue)
28812909
blk_add_trace_msg(conf->mddev->queue, "raid5 rcw %llu %d %d %d",
28822910
(unsigned long long)sh->sector,
28832911
rcw, qread, test_bit(STRIPE_DELAYED, &sh->state));
@@ -3417,9 +3445,15 @@ static void handle_stripe(struct stripe_head *sh)
34173445
return;
34183446
}
34193447

3420-
if (test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
3421-
set_bit(STRIPE_SYNCING, &sh->state);
3422-
clear_bit(STRIPE_INSYNC, &sh->state);
3448+
if (test_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
3449+
spin_lock(&sh->stripe_lock);
3450+
/* Cannot process 'sync' concurrently with 'discard' */
3451+
if (!test_bit(STRIPE_DISCARD, &sh->state) &&
3452+
test_and_clear_bit(STRIPE_SYNC_REQUESTED, &sh->state)) {
3453+
set_bit(STRIPE_SYNCING, &sh->state);
3454+
clear_bit(STRIPE_INSYNC, &sh->state);
3455+
}
3456+
spin_unlock(&sh->stripe_lock);
34233457
}
34243458
clear_bit(STRIPE_DELAYED, &sh->state);
34253459

@@ -3579,6 +3613,8 @@ static void handle_stripe(struct stripe_head *sh)
35793613
test_bit(STRIPE_INSYNC, &sh->state)) {
35803614
md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
35813615
clear_bit(STRIPE_SYNCING, &sh->state);
3616+
if (test_and_clear_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags))
3617+
wake_up(&conf->wait_for_overlap);
35823618
}
35833619

35843620
/* If the failed drives are just a ReadError, then we might need
@@ -3982,9 +4018,10 @@ static int chunk_aligned_read(struct mddev *mddev, struct bio * raid_bio)
39824018
atomic_inc(&conf->active_aligned_reads);
39834019
spin_unlock_irq(&conf->device_lock);
39844020

3985-
trace_block_bio_remap(bdev_get_queue(align_bi->bi_bdev),
3986-
align_bi, disk_devt(mddev->gendisk),
3987-
raid_bio->bi_sector);
4021+
if (mddev->gendisk)
4022+
trace_block_bio_remap(bdev_get_queue(align_bi->bi_bdev),
4023+
align_bi, disk_devt(mddev->gendisk),
4024+
raid_bio->bi_sector);
39884025
generic_make_request(align_bi);
39894026
return 1;
39904027
} else {
@@ -4078,7 +4115,8 @@ static void raid5_unplug(struct blk_plug_cb *blk_cb, bool from_schedule)
40784115
}
40794116
spin_unlock_irq(&conf->device_lock);
40804117
}
4081-
trace_block_unplug(mddev->queue, cnt, !from_schedule);
4118+
if (mddev->queue)
4119+
trace_block_unplug(mddev->queue, cnt, !from_schedule);
40824120
kfree(cb);
40834121
}
40844122

@@ -4141,6 +4179,13 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
41414179
sh = get_active_stripe(conf, logical_sector, 0, 0, 0);
41424180
prepare_to_wait(&conf->wait_for_overlap, &w,
41434181
TASK_UNINTERRUPTIBLE);
4182+
set_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags);
4183+
if (test_bit(STRIPE_SYNCING, &sh->state)) {
4184+
release_stripe(sh);
4185+
schedule();
4186+
goto again;
4187+
}
4188+
clear_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags);
41444189
spin_lock_irq(&sh->stripe_lock);
41454190
for (d = 0; d < conf->raid_disks; d++) {
41464191
if (d == sh->pd_idx || d == sh->qd_idx)
@@ -4153,6 +4198,7 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
41534198
goto again;
41544199
}
41554200
}
4201+
set_bit(STRIPE_DISCARD, &sh->state);
41564202
finish_wait(&conf->wait_for_overlap, &w);
41574203
for (d = 0; d < conf->raid_disks; d++) {
41584204
if (d == sh->pd_idx || d == sh->qd_idx)

‎drivers/md/raid5.h‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ struct stripe_head {
221221
struct stripe_operations {
222222
int target, target2;
223223
enum sum_check_flags zero_sum_result;
224-
#ifdef CONFIG_MULTICORE_RAID456
225-
unsigned long request;
226-
wait_queue_head_t wait_for_ops;
227-
#endif
228224
} ops;
229225
struct r5dev {
230226
/* rreq and rvec are used for the replacement device when
@@ -323,6 +319,7 @@ enum {
323319
STRIPE_COMPUTE_RUN,
324320
STRIPE_OPS_REQ_PENDING,
325321
STRIPE_ON_UNPLUG_LIST,
322+
STRIPE_DISCARD,
326323
};
327324

328325
/*

0 commit comments

Comments
 (0)