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 ...
Showing the changes to drivers/md (9 of 40 files). Show all
Unified · Split
| @@ -574,7 +574,7 @@ static int process_recvd_msg(struct mddev *mddev, struct cluster_msg *msg) · 573 unmodified lines | ||
| 574 | 574 | int ret = 0; |
| 575 | 575 | |
| 576 | 576 | 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))) | |
| 578 | 578 | return -1; |
| 579 | 579 | switch (le32_to_cpu(msg->type)) { |
| 580 | 580 | case METADATA_UPDATED: |
| @@ -418,6 +418,12 @@ check_suspended: · 417 unmodified lines | ||
| 418 | 418 | rcu_read_lock(); |
| 419 | 419 | if (is_suspended(mddev, bio)) { |
| 420 | 420 | 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 | + } | |
| 421 | 427 | for (;;) { |
| 422 | 428 | prepare_to_wait(&mddev->sb_wait, &__wait, |
| 423 | 429 | TASK_UNINTERRUPTIBLE); |
| @@ -3603,6 +3609,7 @@ static struct attribute *rdev_default_attrs[] = { · 3179 unmodified lines | ||
| 3603 | 3609 | &rdev_ppl_size.attr, |
| 3604 | 3610 | NULL, |
| 3605 | 3611 | }; |
| 3612 | +ATTRIBUTE_GROUPS(rdev_default); | |
| 3606 | 3613 | static ssize_t |
| 3607 | 3614 | rdev_attr_show(struct kobject *kobj, struct attribute *attr, char *page) |
| 3608 | 3615 | { |
| @@ -3652,7 +3659,7 @@ static const struct sysfs_ops rdev_sysfs_ops = { · 43 unmodified lines | ||
| 3652 | 3659 | static struct kobj_type rdev_ktype = { |
| 3653 | 3660 | .release = rdev_free, |
| 3654 | 3661 | .sysfs_ops = &rdev_sysfs_ops, |
| 3655 | − .default_attrs = rdev_default_attrs, | |
| 3662 | + .default_groups = rdev_default_groups, | |
| 3656 | 3663 | }; |
| 3657 | 3664 | |
| 3658 | 3665 | int md_rdev_init(struct md_rdev *rdev) |
| @@ -5788,6 +5795,7 @@ int md_run(struct mddev *mddev) · 2129 unmodified lines | ||
| 5788 | 5795 | int err; |
| 5789 | 5796 | struct md_rdev *rdev; |
| 5790 | 5797 | struct md_personality *pers; |
| 5798 | + bool nowait = true; | |
| 5791 | 5799 | |
| 5792 | 5800 | if (list_empty(&mddev->disks)) |
| 5793 | 5801 | /* cannot run an array with no devices.. */ |
| @@ -5858,8 +5866,13 @@ int md_run(struct mddev *mddev) · 64 unmodified lines | ||
| 5858 | 5866 | } |
| 5859 | 5867 | } |
| 5860 | 5868 | sysfs_notify_dirent_safe(rdev->sysfs_state); |
| 5869 | + nowait = nowait && blk_queue_nowait(bdev_get_queue(rdev->bdev)); | |
| 5861 | 5870 | } |
| 5862 | 5871 | |
| 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 | + | |
| 5863 | 5876 | if (!bioset_initialized(&mddev->bio_set)) { |
| 5864 | 5877 | err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS); |
| 5865 | 5878 | if (err) |
| @@ -5870,13 +5883,6 @@ int md_run(struct mddev *mddev) · 4 unmodified lines | ||
| 5870 | 5883 | if (err) |
| 5871 | 5884 | goto exit_bio_set; |
| 5872 | 5885 | } |
| 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 | − } | |
| 5880 | 5886 | |
| 5881 | 5887 | spin_lock(&pers_lock); |
| 5882 | 5888 | pers = find_pers(mddev->level, mddev->clevel); |
| @@ -6053,9 +6059,6 @@ bitmap_abort: · 170 unmodified lines | ||
| 6053 | 6059 | module_put(pers->owner); |
| 6054 | 6060 | md_bitmap_destroy(mddev); |
| 6055 | 6061 | abort: |
| 6056 | − if (mddev->level != 1 && mddev->level != 10) | |
| 6057 | − bioset_exit(&mddev->io_acct_set); | |
| 6058 | −exit_sync_set: | |
| 6059 | 6062 | bioset_exit(&mddev->sync_set); |
| 6060 | 6063 | exit_bio_set: |
| 6061 | 6064 | bioset_exit(&mddev->bio_set); |
| @@ -7004,6 +7007,15 @@ static int hot_add_disk(struct mddev *mddev, dev_t dev) · 942 unmodified lines | ||
| 7004 | 7007 | set_bit(MD_SB_CHANGE_DEVS, &mddev->sb_flags); |
| 7005 | 7008 | if (!mddev->thread) |
| 7006 | 7009 | 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 | + } | |
| 7007 | 7019 | /* |
| 7008 | 7020 | * Kick recovery, maybe this spare has to be added to the |
| 7009 | 7021 | * array immediately. |
| @@ -8402,7 +8414,7 @@ int md_setup_cluster(struct mddev *mddev, int nodes) · 1392 unmodified lines | ||
| 8402 | 8414 | spin_lock(&pers_lock); |
| 8403 | 8415 | /* ensure module won't be unloaded */ |
| 8404 | 8416 | 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"); | |
| 8406 | 8418 | spin_unlock(&pers_lock); |
| 8407 | 8419 | return -ENOENT; |
| 8408 | 8420 | } |
| @@ -8589,6 +8601,23 @@ void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, · 180 unmodified lines | ||
| 8589 | 8601 | } |
| 8590 | 8602 | EXPORT_SYMBOL_GPL(md_submit_discard_bio); |
| 8591 | 8603 | |
| 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 | + | |
| 8592 | 8621 | static void md_end_io_acct(struct bio *bio) |
| 8593 | 8622 | { |
| 8594 | 8623 | struct md_io_acct *md_io_acct = bio->bi_private; |
| @@ -721,6 +721,8 @@ extern void md_error(struct mddev *mddev, struct md_rdev *rdev); · 720 unmodified lines | ||
| 721 | 721 | extern void md_finish_reshape(struct mddev *mddev); |
| 722 | 722 | void md_submit_discard_bio(struct mddev *mddev, struct md_rdev *rdev, |
| 723 | 723 | 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); | |
| 724 | 726 | void md_account_bio(struct mddev *mddev, struct bio **bio); |
| 725 | 727 | |
| 726 | 728 | extern bool __must_check md_flush_request(struct mddev *mddev, struct bio *bio); |
| @@ -356,7 +356,21 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks · 355 unmodified lines | ||
| 356 | 356 | return array_sectors; |
| 357 | 357 | } |
| 358 | 358 | |
| 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 | +} | |
| 360 | 374 | |
| 361 | 375 | static int raid0_run(struct mddev *mddev) |
| 362 | 376 | { |
| @@ -370,11 +384,16 @@ static int raid0_run(struct mddev *mddev) · 7 unmodified lines | ||
| 370 | 384 | if (md_check_no_bitmap(mddev)) |
| 371 | 385 | return -EINVAL; |
| 372 | 386 | |
| 387 | + if (acct_bioset_init(mddev)) { | |
| 388 | + pr_err("md/raid0:%s: alloc acct bioset failed.\n", mdname(mddev)); | |
| 389 | + return -ENOMEM; | |
| 390 | + } | |
| 391 | + | |
| 373 | 392 | /* if private is not null, we are here after takeover */ |
| 374 | 393 | if (mddev->private == NULL) { |
| 375 | 394 | ret = create_strip_zones(mddev, &conf); |
| 376 | 395 | if (ret < 0) |
| 377 | − return ret; | |
| 396 | + goto exit_acct_set; | |
| 378 | 397 | mddev->private = conf; |
| 379 | 398 | } |
| 380 | 399 | conf = mddev->private; |
| @@ -413,17 +432,16 @@ static int raid0_run(struct mddev *mddev) · 32 unmodified lines | ||
| 413 | 432 | dump_zones(mddev); |
| 414 | 433 | |
| 415 | 434 | ret = md_integrity_register(mddev); |
| 435 | + if (ret) | |
| 436 | + goto free; | |
| 416 | 437 | |
| 417 | 438 | return ret; |
| 418 | −} | |
| 419 | 439 | |
| 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; | |
| 427 | 445 | } |
| 428 | 446 | |
| 429 | 447 | static void raid0_handle_discard(struct mddev *mddev, struct bio *bio) |
| @@ -22,12 +22,6 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2) |
| 24 | 24 | |
| 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 | − | |
| 31 | 25 | /* for managing resync I/O pages */ |
| 32 | 26 | struct resync_pages { |
| 33 | 27 | void *raid_bio; |
| @@ -929,8 +929,10 @@ static void lower_barrier(struct r1conf *conf, sector_t sector_nr) · 928 unmodified lines | ||
| 929 | 929 | wake_up(&conf->wait_barrier); |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | −static void _wait_barrier(struct r1conf *conf, int idx) | |
| 932 | +static bool _wait_barrier(struct r1conf *conf, int idx, bool nowait) | |
| 933 | 933 | { |
| 934 | + bool ret = true; | |
| 935 | + | |
| 934 | 936 | /* |
| 935 | 937 | * We need to increase conf->nr_pending[idx] very early here, |
| 936 | 938 | * 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 | ||
| 961 | 963 | */ |
| 962 | 964 | if (!READ_ONCE(conf->array_frozen) && |
| 963 | 965 | !atomic_read(&conf->barrier[idx])) |
| 964 | − return; | |
| 966 | + return ret; | |
| 965 | 967 | |
| 966 | 968 | /* |
| 967 | 969 | * 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 | ||
| 979 | 981 | */ |
| 980 | 982 | wake_up(&conf->wait_barrier); |
| 981 | 983 | /* 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 | + | |
| 987 | 996 | atomic_dec(&conf->nr_waiting[idx]); |
| 988 | 997 | spin_unlock_irq(&conf->resync_lock); |
| 998 | + return ret; | |
| 989 | 999 | } |
| 990 | 1000 | |
| 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) | |
| 992 | 1002 | { |
| 993 | 1003 | int idx = sector_to_idx(sector_nr); |
| 1004 | + bool ret = true; | |
| 994 | 1005 | |
| 995 | 1006 | /* |
| 996 | 1007 | * 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 | ||
| 1002 | 1013 | atomic_inc(&conf->nr_pending[idx]); |
| 1003 | 1014 | |
| 1004 | 1015 | if (!READ_ONCE(conf->array_frozen)) |
| 1005 | − return; | |
| 1016 | + return ret; | |
| 1006 | 1017 | |
| 1007 | 1018 | spin_lock_irq(&conf->resync_lock); |
| 1008 | 1019 | 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 | ||
| 1013 | 1024 | */ |
| 1014 | 1025 | wake_up(&conf->wait_barrier); |
| 1015 | 1026 | /* 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 | + | |
| 1020 | 1039 | atomic_dec(&conf->nr_waiting[idx]); |
| 1021 | 1040 | spin_unlock_irq(&conf->resync_lock); |
| 1041 | + return ret; | |
| 1022 | 1042 | } |
| 1023 | 1043 | |
| 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) | |
| 1025 | 1045 | { |
| 1026 | 1046 | int idx = sector_to_idx(sector_nr); |
| 1027 | 1047 | |
| 1028 | − _wait_barrier(conf, idx); | |
| 1048 | + return _wait_barrier(conf, idx, nowait); | |
| 1029 | 1049 | } |
| 1030 | 1050 | |
| 1031 | 1051 | 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 | ||
| 1236 | 1256 | * Still need barrier for READ in case that whole |
| 1237 | 1257 | * array is frozen. |
| 1238 | 1258 | */ |
| 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 | + } | |
| 1240 | 1264 | |
| 1241 | 1265 | if (!r1_bio) |
| 1242 | 1266 | r1_bio = alloc_r1bio(mddev, bio); |
| @@ -1336,6 +1360,10 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 93 unmodified lines | ||
| 1336 | 1360 | bio->bi_iter.bi_sector, bio_end_sector(bio))) { |
| 1337 | 1361 | |
| 1338 | 1362 | DEFINE_WAIT(w); |
| 1363 | + if (bio->bi_opf & REQ_NOWAIT) { | |
| 1364 | + bio_wouldblock_error(bio); | |
| 1365 | + return; | |
| 1366 | + } | |
| 1339 | 1367 | for (;;) { |
| 1340 | 1368 | prepare_to_wait(&conf->wait_barrier, |
| 1341 | 1369 | &w, TASK_IDLE); |
| @@ -1353,17 +1381,15 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 11 unmodified lines | ||
| 1353 | 1381 | * thread has put up a bar for new requests. |
| 1354 | 1382 | * Continue immediately if no resync is active currently. |
| 1355 | 1383 | */ |
| 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 | + } | |
| 1357 | 1389 | |
| 1358 | 1390 | r1_bio = alloc_r1bio(mddev, bio); |
| 1359 | 1391 | r1_bio->sectors = max_write_sectors; |
| 1360 | 1392 | |
| 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 | − } | |
| 1367 | 1393 | /* first select target devices under rcu_lock and |
| 1368 | 1394 | * inc refcount on their rdev. Record them by setting |
| 1369 | 1395 | * bios[x] to bio |
| @@ -1458,9 +1484,14 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, · 88 unmodified lines | ||
| 1458 | 1484 | rdev_dec_pending(conf->mirrors[j].rdev, mddev); |
| 1459 | 1485 | r1_bio->state = 0; |
| 1460 | 1486 | allow_barrier(conf, bio->bi_iter.bi_sector); |
| 1487 | + | |
| 1488 | + if (bio->bi_opf & REQ_NOWAIT) { | |
| 1489 | + bio_wouldblock_error(bio); | |
| 1490 | + return; | |
| 1491 | + } | |
| 1461 | 1492 | raid1_log(mddev, "wait rdev %d blocked", blocked_rdev->raid_disk); |
| 1462 | 1493 | 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); | |
| 1464 | 1495 | goto retry_write; |
| 1465 | 1496 | } |
| 1466 | 1497 | |
| @@ -1688,7 +1719,7 @@ static void close_sync(struct r1conf *conf) · 221 unmodified lines | ||
| 1688 | 1719 | int idx; |
| 1689 | 1720 | |
| 1690 | 1721 | for (idx = 0; idx < BARRIER_BUCKETS_NR; idx++) { |
| 1691 | − _wait_barrier(conf, idx); | |
| 1722 | + _wait_barrier(conf, idx, false); | |
| 1692 | 1723 | _allow_barrier(conf, idx); |
| 1693 | 1724 | } |
| 1694 | 1725 | |
| @@ -3410,5 +3441,3 @@ MODULE_DESCRIPTION("RAID1 (mirroring) personality for MD"); · 1715 unmodified lines | ||
| 3410 | 3441 | MODULE_ALIAS("md-personality-3"); /* RAID1 */ |
| 3411 | 3442 | MODULE_ALIAS("md-raid1"); |
| 3412 | 3443 | MODULE_ALIAS("md-level-1"); |
| 3413 | − | |
| 3414 | −module_param(max_queued_requests, int, S_IRUGO|S_IWUSR); | |
| @@ -952,8 +952,10 @@ static void lower_barrier(struct r10conf *conf) · 951 unmodified lines | ||
| 952 | 952 | wake_up(&conf->wait_barrier); |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | −static void wait_barrier(struct r10conf *conf) | |
| 955 | +static bool wait_barrier(struct r10conf *conf, bool nowait) | |
| 956 | 956 | { |
| 957 | + bool ret = true; | |
| 958 | + | |
| 957 | 959 | spin_lock_irq(&conf->resync_lock); |
| 958 | 960 | if (conf->barrier) { |
| 959 | 961 | struct bio_list *bio_list = current->bio_list; |
| @@ -967,27 +969,35 @@ static void wait_barrier(struct r10conf *conf) · 7 unmodified lines | ||
| 967 | 969 | * that queue to get the nr_pending |
| 968 | 970 | * count down. |
| 969 | 971 | */ |
| 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 | + } | |
| 985 | 992 | conf->nr_waiting--; |
| 986 | 993 | if (!conf->nr_waiting) |
| 987 | 994 | wake_up(&conf->wait_barrier); |
| 988 | 995 | } |
| 989 | − atomic_inc(&conf->nr_pending); | |
| 996 | + /* Only increment nr_pending when we wait */ | |
| 997 | + if (ret) | |
| 998 | + atomic_inc(&conf->nr_pending); | |
| 990 | 999 | spin_unlock_irq(&conf->resync_lock); |
| 1000 | + return ret; | |
| 991 | 1001 | } |
| 992 | 1002 | |
| 993 | 1003 | 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 | ||
| 1098 | 1108 | * currently. |
| 1099 | 1109 | * 2. If IO spans the reshape position. Need to wait for reshape to pass. |
| 1100 | 1110 | */ |
| 1101 | −static void regular_request_wait(struct mddev *mddev, struct r10conf *conf, | |
| 1111 | +static bool regular_request_wait(struct mddev *mddev, struct r10conf *conf, | |
| 1102 | 1112 | struct bio *bio, sector_t sectors) |
| 1103 | 1113 | { |
| 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 | + } | |
| 1105 | 1119 | while (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && |
| 1106 | 1120 | bio->bi_iter.bi_sector < conf->reshape_progress && |
| 1107 | 1121 | bio->bi_iter.bi_sector + sectors > conf->reshape_progress) { |
| 1108 | − raid10_log(conf->mddev, "wait reshape"); | |
| 1109 | 1122 | 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"); | |
| 1110 | 1128 | wait_event(conf->wait_barrier, |
| 1111 | 1129 | conf->reshape_progress <= bio->bi_iter.bi_sector || |
| 1112 | 1130 | conf->reshape_progress >= bio->bi_iter.bi_sector + |
| 1113 | 1131 | sectors); |
| 1114 | − wait_barrier(conf); | |
| 1132 | + wait_barrier(conf, false); | |
| 1115 | 1133 | } |
| 1134 | + return true; | |
| 1116 | 1135 | } |
| 1117 | 1136 | |
| 1118 | 1137 | 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 | ||
| 1157 | 1176 | rcu_read_unlock(); |
| 1158 | 1177 | } |
| 1159 | 1178 | |
| 1160 | − regular_request_wait(mddev, conf, bio, r10_bio->sectors); | |
| 1179 | + if (!regular_request_wait(mddev, conf, bio, r10_bio->sectors)) | |
| 1180 | + return; | |
| 1161 | 1181 | rdev = read_balance(conf, r10_bio, &max_sectors); |
| 1162 | 1182 | if (!rdev) { |
| 1163 | 1183 | if (err_rdev) { |
| @@ -1179,7 +1199,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, · 15 unmodified lines | ||
| 1179 | 1199 | bio_chain(split, bio); |
| 1180 | 1200 | allow_barrier(conf); |
| 1181 | 1201 | submit_bio_noacct(bio); |
| 1182 | − wait_barrier(conf); | |
| 1202 | + wait_barrier(conf, false); | |
| 1183 | 1203 | bio = split; |
| 1184 | 1204 | r10_bio->master_bio = bio; |
| 1185 | 1205 | r10_bio->sectors = max_sectors; |
| @@ -1338,7 +1358,7 @@ retry_wait: · 152 unmodified lines | ||
| 1338 | 1358 | raid10_log(conf->mddev, "%s wait rdev %d blocked", |
| 1339 | 1359 | __func__, blocked_rdev->raid_disk); |
| 1340 | 1360 | md_wait_for_blocked_rdev(blocked_rdev, mddev); |
| 1341 | − wait_barrier(conf); | |
| 1361 | + wait_barrier(conf, false); | |
| 1342 | 1362 | goto retry_wait; |
| 1343 | 1363 | } |
| 1344 | 1364 | } |
| @@ -1356,6 +1376,11 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 11 unmodified lines | ||
| 1356 | 1376 | bio->bi_iter.bi_sector, |
| 1357 | 1377 | bio_end_sector(bio)))) { |
| 1358 | 1378 | 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 | + } | |
| 1359 | 1384 | for (;;) { |
| 1360 | 1385 | prepare_to_wait(&conf->wait_barrier, |
| 1361 | 1386 | &w, TASK_IDLE); |
| @@ -1368,7 +1393,8 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 6 unmodified lines | ||
| 1368 | 1393 | } |
| 1369 | 1394 | |
| 1370 | 1395 | sectors = r10_bio->sectors; |
| 1371 | − regular_request_wait(mddev, conf, bio, sectors); | |
| 1396 | + if (!regular_request_wait(mddev, conf, bio, sectors)) | |
| 1397 | + return; | |
| 1372 | 1398 | if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery) && |
| 1373 | 1399 | (mddev->reshape_backwards |
| 1374 | 1400 | ? (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 | ||
| 1380 | 1406 | set_mask_bits(&mddev->sb_flags, 0, |
| 1381 | 1407 | BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING)); |
| 1382 | 1408 | md_wakeup_thread(mddev->thread); |
| 1409 | + if (bio->bi_opf & REQ_NOWAIT) { | |
| 1410 | + allow_barrier(conf); | |
| 1411 | + bio_wouldblock_error(bio); | |
| 1412 | + return; | |
| 1413 | + } | |
| 1383 | 1414 | raid10_log(conf->mddev, "wait reshape metadata"); |
| 1384 | 1415 | wait_event(mddev->sb_wait, |
| 1385 | 1416 | !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 | ||
| 1387 | 1418 | conf->reshape_safe = mddev->reshape_position; |
| 1388 | 1419 | } |
| 1389 | 1420 | |
| 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 | − } | |
| 1396 | 1421 | /* first select target devices under rcu_lock and |
| 1397 | 1422 | * inc refcount on their rdev. Record them by setting |
| 1398 | 1423 | * bios[x] to bio |
| @@ -1482,7 +1507,7 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, · 83 unmodified lines | ||
| 1482 | 1507 | bio_chain(split, bio); |
| 1483 | 1508 | allow_barrier(conf); |
| 1484 | 1509 | submit_bio_noacct(bio); |
| 1485 | − wait_barrier(conf); | |
| 1510 | + wait_barrier(conf, false); | |
| 1486 | 1511 | bio = split; |
| 1487 | 1512 | r10_bio->master_bio = bio; |
| 1488 | 1513 | } |
| @@ -1607,7 +1632,11 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) · 118 unmodified lines | ||
| 1607 | 1632 | if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) |
| 1608 | 1633 | return -EAGAIN; |
| 1609 | 1634 | |
| 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); | |
| 1611 | 1640 | |
| 1612 | 1641 | /* |
| 1613 | 1642 | * 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 | ||
| 1649 | 1678 | allow_barrier(conf); |
| 1650 | 1679 | /* Resend the fist split part */ |
| 1651 | 1680 | submit_bio_noacct(split); |
| 1652 | − wait_barrier(conf); | |
| 1681 | + wait_barrier(conf, false); | |
| 1653 | 1682 | } |
| 1654 | 1683 | div_u64_rem(bio_end, stripe_size, &remainder); |
| 1655 | 1684 | if (remainder) { |
| @@ -1660,7 +1689,7 @@ static int raid10_handle_discard(struct mddev *mddev, struct bio *bio) · 4 unmodified lines | ||
| 1660 | 1689 | /* Resend the second split part */ |
| 1661 | 1690 | submit_bio_noacct(bio); |
| 1662 | 1691 | bio = split; |
| 1663 | − wait_barrier(conf); | |
| 1692 | + wait_barrier(conf, false); | |
| 1664 | 1693 | } |
| 1665 | 1694 | |
| 1666 | 1695 | bio_start = bio->bi_iter.bi_sector; |
| @@ -1816,7 +1845,7 @@ retry_discard: · 149 unmodified lines | ||
| 1816 | 1845 | end_disk_offset += geo->stride; |
| 1817 | 1846 | atomic_inc(&first_r10bio->remaining); |
| 1818 | 1847 | raid_end_discard_bio(r10_bio); |
| 1819 | − wait_barrier(conf); | |
| 1848 | + wait_barrier(conf, false); | |
| 1820 | 1849 | goto retry_discard; |
| 1821 | 1850 | } |
| 1822 | 1851 | |
| @@ -2011,7 +2040,7 @@ static void print_conf(struct r10conf *conf) · 188 unmodified lines | ||
| 2011 | 2040 | |
| 2012 | 2041 | static void close_sync(struct r10conf *conf) |
| 2013 | 2042 | { |
| 2014 | − wait_barrier(conf); | |
| 2043 | + wait_barrier(conf, false); | |
| 2015 | 2044 | allow_barrier(conf); |
| 2016 | 2045 | |
| 2017 | 2046 | mempool_exit(&conf->r10buf_pool); |
| @@ -4819,7 +4848,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, · 2801 unmodified lines | ||
| 4819 | 4848 | if (need_flush || |
| 4820 | 4849 | time_after(jiffies, conf->reshape_checkpoint + 10*HZ)) { |
| 4821 | 4850 | /* Need to update reshape_position in metadata */ |
| 4822 | − wait_barrier(conf); | |
| 4851 | + wait_barrier(conf, false); | |
| 4823 | 4852 | mddev->reshape_position = conf->reshape_progress; |
| 4824 | 4853 | if (mddev->reshape_backwards) |
| 4825 | 4854 | mddev->curr_resync_completed = raid10_size(mddev, 0, 0) |
| @@ -5242,5 +5271,3 @@ MODULE_DESCRIPTION("RAID10 (striped mirror) personality for MD"); · 416 unmodified lines | ||
| 5242 | 5271 | MODULE_ALIAS("md-personality-9"); /* RAID10 */ |
| 5243 | 5272 | MODULE_ALIAS("md-raid10"); |
| 5244 | 5273 | MODULE_ALIAS("md-level-10"); |
| 5245 | − | |
| 5246 | −module_param(max_queued_requests, int, S_IRUGO|S_IWUSR); | |
| @@ -2215,10 +2215,9 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) · 2214 unmodified lines | ||
| 2215 | 2215 | struct r5conf *conf = sh->raid_conf; |
| 2216 | 2216 | int level = conf->level; |
| 2217 | 2217 | struct raid5_percpu *percpu; |
| 2218 | − unsigned long cpu; | |
| 2219 | 2218 | |
| 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); | |
| 2222 | 2221 | if (test_bit(STRIPE_OP_BIOFILL, &ops_request)) { |
| 2223 | 2222 | ops_run_biofill(sh); |
| 2224 | 2223 | overlap_clear++; |
| @@ -2271,13 +2270,14 @@ static void raid_run_ops(struct stripe_head *sh, unsigned long ops_request) · 46 unmodified lines | ||
| 2271 | 2270 | BUG(); |
| 2272 | 2271 | } |
| 2273 | 2272 | |
| 2274 | − if (overlap_clear && !sh->batch_head) | |
| 2273 | + if (overlap_clear && !sh->batch_head) { | |
| 2275 | 2274 | for (i = disks; i--; ) { |
| 2276 | 2275 | struct r5dev *dev = &sh->dev[i]; |
| 2277 | 2276 | if (test_and_clear_bit(R5_Overlap, &dev->flags)) |
| 2278 | 2277 | wake_up(&sh->raid_conf->wait_for_overlap); |
| 2279 | 2278 | } |
| 2280 | − put_cpu(); | |
| 2279 | + } | |
| 2280 | + local_unlock(&conf->percpu->lock); | |
| 2281 | 2281 | } |
| 2282 | 2282 | |
| 2283 | 2283 | 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 | ||
| 5686 | 5686 | struct stripe_head *sh; |
| 5687 | 5687 | int stripe_sectors; |
| 5688 | 5688 | |
| 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 | + | |
| 5689 | 5693 | if (mddev->reshape_position != MaxSector) |
| 5690 | 5694 | /* Skip discard while reshape is happening */ |
| 5691 | 5695 | return; |
| @@ -5819,6 +5823,17 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi) · 127 unmodified lines | ||
| 5819 | 5823 | last_sector = bio_end_sector(bi); |
| 5820 | 5824 | bi->bi_next = NULL; |
| 5821 | 5825 | |
| 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 | + } | |
| 5822 | 5837 | md_account_bio(mddev, &bi); |
| 5823 | 5838 | prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE); |
| 5824 | 5839 | 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 | ||
| 7052 | 7067 | return -ENOMEM; |
| 7053 | 7068 | } |
| 7054 | 7069 | |
| 7070 | + local_lock_init(&percpu->lock); | |
| 7055 | 7071 | return 0; |
| 7056 | 7072 | } |
| 7057 | 7073 | |
| @@ -7446,12 +7462,19 @@ static int raid5_run(struct mddev *mddev) · 388 unmodified lines | ||
| 7446 | 7462 | struct md_rdev *rdev; |
| 7447 | 7463 | struct md_rdev *journal_dev = NULL; |
| 7448 | 7464 | sector_t reshape_offset = 0; |
| 7449 | − int i; | |
| 7465 | + int i, ret = 0; | |
| 7450 | 7466 | long long min_offset_diff = 0; |
| 7451 | 7467 | int first = 1; |
| 7452 | 7468 | |
| 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)); | |
| 7454 | 7471 | return -ENOMEM; |
| 7472 | + } | |
| 7473 | + | |
| 7474 | + if (mddev_init_writes_pending(mddev) < 0) { | |
| 7475 | + ret = -ENOMEM; | |
| 7476 | + goto exit_acct_set; | |
| 7477 | + } | |
| 7455 | 7478 | |
| 7456 | 7479 | if (mddev->recovery_cp != MaxSector) |
| 7457 | 7480 | 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 | ||
| 7482 | 7505 | (mddev->bitmap_info.offset || mddev->bitmap_info.file)) { |
| 7483 | 7506 | pr_notice("md/raid:%s: array cannot have both journal and bitmap\n", |
| 7484 | 7507 | mdname(mddev)); |
| 7485 | − return -EINVAL; | |
| 7508 | + ret = -EINVAL; | |
| 7509 | + goto exit_acct_set; | |
| 7486 | 7510 | } |
| 7487 | 7511 | |
| 7488 | 7512 | if (mddev->reshape_position != MaxSector) { |
| @@ -7507,13 +7531,15 @@ static int raid5_run(struct mddev *mddev) · 18 unmodified lines | ||
| 7507 | 7531 | if (journal_dev) { |
| 7508 | 7532 | pr_warn("md/raid:%s: don't support reshape with journal - aborting.\n", |
| 7509 | 7533 | mdname(mddev)); |
| 7510 | − return -EINVAL; | |
| 7534 | + ret = -EINVAL; | |
| 7535 | + goto exit_acct_set; | |
| 7511 | 7536 | } |
| 7512 | 7537 | |
| 7513 | 7538 | if (mddev->new_level != mddev->level) { |
| 7514 | 7539 | pr_warn("md/raid:%s: unsupported reshape required - aborting.\n", |
| 7515 | 7540 | mdname(mddev)); |
| 7516 | − return -EINVAL; | |
| 7541 | + ret = -EINVAL; | |
| 7542 | + goto exit_acct_set; | |
| 7517 | 7543 | } |
| 7518 | 7544 | old_disks = mddev->raid_disks - mddev->delta_disks; |
| 7519 | 7545 | /* 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 | ||
| 7529 | 7555 | if (sector_div(here_new, chunk_sectors * new_data_disks)) { |
| 7530 | 7556 | pr_warn("md/raid:%s: reshape_position not on a stripe boundary\n", |
| 7531 | 7557 | mdname(mddev)); |
| 7532 | − return -EINVAL; | |
| 7558 | + ret = -EINVAL; | |
| 7559 | + goto exit_acct_set; | |
| 7533 | 7560 | } |
| 7534 | 7561 | reshape_offset = here_new * chunk_sectors; |
| 7535 | 7562 | /* here_new is the stripe we will write to */ |
| @@ -7551,7 +7578,8 @@ static int raid5_run(struct mddev *mddev) · 15 unmodified lines | ||
| 7551 | 7578 | else if (mddev->ro == 0) { |
| 7552 | 7579 | pr_warn("md/raid:%s: in-place reshape must be started in read-only mode - aborting\n", |
| 7553 | 7580 | mdname(mddev)); |
| 7554 | − return -EINVAL; | |
| 7581 | + ret = -EINVAL; | |
| 7582 | + goto exit_acct_set; | |
| 7555 | 7583 | } |
| 7556 | 7584 | } else if (mddev->reshape_backwards |
| 7557 | 7585 | ? (here_new * chunk_sectors + min_offset_diff <= |
| @@ -7561,7 +7589,8 @@ static int raid5_run(struct mddev *mddev) · 3 unmodified lines | ||
| 7561 | 7589 | /* Reading from the same stripe as writing to - bad */ |
| 7562 | 7590 | pr_warn("md/raid:%s: reshape_position too early for auto-recovery - aborting.\n", |
| 7563 | 7591 | mdname(mddev)); |
| 7564 | − return -EINVAL; | |
| 7592 | + ret = -EINVAL; | |
| 7593 | + goto exit_acct_set; | |
| 7565 | 7594 | } |
| 7566 | 7595 | pr_debug("md/raid:%s: reshape will continue\n", mdname(mddev)); |
| 7567 | 7596 | /* OK, we should be able to continue; */ |
| @@ -7585,8 +7614,10 @@ static int raid5_run(struct mddev *mddev) · 17 unmodified lines | ||
| 7585 | 7614 | else |
| 7586 | 7615 | conf = mddev->private; |
| 7587 | 7616 | |
| 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 | + } | |
| 7590 | 7621 | |
| 7591 | 7622 | if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) { |
| 7592 | 7623 | if (!journal_dev) { |
| @@ -7783,7 +7814,10 @@ abort: · 190 unmodified lines | ||
| 7783 | 7814 | free_conf(conf); |
| 7784 | 7815 | mddev->private = NULL; |
| 7785 | 7816 | 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; | |
| 7787 | 7821 | } |
| 7788 | 7822 | |
| 7789 | 7823 | 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 | ||
| 7791 | 7825 | struct r5conf *conf = priv; |
| 7792 | 7826 | |
| 7793 | 7827 | free_conf(conf); |
| 7828 | + acct_bioset_exit(mddev); | |
| 7794 | 7829 | mddev->to_remove = &raid5_attrs_group; |
| 7795 | 7830 | } |
| 7796 | 7831 | |
| @@ -4,6 +4,7 @@ · 3 unmodified lines | ||
| 4 | 4 | |
| 5 | 5 | #include <linux/raid/xor.h> |
| 6 | 6 | #include <linux/dmaengine.h> |
| 7 | +#include <linux/local_lock.h> | |
| 7 | 8 | |
| 8 | 9 | /* |
| 9 | 10 | * |
| @@ -640,7 +641,8 @@ struct r5conf { · 630 unmodified lines | ||
| 640 | 641 | * lists and performing address |
| 641 | 642 | * conversions |
| 642 | 643 | */ |
| 643 | − int scribble_obj_size; | |
| 644 | + int scribble_obj_size; | |
| 645 | + local_lock_t lock; | |
| 644 | 646 | } __percpu *percpu; |
| 645 | 647 | int scribble_disks; |
| 646 | 648 | int scribble_sectors; |