f2fs: use __GFP_NOFAIL to avoid infinite loop

__GFP_NOFAIL can avoid retrying the whole path of kmem_cache_alloc and
bio_alloc.
And, it also fixes the use cases of GFP_ATOMIC correctly.

Suggested-by: Chao Yu <chao2.yu@samsung.com>
Reviewed-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Jaegeuk Kim
2015-08-20 08:51:56 -07:00
parent dac2ddefe6
commit 80c545055d
4 changed files with 16 additions and 27 deletions
+5 -11
View File
@@ -1252,13 +1252,10 @@ static inline void *f2fs_kmem_cache_alloc(struct kmem_cache *cachep,
gfp_t flags)
{
void *entry;
retry:
entry = kmem_cache_alloc(cachep, flags);
if (!entry) {
cond_resched();
goto retry;
}
entry = kmem_cache_alloc(cachep, flags);
if (!entry)
entry = kmem_cache_alloc(cachep, flags | __GFP_NOFAIL);
return entry;
}
@@ -1267,12 +1264,9 @@ static inline struct bio *f2fs_bio_alloc(int npages)
struct bio *bio;
/* No failure on bio allocation */
retry:
bio = bio_alloc(GFP_NOIO, npages);
if (!bio) {
cond_resched();
goto retry;
}
if (!bio)
bio = bio_alloc(GFP_NOIO | __GFP_NOFAIL, npages);
return bio;
}