Skip to content

Commit 7d07402

Browse files
committed
Merge tag 'md-next-20230814-resend' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md into for-6.6/block
Pull MD fixes from Song: "1. raid6test build fixes, by WANG Xuerui 2. Various non-urgent fixes." * tag 'md-next-20230814-resend' of https://git.kernel.org/pub/scm/linux/kernel/git/song/md: md/raid5-cache: fix null-ptr-deref for r5l_flush_stripe_to_raid() raid6: test: only check for Altivec if building on powerpc hosts raid6: test: make sure all intermediate and artifact files are .gitignored raid6: test: cosmetic cleanups for the test Makefile raid6: guard the tables.c include of <linux/export.h> with __KERNEL__ raid6: remove the <linux/export.h> include from recov.c md: Hold mddev->reconfig_mutex when trying to get mddev->sync_thread md/raid10: fix a 'conf->barrier' leakage in raid10_takeover() md: raid1: fix potential OOB in raid1_remove_disk() md/raid5-cache: fix a deadlock in r5l_exit_log()
2 parents 66a6a5d + 0d0bd28 commit 7d07402

File tree

11 files changed

+57
-45
lines changed

11 files changed

+57
-45
lines changed

drivers/md/md-cluster.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,8 @@ static int join(struct mddev *mddev, int nodes)
952952
return 0;
953953
err:
954954
set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state);
955-
md_unregister_thread(&cinfo->recovery_thread);
956-
md_unregister_thread(&cinfo->recv_thread);
955+
md_unregister_thread(mddev, &cinfo->recovery_thread);
956+
md_unregister_thread(mddev, &cinfo->recv_thread);
957957
lockres_free(cinfo->message_lockres);
958958
lockres_free(cinfo->token_lockres);
959959
lockres_free(cinfo->ack_lockres);
@@ -1015,8 +1015,8 @@ static int leave(struct mddev *mddev)
10151015
resync_bitmap(mddev);
10161016

10171017
set_bit(MD_CLUSTER_HOLDING_MUTEX_FOR_RECVD, &cinfo->state);
1018-
md_unregister_thread(&cinfo->recovery_thread);
1019-
md_unregister_thread(&cinfo->recv_thread);
1018+
md_unregister_thread(mddev, &cinfo->recovery_thread);
1019+
md_unregister_thread(mddev, &cinfo->recv_thread);
10201020
lockres_free(cinfo->message_lockres);
10211021
lockres_free(cinfo->token_lockres);
10221022
lockres_free(cinfo->ack_lockres);

drivers/md/md.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6258,7 +6258,7 @@ static void mddev_detach(struct mddev *mddev)
62586258
mddev->pers->quiesce(mddev, 1);
62596259
mddev->pers->quiesce(mddev, 0);
62606260
}
6261-
md_unregister_thread(&mddev->thread);
6261+
md_unregister_thread(mddev, &mddev->thread);
62626262
if (mddev->queue)
62636263
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
62646264
}
@@ -7990,9 +7990,10 @@ struct md_thread *md_register_thread(void (*run) (struct md_thread *),
79907990
}
79917991
EXPORT_SYMBOL(md_register_thread);
79927992

7993-
void md_unregister_thread(struct md_thread __rcu **threadp)
7993+
void md_unregister_thread(struct mddev *mddev, struct md_thread __rcu **threadp)
79947994
{
7995-
struct md_thread *thread = rcu_dereference_protected(*threadp, true);
7995+
struct md_thread *thread = rcu_dereference_protected(*threadp,
7996+
lockdep_is_held(&mddev->reconfig_mutex));
79967997

79977998
if (!thread)
79987999
return;
@@ -9484,7 +9485,7 @@ void md_reap_sync_thread(struct mddev *mddev)
94849485
bool is_reshaped = false;
94859486

94869487
/* resync has finished, collect result */
9487-
md_unregister_thread(&mddev->sync_thread);
9488+
md_unregister_thread(mddev, &mddev->sync_thread);
94889489
atomic_inc(&mddev->sync_seq);
94899490

94909491
if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery) &&

drivers/md/md.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ extern struct md_thread *md_register_thread(
761761
void (*run)(struct md_thread *thread),
762762
struct mddev *mddev,
763763
const char *name);
764-
extern void md_unregister_thread(struct md_thread __rcu **threadp);
764+
extern void md_unregister_thread(struct mddev *mddev, struct md_thread __rcu **threadp);
765765
extern void md_wakeup_thread(struct md_thread __rcu *thread);
766766
extern void md_check_recovery(struct mddev *mddev);
767767
extern void md_reap_sync_thread(struct mddev *mddev);

drivers/md/raid1.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1837,6 +1837,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
18371837
struct r1conf *conf = mddev->private;
18381838
int err = 0;
18391839
int number = rdev->raid_disk;
1840+
1841+
if (unlikely(number >= conf->raid_disks))
1842+
goto abort;
1843+
18401844
struct raid1_info *p = conf->mirrors + number;
18411845

18421846
if (rdev != p->rdev)
@@ -3152,7 +3156,7 @@ static int raid1_run(struct mddev *mddev)
31523156
* RAID1 needs at least one disk in active
31533157
*/
31543158
if (conf->raid_disks - mddev->degraded < 1) {
3155-
md_unregister_thread(&conf->thread);
3159+
md_unregister_thread(mddev, &conf->thread);
31563160
ret = -EINVAL;
31573161
goto abort;
31583162
}
@@ -3179,7 +3183,7 @@ static int raid1_run(struct mddev *mddev)
31793183

31803184
ret = md_integrity_register(mddev);
31813185
if (ret) {
3182-
md_unregister_thread(&mddev->thread);
3186+
md_unregister_thread(mddev, &mddev->thread);
31833187
goto abort;
31843188
}
31853189
return 0;

drivers/md/raid10.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4320,7 +4320,7 @@ static int raid10_run(struct mddev *mddev)
43204320
return 0;
43214321

43224322
out_free_conf:
4323-
md_unregister_thread(&mddev->thread);
4323+
md_unregister_thread(mddev, &mddev->thread);
43244324
raid10_free_conf(conf);
43254325
mddev->private = NULL;
43264326
out:
@@ -4417,7 +4417,6 @@ static void *raid10_takeover_raid0(struct mddev *mddev, sector_t size, int devs)
44174417
rdev->new_raid_disk = rdev->raid_disk * 2;
44184418
rdev->sectors = size;
44194419
}
4420-
WRITE_ONCE(conf->barrier, 1);
44214420
}
44224421

44234422
return conf;

drivers/md/raid5-cache.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,14 +1260,13 @@ static void r5l_log_flush_endio(struct bio *bio)
12601260

12611261
if (bio->bi_status)
12621262
md_error(log->rdev->mddev, log->rdev);
1263+
bio_uninit(bio);
12631264

12641265
spin_lock_irqsave(&log->io_list_lock, flags);
12651266
list_for_each_entry(io, &log->flushing_ios, log_sibling)
12661267
r5l_io_run_stripes(io);
12671268
list_splice_tail_init(&log->flushing_ios, &log->finished_ios);
12681269
spin_unlock_irqrestore(&log->io_list_lock, flags);
1269-
1270-
bio_uninit(bio);
12711270
}
12721271

12731272
/*
@@ -3168,12 +3167,15 @@ void r5l_exit_log(struct r5conf *conf)
31683167
{
31693168
struct r5l_log *log = conf->log;
31703169

3171-
/* Ensure disable_writeback_work wakes up and exits */
3172-
wake_up(&conf->mddev->sb_wait);
3173-
flush_work(&log->disable_writeback_work);
3174-
md_unregister_thread(&log->reclaim_thread);
3170+
md_unregister_thread(conf->mddev, &log->reclaim_thread);
31753171

3172+
/*
3173+
* 'reconfig_mutex' is held by caller, set 'confg->log' to NULL to
3174+
* ensure disable_writeback_work wakes up and exits.
3175+
*/
31763176
conf->log = NULL;
3177+
wake_up(&conf->mddev->sb_wait);
3178+
flush_work(&log->disable_writeback_work);
31773179

31783180
mempool_exit(&log->meta_pool);
31793181
bioset_exit(&log->bs);

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8107,7 +8107,7 @@ static int raid5_run(struct mddev *mddev)
81078107

81088108
return 0;
81098109
abort:
8110-
md_unregister_thread(&mddev->thread);
8110+
md_unregister_thread(mddev, &mddev->thread);
81118111
print_raid5_conf(conf);
81128112
free_conf(conf);
81138113
mddev->private = NULL;

lib/raid6/mktables.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ int main(int argc, char *argv[])
5656
uint8_t v;
5757
uint8_t exptbl[256], invtbl[256];
5858

59+
printf("#ifdef __KERNEL__\n");
5960
printf("#include <linux/export.h>\n");
61+
printf("#endif\n");
6062
printf("#include <linux/raid/pq.h>\n");
6163

6264
/* Compute multiplication table */

lib/raid6/recov.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* the syndrome.)
1414
*/
1515

16-
#include <linux/export.h>
1716
#include <linux/raid/pq.h>
1817

1918
/* Recover two failed data blocks. */

lib/raid6/test/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/int.uc
2+
/neon.uc
3+
/raid6test

0 commit comments

Comments
 (0)