summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2022-03-10 13:18:32 +0300
committerTheodore Ts'o <tytso@mit.edu>2022-03-13 05:02:18 +0300
commit2bb8dd401a4f96973d6a9de4218d7f01fbd497ee (patch)
tree1276facc1b00095ccf9c01f887583c846d5ab2ee /fs
parent688b0d8536e0e937f608a93cb6909e14389a0c45 (diff)
downloadlinux-2bb8dd401a4f96973d6a9de4218d7f01fbd497ee.tar.xz
ext4: warn when dirtying page w/o buffers in data=journal mode
Recently I've got a report of BUG_ON trigerring during transaction commit in ext4_journalled_writepage_callback() because we've spotted a dirty page without buffers. Add WARN_ON_ONCE to ext4_journalled_set_page_dirty() to catch the problematic condition earlier where we have better chance of understanding which code path is creating dirty data without preparing the page properly. Also update the comment with current information when we are at it. Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20220310101832.5645-1-jack@suse.cz Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/inode.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 531a94f48637..26218088f63b 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3566,10 +3566,11 @@ const struct iomap_ops ext4_iomap_report_ops = {
};
/*
- * Pages can be marked dirty completely asynchronously from ext4's journalling
- * activity. By filemap_sync_pte(), try_to_unmap_one(), etc. We cannot do
- * much here because ->set_page_dirty is called under VFS locks. The page is
- * not necessarily locked.
+ * Whenever the page is being dirtied, corresponding buffers should already be
+ * attached to the transaction (we take care of this in ext4_page_mkwrite() and
+ * ext4_write_begin()). However we cannot move buffers to dirty transaction
+ * lists here because ->set_page_dirty is called under VFS locks and the page
+ * is not necessarily locked.
*
* We cannot just dirty the page and leave attached buffers clean, because the
* buffers' dirty state is "definitive". We cannot just set the buffers dirty
@@ -3580,6 +3581,7 @@ const struct iomap_ops ext4_iomap_report_ops = {
*/
static int ext4_journalled_set_page_dirty(struct page *page)
{
+ WARN_ON_ONCE(!page_has_buffers(page));
SetPageChecked(page);
return __set_page_dirty_nobuffers(page);
}