dm thin: send event about thin-pool state change _after_ making it
authorMike Snitzer <snitzer@redhat.com>
Tue, 11 Dec 2018 18:31:40 +0000 (13:31 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Dec 2018 13:13:05 +0000 (14:13 +0100)
commitcd5d8a9203ed16bfb16a03c570fb4cf7e7899125
tree9841f0d68011a5ca524fce8414db5e554b21c9bc
parent529571392b7a3efb91d12d70551ece5c0e60ece6
dm thin: send event about thin-pool state change _after_ making it

commit f6c367585d0d851349d3a9e607c43e5bea993fa1 upstream.

Sending a DM event before a thin-pool state change is about to happen is
a bug.  It wasn't realized until it became clear that userspace response
to the event raced with the actual state change that the event was
meant to notify about.

Fix this by first updating internal thin-pool state to reflect what the
DM event is being issued about.  This fixes a long-standing racey/buggy
userspace device-mapper-test-suite 'resize_io' test that would get an
event but not find the state it was looking for -- so it would just go
on to hang because no other events caused the test to reevaluate the
thin-pool's state.

Cc: stable@vger.kernel.org
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-thin.c