drivers/nvme/target/nvmet.h

Source file repositories/reference/linux-study-clean/drivers/nvme/target/nvmet.h

File Facts

System
Linux kernel
Corpus path
drivers/nvme/target/nvmet.h
Extension
.h
Size
28169 bytes
Lines
994
Domain
Representative Device Path
Bucket
PCIe NVMe Storage Path
Inferred role
Representative Device Path: implementation source
Status
source 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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nvmet_pr_registrant {
	u64			rkey;
	uuid_t			hostid;
	enum nvme_pr_type	rtype;
	struct list_head	entry;
	struct rcu_head		rcu;
};

struct nvmet_pr {
	bool			enable;
	unsigned long		notify_mask;
	atomic_t		generation;
	struct nvmet_pr_registrant __rcu *holder;
	/*
	 * During the execution of the reservation command, mutual
	 * exclusion is required throughout the process. However,
	 * while waiting asynchronously for the 'per controller
	 * percpu_ref' to complete before the 'preempt and abort'
	 * command finishes, a semaphore is needed to ensure mutual
	 * exclusion instead of a mutex.
	 */
	struct semaphore	pr_sem;
	struct list_head	registrant_list;
};

struct nvmet_pr_per_ctrl_ref {
	struct percpu_ref	ref;
	struct completion	free_done;
	struct completion	confirm_done;
	uuid_t			hostid;
};

struct nvmet_ns {
	struct percpu_ref	ref;
	struct file		*bdev_file;
	struct block_device	*bdev;
	struct file		*file;
	bool			readonly;
	u32			nsid;
	u32			blksize_shift;
	loff_t			size;
	u8			nguid[16];
	uuid_t			uuid;
	u32			anagrpid;

	bool			buffered_io;
	bool			enabled;
	struct nvmet_subsys	*subsys;
	const char		*device_path;

	struct config_group	device_group;
	struct config_group	group;

	struct completion	disable_done;
	mempool_t		*bvec_pool;

	struct pci_dev		*p2p_dev;
	int			use_p2pmem;
	int			pi_type;
	int			metadata_size;
	u8			csi;
	struct nvmet_pr		pr;
	struct xarray		pr_per_ctrl_refs;
};

static inline struct nvmet_ns *to_nvmet_ns(struct config_item *item)
{
	return container_of(to_config_group(item), struct nvmet_ns, group);
}

static inline struct device *nvmet_ns_dev(struct nvmet_ns *ns)
{
	return ns->bdev ? disk_to_dev(ns->bdev->bd_disk) : NULL;
}

struct nvmet_cq {
	struct nvmet_ctrl	*ctrl;
	u16			qid;
	u16			size;
	refcount_t		ref;
};

struct nvmet_sq {
	struct nvmet_ctrl	*ctrl;
	struct percpu_ref	ref;
	struct nvmet_cq		*cq;
	u16			qid;
	u16			size;
	u32			sqhd;
	bool			sqhd_disabled;

Annotation

Implementation Notes