aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2018-06-01 12:03:06 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2018-06-01 21:37:32 -0400
commit19319b53210c6b89c375cf395c08f156cccd83ea (patch)
treed0379f5b72aea5bbd5cf8d20738daa9aca93ff54
parentb3751e6ab45a3b92da1e4acd42ada7b6a4122f2b (diff)
iomap: inline data should be an iomap type, not a flag
Inline data is fundamentally different from our normal mapped case in that it doesn't even have a block address. So instead of having a flag for it it should be an entirely separate iomap range type. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/ext4/inline.c4
-rw-r--r--fs/gfs2/bmap.c3
-rw-r--r--fs/iomap.c21
-rw-r--r--include/linux/iomap.h2
4 files changed, 16 insertions, 14 deletions
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 70cf4c7b268a..e1f00891ef95 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1835,8 +1835,8 @@ int ext4_inline_data_iomap(struct inode *inode, struct iomap *iomap)
1835 iomap->offset = 0; 1835 iomap->offset = 0;
1836 iomap->length = min_t(loff_t, ext4_get_inline_size(inode), 1836 iomap->length = min_t(loff_t, ext4_get_inline_size(inode),
1837 i_size_read(inode)); 1837 i_size_read(inode));
1838 iomap->type = 0; 1838 iomap->type = IOMAP_INLINE;
1839 iomap->flags = IOMAP_F_DATA_INLINE; 1839 iomap->flags = 0;
1840 1840
1841out: 1841out:
1842 up_read(&EXT4_I(inode)->xattr_sem); 1842 up_read(&EXT4_I(inode)->xattr_sem);
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 278ed0869c3c..cbeedd3cfb36 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -680,8 +680,7 @@ static void gfs2_stuffed_iomap(struct inode *inode, struct iomap *iomap)
680 sizeof(struct gfs2_dinode); 680 sizeof(struct gfs2_dinode);
681 iomap->offset = 0; 681 iomap->offset = 0;
682 iomap->length = i_size_read(inode); 682 iomap->length = i_size_read(inode);
683 iomap->type = IOMAP_MAPPED; 683 iomap->type = IOMAP_INLINE;
684 iomap->flags = IOMAP_F_DATA_INLINE;
685} 684}
686 685
687/** 686/**
diff --git a/fs/iomap.c b/fs/iomap.c
index f2456d0d8ddd..df2652b0d85d 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -502,10 +502,13 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
502 case IOMAP_DELALLOC: 502 case IOMAP_DELALLOC:
503 flags |= FIEMAP_EXTENT_DELALLOC | FIEMAP_EXTENT_UNKNOWN; 503 flags |= FIEMAP_EXTENT_DELALLOC | FIEMAP_EXTENT_UNKNOWN;
504 break; 504 break;
505 case IOMAP_MAPPED:
506 break;
505 case IOMAP_UNWRITTEN: 507 case IOMAP_UNWRITTEN:
506 flags |= FIEMAP_EXTENT_UNWRITTEN; 508 flags |= FIEMAP_EXTENT_UNWRITTEN;
507 break; 509 break;
508 case IOMAP_MAPPED: 510 case IOMAP_INLINE:
511 flags |= FIEMAP_EXTENT_DATA_INLINE;
509 break; 512 break;
510 } 513 }
511 514
@@ -513,8 +516,6 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi,
513 flags |= FIEMAP_EXTENT_MERGED; 516 flags |= FIEMAP_EXTENT_MERGED;
514 if (iomap->flags & IOMAP_F_SHARED) 517 if (iomap->flags & IOMAP_F_SHARED)
515 flags |= FIEMAP_EXTENT_SHARED; 518 flags |= FIEMAP_EXTENT_SHARED;
516 if (iomap->flags & IOMAP_F_DATA_INLINE)
517 flags |= FIEMAP_EXTENT_DATA_INLINE;
518 519
519 return fiemap_fill_next_extent(fi, iomap->offset, 520 return fiemap_fill_next_extent(fi, iomap->offset,
520 iomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0, 521 iomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0,
@@ -1214,14 +1215,16 @@ static loff_t iomap_swapfile_activate_actor(struct inode *inode, loff_t pos,
1214 struct iomap_swapfile_info *isi = data; 1215 struct iomap_swapfile_info *isi = data;
1215 int error; 1216 int error;
1216 1217
1217 /* No inline data. */ 1218 switch (iomap->type) {
1218 if (iomap->flags & IOMAP_F_DATA_INLINE) { 1219 case IOMAP_MAPPED:
1220 case IOMAP_UNWRITTEN:
1221 /* Only real or unwritten extents. */
1222 break;
1223 case IOMAP_INLINE:
1224 /* No inline data. */
1219 pr_err("swapon: file is inline\n"); 1225 pr_err("swapon: file is inline\n");
1220 return -EINVAL; 1226 return -EINVAL;
1221 } 1227 default:
1222
1223 /* Only real or unwritten extents. */
1224 if (iomap->type != IOMAP_MAPPED && iomap->type != IOMAP_UNWRITTEN) {
1225 pr_err("swapon: file has unallocated extents\n"); 1228 pr_err("swapon: file has unallocated extents\n");
1226 return -EINVAL; 1229 return -EINVAL;
1227 } 1230 }
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 4bd87294219a..8f7095fc514e 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -18,6 +18,7 @@ struct vm_fault;
18#define IOMAP_DELALLOC 0x02 /* delayed allocation blocks */ 18#define IOMAP_DELALLOC 0x02 /* delayed allocation blocks */
19#define IOMAP_MAPPED 0x03 /* blocks allocated at @addr */ 19#define IOMAP_MAPPED 0x03 /* blocks allocated at @addr */
20#define IOMAP_UNWRITTEN 0x04 /* blocks allocated at @addr in unwritten state */ 20#define IOMAP_UNWRITTEN 0x04 /* blocks allocated at @addr in unwritten state */
21#define IOMAP_INLINE 0x05 /* data inline in the inode */
21 22
22/* 23/*
23 * Flags for all iomap mappings: 24 * Flags for all iomap mappings:
@@ -34,7 +35,6 @@ struct vm_fault;
34 */ 35 */
35#define IOMAP_F_MERGED 0x10 /* contains multiple blocks/extents */ 36#define IOMAP_F_MERGED 0x10 /* contains multiple blocks/extents */
36#define IOMAP_F_SHARED 0x20 /* block shared with another file */ 37#define IOMAP_F_SHARED 0x20 /* block shared with another file */
37#define IOMAP_F_DATA_INLINE 0x40 /* data inline in the inode */
38 38
39/* 39/*
40 * Magic value for addr: 40 * Magic value for addr: