From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:50871 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728169AbeKQCTl (ORCPT ); Fri, 16 Nov 2018 21:19:41 -0500 Date: Fri, 16 Nov 2018 17:06:43 +0100 From: Christoph Hellwig To: Carlos Maiolino Cc: linux-fsdevel@vger.kernel.org, sandeen@redhat.com, hch@lst.de, david@fromorbit.com, darrick.wong@oracle.com Subject: Re: [PATCH 18/20] Use FIEMAP for FIBMAP calls Message-ID: <20181116160643.GB17130@lst.de> References: <20181030131823.29040-1-cmaiolino@redhat.com> <20181030131823.29040-19-cmaiolino@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181030131823.29040-19-cmaiolino@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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.