Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754008Ab0FNNiD (ORCPT ); Mon, 14 Jun 2010 09:38:03 -0400 Received: from rcsinet10.oracle.com ([148.87.113.121]:31281 "EHLO rcsinet10.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753888Ab0FNNiA (ORCPT ); Mon, 14 Jun 2010 09:38:00 -0400 Message-ID: <4C16308E.1030305@oracle.com> Date: Mon, 14 Jun 2010 21:37:18 +0800 From: Tao Ma Organization: Oracle Corporation User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Dave Chinner CC: xfs@oss.sgi.com, linux-kernel@vger.kernel.org, sandeen@sandeen.net, Alex Elder , Christoph Hellwig Subject: Re: [PATCH v2] xfs: Make fiemap works with sparse file. References: <1276308495-14267-1-git-send-email-tao.ma@oracle.com> <20100614002705.GA6590@dastard> <20100614122912.GD6590@dastard> In-Reply-To: <20100614122912.GD6590@dastard> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Auth-Type: Internal IP X-Source-IP: acsinet15.oracle.com [141.146.126.227] X-CT-RefId: str=0001.0A090202.4C1630A7.00B5:SCFMA922111,ss=1,fgs=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1924 Lines: 46 Hi Dave, Dave Chinner wrote: > On Mon, Jun 14, 2010 at 10:27:06AM +1000, Dave Chinner wrote: > >> On Sat, Jun 12, 2010 at 10:08:15AM +0800, Tao Ma wrote: >> >>> The reason is that in xfs_getbmap we will >>> calculate holes and set it in 'out', while out is malloced by >>> bmv_count(fi_extent_max+1) which didn't consider holes. So in the >>> worst case, if 'out' vector looks like >>> [hole, extent, hole, extent, hole, ... hole, extent, hole], >>> we will only return half of fi_extent_max extents. >>> >> Right, it's not broken, we simply return less than fi_extent_mex >> extents when there are holes. I don't see that as a problem as >> applications have to handle that case anyway, and.... >> >> >>> So in xfs_vn_fiemap, we should consider this worst case. If the >>> user wants fi_extent_max extents, we need a 'out' with size of >>> 2 *fi_extent_max + 2(one more the header). >>> >> That's rather dangerous, I think. It relies on other code to catch >> the buffer overrun that this sets up for fragmented, non-sparse >> files. Personally I'd much prefer to return fewer extents for sparse >> files than to add a landmine like this into the kernel code.... >> > > I just had a thought - if you want to avoid holes being reported to > fiemap, then add a BMV_IF_NO_HOLES flag to xfs_getbmap() and skip > holes in the mappin gloop when this flag is set. That will make > fiemap fill in the full number of extents without hacking the > extent count... > yeah, that should work and I will try to generate a patch for it. I am not quite familiar with xfs, so please be kind to me if I make some stupid mistake in the patch. ;) Regards, Tao -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/