History

Merge tag 'for-5.17/drivers-2022-01-11' of git://git.kernel.dk/linux-block

Pull block driver updates from Jens Axboe: - mtip32xx pci cleanups (Bjorn) - mtip32xx conversion to generic power management (Vaibhav) - rsxx pci powermanagement cleanups (Bjorn) - Remove the rsxx driver. This hardware never saw much adoption, and it's been end of lifed for a while. (Christoph) - MD pull request from Song: - REQ_NOWAIT support (Vishal Verma) - raid6 benchmark optimization (Dirk Müller) - Fix for acct bioset (Xiao Ni) - Clean up max_queued_requests (Mariusz Tkaczyk) - PREEMPT_RT optimization (Davidlohr Bueso) - Use default_groups in kobj_type (Greg Kroah-Hartman) - Use attribute groups in pktcdvd and rnbd (Greg) - NVMe pull request from Christoph: - increment request genctr on completion (Keith Busch, Geliang Tang) - add a 'iopolicy' module parameter (Hannes Reinecke) - print out valid arguments when reading from /dev/nvme-fabrics (Hannes Reinecke) - Use struct_group() in drbd (Kees) - null_blk fixes (Ming) - Get rid of congestion logic in pktcdvd (Neil) - Floppy ejection hang fix (Tasos) - Floppy max user request size fix (Xiongwei) - Loop locking fix (Tetsuo) * tag 'for-5.17/drivers-2022-01-11' of git://git.kernel.dk/linux-block: (32 commits) md: use default_groups in kobj_type md: Move alloc/free acct bioset in to personality lib/raid6: Use strict priority ranking for pq gen() benchmarking lib/raid6: skip benchmark of non-chosen xor_syndrome functions md: fix spelling of "its" md: raid456 add nowait support md: raid10 add nowait support md: raid1 add nowait support md: add support for REQ_NOWAIT md: drop queue limitation for RAID1 and RAID10 md/raid5: play nice with PREEMPT_RT block/rnbd-clt-sysfs: use default_groups in kobj_type pktcdvd: convert to use attribute groups block: null_blk: only set set->nr_maps as 3 if active poll_queues is > 0 nvme: add 'iopolicy' module parameter nvme: drop unused variable ctrl in nvme_setup_cmd nvme: increment request genctr on completion nvme-fabrics: print out valid arguments when reading from /dev/nvme-fabrics block: remove the rsxx driver rsxx: Drop PCI legacy power management ...

Linus Torvalds committed 4 years ago

Commit c9193f42 parents d3c8108 d85bd8240 files · +612 −4501Browse files

Showing the changes to drivers/md (9 of 40 files). Show all

Unified · Split

9 files
  1. drivers/md/md-cluster.c +1 −1
  2. drivers/md/md.c +41 −12
  3. drivers/md/md.h +2 −0
  4. drivers/md/raid0.c +28 −10
  5. drivers/md/raid1-10.c +0 −6
  6. drivers/md/raid1.c +56 −27
  7. drivers/md/raid10.c +67 −40
  8. drivers/md/raid5.c +51 −16
  9. drivers/md/raid5.h +3 −1
drivers/md/md-cluster.c+1−1
@@ -574,7 +574,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) · 573 unmodified lines
574574 int ret = 0;
575575
576576 if (WARN(mddev->cluster_info->slot_number - 1 == le32_to_cpu(msg->slot),
577− "node %d received it's own msg\n", le32_to_cpu(msg->slot)))
577+ "node %d received its own msg\n", le32_to_cpu(msg->slot)))
578578 return -1;
579579 switch (le32_to_cpu(msg->type)) {
580580 case METADATA_UPDATED:
drivers/md/md.c+41−12
@@ -418,6 +418,12 @@ check_suspended: · 417 unmodified lines
418418 rcu_read_lock();
419419 if (is_suspended(mddev, bio)) {
420420 DEFINE_WAIT(__wait);
421+ /* Bail out if REQ_NOWAIT is set for the bio */
422+ if (bio->bi_opf & REQ_NOWAIT) {
423+ rcu_read_unlock();
424+ bio_wouldblock_error(bio);
425+ return;
426+ }
421427 for (;;) {
422428 prepare_to_wait(&mddev->sb_wait, &__wait,
423429 TASK_UNINTERRUPTIBLE);
@@ -3603,6 +3609,7 @@ static struct attribute *rdev_default_attrs[] = { · 3179 unmodified lines
36033609 &rdev_ppl_size.attr,
36043610 NULL,
36053611 };
3612+ATTRIBUTE_GROUPS(rdev_default);
36063613 static ssize_t
36073614 rdev_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
36083615 {
@@ -3652,7 +3659,7 @@ static const struct sysfs_ops rdev_sysfs_ops = { · 43 unmodified lines
36523659 static struct kobj_type rdev_ktype = {
36533660 .release = rdev_free,
36543661 .sysfs_ops = &rdev_sysfs_ops,
3655− .default_attrs = rdev_default_attrs,
3662+ .default_groups = rdev_default_groups,
36563663 };
36573664
36583665 int md_rdev_init(struct md_rdev *rdev)
@@ -5788,6 +5795,7 @@ int md_run(struct mddev *mddev) · 2129 unmodified lines
57885795 int err;
57895796 struct md_rdev *rdev;
57905797 struct md_personality *pers;
5798+ bool nowait = true;
57915799
57925800 if (list_empty(&mddev->disks))
57935801 /* cannot run an array with no devices.. */
@@ -5858,8 +5866,13 @@ int md_run(struct mddev *mddev) · 64 unmodified lines
58585866 }
58595867 }
58605868 sysfs_notify_dirent_safe(rdev->sysfs_state);
5869+ nowait = nowait && blk_queue_nowait(bdev_get_queue(rdev->bdev));
58615870 }
58625871
5872+ /* Set the NOWAIT flags if all underlying devices support it */
5873+ if (nowait)
5874+ blk_queue_flag_set(QUEUE_FLAG_NOWAIT, mddev->queue);
5875+
58635876 if (!bioset_initialized(&mddev->bio_set)) {
58645877 err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
58655878 if (err)
@@ -5870,13 +5883,6 @@ int md_run(struct mddev *mddev) · 4 unmodified lines
58705883 if (err)
58715884 goto exit_bio_set;
58725885 }
5873− if (mddev->level != 1 && mddev->level != 10 &&
5874− !bioset_initialized(&mddev->io_acct_set)) {
5875− err = bioset_init(&mddev->io_acct_set, BIO_POOL_SIZE,
5876− offsetof(struct md_io_acct, bio_clone), 0);
5877− if (err)
5878− goto exit_sync_set;
5879− }
58805886
58815887 spin_lock(&pers_lock);
58825888 pers = find_pers(mddev->level, mddev->clevel);
@@ -6053,9 +6059,6 @@ bitmap_abort: · 170 unmodified lines
60536059 module_put(pers->owner);
60546060 md_bitmap_destroy(mddev);
60556061 abort:
6056− if (mddev->level != 1 && mddev->level != 10)
6057− bioset_exit(&mddev->io_acct_set);
6058−exit_sync_set:
60596062 bioset_exit(&mddev->sync_set);
60606063 exit_bio_set:
60616064 bioset_exit(&mddev->bio_set);
@@ -7004,6 +7007,15 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev) · 942 unmodified lines
70047007 set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags);
70057008 if (!mddev->thread)
70067009 md_update_sb(mddev, 1);
7010+ /*
7011+ * If the new disk does not support REQ_NOWAIT,
7012+ * disable on the whole MD.
7013+ */
7014+ if (!blk_queue_nowait(bdev_get_queue(rdev->bdev))) {
7015+ pr_info("%s: Disabling nowait because %s does not support nowait\n",
7016+ mdname(mddev), bdevname(rdev->bdev, b));
7017+ blk_queue_flag_clear(QUEUE_FLAG_NOWAIT, mddev->queue);
7018+ }
70077019 /*
70087020 * Kick recovery, maybe this spare has to be added to the
70097021 * array immediately.
@@ -8402,7 +8414,7 @@ int md_setup_cluster(struct mddev *mddev, int nodes) · 1392 unmodified lines
84028414 spin_lock(&pers_lock);
84038415 /* ensure module won't be unloaded */
84048416 if (!md_cluster_ops || !try_module_get(md_cluster_mod)) {
8405− pr_warn("can't find md-cluster module or get it's reference.\n");
8417+ pr_warn("can't find md-cluster module or get its reference.\n");
84068418 spin_unlock(&pers_lock);
84078419 return -ENOENT;
84088420 }
@@ -8589,6 +8601,23 @@ void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, · 180 unmodified lines
85898601 }
85908602 EXPORT_SYMBOL_GPL(md_submit_discard_bio);
85918603
8604+int acct_bioset_init(struct mddev *mddev)
8605+{
8606+ int err = 0;
8607+
8608+ if (!bioset_initialized(&mddev->io_acct_set))
8609+ err = bioset_init(&mddev->io_acct_set, BIO_POOL_SIZE,
8610+ offsetof(struct md_io_acct, bio_clone), 0);
8611+ return err;
8612+}
8613+EXPORT_SYMBOL_GPL(acct_bioset_init);
8614+
8615+void acct_bioset_exit(struct mddev *mddev)
8616+{
8617+ bioset_exit(&mddev->io_acct_set);
8618+}
8619+EXPORT_SYMBOL_GPL(acct_bioset_exit);
8620+
85928621 static void md_end_io_acct(struct bio *bio)
85938622 {
85948623 struct md_io_acct *md_io_acct = bio->bi_private;
drivers/md/md.h+2−0
@@ -721,6 +721,8 @@ extern void md_error(struct mddev *mddev, struct md_rdev *rdev); · 720 unmodified lines
721721 extern void md_finish_reshape(struct mddev *mddev);
722722 void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev,
723723 struct bio *bio, sector_t start, sector_t size);
724+int acct_bioset_init(struct mddev *mddev);
725+void acct_bioset_exit(struct mddev *mddev);
724726 void md_account_bio(struct mddev *mddev, struct bio **bio);
725727
726728 extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio);
drivers/md/raid0.c+28−10
@@ -356,7 +356,21 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks · 355 unmodified lines
356356 return array_sectors;
357357 }
358358
359−static void raid0_free(struct mddev *mddev, void *priv);
359+static void free_conf(struct mddev *mddev, struct r0conf *conf)
360+{
361+ kfree(conf->strip_zone);
362+ kfree(conf->devlist);
363+ kfree(conf);
364+ mddev->private = NULL;
365+}
366+
367+static void raid0_free(struct mddev *mddev, void *priv)
368+{
369+ struct r0conf *conf = priv;
370+
371+ free_conf(mddev, conf);
372+ acct_bioset_exit(mddev);
373+}
360374
361375 static int raid0_run(struct mddev *mddev)
362376 {
@@ -370,11 +384,16 @@ static int raid0_run(struct mddev *mddev) · 7 unmodified lines
370384 if (md_check_no_bitmap(mddev))
371385 return -EINVAL;
372386
387+ if (acct_bioset_init(mddev)) {
388+ pr_err("md/raid0:%s: alloc acct bioset failed.\n", mdname(mddev));
389+ return -ENOMEM;
390+ }
391+
373392 /* if private is not null, we are here after takeover */
374393 if (mddev->private == NULL) {
375394 ret = create_strip_zones(mddev, &conf);
376395 if (ret < 0)
377− return ret;
396+ goto exit_acct_set;
378397 mddev->private = conf;
379398 }
380399 conf = mddev->private;
@@ -413,17 +432,16 @@ static int raid0_run(struct mddev *mddev) · 32 unmodified lines
413432 dump_zones(mddev);
414433
415434 ret = md_integrity_register(mddev);
435+ if (ret)
436+ goto free;
416437
417438 return ret;
418−}
419439
420−static void raid0_free(struct mddev *mddev, void *priv)
421−{
422− struct r0conf *conf = priv;
423−
424− kfree(conf->strip_zone);
425− kfree(conf->devlist);
426− kfree(conf);
440+free:
441+ free_conf(mddev, conf);
442+exit_acct_set:
443+ acct_bioset_exit(mddev);
444+ return ret;
427445 }
428446
429447 static void raid0_handle_discard(struct mddev *mddev, struct bio *bio)
drivers/md/raid1-10.c+0−6
@@ -22,12 +22,6 @@ · 21 unmodified lines
2222
2323 #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2)
2424
25−/* When there are this many requests queue to be written by
26− * the raid thread, we become 'congested' to provide back-pressure
27− * for writeback.
28− */
29−static int max_queued_requests = 1024;
30−
3125 /* for managing resync I/O pages */
3226 struct resync_pages {
3327 void *raid_bio;
drivers/md/raid1.c+56−27
@@ -929,8 +929,10 @@ static void lower_barrier(struct r1conf *conf, sector_t sector_nr) · 928 unmodified lines
929929 wake_up(&conf->wait_barrier);
930930 }
931931
932−static void _wait_barrier(struct r1conf *conf, int idx)
932+static bool _wait_barrier(struct r1conf *conf, int idx, bool nowait)
933933 {
934+ bool ret = true;
935+
934936 /*
935937 * We need to increase conf->nr_pending[idx] very early here,
936938 * then raise_barrier() can be blocked when it waits for
@@ -961,7 +963,7 @@ static void _wait_barrier(struct r1conf *conf, int idx) · 24 unmodified lines
961963 */
962964 if (!READ_ONCE(conf->array_frozen) &&
963965 !atomic_read(&conf->barrier[idx]))
964− return;
966+ return ret;
965967
966968 /*
967969 * After holding conf->resync_lock, conf->nr_pending[idx]
@@ -979,18 +981,27 @@ static void _wait_barrier(struct r1conf *conf, int idx) · 11 unmodified lines
979981 */
980982 wake_up(&conf->wait_barrier);
981983 /* Wait for the barrier in same barrier unit bucket to drop. */
982− wait_event_lock_irq(conf->wait_barrier,
983− !conf->array_frozen &&
984− !atomic_read(&conf->barrier[idx]),
985− conf->resync_lock);
986− atomic_inc(&conf->nr_pending[idx]);
984+
985+ /* Return false when nowait flag is set */
986+ if (nowait) {
987+ ret = false;
988+ } else {
989+ wait_event_lock_irq(conf->wait_barrier,
990+ !conf->array_frozen &&
991+ !atomic_read(&conf->barrier[idx]),
992+ conf->resync_lock);
993+ atomic_inc(&conf->nr_pending[idx]);
994+ }
995+
987996 atomic_dec(&conf->nr_waiting[idx]);
988997 spin_unlock_irq(&conf->resync_lock);
998+ return ret;
989999 }
9901000
991−static void wait_read_barrier(struct r1conf *conf, sector_t sector_nr)
1001+static bool wait_read_barrier(struct r1conf *conf, sector_t sector_nr, bool nowait)
9921002 {
9931003 int idx = sector_to_idx(sector_nr);
1004+ bool ret = true;
9941005
9951006 /*
9961007 * Very similar to _wait_barrier(). The difference is, for read
@@ -1002,7 +1013,7 @@ static void wait_read_barrier(struct r1conf *conf, sector_t sector_nr) · 5 unmodified lines
10021013 atomic_inc(&conf->nr_pending[idx]);
10031014
10041015 if (!READ_ONCE(conf->array_frozen))
1005− return;
1016+ return ret;
10061017
10071018 spin_lock_irq(&conf->resync_lock);
10081019 atomic_inc(&conf->nr_waiting[idx]);
@@ -1013,19 +1024,28 @@ static void wait_read_barrier(struct r1conf *conf, sector_t sector_nr) · 4 unmodified lines
10131024 */
10141025 wake_up(&conf->wait_barrier);
10151026 /* Wait for array to be unfrozen */
1016− wait_event_lock_irq(conf->wait_barrier,
1017− !conf->array_frozen,
1018− conf->resync_lock);
1019− atomic_inc(&conf->nr_pending[idx]);
1027+
1028+ /* Return false when nowait flag is set */
1029+ if (nowait) {
1030+ /* Return false when nowait flag is set */
1031+ ret = false;
1032+ } else {
1033+ wait_event_lock_irq(conf->wait_barrier,
1034+ !conf->array_frozen,
1035+ conf->resync_lock);
1036+ atomic_inc(&conf->nr_pending[idx]);
1037+ }
1038+
10201039 atomic_dec(&conf->nr_waiting[idx]);
10211040 spin_unlock_irq(&conf->resync_lock);
1041+ return ret;
10221042 }
10231043
1024−static void wait_barrier(struct r1conf *conf, sector_t sector_nr)
1044+static bool wait_barrier(struct r1conf *conf, sector_t sector_nr, bool nowait)
10251045 {
10261046 int idx = sector_to_idx(sector_nr);
10271047
1028− _wait_barrier(conf, idx);
1048+ return _wait_barrier(conf, idx, nowait);
10291049 }
10301050
10311051 static void _allow_barrier(struct r1conf *conf, int idx)
@@ -1236,7 +1256,11 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, · 204 unmodified lines
12361256 * Still need barrier for READ in case that whole
12371257 * array is frozen.
12381258 */
1239− wait_read_barrier(conf, bio->bi_iter.bi_sector);
1259+ if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
1260+ bio->bi_opf & REQ_NOWAIT)) {
1261+ bio_wouldblock_error(bio);
1262+ return;
1263+ }
12401264
12411265 if (!r1_bio)
12421266 r1_bio = alloc_r1bio(mddev, bio);
@@ -1336,6 +1360,10 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 93 unmodified lines
13361360 bio->bi_iter.bi_sector, bio_end_sector(bio))) {
13371361
13381362 DEFINE_WAIT(w);
1363+ if (bio->bi_opf & REQ_NOWAIT) {
1364+ bio_wouldblock_error(bio);
1365+ return;
1366+ }
13391367 for (;;) {
13401368 prepare_to_wait(&conf->wait_barrier,
13411369 &w, TASK_IDLE);
@@ -1353,17 +1381,15 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 11 unmodified lines
13531381 * thread has put up a bar for new requests.
13541382 * Continue immediately if no resync is active currently.
13551383 */
1356− wait_barrier(conf, bio->bi_iter.bi_sector);
1384+ if (!wait_barrier(conf, bio->bi_iter.bi_sector,
1385+ bio->bi_opf & REQ_NOWAIT)) {
1386+ bio_wouldblock_error(bio);
1387+ return;
1388+ }
13571389
13581390 r1_bio = alloc_r1bio(mddev, bio);
13591391 r1_bio->sectors = max_write_sectors;
13601392
1361− if (conf->pending_count >= max_queued_requests) {
1362− md_wakeup_thread(mddev->thread);
1363− raid1_log(mddev, "wait queued");
1364− wait_event(conf->wait_barrier,
1365− conf->pending_count < max_queued_requests);
1366− }
13671393 /* first select target devices under rcu_lock and
13681394 * inc refcount on their rdev. Record them by setting
13691395 * bios[x] to bio
@@ -1458,9 +1484,14 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 88 unmodified lines
14581484 rdev_dec_pending(conf->mirrors[j].rdev, mddev);
14591485 r1_bio->state = 0;
14601486 allow_barrier(conf, bio->bi_iter.bi_sector);
1487+
1488+ if (bio->bi_opf & REQ_NOWAIT) {
1489+ bio_wouldblock_error(bio);
1490+ return;
1491+ }
14611492 raid1_log(mddev, "wait rdev %d blocked", blocked_rdev->raid_disk);
14621493 md_wait_for_blocked_rdev(blocked_rdev, mddev);
1463− wait_barrier(conf, bio->bi_iter.bi_sector);
1494+ wait_barrier(conf, bio->bi_iter.bi_sector, false);
14641495 goto retry_write;
14651496 }
14661497
@@ -1688,7 +1719,7 @@ static void close_sync(struct r1conf *conf) · 221 unmodified lines
16881719 int idx;
16891720
16901721 for (idx = 0; idx < BARRIER_BUCKETS_NR; idx++) {
1691− _wait_barrier(conf, idx);
1722+ _wait_barrier(conf, idx, false);
16921723 _allow_barrier(conf, idx);
16931724 }
16941725
@@ -3410,5 +3441,3 @@ MODULE_DESCRIPTION("RAID1 (mirroring) personality for MD"); · 1715 unmodified lines
34103441 MODULE_ALIAS("md-personality-3"); /* RAID1 */
34113442 MODULE_ALIAS("md-raid1");
34123443 MODULE_ALIAS("md-level-1");
3413−
3414−module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);
drivers/md/raid10.c+67−40
@@ -952,8 +952,10 @@ static void lower_barrier(struct r10conf *conf) · 951 unmodified lines
952952 wake_up(&conf->wait_barrier);
953953 }
954954
955−static void wait_barrier(struct r10conf *conf)
955+static bool wait_barrier(struct r10conf *conf, bool nowait)
956956 {
957+ bool ret = true;
958+
957959 spin_lock_irq(&conf->resync_lock);
958960 if (conf->barrier) {
959961 struct bio_list *bio_list = current->bio_list;
@@ -967,27 +969,35 @@ static void wait_barrier(struct r10conf *conf) · 7 unmodified lines
967969 * that queue to get the nr_pending
968970 * count down.
969971 */
970− raid10_log(conf->mddev, "wait barrier");
971− wait_event_lock_irq(conf->wait_barrier,
972− !conf->barrier ||
973− (atomic_read(&conf->nr_pending) &&
974− bio_list &&
975− (!bio_list_empty(&bio_list[0]) ||
976− !bio_list_empty(&bio_list[1]))) ||
977− /* move on if recovery thread is
978− * blocked by us
979− */
980− (conf->mddev->thread->tsk == current &&
981− test_bit(MD_RECOVERY_RUNNING,
982− &conf->mddev->recovery) &&
983− conf->nr_queued > 0),
984− conf->resync_lock);
972+ /* Return false when nowait flag is set */
973+ if (nowait) {
974+ ret = false;
975+ } else {
976+ raid10_log(conf->mddev, "wait barrier");
977+ wait_event_lock_irq(conf->wait_barrier,
978+ !conf->barrier ||
979+ (atomic_read(&conf->nr_pending) &&
980+ bio_list &&
981+ (!bio_list_empty(&bio_list[0]) ||
982+ !bio_list_empty(&bio_list[1]))) ||
983+ /* move on if recovery thread is
984+ * blocked by us
985+ */
986+ (conf->mddev->thread->tsk == current &&
987+ test_bit(MD_RECOVERY_RUNNING,
988+ &conf->mddev->recovery) &&
989+ conf->nr_queued > 0),
990+ conf->resync_lock);
991+ }
985992 conf->nr_waiting--;
986993 if (!conf->nr_waiting)
987994 wake_up(&conf->wait_barrier);
988995 }
989− atomic_inc(&conf->nr_pending);
996+ /* Only increment nr_pending when we wait */
997+ if (ret)
998+ atomic_inc(&conf->nr_pending);
990999 spin_unlock_irq(&conf->resync_lock);
1000+ return ret;
9911001 }
9921002
9931003 static void allow_barrier(struct r10conf *conf)
@@ -1098,21 +1108,30 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule) · 104 unmodified lines
10981108 * currently.
10991109 * 2. If IO spans the reshape position. Need to wait for reshape to pass.
11001110 */
1101−static void regular_request_wait(struct mddev *mddev, struct r10conf *conf,
1111+static bool regular_request_wait(struct mddev *mddev, struct r10conf *conf,
11021112 struct bio *bio, sector_t sectors)
11031113 {
1104− wait_barrier(conf);
1114+ /* Bail out if REQ_NOWAIT is set for the bio */
1115+ if (!wait_barrier(conf, bio->bi_opf & REQ_NOWAIT)) {
1116+ bio_wouldblock_error(bio);
1117+ return false;
1118+ }
11051119 while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
11061120 bio->bi_iter.bi_sector < conf->reshape_progress &&
11071121 bio->bi_iter.bi_sector + sectors > conf->reshape_progress) {
1108− raid10_log(conf->mddev, "wait reshape");
11091122 allow_barrier(conf);
1123+ if (bio->bi_opf & REQ_NOWAIT) {
1124+ bio_wouldblock_error(bio);
1125+ return false;
1126+ }
1127+ raid10_log(conf->mddev, "wait reshape");
11101128 wait_event(conf->wait_barrier,
11111129 conf->reshape_progress <= bio->bi_iter.bi_sector ||
11121130 conf->reshape_progress >= bio->bi_iter.bi_sector +
11131131 sectors);
1114− wait_barrier(conf);
1132+ wait_barrier(conf, false);
11151133 }
1134+ return true;
11161135 }
11171136
11181137 static void raid10_read_request(struct mddev *mddev, struct bio *bio,
@@ -1157,7 +1176,8 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, · 38 unmodified lines
11571176 rcu_read_unlock();
11581177 }
11591178
1160− regular_request_wait(mddev, conf, bio, r10_bio->sectors);
1179+ if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors))
1180+ return;
11611181 rdev = read_balance(conf, r10_bio, &max_sectors);
11621182 if (!rdev) {
11631183 if (err_rdev) {
@@ -1179,7 +1199,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, · 15 unmodified lines
11791199 bio_chain(split, bio);
11801200 allow_barrier(conf);
11811201 submit_bio_noacct(bio);
1182− wait_barrier(conf);
1202+ wait_barrier(conf, false);
11831203 bio = split;
11841204 r10_bio->master_bio = bio;
11851205 r10_bio->sectors = max_sectors;
@@ -1338,7 +1358,7 @@ retry_wait: · 152 unmodified lines
13381358 raid10_log(conf->mddev, "%s wait rdev %d blocked",
13391359 __func__, blocked_rdev->raid_disk);
13401360 md_wait_for_blocked_rdev(blocked_rdev, mddev);
1341− wait_barrier(conf);
1361+ wait_barrier(conf, false);
13421362 goto retry_wait;
13431363 }
13441364 }
@@ -1356,6 +1376,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 11 unmodified lines
13561376 bio->bi_iter.bi_sector,
13571377 bio_end_sector(bio)))) {
13581378 DEFINE_WAIT(w);
1379+ /* Bail out if REQ_NOWAIT is set for the bio */
1380+ if (bio->bi_opf & REQ_NOWAIT) {
1381+ bio_wouldblock_error(bio);
1382+ return;
1383+ }
13591384 for (;;) {
13601385 prepare_to_wait(&conf->wait_barrier,
13611386 &w, TASK_IDLE);
@@ -1368,7 +1393,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 6 unmodified lines
13681393 }
13691394
13701395 sectors = r10_bio->sectors;
1371− regular_request_wait(mddev, conf, bio, sectors);
1396+ if (!regular_request_wait(mddev, conf, bio, sectors))
1397+ return;
13721398 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) &&
13731399 (mddev->reshape_backwards
13741400 ? (bio->bi_iter.bi_sector < conf->reshape_safe &&
@@ -1380,6 +1406,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 5 unmodified lines
13801406 set_mask_bits(&mddev->sb_flags, 0,
13811407 BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
13821408 md_wakeup_thread(mddev->thread);
1409+ if (bio->bi_opf & REQ_NOWAIT) {
1410+ allow_barrier(conf);
1411+ bio_wouldblock_error(bio);
1412+ return;
1413+ }
13831414 raid10_log(conf->mddev, "wait reshape metadata");
13841415 wait_event(mddev->sb_wait,
13851416 !test_bit(MD_SB_CHANGE_PENDING, &mddev->sb_flags));
@@ -1387,12 +1418,6 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 1 unmodified line
13871418 conf->reshape_safe = mddev->reshape_position;
13881419 }
13891420
1390− if (conf->pending_count >= max_queued_requests) {
1391− md_wakeup_thread(mddev->thread);
1392− raid10_log(mddev, "wait queued");
1393− wait_event(conf->wait_barrier,
1394− conf->pending_count < max_queued_requests);
1395− }
13961421 /* first select target devices under rcu_lock and
13971422 * inc refcount on their rdev. Record them by setting
13981423 * bios[x] to bio
@@ -1482,7 +1507,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 83 unmodified lines
14821507 bio_chain(split, bio);
14831508 allow_barrier(conf);
14841509 submit_bio_noacct(bio);
1485− wait_barrier(conf);
1510+ wait_barrier(conf, false);
14861511 bio = split;
14871512 r10_bio->master_bio = bio;
14881513 }
@@ -1607,7 +1632,11 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) · 118 unmodified lines
16071632 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
16081633 return -EAGAIN;
16091634
1610− wait_barrier(conf);
1635+ if (WARN_ON_ONCE(bio->bi_opf & REQ_NOWAIT)) {
1636+ bio_wouldblock_error(bio);
1637+ return 0;
1638+ }
1639+ wait_barrier(conf, false);
16111640
16121641 /*
16131642 * Check reshape again to avoid reshape happens after checking
@@ -1649,7 +1678,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) · 35 unmodified lines
16491678 allow_barrier(conf);
16501679 /* Resend the fist split part */
16511680 submit_bio_noacct(split);
1652− wait_barrier(conf);
1681+ wait_barrier(conf, false);
16531682 }
16541683 div_u64_rem(bio_end, stripe_size, &remainder);
16551684 if (remainder) {
@@ -1660,7 +1689,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) · 4 unmodified lines
16601689 /* Resend the second split part */
16611690 submit_bio_noacct(bio);
16621691 bio = split;
1663− wait_barrier(conf);
1692+ wait_barrier(conf, false);
16641693 }
16651694
16661695 bio_start = bio->bi_iter.bi_sector;
@@ -1816,7 +1845,7 @@ retry_discard: · 149 unmodified lines
18161845 end_disk_offset += geo->stride;
18171846 atomic_inc(&first_r10bio->remaining);
18181847 raid_end_discard_bio(r10_bio);
1819− wait_barrier(conf);
1848+ wait_barrier(conf, false);
18201849 goto retry_discard;
18211850 }
18221851
@@ -2011,7 +2040,7 @@ static void print_conf(struct r10conf *conf) · 188 unmodified lines
20112040
20122041 static void close_sync(struct r10conf *conf)
20132042 {
2014− wait_barrier(conf);
2043+ wait_barrier(conf, false);
20152044 allow_barrier(conf);
20162045
20172046 mempool_exit(&conf->r10buf_pool);
@@ -4819,7 +4848,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, · 2801 unmodified lines
48194848 if (need_flush ||
48204849 time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) {
48214850 /* Need to update reshape_position in metadata */
4822− wait_barrier(conf);
4851+ wait_barrier(conf, false);
48234852 mddev->reshape_position = conf->reshape_progress;
48244853 if (mddev->reshape_backwards)
48254854 mddev->curr_resync_completed = raid10_size(mddev, 0, 0)
@@ -5242,5 +5271,3 @@ MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD"); · 416 unmodified lines
52425271 MODULE_ALIAS("md-personality-9"); /* RAID10 */
52435272 MODULE_ALIAS("md-raid10");
52445273 MODULE_ALIAS("md-level-10");
5245−
5246−module_param(max_queued_requests, int, S_IRUGO|S_IWUSR);
drivers/md/raid5.c+51−16
@@ -2215,10 +2215,9 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) · 2214 unmodified lines
22152215 struct r5conf *conf = sh->raid_conf;
22162216 int level = conf->level;
22172217 struct raid5_percpu *percpu;
2218− unsigned long cpu;
22192218
2220− cpu = get_cpu();
2221− percpu = per_cpu_ptr(conf->percpu, cpu);
2219+ local_lock(&conf->percpu->lock);
2220+ percpu = this_cpu_ptr(conf->percpu);
22222221 if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) {
22232222 ops_run_biofill(sh);
22242223 overlap_clear++;
@@ -2271,13 +2270,14 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) · 46 unmodified lines
22712270 BUG();
22722271 }
22732272
2274− if (overlap_clear && !sh->batch_head)
2273+ if (overlap_clear && !sh->batch_head) {
22752274 for (i = disks; i--; ) {
22762275 struct r5dev *dev = &sh->dev[i];
22772276 if (test_and_clear_bit(R5_Overlap, &dev->flags))
22782277 wake_up(&sh->raid_conf->wait_for_overlap);
22792278 }
2280− put_cpu();
2279+ }
2280+ local_unlock(&conf->percpu->lock);
22812281 }
22822282
22832283 static void free_stripe(struct kmem_cache *sc, struct stripe_head *sh)
@@ -5686,6 +5686,10 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi) · 3402 unmodified lines
56865686 struct stripe_head *sh;
56875687 int stripe_sectors;
56885688
5689+ /* We need to handle this when io_uring supports discard/trim */
5690+ if (WARN_ON_ONCE(bi->bi_opf & REQ_NOWAIT))
5691+ return;
5692+
56895693 if (mddev->reshape_position != MaxSector)
56905694 /* Skip discard while reshape is happening */
56915695 return;
@@ -5819,6 +5823,17 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi) · 127 unmodified lines
58195823 last_sector = bio_end_sector(bi);
58205824 bi->bi_next = NULL;
58215825
5826+ /* Bail out if conflicts with reshape and REQ_NOWAIT is set */
5827+ if ((bi->bi_opf & REQ_NOWAIT) &&
5828+ (conf->reshape_progress != MaxSector) &&
5829+ (mddev->reshape_backwards
5830+ ? (logical_sector > conf->reshape_progress && logical_sector <= conf->reshape_safe)
5831+ : (logical_sector >= conf->reshape_safe && logical_sector < conf->reshape_progress))) {
5832+ bio_wouldblock_error(bi);
5833+ if (rw == WRITE)
5834+ md_write_end(mddev);
5835+ return true;
5836+ }
58225837 md_account_bio(mddev, &bi);
58235838 prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
58245839 for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) {
@@ -7052,6 +7067,7 @@ static int alloc_scratch_buffer(struct r5conf *conf, struct raid5_percpu *percpu · 1227 unmodified lines
70527067 return -ENOMEM;
70537068 }
70547069
7070+ local_lock_init(&percpu->lock);
70557071 return 0;
70567072 }
70577073
@@ -7446,12 +7462,19 @@ static int raid5_run(struct mddev *mddev) · 388 unmodified lines
74467462 struct md_rdev *rdev;
74477463 struct md_rdev *journal_dev = NULL;
74487464 sector_t reshape_offset = 0;
7449− int i;
7465+ int i, ret = 0;
74507466 long long min_offset_diff = 0;
74517467 int first = 1;
74527468
7453− if (mddev_init_writes_pending(mddev) < 0)
7469+ if (acct_bioset_init(mddev)) {
7470+ pr_err("md/raid456:%s: alloc acct bioset failed.\n", mdname(mddev));
74547471 return -ENOMEM;
7472+ }
7473+
7474+ if (mddev_init_writes_pending(mddev) < 0) {
7475+ ret = -ENOMEM;
7476+ goto exit_acct_set;
7477+ }
74557478
74567479 if (mddev->recovery_cp != MaxSector)
74577480 pr_notice("md/raid:%s: not clean -- starting background reconstruction\n",
@@ -7482,7 +7505,8 @@ static int raid5_run(struct mddev *mddev) · 24 unmodified lines
74827505 (mddev->bitmap_info.offset || mddev->bitmap_info.file)) {
74837506 pr_notice("md/raid:%s: array cannot have both journal and bitmap\n",
74847507 mdname(mddev));
7485− return -EINVAL;
7508+ ret = -EINVAL;
7509+ goto exit_acct_set;
74867510 }
74877511
74887512 if (mddev->reshape_position != MaxSector) {
@@ -7507,13 +7531,15 @@ static int raid5_run(struct mddev *mddev) · 18 unmodified lines
75077531 if (journal_dev) {
75087532 pr_warn("md/raid:%s: don't support reshape with journal - aborting.\n",
75097533 mdname(mddev));
7510− return -EINVAL;
7534+ ret = -EINVAL;
7535+ goto exit_acct_set;
75117536 }
75127537
75137538 if (mddev->new_level != mddev->level) {
75147539 pr_warn("md/raid:%s: unsupported reshape required - aborting.\n",
75157540 mdname(mddev));
7516− return -EINVAL;
7541+ ret = -EINVAL;
7542+ goto exit_acct_set;
75177543 }
75187544 old_disks = mddev->raid_disks - mddev->delta_disks;
75197545 /* reshape_position must be on a new-stripe boundary, and one
@@ -7529,7 +7555,8 @@ static int raid5_run(struct mddev *mddev) · 9 unmodified lines
75297555 if (sector_div(here_new, chunk_sectors * new_data_disks)) {
75307556 pr_warn("md/raid:%s: reshape_position not on a stripe boundary\n",
75317557 mdname(mddev));
7532− return -EINVAL;
7558+ ret = -EINVAL;
7559+ goto exit_acct_set;
75337560 }
75347561 reshape_offset = here_new * chunk_sectors;
75357562 /* here_new is the stripe we will write to */
@@ -7551,7 +7578,8 @@ static int raid5_run(struct mddev *mddev) · 15 unmodified lines
75517578 else if (mddev->ro == 0) {
75527579 pr_warn("md/raid:%s: in-place reshape must be started in read-only mode - aborting\n",
75537580 mdname(mddev));
7554− return -EINVAL;
7581+ ret = -EINVAL;
7582+ goto exit_acct_set;
75557583 }
75567584 } else if (mddev->reshape_backwards
75577585 ? (here_new * chunk_sectors + min_offset_diff <=
@@ -7561,7 +7589,8 @@ static int raid5_run(struct mddev *mddev) · 3 unmodified lines
75617589 /* Reading from the same stripe as writing to - bad */
75627590 pr_warn("md/raid:%s: reshape_position too early for auto-recovery - aborting.\n",
75637591 mdname(mddev));
7564− return -EINVAL;
7592+ ret = -EINVAL;
7593+ goto exit_acct_set;
75657594 }
75667595 pr_debug("md/raid:%s: reshape will continue\n", mdname(mddev));
75677596 /* OK, we should be able to continue; */
@@ -7585,8 +7614,10 @@ static int raid5_run(struct mddev *mddev) · 17 unmodified lines
75857614 else
75867615 conf = mddev->private;
75877616
7588− if (IS_ERR(conf))
7589− return PTR_ERR(conf);
7617+ if (IS_ERR(conf)) {
7618+ ret = PTR_ERR(conf);
7619+ goto exit_acct_set;
7620+ }
75907621
75917622 if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
75927623 if (!journal_dev) {
@@ -7783,7 +7814,10 @@ abort: · 190 unmodified lines
77837814 free_conf(conf);
77847815 mddev->private = NULL;
77857816 pr_warn("md/raid:%s: failed to run raid set.\n", mdname(mddev));
7786− return -EIO;
7817+ ret = -EIO;
7818+exit_acct_set:
7819+ acct_bioset_exit(mddev);
7820+ return ret;
77877821 }
77887822
77897823 static void raid5_free(struct mddev *mddev, void *priv)
@@ -7791,6 +7825,7 @@ static void raid5_free(struct mddev *mddev, void *priv) · 1 unmodified line
77917825 struct r5conf *conf = priv;
77927826
77937827 free_conf(conf);
7828+ acct_bioset_exit(mddev);
77947829 mddev->to_remove = &raid5_attrs_group;
77957830 }
77967831
drivers/md/raid5.h+3−1
@@ -4,6 +4,7 @@ · 3 unmodified lines
44
55 #include <linux/raid/xor.h>
66 #include <linux/dmaengine.h>
7+#include <linux/local_lock.h>
78
89 /*
910 *
@@ -640,7 +641,8 @@ struct r5conf { · 630 unmodified lines
640641 * lists and performing address
641642 * conversions
642643 */
643− int scribble_obj_size;
644+ int scribble_obj_size;
645+ local_lock_t lock;
644646 } __percpu *percpu;
645647 int scribble_disks;
646648 int scribble_sectors;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t