From f50891a7a1c272c220c0b2b25120b279f22ad5f2 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Tue, 20 Sep 2022 16:17:22 +0200 Subject: [PATCH] ext4: Avoid writeback path when fs is shut down Patch suggtestd by Teodore Ts'o in https://lore.kernel.org/linux-ext4/4e83fb26-4d4a-d482-640c-8104973b7ebf@molgen.mpg.de/T/#u to avoid the error EXT4-fs (dm-0): ext4_writepages: jbd2_start: 5120 pages, ino 11; err -5 which sometimed occurs, when we set the fs to EXT4_IOC_SHUTDOWN+EXT4_GOING_FLAGS_NOLOGFLUSH --- fs/ext4/super.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index cd9a26ca12e02..3a31450e292b3 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -523,6 +523,10 @@ static int ext4_journalled_submit_inode_data_buffers(struct jbd2_inode *jinode) static int ext4_journal_submit_inode_data_buffers(struct jbd2_inode *jinode) { int ret; + journal_t *journal = EXT4_SB(jinode->i_vfs_inode->i_sb)->s_journal; + + if (!journal || is_journal_aborted(journal)) + return 0; if (ext4_should_journal_data(jinode->i_vfs_inode)) ret = ext4_journalled_submit_inode_data_buffers(jinode); @@ -535,6 +539,10 @@ static int ext4_journal_submit_inode_data_buffers(struct jbd2_inode *jinode) static int ext4_journal_finish_inode_data_buffers(struct jbd2_inode *jinode) { int ret = 0; + journal_t *journal = EXT4_SB(jinode->i_vfs_inode->i_sb)->s_journal; + + if (!journal || is_journal_aborted(journal)) + return 0; if (!ext4_should_journal_data(jinode->i_vfs_inode)) ret = jbd2_journal_finish_inode_data_buffers(jinode);