Lines Matching defs:ctrlr_device

36 	struct cuse_device		*ctrlr_device;
1035 cuse_nvme_ns_start(struct cuse_device *ctrlr_device, uint32_t nsid)
1040 ns_device = nvme_cuse_get_cuse_ns_device(ctrlr_device->ctrlr, nsid);
1050 ns_device->ctrlr = ctrlr_device->ctrlr;
1051 ns_device->ctrlr_device = ctrlr_device;
1054 ctrlr_device->dev_name, ns_device->nsid);
1066 TAILQ_INSERT_TAIL(&ctrlr_device->ns_devices, ns_device, tailq);
1076 cuse_nvme_ns_stop(struct cuse_device *ctrlr_device, struct cuse_device *ns_device)
1078 TAILQ_REMOVE(&ctrlr_device->ns_devices, ns_device, tailq);
1087 nvme_cuse_claim(struct cuse_device *ctrlr_device, uint32_t index)
1099 snprintf(ctrlr_device->lock_name, sizeof(ctrlr_device->lock_name),
1102 dev_fd = open(ctrlr_device->lock_name, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
1104 SPDK_ERRLOG("could not open %s\n", ctrlr_device->lock_name);
1109 SPDK_ERRLOG("could not truncate %s\n", ctrlr_device->lock_name);
1117 SPDK_ERRLOG("could not mmap dev %s (%d)\n", ctrlr_device->lock_name, errno);
1125 " process %d has claimed it\n", ctrlr_device->lock_name, pid);
1134 ctrlr_device->claim_fd = dev_fd;
1135 ctrlr_device->index = index;
1141 nvme_cuse_unclaim(struct cuse_device *ctrlr_device)
1143 close(ctrlr_device->claim_fd);
1144 ctrlr_device->claim_fd = -1;
1145 unlink(ctrlr_device->lock_name);
1149 cuse_nvme_ctrlr_stop(struct cuse_device *ctrlr_device)
1153 TAILQ_FOREACH_SAFE(ns_device, &ctrlr_device->ns_devices, tailq, tmp) {
1154 cuse_nvme_ns_stop(ctrlr_device, ns_device);
1157 assert(TAILQ_EMPTY(&ctrlr_device->ns_devices));
1159 spdk_bit_array_clear(g_ctrlr_started, ctrlr_device->index);
1163 nvme_cuse_unclaim(ctrlr_device);
1165 TAILQ_REMOVE(&g_ctrlr_ctx_head, ctrlr_device, tailq);
1166 /* ctrlr_device will be freed by cuse_thread */
1167 ctrlr_device->force_exit = true;
1168 fuse_session_exit(ctrlr_device->session);
1172 cuse_nvme_ctrlr_update_namespaces(struct cuse_device *ctrlr_device)
1178 TAILQ_FOREACH_SAFE(ns_device, &ctrlr_device->ns_devices, tailq, tmp) {
1179 if (!spdk_nvme_ctrlr_is_active_ns(ctrlr_device->ctrlr, ns_device->nsid)) {
1180 cuse_nvme_ns_stop(ctrlr_device, ns_device);
1185 nsid = spdk_nvme_ctrlr_get_first_active_ns(ctrlr_device->ctrlr);
1187 if (cuse_nvme_ns_start(ctrlr_device, nsid) < 0) {
1192 nsid = spdk_nvme_ctrlr_get_next_active_ns(ctrlr_device->ctrlr, nsid);
1218 struct cuse_device *ctrlr_device;
1237 ctrlr_device = (struct cuse_device *)calloc(1, sizeof(struct cuse_device));
1238 if (!ctrlr_device) {
1239 SPDK_ERRLOG("Cannot allocate memory for ctrlr_device.");
1244 ctrlr_device->ctrlr = ctrlr;
1247 ctrlr_device->index = 0;
1249 ctrlr_device->index = spdk_bit_array_find_first_clear(g_ctrlr_started, ctrlr_device->index);
1250 if (ctrlr_device->index == UINT32_MAX) {
1255 if (nvme_cuse_claim(ctrlr_device, ctrlr_device->index) == 0) {
1258 ctrlr_device->index++;
1260 spdk_bit_array_set(g_ctrlr_started, ctrlr_device->index);
1261 snprintf(ctrlr_device->dev_name, sizeof(ctrlr_device->dev_name), "spdk/nvme%d",
1262 ctrlr_device->index);
1264 rv = cuse_session_create(ctrlr_device);
1269 TAILQ_INSERT_TAIL(&g_ctrlr_ctx_head, ctrlr_device, tailq);
1271 TAILQ_INIT(&ctrlr_device->ns_devices);
1274 if (cuse_nvme_ctrlr_update_namespaces(ctrlr_device) < 0) {
1276 cuse_nvme_ctrlr_stop(ctrlr_device);
1283 spdk_bit_array_clear(g_ctrlr_started, ctrlr_device->index);
1285 free(ctrlr_device);
1295 struct cuse_device *ctrlr_device = NULL;
1297 TAILQ_FOREACH(ctrlr_device, &g_ctrlr_ctx_head, tailq) {
1298 if (ctrlr_device->ctrlr == ctrlr) {
1303 return ctrlr_device;
1309 struct cuse_device *ctrlr_device = NULL;
1312 ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
1313 if (!ctrlr_device) {
1317 TAILQ_FOREACH(ns_device, &ctrlr_device->ns_devices, tailq) {
1329 struct cuse_device *ctrlr_device;
1335 ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
1336 if (!ctrlr_device) {
1342 cuse_nvme_ctrlr_stop(ctrlr_device);
1350 struct cuse_device *ctrlr_device;
1356 ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
1357 if (!ctrlr_device) {
1362 cuse_nvme_ctrlr_update_namespaces(ctrlr_device);
1460 struct cuse_device *ctrlr_device;
1469 ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
1470 if (!ctrlr_device) {
1476 cuse_nvme_ctrlr_stop(ctrlr_device);
1494 struct cuse_device *ctrlr_device;
1499 ctrlr_device = nvme_cuse_get_cuse_ctrlr_device(ctrlr);
1500 if (!ctrlr_device) {
1505 req_len = strnlen(ctrlr_device->dev_name, sizeof(ctrlr_device->dev_name));
1511 snprintf(name, req_len + 1, "%s", ctrlr_device->dev_name);