* FAILED: patch "[PATCH] f2fs: force out-place update for all writes on compressed file" failed to apply to 6.6-stable tree
@ 2026-11-07 10:29 Sasha Levin
2026-11-10 3:10 ` [PATCH 6.6.y] f2fs: force out-place update for all writes on compressed file Jiucheng Xu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Sasha Levin @ 2026-11-07 10:29 UTC (permalink / raw)
To: jiucheng.xu, chao, jaegeuk; +Cc: stable
The patch below does not apply to the 6.6-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-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '20261107052913-failed-6.6-a64a3fec11e7@kernel.org' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4 Mon Sep 17 00:00:00 2001
From: Jiucheng Xu <jiucheng.xu@amlogic.com>
Date: Mon, 7 Sep 2026 19:35:42 +0800
Subject: [PATCH] f2fs: force out-place update for all writes on compressed
file
For compressed file, compressed write may fail and fall back to raw
write.
-Thread A - Thread B
- f2fs_write_multi_pages - f2fs_down_write(&sbi->cp_rwsem);
- f2fs_write_compressed_pages - ...
- f2fs_trylock_op - ...
- f2fs_down_read_trylock(&sbi->cp_rwsem); - ...
- f2fs_write_raw_pages - ...
Thread B acquires the lock first, which causes Thread A to fail lock
acquisition and fall back to raw-data write.
IPU_FORCE is enabled on small-capacity storage devices (< 16GB),
so f2fs_write_raw_pages() overwrites the original compressed data
in-place.
The in-memory node has been updated with raw-data addresses, while the
node metadata stored on eMMC still remains in compressed state.
If a power-cut occurs before the node is flushed to disk, on-disk
inconsistency arises: disk data is raw, yet metadata treats it as a
compressed cluster, leading to decompression failure.
To eliminate this risk completely, force out-place update for all
write operations on compressed file.
Cc: stable@kernel.org
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/data.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index bc53ac21efeee..22de00754678c 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2914,10 +2914,12 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (f2fs_used_in_atomic_write(inode))
return true;
- /* rewrite low ratio compress data w/ OPU mode to avoid fragmentation */
- if (f2fs_compressed_file(inode) &&
- F2FS_OPTION(sbi).compress_mode == COMPR_MODE_USER &&
- is_inode_flag_set(inode, FI_ENABLE_COMPRESS))
+ /*
+ * rewrite low ratio compress data w/ OPU mode to avoid fragmentation.
+ * If IO comes from compressed write path and fallback to raw write,
+ * force out‑place to prevent metadata‑data inconsistency.
+ */
+ if (f2fs_compressed_file(inode))
return true;
/* swap file is migrating in aligned write mode */
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.6.y] f2fs: force out-place update for all writes on compressed file
2026-11-07 10:29 FAILED: patch "[PATCH] f2fs: force out-place update for all writes on compressed file" failed to apply to 6.6-stable tree Sasha Levin
@ 2026-11-10 3:10 ` Jiucheng Xu
2026-11-10 3:12 ` [PATCH 6.1.y] " Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 1/2] " Jiucheng Xu
2 siblings, 0 replies; 6+ messages in thread
From: Jiucheng Xu @ 2026-11-10 3:10 UTC (permalink / raw)
To: stable; +Cc: Jiucheng Xu, stable, Chao Yu, Jaegeuk Kim
commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4 upstream.
For compressed file, compressed write may fail and fall back to raw
write.
-Thread A - Thread B
- f2fs_write_multi_pages - f2fs_down_write(&sbi->cp_rwsem);
- f2fs_write_compressed_pages - ...
- f2fs_trylock_op - ...
- f2fs_down_read_trylock(&sbi->cp_rwsem); - ...
- f2fs_write_raw_pages - ...
Thread B acquires the lock first, which causes Thread A to fail lock
acquisition and fall back to raw-data write.
IPU_FORCE is enabled on small-capacity storage devices (< 16GB),
so f2fs_write_raw_pages() overwrites the original compressed data
in-place.
The in-memory node has been updated with raw-data addresses, while the
node metadata stored on eMMC still remains in compressed state.
If a power-cut occurs before the node is flushed to disk, on-disk
inconsistency arises: disk data is raw, yet metadata treats it as a
compressed cluster, leading to decompression failure.
To eliminate this risk completely, force out-place update for all
write operations on compressed file.
Cc: stable@kernel.org
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4)
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
fs/f2fs/data.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b0c633c5deb7..65f933d24fe8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2629,6 +2629,13 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (f2fs_used_in_atomic_write(inode))
return true;
+ /*
+ * rewrite low ratio compress data w/ OPU mode to avoid fragmentation.
+ * If IO comes from compressed write path and fallback to raw write,
+ * force out-place to prevent metadata-data inconsistency.
+ */
+ if (f2fs_compressed_file(inode))
+ return true;
/* swap file is migrating in aligned write mode */
if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.1.y] f2fs: force out-place update for all writes on compressed file
2026-11-07 10:29 FAILED: patch "[PATCH] f2fs: force out-place update for all writes on compressed file" failed to apply to 6.6-stable tree Sasha Levin
2026-11-10 3:10 ` [PATCH 6.6.y] f2fs: force out-place update for all writes on compressed file Jiucheng Xu
@ 2026-11-10 3:12 ` Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 1/2] " Jiucheng Xu
2 siblings, 0 replies; 6+ messages in thread
From: Jiucheng Xu @ 2026-11-10 3:12 UTC (permalink / raw)
To: stable; +Cc: Jiucheng Xu, stable, Chao Yu, Jaegeuk Kim
commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4 upstream.
For compressed file, compressed write may fail and fall back to raw
write.
-Thread A - Thread B
- f2fs_write_multi_pages - f2fs_down_write(&sbi->cp_rwsem);
- f2fs_write_compressed_pages - ...
- f2fs_trylock_op - ...
- f2fs_down_read_trylock(&sbi->cp_rwsem); - ...
- f2fs_write_raw_pages - ...
Thread B acquires the lock first, which causes Thread A to fail lock
acquisition and fall back to raw-data write.
IPU_FORCE is enabled on small-capacity storage devices (< 16GB),
so f2fs_write_raw_pages() overwrites the original compressed data
in-place.
The in-memory node has been updated with raw-data addresses, while the
node metadata stored on eMMC still remains in compressed state.
If a power-cut occurs before the node is flushed to disk, on-disk
inconsistency arises: disk data is raw, yet metadata treats it as a
compressed cluster, leading to decompression failure.
To eliminate this risk completely, force out-place update for all
write operations on compressed file.
Cc: stable@kernel.org
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4)
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
fs/f2fs/data.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 6384ac931bb7..4a0bf44b3a54 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2662,6 +2662,13 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (f2fs_is_atomic_file(inode))
return true;
+ /*
+ * rewrite low ratio compress data w/ OPU mode to avoid fragmentation.
+ * If IO comes from compressed write path and fallback to raw write,
+ * force out-place to prevent metadata-data inconsistency.
+ */
+ if (f2fs_compressed_file(inode))
+ return true;
/* swap file is migrating in aligned write mode */
if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file
2026-11-07 10:29 FAILED: patch "[PATCH] f2fs: force out-place update for all writes on compressed file" failed to apply to 6.6-stable tree Sasha Levin
2026-11-10 3:10 ` [PATCH 6.6.y] f2fs: force out-place update for all writes on compressed file Jiucheng Xu
2026-11-10 3:12 ` [PATCH 6.1.y] " Jiucheng Xu
@ 2026-11-11 7:54 ` Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 2/2] f2fs: allow pinning empty compressed files Jiucheng Xu
2026-11-11 21:54 ` [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file Sasha Levin
2 siblings, 2 replies; 6+ messages in thread
From: Jiucheng Xu @ 2026-11-11 7:54 UTC (permalink / raw)
To: stable; +Cc: Jiucheng Xu, stable, Chao Yu, Jaegeuk Kim
commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4 upstream.
For compressed file, compressed write may fail and fall back to raw
write.
-Thread A - Thread B
- f2fs_write_multi_pages - f2fs_down_write(&sbi->cp_rwsem);
- f2fs_write_compressed_pages - ...
- f2fs_trylock_op - ...
- f2fs_down_read_trylock(&sbi->cp_rwsem); - ...
- f2fs_write_raw_pages - ...
Thread B acquires the lock first, which causes Thread A to fail lock
acquisition and fall back to raw-data write.
IPU_FORCE is enabled on small-capacity storage devices (< 16GB),
so f2fs_write_raw_pages() overwrites the original compressed data
in-place.
The in-memory node has been updated with raw-data addresses, while the
node metadata stored on eMMC still remains in compressed state.
If a power-cut occurs before the node is flushed to disk, on-disk
inconsistency arises: disk data is raw, yet metadata treats it as a
compressed cluster, leading to decompression failure.
To eliminate this risk completely, force out-place update for all
write operations on compressed file.
Cc: stable@kernel.org
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit a64a3fec11e77a3a0dc0009bdc58b925e45a1bb4)
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
fs/f2fs/data.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b0c633c5deb7..65f933d24fe8 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2629,6 +2629,13 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
return true;
if (f2fs_used_in_atomic_write(inode))
return true;
+ /*
+ * rewrite low ratio compress data w/ OPU mode to avoid fragmentation.
+ * If IO comes from compressed write path and fallback to raw write,
+ * force out-place to prevent metadata-data inconsistency.
+ */
+ if (f2fs_compressed_file(inode))
+ return true;
/* swap file is migrating in aligned write mode */
if (is_inode_flag_set(inode, FI_ALIGNED_WRITE))
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 6.6.y 2/2] f2fs: allow pinning empty compressed files
2026-11-11 7:54 ` [PATCH 6.6.y 1/2] " Jiucheng Xu
@ 2026-11-11 7:54 ` Jiucheng Xu
2026-11-11 21:54 ` [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file Sasha Levin
1 sibling, 0 replies; 6+ messages in thread
From: Jiucheng Xu @ 2026-11-11 7:54 UTC (permalink / raw)
To: stable; +Cc: Joanne Chang, stable, Chao Yu, Jaegeuk Kim, Jiucheng Xu
From: Joanne Chang <joannechien@google.com>
commit 2eebc31ae5f53e1066bb6238c8087c23b688ad17 upstream.
Commit a64a3fec11e7 ("f2fs: force out-place update for all writes on
compressed file") updated f2fs_should_update_outplace() to always
return true for compressed files. However, this function is also
called during f2fs_ioc_set_pin_file() validation, so pinning an
empty file with compression enabled now fails with -EINVAL before the
compression flag can be stripped.
Fix this by guarding the f2fs_compressed_file(inode) check with fio in
f2fs_should_update_outplace(). This preserves forced OPU for actual
compressed writes (fio != NULL), while allowing f2fs_ioc_set_pin_file()
(fio == NULL) to proceed to f2fs_disable_compressed_file(inode).
Cc: stable@kernel.org
Fixes: a64a3fec11e7 ("f2fs: force out-place update for all writes on compressed file")
Assisted-by: LLM
Signed-off-by: Joanne Chang <joannechien@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 2eebc31ae5f53e1066bb6238c8087c23b688ad17)
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 65f933d24fe8..435eaf4f7547 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2634,7 +2634,7 @@ bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
* If IO comes from compressed write path and fallback to raw write,
* force out-place to prevent metadata-data inconsistency.
*/
- if (f2fs_compressed_file(inode))
+ if (fio && f2fs_compressed_file(inode))
return true;
/* swap file is migrating in aligned write mode */
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file
2026-11-11 7:54 ` [PATCH 6.6.y 1/2] " Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 2/2] f2fs: allow pinning empty compressed files Jiucheng Xu
@ 2026-11-11 21:54 ` Sasha Levin
1 sibling, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2026-11-11 21:54 UTC (permalink / raw)
To: stable; +Cc: Sasha Levin, Jiucheng Xu, stable, Chao Yu, Jaegeuk Kim
> [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file
Queued the series for 6.6, 6.1, 5.15 and 5.10, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-11 21:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-07 10:29 FAILED: patch "[PATCH] f2fs: force out-place update for all writes on compressed file" failed to apply to 6.6-stable tree Sasha Levin
2026-11-10 3:10 ` [PATCH 6.6.y] f2fs: force out-place update for all writes on compressed file Jiucheng Xu
2026-11-10 3:12 ` [PATCH 6.1.y] " Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 1/2] " Jiucheng Xu
2026-11-11 7:54 ` [PATCH 6.6.y 2/2] f2fs: allow pinning empty compressed files Jiucheng Xu
2026-11-11 21:54 ` [PATCH 6.6.y 1/2] f2fs: force out-place update for all writes on compressed file Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox