Skip to content

Commit 17de0a9

Browse files
Christoph Hellwigdchinner
authored andcommitted
iomap: don't set FIEMAP_EXTENT_MERGED for extent based filesystems
Filesystems like XFS that use extents should not set the FIEMAP_EXTENT_MERGED flag in the fiemap extent structures. To allow for both behaviors for the upcoming gfs2 usage split the iomap type field into type and flags, and only set FIEMAP_EXTENT_MERGED if the IOMAP_F_MERGED flag is set. The flags field will also come in handy for future features such as shared extents on reflink-enabled file systems. Reported-by: Andreas Gruenbacher <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Acked-by: Darrick J. Wong <[email protected]> Signed-off-by: Dave Chinner <[email protected]>
1 parent 800b269 commit 17de0a9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

fs/iomap.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,12 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
428428
break;
429429
}
430430

431+
if (iomap->flags & IOMAP_F_MERGED)
432+
flags |= FIEMAP_EXTENT_MERGED;
433+
431434
return fiemap_fill_next_extent(fi, iomap->offset,
432435
iomap->blkno != IOMAP_NULL_BLOCK ? iomap->blkno << 9: 0,
433-
iomap->length, flags | FIEMAP_EXTENT_MERGED);
436+
iomap->length, flags);
434437

435438
}
436439

include/linux/iomap.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ struct vm_fault;
1818
#define IOMAP_MAPPED 0x03 /* blocks allocated @blkno */
1919
#define IOMAP_UNWRITTEN 0x04 /* blocks allocated @blkno in unwritten state */
2020

21+
/*
22+
* Flags for iomap mappings:
23+
*/
24+
#define IOMAP_F_MERGED 0x01 /* contains multiple blocks/extents */
25+
2126
/*
2227
* Magic value for blkno:
2328
*/
@@ -27,7 +32,8 @@ struct iomap {
2732
sector_t blkno; /* 1st sector of mapping, 512b units */
2833
loff_t offset; /* file offset of mapping, bytes */
2934
u64 length; /* length of mapping, bytes */
30-
int type; /* type of mapping */
35+
u16 type; /* type of mapping */
36+
u16 flags; /* flags for mapping */
3137
struct block_device *bdev; /* block device for I/O */
3238
};
3339

0 commit comments

Comments
 (0)