drivers/nvme/host/sysfs.c
Source file repositories/reference/linux-study-clean/drivers/nvme/host/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/nvme/host/sysfs.c- Extension
.c- Size
- 34815 bytes
- Lines
- 1311
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/nvme-auth.hlinux/blkdev.hnvme.hfabrics.h
Detected Declarations
function Copyrightfunction nvme_sysfs_rescanfunction nvme_adm_passthru_err_log_enabled_showfunction nvme_adm_passthru_err_log_enabled_storefunction nvme_io_passthru_err_log_enabled_showfunction nvme_io_passthru_err_log_enabled_storefunction wwid_showfunction nguid_showfunction uuid_showfunction eui_showfunction nsid_showfunction csi_showfunction metadata_bytes_showfunction ns_head_update_nusefunction ns_update_nusefunction nuse_showfunction nvme_ns_attrs_are_visiblefunction multipath_sysfs_group_visiblefunction command_retries_count_showfunction command_retries_count_storefunction nvme_io_errors_showfunction nvme_io_errors_storefunction nvme_ns_diag_attrs_are_visiblefunction nvme_sysfs_deletefunction nvme_sysfs_show_transportfunction nvme_sysfs_show_statefunction nvme_sysfs_show_subsysnqnfunction nvme_sysfs_show_hostnqnfunction nvme_sysfs_show_hostidfunction nvme_sysfs_show_addressfunction nvme_ctrl_loss_tmo_showfunction nvme_ctrl_loss_tmo_storefunction nvme_ctrl_reconnect_delay_showfunction nvme_ctrl_reconnect_delay_storefunction nvme_ctrl_fast_io_fail_tmo_showfunction nvme_ctrl_fast_io_fail_tmo_storefunction cntrltype_showfunction dctype_showfunction quirks_showfunction nvme_admin_timeout_showfunction nvme_admin_timeout_storefunction nvme_io_timeout_showfunction nvme_io_timeout_storefunction nvme_ctrl_dhchap_secret_showfunction nvme_ctrl_dhchap_secret_storefunction nvme_ctrl_dhchap_ctrl_secret_showfunction nvme_ctrl_dhchap_ctrl_secret_storefunction nvme_dev_attrs_are_visible
Annotated Snippet
if (quirks & 1) {
count += sysfs_emit_at(buf, count, "%s\n",
nvme_quirk_name(BIT(i)));
}
quirks >>= 1;
}
return count;
}
static DEVICE_ATTR_RO(quirks);
static ssize_t nvme_admin_timeout_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
return sysfs_emit(buf, "%u\n",
jiffies_to_msecs(ctrl->admin_timeout));
}
static ssize_t nvme_admin_timeout_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
u32 timeout;
int err;
/*
* Wait until the controller reaches the LIVE state to be sure that
* admin_q and fabrics_q are properly initialized.
*/
if (!test_bit(NVME_CTRL_STARTED_ONCE, &ctrl->flags))
return -EBUSY;
err = kstrtou32(buf, 10, &timeout);
if (err || !timeout)
return -EINVAL;
ctrl->admin_timeout = msecs_to_jiffies(timeout);
blk_queue_rq_timeout(ctrl->admin_q, ctrl->admin_timeout);
if (ctrl->fabrics_q)
blk_queue_rq_timeout(ctrl->fabrics_q, ctrl->admin_timeout);
return count;
}
static DEVICE_ATTR(admin_timeout, S_IRUGO | S_IWUSR,
nvme_admin_timeout_show, nvme_admin_timeout_store);
static ssize_t nvme_io_timeout_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
return sysfs_emit(buf, "%u\n", jiffies_to_msecs(ctrl->io_timeout));
}
static ssize_t nvme_io_timeout_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct nvme_ctrl *ctrl = dev_get_drvdata(dev);
struct nvme_ns *ns;
u32 timeout;
int err;
/*
* Wait until the controller reaches the LIVE state to be sure that
* connect_q is properly initialized.
*/
if (!test_bit(NVME_CTRL_STARTED_ONCE, &ctrl->flags))
return -EBUSY;
err = kstrtou32(buf, 10, &timeout);
if (err || !timeout)
return -EINVAL;
/* Take the namespaces_lock to avoid racing against nvme_alloc_ns() */
mutex_lock(&ctrl->namespaces_lock);
ctrl->io_timeout = msecs_to_jiffies(timeout);
list_for_each_entry(ns, &ctrl->namespaces, list)
blk_queue_rq_timeout(ns->queue, ctrl->io_timeout);
mutex_unlock(&ctrl->namespaces_lock);
if (ctrl->connect_q)
blk_queue_rq_timeout(ctrl->connect_q, ctrl->io_timeout);
Annotation
- Immediate include surface: `linux/nvme-auth.h`, `linux/blkdev.h`, `nvme.h`, `fabrics.h`.
- Detected declarations: `function Copyright`, `function nvme_sysfs_rescan`, `function nvme_adm_passthru_err_log_enabled_show`, `function nvme_adm_passthru_err_log_enabled_store`, `function nvme_io_passthru_err_log_enabled_show`, `function nvme_io_passthru_err_log_enabled_store`, `function wwid_show`, `function nguid_show`, `function uuid_show`, `function eui_show`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.