Mikulas Patocka 13bd677a47 dm cache: fix bugs when a GFP_NOWAIT allocation fails
GFP_NOWAIT allocation can fail anytime - it doesn't wait for memory being
available and it fails if the mempool is exhausted and there is not enough
memory.

If we go down this path:
  map_bio -> mg_start -> alloc_migration -> mempool_alloc(GFP_NOWAIT)
we can see that map_bio() doesn't check the return value of mg_start(),
and the bio is leaked.

If we go down this path:
  map_bio -> mg_start -> mg_lock_writes -> alloc_prison_cell ->
  dm_bio_prison_alloc_cell_v2 -> mempool_alloc(GFP_NOWAIT) ->
  mg_lock_writes -> mg_complete
the bio is ended with an error - it is unacceptable because it could
cause filesystem corruption if the machine ran out of memory
temporarily.

Change GFP_NOWAIT to GFP_NOIO, so that the mempool code will properly
wait until memory becomes available. mempool_alloc with GFP_NOIO can't
fail, so remove the code paths that deal with allocation failure.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2019-10-17 11:13:50 -04:00
..
2019-09-17 16:57:47 -07:00
2019-09-12 09:32:31 -04:00
2019-09-12 09:32:31 -04:00
2019-09-16 10:18:01 -04:00
2016-11-01 09:43:26 -06:00
2019-09-04 09:39:22 -04:00
2017-06-09 09:27:32 -06:00
2019-08-15 15:57:43 -04:00
2019-08-23 10:13:12 -04:00
2019-08-23 10:13:12 -04:00
2019-09-12 09:32:31 -04:00
2019-09-12 09:32:31 -04:00
2019-03-12 10:15:18 -07:00
2019-09-13 13:14:39 -07:00