Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions include/spdk/nvmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ extern "C" {

#define SPDK_TLS_PSK_MAX_LEN 200

#define SPDK_NVMF_SUBSYSTEM_PAUSE_KEEP_ADMINQ 0x1

struct spdk_nvmf_tgt;
struct spdk_nvmf_subsystem;
struct spdk_nvmf_ctrlr;
Expand Down Expand Up @@ -543,6 +545,15 @@ int spdk_nvmf_subsystem_pause(struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg);

/**
* Vendor specific wrapper of subsystem pause
* we need to keep allow some admin commands during subsystem pause
*/
int spdk_nvmf_subsystem_pause_ext(struct spdk_nvmf_subsystem *subsystem,
uint32_t nsid,
uint32_t flags,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg);
/**
* Transition an NVMe-oF subsystem from Paused to Active state.
*
Expand All @@ -559,6 +570,13 @@ int spdk_nvmf_subsystem_resume(struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg);

/**
* Vendor specific wrapper of subsystem resume
* We need to clear vendor specific flags during resume
*/
int spdk_nvmf_subsystem_resume_ext(struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg);
/**
* Search the target for a subsystem with the given NQN.
*
Expand Down
10 changes: 10 additions & 0 deletions lib/nvmf/ctrlr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4606,6 +4606,16 @@ nvmf_check_subsystem_active(struct spdk_nvmf_request *req)
if (spdk_unlikely(req->cmd->nvmf_cmd.opcode == SPDK_NVME_OPC_FABRIC ||
nvmf_qpair_is_admin_queue(qpair))) {
if (sgroup->state != SPDK_NVMF_SUBSYSTEM_ACTIVE) {
struct spdk_nvmf_subsystem *subsystem = qpair->ctrlr->subsys;
Comment thread
susobhandey marked this conversation as resolved.
Outdated
if (req->cmd->nvmf_cmd.opcode != SPDK_NVME_OPC_FABRIC &&
(subsystem->pause_flags & SPDK_NVMF_SUBSYSTEM_PAUSE_KEEP_ADMINQ)) {
/*
* Vendor maintenance pause
* allow normal admin queue commands while data IO is paused
*/
sgroup->mgmt_io_outstanding++;
return true;
}
/* The subsystem is not currently active. Queue this request. */
TAILQ_INSERT_TAIL(&sgroup->queued, req, link);
return false;
Expand Down
3 changes: 3 additions & 0 deletions lib/nvmf/nvmf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ struct spdk_nvmf_subsystem {
/* Subsystem event callback and its argument. */
spdk_nvmf_subsystem_event_cb event_cb_fn;
void *event_cb_arg;
/* Vendor specific flags for maintainance work */
uint32_t pause_flags;
struct spdk_poller *pause_timer;
};

static int
Expand Down
48 changes: 48 additions & 0 deletions lib/nvmf/subsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,11 @@ _nvmf_subsystem_destroy(struct spdk_nvmf_subsystem *subsystem)
return -EINPROGRESS;
}

if (subsystem->pause_timer) {
spdk_poller_unregister(&subsystem->pause_timer);
subsystem->pause_timer = NULL;
}

ns = spdk_nvmf_subsystem_get_first_ns(subsystem);
while (ns != NULL) {
struct spdk_nvmf_ns *next_ns = spdk_nvmf_subsystem_get_next_ns(subsystem, ns);
Expand Down Expand Up @@ -758,6 +763,36 @@ spdk_nvmf_subsystem_stop(struct spdk_nvmf_subsystem *subsystem,
return nvmf_subsystem_state_change(subsystem, 0, SPDK_NVMF_SUBSYSTEM_INACTIVE, cb_fn, cb_arg);
}

static
int nvmf_subsys_pause_timer_cb(void *arg)
{
struct spdk_nvmf_subsystem *subsystem = arg;
subsystem->pause_flags = 0;
if (subsystem->pause_timer) {
spdk_poller_unregister(&subsystem->pause_timer);
subsystem->pause_timer = NULL;
}
return SPDK_POLLER_BUSY;
}

int
spdk_nvmf_subsystem_pause_ext(struct spdk_nvmf_subsystem *subsystem,
uint32_t nsid,
uint32_t flags,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg)
{
subsystem->pause_flags = flags;
if (subsystem->pause_timer == NULL) {
subsystem->pause_timer = spdk_poller_register(
nvmf_subsys_pause_timer_cb,
subsystem,
120ULL * 1000000ULL
Comment thread
susobhandey marked this conversation as resolved.
Outdated
);
}
return spdk_nvmf_subsystem_pause(subsystem, nsid, cb_fn, cb_arg);
}

int
spdk_nvmf_subsystem_pause(struct spdk_nvmf_subsystem *subsystem,
uint32_t nsid,
Expand All @@ -767,6 +802,19 @@ spdk_nvmf_subsystem_pause(struct spdk_nvmf_subsystem *subsystem,
return nvmf_subsystem_state_change(subsystem, nsid, SPDK_NVMF_SUBSYSTEM_PAUSED, cb_fn, cb_arg);
}

int
spdk_nvmf_subsystem_resume_ext(struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_subsystem_state_change_done cb_fn,
void *cb_arg)
{
subsystem->pause_flags = 0;
if (subsystem->pause_timer) {
spdk_poller_unregister(&subsystem->pause_timer);
subsystem->pause_timer = NULL;
}
return spdk_nvmf_subsystem_resume(subsystem, cb_fn, cb_arg);
}

int
spdk_nvmf_subsystem_resume(struct spdk_nvmf_subsystem *subsystem,
spdk_nvmf_subsystem_state_change_done cb_fn,
Expand Down
Loading