From: Chris Mason Subject: Re: [PATCH 5/5] generic block based fiemap implementation Date: Tue, 27 May 2008 13:51:44 -0400 Message-ID: <200805271351.45052.chris.mason@oracle.com> References: <20080525000235.GO8325@wotan.suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org, Josef Bacik To: Mark Fasheh Return-path: Received: from agminet01.oracle.com ([141.146.126.228]:17402 "EHLO agminet01.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755515AbYE0Rwh (ORCPT ); Tue, 27 May 2008 13:52:37 -0400 In-Reply-To: <20080525000235.GO8325@wotan.suse.de> Content-Disposition: inline Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Saturday 24 May 2008, Mark Fasheh wrote: > From: Josef Bacik > > Here is my updated generic block based fiemap implementation with the fixes > that Andreas suggested. Basically any block based fs (this patch includes > ext3) just has to declare its own fiemap() function and then call this > generic function with its own get_block_t. > > +int generic_block_fiemap(struct inode *inode, > + struct fiemap_extent_info *fieinfo, u64 start, > + u64 len, get_block_t *get_block) > +{ > + struct buffer_head tmp; [ ... ] > + do { > + /* > + * we set b_size to the total size we want so it will map as > + * many contiguous blocks as possible at once > + */ > + memset(&tmp, 0, sizeof(struct buffer_head)); > + tmp.b_size = map_len; > + > + ret = get_block(inode, start_blk, &tmp, 0); > + if (ret) > + break; > + > + /* HOLE */ > + if (!tmp.b_blocknr) { This should be if (!buffer_mapped(&tmp)). You can't be sure that filesystems returning a hole will use a b_blocknr of zero, and you can't be sure that a block number of zero is a hole. -chris -chris