diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 987225bdd661c33cffa0674e3fae7245a6b85a1f..b37dc0f78d077834a8839f92ca0ad93f4f49c971 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -895,6 +895,7 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
 	if (((p->flags & PF_MEMALLOC) || unlikely(test_thread_flag(TIF_MEMDIE)))
 			&& !in_interrupt()) {
 		if (!(gfp_mask & __GFP_NOMEMALLOC)) {
+nofail_alloc:
 			/* go through the zonelist yet again, ignoring mins */
 			for (i = 0; (z = zones[i]) != NULL; i++) {
 				if (!cpuset_zone_allowed(z, gfp_mask))
@@ -903,6 +904,10 @@ __alloc_pages(gfp_t gfp_mask, unsigned int order,
 				if (page)
 					goto got_pg;
 			}
+			if (gfp_mask & __GFP_NOFAIL) {
+				blk_congestion_wait(WRITE, HZ/50);
+				goto nofail_alloc;
+			}
 		}
 		goto nopage;
 	}