c259cc9cb4
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmUlrb4ACgkQONu9yGCS aT4b+hAAgvFC6P+XmyyNXJ9ISHLkgSlcIAdatb+qeOCUtdiWHqfxIha13FdnCdhL WS2c/O9ORfAzjFwnYWF6LBwH8ArxRSkAXrGCMuCkEFBP3cG/j2HD+XLAAYEuBjjb sf1fw8e8VSgaPEOnwXie5rTfAY4VnZKEtZjAxjyIQnJKVVKfxQRb8CyaWDPzPD0Z tL/iABt7UWNHZayHTHsh0YhF2UhXtOjHinWigEarcZQEvOB2qRQtFl71cnqosi+t 3ZRZzepH7/Fx3v6/H/6PNq+GSI/ZzhOiCQolVV5YcMGHXsW9cP6arjLUxco5pzpk pEg0vdMq47JOZYQ2pIewG4t7+NLmFIxCRFnKQVbxeFNSY9c1jhd8g5lhx9YEXwjT BzMtV5DnZoaoMdq2P1STw/+RVYrDI1Lm6jqfgw/D27b7LzQ13VsGM9BJ1rCs8Hm7 UhWyjwFcgo0vhpfML1RF0RtT9Mo5SOnpGPfpbFdjg8jdXlGknNH0QsH+EY/BpF8l h77P5BvoNIjsIN3B1YunfXtFXhx3h0sI8zZrqHR+zhOeWGsXcqQ5mZ/lYdYKkKuH R8LRB7shPndF4xdRX0uRXwomcXhs+60eA5xEvE9u0CqqdpXfQN5oTwixfCm2C8MS O5Fc7hfvK11XtR3ja+y3KRhiNG3YsfW2PXnlOfZxMZ6iPqXtA/o= =5/pn -----END PGP SIGNATURE----- Merge 6.1.57 into android14-6.1-lts Changes in 6.1.57 spi: zynqmp-gqspi: fix clock imbalance on probe failure ASoC: soc-utils: Export snd_soc_dai_is_dummy() symbol ASoC: tegra: Fix redundant PLLA and PLLA_OUT0 updates mptcp: rename timer related helper to less confusing names mptcp: fix dangling connection hang-up mptcp: annotate lockless accesses to sk->sk_err mptcp: move __mptcp_error_report in protocol.c mptcp: process pending subflow error on close ata,scsi: do not issue START STOP UNIT on resume scsi: sd: Differentiate system and runtime start/stop management scsi: sd: Do not issue commands to suspended disks on shutdown scsi: core: Improve type safety of scsi_rescan_device() scsi: Do not attempt to rescan suspended devices ata: libata-scsi: Fix delayed scsi_rescan_device() execution NFS: Cleanup unused rpc_clnt variable NFS: rename nfs_client_kset to nfs_kset NFSv4: Fix a state manager thread deadlock regression mm/memory: add vm_normal_folio() mm/mempolicy: convert queue_pages_pmd() to queue_folios_pmd() mm/mempolicy: convert queue_pages_pte_range() to queue_folios_pte_range() mm/mempolicy: convert migrate_page_add() to migrate_folio_add() mm: mempolicy: keep VMA walk if both MPOL_MF_STRICT and MPOL_MF_MOVE are specified mm/page_alloc: always remove pages from temporary list mm/page_alloc: leave IRQs enabled for per-cpu page allocations mm: page_alloc: fix CMA and HIGHATOMIC landing on the wrong buddy list ring-buffer: remove obsolete comment for free_buffer_page() ring-buffer: Fix bytes info in per_cpu buffer stats btrfs: use struct qstr instead of name and namelen pairs btrfs: setup qstr from dentrys using fscrypt helper btrfs: use struct fscrypt_str instead of struct qstr Revert "NFSv4: Retry LOCK on OLD_STATEID during delegation return" arm64: Avoid repeated AA64MMFR1_EL1 register read on pagefault path net: add sysctl accept_ra_min_rtr_lft net: change accept_ra_min_rtr_lft to affect all RA lifetimes net: release reference to inet6_dev pointer arm64: cpufeature: Fix CLRBHB and BC detection drm/amd/display: Adjust the MST resume flow iommu/arm-smmu-v3: Set TTL invalidation hint better iommu/arm-smmu-v3: Avoid constructing invalid range commands rbd: move rbd_dev_refresh() definition rbd: decouple header read-in from updating rbd_dev->header rbd: decouple parent info read-in from updating rbd_dev rbd: take header_rwsem in rbd_dev_refresh() only when updating block: fix use-after-free of q->q_usage_counter hwmon: (nzxt-smart2) Add device id hwmon: (nzxt-smart2) add another USB ID i40e: fix the wrong PTP frequency calculation scsi: zfcp: Fix a double put in zfcp_port_enqueue() iommu/vt-d: Avoid memory allocation in iommu_suspend() vringh: don't use vringh_kiov_advance() in vringh_iov_xfer() net: ethernet: mediatek: disable irq before schedule napi mptcp: userspace pm allow creating id 0 subflow qed/red_ll2: Fix undefined behavior bug in struct qed_ll2_info Bluetooth: hci_codec: Fix leaking content of local_codecs Bluetooth: hci_sync: Fix handling of HCI_QUIRK_STRICT_DUPLICATE_FILTER wifi: mwifiex: Fix tlv_buf_left calculation md/raid5: release batch_last before waiting for another stripe_head PCI: qcom: Fix IPQ8074 enumeration net: replace calls to sock->ops->connect() with kernel_connect() net: prevent rewrite of msg_name in sock_sendmsg() drm/amd: Fix detection of _PR3 on the PCIe root port drm/amd: Fix logic error in sienna_cichlid_update_pcie_parameters() arm64: Add Cortex-A520 CPU part definition arm64: errata: Add Cortex-A520 speculative unprivileged load workaround HID: sony: Fix a potential memory leak in sony_probe() ubi: Refuse attaching if mtd's erasesize is 0 erofs: fix memory leak of LZMA global compressed deduplication wifi: iwlwifi: dbg_ini: fix structure packing wifi: iwlwifi: mvm: Fix a memory corruption issue wifi: cfg80211: hold wiphy lock in auto-disconnect wifi: cfg80211: move wowlan disable under locks wifi: cfg80211: add a work abstraction with special semantics wifi: cfg80211: fix cqm_config access race wifi: cfg80211: add missing kernel-doc for cqm_rssi_work wifi: mwifiex: Fix oob check condition in mwifiex_process_rx_packet leds: Drop BUG_ON check for LED_COLOR_ID_MULTI bpf: Fix tr dereferencing regulator: mt6358: Drop *_SSHUB regulators regulator: mt6358: Use linear voltage helpers for single range regulators regulator: mt6358: split ops for buck and linear range LDO regulators Bluetooth: Delete unused hci_req_prepare_suspend() declaration Bluetooth: ISO: Fix handling of listen for unicast drivers/net: process the result of hdlc_open() and add call of hdlc_close() in uhdlc_close() wifi: mt76: mt76x02: fix MT76x0 external LNA gain handling perf/x86/amd/core: Fix overflow reset on hotplug regmap: rbtree: Fix wrong register marked as in-cache when creating new node wifi: mac80211: fix potential key use-after-free perf/x86/amd: Do not WARN() on every IRQ iommu/mediatek: Fix share pgtable for iova over 4GB regulator/core: regulator_register: set device->class earlier ima: Finish deprecation of IMA_TRUSTED_KEYRING Kconfig scsi: target: core: Fix deadlock due to recursive locking ima: rework CONFIG_IMA dependency block NFSv4: Fix a nfs4_state_manager() race bpf: tcp_read_skb needs to pop skb regardless of seq bpf, sockmap: Do not inc copied_seq when PEEK flag set bpf, sockmap: Reject sk_msg egress redirects to non-TCP sockets modpost: add missing else to the "of" check net: fix possible store tearing in neigh_periodic_work() bpf: Add BPF_FIB_LOOKUP_SKIP_NEIGH for bpf_fib_lookup neighbour: annotate lockless accesses to n->nud_state neighbour: switch to standard rcu, instead of rcu_bh neighbour: fix data-races around n->output ipv4, ipv6: Fix handling of transhdrlen in __ip{,6}_append_data() ptp: ocp: Fix error handling in ptp_ocp_device_init net: dsa: mv88e6xxx: Avoid EEPROM timeout when EEPROM is absent ipv6: tcp: add a missing nf_reset_ct() in 3WHS handling net: usb: smsc75xx: Fix uninit-value access in __smsc75xx_read_reg net: nfc: llcp: Add lock when modifying device list net: ethernet: ti: am65-cpsw: Fix error code in am65_cpsw_nuss_init_tx_chns() ibmveth: Remove condition to recompute TCP header checksum. netfilter: handle the connecting collision properly in nf_conntrack_proto_sctp selftests: netfilter: Test nf_tables audit logging selftests: netfilter: Extend nft_audit.sh netfilter: nf_tables: Deduplicate nft_register_obj audit logs netfilter: nf_tables: nft_set_rbtree: fix spurious insertion failure ipv4: Set offload_failed flag in fibmatch results net: stmmac: dwmac-stm32: fix resume on STM32 MCU tipc: fix a potential deadlock on &tx->lock tcp: fix quick-ack counting to count actual ACKs of new data tcp: fix delayed ACKs for MSS boundary condition sctp: update transport state when processing a dupcook packet sctp: update hb timer immediately after users change hb_interval netlink: split up copies in the ack construction netlink: Fix potential skb memleak in netlink_ack netlink: annotate data-races around sk->sk_err HID: sony: remove duplicate NULL check before calling usb_free_urb() HID: intel-ish-hid: ipc: Disable and reenable ACPI GPE bit intel_idle: add Emerald Rapids Xeon support smb: use kernel_connect() and kernel_bind() parisc: Fix crash with nr_cpus=1 option dm zoned: free dmz->ddev array in dmz_put_zoned_devices RDMA/core: Require admin capabilities to set system parameters of: dynamic: Fix potential memory leak in of_changeset_action() IB/mlx4: Fix the size of a buffer in add_port_entries() gpio: aspeed: fix the GPIO number passed to pinctrl_gpio_set_config() gpio: pxa: disable pinctrl calls for MMP_GPIO RDMA/cma: Initialize ib_sa_multicast structure to 0 when join RDMA/cma: Fix truncation compilation warning in make_cma_ports RDMA/uverbs: Fix typo of sizeof argument RDMA/srp: Do not call scsi_done() from srp_abort() RDMA/siw: Fix connection failure handling RDMA/mlx5: Fix mutex unlocking on error flow for steering anchor creation RDMA/mlx5: Fix NULL string error x86/sev: Use the GHCB protocol when available for SNP CPUID requests ksmbd: fix race condition between session lookup and expire ksmbd: fix uaf in smb20_oplock_break_ack parisc: Restore __ldcw_align for PA-RISC 2.0 processors ipv6: remove nexthop_fib6_nh_bh() vrf: Fix lockdep splat in output path btrfs: fix an error handling path in btrfs_rename() btrfs: fix fscrypt name leak after failure to join log transaction netlink: remove the flex array from struct nlmsghdr btrfs: file_remove_privs needs an exclusive lock in direct io write ipv6: remove one read_lock()/read_unlock() pair in rt6_check_neigh() xen/events: replace evtchn_rwlock with RCU Linux 6.1.57 Change-Id: I2c200264df72a9043d91d31479c91b0d7f94863e Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
932 lines
24 KiB
C
932 lines
24 KiB
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/blk-mq.h>
|
|
#include <linux/debugfs.h>
|
|
|
|
#include "blk.h"
|
|
#include "blk-mq.h"
|
|
#include "blk-mq-debugfs.h"
|
|
#include "blk-mq-sched.h"
|
|
#include "blk-wbt.h"
|
|
#include "blk-cgroup.h"
|
|
#include "blk-throttle.h"
|
|
|
|
struct queue_sysfs_entry {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct request_queue *, char *);
|
|
ssize_t (*store)(struct request_queue *, const char *, size_t);
|
|
};
|
|
|
|
static ssize_t
|
|
queue_var_show(unsigned long var, char *page)
|
|
{
|
|
return sprintf(page, "%lu\n", var);
|
|
}
|
|
|
|
static ssize_t
|
|
queue_var_store(unsigned long *var, const char *page, size_t count)
|
|
{
|
|
int err;
|
|
unsigned long v;
|
|
|
|
err = kstrtoul(page, 10, &v);
|
|
if (err || v > UINT_MAX)
|
|
return -EINVAL;
|
|
|
|
*var = v;
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_var_store64(s64 *var, const char *page)
|
|
{
|
|
int err;
|
|
s64 v;
|
|
|
|
err = kstrtos64(page, 10, &v);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
*var = v;
|
|
return 0;
|
|
}
|
|
|
|
static ssize_t queue_requests_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(q->nr_requests, page);
|
|
}
|
|
|
|
static ssize_t
|
|
queue_requests_store(struct request_queue *q, const char *page, size_t count)
|
|
{
|
|
unsigned long nr;
|
|
int ret, err;
|
|
|
|
if (!queue_is_mq(q))
|
|
return -EINVAL;
|
|
|
|
ret = queue_var_store(&nr, page, count);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
if (nr < BLKDEV_MIN_RQ)
|
|
nr = BLKDEV_MIN_RQ;
|
|
|
|
err = blk_mq_update_nr_requests(q, nr);
|
|
if (err)
|
|
return err;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_ra_show(struct request_queue *q, char *page)
|
|
{
|
|
unsigned long ra_kb;
|
|
|
|
if (!q->disk)
|
|
return -EINVAL;
|
|
ra_kb = q->disk->bdi->ra_pages << (PAGE_SHIFT - 10);
|
|
return queue_var_show(ra_kb, page);
|
|
}
|
|
|
|
static ssize_t
|
|
queue_ra_store(struct request_queue *q, const char *page, size_t count)
|
|
{
|
|
unsigned long ra_kb;
|
|
ssize_t ret;
|
|
|
|
if (!q->disk)
|
|
return -EINVAL;
|
|
ret = queue_var_store(&ra_kb, page, count);
|
|
if (ret < 0)
|
|
return ret;
|
|
q->disk->bdi->ra_pages = ra_kb >> (PAGE_SHIFT - 10);
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_max_sectors_show(struct request_queue *q, char *page)
|
|
{
|
|
int max_sectors_kb = queue_max_sectors(q) >> 1;
|
|
|
|
return queue_var_show(max_sectors_kb, page);
|
|
}
|
|
|
|
static ssize_t queue_max_segments_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_max_segments(q), page);
|
|
}
|
|
|
|
static ssize_t queue_max_discard_segments_show(struct request_queue *q,
|
|
char *page)
|
|
{
|
|
return queue_var_show(queue_max_discard_segments(q), page);
|
|
}
|
|
|
|
static ssize_t queue_max_integrity_segments_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(q->limits.max_integrity_segments, page);
|
|
}
|
|
|
|
static ssize_t queue_max_segment_size_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_max_segment_size(q), page);
|
|
}
|
|
|
|
static ssize_t queue_logical_block_size_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_logical_block_size(q), page);
|
|
}
|
|
|
|
static ssize_t queue_physical_block_size_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_physical_block_size(q), page);
|
|
}
|
|
|
|
static ssize_t queue_chunk_sectors_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(q->limits.chunk_sectors, page);
|
|
}
|
|
|
|
static ssize_t queue_io_min_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_io_min(q), page);
|
|
}
|
|
|
|
static ssize_t queue_io_opt_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_io_opt(q), page);
|
|
}
|
|
|
|
static ssize_t queue_discard_granularity_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(q->limits.discard_granularity, page);
|
|
}
|
|
|
|
static ssize_t queue_discard_max_hw_show(struct request_queue *q, char *page)
|
|
{
|
|
|
|
return sprintf(page, "%llu\n",
|
|
(unsigned long long)q->limits.max_hw_discard_sectors << 9);
|
|
}
|
|
|
|
static ssize_t queue_discard_max_show(struct request_queue *q, char *page)
|
|
{
|
|
return sprintf(page, "%llu\n",
|
|
(unsigned long long)q->limits.max_discard_sectors << 9);
|
|
}
|
|
|
|
static ssize_t queue_discard_max_store(struct request_queue *q,
|
|
const char *page, size_t count)
|
|
{
|
|
unsigned long max_discard;
|
|
ssize_t ret = queue_var_store(&max_discard, page, count);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
if (max_discard & (q->limits.discard_granularity - 1))
|
|
return -EINVAL;
|
|
|
|
max_discard >>= 9;
|
|
if (max_discard > UINT_MAX)
|
|
return -EINVAL;
|
|
|
|
if (max_discard > q->limits.max_hw_discard_sectors)
|
|
max_discard = q->limits.max_hw_discard_sectors;
|
|
|
|
q->limits.max_discard_sectors = max_discard;
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_discard_zeroes_data_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(0, page);
|
|
}
|
|
|
|
static ssize_t queue_write_same_max_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(0, page);
|
|
}
|
|
|
|
static ssize_t queue_write_zeroes_max_show(struct request_queue *q, char *page)
|
|
{
|
|
return sprintf(page, "%llu\n",
|
|
(unsigned long long)q->limits.max_write_zeroes_sectors << 9);
|
|
}
|
|
|
|
static ssize_t queue_zone_write_granularity_show(struct request_queue *q,
|
|
char *page)
|
|
{
|
|
return queue_var_show(queue_zone_write_granularity(q), page);
|
|
}
|
|
|
|
static ssize_t queue_zone_append_max_show(struct request_queue *q, char *page)
|
|
{
|
|
unsigned long long max_sectors = q->limits.max_zone_append_sectors;
|
|
|
|
return sprintf(page, "%llu\n", max_sectors << SECTOR_SHIFT);
|
|
}
|
|
|
|
static ssize_t
|
|
queue_max_sectors_store(struct request_queue *q, const char *page, size_t count)
|
|
{
|
|
unsigned long max_sectors_kb,
|
|
max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1,
|
|
page_kb = 1 << (PAGE_SHIFT - 10);
|
|
ssize_t ret = queue_var_store(&max_sectors_kb, page, count);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
max_hw_sectors_kb = min_not_zero(max_hw_sectors_kb, (unsigned long)
|
|
q->limits.max_dev_sectors >> 1);
|
|
|
|
if (max_sectors_kb > max_hw_sectors_kb || max_sectors_kb < page_kb)
|
|
return -EINVAL;
|
|
|
|
spin_lock_irq(&q->queue_lock);
|
|
q->limits.max_sectors = max_sectors_kb << 1;
|
|
if (q->disk)
|
|
q->disk->bdi->io_pages = max_sectors_kb >> (PAGE_SHIFT - 10);
|
|
spin_unlock_irq(&q->queue_lock);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_max_hw_sectors_show(struct request_queue *q, char *page)
|
|
{
|
|
int max_hw_sectors_kb = queue_max_hw_sectors(q) >> 1;
|
|
|
|
return queue_var_show(max_hw_sectors_kb, page);
|
|
}
|
|
|
|
static ssize_t queue_virt_boundary_mask_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(q->limits.virt_boundary_mask, page);
|
|
}
|
|
|
|
static ssize_t queue_dma_alignment_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(queue_dma_alignment(q), page);
|
|
}
|
|
|
|
#define QUEUE_SYSFS_BIT_FNS(name, flag, neg) \
|
|
static ssize_t \
|
|
queue_##name##_show(struct request_queue *q, char *page) \
|
|
{ \
|
|
int bit; \
|
|
bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags); \
|
|
return queue_var_show(neg ? !bit : bit, page); \
|
|
} \
|
|
static ssize_t \
|
|
queue_##name##_store(struct request_queue *q, const char *page, size_t count) \
|
|
{ \
|
|
unsigned long val; \
|
|
ssize_t ret; \
|
|
ret = queue_var_store(&val, page, count); \
|
|
if (ret < 0) \
|
|
return ret; \
|
|
if (neg) \
|
|
val = !val; \
|
|
\
|
|
if (val) \
|
|
blk_queue_flag_set(QUEUE_FLAG_##flag, q); \
|
|
else \
|
|
blk_queue_flag_clear(QUEUE_FLAG_##flag, q); \
|
|
return ret; \
|
|
}
|
|
|
|
QUEUE_SYSFS_BIT_FNS(nonrot, NONROT, 1);
|
|
QUEUE_SYSFS_BIT_FNS(random, ADD_RANDOM, 0);
|
|
QUEUE_SYSFS_BIT_FNS(iostats, IO_STAT, 0);
|
|
QUEUE_SYSFS_BIT_FNS(stable_writes, STABLE_WRITES, 0);
|
|
#undef QUEUE_SYSFS_BIT_FNS
|
|
|
|
static ssize_t queue_zoned_show(struct request_queue *q, char *page)
|
|
{
|
|
switch (blk_queue_zoned_model(q)) {
|
|
case BLK_ZONED_HA:
|
|
return sprintf(page, "host-aware\n");
|
|
case BLK_ZONED_HM:
|
|
return sprintf(page, "host-managed\n");
|
|
default:
|
|
return sprintf(page, "none\n");
|
|
}
|
|
}
|
|
|
|
static ssize_t queue_nr_zones_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(disk_nr_zones(q->disk), page);
|
|
}
|
|
|
|
static ssize_t queue_max_open_zones_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(bdev_max_open_zones(q->disk->part0), page);
|
|
}
|
|
|
|
static ssize_t queue_max_active_zones_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(bdev_max_active_zones(q->disk->part0), page);
|
|
}
|
|
|
|
static ssize_t queue_nomerges_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show((blk_queue_nomerges(q) << 1) |
|
|
blk_queue_noxmerges(q), page);
|
|
}
|
|
|
|
static ssize_t queue_nomerges_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
unsigned long nm;
|
|
ssize_t ret = queue_var_store(&nm, page, count);
|
|
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
blk_queue_flag_clear(QUEUE_FLAG_NOMERGES, q);
|
|
blk_queue_flag_clear(QUEUE_FLAG_NOXMERGES, q);
|
|
if (nm == 2)
|
|
blk_queue_flag_set(QUEUE_FLAG_NOMERGES, q);
|
|
else if (nm)
|
|
blk_queue_flag_set(QUEUE_FLAG_NOXMERGES, q);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_rq_affinity_show(struct request_queue *q, char *page)
|
|
{
|
|
bool set = test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags);
|
|
bool force = test_bit(QUEUE_FLAG_SAME_FORCE, &q->queue_flags);
|
|
|
|
return queue_var_show(set << force, page);
|
|
}
|
|
|
|
static ssize_t
|
|
queue_rq_affinity_store(struct request_queue *q, const char *page, size_t count)
|
|
{
|
|
ssize_t ret = -EINVAL;
|
|
#ifdef CONFIG_SMP
|
|
unsigned long val;
|
|
|
|
ret = queue_var_store(&val, page, count);
|
|
if (ret < 0)
|
|
return ret;
|
|
|
|
if (val == 2) {
|
|
blk_queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
|
|
blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, q);
|
|
} else if (val == 1) {
|
|
blk_queue_flag_set(QUEUE_FLAG_SAME_COMP, q);
|
|
blk_queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
|
|
} else if (val == 0) {
|
|
blk_queue_flag_clear(QUEUE_FLAG_SAME_COMP, q);
|
|
blk_queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q);
|
|
}
|
|
#endif
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t queue_poll_delay_show(struct request_queue *q, char *page)
|
|
{
|
|
int val;
|
|
|
|
if (q->poll_nsec == BLK_MQ_POLL_CLASSIC)
|
|
val = BLK_MQ_POLL_CLASSIC;
|
|
else
|
|
val = q->poll_nsec / 1000;
|
|
|
|
return sprintf(page, "%d\n", val);
|
|
}
|
|
|
|
static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
int err, val;
|
|
|
|
if (!q->mq_ops || !q->mq_ops->poll)
|
|
return -EINVAL;
|
|
|
|
err = kstrtoint(page, 10, &val);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
if (val == BLK_MQ_POLL_CLASSIC)
|
|
q->poll_nsec = BLK_MQ_POLL_CLASSIC;
|
|
else if (val >= 0)
|
|
q->poll_nsec = val * 1000;
|
|
else
|
|
return -EINVAL;
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_poll_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(test_bit(QUEUE_FLAG_POLL, &q->queue_flags), page);
|
|
}
|
|
|
|
static ssize_t queue_poll_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
if (!test_bit(QUEUE_FLAG_POLL, &q->queue_flags))
|
|
return -EINVAL;
|
|
pr_info_ratelimited("writes to the poll attribute are ignored.\n");
|
|
pr_info_ratelimited("please use driver specific parameters instead.\n");
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_io_timeout_show(struct request_queue *q, char *page)
|
|
{
|
|
return sprintf(page, "%u\n", jiffies_to_msecs(q->rq_timeout));
|
|
}
|
|
|
|
static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
unsigned int val;
|
|
int err;
|
|
|
|
err = kstrtou32(page, 10, &val);
|
|
if (err || val == 0)
|
|
return -EINVAL;
|
|
|
|
blk_queue_rq_timeout(q, msecs_to_jiffies(val));
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
|
|
{
|
|
if (!wbt_rq_qos(q))
|
|
return -EINVAL;
|
|
|
|
return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000));
|
|
}
|
|
|
|
static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
struct rq_qos *rqos;
|
|
ssize_t ret;
|
|
s64 val;
|
|
|
|
ret = queue_var_store64(&val, page);
|
|
if (ret < 0)
|
|
return ret;
|
|
if (val < -1)
|
|
return -EINVAL;
|
|
|
|
rqos = wbt_rq_qos(q);
|
|
if (!rqos) {
|
|
ret = wbt_init(q);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
if (val == -1)
|
|
val = wbt_default_latency_nsec(q);
|
|
else if (val >= 0)
|
|
val *= 1000ULL;
|
|
|
|
if (wbt_get_min_lat(q) == val)
|
|
return count;
|
|
|
|
/*
|
|
* Ensure that the queue is idled, in case the latency update
|
|
* ends up either enabling or disabling wbt completely. We can't
|
|
* have IO inflight if that happens.
|
|
*/
|
|
blk_mq_freeze_queue(q);
|
|
blk_mq_quiesce_queue(q);
|
|
|
|
wbt_set_min_lat(q, val);
|
|
|
|
blk_mq_unquiesce_queue(q);
|
|
blk_mq_unfreeze_queue(q);
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_wc_show(struct request_queue *q, char *page)
|
|
{
|
|
if (test_bit(QUEUE_FLAG_WC, &q->queue_flags))
|
|
return sprintf(page, "write back\n");
|
|
|
|
return sprintf(page, "write through\n");
|
|
}
|
|
|
|
static ssize_t queue_wc_store(struct request_queue *q, const char *page,
|
|
size_t count)
|
|
{
|
|
if (!strncmp(page, "write back", 10)) {
|
|
if (!test_bit(QUEUE_FLAG_HW_WC, &q->queue_flags))
|
|
return -EINVAL;
|
|
blk_queue_flag_set(QUEUE_FLAG_WC, q);
|
|
} else if (!strncmp(page, "write through", 13) ||
|
|
!strncmp(page, "none", 4)) {
|
|
blk_queue_flag_clear(QUEUE_FLAG_WC, q);
|
|
} else {
|
|
return -EINVAL;
|
|
}
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t queue_fua_show(struct request_queue *q, char *page)
|
|
{
|
|
return sprintf(page, "%u\n", test_bit(QUEUE_FLAG_FUA, &q->queue_flags));
|
|
}
|
|
|
|
static ssize_t queue_dax_show(struct request_queue *q, char *page)
|
|
{
|
|
return queue_var_show(blk_queue_dax(q), page);
|
|
}
|
|
|
|
#define QUEUE_RO_ENTRY(_prefix, _name) \
|
|
static struct queue_sysfs_entry _prefix##_entry = { \
|
|
.attr = { .name = _name, .mode = 0444 }, \
|
|
.show = _prefix##_show, \
|
|
};
|
|
|
|
#define QUEUE_RW_ENTRY(_prefix, _name) \
|
|
static struct queue_sysfs_entry _prefix##_entry = { \
|
|
.attr = { .name = _name, .mode = 0644 }, \
|
|
.show = _prefix##_show, \
|
|
.store = _prefix##_store, \
|
|
};
|
|
|
|
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_discard_max_hw, "discard_max_hw_bytes");
|
|
QUEUE_RW_ENTRY(queue_discard_max, "discard_max_bytes");
|
|
QUEUE_RO_ENTRY(queue_discard_zeroes_data, "discard_zeroes_data");
|
|
|
|
QUEUE_RO_ENTRY(queue_write_same_max, "write_same_max_bytes");
|
|
QUEUE_RO_ENTRY(queue_write_zeroes_max, "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_RW_ENTRY(queue_wb_lat, "wbt_lat_usec");
|
|
QUEUE_RO_ENTRY(queue_virt_boundary_mask, "virt_boundary_mask");
|
|
QUEUE_RO_ENTRY(queue_dma_alignment, "dma_alignment");
|
|
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
|
|
QUEUE_RW_ENTRY(blk_throtl_sample_time, "throttle_sample_time");
|
|
#endif
|
|
|
|
/* legacy alias for logical_block_size: */
|
|
static struct queue_sysfs_entry queue_hw_sector_size_entry = {
|
|
.attr = {.name = "hw_sector_size", .mode = 0444 },
|
|
.show = queue_logical_block_size_show,
|
|
};
|
|
|
|
QUEUE_RW_ENTRY(queue_nonrot, "rotational");
|
|
QUEUE_RW_ENTRY(queue_iostats, "iostats");
|
|
QUEUE_RW_ENTRY(queue_random, "add_random");
|
|
QUEUE_RW_ENTRY(queue_stable_writes, "stable_writes");
|
|
|
|
static struct attribute *queue_attrs[] = {
|
|
&queue_requests_entry.attr,
|
|
&queue_ra_entry.attr,
|
|
&queue_max_hw_sectors_entry.attr,
|
|
&queue_max_sectors_entry.attr,
|
|
&queue_max_segments_entry.attr,
|
|
&queue_max_discard_segments_entry.attr,
|
|
&queue_max_integrity_segments_entry.attr,
|
|
&queue_max_segment_size_entry.attr,
|
|
&elv_iosched_entry.attr,
|
|
&queue_hw_sector_size_entry.attr,
|
|
&queue_logical_block_size_entry.attr,
|
|
&queue_physical_block_size_entry.attr,
|
|
&queue_chunk_sectors_entry.attr,
|
|
&queue_io_min_entry.attr,
|
|
&queue_io_opt_entry.attr,
|
|
&queue_discard_granularity_entry.attr,
|
|
&queue_discard_max_entry.attr,
|
|
&queue_discard_max_hw_entry.attr,
|
|
&queue_discard_zeroes_data_entry.attr,
|
|
&queue_write_same_max_entry.attr,
|
|
&queue_write_zeroes_max_entry.attr,
|
|
&queue_zone_append_max_entry.attr,
|
|
&queue_zone_write_granularity_entry.attr,
|
|
&queue_nonrot_entry.attr,
|
|
&queue_zoned_entry.attr,
|
|
&queue_nr_zones_entry.attr,
|
|
&queue_max_open_zones_entry.attr,
|
|
&queue_max_active_zones_entry.attr,
|
|
&queue_nomerges_entry.attr,
|
|
&queue_rq_affinity_entry.attr,
|
|
&queue_iostats_entry.attr,
|
|
&queue_stable_writes_entry.attr,
|
|
&queue_random_entry.attr,
|
|
&queue_poll_entry.attr,
|
|
&queue_wc_entry.attr,
|
|
&queue_fua_entry.attr,
|
|
&queue_dax_entry.attr,
|
|
&queue_wb_lat_entry.attr,
|
|
&queue_poll_delay_entry.attr,
|
|
&queue_io_timeout_entry.attr,
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
|
|
&blk_throtl_sample_time_entry.attr,
|
|
#endif
|
|
&queue_virt_boundary_mask_entry.attr,
|
|
&queue_dma_alignment_entry.attr,
|
|
NULL,
|
|
};
|
|
|
|
static umode_t queue_attr_visible(struct kobject *kobj, struct attribute *attr,
|
|
int n)
|
|
{
|
|
struct request_queue *q =
|
|
container_of(kobj, struct request_queue, kobj);
|
|
|
|
if (attr == &queue_io_timeout_entry.attr &&
|
|
(!q->mq_ops || !q->mq_ops->timeout))
|
|
return 0;
|
|
|
|
if ((attr == &queue_max_open_zones_entry.attr ||
|
|
attr == &queue_max_active_zones_entry.attr) &&
|
|
!blk_queue_is_zoned(q))
|
|
return 0;
|
|
|
|
return attr->mode;
|
|
}
|
|
|
|
static struct attribute_group queue_attr_group = {
|
|
.attrs = queue_attrs,
|
|
.is_visible = queue_attr_visible,
|
|
};
|
|
|
|
|
|
#define to_queue(atr) container_of((atr), struct queue_sysfs_entry, attr)
|
|
|
|
static ssize_t
|
|
queue_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
|
|
{
|
|
struct queue_sysfs_entry *entry = to_queue(attr);
|
|
struct request_queue *q =
|
|
container_of(kobj, struct request_queue, kobj);
|
|
ssize_t res;
|
|
|
|
if (!entry->show)
|
|
return -EIO;
|
|
mutex_lock(&q->sysfs_lock);
|
|
res = entry->show(q, page);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
return res;
|
|
}
|
|
|
|
static ssize_t
|
|
queue_attr_store(struct kobject *kobj, struct attribute *attr,
|
|
const char *page, size_t length)
|
|
{
|
|
struct queue_sysfs_entry *entry = to_queue(attr);
|
|
struct request_queue *q;
|
|
ssize_t res;
|
|
|
|
if (!entry->store)
|
|
return -EIO;
|
|
|
|
q = container_of(kobj, struct request_queue, kobj);
|
|
mutex_lock(&q->sysfs_lock);
|
|
res = entry->store(q, page, length);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
return res;
|
|
}
|
|
|
|
static void blk_free_queue_rcu(struct rcu_head *rcu_head)
|
|
{
|
|
struct request_queue *q = container_of(rcu_head, struct request_queue,
|
|
rcu_head);
|
|
|
|
percpu_ref_exit(&q->q_usage_counter);
|
|
kmem_cache_free(blk_get_queue_kmem_cache(blk_queue_has_srcu(q)), q);
|
|
}
|
|
|
|
/**
|
|
* blk_release_queue - releases all allocated resources of the request_queue
|
|
* @kobj: pointer to a kobject, whose container is a request_queue
|
|
*
|
|
* This function releases all allocated resources of the request queue.
|
|
*
|
|
* The struct request_queue refcount is incremented with blk_get_queue() and
|
|
* decremented with blk_put_queue(). Once the refcount reaches 0 this function
|
|
* is called.
|
|
*
|
|
* Drivers exist which depend on the release of the request_queue to be
|
|
* synchronous, it should not be deferred.
|
|
*
|
|
* Context: can sleep
|
|
*/
|
|
static void blk_release_queue(struct kobject *kobj)
|
|
{
|
|
struct request_queue *q =
|
|
container_of(kobj, struct request_queue, kobj);
|
|
|
|
might_sleep();
|
|
|
|
if (q->poll_stat)
|
|
blk_stat_remove_callback(q, q->poll_cb);
|
|
blk_stat_free_callback(q->poll_cb);
|
|
|
|
blk_free_queue_stats(q->stats);
|
|
kfree(q->poll_stat);
|
|
|
|
if (queue_is_mq(q))
|
|
blk_mq_release(q);
|
|
|
|
if (blk_queue_has_srcu(q))
|
|
cleanup_srcu_struct(q->srcu);
|
|
|
|
ida_free(&blk_queue_ida, q->id);
|
|
call_rcu(&q->rcu_head, blk_free_queue_rcu);
|
|
}
|
|
|
|
static const struct sysfs_ops queue_sysfs_ops = {
|
|
.show = queue_attr_show,
|
|
.store = queue_attr_store,
|
|
};
|
|
|
|
static const struct attribute_group *blk_queue_attr_groups[] = {
|
|
&queue_attr_group,
|
|
NULL
|
|
};
|
|
|
|
struct kobj_type blk_queue_ktype = {
|
|
.default_groups = blk_queue_attr_groups,
|
|
.sysfs_ops = &queue_sysfs_ops,
|
|
.release = blk_release_queue,
|
|
};
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
struct request_queue *q = disk->queue;
|
|
int ret;
|
|
|
|
mutex_lock(&q->sysfs_dir_lock);
|
|
|
|
ret = kobject_add(&q->kobj, &disk_to_dev(disk)->kobj, "queue");
|
|
if (ret < 0)
|
|
goto unlock;
|
|
|
|
if (queue_is_mq(q))
|
|
blk_mq_sysfs_register(disk);
|
|
mutex_lock(&q->sysfs_lock);
|
|
|
|
mutex_lock(&q->debugfs_mutex);
|
|
q->debugfs_dir = debugfs_create_dir(kobject_name(q->kobj.parent),
|
|
blk_debugfs_root);
|
|
if (queue_is_mq(q))
|
|
blk_mq_debugfs_register(q);
|
|
mutex_unlock(&q->debugfs_mutex);
|
|
|
|
ret = disk_register_independent_access_ranges(disk);
|
|
if (ret)
|
|
goto put_dev;
|
|
|
|
if (q->elevator) {
|
|
ret = elv_register_queue(q, false);
|
|
if (ret)
|
|
goto put_dev;
|
|
}
|
|
|
|
ret = blk_crypto_sysfs_register(disk);
|
|
if (ret)
|
|
goto put_dev;
|
|
|
|
blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
|
|
wbt_enable_default(q);
|
|
blk_throtl_register(disk);
|
|
|
|
/* Now everything is ready and send out KOBJ_ADD uevent */
|
|
kobject_uevent(&q->kobj, KOBJ_ADD);
|
|
if (q->elevator)
|
|
kobject_uevent(&q->elevator->kobj, KOBJ_ADD);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
unlock:
|
|
mutex_unlock(&q->sysfs_dir_lock);
|
|
|
|
/*
|
|
* SCSI probing may synchronously create and destroy a lot of
|
|
* request_queues for non-existent devices. Shutting down a fully
|
|
* functional queue takes measureable wallclock time as RCU grace
|
|
* periods are involved. To avoid excessive latency in these
|
|
* cases, a request_queue starts out in a degraded mode which is
|
|
* faster to shut down and is made fully functional here as
|
|
* request_queues for non-existent devices never get registered.
|
|
*/
|
|
if (!blk_queue_init_done(q)) {
|
|
blk_queue_flag_set(QUEUE_FLAG_INIT_DONE, q);
|
|
percpu_ref_switch_to_percpu(&q->q_usage_counter);
|
|
}
|
|
|
|
return ret;
|
|
|
|
put_dev:
|
|
elv_unregister_queue(q);
|
|
disk_unregister_independent_access_ranges(disk);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
mutex_unlock(&q->sysfs_dir_lock);
|
|
kobject_del(&q->kobj);
|
|
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
struct request_queue *q = disk->queue;
|
|
|
|
if (WARN_ON(!q))
|
|
return;
|
|
|
|
/* Return early if disk->queue was never registered. */
|
|
if (!blk_queue_registered(q))
|
|
return;
|
|
|
|
/*
|
|
* Since sysfs_remove_dir() prevents adding new directory entries
|
|
* before removal of existing entries starts, protect against
|
|
* concurrent elv_iosched_store() calls.
|
|
*/
|
|
mutex_lock(&q->sysfs_lock);
|
|
blk_queue_flag_clear(QUEUE_FLAG_REGISTERED, q);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
mutex_lock(&q->sysfs_dir_lock);
|
|
/*
|
|
* Remove the sysfs attributes before unregistering the queue data
|
|
* structures that can be modified through sysfs.
|
|
*/
|
|
if (queue_is_mq(q))
|
|
blk_mq_sysfs_unregister(disk);
|
|
blk_crypto_sysfs_unregister(disk);
|
|
|
|
mutex_lock(&q->sysfs_lock);
|
|
elv_unregister_queue(q);
|
|
disk_unregister_independent_access_ranges(disk);
|
|
mutex_unlock(&q->sysfs_lock);
|
|
|
|
/* Now that we've deleted all child objects, we can delete the queue. */
|
|
kobject_uevent(&q->kobj, KOBJ_REMOVE);
|
|
kobject_del(&q->kobj);
|
|
mutex_unlock(&q->sysfs_dir_lock);
|
|
|
|
mutex_lock(&q->debugfs_mutex);
|
|
blk_trace_shutdown(q);
|
|
debugfs_remove_recursive(q->debugfs_dir);
|
|
q->debugfs_dir = NULL;
|
|
q->sched_debugfs_dir = NULL;
|
|
q->rqos_debugfs_dir = NULL;
|
|
mutex_unlock(&q->debugfs_mutex);
|
|
}
|