64-bit bitmaps for e2fsprogs
RFC PATCH 1/1 64-bit bitmaps for e2fsprogs
Hi all,
I've been working on 64-bit bitmaps for e2fsprogs, which will allow us to create an ext4 file system with more than 2^32 blocks. Below is a snapshot of my development tree as-is (doesn't even compile); I'd appreciate comments on the direction, especially from Ted and Jose.
Some background: Ted's goal is to preserve the ABI for programs dynamically linked against libext2. This is implemented by preserving the existing 32-bit bitmap interfaces as-is and implementing a new set of 64-bit interfaces which detect whether the application has been recompiled since the new 64-bit support went in. If so, it uses the new functions, otherwise it passes the arguments back to the old functions.
The diff includes three patches: implementation of 64-bit bmap ops, warning squashing (so I can concentrate on my warnings), and a partial port to the new 64-bit interfaces. I can split them out if necessary. Diff is against commit 6db77ec039ff241dab0f1e267fabcfa814fbaf4c in the pu branch.
-VAL
debugfs/debugfs.c +1 -1
@@ -1850,7 +1850,7 @@ static int find_supp_feature(__u32 *supp, int feature_type, char *name)void do_supported_features (int argc,char *argv[]) { -int i, j, ret; +int ret;__u32 supp[3 ] = {EXT2_LIB_FEATURE_COMPAT_SUPP ,EXT2_LIB_FEATURE_INCOMPAT_SUPP ,EXT2_LIB_FEATURE_RO_COMPAT_SUPP };
debugfs/htree.c +2 -2
@@ -48,11 +48,11 @@ static void htree_dump_leaf_node(ext2_filsys fs, ext2_ino_t ino,return ; } -printf ("Reading directory block %lu, phys %lu\n" , blk, pblk); +printf ("Reading directory block %u, phys %u\n" , blk, pblk); errcode =ext2fs_read_dir_block2 (current_fs, pblk, buf,0 );if (errcode) {com_err ("htree_dump_leaf_node" , errcode, -"while reading block %lu (%lu)\n" , blk, pblk); +"while reading block %u (%u)\n" , blk, pblk);return ; } hash_alg = rootnode->hash_version;
lib/blkid/probe.c +3 -2
@@ -1099,7 +1099,8 @@ static int probe_hfs(struct blkid_probe *probe __BLKID_ATTR((unused)),sprintf (uuid_str,"%016llX" , uuid);blkid_set_tag (probe->dev,"UUID" , uuid_str,0 ); } -blkid_set_tag (probe->dev,"LABEL" , hfs->label, hfs->label_len); +blkid_set_tag (probe->dev,"LABEL" , (char *) hfs->label, + hfs->label_len);return 0 ; }
@@ -1220,7 +1221,7 @@ static int probe_hfsplus(struct blkid_probe *probe,return 0 ; label_len =blkid_be16 (key->unicode_len) *2 ; -unicode_16be_to_utf8 (label,sizeof (label), key->unicode, label_len); +unicode_16be_to_utf8 ((unsigned char *) label,sizeof (label), key->unicode, label_len);blkid_set_tag (probe->dev,"LABEL" , label,0 );return 0 ; }
lib/e2p/e2p.h +2 -0
@@ -38,6 +38,8 @@ int setversion (int fd, unsigned long version);const char *e2p_feature2string (int compat,unsigned int mask);int e2p_string2feature (char *string,int *compat,unsigned int *mask); +const char *e2p_jrnl_feature2string (int compat,unsigned int mask); +int e2p_jrnl_string2feature (char *string,int *compat_type,unsigned int *mask);int e2p_edit_feature (const char *str,__u32 *compat_array,__u32 *ok_array); int e2p_edit_feature2(const char *str, __u32 *compat_array, __u32 *ok_array, __u32 *clear_ok_array, int *type_err,
lib/ext2fs/alloc.c +3 -3
@@ -29,8 +29,8 @@/* * Check for uninit block bitmaps and deal with them appropriately */ -static check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map, - dgrp_t group) +static void check_block_uninit (ext2_filsys fs,ext2fs_block_bitmap map, +dgrp_t group) {int i;blk_t blk, super_blk, old_desc_blk, new_desc_blk;
@@ -75,7 +75,7 @@ static check_block_uninit(ext2_filsys fs, ext2fs_block_bitmap map,/* * Check for uninit inode bitmaps and deal with them appropriately */ -static check_inode_uninit(ext2_filsys fs, ext2fs_inode_bitmap map, +static void check_inode_uninit (ext2_filsys fs,ext2fs_inode_bitmap map,dgrp_t group) {int i;
lib/ext2fs/bitmaps.c +68 -39
210 lines not on this page · raw message
lib/ext2fs/bitops.c +40 -0
@@ -76,3 +76,43 @@ void ext2fs_warn_bitmap(errcode_t errcode, unsigned long arg,com_err (0 , errcode,"#%lu" , arg);#endif } + +/* +* C-only 64 bit ops. These are compiled and partially tested for +* 32-bit binaries, but will not work for bit numbers > 32 bits. +*/ + +int ext2fs_set_bit64 (__u64 nr,void * addr) +{ +int mask, retval; +unsigned char *ADDR = (unsigned char *) addr; + +ADDR += nr >>3 ; + mask =1 << (nr &0x07 ); + retval = mask & *ADDR ; + *ADDR |= mask; +return retval; +} + +int ext2fs_clear_bit64 (__u64 nr,void * addr) +{ +int mask, retval; +unsigned char *ADDR = (unsigned char *) addr; + +ADDR += nr >>3 ; + mask =1 << (nr &0x07 ); + retval = mask & *ADDR ; + *ADDR &= ~mask; +return retval; +} + +int ext2fs_test_bit64 (__u64 nr,const void * addr) +{ +int mask; +const unsigned char *ADDR = (const unsigned char *) addr; + +ADDR += nr >>3 ; + mask =1 << (nr &0x07 ); +return (mask & *ADDR ); +} +
lib/ext2fs/bitops.h +89 -64
278 lines not on this page · raw message
lib/ext2fs/blkmap64_ba.c +156 -7
210 lines not on this page · raw message
lib/ext2fs/ext2fs.h +32 -10
73 lines not on this page · raw message
lib/ext2fs/ext2fsP.h +6 -8
@@ -113,15 +113,13 @@ struct ext2fs_struct_generic_bitmap64 {#define EXT2FS_BMAP64_BITARRAY 1 -typedef struct ext2fs_struct_generic_bitmap64 *ext2fs_generic_bitmap64 ; -struct ext2_bitmap_ops {int type;/* Generic bmap operators */ -errcode_t (*new_bmap)(ext2_filsys fs,ext2fs_generic_bitmap64 *bmap); +errcode_t (*new_bmap)(ext2_filsys fs,ext2fs_generic_bitmap64 bmap);void (*free_bmap)(ext2fs_generic_bitmap64 bitmap);errcode_t (*copy_bmap)(ext2fs_generic_bitmap64 src, -ext2fs_generic_bitmap64 *dest); +ext2fs_generic_bitmap64 dest);errcode_t (*resize_bmap)(ext2fs_generic_bitmap64 bitmap,__u64 new_end,__u64 new_real_end);
@@ -130,13 +128,13 @@ struct ext2_bitmap_ops {int (*unmark_bmap)(ext2fs_generic_bitmap64 bitmap,__u64 arg);int (*test_bmap)(ext2fs_generic_bitmap64 bitmap,__u64 arg);void (*mark_bmap_extent)(ext2fs_generic_bitmap64 bitmap,__u64 arg, -int num); +size_t num);void (*unmark_bmap_extent)(ext2fs_generic_bitmap64 bitmap,__u64 arg, -int num); +size_t num);errcode_t (*set_bmap_range)(ext2fs_generic_bitmap64 bitmap, -__u64 start,unsigned int num,void *in); +__u64 start,size_t num,void *in);errcode_t (*get_bmap_range)(ext2fs_generic_bitmap64 bitmap, -__u64 start,unsigned int num,void *out); +__u64 start,size_t num,void *out); };extern struct ext2_bitmap_ops ext2fs_blkmap64_bitarray;
lib/ext2fs/gen_bitmap.c +2 -2
@@ -138,7 +138,7 @@ errcode_t ext2fs_copy_generic_bitmap(ext2fs_generic_bitmap src, dest)); } -void ext2fs_free_generic_bitmap (ext2fs_inode_bitmap bitmap) +void ext2fs_free_generic_bitmap (ext2fs_generic_bitmap bitmap) {if (check_magic (bitmap))return ;
@@ -204,7 +204,7 @@ void ext2fs_clear_generic_bitmap(ext2fs_generic_bitmap bitmap) (size_t) (((bitmap->real_end - bitmap->start) / 8) + 1)); } -errcode_t ext2fs_fudge_generic_bitmap_end (ext2fs_inode_bitmap bitmap, +errcode_t ext2fs_fudge_generic_bitmap_end (ext2fs_generic_bitmap bitmap,errcode_t magic,errcode_t neq,ext2_ino_t end,ext2_ino_t *oend) {
lib/ext2fs/gen_bitmap64.c +122 -25
249 lines not on this page · raw message
lib/ext2fs/imager.c +6 -6
@@ -277,7 +277,7 @@ errout:*/ errcode_t ext2fs_image_bitmap_write (ext2_filsys fs,int fd,int flags) { -ext2fs_generic_bitmap bmap; +ext2fs_generic_bitmap64 bmap;errcode_t err, retval;ssize_t actual;__u32 itr, cnt, size;
@@ -314,8 +314,8 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)if (size > (cnt >>3 )) size = (cnt >>3 ); - retval =ext2fs_get_generic_bitmap_range (bmap, - err, itr, size <<3 , buf); + retval =ext2fs_get_generic_bmap_range (bmap, + itr, size <<3 , buf);if (retval)return retval;
@@ -354,7 +354,7 @@ errcode_t ext2fs_image_bitmap_write(ext2_filsys fs, int fd, int flags)*/ errcode_t ext2fs_image_bitmap_read (ext2_filsys fs,int fd,int flags) { -ext2fs_generic_bitmap bmap; +ext2fs_generic_bitmap64 bmap;errcode_t err, retval;__u32 itr, cnt;char buf[1024 ];
@@ -396,8 +396,8 @@ errcode_t ext2fs_image_bitmap_read(ext2_filsys fs, int fd, int flags)if (actual != (int ) size)return EXT2_ET_SHORT_READ ; - retval =ext2fs_set_generic_bitmap_range (bmap, - err, itr, size <<3 , buf); + retval =ext2fs_set_generic_bmap_range (bmap, + itr, size <<3 , buf);if (retval)return retval;
lib/ext2fs/inode.c +1 -0
@@ -11,6 +11,7 @@#include <stdio.h> #include <string.h> +#include <time.h> #if HAVE_UNISTD_H #include <unistd.h> #endif
lib/ext2fs/tst_bitops.c +122 -0
127 lines not on this page · raw message
lib/uuid/gen_uuid.c +3 -1
@@ -35,8 +35,10 @@/* * Force inclusion of SVID stuff since we need it if we're compiling in * gcc-wall wall mode +* +* XXX - below somehow hides ftruncate() definition and _creates_ warnings */ -#define _SVID_SOURCE +/* #define _SVID_SOURCE */ #ifdef _WIN32#define _WIN32_WINNT 0x0500
misc/blkid.c +0 -1
@@ -170,7 +170,6 @@ static void pretty_print_dev(blkid_dev dev)blkid_tag_iterate iter;const char *type, *value, *devname;const char *uuid ="" , *fs_type ="" , *label ="" ; -char *cp;int len, mount_flags;char mtpt[80 ];errcode_t retval;
misc/dumpe2fs.c +1 -1
@@ -214,7 +214,7 @@ static void list_desc (ext2_filsys fs) diff = fs->group_desc[i].bg_inode_table - first_block;if (diff >0 )printf (" (+%ld)" , diff); - printf (_("\n %u free blocks, %u free inodes, " + printf (_("\n %d free blocks, %u free inodes, " "%u directories%s"), fs->group_desc[i].bg_free_blocks_count, fs->group_desc[i].bg_free_inodes_count,
misc/mke2fs.c +4 -3
@@ -48,6 +48,7 @@ extern int optind;#include <sys/types.h> #include <libgen.h> #include <limits.h> +#include <strings.h> #include "ext2fs/ext2_fs.h" #include "et/com_err.h"
@@ -380,7 +381,7 @@ static void write_inode_tables(ext2_filsys fs, int lazy_flag) retval =ext2fs_zero_blocks2 (fs, blk, num, &blk, &num);if (retval) {fprintf (stderr,_ ("\nCould not write %d " -"blocks in inode table starting at %ull: %s\n" ), +"blocks in inode table starting at %llu: %s\n" ), num, blk,error_message (retval));exit (1 ); }
@@ -597,7 +598,7 @@ static void show_stats(ext2_filsys fs)int need, col_left;if (ext2fs_blocks_count (&fs_param) !=ext2fs_blocks_count (s)) -fprintf (stderr,_ ("warning: %u blocks unused.\n\n" ), +fprintf (stderr,_ ("warning: %llu blocks unused.\n\n" ),ext2fs_blocks_count (&fs_param) -ext2fs_blocks_count (s));memset (buf,0 ,sizeof (buf));
@@ -1995,7 +1996,7 @@ int main (int argc, char *argv[])if (retval) {com_err (program_name, retval, -_ ("while zeroing block %u at end of filesystem" ), +_ ("while zeroing block %llu at end of filesystem" ), ret_blk); }write_inode_tables (fs, lazy_itable_init);
misc/tune2fs.c +1 -1
@@ -1440,7 +1440,7 @@ retry_open:* file. */ if (new_inode_size ==EXT2_INODE_SIZE (fs->super)) { -fprintf (stderr,_ ("The inode size is already %d\n" ), +fprintf (stderr,_ ("The inode size is already %lu\n" ), new_inode_size);exit (1 ); }