]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
jbd2: make b_frozen_data allocation always succeed
authorZhihao Cheng <chengzhihao1@huawei.com>
Sat, 12 Oct 2024 08:55:30 +0000 (16:55 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 13 Nov 2024 04:54:15 +0000 (23:54 -0500)
The b_frozen_data allocation should not be failed during journal
committing process, otherwise jbd2 will abort.
Since commit 490c1b444ce653d("jbd2: do not fail journal because of
frozen_buffer allocation failure") already added '__GFP_NOFAIL' flag
in do_get_write_access(), just add '__GFP_NOFAIL' flag for all allocations
in jbd2_journal_write_metadata_buffer(), like 'new_bh' allocation does.
Besides, remove all error handling branches for do_get_write_access().

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
Link: https://patch.msgid.link/20241012085530.2147846-1-chengzhihao@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/jbd2/commit.c
fs/jbd2/journal.c

index 4305a1ac808a60a2fe395518f5ca2b0cd9144510..9153ff3a08e76c8b8fce12c90e25a4acc99139f5 100644 (file)
@@ -662,10 +662,6 @@ void jbd2_journal_commit_transaction(journal_t *journal)
                JBUFFER_TRACE(jh, "ph3: write metadata");
                escape = jbd2_journal_write_metadata_buffer(commit_transaction,
                                                jh, &wbuf[bufs], blocknr);
-               if (escape < 0) {
-                       jbd2_journal_abort(journal, escape);
-                       continue;
-               }
                jbd2_file_log_bh(&io_bufs, wbuf[bufs]);
 
                /* Record the new block's tag in the current descriptor
index 97f487c3d8fcf0aca61d43aeb3007d068a76963f..29d30eddf727180b227c6e0cd1e561453cbb9da0 100644 (file)
@@ -318,7 +318,6 @@ static inline void jbd2_data_do_escape(char *data)
  *
  *
  * Return value:
- *  <0: Error
  *  =0: Finished OK without escape
  *  =1: Finished OK with escape
  */
@@ -386,12 +385,7 @@ int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
                        goto escape_done;
 
                spin_unlock(&jh_in->b_state_lock);
-               tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS);
-               if (!tmp) {
-                       brelse(new_bh);
-                       free_buffer_head(new_bh);
-                       return -ENOMEM;
-               }
+               tmp = jbd2_alloc(bh_in->b_size, GFP_NOFS | __GFP_NOFAIL);
                spin_lock(&jh_in->b_state_lock);
                if (jh_in->b_frozen_data) {
                        jbd2_free(tmp, bh_in->b_size);