scsi: cxlflash: Add kref to context
authorMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Tue, 9 Aug 2016 23:39:42 +0000 (18:39 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 19 Aug 2016 02:41:36 +0000 (22:41 -0400)
commit888baf069f49529f33c0b1dfb0fc4811dc0ca1d2
tree6adddf35f84cb2a08756eeef7a0b8d6fb0ab56ed
parent44ef38f9a2af8644c24ace6cbe1132dc70174c39
scsi: cxlflash: Add kref to context

Currently, context user references are tracked via the list of LUNs that
have attached to the context. While convenient, this is not intuitive
without a deep study of the code and is inconsistent with the existing
reference tracking patterns within the kernel. This design choice can
lead to future bug injection.

To improve code comprehension and better protect against future bugs,
add explicit reference counting to contexts and migrate the context
removal code to the kref release handler.

Inspired-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: Manoj N. Kumar <manoj@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/cxlflash/superpipe.c
drivers/scsi/cxlflash/superpipe.h