Re: [PATCH 18/20] Use FIEMAP for FIBMAP calls

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

 



On Fri, Nov 16, 2018 at 05:06:43PM +0100, Christoph Hellwig wrote:
> On Tue, Oct 30, 2018 at 02:18:21PM +0100, Carlos Maiolino wrote:
> > +	if (inode->i_op->fiemap) {
> > +		fextent.fe_logical = 0;
> > +		fextent.fe_physical = 0;
> > +		f_ctx.fc_extents_max = 1;
> > +		f_ctx.fc_extents_mapped = 0;
> > +		f_ctx.fc_data = &fextent;
> > +		f_ctx.fc_start = start;
> > +		f_ctx.fc_len = 1;
> > +		f_ctx.fc_flags = 0;
> > +		f_ctx.fc_cb = fiemap_fill_kernel_extent;
> > +
> > +		error = inode->i_op->fiemap(inode, &f_ctx);
> > +
> > +		if (error)
> > +			goto out;
> > +
> > +		*block = (fextent.fe_physical +
> > +			(start - fextent.fe_logical)) >> inode->i_blkbits;
> > +
> 
> I think this code needs to be split into a helper.
> 

Yup, my idea is to try to reduce as much as possible the shared code between
usr/kernel helpers, I just didn't want to spend more time thinking about it
without having a review of the overall design :P

> Also we need to check for various "dangerous" flags and fail the
> call, e.g. FIEMAP_EXTENT_ENCODED, FIEMAP_EXTENT_DELALLOC,
> FIEMAP_EXTENT_DATA_ENCRYPTED, FIEMAP_EXTENT_DATA_INLINE,
> FIEMAP_EXTENT_DATA_TAIL, FIEMAP_EXTENT_UNWRITTEN,
> FIEMAP_EXTENT_SHARED.
> 
> > +	} else if (inode->i_mapping->a_ops->bmap) {
> > +		*block = inode->i_mapping->a_ops->bmap(inode->i_mapping, *block);
> 
> Too long line.
> 
> > +		error = 0;
> > +	}
> > +out:
> > +	return error;
> 
> No need for a goto label just to return an error.
> 
> > +		return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
> 
> Plain old if statement, please.
> 
> > +	return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0;
> 
> Same here.  But in this case we could actually use a goto to share
> the code.

Ok, fair enough.

Thanks a lot for the whole review.

Cheers

-- 
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