From: jsmart2021@gmail.com (James Smart) Date: Thu, 9 Aug 2018 16:29:18 -0700 Subject: [PATCH] nvmet_fc: support target port removal with nvmet layer In-Reply-To: <20180809225953.6600-1-jsmart2021@gmail.com> References: <20180809225953.6600-1-jsmart2021@gmail.com> Message-ID: <52224f2e-be93-ea76-1171-6bfb64ae4ee3@gmail.com> Please ignore. There is one test case (where port ptr is NULL) that isn't handled correctly. Will repost shortly. -- james On 8/9/2018 3:59 PM, James Smart wrote: > Currently, if a targetport has been connected to via the nvmet > config (in other words, the add_port() transport routine called, and > the nvmet port pointer stored for using in upcalls on new io), and > if the targetport is then removed (say the lldd driver decides to > unload or fully reset its hardware) and then re-added (the lldd > driver reloads or reinits its hardware), the port pointer has been > lost so there's no way to continue to post commands up to nvmet > via the transport port. > > Correct by allocating a small "port context" structure that will > be linked to by the targetport. The context will save the targetport > WWN's and the nvmet port pointer to use for it. Initial allocation > will occur when the targetport is bound to via add_port. The context > will be deallocated when remove_port() is called. If a targetport > is removed while nvmet has the active port context, the targetport > will be unlinked from the port context before removal. If a new > targetport is registered, the port contexts without a binding are > looked through and if the WWN's match (so it's the same as nvmet's > port context) the port context is linked to the new target port. > Thus new io can be received on the new targetport and operation > resumes with nvmet. > > Signed-off-by: James Smart