From a72986c562eeec3f7b992198c168f0f41606fe53 Mon Sep 17 00:00:00 2001 From: Mikulas Patocka Date: Mon, 22 Jun 2009 10:12:13 +0100 Subject: [RHEL5.7 PATCH] dm raid1: keep retrying alloc if mempool_alloc failed Upstream commit a72986c562eeec3f7b992198c168f0f41606fe53 Author: Mikulas Patocka Date: Mon Jun 22 10:12:13 2009 +0100 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: Mikulas Patocka Signed-off-by: Alasdair G Kergon --- drivers/md/dm-raid1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Index: linux-rhel5/drivers/md/dm-raid1.c =================================================================== --- linux-rhel5.orig/drivers/md/dm-raid1.c +++ linux-rhel5/drivers/md/dm-raid1.c @@ -313,7 +313,7 @@ static struct region *__rh_alloc(struct read_unlock(&rh->hash_lock); nreg = mempool_alloc(rh->region_pool, GFP_ATOMIC); if (unlikely(!nreg)) - nreg = kmalloc(sizeof(struct region), GFP_NOIO); + nreg = kmalloc(sizeof(struct region), GFP_NOIO | __GFP_NOFAIL); nreg->state = rh->log->type->in_sync(rh->log, region, 1) ? RH_CLEAN : RH_NOSYNC; nreg->rh = rh;