From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44BA246EC8B; Tue, 21 Jul 2026 19:23:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661814; cv=none; b=DfgziOkI/o2Y60d9vtC8h6agJhj5cfnWNat6Q7XCMGLK/qeY9V16cwDLBRixhsHJ72/+XmLRs2jBZnJGkzNe3xLSw8IPdh2sghhsh/9kIxZfpBfXRB+Jb+ABxlASuPAabKgRNBgUY+2PCWxJbx2u20Fp32Kt7b4JK5bX7RRft+g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784661814; c=relaxed/simple; bh=sWmK3f4msuDZ9Gz8zL3oQKfeITlTx4r+dVlzLeyed/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gss2cPzY7kj8eZmnfAvnfbLlure3n9dlXxXgWBEkS6pcd+jwkDqJuR3JOxqMHOqYiKvc2Bw1B6Yzcb9jMqGO7o5NcTT7zVNxeqKOW8M1HBC+yJtEF/4KgyvIU03Teaf/KJx4NGQ9fQglI6a64WAyCukdIOjK1cTfUDVISinVt8k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZCKDMlFk; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZCKDMlFk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A228E1F000E9; Tue, 21 Jul 2026 19:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784661813; bh=AW0YZOC6xLHUSrSEKk0w5iCHpWnJoFw92u/oheKrVP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZCKDMlFkmHI88Aofai0CnTBKxJw9rprnZkGjFFECAxKxEVnx2NNQpHhkSgJpfIqLX 0aPytIra91Uc8O90FK3N1AzUoK1ojdVTqkkyI8/paaxyi05GSVEX6yKDRzbLcloVLt wNfjcQHbl3Kja3rkbEg/Evloge9dPanE/tvkX6iE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhang Yi , Baokun Li , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 6.12 0208/1276] ext4: fix LOGFLUSH shutdown ordering to allow ordered-mode data writeback Date: Tue, 21 Jul 2026 17:10:51 +0200 Message-ID: <20260721152450.741905154@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152446.065700225@linuxfoundation.org> References: <20260721152446.065700225@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhang Yi [ Upstream commit d99748ef1695ce17eaf51c64b7a06952fa7cddab ] In EXT4_GOING_FLAGS_LOGFLUSH mode, the EXT4_FLAGS_SHUTDOWN flag was set before calling ext4_force_commit(). This caused ordered-mode data writeback (triggered by journal commit) to fail with -EIO, since ext4_do_writepages() checks for the shutdown flag. The journal would then be aborted prematurely before the commit could succeed. Fix this by calling ext4_force_commit() first, then setting the shutdown flag, so that pending data can be written back correctly. Note that moving ext4_force_commit() before setting the shutdown flag creates a small window in which new writes may occur and generate new journal transactions. When the journal is subsequently aborted, the new transactions will not be able to write to disk. This is intentional because LOGFLUSH's semantics are to flush pre-existing journal entries before shutdown, not to guarantee atomicity for writes that race with the ioctl. Fixes: 783d94854499 ("ext4: add EXT4_IOC_GOINGDOWN ioctl") Signed-off-by: Zhang Yi Reviewed-by: Baokun Li Reviewed-by: Jan Kara Link: https://patch.msgid.link/20260424104201.1930823-1-yi.zhang@huaweicloud.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/ioctl.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 99d185d00f3771..c3758c64fc4e03 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -826,11 +826,17 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) bdev_thaw(sb->s_bdev); break; case EXT4_GOING_FLAGS_LOGFLUSH: + /* + * Call ext4_force_commit() before setting EXT4_FLAGS_SHUTDOWN. + * This is because in data=ordered mode, journal commit + * triggers data writeback which fails if shutdown is already + * set, causing the journal to be aborted prematurely before + * the commit succeeds. + */ + (void) ext4_force_commit(sb); set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); - if (sbi->s_journal && !is_journal_aborted(sbi->s_journal)) { - (void) ext4_force_commit(sb); + if (sbi->s_journal && !is_journal_aborted(sbi->s_journal)) jbd2_journal_abort(sbi->s_journal, -ESHUTDOWN); - } break; case EXT4_GOING_FLAGS_NOLOGFLUSH: set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); -- 2.53.0