.. | .. |
---|
195 | 195 | reconstruct_state_result, |
---|
196 | 196 | }; |
---|
197 | 197 | |
---|
| 198 | +#define DEFAULT_STRIPE_SIZE 4096 |
---|
198 | 199 | struct stripe_head { |
---|
199 | 200 | struct hlist_node hash; |
---|
200 | 201 | struct list_head lru; /* inactive_list or handle_list */ |
---|
.. | .. |
---|
246 | 247 | int target, target2; |
---|
247 | 248 | enum sum_check_flags zero_sum_result; |
---|
248 | 249 | } ops; |
---|
| 250 | + |
---|
| 251 | +#if PAGE_SIZE != DEFAULT_STRIPE_SIZE |
---|
| 252 | + /* These pages will be used by bios in dev[i] */ |
---|
| 253 | + struct page **pages; |
---|
| 254 | + int nr_pages; /* page array size */ |
---|
| 255 | + int stripes_per_page; |
---|
| 256 | +#endif |
---|
249 | 257 | struct r5dev { |
---|
250 | 258 | /* rreq and rvec are used for the replacement device when |
---|
251 | 259 | * writing data to both devices. |
---|
.. | .. |
---|
253 | 261 | struct bio req, rreq; |
---|
254 | 262 | struct bio_vec vec, rvec; |
---|
255 | 263 | struct page *page, *orig_page; |
---|
| 264 | + unsigned int offset; /* offset of the page */ |
---|
256 | 265 | struct bio *toread, *read, *towrite, *written; |
---|
257 | 266 | sector_t sector; /* sector of this page */ |
---|
258 | 267 | unsigned long flags; |
---|
.. | .. |
---|
357 | 366 | STRIPE_FULL_WRITE, /* all blocks are set to be overwritten */ |
---|
358 | 367 | STRIPE_BIOFILL_RUN, |
---|
359 | 368 | STRIPE_COMPUTE_RUN, |
---|
360 | | - STRIPE_OPS_REQ_PENDING, |
---|
361 | 369 | STRIPE_ON_UNPLUG_LIST, |
---|
362 | 370 | STRIPE_DISCARD, |
---|
363 | 371 | STRIPE_ON_RELEASE_LIST, |
---|
.. | .. |
---|
473 | 481 | */ |
---|
474 | 482 | |
---|
475 | 483 | #define NR_STRIPES 256 |
---|
| 484 | + |
---|
| 485 | +#if PAGE_SIZE == DEFAULT_STRIPE_SIZE |
---|
476 | 486 | #define STRIPE_SIZE PAGE_SIZE |
---|
477 | 487 | #define STRIPE_SHIFT (PAGE_SHIFT - 9) |
---|
478 | 488 | #define STRIPE_SECTORS (STRIPE_SIZE>>9) |
---|
| 489 | +#endif |
---|
| 490 | + |
---|
479 | 491 | #define IO_THRESHOLD 1 |
---|
480 | 492 | #define BYPASS_THRESHOLD 1 |
---|
481 | 493 | #define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head)) |
---|
482 | 494 | #define HASH_MASK (NR_HASH - 1) |
---|
483 | 495 | #define MAX_STRIPE_BATCH 8 |
---|
484 | | - |
---|
485 | | -/* bio's attached to a stripe+device for I/O are linked together in bi_sector |
---|
486 | | - * order without overlap. There may be several bio's per stripe+device, and |
---|
487 | | - * a bio could span several devices. |
---|
488 | | - * When walking this list for a particular stripe+device, we must never proceed |
---|
489 | | - * beyond a bio that extends past this device, as the next bio might no longer |
---|
490 | | - * be valid. |
---|
491 | | - * This function is used to determine the 'next' bio in the list, given the |
---|
492 | | - * sector of the current stripe+device |
---|
493 | | - */ |
---|
494 | | -static inline struct bio *r5_next_bio(struct bio *bio, sector_t sector) |
---|
495 | | -{ |
---|
496 | | - int sectors = bio_sectors(bio); |
---|
497 | | - |
---|
498 | | - if (bio->bi_iter.bi_sector + sectors < sector + STRIPE_SECTORS) |
---|
499 | | - return bio->bi_next; |
---|
500 | | - else |
---|
501 | | - return NULL; |
---|
502 | | -} |
---|
503 | 496 | |
---|
504 | 497 | /* NOTE NR_STRIPE_HASH_LOCKS must remain below 64. |
---|
505 | 498 | * This is because we sometimes take all the spinlocks |
---|
.. | .. |
---|
577 | 570 | int raid_disks; |
---|
578 | 571 | int max_nr_stripes; |
---|
579 | 572 | int min_nr_stripes; |
---|
| 573 | +#if PAGE_SIZE != DEFAULT_STRIPE_SIZE |
---|
| 574 | + unsigned long stripe_size; |
---|
| 575 | + unsigned int stripe_shift; |
---|
| 576 | + unsigned long stripe_sectors; |
---|
| 577 | +#endif |
---|
580 | 578 | |
---|
581 | 579 | /* reshape_progress is the leading edge of a 'reshape' |
---|
582 | 580 | * It has value MaxSector when no reshape is happening |
---|
.. | .. |
---|
592 | 590 | int prev_chunk_sectors; |
---|
593 | 591 | int prev_algo; |
---|
594 | 592 | short generation; /* increments with every reshape */ |
---|
595 | | - seqcount_t gen_lock; /* lock against generation changes */ |
---|
| 593 | + seqcount_spinlock_t gen_lock; /* lock against generation changes */ |
---|
596 | 594 | unsigned long reshape_checkpoint; /* Time we last updated |
---|
597 | 595 | * metadata */ |
---|
598 | 596 | long long min_offset_diff; /* minimum difference between |
---|
.. | .. |
---|
638 | 636 | /* per cpu variables */ |
---|
639 | 637 | struct raid5_percpu { |
---|
640 | 638 | struct page *spare_page; /* Used when checking P/Q in raid6 */ |
---|
641 | | - struct flex_array *scribble; /* space for constructing buffer |
---|
642 | | - * lists and performing address |
---|
643 | | - * conversions |
---|
644 | | - */ |
---|
| 639 | + void *scribble; /* space for constructing buffer |
---|
| 640 | + * lists and performing address |
---|
| 641 | + * conversions |
---|
| 642 | + */ |
---|
| 643 | + int scribble_obj_size; |
---|
645 | 644 | } __percpu *percpu; |
---|
646 | 645 | int scribble_disks; |
---|
647 | 646 | int scribble_sectors; |
---|
.. | .. |
---|
692 | 691 | struct r5pending_data *next_pending_data; |
---|
693 | 692 | }; |
---|
694 | 693 | |
---|
| 694 | +#if PAGE_SIZE == DEFAULT_STRIPE_SIZE |
---|
| 695 | +#define RAID5_STRIPE_SIZE(conf) STRIPE_SIZE |
---|
| 696 | +#define RAID5_STRIPE_SHIFT(conf) STRIPE_SHIFT |
---|
| 697 | +#define RAID5_STRIPE_SECTORS(conf) STRIPE_SECTORS |
---|
| 698 | +#else |
---|
| 699 | +#define RAID5_STRIPE_SIZE(conf) ((conf)->stripe_size) |
---|
| 700 | +#define RAID5_STRIPE_SHIFT(conf) ((conf)->stripe_shift) |
---|
| 701 | +#define RAID5_STRIPE_SECTORS(conf) ((conf)->stripe_sectors) |
---|
| 702 | +#endif |
---|
| 703 | + |
---|
| 704 | +/* bio's attached to a stripe+device for I/O are linked together in bi_sector |
---|
| 705 | + * order without overlap. There may be several bio's per stripe+device, and |
---|
| 706 | + * a bio could span several devices. |
---|
| 707 | + * When walking this list for a particular stripe+device, we must never proceed |
---|
| 708 | + * beyond a bio that extends past this device, as the next bio might no longer |
---|
| 709 | + * be valid. |
---|
| 710 | + * This function is used to determine the 'next' bio in the list, given the |
---|
| 711 | + * sector of the current stripe+device |
---|
| 712 | + */ |
---|
| 713 | +static inline struct bio *r5_next_bio(struct r5conf *conf, struct bio *bio, sector_t sector) |
---|
| 714 | +{ |
---|
| 715 | + if (bio_end_sector(bio) < sector + RAID5_STRIPE_SECTORS(conf)) |
---|
| 716 | + return bio->bi_next; |
---|
| 717 | + else |
---|
| 718 | + return NULL; |
---|
| 719 | +} |
---|
695 | 720 | |
---|
696 | 721 | /* |
---|
697 | 722 | * Our supported algorithms |
---|
.. | .. |
---|
754 | 779 | return layout >= 8 && layout <= 10; |
---|
755 | 780 | } |
---|
756 | 781 | |
---|
| 782 | +#if PAGE_SIZE != DEFAULT_STRIPE_SIZE |
---|
| 783 | +/* |
---|
| 784 | + * Return offset of the corresponding page for r5dev. |
---|
| 785 | + */ |
---|
| 786 | +static inline int raid5_get_page_offset(struct stripe_head *sh, int disk_idx) |
---|
| 787 | +{ |
---|
| 788 | + return (disk_idx % sh->stripes_per_page) * RAID5_STRIPE_SIZE(sh->raid_conf); |
---|
| 789 | +} |
---|
| 790 | + |
---|
| 791 | +/* |
---|
| 792 | + * Return corresponding page address for r5dev. |
---|
| 793 | + */ |
---|
| 794 | +static inline struct page * |
---|
| 795 | +raid5_get_dev_page(struct stripe_head *sh, int disk_idx) |
---|
| 796 | +{ |
---|
| 797 | + return sh->pages[disk_idx / sh->stripes_per_page]; |
---|
| 798 | +} |
---|
| 799 | +#endif |
---|
| 800 | + |
---|
757 | 801 | extern void md_raid5_kick_device(struct r5conf *conf); |
---|
758 | 802 | extern int raid5_set_cache_size(struct mddev *mddev, int size); |
---|
759 | 803 | extern sector_t raid5_compute_blocknr(struct stripe_head *sh, int i, int previous); |
---|