public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <dgc@kernel.org>
To: Kanchan Joshi <joshi.k@samsung.com>
Cc: brauner@kernel.org, hch@lst.de, djwong@kernel.org, jack@suse.cz,
	cem@kernel.org, kbusch@kernel.org, axboe@kernel.dk,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	gost.dev@samsung.com
Subject: Re: [PATCH v2 4/5] xfs: steer allocation using write stream
Date: Tue, 10 Mar 2026 16:47:50 +1100	[thread overview]
Message-ID: <aa-whgDFL7h8-gIl@dread> (raw)
In-Reply-To: <20260309052944.156054-5-joshi.k@samsung.com>

On Mon, Mar 09, 2026 at 10:59:43AM +0530, Kanchan Joshi wrote:
> When write stream is set on the file, override the default
> directory-locality heuristic with a new heuristic that maps
> available AGs into streams.
>
> Isolating distinct write streams into dedicated allocation groups helps
> in reducing the block interleaving of concurrent writers. Keeping these
> streams spatially separated reduces AGF lock contention and logical file
> fragmentation.

a.k.a. the XFS filestreams allocator.

i.e. we already have an allocator that performs this exact locality
mapping. See xfs_inode_is_filestream() and the allocator code path
that goes this way:

xfs_bmap_btalloc()
  xfs_bmap_btalloc_filestreams()
    xfs_filestream_select_ag()

Please integrate this write stream mapping functionality into that
allocator rather than hacking a new, almost identical allocator
policy into XFS.

filestreams currently uses the parent inode number as the stream ID
and maps that to an AG. It should be relatively trivial to use the
ip->i_write_stream as the stream ID instead of the parent inode.

> If AGs are fewer than write streams, write streams are distributed into
> available AGs in round robin fashion.
> If not, available AGs are partitioned into write streams. Since each
> write stream maps to a partition of multiple contiguous AGs, the inode hash
> is used to choose the specific AG within the stream partition. This can
> help with intra-stream concurency when multiple files are being written in
> a single stream that has 2 or more AGs.
> 
> Example: 8 Allocation Groups, 4 Streams
> Partition Size = 2 AGs per Stream
> 
>    Stream 1 (ID: 1)         Stream 2 (ID: 2)         Streams 3 & 4
>  +---------+---------+    +---------+---------+    +-------------
>  |   AG0   |   AG1   |    |   AG2   |   AG3   |    |  AG4...AG7
>  +---------+---------+    +---------+---------+    +-------------
>       ^         ^              ^         ^
>       |         |              |         |
>       | File B (ino: 101)      | File D (ino: 201)
>       | 101 % 2 = 1 -> AG 1    | 201 % 2 = 1 -> AG 3
>       |                        |
>  File A (ino: 100)        File C (ino: 200)
>  100 % 2 = 0 -> AG 0      200 % 2 = 0 -> AG 2
> 
> If AGs can not be evenly distributed among streams, the last stream will
> absorb the remaining AGs.

Yeah, this should all be hidden behind xfs_filestream_select_ag()
when ip->i_write_stream is set....

> Note that there are no hard boundaries; this only provides explicit
> routing hint to xfs allocator so that it can group/isolate files in the way
> application has decided to group/isolate. We still try to preserve file
> contiguity, and the full space can be utilized even with a single stream.

Yes, that's pretty much exactly what the filestreams allocator was
designed to do. It's a whole lot more dynamic that what you are
trying to do above and is not limited fixed AGs for streams - as
soon as an AG is out of space, it will select the AG with the most
free space for the stream and keep that relationship until that AG
is out of space.

IOWs, filestreams does not limit a stream to a fixed number of AGs.
All it does is keep IO with the same stream ID in the same AG until
the AG is full and, as much as possible, prevents multiple streams
from using the same AG.

-Dave.
-- 
Dave Chinner
dgc@kernel.org

  parent reply	other threads:[~2026-03-10  5:47 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260309053425epcas5p32886580a4fbe646ceee66f2864970e9f@epcas5p3.samsung.com>
2026-03-09  5:29 ` [PATCH v2 0/5] write streams and xfs spatial isolation Kanchan Joshi
2026-03-09  5:29   ` [PATCH v2 1/5] fs: add generic write-stream management ioctl Kanchan Joshi
2026-03-09 16:33     ` Darrick J. Wong
2026-03-10 17:55       ` Kanchan Joshi
2026-03-10 20:44         ` Darrick J. Wong
2026-03-09  5:29   ` [PATCH v2 2/5] iomap: introduce and propagate write_stream Kanchan Joshi
2026-03-09 16:34     ` Darrick J. Wong
2026-03-10 17:58       ` Kanchan Joshi
2026-03-09  5:29   ` [PATCH v2 3/5] xfs: implement write-stream management support Kanchan Joshi
2026-03-09 16:38     ` Darrick J. Wong
2026-03-10 18:07       ` Kanchan Joshi
2026-03-09  5:29   ` [PATCH v2 4/5] xfs: steer allocation using write stream Kanchan Joshi
2026-03-09 12:45     ` kernel test robot
2026-03-09 20:01     ` kernel test robot
2026-03-10  5:47     ` Dave Chinner [this message]
2026-03-10 19:03       ` Kanchan Joshi
2026-03-10 22:44         ` Dave Chinner
2026-03-11  9:59           ` Kanchan Joshi
2026-03-09  5:29   ` [PATCH v2 5/5] xfs: introduce software write streams Kanchan Joshi
2026-03-10  6:01     ` Dave Chinner
2026-03-09 15:40   ` [PATCH v2 0/5] write streams and xfs spatial isolation Christoph Hellwig
2026-03-10 21:19     ` Kanchan Joshi

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=aa-whgDFL7h8-gIl@dread \
    --to=dgc@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=gost.dev@samsung.com \
    --cc=hch@lst.de \
    --cc=jack@suse.cz \
    --cc=joshi.k@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /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