linux/drivers/md/dm-ebs-target.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2020 Red Hat GmbH
 *
 * This file is released under the GPL.
 *
 * Device-mapper target to emulate smaller logical block
 * size on backing devices exposing (natively) larger ones.
 *
 * E.g. 512 byte sector emulation on 4K native disks.
 */

#include "dm.h"
#include <linux/module.h>
#include <linux/workqueue.h>
#include <linux/dm-bufio.h>

#define DM_MSG_PREFIX

static void ebs_dtr(struct dm_target *ti);

/* Emulated block size context. */
struct ebs_c {};

static inline sector_t __sector_to_block(struct ebs_c *ec, sector_t sector)
{}

static inline sector_t __block_mod(sector_t sector, unsigned int bs)
{}

/* Return number of blocks for a bio, accounting for misalignment of start and end sectors. */
static inline unsigned int __nr_blocks(struct ebs_c *ec, struct bio *bio)
{}

static inline bool __ebs_check_bs(unsigned int bs)
{}

/*
 * READ/WRITE:
 *
 * copy blocks between bufio blocks and bio vector's (partial/overlapping) pages.
 */
static int __ebs_rw_bvec(struct ebs_c *ec, enum req_op op, struct bio_vec *bv,
			 struct bvec_iter *iter)
{}

/* READ/WRITE: iterate bio vector's copying between (partial) pages and bufio blocks. */
static int __ebs_rw_bio(struct ebs_c *ec, enum req_op op, struct bio *bio)
{}

/*
 * Discard bio's blocks, i.e. pass discards down.
 *
 * Avoid discarding partial blocks at beginning and end;
 * return 0 in case no blocks can be discarded as a result.
 */
static int __ebs_discard_bio(struct ebs_c *ec, struct bio *bio)
{}

/* Release blocks them from the bufio cache. */
static void __ebs_forget_bio(struct ebs_c *ec, struct bio *bio)
{}

/* Worker function to process incoming bios. */
static void __ebs_process_bios(struct work_struct *ws)
{}

/*
 * Construct an emulated block size mapping: <dev_path> <offset> <ebs> [<ubs>]
 *
 * <dev_path>: path of the underlying device
 * <offset>: offset in 512 bytes sectors into <dev_path>
 * <ebs>: emulated block size in units of 512 bytes exposed to the upper layer
 * [<ubs>]: underlying block size in units of 512 bytes imposed on the lower layer;
 *	    optional, if not supplied, retrieve logical block size from underlying device
 */
static int ebs_ctr(struct dm_target *ti, unsigned int argc, char **argv)
{}

static void ebs_dtr(struct dm_target *ti)
{}

static int ebs_map(struct dm_target *ti, struct bio *bio)
{}

static void ebs_status(struct dm_target *ti, status_type_t type,
		       unsigned int status_flags, char *result, unsigned int maxlen)
{}

static int ebs_prepare_ioctl(struct dm_target *ti, struct block_device **bdev)
{}

static void ebs_io_hints(struct dm_target *ti, struct queue_limits *limits)
{}

static int ebs_iterate_devices(struct dm_target *ti,
				  iterate_devices_callout_fn fn, void *data)
{}

static struct target_type ebs_target =;
module_dm(ebs);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();