diff mbox series

[16/20] fibmap: Use bmap instead of ->bmap method in ioctl_fibmap

Message ID 20181030131823.29040-17-cmaiolino@redhat.com (mailing list archive)
State New, archived
Headers show
Series New ->fiemap infrastructure and ->bmap removal | expand

Commit Message

Carlos Maiolino Oct. 30, 2018, 1:18 p.m. UTC
Now we have the possibility of proper error return in bmap, use bmap()
function in ioctl_fibmap() instead of calling ->bmap method directly.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---
 fs/ioctl.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

Comments

Christoph Hellwig Nov. 16, 2018, 3:58 p.m. UTC | #1
> +	error = bmap(inode, (sector_t *)&block);

You can't cast and int * to a sector_t * without causing problems.
You'll need a local variable of type sector_t that the value
gets assigned to and read back from instead.

Also shouldn't this patch be earlier in the series?
Carlos Maiolino Nov. 19, 2018, 12:41 p.m. UTC | #2
On Fri, Nov 16, 2018 at 04:58:53PM +0100, Christoph Hellwig wrote:
> > +	error = bmap(inode, (sector_t *)&block);
> 
> You can't cast and int * to a sector_t * without causing problems.
> You'll need a local variable of type sector_t that the value
> gets assigned to and read back from instead.

Ok, thanks for the information, I'll update it, but, could you detail a bit more
what kind of problem you are referring to? I'm curious to understand why and
which kind of problems it can cause.

> Also shouldn't this patch be earlier in the series?

I opted to move this patch to the end of the series, when most of the fiemap
rework is done, I can move it to the beginning of the series if it's better.
diff mbox series

Patch

diff --git a/fs/ioctl.c b/fs/ioctl.c
index 85a7aec40e3d..cbc1b21c4f7c 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -53,19 +53,23 @@  EXPORT_SYMBOL(vfs_ioctl);
 
 static int ioctl_fibmap(struct file *filp, int __user *p)
 {
-	struct address_space *mapping = filp->f_mapping;
-	int res, block;
+	struct inode *inode = file_inode(filp);
+	int error, block;
 
-	/* do we support this mess? */
-	if (!mapping->a_ops->bmap)
-		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	res = get_user(block, p);
-	if (res)
-		return res;
-	res = mapping->a_ops->bmap(mapping, block);
-	return put_user(res, p);
+
+	error = get_user(block, p);
+	if (error)
+		return error;
+
+	error = bmap(inode, (sector_t *)&block);
+	if (error)
+		return error;
+
+	error = put_user(block, p);
+
+	return error;
 }
 
 #define SET_UNKNOWN_FLAGS	(FIEMAP_EXTENT_DELALLOC)