Re: question on ext2fs_get_free_blocks() in e2fsprogs

Andreas Dilger <[email protected]> Thu, 24 Aug 2006 14:48:07 -0600
Newsgroups gmane.comp.file-systems.ext2.devel
Message-ID <[email protected]>
On Aug 24, 2006  15:33 -0500, Eric Sandeen wrote:
> But what seems odd to me is:
> 
>      do {
>          if (start + num - 1 > fs->super->s_blocks_count)
>                  start = fs->super->s_first_data_block;
>          if (ext2fs_fast_test_block_bitmap_range(map, start, num)) {
>                  *ret = start;
>                  return 0;
>          }
>          start++;
>      } while (start != finish);
> 
> ("b" in the code replaced with "start" here for clarity, not sure why 
> "b" is in the code...)
> 
> 1) is it really kosher to just move start back to the beginning of the 
> filesystem, if the original request was for some other starting point?

The intent is to do a full-filesystem search, from "start" to "start-1"
as opposed to "0" to "s_blocks_count".  That is why it wraps.

> 2) the loop test seems odd; why (start != finish)? (Takashi had changed 
> this to (start <= finish)(  But it seems to me that

That is incorrect, since it will break if, say, start is near the end
of the filesystem very little will be checked.

I believe there was some discussion of this code when Takashi first
submitted it.  It might shed more light here.  Improved comments are
also welcome.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642