#define pr_fmt(fmt) …
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/drbd.h>
#include <linux/uaccess.h>
#include <asm/types.h>
#include <net/sock.h>
#include <linux/ctype.h>
#include <linux/mutex.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/proc_fs.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/memcontrol.h>
#include <linux/mm_inline.h>
#include <linux/slab.h>
#include <linux/random.h>
#include <linux/reboot.h>
#include <linux/notifier.h>
#include <linux/kthread.h>
#include <linux/workqueue.h>
#include <linux/unistd.h>
#include <linux/vmalloc.h>
#include <linux/sched/signal.h>
#include <linux/drbd_limits.h>
#include "drbd_int.h"
#include "drbd_protocol.h"
#include "drbd_req.h"
#include "drbd_vli.h"
#include "drbd_debugfs.h"
static DEFINE_MUTEX(drbd_main_mutex);
static int drbd_open(struct gendisk *disk, blk_mode_t mode);
static void drbd_release(struct gendisk *gd);
static void md_sync_timer_fn(struct timer_list *t);
static int w_bitmap_io(struct drbd_work *w, int unused);
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_VERSION(…);
MODULE_LICENSE(…) …;
MODULE_PARM_DESC(…) …;
MODULE_ALIAS_BLOCKDEV_MAJOR(…);
#include <linux/moduleparam.h>
#ifdef CONFIG_DRBD_FAULT_INJECTION
int drbd_enable_faults;
int drbd_fault_rate;
static int drbd_fault_count;
static int drbd_fault_devs;
module_param_named(enable_faults, drbd_enable_faults, int, 0664);
module_param_named(fault_rate, drbd_fault_rate, int, 0664);
module_param_named(fault_count, drbd_fault_count, int, 0664);
module_param_named(fault_devs, drbd_fault_devs, int, 0644);
#endif
static bool drbd_allow_oos;
static bool drbd_disable_sendpage;
MODULE_PARM_DESC(…) …;
module_param_named(allow_oos, drbd_allow_oos, bool, 0);
module_param_named(disable_sendpage, drbd_disable_sendpage, bool, 0644);
int drbd_proc_details;
module_param_named(proc_details, drbd_proc_details, int, 0644);
unsigned int drbd_minor_count = …;
char drbd_usermode_helper[80] = …;
module_param_named(minor_count, drbd_minor_count, uint, 0444);
module_param_string(…);
struct idr drbd_devices;
struct list_head drbd_resources;
struct mutex resources_mutex;
struct kmem_cache *drbd_request_cache;
struct kmem_cache *drbd_ee_cache;
struct kmem_cache *drbd_bm_ext_cache;
struct kmem_cache *drbd_al_ext_cache;
mempool_t drbd_request_mempool;
mempool_t drbd_ee_mempool;
mempool_t drbd_md_io_page_pool;
struct bio_set drbd_md_io_bio_set;
struct bio_set drbd_io_bio_set;
struct page *drbd_pp_pool;
DEFINE_SPINLOCK(…);
int drbd_pp_vacant;
wait_queue_head_t drbd_pp_wait;
DEFINE_RATELIMIT_STATE(…);
static const struct block_device_operations drbd_ops = …;
#ifdef __CHECKER__
int _get_ldev_if_state(struct drbd_device *device, enum drbd_disk_state mins)
{
int io_allowed;
atomic_inc(&device->local_cnt);
io_allowed = (device->state.disk >= mins);
if (!io_allowed) {
if (atomic_dec_and_test(&device->local_cnt))
wake_up(&device->misc_wait);
}
return io_allowed;
}
#endif
void tl_release(struct drbd_connection *connection, unsigned int barrier_nr,
unsigned int set_size)
{ … }
void _tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
{ … }
void tl_restart(struct drbd_connection *connection, enum drbd_req_event what)
{ … }
void tl_clear(struct drbd_connection *connection)
{ … }
void tl_abort_disk_io(struct drbd_device *device)
{ … }
static int drbd_thread_setup(void *arg)
{ … }
static void drbd_thread_init(struct drbd_resource *resource, struct drbd_thread *thi,
int (*func) (struct drbd_thread *), const char *name)
{ … }
int drbd_thread_start(struct drbd_thread *thi)
{ … }
void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)
{ … }
#ifdef CONFIG_SMP
static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask)
{ … }
void drbd_thread_current_set_cpu(struct drbd_thread *thi)
{ … }
#else
#define drbd_calc_cpu_mask …
#endif
unsigned int drbd_header_size(struct drbd_connection *connection)
{ … }
static unsigned int prepare_header80(struct p_header80 *h, enum drbd_packet cmd, int size)
{ … }
static unsigned int prepare_header95(struct p_header95 *h, enum drbd_packet cmd, int size)
{ … }
static unsigned int prepare_header100(struct p_header100 *h, enum drbd_packet cmd,
int size, int vnr)
{ … }
static unsigned int prepare_header(struct drbd_connection *connection, int vnr,
void *buffer, enum drbd_packet cmd, int size)
{ … }
static void *__conn_prepare_command(struct drbd_connection *connection,
struct drbd_socket *sock)
{ … }
void *conn_prepare_command(struct drbd_connection *connection, struct drbd_socket *sock)
{ … }
void *drbd_prepare_command(struct drbd_peer_device *peer_device, struct drbd_socket *sock)
{ … }
static int __send_command(struct drbd_connection *connection, int vnr,
struct drbd_socket *sock, enum drbd_packet cmd,
unsigned int header_size, void *data,
unsigned int size)
{ … }
static int __conn_send_command(struct drbd_connection *connection, struct drbd_socket *sock,
enum drbd_packet cmd, unsigned int header_size,
void *data, unsigned int size)
{ … }
int conn_send_command(struct drbd_connection *connection, struct drbd_socket *sock,
enum drbd_packet cmd, unsigned int header_size,
void *data, unsigned int size)
{ … }
int drbd_send_command(struct drbd_peer_device *peer_device, struct drbd_socket *sock,
enum drbd_packet cmd, unsigned int header_size,
void *data, unsigned int size)
{ … }
int drbd_send_ping(struct drbd_connection *connection)
{ … }
int drbd_send_ping_ack(struct drbd_connection *connection)
{ … }
int drbd_send_sync_param(struct drbd_peer_device *peer_device)
{ … }
int __drbd_send_protocol(struct drbd_connection *connection, enum drbd_packet cmd)
{ … }
int drbd_send_protocol(struct drbd_connection *connection)
{ … }
static int _drbd_send_uuids(struct drbd_peer_device *peer_device, u64 uuid_flags)
{ … }
int drbd_send_uuids(struct drbd_peer_device *peer_device)
{ … }
int drbd_send_uuids_skip_initial_sync(struct drbd_peer_device *peer_device)
{ … }
void drbd_print_uuids(struct drbd_device *device, const char *text)
{ … }
void drbd_gen_and_send_sync_uuid(struct drbd_peer_device *peer_device)
{ … }
int drbd_send_sizes(struct drbd_peer_device *peer_device, int trigger_reply, enum dds_flags flags)
{ … }
int drbd_send_current_state(struct drbd_peer_device *peer_device)
{ … }
int drbd_send_state(struct drbd_peer_device *peer_device, union drbd_state state)
{ … }
int drbd_send_state_req(struct drbd_peer_device *peer_device, union drbd_state mask, union drbd_state val)
{ … }
int conn_send_state_req(struct drbd_connection *connection, union drbd_state mask, union drbd_state val)
{ … }
void drbd_send_sr_reply(struct drbd_peer_device *peer_device, enum drbd_state_rv retcode)
{ … }
void conn_send_sr_reply(struct drbd_connection *connection, enum drbd_state_rv retcode)
{ … }
static void dcbp_set_code(struct p_compressed_bm *p, enum drbd_bitmap_code code)
{ … }
static void dcbp_set_start(struct p_compressed_bm *p, int set)
{ … }
static void dcbp_set_pad_bits(struct p_compressed_bm *p, int n)
{ … }
static int fill_bitmap_rle_bits(struct drbd_device *device,
struct p_compressed_bm *p,
unsigned int size,
struct bm_xfer_ctx *c)
{ … }
static int
send_bitmap_rle_or_plain(struct drbd_peer_device *peer_device, struct bm_xfer_ctx *c)
{ … }
static int _drbd_send_bitmap(struct drbd_device *device,
struct drbd_peer_device *peer_device)
{ … }
int drbd_send_bitmap(struct drbd_device *device, struct drbd_peer_device *peer_device)
{ … }
void drbd_send_b_ack(struct drbd_connection *connection, u32 barrier_nr, u32 set_size)
{ … }
static int _drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
u64 sector, u32 blksize, u64 block_id)
{ … }
void drbd_send_ack_dp(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
struct p_data *dp, int data_size)
{ … }
void drbd_send_ack_rp(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
struct p_block_req *rp)
{ … }
int drbd_send_ack(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
struct drbd_peer_request *peer_req)
{ … }
int drbd_send_ack_ex(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
sector_t sector, int blksize, u64 block_id)
{ … }
int drbd_send_rs_deallocated(struct drbd_peer_device *peer_device,
struct drbd_peer_request *peer_req)
{ … }
int drbd_send_drequest(struct drbd_peer_device *peer_device, int cmd,
sector_t sector, int size, u64 block_id)
{ … }
int drbd_send_drequest_csum(struct drbd_peer_device *peer_device, sector_t sector, int size,
void *digest, int digest_size, enum drbd_packet cmd)
{ … }
int drbd_send_ov_request(struct drbd_peer_device *peer_device, sector_t sector, int size)
{ … }
static int we_should_drop_the_connection(struct drbd_connection *connection, struct socket *sock)
{ … }
static void drbd_update_congested(struct drbd_connection *connection)
{ … }
static int _drbd_no_send_page(struct drbd_peer_device *peer_device, struct page *page,
int offset, size_t size, unsigned msg_flags)
{ … }
static int _drbd_send_page(struct drbd_peer_device *peer_device, struct page *page,
int offset, size_t size, unsigned msg_flags)
{ … }
static int _drbd_send_bio(struct drbd_peer_device *peer_device, struct bio *bio)
{ … }
static int _drbd_send_zc_bio(struct drbd_peer_device *peer_device, struct bio *bio)
{ … }
static int _drbd_send_zc_ee(struct drbd_peer_device *peer_device,
struct drbd_peer_request *peer_req)
{ … }
static u32 bio_flags_to_wire(struct drbd_connection *connection,
struct bio *bio)
{ … }
int drbd_send_dblock(struct drbd_peer_device *peer_device, struct drbd_request *req)
{ … }
int drbd_send_block(struct drbd_peer_device *peer_device, enum drbd_packet cmd,
struct drbd_peer_request *peer_req)
{ … }
int drbd_send_out_of_sync(struct drbd_peer_device *peer_device, struct drbd_request *req)
{ … }
int drbd_send(struct drbd_connection *connection, struct socket *sock,
void *buf, size_t size, unsigned msg_flags)
{ … }
int drbd_send_all(struct drbd_connection *connection, struct socket *sock, void *buffer,
size_t size, unsigned msg_flags)
{ … }
static int drbd_open(struct gendisk *disk, blk_mode_t mode)
{ … }
static void drbd_release(struct gendisk *gd)
{ … }
void drbd_queue_unplug(struct drbd_device *device)
{ … }
static void drbd_set_defaults(struct drbd_device *device)
{ … }
void drbd_init_set_defaults(struct drbd_device *device)
{ … }
void drbd_set_my_capacity(struct drbd_device *device, sector_t size)
{ … }
void drbd_device_cleanup(struct drbd_device *device)
{ … }
static void drbd_destroy_mempools(void)
{ … }
static int drbd_create_mempools(void)
{ … }
static void drbd_release_all_peer_reqs(struct drbd_device *device)
{ … }
void drbd_destroy_device(struct kref *kref)
{ … }
static struct retry_worker { … } retry;
static void do_retry(struct work_struct *ws)
{ … }
void drbd_restart_request(struct drbd_request *req)
{ … }
void drbd_destroy_resource(struct kref *kref)
{ … }
void drbd_free_resource(struct drbd_resource *resource)
{ … }
static void drbd_cleanup(void)
{ … }
static void drbd_init_workqueue(struct drbd_work_queue* wq)
{ … }
struct completion_work { … };
static int w_complete(struct drbd_work *w, int cancel)
{ … }
void drbd_flush_workqueue(struct drbd_work_queue *work_queue)
{ … }
struct drbd_resource *drbd_find_resource(const char *name)
{ … }
struct drbd_connection *conn_get_by_addrs(void *my_addr, int my_addr_len,
void *peer_addr, int peer_addr_len)
{ … }
static int drbd_alloc_socket(struct drbd_socket *socket)
{ … }
static void drbd_free_socket(struct drbd_socket *socket)
{ … }
void conn_free_crypto(struct drbd_connection *connection)
{ … }
int set_resource_options(struct drbd_resource *resource, struct res_opts *res_opts)
{ … }
struct drbd_resource *drbd_create_resource(const char *name)
{ … }
struct drbd_connection *conn_create(const char *name, struct res_opts *res_opts)
{ … }
void drbd_destroy_connection(struct kref *kref)
{ … }
static int init_submitter(struct drbd_device *device)
{ … }
enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsigned int minor)
{ … }
void drbd_delete_device(struct drbd_device *device)
{ … }
static int __init drbd_init(void)
{ … }
static void drbd_free_one_sock(struct drbd_socket *ds)
{ … }
void drbd_free_sock(struct drbd_connection *connection)
{ … }
void conn_md_sync(struct drbd_connection *connection)
{ … }
struct meta_data_on_disk { … } __packed;
void drbd_md_write(struct drbd_device *device, void *b)
{ … }
void drbd_md_sync(struct drbd_device *device)
{ … }
static int check_activity_log_stripe_size(struct drbd_device *device,
struct meta_data_on_disk *on_disk,
struct drbd_md *in_core)
{ … }
static int check_offsets_and_sizes(struct drbd_device *device, struct drbd_backing_dev *bdev)
{ … }
int drbd_md_read(struct drbd_device *device, struct drbd_backing_dev *bdev)
{ … }
void drbd_md_mark_dirty(struct drbd_device *device)
{ … }
void drbd_uuid_move_history(struct drbd_device *device) __must_hold(local)
{ … }
void __drbd_uuid_set(struct drbd_device *device, int idx, u64 val) __must_hold(local)
{ … }
void _drbd_uuid_set(struct drbd_device *device, int idx, u64 val) __must_hold(local)
{ … }
void drbd_uuid_set(struct drbd_device *device, int idx, u64 val) __must_hold(local)
{ … }
void drbd_uuid_new_current(struct drbd_device *device) __must_hold(local)
{ … }
void drbd_uuid_set_bm(struct drbd_device *device, u64 val) __must_hold(local)
{ … }
int drbd_bmio_set_n_write(struct drbd_device *device,
struct drbd_peer_device *peer_device) __must_hold(local)
{ … }
int drbd_bmio_clear_n_write(struct drbd_device *device,
struct drbd_peer_device *peer_device) __must_hold(local)
{ … }
static int w_bitmap_io(struct drbd_work *w, int unused)
{ … }
void drbd_queue_bitmap_io(struct drbd_device *device,
int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
void (*done)(struct drbd_device *, int),
char *why, enum bm_flag flags,
struct drbd_peer_device *peer_device)
{ … }
int drbd_bitmap_io(struct drbd_device *device,
int (*io_fn)(struct drbd_device *, struct drbd_peer_device *),
char *why, enum bm_flag flags,
struct drbd_peer_device *peer_device)
{ … }
void drbd_md_set_flag(struct drbd_device *device, int flag) __must_hold(local)
{ … }
void drbd_md_clear_flag(struct drbd_device *device, int flag) __must_hold(local)
{ … }
int drbd_md_test_flag(struct drbd_backing_dev *bdev, int flag)
{ … }
static void md_sync_timer_fn(struct timer_list *t)
{ … }
const char *cmdname(enum drbd_packet cmd)
{ … }
int drbd_wait_misc(struct drbd_device *device, struct drbd_interval *i)
{ … }
void lock_all_resources(void)
{ … }
void unlock_all_resources(void)
{ … }
#ifdef CONFIG_DRBD_FAULT_INJECTION
struct fault_random_state { … };
#define FAULT_RANDOM_MULT …
#define FAULT_RANDOM_ADD …
#define FAULT_RANDOM_REFRESH …
static unsigned long
_drbd_fault_random(struct fault_random_state *rsp)
{ … }
static char *
_drbd_fault_str(unsigned int type) { … }
unsigned int
_drbd_insert_fault(struct drbd_device *device, unsigned int type)
{ … }
#endif
module_init(…) …
module_exit(…)
EXPORT_SYMBOL(…);
EXPORT_SYMBOL(…);
EXPORT_SYMBOL(…);
EXPORT_SYMBOL(…);