linux/block/blk-sysfs.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Functions related to sysfs handling
 */
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/bio.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/blktrace_api.h>
#include <linux/debugfs.h>

#include "blk.h"
#include "blk-mq.h"
#include "blk-mq-debugfs.h"
#include "blk-mq-sched.h"
#include "blk-rq-qos.h"
#include "blk-wbt.h"
#include "blk-cgroup.h"
#include "blk-throttle.h"

struct queue_sysfs_entry {};

static ssize_t
queue_var_show(unsigned long var, char *page)
{}

static ssize_t
queue_var_store(unsigned long *var, const char *page, size_t count)
{}

static ssize_t queue_requests_show(struct gendisk *disk, char *page)
{}

static ssize_t
queue_requests_store(struct gendisk *disk, const char *page, size_t count)
{}

static ssize_t queue_ra_show(struct gendisk *disk, char *page)
{}

static ssize_t
queue_ra_store(struct gendisk *disk, const char *page, size_t count)
{}

#define QUEUE_SYSFS_LIMIT_SHOW(_field)

QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()
QUEUE_SYSFS_LIMIT_SHOW()

#define QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES(_field)

QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES()
QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES()
QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES()
QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES()
QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES()

#define QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB(_field)

QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB()
QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_KB()

#define QUEUE_SYSFS_SHOW_CONST(_name, _val)

/* deprecated fields */
QUEUE_SYSFS_SHOW_CONST(discard_zeroes_data, 0)
QUEUE_SYSFS_SHOW_CONST(write_same_max, 0)
QUEUE_SYSFS_SHOW_CONST(poll_delay, -1)

static ssize_t queue_max_discard_sectors_store(struct gendisk *disk,
		const char *page, size_t count)
{}

/*
 * For zone append queue_max_zone_append_sectors does not just return the
 * underlying queue limits, but actually contains a calculation.  Because of
 * that we can't simply use QUEUE_SYSFS_LIMIT_SHOW_SECTORS_TO_BYTES here.
 */
static ssize_t queue_zone_append_max_show(struct gendisk *disk, char *page)
{}

static ssize_t
queue_max_sectors_store(struct gendisk *disk, const char *page, size_t count)
{}

static ssize_t queue_feature_store(struct gendisk *disk, const char *page,
		size_t count, blk_features_t feature)
{}

#define QUEUE_SYSFS_FEATURE(_name, _feature)

QUEUE_SYSFS_FEATURE(rotational, BLK_FEAT_ROTATIONAL)
QUEUE_SYSFS_FEATURE(add_random, BLK_FEAT_ADD_RANDOM)
QUEUE_SYSFS_FEATURE(iostats, BLK_FEAT_IO_STAT)
QUEUE_SYSFS_FEATURE(stable_writes, BLK_FEAT_STABLE_WRITES);

#define QUEUE_SYSFS_FEATURE_SHOW(_name, _feature)

QUEUE_SYSFS_FEATURE_SHOW(poll, BLK_FEAT_POLL);
QUEUE_SYSFS_FEATURE_SHOW(fua, BLK_FEAT_FUA);
QUEUE_SYSFS_FEATURE_SHOW(dax, BLK_FEAT_DAX);

static ssize_t queue_zoned_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_nr_zones_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_nomerges_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_nomerges_store(struct gendisk *disk, const char *page,
				    size_t count)
{}

static ssize_t queue_rq_affinity_show(struct gendisk *disk, char *page)
{}

static ssize_t
queue_rq_affinity_store(struct gendisk *disk, const char *page, size_t count)
{}

static ssize_t queue_poll_delay_store(struct gendisk *disk, const char *page,
				size_t count)
{}

static ssize_t queue_poll_store(struct gendisk *disk, const char *page,
				size_t count)
{}

static ssize_t queue_io_timeout_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_io_timeout_store(struct gendisk *disk, const char *page,
				  size_t count)
{}

static ssize_t queue_wc_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_wc_store(struct gendisk *disk, const char *page,
			      size_t count)
{}

#define QUEUE_RO_ENTRY(_prefix, _name)

#define QUEUE_RW_ENTRY(_prefix, _name)

QUEUE_RW_ENTRY(queue_requests, "nr_requests");
QUEUE_RW_ENTRY(queue_ra, "read_ahead_kb");
QUEUE_RW_ENTRY(queue_max_sectors, "max_sectors_kb");
QUEUE_RO_ENTRY(queue_max_hw_sectors, "max_hw_sectors_kb");
QUEUE_RO_ENTRY(queue_max_segments, "max_segments");
QUEUE_RO_ENTRY(queue_max_integrity_segments, "max_integrity_segments");
QUEUE_RO_ENTRY(queue_max_segment_size, "max_segment_size");
QUEUE_RW_ENTRY(elv_iosched, "scheduler");

QUEUE_RO_ENTRY(queue_logical_block_size, "logical_block_size");
QUEUE_RO_ENTRY(queue_physical_block_size, "physical_block_size");
QUEUE_RO_ENTRY(queue_chunk_sectors, "chunk_sectors");
QUEUE_RO_ENTRY(queue_io_min, "minimum_io_size");
QUEUE_RO_ENTRY(queue_io_opt, "optimal_io_size");

QUEUE_RO_ENTRY(queue_max_discard_segments, "max_discard_segments");
QUEUE_RO_ENTRY(queue_discard_granularity, "discard_granularity");
QUEUE_RO_ENTRY(queue_max_hw_discard_sectors, "discard_max_hw_bytes");
QUEUE_RW_ENTRY(queue_max_discard_sectors, "discard_max_bytes");
QUEUE_RO_ENTRY(queue_discard_zeroes_data, "discard_zeroes_data");

QUEUE_RO_ENTRY(queue_atomic_write_max_sectors, "atomic_write_max_bytes");
QUEUE_RO_ENTRY(queue_atomic_write_boundary_sectors,
		"atomic_write_boundary_bytes");
QUEUE_RO_ENTRY(queue_atomic_write_unit_max, "atomic_write_unit_max_bytes");
QUEUE_RO_ENTRY(queue_atomic_write_unit_min, "atomic_write_unit_min_bytes");

QUEUE_RO_ENTRY(queue_write_same_max, "write_same_max_bytes");
QUEUE_RO_ENTRY(queue_max_write_zeroes_sectors, "write_zeroes_max_bytes");
QUEUE_RO_ENTRY(queue_zone_append_max, "zone_append_max_bytes");
QUEUE_RO_ENTRY(queue_zone_write_granularity, "zone_write_granularity");

QUEUE_RO_ENTRY(queue_zoned, "zoned");
QUEUE_RO_ENTRY(queue_nr_zones, "nr_zones");
QUEUE_RO_ENTRY(queue_max_open_zones, "max_open_zones");
QUEUE_RO_ENTRY(queue_max_active_zones, "max_active_zones");

QUEUE_RW_ENTRY(queue_nomerges, "nomerges");
QUEUE_RW_ENTRY(queue_rq_affinity, "rq_affinity");
QUEUE_RW_ENTRY(queue_poll, "io_poll");
QUEUE_RW_ENTRY(queue_poll_delay, "io_poll_delay");
QUEUE_RW_ENTRY(queue_wc, "write_cache");
QUEUE_RO_ENTRY(queue_fua, "fua");
QUEUE_RO_ENTRY(queue_dax, "dax");
QUEUE_RW_ENTRY(queue_io_timeout, "io_timeout");
QUEUE_RO_ENTRY(queue_virt_boundary_mask, "virt_boundary_mask");
QUEUE_RO_ENTRY(queue_dma_alignment, "dma_alignment");

/* legacy alias for logical_block_size: */
static struct queue_sysfs_entry queue_hw_sector_size_entry =;

QUEUE_RW_ENTRY(queue_rotational, "rotational");
QUEUE_RW_ENTRY(queue_iostats, "iostats");
QUEUE_RW_ENTRY(queue_add_random, "add_random");
QUEUE_RW_ENTRY(queue_stable_writes, "stable_writes");

#ifdef CONFIG_BLK_WBT
static ssize_t queue_var_store64(s64 *var, const char *page)
{}

static ssize_t queue_wb_lat_show(struct gendisk *disk, char *page)
{}

static ssize_t queue_wb_lat_store(struct gendisk *disk, const char *page,
				  size_t count)
{}

QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
#endif

/* Common attributes for bio-based and request-based queues. */
static struct attribute *queue_attrs[] =;

/* Request-based queue attributes that are not relevant for bio-based queues. */
static struct attribute *blk_mq_queue_attrs[] =;

static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
				int n)
{}

static umode_t blk_mq_queue_attr_visible(struct kobject *kobj,
					 struct attribute *attr, int n)
{}

static struct attribute_group queue_attr_group =;

static struct attribute_group blk_mq_queue_attr_group =;

#define to_queue(atr)

static ssize_t
queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
{}

static ssize_t
queue_attr_store(struct kobject *kobj, struct attribute *attr,
		    const char *page, size_t length)
{}

static const struct sysfs_ops queue_sysfs_ops =;

static const struct attribute_group *blk_queue_attr_groups[] =;

static void blk_queue_release(struct kobject *kobj)
{}

static const struct kobj_type blk_queue_ktype =;

static void blk_debugfs_remove(struct gendisk *disk)
{}

/**
 * blk_register_queue - register a block layer queue with sysfs
 * @disk: Disk of which the request queue should be registered with sysfs.
 */
int blk_register_queue(struct gendisk *disk)
{}

/**
 * blk_unregister_queue - counterpart of blk_register_queue()
 * @disk: Disk of which the request queue should be unregistered from sysfs.
 *
 * Note: the caller is responsible for guaranteeing that this function is called
 * after blk_register_queue() has finished.
 */
void blk_unregister_queue(struct gendisk *disk)
{}