cregit-Linux how code gets into the kernel

Release 4.14 drivers/nvme/target/core.c

/*
 * Common code for the NVMe target.
 * Copyright (c) 2015-2016 HGST, a Western Digital Company.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/random.h>
#include <linux/rculist.h>

#include "nvmet.h"


static struct nvmet_fabrics_ops *nvmet_transports[NVMF_TRTYPE_MAX];
static DEFINE_IDA(cntlid_ida);

/*
 * This read/write semaphore is used to synchronize access to configuration
 * information on a target system that will result in discovery log page
 * information change for at least one host.
 * The full list of resources to protected by this semaphore is:
 *
 *  - subsystems list
 *  - per-subsystem allowed hosts list
 *  - allow_any_host subsystem attribute
 *  - nvmet_genctr
 *  - the nvmet_transports array
 *
 * When updating any of those lists/structures write lock should be obtained,
 * while when reading (popolating discovery log page or checking host-subsystem
 * link) read lock is obtained to allow concurrent reads.
 */

DECLARE_RWSEM(nvmet_config_sem);

static struct nvmet_subsys *nvmet_find_get_subsys(struct nvmet_port *port,
		const char *subsysnqn);


u16 nvmet_copy_to_sgl(struct nvmet_req *req, off_t off, const void *buf, size_t len) { if (sg_pcopy_from_buffer(req->sg, req->sg_cnt, buf, len, off) != len) return NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig50100.00%1100.00%
Total50100.00%1100.00%


u16 nvmet_copy_from_sgl(struct nvmet_req *req, off_t off, void *buf, size_t len) { if (sg_pcopy_to_buffer(req->sg, req->sg_cnt, buf, len, off) != len) return NVME_SC_SGL_INVALID_DATA | NVME_SC_DNR; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig49100.00%1100.00%
Total49100.00%1100.00%


static u32 nvmet_async_event_result(struct nvmet_async_event *aen) { return aen->event_type | (aen->event_info << 8) | (aen->log_page << 16); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig32100.00%1100.00%
Total32100.00%1100.00%


static void nvmet_async_events_free(struct nvmet_ctrl *ctrl) { struct nvmet_req *req; while (1) { mutex_lock(&ctrl->lock); if (!ctrl->nr_async_event_cmds) { mutex_unlock(&ctrl->lock); return; } req = ctrl->async_event_cmds[--ctrl->nr_async_event_cmds]; mutex_unlock(&ctrl->lock); nvmet_req_complete(req, NVME_SC_INTERNAL | NVME_SC_DNR); } }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig77100.00%1100.00%
Total77100.00%1100.00%


static void nvmet_async_event_work(struct work_struct *work) { struct nvmet_ctrl *ctrl = container_of(work, struct nvmet_ctrl, async_event_work); struct nvmet_async_event *aen; struct nvmet_req *req; while (1) { mutex_lock(&ctrl->lock); aen = list_first_entry_or_null(&ctrl->async_events, struct nvmet_async_event, entry); if (!aen || !ctrl->nr_async_event_cmds) { mutex_unlock(&ctrl->lock); return; } req = ctrl->async_event_cmds[--ctrl->nr_async_event_cmds]; nvmet_set_result(req, nvmet_async_event_result(aen)); list_del(&aen->entry); kfree(aen); mutex_unlock(&ctrl->lock); nvmet_req_complete(req, 0); } }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig136100.00%1100.00%
Total136100.00%1100.00%


static void nvmet_add_async_event(struct nvmet_ctrl *ctrl, u8 event_type, u8 event_info, u8 log_page) { struct nvmet_async_event *aen; aen = kmalloc(sizeof(*aen), GFP_KERNEL); if (!aen) return; aen->event_type = event_type; aen->event_info = event_info; aen->log_page = log_page; mutex_lock(&ctrl->lock); list_add_tail(&aen->entry, &ctrl->async_events); mutex_unlock(&ctrl->lock); schedule_work(&ctrl->async_event_work); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig99100.00%1100.00%
Total99100.00%1100.00%


int nvmet_register_transport(struct nvmet_fabrics_ops *ops) { int ret = 0; down_write(&nvmet_config_sem); if (nvmet_transports[ops->type]) ret = -EINVAL; else nvmet_transports[ops->type] = ops; up_write(&nvmet_config_sem); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig54100.00%1100.00%
Total54100.00%1100.00%

EXPORT_SYMBOL_GPL(nvmet_register_transport);
void nvmet_unregister_transport(struct nvmet_fabrics_ops *ops) { down_write(&nvmet_config_sem); nvmet_transports[ops->type] = NULL; up_write(&nvmet_config_sem); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig31100.00%1100.00%
Total31100.00%1100.00%

EXPORT_SYMBOL_GPL(nvmet_unregister_transport);
int nvmet_enable_port(struct nvmet_port *port) { struct nvmet_fabrics_ops *ops; int ret; lockdep_assert_held(&nvmet_config_sem); ops = nvmet_transports[port->disc_addr.trtype]; if (!ops) { up_write(&nvmet_config_sem); request_module("nvmet-transport-%d", port->disc_addr.trtype); down_write(&nvmet_config_sem); ops = nvmet_transports[port->disc_addr.trtype]; if (!ops) { pr_err("transport type %d not supported\n", port->disc_addr.trtype); return -EINVAL; } } if (!try_module_get(ops->owner)) return -EINVAL; ret = ops->add_port(port); if (ret) { module_put(ops->owner); return ret; } port->enabled = true; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig146100.00%1100.00%
Total146100.00%1100.00%


void nvmet_disable_port(struct nvmet_port *port) { struct nvmet_fabrics_ops *ops; lockdep_assert_held(&nvmet_config_sem); port->enabled = false; ops = nvmet_transports[port->disc_addr.trtype]; ops->remove_port(port); module_put(ops->owner); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig52100.00%1100.00%
Total52100.00%1100.00%


static void nvmet_keep_alive_timer(struct work_struct *work) { struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work), struct nvmet_ctrl, ka_work); pr_err("ctrl %d keep-alive timer (%d seconds) expired!\n", ctrl->cntlid, ctrl->kato); nvmet_ctrl_fatal_error(ctrl); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig4697.87%150.00%
Sagi Grimberg12.13%150.00%
Total47100.00%2100.00%


static void nvmet_start_keep_alive_timer(struct nvmet_ctrl *ctrl) { pr_debug("ctrl %d start keep-alive timer for %d secs\n", ctrl->cntlid, ctrl->kato); INIT_DELAYED_WORK(&ctrl->ka_work, nvmet_keep_alive_timer); schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig48100.00%1100.00%
Total48100.00%1100.00%


static void nvmet_stop_keep_alive_timer(struct nvmet_ctrl *ctrl) { pr_debug("ctrl %d stop keep-alive\n", ctrl->cntlid); cancel_delayed_work_sync(&ctrl->ka_work); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig28100.00%1100.00%
Total28100.00%1100.00%


static struct nvmet_ns *__nvmet_find_namespace(struct nvmet_ctrl *ctrl, __le32 nsid) { struct nvmet_ns *ns; list_for_each_entry_rcu(ns, &ctrl->subsys->namespaces, dev_link) { if (ns->nsid == le32_to_cpu(nsid)) return ns; } return NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig48100.00%1100.00%
Total48100.00%1100.00%


struct nvmet_ns *nvmet_find_namespace(struct nvmet_ctrl *ctrl, __le32 nsid) { struct nvmet_ns *ns; rcu_read_lock(); ns = __nvmet_find_namespace(ctrl, nsid); if (ns) percpu_ref_get(&ns->ref); rcu_read_unlock(); return ns; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig50100.00%1100.00%
Total50100.00%1100.00%


static void nvmet_destroy_namespace(struct percpu_ref *ref) { struct nvmet_ns *ns = container_of(ref, struct nvmet_ns, ref); complete(&ns->disable_done); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig34100.00%1100.00%
Total34100.00%1100.00%


void nvmet_put_namespace(struct nvmet_ns *ns) { percpu_ref_put(&ns->ref); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig18100.00%1100.00%
Total18100.00%1100.00%


int nvmet_ns_enable(struct nvmet_ns *ns) { struct nvmet_subsys *subsys = ns->subsys; struct nvmet_ctrl *ctrl; int ret = 0; mutex_lock(&subsys->lock); if (ns->enabled) goto out_unlock; ns->bdev = blkdev_get_by_path(ns->device_path, FMODE_READ | FMODE_WRITE, NULL); if (IS_ERR(ns->bdev)) { pr_err("failed to open block device %s: (%ld)\n", ns->device_path, PTR_ERR(ns->bdev)); ret = PTR_ERR(ns->bdev); ns->bdev = NULL; goto out_unlock; } ns->size = i_size_read(ns->bdev->bd_inode); ns->blksize_shift = blksize_bits(bdev_logical_block_size(ns->bdev)); ret = percpu_ref_init(&ns->ref, nvmet_destroy_namespace, 0, GFP_KERNEL); if (ret) goto out_blkdev_put; if (ns->nsid > subsys->max_nsid) subsys->max_nsid = ns->nsid; /* * The namespaces list needs to be sorted to simplify the implementation * of the Identify Namepace List subcommand. */ if (list_empty(&subsys->namespaces)) { list_add_tail_rcu(&ns->dev_link, &subsys->namespaces); } else { struct nvmet_ns *old; list_for_each_entry_rcu(old, &subsys->namespaces, dev_link) { BUG_ON(ns->nsid == old->nsid); if (ns->nsid < old->nsid) break; } list_add_tail_rcu(&ns->dev_link, &old->dev_link); } list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE, 0, 0); ns->enabled = true; ret = 0; out_unlock: mutex_unlock(&subsys->lock); return ret; out_blkdev_put: blkdev_put(ns->bdev, FMODE_WRITE|FMODE_READ); ns->bdev = NULL; goto out_unlock; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig31197.49%133.33%
Alexander Solganik72.19%133.33%
Parav Pandit10.31%133.33%
Total319100.00%3100.00%


void nvmet_ns_disable(struct nvmet_ns *ns) { struct nvmet_subsys *subsys = ns->subsys; struct nvmet_ctrl *ctrl; mutex_lock(&subsys->lock); if (!ns->enabled) goto out_unlock; ns->enabled = false; list_del_rcu(&ns->dev_link); mutex_unlock(&subsys->lock); /* * Now that we removed the namespaces from the lookup list, we * can kill the per_cpu ref and wait for any remaining references * to be dropped, as well as a RCU grace period for anyone only * using the namepace under rcu_read_lock(). Note that we can't * use call_rcu here as we need to ensure the namespaces have * been fully destroyed before unloading the module. */ percpu_ref_kill(&ns->ref); synchronize_rcu(); wait_for_completion(&ns->disable_done); percpu_ref_exit(&ns->ref); mutex_lock(&subsys->lock); list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) nvmet_add_async_event(ctrl, NVME_AER_TYPE_NOTICE, 0, 0); if (ns->bdev) blkdev_put(ns->bdev, FMODE_WRITE|FMODE_READ); out_unlock: mutex_unlock(&subsys->lock); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig13491.78%150.00%
Alexander Solganik128.22%150.00%
Total146100.00%2100.00%


void nvmet_ns_free(struct nvmet_ns *ns) { nvmet_ns_disable(ns); kfree(ns->device_path); kfree(ns); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig27100.00%1100.00%
Total27100.00%1100.00%


struct nvmet_ns *nvmet_ns_alloc(struct nvmet_subsys *subsys, u32 nsid) { struct nvmet_ns *ns; ns = kzalloc(sizeof(*ns), GFP_KERNEL); if (!ns) return NULL; INIT_LIST_HEAD(&ns->dev_link); init_completion(&ns->disable_done); ns->nsid = nsid; ns->subsys = subsys; uuid_gen(&ns->uuid); return ns; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig7290.00%150.00%
Johannes Thumshirn810.00%150.00%
Total80100.00%2100.00%


static void __nvmet_req_complete(struct nvmet_req *req, u16 status) { u32 old_sqhd, new_sqhd; u16 sqhd; if (status) nvmet_set_status(req, status); if (req->sq->size) { do { old_sqhd = req->sq->sqhd; new_sqhd = (old_sqhd + 1) % req->sq->size; } while (cmpxchg(&req->sq->sqhd, old_sqhd, new_sqhd) != old_sqhd); } sqhd = req->sq->sqhd & 0x0000FFFF; req->rsp->sq_head = cpu_to_le16(sqhd); req->rsp->sq_id = cpu_to_le16(req->sq->qid); req->rsp->command_id = req->cmd->common.command_id; if (req->ns) nvmet_put_namespace(req->ns); req->ops->queue_response(req); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig8452.83%125.00%
James Smart7547.17%375.00%
Total159100.00%4100.00%


void nvmet_req_complete(struct nvmet_req *req, u16 status) { __nvmet_req_complete(req, status); percpu_ref_put(&req->sq->ref); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig30100.00%1100.00%
Total30100.00%1100.00%

EXPORT_SYMBOL_GPL(nvmet_req_complete);
void nvmet_cq_setup(struct nvmet_ctrl *ctrl, struct nvmet_cq *cq, u16 qid, u16 size) { cq->qid = qid; cq->size = size; ctrl->cqs[qid] = cq; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig42100.00%1100.00%
Total42100.00%1100.00%


void nvmet_sq_setup(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, u16 qid, u16 size) { sq->sqhd = 0; sq->qid = qid; sq->size = size; ctrl->sqs[qid] = sq; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig4287.50%150.00%
James Smart612.50%150.00%
Total48100.00%2100.00%


static void nvmet_confirm_sq(struct percpu_ref *ref) { struct nvmet_sq *sq = container_of(ref, struct nvmet_sq, ref); complete(&sq->confirm_done); }

Contributors

PersonTokensPropCommitsCommitProp
Sagi Grimberg34100.00%1100.00%
Total34100.00%1100.00%


void nvmet_sq_destroy(struct nvmet_sq *sq) { /* * If this is the admin queue, complete all AERs so that our * queue doesn't have outstanding requests on it. */ if (sq->ctrl && sq->ctrl->sqs && sq->ctrl->sqs[0] == sq) nvmet_async_events_free(sq->ctrl); percpu_ref_kill_and_confirm(&sq->ref, nvmet_confirm_sq); wait_for_completion(&sq->confirm_done); wait_for_completion(&sq->free_done); percpu_ref_exit(&sq->ref); if (sq->ctrl) { nvmet_ctrl_put(sq->ctrl); sq->ctrl = NULL; /* allows reusing the queue later */ } }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig8688.66%150.00%
Sagi Grimberg1111.34%150.00%
Total97100.00%2100.00%

EXPORT_SYMBOL_GPL(nvmet_sq_destroy);
static void nvmet_sq_free(struct percpu_ref *ref) { struct nvmet_sq *sq = container_of(ref, struct nvmet_sq, ref); complete(&sq->free_done); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig34100.00%1100.00%
Total34100.00%1100.00%


int nvmet_sq_init(struct nvmet_sq *sq) { int ret; ret = percpu_ref_init(&sq->ref, nvmet_sq_free, 0, GFP_KERNEL); if (ret) { pr_err("percpu_ref init failed!\n"); return ret; } init_completion(&sq->free_done); init_completion(&sq->confirm_done); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig5487.10%150.00%
Sagi Grimberg812.90%150.00%
Total62100.00%2100.00%

EXPORT_SYMBOL_GPL(nvmet_sq_init);
bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, struct nvmet_sq *sq, struct nvmet_fabrics_ops *ops) { u8 flags = req->cmd->common.flags; u16 status; req->cq = cq; req->sq = sq; req->ops = ops; req->sg = NULL; req->sg_cnt = 0; req->rsp->status = 0; /* no support for fused commands yet */ if (unlikely(flags & (NVME_CMD_FUSE_FIRST | NVME_CMD_FUSE_SECOND))) { status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; goto fail; } /* either variant of SGLs is fine, as we don't support metadata */ if (unlikely((flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METABUF && (flags & NVME_CMD_SGL_ALL) != NVME_CMD_SGL_METASEG)) { status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; goto fail; } if (unlikely(!req->sq->ctrl)) /* will return an error for any Non-connect command: */ status = nvmet_parse_connect_cmd(req); else if (likely(req->sq->qid != 0)) status = nvmet_parse_io_cmd(req); else if (req->cmd->common.opcode == nvme_fabrics_command) status = nvmet_parse_fabrics_cmd(req); else if (req->sq->ctrl->subsys->type == NVME_NQN_DISC) status = nvmet_parse_discovery_cmd(req); else status = nvmet_parse_admin_cmd(req); if (status) goto fail; if (unlikely(!percpu_ref_tryget_live(&sq->ref))) { status = NVME_SC_INVALID_FIELD | NVME_SC_DNR; goto fail; } return true; fail: __nvmet_req_complete(req, status); return false; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig273100.00%1100.00%
Total273100.00%1100.00%

EXPORT_SYMBOL_GPL(nvmet_req_init);
void nvmet_req_uninit(struct nvmet_req *req) { percpu_ref_put(&req->sq->ref); }

Contributors

PersonTokensPropCommitsCommitProp
Vijay Immanuel20100.00%1100.00%
Total20100.00%1100.00%

EXPORT_SYMBOL_GPL(nvmet_req_uninit);
static inline bool nvmet_cc_en(u32 cc) { return (cc >> NVME_CC_EN_SHIFT) & 0x1; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1578.95%150.00%
Max Gurtovoy421.05%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_css(u32 cc) { return (cc >> NVME_CC_CSS_SHIFT) & 0x7; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_mps(u32 cc) { return (cc >> NVME_CC_MPS_SHIFT) & 0xf; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_ams(u32 cc) { return (cc >> NVME_CC_AMS_SHIFT) & 0x7; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_shn(u32 cc) { return (cc >> NVME_CC_SHN_SHIFT) & 0x3; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_iosqes(u32 cc) { return (cc >> NVME_CC_IOSQES_SHIFT) & 0xf; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static inline u8 nvmet_cc_iocqes(u32 cc) { return (cc >> NVME_CC_IOCQES_SHIFT) & 0xf; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig1894.74%150.00%
Max Gurtovoy15.26%150.00%
Total19100.00%2100.00%


static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) { lockdep_assert_held(&ctrl->lock); if (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES || nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES || nvmet_cc_mps(ctrl->cc) != 0 || nvmet_cc_ams(ctrl->cc) != 0 || nvmet_cc_css(ctrl->cc) != 0) { ctrl->csts = NVME_CSTS_CFS; return; } ctrl->csts = NVME_CSTS_RDY; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig81100.00%1100.00%
Total81100.00%1100.00%


static void nvmet_clear_ctrl(struct nvmet_ctrl *ctrl) { lockdep_assert_held(&ctrl->lock); /* XXX: tear down queues? */ ctrl->csts &= ~NVME_CSTS_RDY; ctrl->cc = 0; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig33100.00%1100.00%
Total33100.00%1100.00%


void nvmet_update_cc(struct nvmet_ctrl *ctrl, u32 new) { u32 old; mutex_lock(&ctrl->lock); old = ctrl->cc; ctrl->cc = new; if (nvmet_cc_en(new) && !nvmet_cc_en(old)) nvmet_start_ctrl(ctrl); if (!nvmet_cc_en(new) && nvmet_cc_en(old)) nvmet_clear_ctrl(ctrl); if (nvmet_cc_shn(new) && !nvmet_cc_shn(old)) { nvmet_clear_ctrl(ctrl); ctrl->csts |= NVME_CSTS_SHST_CMPLT; } if (!nvmet_cc_shn(new) && nvmet_cc_shn(old)) ctrl->csts &= ~NVME_CSTS_SHST_CMPLT; mutex_unlock(&ctrl->lock); }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig126100.00%1100.00%
Total126100.00%1100.00%


static void nvmet_init_cap(struct nvmet_ctrl *ctrl) { /* command sets supported: NVMe command set: */ ctrl->cap = (1ULL << 37); /* CC.EN timeout in 500msec units: */ ctrl->cap |= (15ULL << 24); /* maximum queue entries supported: */ ctrl->cap |= NVMET_QUEUE_SIZE - 1; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig42100.00%1100.00%
Total42100.00%1100.00%


u16 nvmet_ctrl_find_get(const char *subsysnqn, const char *hostnqn, u16 cntlid, struct nvmet_req *req, struct nvmet_ctrl **ret) { struct nvmet_subsys *subsys; struct nvmet_ctrl *ctrl; u16 status = 0; subsys = nvmet_find_get_subsys(req->port, subsysnqn); if (!subsys) { pr_warn("connect request for invalid subsystem %s!\n", subsysnqn); req->rsp->result.u32 = IPO_IATTR_CONNECT_DATA(subsysnqn); return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR; } mutex_lock(&subsys->lock); list_for_each_entry(ctrl, &subsys->ctrls, subsys_entry) { if (ctrl->cntlid == cntlid) { if (strncmp(hostnqn, ctrl->hostnqn, NVMF_NQN_SIZE)) { pr_warn("hostnqn mismatch.\n"); continue; } if (!kref_get_unless_zero(&ctrl->ref)) continue; *ret = ctrl; goto out; } } pr_warn("could not find controller %d for subsys %s / host %s\n", cntlid, subsysnqn, hostnqn); req->rsp->result.u32 = IPO_IATTR_CONNECT_DATA(cntlid); status =