* FAILED: patch "[PATCH] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()" failed to apply to 7.3-stable tree
@ 2026-11-25 10:11 gregkh
2026-11-25 16:40 ` [PATCH 7.3.y 1/2] buffer: Document mmb_mark_buffer_dirty() Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-11-25 10:11 UTC (permalink / raw)
To: brauner, jack; +Cc: stable
The patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x d4fdde3257a577f184b4498d040f6fe20be72326
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026112543-dipped-sultry-a7a2@gregkh' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d4fdde3257a577f184b4498d040f6fe20be72326 Mon Sep 17 00:00:00 2001
From: Christian Brauner <brauner@kernel.org>
Date: Mon, 9 Nov 2026 17:51:23 +0100
Subject: [PATCH] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
ext2, ext4 without a journal, fat, udf and minix track the metadata
buffers of an inode in a mapping_metadata_bhs list and sync them from
->sync_inode_metadata() and ->evict_inode(). The inode block itself is
only tracked by I_METADATA_WRITEBACK which ->write_inode() sets after
copying the inode into its buffer.
Set the bit in mmb_mark_buffer_dirty() as well so that it covers all
the metadata an inode may still have to write out. Set it after the
buffer is on the list. An fsync() that sees the bit then also finds the
buffer when it walks the list, and one that cleared the bit before we
set it leaves it set for the next one.
The inode itself may never have been dirtied. fat for example tracks
the FAT buffers on a private inode that nothing marks dirty. So attach
the inode to a wb before setting the bit, the way ext4_mark_iloc_dirty()
does, or writeback_single_inode() has no wb to lock once evict() syncs
it.
That lets evict() write out everything the bit tracks in one place
instead of every ->evict_inode() calling mmb_sync() itself.
Suggested-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org # v7.3
Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-8-91ac6c024018@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
diff --git a/fs/buffer.c b/fs/buffer.c
index 5d3852b726d6..f951559e7d32 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -621,12 +621,15 @@ void write_boundary_block(struct block_device *bdev,
* @bh: The buffer to mark dirty.
* @mmb: The list of buffers to add the buffer to.
*
- * Mark the buffer dirty and add it to the list if it is not already on
- * a list.
+ * Mark the buffer dirty, add it to the list if it is not already on a list
+ * and set I_METADATA_WRITEBACK on the inode so that fsync() and eviction
+ * write it out.
*/
void mmb_mark_buffer_dirty(struct buffer_head *bh,
struct mapping_metadata_bhs *mmb)
{
+ struct inode *inode = mmb->mapping->host;
+
mark_buffer_dirty(bh);
if (!bh->b_mmb) {
spin_lock(&mmb->lock);
@@ -641,6 +644,15 @@ void mmb_mark_buffer_dirty(struct buffer_head *bh,
list_move_tail(&bh->b_assoc_buffers, &mmb->list);
spin_unlock(&mmb->lock);
}
+ /*
+ * The inode itself may never have been dirtied, so attach it to a wb
+ * before setting the bit or writeback_single_inode() has nothing to
+ * lock when evict() syncs it.
+ */
+ spin_lock(&inode->i_lock);
+ inode_attach_wb(inode, NULL);
+ inode_state_set(inode, I_METADATA_WRITEBACK);
+ spin_unlock(&inode->i_lock);
}
EXPORT_SYMBOL(mmb_mark_buffer_dirty);
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 7.3.y 1/2] buffer: Document mmb_mark_buffer_dirty()
2026-11-25 10:11 FAILED: patch "[PATCH] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()" failed to apply to 7.3-stable tree gregkh
@ 2026-11-25 16:40 ` Sasha Levin
2026-11-25 16:40 ` [PATCH 7.3.y 2/2] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty() Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: Sasha Levin @ 2026-11-25 16:40 UTC (permalink / raw)
To: stable
Cc: Matthew Wilcox (Oracle), Jan Kara, Christian Brauner (Amutable),
Sasha Levin
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
[ Upstream commit 6c8b7651d06f635fe3d8789eda493eda3b4d13ef ]
Add kernel-doc for mmb_mark_buffer_dirty().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://patch.msgid.link/20260828205429.3678204-5-willy@infradead.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Stable-dep-of: d4fdde3257a5 ("fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/buffer.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/fs/buffer.c b/fs/buffer.c
index ed966fa73b1ba..30e7f2cc2386f 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -618,6 +618,14 @@ void write_boundary_block(struct block_device *bdev,
}
}
+/**
+ * mmb_mark_buffer_dirty - Mark a metadata buffer dirty.
+ * @bh: The buffer to mark dirty.
+ * @mmb: The list of buffers to add the buffer to.
+ *
+ * Mark the buffer dirty and add it to the list if it is not already on
+ * a list.
+ */
void mmb_mark_buffer_dirty(struct buffer_head *bh,
struct mapping_metadata_bhs *mmb)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 7.3.y 2/2] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()
2026-11-25 16:40 ` [PATCH 7.3.y 1/2] buffer: Document mmb_mark_buffer_dirty() Sasha Levin
@ 2026-11-25 16:40 ` Sasha Levin
0 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2026-11-25 16:40 UTC (permalink / raw)
To: stable; +Cc: Christian Brauner, Jan Kara, Sasha Levin
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit d4fdde3257a577f184b4498d040f6fe20be72326 ]
ext2, ext4 without a journal, fat, udf and minix track the metadata
buffers of an inode in a mapping_metadata_bhs list and sync them from
->sync_inode_metadata() and ->evict_inode(). The inode block itself is
only tracked by I_METADATA_WRITEBACK which ->write_inode() sets after
copying the inode into its buffer.
Set the bit in mmb_mark_buffer_dirty() as well so that it covers all
the metadata an inode may still have to write out. Set it after the
buffer is on the list. An fsync() that sees the bit then also finds the
buffer when it walks the list, and one that cleared the bit before we
set it leaves it set for the next one.
The inode itself may never have been dirtied. fat for example tracks
the FAT buffers on a private inode that nothing marks dirty. So attach
the inode to a wb before setting the bit, the way ext4_mark_iloc_dirty()
does, or writeback_single_inode() has no wb to lock once evict() syncs
it.
That lets evict() write out everything the bit tracks in one place
instead of every ->evict_inode() calling mmb_sync() itself.
Suggested-by: Jan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org # v7.3
Link: https://patch.msgid.link/20261109-work-inode-metadata_writeback-v3-8-91ac6c024018@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/buffer.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 30e7f2cc2386f..3f430fb824500 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -623,12 +623,15 @@ void write_boundary_block(struct block_device *bdev,
* @bh: The buffer to mark dirty.
* @mmb: The list of buffers to add the buffer to.
*
- * Mark the buffer dirty and add it to the list if it is not already on
- * a list.
+ * Mark the buffer dirty, add it to the list if it is not already on a list
+ * and set I_METADATA_WRITEBACK on the inode so that fsync() and eviction
+ * write it out.
*/
void mmb_mark_buffer_dirty(struct buffer_head *bh,
struct mapping_metadata_bhs *mmb)
{
+ struct inode *inode = mmb->mapping->host;
+
mark_buffer_dirty(bh);
if (!bh->b_mmb) {
spin_lock(&mmb->lock);
@@ -643,6 +646,15 @@ void mmb_mark_buffer_dirty(struct buffer_head *bh,
list_move_tail(&bh->b_assoc_buffers, &mmb->list);
spin_unlock(&mmb->lock);
}
+ /*
+ * The inode itself may never have been dirtied, so attach it to a wb
+ * before setting the bit or writeback_single_inode() has nothing to
+ * lock when evict() syncs it.
+ */
+ spin_lock(&inode->i_lock);
+ inode_attach_wb(inode, NULL);
+ inode_state_set(inode, I_METADATA_WRITEBACK);
+ spin_unlock(&inode->i_lock);
}
EXPORT_SYMBOL(mmb_mark_buffer_dirty);
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-25 16:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 10:11 FAILED: patch "[PATCH] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty()" failed to apply to 7.3-stable tree gregkh
2026-11-25 16:40 ` [PATCH 7.3.y 1/2] buffer: Document mmb_mark_buffer_dirty() Sasha Levin
2026-11-25 16:40 ` [PATCH 7.3.y 2/2] fs: set I_METADATA_WRITEBACK in mmb_mark_buffer_dirty() Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox