From 650ee9f8aab53b6d23db4435e5df47a53db44227 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 8 Nov 2019 22:47:31 -0500 Subject: [PATCH] Sync kernel's removal of open-coded allocation retry loop in revoke.c Apply the kernel's changes for commit 7b506b103532 ("jbd2: get rid of open coded allocation retry loop") for revoke.c. This required adjusting some of kernel compatibility defines. Note that retrying allocations in user space never makes any sense! Signed-off-by: Theodore Ts'o --- e2fsck/revoke.c | 15 +++++---------- lib/ext2fs/jfs_compat.h | 4 +++- lib/ext2fs/kernel-jbd.h | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/e2fsck/revoke.c b/e2fsck/revoke.c index 7779b9d..6406cae 100644 --- a/e2fsck/revoke.c +++ b/e2fsck/revoke.c @@ -138,11 +138,13 @@ static int insert_revoke_hash(journal_t *journal, unsigned long long blocknr, { struct list_head *hash_list; struct jbd2_revoke_record_s *record; + gfp_t gfp_mask = GFP_NOFS; -repeat: - record = kmem_cache_alloc(jbd2_revoke_record_cache, GFP_NOFS); + if (journal_oom_retry) + gfp_mask |= __GFP_NOFAIL; + record = kmem_cache_alloc(jbd2_revoke_record_cache, gfp_mask); if (!record) - goto oom; + return -ENOMEM; record->sequence = seq; record->blocknr = blocknr; @@ -151,13 +153,6 @@ repeat: list_add(&record->hash, hash_list); spin_unlock(&journal->j_revoke_lock); return 0; - -oom: - if (!journal_oom_retry) - return -ENOMEM; - jbd_debug(1, "ENOMEM in %s, retrying\n", __func__); - yield(); - goto repeat; } /* Find a revoke record in the journal's hash table. */ diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index c595be3..a51aebc 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -32,7 +32,10 @@ typedef struct kdev_s *kdev_t; struct buffer_head; struct inode; +typedef unsigned int gfp_t; #define GFP_KERNEL 0 +#define GFP_NOFS 0 +#define __GFP_NOFAIL 0 #define JBD2_TAG_SIZE32 JBD_TAG_SIZE32 #define JBD2_BARRIER 0 typedef __u64 u64; @@ -49,7 +52,6 @@ static inline __u32 jbd2_chksum(journal_t *j EXT2FS_ATTR((unused)), #define spin_lock_init(x) #define spin_lock(x) #define spin_unlock(x) -#define yield() #define SLAB_HWCACHE_ALIGN 0 #define SLAB_TEMPORARY 0 #define KMEM_CACHE(__struct, __flags) kmem_cache_create(#__struct,\ diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h index 70a1206..650a2f7 100644 --- a/lib/ext2fs/kernel-jbd.h +++ b/lib/ext2fs/kernel-jbd.h @@ -24,7 +24,7 @@ #define __FUNCTION__ "" #endif -#define journal_oom_retry 1 +#define journal_oom_retry 0 #ifdef __STDC__ #ifdef CONFIG_JBD_DEBUG -- 1.8.3.1