Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-fcloop: add support for nvmet discovery_event op

Update fcloop to support the discovery_event operation and
invoke a nvme rescan. In a real fc adapter, this would generate an
RSCN, which the host would receive and convert into a nvme rescan
on the remote port specified in the rscn payload.

Signed-off-by: James Smart <jsmart2021@gmail.com>
[kbuild-bot: fcloop_tgt_discovery_evt can be static]
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>

authored by

James Smart and committed by
Christoph Hellwig
4cf7c363 150d71f7

+37
+37
drivers/nvme/target/fcloop.c
··· 231 231 int status; 232 232 }; 233 233 234 + struct fcloop_rscn { 235 + struct fcloop_tport *tport; 236 + struct work_struct work; 237 + }; 238 + 234 239 enum { 235 240 INI_IO_START = 0, 236 241 INI_IO_ACTIVE = 1, ··· 351 346 schedule_work(&tls_req->work); 352 347 353 348 return 0; 349 + } 350 + 351 + /* 352 + * Simulate reception of RSCN and converting it to a initiator transport 353 + * call to rescan a remote port. 354 + */ 355 + static void 356 + fcloop_tgt_rscn_work(struct work_struct *work) 357 + { 358 + struct fcloop_rscn *tgt_rscn = 359 + container_of(work, struct fcloop_rscn, work); 360 + struct fcloop_tport *tport = tgt_rscn->tport; 361 + 362 + if (tport->remoteport) 363 + nvme_fc_rescan_remoteport(tport->remoteport); 364 + kfree(tgt_rscn); 365 + } 366 + 367 + static void 368 + fcloop_tgt_discovery_evt(struct nvmet_fc_target_port *tgtport) 369 + { 370 + struct fcloop_rscn *tgt_rscn; 371 + 372 + tgt_rscn = kzalloc(sizeof(*tgt_rscn), GFP_KERNEL); 373 + if (!tgt_rscn) 374 + return; 375 + 376 + tgt_rscn->tport = tgtport->private; 377 + INIT_WORK(&tgt_rscn->work, fcloop_tgt_rscn_work); 378 + 379 + schedule_work(&tgt_rscn->work); 354 380 } 355 381 356 382 static void ··· 875 839 .fcp_op = fcloop_fcp_op, 876 840 .fcp_abort = fcloop_tgt_fcp_abort, 877 841 .fcp_req_release = fcloop_fcp_req_release, 842 + .discovery_event = fcloop_tgt_discovery_evt, 878 843 .max_hw_queues = FCLOOP_HW_QUEUES, 879 844 .max_sgl_segments = FCLOOP_SGL_SEGS, 880 845 .max_dif_sgl_segments = FCLOOP_SGL_SEGS,