// SPDX-License-Identifier: GPL-2.0 /* Maximum size of each resync request */ #define RESYNC_BLOCK_SIZE … #define RESYNC_PAGES … /* * Number of guaranteed raid bios in case of extreme VM load: */ #define NR_RAID_BIOS … /* when we get a read error on a read-only array, we redirect to another * device without failing the first device, or trying to over-write to * correct the read error. To keep track of bad blocks on a per-bio * level, we store IO_BLOCKED in the appropriate 'bios' pointer */ #define IO_BLOCKED … /* When we successfully write to a known bad-block, we need to remove the * bad-block marking which must be done from process context. So we record * the success by setting devs[n].bio to IO_MADE_GOOD */ #define IO_MADE_GOOD … #define BIO_SPECIAL(bio) … #define MAX_PLUG_BIO … /* for managing resync I/O pages */ struct resync_pages { … }; struct raid1_plug_cb { … }; static void rbio_pool_free(void *rbio, void *data) { … } static inline int resync_alloc_pages(struct resync_pages *rp, gfp_t gfp_flags) { … } static inline void resync_free_pages(struct resync_pages *rp) { … } static inline void resync_get_all_pages(struct resync_pages *rp) { … } static inline struct page *resync_fetch_page(struct resync_pages *rp, unsigned idx) { … } /* * 'strct resync_pages' stores actual pages used for doing the resync * IO, and it is per-bio, so make .bi_private points to it. */ static inline struct resync_pages *get_resync_pages(struct bio *bio) { … } /* generally called after bio_reset() for reseting bvec */ static void md_bio_reset_resync_pages(struct bio *bio, struct resync_pages *rp, int size) { … } static inline void raid1_submit_write(struct bio *bio) { … } static inline bool raid1_add_bio_to_plug(struct mddev *mddev, struct bio *bio, blk_plug_cb_fn unplug, int copies) { … } /* * current->bio_list will be set under submit_bio() context, in this case bitmap * io will be added to the list and wait for current io submission to finish, * while current io submission must wait for bitmap io to be done. In order to * avoid such deadlock, submit bitmap io asynchronously. */ static inline void raid1_prepare_flush_writes(struct bitmap *bitmap) { … } /* * Used by fix_read_error() to decay the per rdev read_errors. * We halve the read error count for every hour that has elapsed * since the last recorded read error. */ static inline void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev) { … } static inline bool exceed_read_errors(struct mddev *mddev, struct md_rdev *rdev) { … } /** * raid1_check_read_range() - check a given read range for bad blocks, * available read length is returned; * @rdev: the rdev to read; * @this_sector: read position; * @len: read length; * * helper function for read_balance() * * 1) If there are no bad blocks in the range, @len is returned; * 2) If the range are all bad blocks, 0 is returned; * 3) If there are partial bad blocks: * - If the bad block range starts after @this_sector, the length of first * good region is returned; * - If the bad block range starts before @this_sector, 0 is returned and * the @len is updated to the offset into the region before we get to the * good blocks; */ static inline int raid1_check_read_range(struct md_rdev *rdev, sector_t this_sector, int *len) { … } /* * Check if read should choose the first rdev. * * Balance on the whole device if no resync is going on (recovery is ok) or * below the resync window. Otherwise, take the first readable disk. */ static inline bool raid1_should_read_first(struct mddev *mddev, sector_t this_sector, int len) { … }