Re: [PATCH 07/20] fiemap: Move fiemap flags to fiemap_ctx

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

 



Hi Andreas,

thanks for the review.

On Mon, Nov 05, 2018 at 03:12:07PM -0700, Andreas Dilger wrote:
> On Oct 30, 2018, at 7:18 AM, Carlos Maiolino <cmaiolino@xxxxxxxxxx> wrote:
> > 
> > struct fiemap_extent_info, will be gone in a later patch, but we still need the flags.
> > So, move the fiemap flags up to the new context structure fiemap_ctx.
> 
> Doesn't this mostly boil down to renaming fiemap_extent_info to fiemap_ctx, if you
> are moving all of the fields from one to the other?

Not really, fiemap_extent_info is removed at the end of the series, and by doing
it directly, I'd need to write a big patch changing all users of
fiemap_extent_info in a single patch, or break the kernel build between patches.
I usually try to avoid a single patch touching several different filesystems, so
that's why I basically slowly replaced fiemap_extent_info, until it get removed
at the end of the series.
> 
> > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> > index ebe5aae69c44..77fd8587b8e7 100644
> > --- a/fs/btrfs/inode.c
> > +++ b/fs/btrfs/inode.c
> > @@ -8619,7 +8619,7 @@ static int btrfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 	u64 len	  = f_ctx->fc_len;
> > 	int	ret;
> > 
> > -	ret = fiemap_check_flags(fieinfo, BTRFS_FIEMAP_FLAGS);
> > +	ret = fiemap_check_flags(f_ctx, BTRFS_FIEMAP_FLAGS);
> 
> The other minor nit about this patch series is that "f_ctx" is not a very
> descriptive variable name.  How about "fiemap_ctx"?  A bit longer, but it
> is immediately clear to the reader what it is.

I don't really mind, f_ctx, fmap_ctx, etc. having the pointer the same name as
the struct doesn't look good to me, but particularly I don't mind.

> 
> Cheers, Andreas
> 
> > diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> > index beccae768dac..d52aafc34e25 100644
> > --- a/fs/ext4/extents.c
> > +++ b/fs/ext4/extents.c
> > @@ -5063,7 +5063,7 @@ int ext4_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 			return error;
> > 	}
> > 
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_CACHE) {
> > 		error = ext4_ext_precache(inode);
> > 		if (error)
> > 			return error;
> > @@ -5073,10 +5073,10 @@ int ext4_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
> > 		return generic_block_fiemap(inode, f_ctx, ext4_get_block);
> > 
> > -	if (fiemap_check_flags(fieinfo, EXT4_FIEMAP_FLAGS))
> > +	if (fiemap_check_flags(f_ctx, EXT4_FIEMAP_FLAGS))
> > 		return -EBADR;
> > 
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
> > 		error = ext4_xattr_fiemap(inode, fieinfo);
> > 	} else {
> > 		ext4_lblk_t len_blks;
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 0f57403feb92..c552e2d1dfbb 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -1409,19 +1409,19 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 	u32 flags = 0;
> > 	int ret = 0;
> > 
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) {
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_CACHE) {
> > 		ret = f2fs_precache_extents(inode);
> > 		if (ret)
> > 			return ret;
> > 	}
> > 
> > -	ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR);
> > +	ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC | FIEMAP_FLAG_XATTR);
> > 	if (ret)
> > 		return ret;
> > 
> > 	inode_lock(inode);
> > 
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
> > 		ret = f2fs_xattr_fiemap(inode, fieinfo);
> > 		goto out;
> > 	}
> > diff --git a/fs/ioctl.c b/fs/ioctl.c
> > index ddcc4f9a9cf1..77af3b116972 100644
> > --- a/fs/ioctl.c
> > +++ b/fs/ioctl.c
> > @@ -139,13 +139,13 @@ EXPORT_SYMBOL(fiemap_fill_next_extent);
> >  *
> >  * Returns 0 on success, -EBADR on bad flags.
> >  */
> > -int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags)
> > +int fiemap_check_flags(struct fiemap_ctx *f_ctx, u32 fs_flags)
> > {
> > 	u32 incompat_flags;
> > 
> > -	incompat_flags = fieinfo->fi_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
> > +	incompat_flags = f_ctx->fc_flags & ~(FIEMAP_FLAGS_COMPAT & fs_flags);
> > 	if (incompat_flags) {
> > -		fieinfo->fi_flags = incompat_flags;
> > +		f_ctx->fc_flags = incompat_flags;
> > 		return -EBADR;
> > 	}
> > 	return 0;
> > @@ -199,25 +199,24 @@ static int ioctl_fiemap(struct file *filp, unsigned long arg)
> > 	if (error)
> > 		return error;
> > 
> > -	fieinfo.fi_flags = fiemap.fm_flags;
> > 	fieinfo.fi_extents_max = fiemap.fm_extent_count;
> > 	fieinfo.fi_extents_start = ufiemap->fm_extents;
> > 
> > +	f_ctx.fc_flags = fiemap.fm_flags;
> > +	f_ctx.fc_data = &fieinfo;
> > +	f_ctx.fc_start = fiemap.fm_start;
> > +	f_ctx.fc_len = len;
> > +
> > 	if (fiemap.fm_extent_count != 0 &&
> > 	    !access_ok(VERIFY_WRITE, fieinfo.fi_extents_start,
> > 		       fieinfo.fi_extents_max * sizeof(struct fiemap_extent)))
> > 		return -EFAULT;
> > 
> > -	if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC)
> > +	if (f_ctx.fc_flags & FIEMAP_FLAG_SYNC)
> > 		filemap_write_and_wait(inode->i_mapping);
> > 
> > -	f_ctx.fc_flags = fieinfo.fi_flags;
> > -	f_ctx.fc_data = &fieinfo;
> > -	f_ctx.fc_start = fiemap.fm_start;
> > -	f_ctx.fc_len = len;
> > -
> > 	error = inode->i_op->fiemap(inode, &f_ctx);
> > -	fiemap.fm_flags = fieinfo.fi_flags;
> > +	fiemap.fm_flags = f_ctx.fc_flags;
> > 	fiemap.fm_mapped_extents = fieinfo.fi_extents_mapped;
> > 	if (copy_to_user(ufiemap, &fiemap, sizeof(fiemap)))
> > 		error = -EFAULT;
> > @@ -298,7 +297,7 @@ int __generic_block_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
> > 	bool past_eof = false, whole_file = false;
> > 	int ret = 0;
> > 
> > -	ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
> > +	ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
> > 	if (ret)
> > 		return ret;
> > 
> > diff --git a/fs/iomap.c b/fs/iomap.c
> > index 42b131e1c955..5afca566c2a9 100644
> > --- a/fs/iomap.c
> > +++ b/fs/iomap.c
> > @@ -1166,11 +1166,11 @@ int iomap_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx,
> > 	ctx.fi = fi;
> > 	ctx.prev.type = IOMAP_HOLE;
> > 
> > -	ret = fiemap_check_flags(fi, FIEMAP_FLAG_SYNC);
> > +	ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
> > 	if (ret)
> > 		return ret;
> > 
> > -	if (fi->fi_flags & FIEMAP_FLAG_SYNC) {
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_SYNC) {
> > 		ret = filemap_write_and_wait(inode->i_mapping);
> > 		if (ret)
> > 			return ret;
> > diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
> > index 529262f0ab7d..a8040ed52bd5 100644
> > --- a/fs/nilfs2/inode.c
> > +++ b/fs/nilfs2/inode.c
> > @@ -1007,7 +1007,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 	unsigned int blkbits = inode->i_blkbits;
> > 	int ret, n;
> > 
> > -	ret = fiemap_check_flags(fieinfo, FIEMAP_FLAG_SYNC);
> > +	ret = fiemap_check_flags(f_ctx, FIEMAP_FLAG_SYNC);
> > 	if (ret)
> > 		return ret;
> > 
> > diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c
> > index 1944f5659267..5ba98d7a7a42 100644
> > --- a/fs/ocfs2/extent_map.c
> > +++ b/fs/ocfs2/extent_map.c
> > @@ -762,7 +762,7 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 	struct buffer_head *di_bh = NULL;
> > 	struct ocfs2_extent_rec rec;
> > 
> > -	ret = fiemap_check_flags(fieinfo, OCFS2_FIEMAP_FLAGS);
> > +	ret = fiemap_check_flags(f_ctx, OCFS2_FIEMAP_FLAGS);
> > 	if (ret)
> > 		return ret;
> > 
> > diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> > index e56606c1ba92..3cef3b9b1854 100644
> > --- a/fs/overlayfs/inode.c
> > +++ b/fs/overlayfs/inode.c
> > @@ -458,7 +458,6 @@ int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
> > 
> > static int ovl_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > {
> > -	struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
> > 	int err;
> > 	struct inode *realinode = ovl_inode_real(inode);
> > 	const struct cred *old_cred;
> > @@ -468,7 +467,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_ctx *f_ctx)
> > 
> > 	old_cred = ovl_override_creds(inode->i_sb);
> > 
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC)
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_SYNC)
> > 		filemap_write_and_wait(realinode->i_mapping);
> > 
> > 	err = realinode->i_op->fiemap(realinode, f_ctx);
> > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> > index 22c479862ba6..d859558de2fe 100644
> > --- a/fs/xfs/xfs_iops.c
> > +++ b/fs/xfs/xfs_iops.c
> > @@ -1095,14 +1095,13 @@ xfs_vn_fiemap(
> > 	struct inode		*inode,
> > 	struct fiemap_ctx	*f_ctx)
> > {
> > -	struct fiemap_extent_info *fieinfo = f_ctx->fc_data;
> > 	u64 start  = f_ctx->fc_start;
> > 	u64 length = f_ctx->fc_len;
> > 	int error;
> > 
> > 	xfs_ilock(XFS_I(inode), XFS_IOLOCK_SHARED);
> > -	if (fieinfo->fi_flags & FIEMAP_FLAG_XATTR) {
> > -		fieinfo->fi_flags &= ~FIEMAP_FLAG_XATTR;
> > +	if (f_ctx->fc_flags & FIEMAP_FLAG_XATTR) {
> > +		f_ctx->fc_flags &= ~FIEMAP_FLAG_XATTR;
> > 		error = iomap_fiemap(inode, f_ctx, start, length,
> > 				&xfs_xattr_iomap_ops);
> > 	} else {
> > diff --git a/include/linux/fs.h b/include/linux/fs.h
> > index bd8e8a7dfd59..fb060123acff 100644
> > --- a/include/linux/fs.h
> > +++ b/include/linux/fs.h
> > @@ -1692,7 +1692,6 @@ extern bool may_open_dev(const struct path *path);
> > struct fiemap_ctx;
> > 
> > struct fiemap_extent_info {
> > -	unsigned int fi_flags;		/* Flags as passed from user */
> > 	unsigned int fi_extents_mapped;	/* Number of mapped extents */
> > 	unsigned int fi_extents_max;	/* Size of fiemap_extent array */
> > 	struct fiemap_extent __user *fi_extents_start; /* Start of
> > @@ -1703,7 +1702,7 @@ typedef int (*fiemap_fill_cb)(struct fiemap_ctx *f_ctx, u64 logical,
> > 			      u64 phys, u64 len, u32 flags);
> > 
> > struct fiemap_ctx {
> > -	unsigned int fc_flags;
> > +	unsigned int fc_flags;	/* Flags as passed from user */
> > 	void *fc_data;
> > 	fiemap_fill_cb fc_cb; /* Unused by now */
> > 	u64 fc_start;
> > @@ -1712,7 +1711,7 @@ struct fiemap_ctx {
> > 
> > int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical,
> > 			    u64 phys, u64 len, u32 flags);
> > -int fiemap_check_flags(struct fiemap_extent_info *fieinfo, u32 fs_flags);
> > +int fiemap_check_flags(struct fiemap_ctx *f_ctx, u32 fs_flags);
> > 
> > /*
> >  * File types
> > --
> > 2.17.1
> > 
> 
> 
> Cheers, Andreas
> 
> 
> 
> 
> 



-- 
Carlos



[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