From nobody Tue Jun 16 01:38:28 2026 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D41D1307AE3 for ; Wed, 15 Apr 2026 08:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776240900; cv=none; b=YfaEr5XBLbt2RXn30gxsWqB+65Iw67aj2ZEPvRcSzntR6lBqCpv2W4SfgEoxd8NoNU6iQTiCX2rdCMqzYQSg3b5NM1C5IRgX00J5nJMuKMDQaaoyiE/4PElrLcNAeIIiXQuKe5IsDKT4/EZJduVPbKt7eP5hAafJXh1GkdBrrIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776240900; c=relaxed/simple; bh=nPHY0SwqqtfL30YUbEdkDPefg1zzPJs3Nm7s/wiQdr8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Zb/+e+h55JvZhJfV8LTAIRU6wY40CPvh6ORap1Ls62GpvyTm+DQDONGbUGFNxUr7YvkGd/fChgAdA15SNWGIhufTSH0SeggpiUJdXt5szij5tHdV0v6WqTHHQ6G0Oe7o/At4nOa1uCURcpG1yrXaRt5oXqNwcA/quOxhCcHCuRE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ele2GToG; arc=none smtp.client-ip=209.85.214.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ele2GToG" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2a871daa98fso42209755ad.1 for ; Wed, 15 Apr 2026 01:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776240898; x=1776845698; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cr3LYjuSIkdSjgKcjE5pXiQW5P99n+0bc+MlVW7WbAQ=; b=Ele2GToGvwInDQsmGsjAdN35WQPKQckdyUtTRSoz6CFQnqSCkPy92QnnfJmQWhmaBJ rHJwyNaNrsLD2/YqSLQSORovvT+AbZ6TETt7u28e8iF1/oMh0WO3bRhjJbjnQM7gssnt xET1OAzKokdhas+mvFq22l3SWjc5/w17G54dl9U/SVUYu6/mOOHnKOWDqxglU7rxOQDF ZYDrOOaUrze/deXMhtgrSuQF/wmPo80FnWXx3AE4Fq+vJAkwbCjIGIGDetmGpxxUd5AH dprt0j+6uMnETog6/cwt++fUxQwm2bP+yFbFJqZNnRTeFphV8vm1a4NkHIDQOwPEhs2u baNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776240898; x=1776845698; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=cr3LYjuSIkdSjgKcjE5pXiQW5P99n+0bc+MlVW7WbAQ=; b=TlxIYlqMWERSZIiAHqv2RRPMu5+D+bkF8uvRdAZPgyV/BH0w0ZQvfIE1XUktY01ynu Uhre0LbuZMpRulbUH2UoXlPiJOfq2JVHVHmhng0JvcfDVaGv/xSqQQOxldiBDphMjzAH PSIi3EeTypP2ablfgc7lv+jn3lMQ9z90/EQ8VLJfAzrBLafdlUhFdjoWZo5DE/uSRDLT NuqsWoFTePsE1UhZGmxU4uoUDJBHsZzLq41wha+1IQtdoVYecDo8l4D8SS+q7JJYh3ne uNr6YXgPEV4vLTQWp+Hzg7clkUY/oF8R+s1NkKVqH76t0Cn3eF782CYsUkmpfefqgRY/ owAA== X-Forwarded-Encrypted: i=1; AFNElJ/VdRlqbdr83S/YWN1jnyK8oOf1VZZHJjwZq1tVol/55SV59slTcvCdXMNlO56+t4LeOu5v3r6UVVDdXSs=@vger.kernel.org X-Gm-Message-State: AOJu0YyErBMUd8nsmmYAjkC6byx1Vmvw2H8/EqnpEs7DN0kf8gD87H7y 02qBGgnGpMZItOoGUph3Q1NPfB1Lvbq0ZzUSi5F8hxGoAjW98kC1hwYT X-Gm-Gg: AeBDieuVpuRjBZMkQ/S+3W/52o4YPKniMwcAjjT6PzJ/ypA9tO1HsuUKCF7JSq5pbgk f8E75iiQQsOtnCM8N1a70gboXnGQCZQAtoQLm1mFAjx51tv6DbYfUkcGoi34LZyRxV8u1NMwkD9 HKsqArmJ+JvgDfqzMEIy2Ijv1aPUSWS5yxJvg7rIpG0qYan/mqCXx7VU7KYuh0J11TYWUf1tgpS pcLvVh4bNX9SqjICuyk6llCoD/0yS18f7WT16cdgygT2OLuUGUAcbgh1wyJwCYPKp+wrSdJyz0E 543lbfUbmi9OInWW/N+/XxGwHWF2pnFEgpkCrxM+iDW4+A6sbzWbnxtkgqIb9OEfu4ZKgZ/hHCG IN7IgVuytzBOeqwiA1YwAy8vHOnUcdy/3g9in60XnYTWs+EcjQOCkkscKpUI1RKAdFIrH1wjiOk S7kx789h+ve330Oi24s69ZYXjfMeMaPtZxVXaPwiFIdqdN+QpftntIgxNTe+c= X-Received: by 2002:a17:902:ca93:b0:2b4:6398:6aa2 with SMTP id d9443c01a7336-2b463986c68mr64461715ad.27.1776240898025; Wed, 15 Apr 2026 01:14:58 -0700 (PDT) Received: from qiwenjie-ThinkCentre-M760t.mioffice.cn ([43.224.245.179]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b478127040sm12630005ad.31.2026.04.15.01.14.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2026 01:14:57 -0700 (PDT) From: Wenjie Qi X-Google-Original-From: Wenjie Qi To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qwjhust@gmail.com Subject: [RFC PATCH v1] f2fs: map data writes to FDP streams Date: Wed, 15 Apr 2026 16:14:49 +0800 Message-ID: <20260415081451.2333535-1-qiwenjie@xiaomi.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Wenjie Qi From: Wenjie Qi F2FS already classifies DATA writes using its existing hot, warm and cold temperature policy, but it only passes that intent down as a write hint. That hint alone is not sufficient for NVMe FDP placement, because the current NVMe command path consumes `bio->bi_write_stream` rather than `bio->bi_write_hint` when selecting a placement ID. When the target block device exposes write streams, map the existing F2FS DATA temperature classes onto stream IDs and set `bio->bi_write_stream` for both buffered and direct writes. If the device exposes no write streams, keep the current behavior by leaving the stream unset. The stream mapping is evaluated against the target block device of each bio, so the existing per-device fallback behavior stays unchanged for multi-device filesystems. Existing blkzoned restrictions also remain in place. The mapping is intentionally small and deterministic: - 1 stream: hot, warm and cold all use stream 1 - 2 streams: hot/warm use 1, cold uses 2 - 3+ streams: hot uses 1, warm uses 2, cold uses 3 Signed-off-by: Wenjie Qi --- RFC notes: - Scope is intentionally limited to DATA writes only. - Validation used stock QEMU 8.2.2 NVMe FDP emulation with a 16G namespace. - FDP enabled: buffered and direct writes each produced 3 dominant NVMe placement tuples. - FDP disabled: buffered and direct writes each collapsed to 1 dominant tuple. fs/f2fs/data.c | 2 ++ fs/f2fs/f2fs.h | 2 ++ fs/f2fs/file.c | 2 ++ fs/f2fs/segment.c | 24 ++++++++++++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 338df7a2a..df9f4a230 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -508,6 +508,8 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio= , int npages) bio->bi_private =3D sbi; bio->bi_write_hint =3D f2fs_io_type_to_rw_hint(sbi, fio->type, fio->temp); + bio->bi_write_stream =3D f2fs_io_type_to_write_stream(bdev, fio->type, + fio->temp); } iostat_alloc_and_bind_ctx(sbi, bio, NULL); =20 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index bb34e864d..2f0777478 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -4056,6 +4056,8 @@ void f2fs_destroy_segment_manager_caches(void); int f2fs_rw_hint_to_seg_type(struct f2fs_sb_info *sbi, enum rw_hint hint); enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi, enum page_type type, enum temp_type temp); +u8 f2fs_io_type_to_write_stream(struct block_device *bdev, + enum page_type type, enum temp_type temp); unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi); unsigned int f2fs_usable_blks_in_seg(struct f2fs_sb_info *sbi, unsigned int segno); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c8a2f17a8..a3186cfc9 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -5064,6 +5064,8 @@ static void f2fs_dio_write_submit_io(const struct iom= ap_iter *iter, enum temp_type temp =3D f2fs_get_segment_temp(sbi, type); =20 bio->bi_write_hint =3D f2fs_io_type_to_rw_hint(sbi, DATA, temp); + bio->bi_write_stream =3D + f2fs_io_type_to_write_stream(bio->bi_bdev, DATA, temp); blk_crypto_submit_bio(bio); } =20 diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 6a97fe767..ef8a3ac55 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3626,6 +3626,30 @@ enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_= info *sbi, } } =20 +u8 f2fs_io_type_to_write_stream(struct block_device *bdev, + enum page_type type, enum temp_type temp) +{ + unsigned short nr =3D bdev_max_write_streams(bdev); + + if (type !=3D DATA || !nr) + return 0; + if (nr =3D=3D 1) + return 1; + if (nr =3D=3D 2) + return temp =3D=3D COLD ? 2 : 1; + + switch (temp) { + case HOT: + return 1; + case WARM: + return 2; + case COLD: + return 3; + default: + return 0; + } +} + static int __get_segment_type_2(struct f2fs_io_info *fio) { if (fio->type =3D=3D DATA) --=20 2.43.0