mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeuk Kim <jeuk20.kim@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, jeuk20.kim@samsung.com,
	d_hyun.kwon@samsung.com, gyusun.lee@samsung.com,
	hyenc.jeong@samsung.com, j-young.choi@samsung.com,
	jaemyung.lee@samsung.com, jieon.seol@samsung.com,
	keosung.park@samsung.com, wone.jung@samsung.com
Subject: [PATCH] f2fs: serialize writeback for inline-crypto inodes
Date: Thu, 16 Oct 2025 14:16:21 +0900	[thread overview]
Message-ID: <20251016051621.7425-1-jeuk20.kim@gmail.com> (raw)

From: Jeuk Kim <jeuk20.kim@samsung.com>

Inline encryption derives DUN from <inode, file offset>,
so bios from different inodes can't merge. With multi-threaded
buffered O_SYNC writes where each thread writes to its own file,
4KiB-per-page LBA allocation interleaves across inodes and
causes bio split. Serialize writeback for fscrypt inline-crypto
inodes via __should_serialize_io() to keep foreground writeback
focused on one inode and avoid split.

Test: fio --name=wb_osync --rw=write --bs=1M \
      --time_based=1 --runtime=60s --size=2G \
      --ioengine=psync --direct=0 --sync=1 \
      --numjobs=8 --thread=1 --nrfiles=1 \
      --filename_format='wb_osync.$jobnum'

device: UFS

Before -
  write throughput: 675MiB/s
  device I/O size distribution (by count, total 1027414):
    4 KiB:  923139 (89.9%)
    8 KiB:  84798 (8.3%)
    ≥512 KiB: 453 (0.0%)

After -
  write throughput: 1760MiB/s
  device I/O size distribution (by count, total 231750):
    4 KiB:  16904 (7.3%)
    8 KiB:  72128 (31.1%)
    ≥512 KiB: 118900 (51.3%)

Signed-off-by: Jeuk Kim <jeuk20.kim@samsung.com>
---
 fs/f2fs/data.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index ef38e62cda8f..ae6fb435d576 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3217,6 +3217,8 @@ static inline bool __should_serialize_io(struct inode *inode,
 
 	if (f2fs_need_compress_data(inode))
 		return true;
+	if (fscrypt_inode_uses_inline_crypto(inode))
+		return true;
 	if (wbc->sync_mode != WB_SYNC_ALL)
 		return true;
 	if (get_dirty_pages(inode) >= SM_I(F2FS_I_SB(inode))->min_seq_blocks)
-- 
2.43.0


             reply	other threads:[~2025-10-16  5:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16  5:16 Jeuk Kim [this message]
2025-10-16 10:12 ` Chao Yu
2025-10-21  3:33   ` Jeuk Kim
2025-10-21  6:51     ` Chao Yu
2025-10-21  7:12       ` Jeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251016051621.7425-1-jeuk20.kim@gmail.com \
    --to=jeuk20.kim@gmail.com \
    --cc=chao@kernel.org \
    --cc=d_hyun.kwon@samsung.com \
    --cc=gyusun.lee@samsung.com \
    --cc=hyenc.jeong@samsung.com \
    --cc=j-young.choi@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=jaemyung.lee@samsung.com \
    --cc=jeuk20.kim@samsung.com \
    --cc=jieon.seol@samsung.com \
    --cc=keosung.park@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wone.jung@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®