Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=203.254.224.33 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795595754; b=JZe5N6D239FjiwjxN5YQzRkopZ5bHRC/xL5JdZZ4Cgs/sU9ORQe8Rr6hbGNWy6oFnDfq hRQMkWLs4AR2EpwUrTRWoZmYw+VFVbJr50MzlP3eo/pN29RvhC+xxUv8gCRb4S0YPixgv g7zpxw6BoxchWIx4fW2V5l06mh9Mn+4vU0HdVrh8sCWb9mSEsgMSk3MYW7VWpoyG0MjyI N16oQyrXEHR2ke0osv0vGw2JVKYdnyzNzeZZYalBM6BffIjTuI0CS8WWGkfw2jhvjt1F4 e8tntnc0z1Q7C54yOAFuyRAxvCtsIVf9AVJso/h+R5q6E4/FhW11Up880x2covSwMZw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795595754; h=DMARC-Filter:Received:DKIM-Filter:DKIM-Signature:Received:Received: Received:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer: In-Reply-To:MIME-Version:Content-Transfer-Encoding:X-CMS-MailID: X-Msg-Generator:Content-Type:CMS-TYPE:cpgsPolicy:X-CFilter-Loop: X-CMS-RootMailID:References; bh=VWQ/lsKjZNhGOhoE2VNJ2uZg4zN7u4SrYf62+pN9Mcs=; b=Z95xTw5KX0vbxpvzhq4onX7eN7+RwjOvP50BzJtfzBTSyymEI+wqwAeVijhez4c1BufS HVWGqPFn6O6vzl1RgHw0MRXE/wBn6OG/Y6OuIEqw8zUw8Ubttj1bIsvLc907Hdt+AwWFw ka1HFDXCBHvMlOztHCvdABR043MRnb5ezgZ+2NNCEugoKLRXlMGYSIQ9uRxbAdpfTOnk3 0z+kFxtvJkPaTvuLayABi1F8LZkI0HfjyIAMIckF1O2B09Jwur7ath9JND2nISo+0yo2e y1LMZFxhZbaQ7Ejr7+BTyUZ8GNLwuUy3rarmugAvuO4xJnPiOEjmA9XlV+kBYduzx3w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=SeTdKDsK; arc=none smtp.remote-ip=203.254.224.33 Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BD4B606A31E for ; Wed, 25 Nov 2026 08:35:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5BD4B606A31E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.a=rsa-sha256 header.s=mail20170921 header.b=SeTdKDsK Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20261125083551epoutp0344fcaafebb66a6bad3341eebb229d946~rPNKbD2e_1704417044epoutp03G for ; Wed, 25 Nov 2026 08:35:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20261125083551epoutp0344fcaafebb66a6bad3341eebb229d946~rPNKbD2e_1704417044epoutp03G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1795595751; bh=VWQ/lsKjZNhGOhoE2VNJ2uZg4zN7u4SrYf62+pN9Mcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SeTdKDsKNeTPydB9fZKAUvDbVa0/hRl/s1oUzeQ66qxpq9TdFyNTmvqErtgfJWRid vnGdxqTqQ+Nq7tk+bdMDwwd4V12h3y+lMqJK5VqI+gkK00uUMCNdF5mX9aTOVqcw30 oHvL9256knEI451TWbbsU/GlF8+PndOnZjf5nHnU= Received: from epsnrtp01.localdomain (unknown [182.195.42.153]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPS id 20261125083551epcas5p2ebe50a815bfb7de79f0beed0514e0f56~rPNJ5m7543005330053epcas5p27; Wed, 25 Nov 2026 08:35:51 +0000 (GMT) Received: from epcas5p2.samsung.com (unknown [182.195.38.94]) by epsnrtp01.localdomain (Postfix) with ESMTP id 4jZCgV14dJz6B9m4; Wed, 25 Nov 2026 08:35:50 +0000 (GMT) Received: from epsmtip1.samsung.com (unknown [182.195.34.30]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20261125083549epcas5p145b41e9d633820499173c72018414f29~rPNIb4fQf1553115531epcas5p1v; Wed, 25 Nov 2026 08:35:49 +0000 (GMT) Received: from localhost.localdomain (unknown [107.99.41.245]) by epsmtip1.samsung.com (KnoxPortal) with ESMTPA id 20261125083547epsmtip16592c9d78525628e66799458821ab22c~rPNG76rXQ0455204552epsmtip1L; Wed, 25 Nov 2026 08:35:47 +0000 (GMT) From: Kanchan Joshi To: brauner@kernel.org, hch@lst.de, djwong@kernel.org, dgc@kernel.org, cem@kernel.org, jack@suse.cz, hans.holmberg@wdc.com Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, anuj20.g@samsung.com, gost.dev@samsung.com, Kanchan Joshi Subject: [PATCH v8 9/9] xfs: support hardware write streams Date: Wed, 25 Nov 2026 14:03:13 +0530 Message-Id: <20261125083313.106334-10-joshi.k@samsung.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261125083313.106334-1-joshi.k@samsung.com> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMS-MailID: 20261125083549epcas5p145b41e9d633820499173c72018414f29 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P cpgsPolicy: CPGSC10-542,Y X-CFilter-Loop: Reflected X-CMS-RootMailID: 20261125083549epcas5p145b41e9d633820499173c72018414f29 References: <20261125083313.106334-1-joshi.k@samsung.com> Use the stream count reported by the data and realtime block devices where they have one, falling back to the geometry-derived count. The count is capped at the group count so that every stream backs onto at least one group; a device with more streams than the filesystem groups loses the excess, so mkfs should create at least as many groups as the device has streams. It is also capped at U8_MAX, the most streams the block layer can tag. Set iomap->write_stream from the inode so that the id reaches the device, but only when the device has write streams. Signed-off-by: Kanchan Joshi Signed-off-by: Anuj Gupta --- fs/xfs/xfs_buf.c | 8 +++++++- fs/xfs/xfs_iomap.c | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index d8ce03a9f49c..41c543e132cb 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c @@ -1711,8 +1711,14 @@ xfs_buftarg_init_streams( unsigned int nr_groups) { unsigned int nr_streams; + unsigned int hw_streams; - nr_streams = xfs_sw_write_stream_count(nr_groups); + hw_streams = bdev_max_write_streams(btp->bt_bdev); + if (hw_streams) + nr_streams = min3(hw_streams, nr_groups, + XFS_MAX_WRITE_STREAMS); + else + nr_streams = xfs_sw_write_stream_count(nr_groups); return write_stream_pool_init(&btp->bt_stream_pool, nr_streams); } diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 329c745e3120..f0d191891a06 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -144,6 +144,11 @@ xfs_bmbt_to_iomap( } iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff); iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount); + /* software stream ids must not reach a device without streams */ + if (bdev_max_write_streams(target->bt_bdev)) + iomap->write_stream = READ_ONCE(VFS_I(ip)->i_write_stream); + else + iomap->write_stream = WRITE_STREAM_NOT_SET; if (mapping_flags & IOMAP_DAX) { iomap->dax_dev = target->bt_daxdev; } else { -- 2.25.1