2008-07-16 12:12:04

by Goswin von Brederlow

[permalink] [raw]
Subject: Suggestions for a 64bit bitmap api

Hi,

which api would you prefer?

Option 1
========

typedef enum {TYPE1, TYPE2} bitmap_type;

struct ext2fs_abstract_bitmap {
bitmap_type type;
};

struct ext2fs_type1_bitmap {
bitmap_type type;
type1_data data;
};

struct ext2fs_type2_bitmap {
bitmap_type type;
type2_data data;
};

int ext2fs_fast_test_block_type1_bitmap(ext2fs_type1_bitmap *map, blk64_t i);
int ext2fs_fast_test_block_type2_bitmap(ext2fs_type2_bitmap *map, blk64_t i);
int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
switch(map->type) {
case TYPE1: return ext2fs_fast_test_block_type1_bitmap((ext2fs_type1_bitmap*)map, i);
case TYPE2: return ext2fs_fast_test_block_type2_bitmap((ext2fs_type2_bitmap*)map, i);
};
return 0;
}


Option 2
========

struct ext2fs_abstract_bitmap {
int (*fast_test_block)(void *map, blk64_t i);
void *map;
};

int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
return map->fast_test_block(map->map, i);
}


Option 3
========

struct ext2fs_bitmap_ops {
int (*fast_test_block)(ext2fs_abstract_bitmap *map, blk64_t i);
};

struct ext2fs_abstract_bitmap {
ext2fs_bitmap_ops *ops;
};

struct ext2fs_type1_bitmap {
ext2fs_bitmap_ops *ops;
type1_data data;
};

struct ext2fs_type2_bitmap {
ext2fs_bitmap_ops *ops;
type2_data data;
};

int ext2fs_fast_test_block_abstract_bitmap(ext2fs_abstract_bitmap *map, blk64_t i) {
return map->ops->fast_test_block(map, i);
}


Or something completly different?

MfG
Goswin


2008-07-16 13:41:25

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Suggestions for a 64bit bitmap api

On Wed, Jul 16, 2008 at 02:12:02PM +0200, Goswin von Brederlow wrote:
>
> which api would you prefer?

There is a lot of comments about my plan for 64-bit bitmaps in the pu
branch of e2fsprogs, in lib/ext2fs/gen_bitmap64.c.

Quoting from there:

/*
* Design of 64-bit bitmaps
*
* In order maintain ABI compatibility with programs that don't
* understand about 64-bit blocks/inodes,
* ext2fs_allocate_inode_bitmap() and ext2fs_allocate_block_bitmap()
* will create old-style bitmaps unless the application passes the
* flag EXT2_FLAG_NEW_BITMAPS to ext2fs_open(). If this flag is
* passed, then we know the application has been recompiled, so we can
* use the new-style bitmaps. If it is not passed, we have to return
* an error if trying to open a filesystem which needs 64-bit bitmaps.
*
* The new bitmaps use a new set of structure magic numbers, so that
* both the old-style and new-style interfaces can identify which
* version of the data structure was used. Both the old-style and
* new-style interfaces will support either type of bitmap, although
* of course 64-bit operation will only be possible when both the
* new-style interface and the new-style bitmap are used.
*
* For example, the new bitmap interfaces will check the structure
* magic numbers and so will be able to detect old-stype bitmap. If
* they see an old-style bitmap, they will pass it to the gen_bitmap.c
* functions for handling. The same will be true for the old
* interfaces as well.
*
* The new-style interfaces will have several different back-end
* implementations, so we can support different encodings that are
* appropriate for different applications. In general the default
* should be whatever makes sense, and what the application/library
* will use. However, e2fsck may need specialized implementations for
* its own uses. For example, when doing parent directory pointer
* loop detections in pass 3, the bitmap will *always* be sparse, so
* e2fsck can request an encoding which is optimized for that.
*/

struct ext2fs_struct_generic_bitmap64 {
errcode_t magic;
ext2_filsys fs;
struct * bitmap_ops;
int flags;
__u64 start, end;
__u64 real_end;
char * description;
void * private;
errcode_t base_error_code;
};

struct ext2_bitmap_ops {
int type;
/* Generic bmap operators */
errcode_t (*new_bmap)(ext2_filsys fs, errcode_t magic,
int type, u64 start, __u64 end,
__u64 real_end,
const char * description,
ext2fs_generic_bitmap64 *bmap);
void (*free_bmap)(ext2fs_generic_bitmap64 bitmap);
void (*copy_bmap)(ext2fs_generic_bitmap64 src,
ext2fs_generic_bitmap64 *dest);
void (*resize_bmap)(ext2fs_generic_bitmap64 bitmap,
__u64 new_end,
__u64 new_real_end);
/* XXX still need file operators */
/* bit set/test operators */
void (*set_bmap)(ext2fs_generic_bitmap64 bitmap, __u64 arg);
void (*clear_bmap)(ext2fs_generic_bitmap64 bitmap, __u64 arg);
int (*test_bmap)(ext2fs_generic_bitmap64 bitmap, __u64 arg);
void (*set_bmap_range)(ext2fs_generic_bitmap64 bitmap, __u64 arg,
int num);
void (*clear_bmap_range)(ext2fs_generic_bitmap64 bitmap, __u64 arg,
int num);
};

extern errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
int type, u64 start, __u64 end,
__u64 real_end,
const char * description,
ext2fs_generic_bitmap64 *bmap);

extern void_t ext2fs_free_generic_bmap(ext2fs_generic_bitmap64 bmap);

extern errcode_t ext2fs_copy_generic_bmap(ext2fs_generic_bitmap64 src,
ext2fs_generic_bitmap64 *dest);

extern errcode_t ext2fs_resize_generic_bmap(ext2fs_generic_bitmap bmap,
__u64 new_end,
__u64 new_real_end);

extern void ext2fs_set_generic_bmap(ext2fs_generic_bitmap64 bitmap,
__u64 arg);
extern void ext2fs_clear_generic_bmap(ext2fs_generic_bitmap64 bitmap,
__u64 arg);
extern int ext2fs_test_generic_bmap(ext2fs_generic_bitmap64 bitmap,
__u64 arg);
extern void ext2fs_set_generic_bmap_range(ext2fs_generic_bitmap64 bitmap,
__u64 arg, int num);
extern void ext2fs_clear_generic_bmap_range(ext2fs_generic_bitmap64 bitmap,
__u64 arg, int num);


2008-07-16 14:05:28

by Goswin von Brederlow

[permalink] [raw]
Subject: Re: Suggestions for a 64bit bitmap api

Theodore Tso <[email protected]> writes:

> On Wed, Jul 16, 2008 at 02:12:02PM +0200, Goswin von Brederlow wrote:
>>
>> which api would you prefer?
>
> There is a lot of comments about my plan for 64-bit bitmaps in the pu
> branch of e2fsprogs, in lib/ext2fs/gen_bitmap64.c.

How/Where can I check out thepu branch?

MfG
Goswin

2008-07-16 14:51:48

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Suggestions for a 64bit bitmap api

On Wed, Jul 16, 2008 at 04:05:25PM +0200, Goswin von Brederlow wrote:
> Theodore Tso <[email protected]> writes:
>
> > On Wed, Jul 16, 2008 at 02:12:02PM +0200, Goswin von Brederlow wrote:
> >>
> >> which api would you prefer?
> >
> > There is a lot of comments about my plan for 64-bit bitmaps in the pu
> > branch of e2fsprogs, in lib/ext2fs/gen_bitmap64.c.
>
> How/Where can I check out thepu branch?

How much do you know about git?

Short version:

git checkout git://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git e2fsprogs
cd e2fsprogs
git branch pu origin/pu
git checkout pu

To update to a newer pu once you have done the above steps

cd /path/to/checked-out-e2fsprogs-repository
git fetch
git checkout pu
git reset --hard origin/pu

(Note that the "git reset --hard" will blow away any local commits you
might have made; this isn't a substitute for a full-blown git
tutorial. The reason for the git reset is because the pu branch is
constantly getting rebased.)

A good place to start for explaining the concepts of git (and why git
is so great) is here:

http://utsl.gen.nz/talks/git-svn/intro.html

The bits about "git svn" won't apply for e2fsprogs, but the concepts
of git are really well explained in the above web page. For the
"crash course", this is pretty good:

http://git.or.cz/course/svn.html

Other good starting points for git are:

http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
http://www.kernel.org/pub/software/scm/git/docs/everyday.html

- Ted


2008-07-16 16:33:35

by Goswin von Brederlow

[permalink] [raw]
Subject: Re: Suggestions for a 64bit bitmap api

Theodore Tso <[email protected]> writes:

> On Wed, Jul 16, 2008 at 04:05:25PM +0200, Goswin von Brederlow wrote:
>> Theodore Tso <[email protected]> writes:
>>
>> > On Wed, Jul 16, 2008 at 02:12:02PM +0200, Goswin von Brederlow wrote:
>> >>
>> >> which api would you prefer?
>> >
>> > There is a lot of comments about my plan for 64-bit bitmaps in the pu
>> > branch of e2fsprogs, in lib/ext2fs/gen_bitmap64.c.
>>
>> How/Where can I check out thepu branch?
>
> How much do you know about git?

Enough to clone a git but not enough to select a branch. Thx.

MfG
Goswin