Skip to contentSkip to conversation

f2fs: force out‑place update for all writes on compressed file

PATCH Chao Yu via Linux-f2fs-devel 1 participant 3 messages Sep 7 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 1 line · Jiucheng Xu

Hi f2fs maintainers,

Jiucheng,

Sorry for delay reply.

Quoted 11 lines

Gentle ping for this patch:

For compressed file, compressed write may fail and fall back to raw write.
If in-place update(IPU) is allowed, raw data could be written into disk before cluster metadata is updated from compressed state to raw state. Sudden power-cut during this window will result in inconsistency:
raw data on disk but metadata still expects compressed content, which causes decompression failure when reading the file later.

I didn't get it, can you please describe the issue w/ call stack in race condition?

Quoted 10 lines

To eliminate this risk completely, force out-place update for all write operations on compressed file, so IPU will never be used.

Could you please take a look at your convenience?
Any comments are welcome.

Thanks,
Jiucheng

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#2 lore raw
Quoted 4 lines · Chao Yu

[ EXTERNAL EMAIL ]

On 9/2/26 11:18, Jiucheng Xu wrote:

Quoted 8 lines

Jiucheng,

Sorry for delay reply.

I didn't get it, can you please describe the issue w/ call stack in race condition?

Hi Chao,

Thanks for your time, The call stack is shown as below:

-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 16G eMMC platforms, 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: The data on disk is raw, but metadata still treats it as a compressed cluster and decompression will fail.

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#3 lore raw
Quoted 25 lines · Jiucheng Xu
Quoted 4 lines · Chao Yu

[ EXTERNAL EMAIL ]

On 9/2/26 11:18, Jiucheng Xu wrote:

Quoted 8 lines

Jiucheng,

Sorry for delay reply.

I didn't get it, can you please describe the issue w/ call stack in race condition?

Hi Chao,

Thanks for your time, The call stack is shown as below:

-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                           - ...
Quoted 9 lines

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 16G eMMC platforms, 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: The data on disk is raw, but metadata still treats it as a compressed cluster and decompression will fail.

Ah, now, I see, thanks for your explanation, can you add above callstack in commit message as well?

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel