Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a72986c5 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Alasdair G Kergon
Browse files

dm raid1: keep retrying alloc if mempool_alloc failed



If the code can't handle allocation failures, use __GFP_NOFAIL so that
in case of memory pressure the allocator will retry indefinitely and
won't return NULL which would cause a crash in the function.

This is still not a correct fix, it may cause a classic deadlock when
memory manager waits for I/O being done and I/O waits for some free memory.
I/O code shouldn't allocate any memory. But in this case it probably
doesn't matter much in practice, people usually do not swap on RAID.

Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
parent e54f77dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -283,7 +283,7 @@ static struct dm_region *__rh_alloc(struct dm_region_hash *rh, region_t region)


	nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC);
	nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC);
	if (unlikely(!nreg))
	if (unlikely(!nreg))
		nreg = kmalloc(sizeof(*nreg), GFP_NOIO);
		nreg = kmalloc(sizeof(*nreg), GFP_NOIO | __GFP_NOFAIL);


	nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
	nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
		      DM_RH_CLEAN : DM_RH_NOSYNC;
		      DM_RH_CLEAN : DM_RH_NOSYNC;