From mboxrd@z Thu Jan 1 00:00:00 1970 From: jim owens Subject: Re: [RFC][PATCH 0/5] Fiemap, an extent mapping ioctl Date: Thu, 29 May 2008 11:33:09 -0400 Message-ID: <483ECCB5.5060909@hp.com> References: <20080525000148.GJ8325@wotan.suse.de> <20080525194203.GB24328@infradead.org> <20080527185622.GR8325@wotan.suse.de> <20080527203124.GC27827@mail.oracle.com> <20080528160201.GA7263@webber.adilger.int> <20080528170419.GA6031@mail.oracle.com> <20080529005134.GB12405@disturbed> <20080529130254.GB21299@infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: Mark Fasheh , linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from g4t0014.houston.hp.com ([15.201.24.17]:15883 "EHLO g4t0014.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754799AbYE2PdZ (ORCPT ); Thu, 29 May 2008 11:33:25 -0400 In-Reply-To: <20080529130254.GB21299@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Christoph Hellwig wrote: > > What use is there geeting the extent count for a range? I'd rather > do it only per-file like the xfs ioctl. I'll answer that from practical experience. Our api equivalents: __u64 fm_start; /* logical offset (inclusive) at * which to start mapping (in) */ __u64 fm_length; /* logical length of mapping which * userspace cares about (in) */ __u32 fm_extent_count; /* size of fm_extents array (in) */ __u32 fm_mapped_extents; /* number of extents that were * mapped (out) */ ... note it has no flags field and no separate ioctl_extent_count. "fm_extent_count" is IN == max_extents to return. OUT == number of extents remaining in-range after fm_mapped_extents Pass in fm_extent_count==0 and you get OUT number of extent entries within your fm_start + fm_length range. Which you can use to set your malloc size because the FS can have massive extent counts :( This is why it was done. In practice this was only used by kernel callers because most application developers simply looped with a fixed buffer and adjusted fm_start. Dumber applications kept doubling their malloc to get all extents at once... or core dump :) I'm not saying there is a good reason to do it this way in linux, just why someone else did it that way. jim