multipath: fix scsi async tur checker corruption
authorBenjamin Marzinski <bmarzins@redhat.com>
Wed, 23 May 2012 21:05:20 +0000 (16:05 -0500)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 23 May 2012 21:49:11 +0000 (23:49 +0200)
commit892f7b333a0311450f525dcfa0dc84a17ee6e5d7
tree7899b835d1f21f3dffc0e7a8f842b6c8530a29a4
parent7df78426669e7c43126f5e71ddd725a0e2849ff0
multipath: fix scsi async tur checker corruption

Since the tur checker runs asynchronously in its own thread, there is nothing
that keeps a path from being orphaned or deleted before the tur thread has
finished. When this happenes the checker struct gets deleted.  However, the tur
thread might still we writing to that memory.  This can lead to memory
corruption.  This patch adds all of the necessary data to the checker context,
and makes the tur thread only use that. This way, if the checker is deleted
while the thread is still using the context, the thread will clean up the
context itself.

Since the context can only be freed when both the thread and the paths checker
structure have stopped needing it, and these can get get finished with the
context asychronously with respect to each other, the context has a holders
counter, protected by a spinlock, to keep track of the users.  When the
counter drops to zero, the context gets freed.

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/checkers/tur.c
libmultipath/discovery.c