Skip to content

Commit 64c58d7

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
iomap: add a merge boundary flag
File systems might have boundaries over which merges aren't possible. In fact these are very common, although most of the time some kind of header at the beginning of this region (e.g. XFS alloation groups, ext4 block groups) automatically create a merge barrier. But if that is not present, say for a device purely used for data we need to manually communicate that to iomap. Add a IOMAP_F_BOUNDARY flag to never merge I/O into a previous mapping. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
1 parent dca9425 commit 64c58d7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

fs/iomap/buffered-io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,8 @@ iomap_ioend_can_merge(struct iomap_ioend *ioend, struct iomap_ioend *next)
16011601
{
16021602
if (ioend->io_bio.bi_status != next->io_bio.bi_status)
16031603
return false;
1604+
if (next->io_flags & IOMAP_F_BOUNDARY)
1605+
return false;
16041606
if ((ioend->io_flags & IOMAP_F_SHARED) ^
16051607
(next->io_flags & IOMAP_F_SHARED))
16061608
return false;
@@ -1720,6 +1722,8 @@ static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
17201722
INIT_LIST_HEAD(&ioend->io_list);
17211723
ioend->io_type = wpc->iomap.type;
17221724
ioend->io_flags = wpc->iomap.flags;
1725+
if (pos > wpc->iomap.offset)
1726+
wpc->iomap.flags &= ~IOMAP_F_BOUNDARY;
17231727
ioend->io_inode = inode;
17241728
ioend->io_size = 0;
17251729
ioend->io_offset = pos;
@@ -1731,6 +1735,8 @@ static struct iomap_ioend *iomap_alloc_ioend(struct iomap_writepage_ctx *wpc,
17311735

17321736
static bool iomap_can_add_to_ioend(struct iomap_writepage_ctx *wpc, loff_t pos)
17331737
{
1738+
if (wpc->iomap.offset == pos && (wpc->iomap.flags & IOMAP_F_BOUNDARY))
1739+
return false;
17341740
if ((wpc->iomap.flags & IOMAP_F_SHARED) !=
17351741
(wpc->ioend->io_flags & IOMAP_F_SHARED))
17361742
return false;

include/linux/iomap.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ struct vm_fault;
5353
*
5454
* IOMAP_F_XATTR indicates that the iomap is for an extended attribute extent
5555
* rather than a file data extent.
56+
*
57+
* IOMAP_F_BOUNDARY indicates that I/O and I/O completions for this iomap must
58+
* never be merged with the mapping before it.
5659
*/
5760
#define IOMAP_F_NEW (1U << 0)
5861
#define IOMAP_F_DIRTY (1U << 1)
@@ -64,6 +67,7 @@ struct vm_fault;
6467
#define IOMAP_F_BUFFER_HEAD 0
6568
#endif /* CONFIG_BUFFER_HEAD */
6669
#define IOMAP_F_XATTR (1U << 5)
70+
#define IOMAP_F_BOUNDARY (1U << 6)
6771

6872
/*
6973
* Flags set by the core iomap code during operations:

0 commit comments

Comments
 (0)