nvme_ctrlr: add get/set for ctrlr->is_failed.

These will be useful helper functions for the trid modification code
that gets introduced later.

Change-Id: Ief73e3045710bf35c511794c19b4dfefb93018f1
Signed-off-by: Seth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471780
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Seth Howell 2019-10-17 16:23:43 -07:00 committed by Jim Harris
parent ecd108eb4b
commit 7d3771f93c
2 changed files with 44 additions and 0 deletions

View File

@ -709,6 +709,31 @@ int spdk_nvme_detach(struct spdk_nvme_ctrlr *ctrlr);
*/ */
int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr); int spdk_nvme_ctrlr_reset(struct spdk_nvme_ctrlr *ctrlr);
/**
* Fail the given NVMe controller.
*
* This function gives the application the opportunity to fail a controller
* at will. When a controller is failed, any calls to process completions or
* submit I/O on qpairs associated with that controller will fail with an error
* code of -ENXIO.
* The controller can only be taken from the failed state by
* calling spdk_nvme_ctrlr_reset. After the controller has been successfully
* reset, any I/O pending when the controller was moved to failed will be
* aborted back to the application and can be resubmitted. I/O can then resume.
*
* \param ctrlr Opaque handle to an NVMe controller.
*/
void spdk_nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr);
/**
* This function returns the failed status of a given controller.
*
* \param ctrlr Opaque handle to an NVMe controller.
*
* \return True if the controller is failed, false otherwise.
*/
bool spdk_nvme_ctrlr_is_failed(struct spdk_nvme_ctrlr *ctrlr);
/** /**
* Get the identify controller data as defined by the NVMe specification. * Get the identify controller data as defined by the NVMe specification.
* *

View File

@ -629,6 +629,12 @@ nvme_ctrlr_set_supported_features(struct spdk_nvme_ctrlr *ctrlr)
nvme_ctrlr_set_arbitration_feature(ctrlr); nvme_ctrlr_set_arbitration_feature(ctrlr);
} }
bool
spdk_nvme_ctrlr_is_failed(struct spdk_nvme_ctrlr *ctrlr)
{
return ctrlr->is_failed;
}
void void
nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove) nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove)
{ {
@ -643,6 +649,19 @@ nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr, bool hot_remove)
SPDK_ERRLOG("ctrlr %s in failed state.\n", ctrlr->trid.traddr); SPDK_ERRLOG("ctrlr %s in failed state.\n", ctrlr->trid.traddr);
} }
/**
* This public API function will try to take the controller lock.
* Any private functions being called from a thread already holding
* the ctrlr lock should call nvme_ctrlr_fail directly.
*/
void
spdk_nvme_ctrlr_fail(struct spdk_nvme_ctrlr *ctrlr)
{
nvme_robust_mutex_lock(&ctrlr->ctrlr_lock);
nvme_ctrlr_fail(ctrlr, false);
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
}
static void static void
nvme_ctrlr_shutdown(struct spdk_nvme_ctrlr *ctrlr) nvme_ctrlr_shutdown(struct spdk_nvme_ctrlr *ctrlr)
{ {