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