linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: sandeen@redhat.com, hch@lst.de, david@fromorbit.com,
	darrick.wong@oracle.com
Subject: [PATCH 14/20] fiemap: Use fiemap_ctx as fiemap_fill_next_extent argument
Date: Tue, 30 Oct 2018 14:18:17 +0100	[thread overview]
Message-ID: <20181030131823.29040-15-cmaiolino@redhat.com> (raw)
In-Reply-To: <20181030131823.29040-1-cmaiolino@redhat.com>

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@redhat.com>
---
 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

  parent reply	other threads:[~2018-10-30 22:12 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 13:18 [PATCH 00/20] New ->fiemap infrastructure and ->bmap removal Carlos Maiolino
2018-10-30 13:18 ` [PATCH 01/20] fs: Enable bmap() function to properly return errors Carlos Maiolino
2018-10-30 13:18 ` [PATCH 02/20] cachefiles: drop direct usage of ->bmap method Carlos Maiolino
2018-10-30 13:18 ` [PATCH 03/20] ecryptfs: drop direct calls to ->bmap Carlos Maiolino
2018-11-16 15:40   ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 04/20] iomap: Rename fiemap_ctx to fiemap_iomap_ctx Carlos Maiolino
2018-11-16 15:44   ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 05/20] fs: Introduce fiemap_ctx data structure Carlos Maiolino
2018-11-16 15:46   ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 06/20] iomap: Update iomap_fiemap to use new fiemap_ctx structure Carlos Maiolino
2018-11-16 15:48   ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 07/20] fiemap: Move fiemap flags to fiemap_ctx Carlos Maiolino
2018-11-05 22:12   ` Andreas Dilger
2018-11-06  8:37     ` Carlos Maiolino
2018-11-16 15:50       ` Christoph Hellwig
2018-11-16 15:51   ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 08/20] ext4: Remove direct usage of fiemap_extent_info Carlos Maiolino
2018-11-05 22:13   ` Andreas Dilger
2018-11-06  8:49     ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 09/20] f2fs: " Carlos Maiolino
2018-10-31  6:10   ` Chao Yu
2018-10-30 13:18 ` [PATCH 10/20] Btrfs: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 11/20] nilfs2: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 12/20] ocfs2: " Carlos Maiolino
2018-10-30 13:18 ` [PATCH 13/20] iomap: " Carlos Maiolino
2018-10-30 13:18 ` Carlos Maiolino [this message]
2018-11-16 15:54   ` [PATCH 14/20] fiemap: Use fiemap_ctx as fiemap_fill_next_extent argument Christoph Hellwig
2018-10-30 13:18 ` [PATCH 15/20] fiemap: Start using new callback from fiemap_ctx Carlos Maiolino
2018-11-05 22:14   ` Andreas Dilger
2018-11-06  8:52     ` Carlos Maiolino
2018-11-16 15:55       ` Christoph Hellwig
2018-11-19 12:26         ` Carlos Maiolino
2018-11-16 15:57   ` Christoph Hellwig
2018-11-19 12:37     ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 16/20] fibmap: Use bmap instead of ->bmap method in ioctl_fibmap Carlos Maiolino
2018-11-16 15:58   ` Christoph Hellwig
2018-11-19 12:41     ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 17/20] fiemap: Get rid of fiemap_extent_info Carlos Maiolino
2018-11-05 22:14   ` Andreas Dilger
2018-11-06  8:56     ` Carlos Maiolino
2018-11-16 16:04   ` Christoph Hellwig
2018-11-19 12:47     ` Carlos Maiolino
2018-10-30 13:18 ` [PATCH 18/20] Use FIEMAP for FIBMAP calls Carlos Maiolino
2018-11-05 22:15   ` Andreas Dilger
2018-11-06  9:11     ` Carlos Maiolino
2018-11-16 16:06   ` Christoph Hellwig
2018-11-19 12:50     ` Carlos Maiolino
2018-11-20  8:53       ` Christoph Hellwig
2018-10-30 13:18 ` [PATCH 19/20] xfs: Get rid of ->bmap Carlos Maiolino
2018-10-30 13:18 ` [PATCH 20/20] ext4: Get rid of ->bmap interface Carlos Maiolino
2018-11-16 16:07   ` Christoph Hellwig

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=20181030131823.29040-15-cmaiolino@redhat.com \
    --to=cmaiolino@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).