static inline struct hlist_head *stripe_hash(struct r5conf *conf, sector_t sect)
 {
-       int hash = (sect >> STRIPE_SHIFT) & HASH_MASK;
+       int hash = (sect >> RAID5_STRIPE_SHIFT(conf)) & HASH_MASK;
        return &conf->stripe_hashtbl[hash];
 }
 
-static inline int stripe_hash_locks_hash(sector_t sect)
+static inline int stripe_hash_locks_hash(struct r5conf *conf, sector_t sect)
 {
-       return (sect >> STRIPE_SHIFT) & STRIPE_HASH_LOCKS_MASK;
+       return (sect >> RAID5_STRIPE_SHIFT(conf)) & STRIPE_HASH_LOCKS_MASK;
 }
 
 static inline void lock_device_hash_lock(struct r5conf *conf, int hash)
                        int previous, int noblock, int noquiesce)
 {
        struct stripe_head *sh;
-       int hash = stripe_hash_locks_hash(sector);
+       int hash = stripe_hash_locks_hash(conf, sector);
        int inc_empty_inactive_list_flag;
 
        pr_debug("get_stripe, sector %llu\n", (unsigned long long)sector);
        tmp_sec = sh->sector;
        if (!sector_div(tmp_sec, conf->chunk_sectors))
                return;
-       head_sector = sh->sector - STRIPE_SECTORS;
+       head_sector = sh->sector - RAID5_STRIPE_SECTORS(conf);
 
-       hash = stripe_hash_locks_hash(head_sector);
+       hash = stripe_hash_locks_hash(conf, head_sector);
        spin_lock_irq(conf->hash_locks + hash);
        head = __find_stripe(conf, head_sector, conf->generation);
        if (head && !atomic_inc_not_zero(&head->count)) {
                       test_bit(WriteErrorSeen, &rdev->flags)) {
                        sector_t first_bad;
                        int bad_sectors;
-                       int bad = is_badblock(rdev, sh->sector, STRIPE_SECTORS,
+                       int bad = is_badblock(rdev, sh->sector, RAID5_STRIPE_SECTORS(conf),
                                              &first_bad, &bad_sectors);
                        if (!bad)
                                break;
                if (rdev) {
                        if (s->syncing || s->expanding || s->expanded
                            || s->replacing)
-                               md_sync_acct(rdev->bdev, STRIPE_SECTORS);
+                               md_sync_acct(rdev->bdev, RAID5_STRIPE_SECTORS(conf));
 
                        set_bit(STRIPE_IO_STARTED, &sh->state);
 
                        else
                                sh->dev[i].vec.bv_page = sh->dev[i].page;
                        bi->bi_vcnt = 1;
-                       bi->bi_io_vec[0].bv_len = STRIPE_SIZE;
+                       bi->bi_io_vec[0].bv_len = RAID5_STRIPE_SIZE(conf);
                        bi->bi_io_vec[0].bv_offset = 0;
-                       bi->bi_iter.bi_size = STRIPE_SIZE;
+                       bi->bi_iter.bi_size = RAID5_STRIPE_SIZE(conf);
                        bi->bi_write_hint = sh->dev[i].write_hint;
                        if (!rrdev)
                                sh->dev[i].write_hint = RWH_WRITE_LIFE_NOT_SET;
                if (rrdev) {
                        if (s->syncing || s->expanding || s->expanded
                            || s->replacing)
-                               md_sync_acct(rrdev->bdev, STRIPE_SECTORS);
+                               md_sync_acct(rrdev->bdev, RAID5_STRIPE_SECTORS(conf));
 
                        set_bit(STRIPE_IO_STARTED, &sh->state);
 
                                WARN_ON(test_bit(R5_UPTODATE, &sh->dev[i].flags));
                        sh->dev[i].rvec.bv_page = sh->dev[i].page;
                        rbi->bi_vcnt = 1;
-                       rbi->bi_io_vec[0].bv_len = STRIPE_SIZE;
+                       rbi->bi_io_vec[0].bv_len = RAID5_STRIPE_SIZE(conf);
                        rbi->bi_io_vec[0].bv_offset = 0;
-                       rbi->bi_iter.bi_size = STRIPE_SIZE;
+                       rbi->bi_iter.bi_size = RAID5_STRIPE_SIZE(conf);
                        rbi->bi_write_hint = sh->dev[i].write_hint;
                        sh->dev[i].write_hint = RWH_WRITE_LIFE_NOT_SET;
                        /*
        int page_offset;
        struct async_submit_ctl submit;
        enum async_tx_flags flags = 0;
+       struct r5conf *conf = sh->raid_conf;
 
        if (bio->bi_iter.bi_sector >= sector)
                page_offset = (signed)(bio->bi_iter.bi_sector - sector) * 512;
                        len -= b_offset;
                }
 
-               if (len > 0 && page_offset + len > STRIPE_SIZE)
-                       clen = STRIPE_SIZE - page_offset;
+               if (len > 0 && page_offset + len > RAID5_STRIPE_SIZE(conf))
+                       clen = RAID5_STRIPE_SIZE(conf) - page_offset;
                else
                        clen = len;
 
                        b_offset += bvl.bv_offset;
                        bio_page = bvl.bv_page;
                        if (frombio) {
-                               if (sh->raid_conf->skip_copy &&
+                               if (conf->skip_copy &&
                                    b_offset == 0 && page_offset == 0 &&
-                                   clen == STRIPE_SIZE &&
+                                   clen == RAID5_STRIPE_SIZE(conf) &&
                                    !no_skipcopy)
                                        *page = bio_page;
                                else
 {
        struct stripe_head *sh = stripe_head_ref;
        int i;
+       struct r5conf *conf = sh->raid_conf;
 
        pr_debug("%s: stripe %llu\n", __func__,
                (unsigned long long)sh->sector);
                        rbi = dev->read;
                        dev->read = NULL;
                        while (rbi && rbi->bi_iter.bi_sector <
-                               dev->sector + STRIPE_SECTORS) {
-                               rbi2 = r5_next_bio(rbi, dev->sector);
+                               dev->sector + RAID5_STRIPE_SECTORS(conf)) {
+                               rbi2 = r5_next_bio(conf, rbi, dev->sector);
                                bio_endio(rbi);
                                rbi = rbi2;
                        }
        struct dma_async_tx_descriptor *tx = NULL;
        struct async_submit_ctl submit;
        int i;
+       struct r5conf *conf = sh->raid_conf;
 
        BUG_ON(sh->batch_head);
        pr_debug("%s: stripe %llu\n", __func__,
                        dev->toread = NULL;
                        spin_unlock_irq(&sh->stripe_lock);
                        while (rbi && rbi->bi_iter.bi_sector <
-                               dev->sector + STRIPE_SECTORS) {
+                               dev->sector + RAID5_STRIPE_SECTORS(conf)) {
                                tx = async_copy_data(0, rbi, &dev->page,
                                                     dev->sector, tx, sh, 0);
-                               rbi = r5_next_bio(rbi, dev->sector);
+                               rbi = r5_next_bio(conf, rbi, dev->sector);
                        }
                }
        }
        init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_XOR_ZERO_DST, NULL,
                          ops_complete_compute, sh, to_addr_conv(sh, percpu, 0));
        if (unlikely(count == 1))
-               tx = async_memcpy(xor_dest, xor_srcs[0], 0, 0, STRIPE_SIZE, &submit);
+               tx = async_memcpy(xor_dest, xor_srcs[0], 0, 0,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
        else
-               tx = async_xor(xor_dest, xor_srcs, 0, count, STRIPE_SIZE, &submit);
+               tx = async_xor(xor_dest, xor_srcs, 0, count,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
 
        return tx;
 }
                init_async_submit(&submit, ASYNC_TX_FENCE, NULL,
                                  ops_complete_compute, sh,
                                  to_addr_conv(sh, percpu, 0));
-               tx = async_gen_syndrome(blocks, 0, count+2, STRIPE_SIZE, &submit);
+               tx = async_gen_syndrome(blocks, 0, count+2,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
        } else {
                /* Compute any data- or p-drive using XOR */
                count = 0;
                init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_XOR_ZERO_DST,
                                  NULL, ops_complete_compute, sh,
                                  to_addr_conv(sh, percpu, 0));
-               tx = async_xor(dest, blocks, 0, count, STRIPE_SIZE, &submit);
+               tx = async_xor(dest, blocks, 0, count,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
        }
 
        return tx;
                                          ops_complete_compute, sh,
                                          to_addr_conv(sh, percpu, 0));
                        return async_gen_syndrome(blocks, 0, syndrome_disks+2,
-                                                 STRIPE_SIZE, &submit);
+                                                 RAID5_STRIPE_SIZE(sh->raid_conf),
+                                                 &submit);
                } else {
                        struct page *dest;
                        int data_target;
                                          ASYNC_TX_FENCE|ASYNC_TX_XOR_ZERO_DST,
                                          NULL, NULL, NULL,
                                          to_addr_conv(sh, percpu, 0));
-                       tx = async_xor(dest, blocks, 0, count, STRIPE_SIZE,
+                       tx = async_xor(dest, blocks, 0, count,
+                                      RAID5_STRIPE_SIZE(sh->raid_conf),
                                       &submit);
 
                        count = set_syndrome_sources(blocks, sh, SYNDROME_SRC_ALL);
                                          ops_complete_compute, sh,
                                          to_addr_conv(sh, percpu, 0));
                        return async_gen_syndrome(blocks, 0, count+2,
-                                                 STRIPE_SIZE, &submit);
+                                                 RAID5_STRIPE_SIZE(sh->raid_conf),
+                                                 &submit);
                }
        } else {
                init_async_submit(&submit, ASYNC_TX_FENCE, NULL,
                if (failb == syndrome_disks) {
                        /* We're missing D+P. */
                        return async_raid6_datap_recov(syndrome_disks+2,
-                                                      STRIPE_SIZE, faila,
-                                                      blocks, &submit);
+                                               RAID5_STRIPE_SIZE(sh->raid_conf),
+                                               faila,
+                                               blocks, &submit);
                } else {
                        /* We're missing D+D. */
                        return async_raid6_2data_recov(syndrome_disks+2,
-                                                      STRIPE_SIZE, faila, failb,
-                                                      blocks, &submit);
+                                               RAID5_STRIPE_SIZE(sh->raid_conf),
+                                               faila, failb,
+                                               blocks, &submit);
                }
        }
 }
 
        init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_XOR_DROP_DST, tx,
                          ops_complete_prexor, sh, to_addr_conv(sh, percpu, 0));
-       tx = async_xor(xor_dest, xor_srcs, 0, count, STRIPE_SIZE, &submit);
+       tx = async_xor(xor_dest, xor_srcs, 0, count,
+                       RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
 
        return tx;
 }
 
        init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_PQ_XOR_DST, tx,
                          ops_complete_prexor, sh, to_addr_conv(sh, percpu, 0));
-       tx = async_gen_syndrome(blocks, 0, count+2, STRIPE_SIZE,  &submit);
+       tx = async_gen_syndrome(blocks, 0, count+2,
+                       RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
 
        return tx;
 }
                        WARN_ON(dev->page != dev->orig_page);
 
                        while (wbi && wbi->bi_iter.bi_sector <
-                               dev->sector + STRIPE_SECTORS) {
+                               dev->sector + RAID5_STRIPE_SECTORS(conf)) {
                                if (wbi->bi_opf & REQ_FUA)
                                        set_bit(R5_WantFUA, &dev->flags);
                                if (wbi->bi_opf & REQ_SYNC)
                                                clear_bit(R5_OVERWRITE, &dev->flags);
                                        }
                                }
-                               wbi = r5_next_bio(wbi, dev->sector);
+                               wbi = r5_next_bio(conf, wbi, dev->sector);
                        }
 
                        if (head_sh->batch_head) {
        }
 
        if (unlikely(count == 1))
-               tx = async_memcpy(xor_dest, xor_srcs[0], 0, 0, STRIPE_SIZE, &submit);
+               tx = async_memcpy(xor_dest, xor_srcs[0], 0, 0,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
        else
-               tx = async_xor(xor_dest, xor_srcs, 0, count, STRIPE_SIZE, &submit);
+               tx = async_xor(xor_dest, xor_srcs, 0, count,
+                               RAID5_STRIPE_SIZE(sh->raid_conf), &submit);
        if (!last_stripe) {
                j++;
                sh = list_first_entry(&sh->batch_list, struct stripe_head,
        } else
                init_async_submit(&submit, 0, tx, NULL, NULL,
                                  to_addr_conv(sh, percpu, j));
-       tx = async_gen_syndrome(blocks, 0, count+2, STRIPE_SIZE,  &submit);
+       tx = async_gen_syndrome(blocks, 0, count+2,
+                       RAID5_STRIPE_SIZE(sh->raid_conf),  &submit);
        if (!last_stripe) {
                j++;
                sh = list_first_entry(&sh->batch_list, struct stripe_head,
 
        init_async_submit(&submit, 0, NULL, NULL, NULL,
                          to_addr_conv(sh, percpu, 0));
-       tx = async_xor_val(xor_dest, xor_srcs, 0, count, STRIPE_SIZE,
+       tx = async_xor_val(xor_dest, xor_srcs, 0, count,
+                          RAID5_STRIPE_SIZE(sh->raid_conf),
                           &sh->ops.zero_sum_result, &submit);
 
        atomic_inc(&sh->count);
        atomic_inc(&sh->count);
        init_async_submit(&submit, ASYNC_TX_ACK, NULL, ops_complete_check,
                          sh, to_addr_conv(sh, percpu, 0));
-       async_syndrome_val(srcs, 0, count+2, STRIPE_SIZE,
+       async_syndrome_val(srcs, 0, count+2,
+                          RAID5_STRIPE_SIZE(sh->raid_conf),
                           &sh->ops.zero_sum_result, percpu->spare_page, &submit);
 }
 
 
                percpu = per_cpu_ptr(conf->percpu, cpu);
                err = scribble_alloc(percpu, new_disks,
-                                    new_sectors / STRIPE_SECTORS);
+                                    new_sectors / RAID5_STRIPE_SECTORS(conf));
                if (err)
                        break;
        }
                         */
                        pr_info_ratelimited(
                                "md/raid:%s: read error corrected (%lu sectors at %llu on %s)\n",
-                               mdname(conf->mddev), STRIPE_SECTORS,
+                               mdname(conf->mddev), RAID5_STRIPE_SECTORS(conf),
                                (unsigned long long)s,
                                bdevname(rdev->bdev, b));
-                       atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
+                       atomic_add(RAID5_STRIPE_SECTORS(conf), &rdev->corrected_errors);
                        clear_bit(R5_ReadError, &sh->dev[i].flags);
                        clear_bit(R5_ReWrite, &sh->dev[i].flags);
                } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
                        if (!(set_bad
                              && test_bit(In_sync, &rdev->flags)
                              && rdev_set_badblocks(
-                                     rdev, sh->sector, STRIPE_SECTORS, 0)))
+                                     rdev, sh->sector, RAID5_STRIPE_SECTORS(conf), 0)))
                                md_error(conf->mddev, rdev);
                }
        }
                if (bi->bi_status)
                        md_error(conf->mddev, rdev);
                else if (is_badblock(rdev, sh->sector,
-                                    STRIPE_SECTORS,
+                                    RAID5_STRIPE_SECTORS(conf),
                                     &first_bad, &bad_sectors))
                        set_bit(R5_MadeGoodRepl, &sh->dev[i].flags);
        } else {
                                set_bit(MD_RECOVERY_NEEDED,
                                        &rdev->mddev->recovery);
                } else if (is_badblock(rdev, sh->sector,
-                                      STRIPE_SECTORS,
+                                      RAID5_STRIPE_SECTORS(conf),
                                       &first_bad, &bad_sectors)) {
                        set_bit(R5_MadeGood, &sh->dev[i].flags);
                        if (test_bit(R5_ReadError, &sh->dev[i].flags))
                /* check if page is covered */
                sector_t sector = sh->dev[dd_idx].sector;
                for (bi=sh->dev[dd_idx].towrite;
-                    sector < sh->dev[dd_idx].sector + STRIPE_SECTORS &&
+                    sector < sh->dev[dd_idx].sector + RAID5_STRIPE_SECTORS(conf) &&
                             bi && bi->bi_iter.bi_sector <= sector;
-                    bi = r5_next_bio(bi, sh->dev[dd_idx].sector)) {
+                    bi = r5_next_bio(conf, bi, sh->dev[dd_idx].sector)) {
                        if (bio_end_sector(bi) >= sector)
                                sector = bio_end_sector(bi);
                }
-               if (sector >= sh->dev[dd_idx].sector + STRIPE_SECTORS)
+               if (sector >= sh->dev[dd_idx].sector + RAID5_STRIPE_SECTORS(conf))
                        if (!test_and_set_bit(R5_OVERWRITE, &sh->dev[dd_idx].flags))
                                sh->overwrite_disks++;
        }
                set_bit(STRIPE_BITMAP_PENDING, &sh->state);
                spin_unlock_irq(&sh->stripe_lock);
                md_bitmap_startwrite(conf->mddev->bitmap, sh->sector,
-                                    STRIPE_SECTORS, 0);
+                                    RAID5_STRIPE_SECTORS(conf), 0);
                spin_lock_irq(&sh->stripe_lock);
                clear_bit(STRIPE_BITMAP_PENDING, &sh->state);
                if (!sh->batch_head) {
                                if (!rdev_set_badblocks(
                                            rdev,
                                            sh->sector,
-                                           STRIPE_SECTORS, 0))
+                                           RAID5_STRIPE_SECTORS(conf), 0))
                                        md_error(conf->mddev, rdev);
                                rdev_dec_pending(rdev, conf->mddev);
                        }
                        wake_up(&conf->wait_for_overlap);
 
                while (bi && bi->bi_iter.bi_sector <
-                       sh->dev[i].sector + STRIPE_SECTORS) {
-                       struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
+                       sh->dev[i].sector + RAID5_STRIPE_SECTORS(conf)) {
+                       struct bio *nextbi = r5_next_bio(conf, bi, sh->dev[i].sector);
 
                        md_write_end(conf->mddev);
                        bio_io_error(bi);
                }
                if (bitmap_end)
                        md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
-                                          STRIPE_SECTORS, 0, 0);
+                                          RAID5_STRIPE_SECTORS(conf), 0, 0);
                bitmap_end = 0;
                /* and fail all 'written' */
                bi = sh->dev[i].written;
 
                if (bi) bitmap_end = 1;
                while (bi && bi->bi_iter.bi_sector <
-                      sh->dev[i].sector + STRIPE_SECTORS) {
-                       struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector);
+                      sh->dev[i].sector + RAID5_STRIPE_SECTORS(conf)) {
+                       struct bio *bi2 = r5_next_bio(conf, bi, sh->dev[i].sector);
 
                        md_write_end(conf->mddev);
                        bio_io_error(bi);
                        if (bi)
                                s->to_read--;
                        while (bi && bi->bi_iter.bi_sector <
-                              sh->dev[i].sector + STRIPE_SECTORS) {
+                              sh->dev[i].sector + RAID5_STRIPE_SECTORS(conf)) {
                                struct bio *nextbi =
-                                       r5_next_bio(bi, sh->dev[i].sector);
+                                       r5_next_bio(conf, bi, sh->dev[i].sector);
 
                                bio_io_error(bi);
                                bi = nextbi;
                }
                if (bitmap_end)
                        md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
-                                          STRIPE_SECTORS, 0, 0);
+                                          RAID5_STRIPE_SECTORS(conf), 0, 0);
                /* If we were in the middle of a write the parity block might
                 * still be locked - so just clear all R5_LOCKED flags
                 */
                            && !test_bit(Faulty, &rdev->flags)
                            && !test_bit(In_sync, &rdev->flags)
                            && !rdev_set_badblocks(rdev, sh->sector,
-                                                  STRIPE_SECTORS, 0))
+                                                  RAID5_STRIPE_SECTORS(conf), 0))
                                abort = 1;
                        rdev = rcu_dereference(conf->disks[i].replacement);
                        if (rdev
                            && !test_bit(Faulty, &rdev->flags)
                            && !test_bit(In_sync, &rdev->flags)
                            && !rdev_set_badblocks(rdev, sh->sector,
-                                                  STRIPE_SECTORS, 0))
+                                                  RAID5_STRIPE_SECTORS(conf), 0))
                                abort = 1;
                }
                rcu_read_unlock();
                        conf->recovery_disabled =
                                conf->mddev->recovery_disabled;
        }
-       md_done_sync(conf->mddev, STRIPE_SECTORS, !abort);
+       md_done_sync(conf->mddev, RAID5_STRIPE_SECTORS(conf), !abort);
 }
 
 static int want_replace(struct stripe_head *sh, int disk_idx)
                                wbi = dev->written;
                                dev->written = NULL;
                                while (wbi && wbi->bi_iter.bi_sector <
-                                       dev->sector + STRIPE_SECTORS) {
-                                       wbi2 = r5_next_bio(wbi, dev->sector);
+                                       dev->sector + RAID5_STRIPE_SECTORS(conf)) {
+                                       wbi2 = r5_next_bio(conf, wbi, dev->sector);
                                        md_write_end(conf->mddev);
                                        bio_endio(wbi);
                                        wbi = wbi2;
                                }
                                md_bitmap_endwrite(conf->mddev->bitmap, sh->sector,
-                                                  STRIPE_SECTORS,
+                                                  RAID5_STRIPE_SECTORS(conf),
                                                   !test_bit(STRIPE_DEGRADED, &sh->state),
                                                   0);
                                if (head_sh->batch_head) {
                         */
                        set_bit(STRIPE_INSYNC, &sh->state);
                else {
-                       atomic64_add(STRIPE_SECTORS, &conf->mddev->resync_mismatches);
+                       atomic64_add(RAID5_STRIPE_SECTORS(conf), &conf->mddev->resync_mismatches);
                        if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) {
                                /* don't try to repair!! */
                                set_bit(STRIPE_INSYNC, &sh->state);
                                                    "%llu-%llu\n", mdname(conf->mddev),
                                                    (unsigned long long) sh->sector,
                                                    (unsigned long long) sh->sector +
-                                                   STRIPE_SECTORS);
+                                                   RAID5_STRIPE_SECTORS(conf));
                        } else {
                                sh->check_state = check_state_compute_run;
                                set_bit(STRIPE_COMPUTE_RUN, &sh->state);
                                 */
                        }
                } else {
-                       atomic64_add(STRIPE_SECTORS, &conf->mddev->resync_mismatches);
+                       atomic64_add(RAID5_STRIPE_SECTORS(conf), &conf->mddev->resync_mismatches);
                        if (test_bit(MD_RECOVERY_CHECK, &conf->mddev->recovery)) {
                                /* don't try to repair!! */
                                set_bit(STRIPE_INSYNC, &sh->state);
                                                    "%llu-%llu\n", mdname(conf->mddev),
                                                    (unsigned long long) sh->sector,
                                                    (unsigned long long) sh->sector +
-                                                   STRIPE_SECTORS);
+                                                   RAID5_STRIPE_SECTORS(conf));
                        } else {
                                int *target = &sh->ops.target;
 
                        /* place all the copies on one channel */
                        init_async_submit(&submit, 0, tx, NULL, NULL, NULL);
                        tx = async_memcpy(sh2->dev[dd_idx].page,
-                                         sh->dev[i].page, 0, 0, STRIPE_SIZE,
+                                         sh->dev[i].page, 0, 0, RAID5_STRIPE_SIZE(conf),
                                          &submit);
 
                        set_bit(R5_Expanded, &sh2->dev[dd_idx].flags);
                 */
                rdev = rcu_dereference(conf->disks[i].replacement);
                if (rdev && !test_bit(Faulty, &rdev->flags) &&
-                   rdev->recovery_offset >= sh->sector + STRIPE_SECTORS &&
-                   !is_badblock(rdev, sh->sector, STRIPE_SECTORS,
+                   rdev->recovery_offset >= sh->sector + RAID5_STRIPE_SECTORS(conf) &&
+                   !is_badblock(rdev, sh->sector, RAID5_STRIPE_SECTORS(conf),
                                 &first_bad, &bad_sectors))
                        set_bit(R5_ReadRepl, &dev->flags);
                else {
                if (rdev && test_bit(Faulty, &rdev->flags))
                        rdev = NULL;
                if (rdev) {
-                       is_bad = is_badblock(rdev, sh->sector, STRIPE_SECTORS,
+                       is_bad = is_badblock(rdev, sh->sector, RAID5_STRIPE_SECTORS(conf),
                                             &first_bad, &bad_sectors);
                        if (s->blocked_rdev == NULL
                            && (test_bit(Blocked, &rdev->flags)
                        }
                } else if (test_bit(In_sync, &rdev->flags))
                        set_bit(R5_Insync, &dev->flags);
-               else if (sh->sector + STRIPE_SECTORS <= rdev->recovery_offset)
+               else if (sh->sector + RAID5_STRIPE_SECTORS(conf) <= rdev->recovery_offset)
                        /* in sync if before recovery_offset */
                        set_bit(R5_Insync, &dev->flags);
                else if (test_bit(R5_UPTODATE, &dev->flags) &&
        if ((s.syncing || s.replacing) && s.locked == 0 &&
            !test_bit(STRIPE_COMPUTE_RUN, &sh->state) &&
            test_bit(STRIPE_INSYNC, &sh->state)) {
-               md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
+               md_done_sync(conf->mddev, RAID5_STRIPE_SECTORS(conf), 1);
                clear_bit(STRIPE_SYNCING, &sh->state);
                if (test_and_clear_bit(R5_Overlap, &sh->dev[sh->pd_idx].flags))
                        wake_up(&conf->wait_for_overlap);
                clear_bit(STRIPE_EXPAND_READY, &sh->state);
                atomic_dec(&conf->reshape_stripes);
                wake_up(&conf->wait_for_overlap);
-               md_done_sync(conf->mddev, STRIPE_SECTORS, 1);
+               md_done_sync(conf->mddev, RAID5_STRIPE_SECTORS(conf), 1);
        }
 
        if (s.expanding && s.locked == 0 &&
                                /* We own a safe reference to the rdev */
                                rdev = conf->disks[i].rdev;
                                if (!rdev_set_badblocks(rdev, sh->sector,
-                                                       STRIPE_SECTORS, 0))
+                                                       RAID5_STRIPE_SECTORS(conf), 0))
                                        md_error(conf->mddev, rdev);
                                rdev_dec_pending(rdev, conf->mddev);
                        }
                        if (test_and_clear_bit(R5_MadeGood, &dev->flags)) {
                                rdev = conf->disks[i].rdev;
                                rdev_clear_badblocks(rdev, sh->sector,
-                                                    STRIPE_SECTORS, 0);
+                                                    RAID5_STRIPE_SECTORS(conf), 0);
                                rdev_dec_pending(rdev, conf->mddev);
                        }
                        if (test_and_clear_bit(R5_MadeGoodRepl, &dev->flags)) {
                                        /* rdev have been moved down */
                                        rdev = conf->disks[i].rdev;
                                rdev_clear_badblocks(rdev, sh->sector,
-                                                    STRIPE_SECTORS, 0);
+                                                    RAID5_STRIPE_SECTORS(conf), 0);
                                rdev_dec_pending(rdev, conf->mddev);
                        }
                }
                /* Skip discard while reshape is happening */
                return;
 
-       logical_sector = bi->bi_iter.bi_sector & ~((sector_t)STRIPE_SECTORS-1);
+       logical_sector = bi->bi_iter.bi_sector & ~((sector_t)RAID5_STRIPE_SECTORS(conf)-1);
        last_sector = bio_end_sector(bi);
 
        bi->bi_next = NULL;
        last_sector *= conf->chunk_sectors;
 
        for (; logical_sector < last_sector;
-            logical_sector += STRIPE_SECTORS) {
+            logical_sector += RAID5_STRIPE_SECTORS(conf)) {
                DEFINE_WAIT(w);
                int d;
        again:
                             d++)
                                md_bitmap_startwrite(mddev->bitmap,
                                                     sh->sector,
-                                                    STRIPE_SECTORS,
+                                                    RAID5_STRIPE_SECTORS(conf),
                                                     0);
                        sh->bm_seq = conf->seq_flush + 1;
                        set_bit(STRIPE_BIT_DELAY, &sh->state);
                return true;
        }
 
-       logical_sector = bi->bi_iter.bi_sector & ~((sector_t)STRIPE_SECTORS-1);
+       logical_sector = bi->bi_iter.bi_sector & ~((sector_t)RAID5_STRIPE_SECTORS(conf)-1);
        last_sector = bio_end_sector(bi);
        bi->bi_next = NULL;
 
        prepare_to_wait(&conf->wait_for_overlap, &w, TASK_UNINTERRUPTIBLE);
-       for (;logical_sector < last_sector; logical_sector += STRIPE_SECTORS) {
+       for (; logical_sector < last_sector; logical_sector += RAID5_STRIPE_SECTORS(conf)) {
                int previous;
                int seq;
 
        }
 
        INIT_LIST_HEAD(&stripes);
-       for (i = 0; i < reshape_sectors; i += STRIPE_SECTORS) {
+       for (i = 0; i < reshape_sectors; i += RAID5_STRIPE_SECTORS(conf)) {
                int j;
                int skipped_disk = 0;
                sh = raid5_get_active_stripe(conf, stripe_addr+i, 0, 0, 1);
                                skipped_disk = 1;
                                continue;
                        }
-                       memset(page_address(sh->dev[j].page), 0, STRIPE_SIZE);
+                       memset(page_address(sh->dev[j].page), 0, RAID5_STRIPE_SIZE(conf));
                        set_bit(R5_Expanded, &sh->dev[j].flags);
                        set_bit(R5_UPTODATE, &sh->dev[j].flags);
                }
                set_bit(STRIPE_EXPAND_SOURCE, &sh->state);
                set_bit(STRIPE_HANDLE, &sh->state);
                raid5_release_stripe(sh);
-               first_sector += STRIPE_SECTORS;
+               first_sector += RAID5_STRIPE_SECTORS(conf);
        }
        /* Now that the sources are clearly marked, we can release
         * the destination stripes
        if (!test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery) &&
            !conf->fullsync &&
            !md_bitmap_start_sync(mddev->bitmap, sector_nr, &sync_blocks, 1) &&
-           sync_blocks >= STRIPE_SECTORS) {
+           sync_blocks >= RAID5_STRIPE_SECTORS(conf)) {
                /* we can skip this block, and probably more */
-               sync_blocks /= STRIPE_SECTORS;
+               sync_blocks /= RAID5_STRIPE_SECTORS(conf);
                *skipped = 1;
-               return sync_blocks * STRIPE_SECTORS; /* keep things rounded to whole stripes */
+               /* keep things rounded to whole stripes */
+               return sync_blocks * RAID5_STRIPE_SECTORS(conf);
        }
 
        md_bitmap_cond_end_sync(mddev->bitmap, sector_nr, false);
 
        raid5_release_stripe(sh);
 
-       return STRIPE_SECTORS;
+       return RAID5_STRIPE_SECTORS(conf);
 }
 
 static int  retry_aligned_read(struct r5conf *conf, struct bio *raid_bio,
        int handled = 0;
 
        logical_sector = raid_bio->bi_iter.bi_sector &
-               ~((sector_t)STRIPE_SECTORS-1);
+               ~((sector_t)RAID5_STRIPE_SECTORS(conf)-1);
        sector = raid5_compute_sector(conf, logical_sector,
                                      0, &dd_idx, NULL);
        last_sector = bio_end_sector(raid_bio);
 
        for (; logical_sector < last_sector;
-            logical_sector += STRIPE_SECTORS,
-                    sector += STRIPE_SECTORS,
+            logical_sector += RAID5_STRIPE_SECTORS(conf),
+                    sector += RAID5_STRIPE_SECTORS(conf),
                     scnt++) {
 
                if (scnt < offset)
                               conf->previous_raid_disks),
                           max(conf->chunk_sectors,
                               conf->prev_chunk_sectors)
-                          / STRIPE_SECTORS)) {
+                          / RAID5_STRIPE_SECTORS(conf))) {
                free_scratch_buffer(conf, percpu);
                return -ENOMEM;
        }
        conf = kzalloc(sizeof(struct r5conf), GFP_KERNEL);
        if (conf == NULL)
                goto abort;
+
        INIT_LIST_HEAD(&conf->free_list);
        INIT_LIST_HEAD(&conf->pending_list);
        conf->pending_data = kcalloc(PENDING_IO_MAX,
        conf->min_nr_stripes = NR_STRIPES;
        if (mddev->reshape_position != MaxSector) {
                int stripes = max_t(int,
-                       ((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4,
-                       ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4);
+                       ((mddev->chunk_sectors << 9) / RAID5_STRIPE_SIZE(conf)) * 4,
+                       ((mddev->new_chunk_sectors << 9) / RAID5_STRIPE_SIZE(conf)) * 4);
                conf->min_nr_stripes = max(NR_STRIPES, stripes);
                if (conf->min_nr_stripes != NR_STRIPES)
                        pr_info("md/raid:%s: force stripe size %d for reshape\n",
         * stripe_heads first.
         */
        struct r5conf *conf = mddev->private;
-       if (((mddev->chunk_sectors << 9) / STRIPE_SIZE) * 4
+       if (((mddev->chunk_sectors << 9) / RAID5_STRIPE_SIZE(conf)) * 4
            > conf->min_nr_stripes ||
-           ((mddev->new_chunk_sectors << 9) / STRIPE_SIZE) * 4
+           ((mddev->new_chunk_sectors << 9) / RAID5_STRIPE_SIZE(conf)) * 4
            > conf->min_nr_stripes) {
                pr_warn("md/raid:%s: reshape: not enough stripes.  Needed %lu\n",
                        mdname(mddev),
                        ((max(mddev->chunk_sectors, mddev->new_chunk_sectors) << 9)
-                        / STRIPE_SIZE)*4);
+                        / RAID5_STRIPE_SIZE(conf))*4);
                return 0;
        }
        return 1;
        while (chunksect && (mddev->array_sectors & (chunksect-1)))
                chunksect >>= 1;
 
-       if ((chunksect<<9) < STRIPE_SIZE)
+       if ((chunksect<<9) < RAID5_STRIPE_SIZE((struct r5conf *)mddev->private))
                /* array size does not allow a suitable chunk size */
                return ERR_PTR(-EINVAL);