// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (c) 2025, Christoph Hellwig.
* Copyright (c) 2025, Western Digital Corporation or its affiliates.
*
* Zoned Loop Device driver - exports a zoned block device using one file per
* zone as backing storage.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/blk-mq.h>
#include <linux/blkzoned.h>
#include <linux/pagemap.h>
#include <linux/miscdevice.h>
#include <linux/falloc.h>
#include <linux/mutex.h>
#include <linux/parser.h>
#include <linux/seq_file.h>
/*
* Options for adding (and removing) a device.
*/
enum {
ZLOOP_OPT_ERR = 0,
ZLOOP_OPT_ID = (1 << 0),
ZLOOP_OPT_CAPACITY = (1 << 1),
ZLOOP_OPT_ZONE_SIZE = (1 << 2),
ZLOOP_OPT_ZONE_CAPACITY = (1 << 3),
ZLOOP_OPT_NR_CONV_ZONES = (1 << 4),
ZLOOP_OPT_BASE_DIR = (1 << 5),
ZLOOP_OPT_NR_QUEUES = (1 << 6),
ZLOOP_OPT_QUEUE_DEPTH = (1 << 7),
ZLOOP_OPT_BUFFERED_IO = (1 << 8),
};
static const match_table_t zloop_opt_tokens = {
{ ZLOOP_OPT_ID, "id=%d" },
{ ZLOOP_OPT_CAPACITY, "capacity_mb=%u" },
{ ZLOOP_OPT_ZONE_SIZE, "zone_size_mb=%u" },
{ ZLOOP_OPT_ZONE_CAPACITY, "zone_capacity_mb=%u" },
{ ZLOOP_OPT_NR_CONV_ZONES, "conv_zones=%u" },
{ ZLOOP_OPT_BASE_DIR, "base_dir=%s" },
{ ZLOOP_OPT_NR_QUEUES, "nr_queues=%u" },
{ ZLOOP_OPT_QUEUE_DEPTH, "queue_depth=%u" },
{ ZLOOP_OPT_BUFFERED_IO, "buffered_io" },
{ ZLOOP_OPT_ERR, NULL