You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
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:
+5
-11
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user