#include <linux/blkdev.h>
#include <linux/ratelimit.h>
#include <linux/sched/mm.h>
#include <crypto/hash.h>
#include "ctree.h"
#include "discard.h"
#include "volumes.h"
#include "disk-io.h"
#include "ordered-data.h"
#include "transaction.h"
#include "backref.h"
#include "extent_io.h"
#include "dev-replace.h"
#include "raid56.h"
#include "block-group.h"
#include "zoned.h"
#include "fs.h"
#include "accessors.h"
#include "file-item.h"
#include "scrub.h"
#include "raid-stripe-tree.h"
struct scrub_ctx;
#define SCRUB_STRIPES_PER_GROUP …
#define SCRUB_GROUPS_PER_SCTX …
#define SCRUB_TOTAL_STRIPES …
#define SCRUB_MAX_SECTORS_PER_BLOCK …
struct scrub_sector_verification { … };
enum scrub_stripe_flags { … };
#define SCRUB_STRIPE_PAGES …
struct scrub_stripe { … };
struct scrub_ctx { … };
struct scrub_warning { … };
static void release_scrub_stripe(struct scrub_stripe *stripe)
{ … }
static int init_scrub_stripe(struct btrfs_fs_info *fs_info,
struct scrub_stripe *stripe)
{ … }
static void wait_scrub_stripe_io(struct scrub_stripe *stripe)
{ … }
static void scrub_put_ctx(struct scrub_ctx *sctx);
static void __scrub_blocked_if_needed(struct btrfs_fs_info *fs_info)
{ … }
static void scrub_pause_on(struct btrfs_fs_info *fs_info)
{ … }
static void scrub_pause_off(struct btrfs_fs_info *fs_info)
{ … }
static void scrub_blocked_if_needed(struct btrfs_fs_info *fs_info)
{ … }
static noinline_for_stack void scrub_free_ctx(struct scrub_ctx *sctx)
{ … }
static void scrub_put_ctx(struct scrub_ctx *sctx)
{ … }
static noinline_for_stack struct scrub_ctx *scrub_setup_ctx(
struct btrfs_fs_info *fs_info, int is_dev_replace)
{ … }
static int scrub_print_warning_inode(u64 inum, u64 offset, u64 num_bytes,
u64 root, void *warn_ctx)
{ … }
static void scrub_print_common_warning(const char *errstr, struct btrfs_device *dev,
bool is_super, u64 logical, u64 physical)
{ … }
static int fill_writer_pointer_gap(struct scrub_ctx *sctx, u64 physical)
{ … }
static struct page *scrub_stripe_get_page(struct scrub_stripe *stripe, int sector_nr)
{ … }
static unsigned int scrub_stripe_get_page_offset(struct scrub_stripe *stripe,
int sector_nr)
{ … }
static void scrub_verify_one_metadata(struct scrub_stripe *stripe, int sector_nr)
{ … }
static void scrub_verify_one_sector(struct scrub_stripe *stripe, int sector_nr)
{ … }
static void scrub_verify_one_stripe(struct scrub_stripe *stripe, unsigned long bitmap)
{ … }
static int calc_sector_number(struct scrub_stripe *stripe, struct bio_vec *first_bvec)
{ … }
static void scrub_repair_read_endio(struct btrfs_bio *bbio)
{ … }
static int calc_next_mirror(int mirror, int num_copies)
{ … }
static void scrub_stripe_submit_repair_read(struct scrub_stripe *stripe,
int mirror, int blocksize, bool wait)
{ … }
static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
struct scrub_stripe *stripe)
{ … }
static void scrub_write_sectors(struct scrub_ctx *sctx, struct scrub_stripe *stripe,
unsigned long write_bitmap, bool dev_replace);
static void scrub_stripe_read_repair_worker(struct work_struct *work)
{ … }
static void scrub_read_endio(struct btrfs_bio *bbio)
{ … }
static void scrub_write_endio(struct btrfs_bio *bbio)
{ … }
static void scrub_submit_write_bio(struct scrub_ctx *sctx,
struct scrub_stripe *stripe,
struct btrfs_bio *bbio, bool dev_replace)
{ … }
static void scrub_write_sectors(struct scrub_ctx *sctx, struct scrub_stripe *stripe,
unsigned long write_bitmap, bool dev_replace)
{ … }
static void scrub_throttle_dev_io(struct scrub_ctx *sctx, struct btrfs_device *device,
unsigned int bio_size)
{ … }
static int get_raid56_logic_offset(u64 physical, int num,
struct btrfs_chunk_map *map, u64 *offset,
u64 *stripe_start)
{ … }
static int compare_extent_item_range(struct btrfs_path *path,
u64 search_start, u64 search_len)
{ … }
static int find_first_extent_item(struct btrfs_root *extent_root,
struct btrfs_path *path,
u64 search_start, u64 search_len)
{ … }
static void get_extent_info(struct btrfs_path *path, u64 *extent_start_ret,
u64 *size_ret, u64 *flags_ret, u64 *generation_ret)
{ … }
static int sync_write_pointer_for_zoned(struct scrub_ctx *sctx, u64 logical,
u64 physical, u64 physical_end)
{ … }
static void fill_one_extent_info(struct btrfs_fs_info *fs_info,
struct scrub_stripe *stripe,
u64 extent_start, u64 extent_len,
u64 extent_flags, u64 extent_gen)
{ … }
static void scrub_stripe_reset_bitmaps(struct scrub_stripe *stripe)
{ … }
static int scrub_find_fill_first_stripe(struct btrfs_block_group *bg,
struct btrfs_path *extent_path,
struct btrfs_path *csum_path,
struct btrfs_device *dev, u64 physical,
int mirror_num, u64 logical_start,
u32 logical_len,
struct scrub_stripe *stripe)
{ … }
static void scrub_reset_stripe(struct scrub_stripe *stripe)
{ … }
static u32 stripe_length(const struct scrub_stripe *stripe)
{ … }
static void scrub_submit_extent_sector_read(struct scrub_ctx *sctx,
struct scrub_stripe *stripe)
{ … }
static void scrub_submit_initial_read(struct scrub_ctx *sctx,
struct scrub_stripe *stripe)
{ … }
static bool stripe_has_metadata_error(struct scrub_stripe *stripe)
{ … }
static void submit_initial_group_read(struct scrub_ctx *sctx,
unsigned int first_slot,
unsigned int nr_stripes)
{ … }
static int flush_scrub_stripes(struct scrub_ctx *sctx)
{ … }
static void raid56_scrub_wait_endio(struct bio *bio)
{ … }
static int queue_scrub_stripe(struct scrub_ctx *sctx, struct btrfs_block_group *bg,
struct btrfs_device *dev, int mirror_num,
u64 logical, u32 length, u64 physical,
u64 *found_logical_ret)
{ … }
static int scrub_raid56_parity_stripe(struct scrub_ctx *sctx,
struct btrfs_device *scrub_dev,
struct btrfs_block_group *bg,
struct btrfs_chunk_map *map,
u64 full_stripe_start)
{ … }
static int scrub_simple_mirror(struct scrub_ctx *sctx,
struct btrfs_block_group *bg,
struct btrfs_chunk_map *map,
u64 logical_start, u64 logical_length,
struct btrfs_device *device,
u64 physical, int mirror_num)
{ … }
static u64 simple_stripe_full_stripe_len(const struct btrfs_chunk_map *map)
{ … }
static u64 simple_stripe_get_logical(struct btrfs_chunk_map *map,
struct btrfs_block_group *bg,
int stripe_index)
{ … }
static int simple_stripe_mirror_num(struct btrfs_chunk_map *map, int stripe_index)
{ … }
static int scrub_simple_stripe(struct scrub_ctx *sctx,
struct btrfs_block_group *bg,
struct btrfs_chunk_map *map,
struct btrfs_device *device,
int stripe_index)
{ … }
static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
struct btrfs_block_group *bg,
struct btrfs_chunk_map *map,
struct btrfs_device *scrub_dev,
int stripe_index)
{ … }
static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx,
struct btrfs_block_group *bg,
struct btrfs_device *scrub_dev,
u64 dev_offset,
u64 dev_extent_len)
{ … }
static int finish_extent_writes_for_zoned(struct btrfs_root *root,
struct btrfs_block_group *cache)
{ … }
static noinline_for_stack
int scrub_enumerate_chunks(struct scrub_ctx *sctx,
struct btrfs_device *scrub_dev, u64 start, u64 end)
{ … }
static int scrub_one_super(struct scrub_ctx *sctx, struct btrfs_device *dev,
struct page *page, u64 physical, u64 generation)
{ … }
static noinline_for_stack int scrub_supers(struct scrub_ctx *sctx,
struct btrfs_device *scrub_dev)
{ … }
static void scrub_workers_put(struct btrfs_fs_info *fs_info)
{ … }
static noinline_for_stack int scrub_workers_get(struct btrfs_fs_info *fs_info)
{ … }
int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
u64 end, struct btrfs_scrub_progress *progress,
int readonly, int is_dev_replace)
{ … }
void btrfs_scrub_pause(struct btrfs_fs_info *fs_info)
{ … }
void btrfs_scrub_continue(struct btrfs_fs_info *fs_info)
{ … }
int btrfs_scrub_cancel(struct btrfs_fs_info *fs_info)
{ … }
int btrfs_scrub_cancel_dev(struct btrfs_device *dev)
{ … }
int btrfs_scrub_progress(struct btrfs_fs_info *fs_info, u64 devid,
struct btrfs_scrub_progress *progress)
{ … }