]> git.karo-electronics.de Git - karo-tx-linux.git/commit
target/user: Recalculate pad size inside is_ring_space_avail()
authorAndy Grover <agrover@redhat.com>
Thu, 2 Oct 2014 17:23:15 +0000 (10:23 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 3 Oct 2014 18:16:12 +0000 (11:16 -0700)
commitf56574a2b554492703030e3d3b9679c9a07a5d69
tree3a5f48487de06e02ab8d30ced77bd5f9ef1e0a87
parent6375f8908255ea7438b60bb5998e6b3e1628500d
target/user: Recalculate pad size inside is_ring_space_avail()

If more than one thread is waiting for command ring space that includes
a PAD, then if the first one finishes (inserts a PAD and a CMD at the
start of the cmd ring) then the second one will incorrectly think it still
needs to insert a PAD (i.e. cmdr_space_needed is now wrong.) This will
lead to it asking for more space than it actually needs, and then inserting
a PAD somewhere else than at the end -- not what we want.

This patch moves the pad calculation inside is_ring_space_available() so
in the above scenario the second thread would then ask for space not
including a PAD. The patch also inserts a PAD op based upon an up-to-date
cmd_head, instead of the potentially stale value.

Signed-off-by: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_user.c