[PATCH 14/20] fiemap: Use fiemap_ctx as fiemap_fill_next_extent argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace the current fiemap_extent_info argument in
fiemap_fill_next_extent(), by the new fiemap_ctx structure. This way we
remove (almost) all direct usage of fiemap_extent_info outside fiemap
code (except by btrfs).

Signed-off-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx>
---
 fs/btrfs/extent_io.c  | 16 ++++++----------
 fs/ext4/extents.c     |  8 +++-----
 fs/ext4/inline.c      |  5 ++---
 fs/f2fs/data.c        | 13 ++++---------
 fs/f2fs/inline.c      |  4 +---
 fs/ioctl.c            | 12 ++++++------
 fs/iomap.c            |  3 +--
 fs/nilfs2/inode.c     | 16 +++++++---------
 fs/ocfs2/extent_map.c |  9 +++------
 include/linux/fs.h    |  2 +-
 10 files changed, 34 insertions(+), 54 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8d4d02d0bf8a..6a8bc502bc04 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -4373,9 +4373,8 @@ static int emit_fiemap_extent(struct fiemap_ctx *f_ctx,
 	}
 
 	/* Not mergeable, need to submit cached one */
-	ret = fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
-			cache->offset, cache->phys, cache->len, cache->flags);
+	ret = fiemap_fill_next_extent(f_ctx, cache->offset, cache->phys,
+				      cache->len, cache->flags);
 	cache->cached = false;
 	if (ret)
 		return ret;
@@ -4387,10 +4386,8 @@ static int emit_fiemap_extent(struct fiemap_ctx *f_ctx,
 	cache->flags = flags;
 try_submit_last:
 	if (cache->flags & FIEMAP_EXTENT_LAST) {
-		ret = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
-				cache->offset, cache->phys, cache->len,
-				cache->flags);
+		ret = fiemap_fill_next_extent(f_ctx, cache->offset, cache->phys,
+					      cache->len, cache->flags);
 		cache->cached = false;
 	}
 	return ret;
@@ -4416,9 +4413,8 @@ static int emit_last_fiemap_cache(struct btrfs_fs_info *fs_info,
 	if (!cache->cached)
 		return 0;
 
-	ret = fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
-			cache->offset, cache->phys, cache->len, cache->flags);
+	ret = fiemap_fill_next_extent(f_ctx, cache->offset, cache->phys,
+				      cache->len, cache->flags);
 	cache->cached = false;
 	if (ret > 0)
 		ret = 0;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 11ee46aff677..94fdebc4d6db 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2277,8 +2277,7 @@ static int ext4_fill_fiemap_extents(struct inode *inode,
 		}
 
 		if (exists) {
-			err = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
+			err = fiemap_fill_next_extent(f_ctx,
 				(__u64)es.es_lblk << blksize_bits,
 				(__u64)es.es_pblk << blksize_bits,
 				(__u64)es.es_len << blksize_bits,
@@ -5041,9 +5040,8 @@ static int ext4_xattr_fiemap(struct inode *inode,
 	}
 
 	if (physical)
-		error = fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
-			0, physical, length, flags);
+		error = fiemap_fill_next_extent(f_ctx, 0, physical,
+						length, flags);
 	return (error < 0 ? error : 0);
 }
 
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 7b9b0da60d54..e1079a1c85f4 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1888,9 +1888,8 @@ int ext4_inline_data_fiemap(struct inode *inode,
 	physical += offsetof(struct ext4_inode, i_block);
 
 	if (physical)
-		error = fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
-			start, physical, inline_len, flags);
+		error = fiemap_fill_next_extent(f_ctx, start, physical,
+						inline_len, flags);
 	brelse(iloc.bh);
 out:
 	up_read(&EXT4_I(inode)->xattr_sem);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8ce60b5954d8..2470f8b346db 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -1366,9 +1366,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 		if (!xnid)
 			flags |= FIEMAP_EXTENT_LAST;
 
-		err = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
-				0, phys, len, flags);
+		err = fiemap_fill_next_extent(f_ctx, 0, phys, len, flags);
 
 		if (err || err == 1)
 			return err;
@@ -1394,9 +1392,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 	}
 
 	if (phys)
-		err = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
-				0, phys, len, flags);
+		err = fiemap_fill_next_extent(f_ctx, 0, phys, len, flags);
 
 	return (err < 0 ? err : 0);
 }
@@ -1465,9 +1461,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 		if (f2fs_encrypted_inode(inode))
 			flags |= FIEMAP_EXTENT_DATA_ENCRYPTED;
 
-		ret = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
-				logical, phys, size, flags);
+		ret = fiemap_fill_next_extent(f_ctx, logical, phys,
+					      size, flags);
 	}
 
 	if (start_blk > last_blk || ret)
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 353a81317fac..0c4534880a99 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -705,9 +705,7 @@ int f2fs_inline_data_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 	byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
 	byteaddr += (char *)inline_data_addr(inode, ipage) -
 					(char *)F2FS_INODE(ipage);
-	err = fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
-			start, byteaddr, ilen, flags);
+	err = fiemap_fill_next_extent(f_ctx, start, byteaddr, ilen, flags);
 
 out:
 	f2fs_put_page(ipage, 1);
diff --git a/fs/ioctl.c b/fs/ioctl.c
index 77af3b116972..27f79b29cb07 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -86,9 +86,10 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
 #define SET_UNKNOWN_FLAGS	(FIEMAP_EXTENT_DELALLOC)
 #define SET_NO_UNMOUNTED_IO_FLAGS	(FIEMAP_EXTENT_DATA_ENCRYPTED)
 #define SET_NOT_ALIGNED_FLAGS	(FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE)
-int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical,
+int fiemap_fill_next_extent(struct fiemap_ctx *f_ctx, u64 logical,
 			    u64 phys, u64 len, u32 flags)
 {
+	struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
 	struct fiemap_extent extent;
 	struct fiemap_extent __user *dest = fieinfo->fi_extents_start;
 
@@ -286,7 +287,6 @@ static inline loff_t blk_to_logical(struct inode *inode, sector_t blk)
 int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
 			   get_block_t *get_block)
 {
-	struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
 	loff_t start = f_ctx->fc_start;
 	loff_t len = f_ctx->fc_len;
 	struct buffer_head map_bh;
@@ -354,11 +354,11 @@ int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
 			 */
 			if (past_eof && size) {
 				flags = FIEMAP_EXTENT_MERGED|FIEMAP_EXTENT_LAST;
-				ret = fiemap_fill_next_extent(fieinfo, logical,
+				ret = fiemap_fill_next_extent(f_ctx, logical,
 							      phys, size,
 							      flags);
 			} else if (size) {
-				ret = fiemap_fill_next_extent(fieinfo, logical,
+				ret = fiemap_fill_next_extent(f_ctx, logical,
 							      phys, size, flags);
 				size = 0;
 			}
@@ -383,7 +383,7 @@ int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
 			 * and break
 			 */
 			if (start_blk > last_blk && !whole_file) {
-				ret = fiemap_fill_next_extent(fieinfo, logical,
+				ret = fiemap_fill_next_extent(f_ctx, logical,
 							      phys, size,
 							      flags);
 				break;
@@ -394,7 +394,7 @@ int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
 			 * to add, so add it.
 			 */
 			if (size) {
-				ret = fiemap_fill_next_extent(fieinfo, logical,
+				ret = fiemap_fill_next_extent(f_ctx, logical,
 							      phys, size,
 							      flags);
 				if (ret)
diff --git a/fs/iomap.c b/fs/iomap.c
index 53e6b4bf10a9..8d4fca1c7ce1 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1128,8 +1128,7 @@ static int iomap_to_fiemap(struct fiemap_ctx *f_ctx,
 	if (iomap->flags & IOMAP_F_SHARED)
 		flags |= FIEMAP_EXTENT_SHARED;
 
-	return fiemap_fill_next_extent(
-			(struct fiemap_extent_info *)f_ctx->fc_data,
+	return fiemap_fill_next_extent(f_ctx,
 			iomap->offset,
 			iomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0,
 			iomap->length, flags);
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 88c13f6c13cd..bb92c08904b7 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -1027,9 +1027,8 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 		if (delalloc_blklen && blkoff == delalloc_blkoff) {
 			if (size) {
 				/* End of the current extent */
-				ret = fiemap_fill_next_extent(
-					(struct fiemap_extent_info *)f_ctx->fc_data,
-					logical, phys, size, flags);
+				ret = fiemap_fill_next_extent(f_ctx, logical,
+							     phys, size, flags);
 				if (ret)
 					break;
 			}
@@ -1078,9 +1077,8 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 				if (past_eof)
 					flags |= FIEMAP_EXTENT_LAST;
 
-				ret = fiemap_fill_next_extent(
-					(struct fiemap_extent_info *)f_ctx->fc_data,
-					logical, phys, size, flags);
+				ret = fiemap_fill_next_extent(f_ctx, logical,
+							     phys, size, flags);
 				if (ret)
 					break;
 				size = 0;
@@ -1094,9 +1092,9 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 					size += n << blkbits;
 				} else {
 					/* Terminate the current extent */
-					ret = fiemap_fill_next_extent(
-						(struct fiemap_extent_info *)f_ctx->fc_data,
-						logical, phys, size, flags);
+					ret = fiemap_fill_next_extent(f_ctx,
+							logical, phys, size,
+							flags);
 					if (ret || blkoff > end_blkoff)
 						break;
 
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
index cffba6e542f9..53847d2bf9d2 100644
--- a/fs/ocfs2/extent_map.c
+++ b/fs/ocfs2/extent_map.c
@@ -737,9 +737,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh,
 			phys += offsetof(struct ocfs2_dinode,
 					 id2.i_data.id_data);
 
-		ret = fiemap_fill_next_extent(
-				(struct fiemap_extent_info *)f_ctx->fc_data,
-				0, phys, id_count, flags);
+		ret = fiemap_fill_next_extent(f_ctx, 0, phys, id_count, flags);
 		if (ret < 0)
 			return ret;
 	}
@@ -812,9 +810,8 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
 		phys_bytes = le64_to_cpu(rec.e_blkno) << osb->sb->s_blocksize_bits;
 		virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits;
 
-		ret = fiemap_fill_next_extent(
-				(struct fiemap_extent_info*)f_ctx->fc_data,
-				virt_bytes, phys_bytes, len_bytes, fe_flags);
+		ret = fiemap_fill_next_extent(f_ctx, virt_bytes, phys_bytes,
+					      len_bytes, fe_flags);
 		if (ret)
 			break;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index fb060123acff..945cfb3e06e4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1709,7 +1709,7 @@ struct fiemap_ctx {
 	u64 fc_len;
 };
 
-int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
+int fiemap_fill_next_extent(struct fiemap_ctx *f_ctx, u64 logical,
 			    u64 phys, u64 len, u32 flags);
 int fiemap_check_flags(struct fiemap_ctx *f_ctx, u32 fs_flags);
 
-- 
2.17.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux