#include <linux/blkdev.h>
#include <linux/module.h>
#include <linux/errno.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/timer.h>
#include <linux/sched.h>
#include <linux/list.h>
#include <linux/file.h>
#include <linux/mount.h>
#include <linux/buffer_head.h>
#include <linux/seq_file.h>
#include <trace/events/block.h>
#include "md.h"
#include "md-bitmap.h"
#define BITMAP_MAJOR_LO …
#define BITMAP_MAJOR_HI …
#define BITMAP_MAJOR_CLUSTERED …
#define BITMAP_MAJOR_HOSTENDIAN …
#define PAGE_BITS …
#define PAGE_BIT_SHIFT …
#define NEEDED(x) …
#define RESYNC(x) …
#define COUNTER(x) …
#define PAGE_COUNTER_RATIO …
#define PAGE_COUNTER_SHIFT …
#define PAGE_COUNTER_MASK …
#define BITMAP_BLOCK_SHIFT …
struct bitmap_page { … };
struct bitmap { … };
static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int chunksize, bool init);
static inline char *bmname(struct bitmap *bitmap)
{ … }
static bool __bitmap_enabled(struct bitmap *bitmap)
{ … }
static bool bitmap_enabled(struct mddev *mddev)
{ … }
static int md_bitmap_checkpage(struct bitmap_counts *bitmap,
unsigned long page, int create, int no_hijack)
__releases(bitmap->lock)
__acquires(bitmap->lock)
{ … }
static void md_bitmap_checkfree(struct bitmap_counts *bitmap, unsigned long page)
{ … }
static int read_sb_page(struct mddev *mddev, loff_t offset,
struct page *page, unsigned long index, int size)
{ … }
static struct md_rdev *next_active_rdev(struct md_rdev *rdev, struct mddev *mddev)
{ … }
static unsigned int optimal_io_size(struct block_device *bdev,
unsigned int last_page_size,
unsigned int io_size)
{ … }
static unsigned int bitmap_io_size(unsigned int io_size, unsigned int opt_size,
loff_t start, loff_t boundary)
{ … }
static int __write_sb_page(struct md_rdev *rdev, struct bitmap *bitmap,
unsigned long pg_index, struct page *page)
{ … }
static void write_sb_page(struct bitmap *bitmap, unsigned long pg_index,
struct page *page, bool wait)
{ … }
static void md_bitmap_file_kick(struct bitmap *bitmap);
#ifdef CONFIG_MD_BITMAP_FILE
static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
{ … }
static void end_bitmap_write(struct buffer_head *bh, int uptodate)
{ … }
static void free_buffers(struct page *page)
{ … }
static int read_file_page(struct file *file, unsigned long index,
struct bitmap *bitmap, unsigned long count, struct page *page)
{ … }
#else
static void write_file_page(struct bitmap *bitmap, struct page *page, int wait)
{
}
static int read_file_page(struct file *file, unsigned long index,
struct bitmap *bitmap, unsigned long count, struct page *page)
{
return -EIO;
}
static void free_buffers(struct page *page)
{
put_page(page);
}
#endif
static void filemap_write_page(struct bitmap *bitmap, unsigned long pg_index,
bool wait)
{ … }
static void md_bitmap_wait_writes(struct bitmap *bitmap)
{ … }
static void bitmap_update_sb(void *data)
{ … }
static void bitmap_print_sb(struct bitmap *bitmap)
{ … }
static int md_bitmap_new_disk_sb(struct bitmap *bitmap)
{ … }
static int md_bitmap_read_sb(struct bitmap *bitmap)
{ … }
static inline unsigned long file_page_index(struct bitmap_storage *store,
unsigned long chunk)
{ … }
static inline unsigned long file_page_offset(struct bitmap_storage *store,
unsigned long chunk)
{ … }
static inline struct page *filemap_get_page(struct bitmap_storage *store,
unsigned long chunk)
{ … }
static int md_bitmap_storage_alloc(struct bitmap_storage *store,
unsigned long chunks, int with_super,
int slot_number)
{ … }
static void md_bitmap_file_unmap(struct bitmap_storage *store)
{ … }
static void md_bitmap_file_kick(struct bitmap *bitmap)
{ … }
enum bitmap_page_attr { … };
static inline void set_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr)
{ … }
static inline void clear_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr)
{ … }
static inline int test_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr)
{ … }
static inline int test_and_clear_page_attr(struct bitmap *bitmap, int pnum,
enum bitmap_page_attr attr)
{ … }
static void md_bitmap_file_set_bit(struct bitmap *bitmap, sector_t block)
{ … }
static void md_bitmap_file_clear_bit(struct bitmap *bitmap, sector_t block)
{ … }
static int md_bitmap_file_test_bit(struct bitmap *bitmap, sector_t block)
{ … }
static void __bitmap_unplug(struct bitmap *bitmap)
{ … }
struct bitmap_unplug_work { … };
static void md_bitmap_unplug_fn(struct work_struct *work)
{ … }
static void bitmap_unplug_async(struct bitmap *bitmap)
{ … }
static void bitmap_unplug(struct mddev *mddev, bool sync)
{ … }
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed);
static int md_bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
{ … }
static void bitmap_write_all(struct mddev *mddev)
{ … }
static void md_bitmap_count_page(struct bitmap_counts *bitmap,
sector_t offset, int inc)
{ … }
static void md_bitmap_set_pending(struct bitmap_counts *bitmap, sector_t offset)
{ … }
static bitmap_counter_t *md_bitmap_get_counter(struct bitmap_counts *bitmap,
sector_t offset, sector_t *blocks,
int create);
static void mddev_set_timeout(struct mddev *mddev, unsigned long timeout,
bool force)
{ … }
static void bitmap_daemon_work(struct mddev *mddev)
{ … }
static bitmap_counter_t *md_bitmap_get_counter(struct bitmap_counts *bitmap,
sector_t offset, sector_t *blocks,
int create)
__releases(bitmap->lock)
__acquires(bitmap->lock)
{ … }
static int bitmap_startwrite(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool behind)
{ … }
static void bitmap_endwrite(struct mddev *mddev, sector_t offset,
unsigned long sectors, bool success, bool behind)
{ … }
static bool __bitmap_start_sync(struct bitmap *bitmap, sector_t offset,
sector_t *blocks, bool degraded)
{ … }
static bool bitmap_start_sync(struct mddev *mddev, sector_t offset,
sector_t *blocks, bool degraded)
{ … }
static void __bitmap_end_sync(struct bitmap *bitmap, sector_t offset,
sector_t *blocks, bool aborted)
{ … }
static void bitmap_end_sync(struct mddev *mddev, sector_t offset,
sector_t *blocks)
{ … }
static void bitmap_close_sync(struct mddev *mddev)
{ … }
static void bitmap_cond_end_sync(struct mddev *mddev, sector_t sector,
bool force)
{ … }
static void bitmap_sync_with_cluster(struct mddev *mddev,
sector_t old_lo, sector_t old_hi,
sector_t new_lo, sector_t new_hi)
{ … }
static void md_bitmap_set_memory_bits(struct bitmap *bitmap, sector_t offset, int needed)
{ … }
static void bitmap_dirty_bits(struct mddev *mddev, unsigned long s,
unsigned long e)
{ … }
static void bitmap_flush(struct mddev *mddev)
{ … }
static void md_bitmap_free(void *data)
{ … }
static void bitmap_wait_behind_writes(struct mddev *mddev)
{ … }
static void bitmap_destroy(struct mddev *mddev)
{ … }
static struct bitmap *__bitmap_create(struct mddev *mddev, int slot)
{ … }
static int bitmap_create(struct mddev *mddev, int slot)
{ … }
static int bitmap_load(struct mddev *mddev)
{ … }
static void *bitmap_get_from_slot(struct mddev *mddev, int slot)
{ … }
static int bitmap_copy_from_slot(struct mddev *mddev, int slot, sector_t *low,
sector_t *high, bool clear_bits)
{ … }
static void bitmap_set_pages(void *data, unsigned long pages)
{ … }
static int bitmap_get_stats(void *data, struct md_bitmap_stats *stats)
{ … }
static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,
int chunksize, bool init)
{ … }
static int bitmap_resize(struct mddev *mddev, sector_t blocks, int chunksize,
bool init)
{ … }
static ssize_t
location_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
location_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_location = …;
static ssize_t
space_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
space_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_space = …;
static ssize_t
timeout_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
timeout_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_timeout = …;
static ssize_t
backlog_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
backlog_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_backlog = …;
static ssize_t
chunksize_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
chunksize_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_chunksize = …;
static ssize_t metadata_show(struct mddev *mddev, char *page)
{ … }
static ssize_t metadata_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_metadata = …;
static ssize_t can_clear_show(struct mddev *mddev, char *page)
{ … }
static ssize_t can_clear_store(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry bitmap_can_clear = …;
static ssize_t
behind_writes_used_show(struct mddev *mddev, char *page)
{ … }
static ssize_t
behind_writes_used_reset(struct mddev *mddev, const char *buf, size_t len)
{ … }
static struct md_sysfs_entry max_backlog_used = …;
static struct attribute *md_bitmap_attrs[] = …;
const struct attribute_group md_bitmap_group = …;
static struct bitmap_operations bitmap_ops = …;
void mddev_set_bitmap_ops(struct mddev *mddev)
{ … }