forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/md/raid5.h
....@@ -195,6 +195,7 @@
195195 reconstruct_state_result,
196196 };
197197
198
+#define DEFAULT_STRIPE_SIZE 4096
198199 struct stripe_head {
199200 struct hlist_node hash;
200201 struct list_head lru; /* inactive_list or handle_list */
....@@ -246,6 +247,13 @@
246247 int target, target2;
247248 enum sum_check_flags zero_sum_result;
248249 } 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
249257 struct r5dev {
250258 /* rreq and rvec are used for the replacement device when
251259 * writing data to both devices.
....@@ -253,6 +261,7 @@
253261 struct bio req, rreq;
254262 struct bio_vec vec, rvec;
255263 struct page *page, *orig_page;
264
+ unsigned int offset; /* offset of the page */
256265 struct bio *toread, *read, *towrite, *written;
257266 sector_t sector; /* sector of this page */
258267 unsigned long flags;
....@@ -357,7 +366,6 @@
357366 STRIPE_FULL_WRITE, /* all blocks are set to be overwritten */
358367 STRIPE_BIOFILL_RUN,
359368 STRIPE_COMPUTE_RUN,
360
- STRIPE_OPS_REQ_PENDING,
361369 STRIPE_ON_UNPLUG_LIST,
362370 STRIPE_DISCARD,
363371 STRIPE_ON_RELEASE_LIST,
....@@ -473,33 +481,18 @@
473481 */
474482
475483 #define NR_STRIPES 256
484
+
485
+#if PAGE_SIZE == DEFAULT_STRIPE_SIZE
476486 #define STRIPE_SIZE PAGE_SIZE
477487 #define STRIPE_SHIFT (PAGE_SHIFT - 9)
478488 #define STRIPE_SECTORS (STRIPE_SIZE>>9)
489
+#endif
490
+
479491 #define IO_THRESHOLD 1
480492 #define BYPASS_THRESHOLD 1
481493 #define NR_HASH (PAGE_SIZE / sizeof(struct hlist_head))
482494 #define HASH_MASK (NR_HASH - 1)
483495 #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
-}
503496
504497 /* NOTE NR_STRIPE_HASH_LOCKS must remain below 64.
505498 * This is because we sometimes take all the spinlocks
....@@ -577,6 +570,11 @@
577570 int raid_disks;
578571 int max_nr_stripes;
579572 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
580578
581579 /* reshape_progress is the leading edge of a 'reshape'
582580 * It has value MaxSector when no reshape is happening
....@@ -592,7 +590,7 @@
592590 int prev_chunk_sectors;
593591 int prev_algo;
594592 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 */
596594 unsigned long reshape_checkpoint; /* Time we last updated
597595 * metadata */
598596 long long min_offset_diff; /* minimum difference between
....@@ -637,12 +635,12 @@
637635 int recovery_disabled;
638636 /* per cpu variables */
639637 struct raid5_percpu {
640
- spinlock_t lock; /* Protection for -RT */
641638 struct page *spare_page; /* Used when checking P/Q in raid6 */
642
- struct flex_array *scribble; /* space for constructing buffer
643
- * lists and performing address
644
- * conversions
645
- */
639
+ void *scribble; /* space for constructing buffer
640
+ * lists and performing address
641
+ * conversions
642
+ */
643
+ int scribble_obj_size;
646644 } __percpu *percpu;
647645 int scribble_disks;
648646 int scribble_sectors;
....@@ -693,6 +691,32 @@
693691 struct r5pending_data *next_pending_data;
694692 };
695693
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
+}
696720
697721 /*
698722 * Our supported algorithms
....@@ -755,6 +779,25 @@
755779 return layout >= 8 && layout <= 10;
756780 }
757781
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
+
758801 extern void md_raid5_kick_device(struct r5conf *conf);
759802 extern int raid5_set_cache_size(struct mddev *mddev, int size);
760803 extern sector_t raid5_compute_blocknr(struct stripe_head *sh, int i, int previous);