Re: [PATCH 4/5] libext2fs: Implement ext2fs_find_first_zero_generic_bmap().
From: Ted Ts'o <tytso@mit.edu>
Date: 2012-03-23 22:33:36
On Mon, Mar 12, 2012 at 09:15:14PM +0200, Sami Liedes wrote:
In the case of ext2fs_new_inode(), the function does not actually iterate through all zero bits; it really only wants to find the first zero in a certain range, after which it returns. So for simplicity of use (and efficiency) I think it still makes sense to have ->find_first_zero() too.
I agree, a find_first_zero() and a find_first_set(), both of which taking a starting bit position for the search, and the best low-level primitives that would be implemented on for each backend bitmap implementation. It would then be very easy to build iterators on *top* of find_first_zero() and find_first_set(), and in fact this could be used to replace some of the places where we are using a sorted list (i.e., the badblocks list). So that sounds like a good idea, and I can definitely think of some places where we could use that code today. So I plan to pull in your patch series and then we can further enhance this with iterator support afterwards. Sami, if you'd be interested in implementing iterators, that would be great! Thanks, - Ted