diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/e2p/ChangeLog | 4 | ||||
-rw-r--r-- | lib/e2p/feature.c | 2 | ||||
-rw-r--r-- | lib/ext2fs/ChangeLog | 26 | ||||
-rw-r--r-- | lib/ext2fs/ext2_fs.h | 6 | ||||
-rw-r--r-- | lib/ext2fs/ext2fs.h | 2 | ||||
-rw-r--r-- | lib/ext2fs/inode.c | 11 | ||||
-rw-r--r-- | lib/ext2fs/rw_bitmaps.c | 29 | ||||
-rw-r--r-- | lib/ext2fs/swapfs.c | 1 |
8 files changed, 76 insertions, 5 deletions
diff --git a/lib/e2p/ChangeLog b/lib/e2p/ChangeLog index 358e108c..641e7d8d 100644 --- a/lib/e2p/ChangeLog +++ b/lib/e2p/ChangeLog @@ -1,3 +1,7 @@ +2006-05-08 Theodore Tso <tytso@mit.edu> + + * feature.c: Add support for EXT2_FEATURE_COMPAT_LAZY_BG feature. + 2006-04-18 Theodore Ts'o <tytso@mit.edu> * uuid.c (e2p_is_null_uuid): Fix really stupid bug which could diff --git a/lib/e2p/feature.c b/lib/e2p/feature.c index 50f1ef3d..e8f6729d 100644 --- a/lib/e2p/feature.c +++ b/lib/e2p/feature.c @@ -35,6 +35,8 @@ static struct feature feature_list[] = { "dir_index" }, { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_RESIZE_INODE, "resize_inode" }, + { E2P_FEATURE_COMPAT, EXT2_FEATURE_COMPAT_LAZY_BG, + "lazy_bg" }, { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER, "sparse_super" }, { E2P_FEATURE_RO_INCOMPAT, EXT2_FEATURE_RO_COMPAT_LARGE_FILE, diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 7da3fe2e..512ef3f7 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,29 @@ +2006-05-08 Theodore Tso <tytso@mit.edu> + + * rw_bitmaps.c (write_bitmaps, read_bitmaps): Added support for + lazy blockgroups. If a block group has flags indicating + that its block or inode data structures have not been + initialized, skip reading or writing that portion of the + bitmap. + + * inode.c (ext2fs_open_inode_scan, ext2fs_read_inode_full): When + scanning a filesystem with lazy blockgroups, skip + uninitialized portions of the inode table when iterating + over the block group. + + * swapfs.c (ext2fs_swap_group_desc): Byte swap the bg_flags field. + + * ext2fs.h: Define the a new internal flag, EXT2_SF_DO_LAZY, so + that the inode interator knows compat_lazy_bg feature is + enabled. Declare that this version of e2fsprogs supports + the EXT2_FEATURE_COMPAY_LAZY_BG feature. + + * ext2_fs.h (struct ext2_group_desc): Use the bg_pad field for + bg_flags, and define the flags EXT2_BG_INODE_UNINIT and + EXT2_BG_BLOCK_UNINIT. These flags are only honored if + EXT2_FEATURE_COMPAT_LAZY_BG feature is enabled (also + added). + 2006-04-23 Theodore Ts'o <tytso@mit.edu> * rw_bitmaps.c (write_bitmaps, ext2fs_write_inode_bitmap, diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index e427addf..1cfbc358 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -143,10 +143,13 @@ struct ext2_group_desc __u16 bg_free_blocks_count; /* Free blocks count */ __u16 bg_free_inodes_count; /* Free inodes count */ __u16 bg_used_dirs_count; /* Directories count */ - __u16 bg_pad; + __u16 bg_flags; __u32 bg_reserved[3]; }; +#define EXT2_BG_INODE_UNINIT 0x0001 /* Inode table/bitmap not initialized */ +#define EXT2_BG_BLOCK_UNINIT 0x0002 /* Block bitmap not initialized */ + /* * Data structures used by the directory indexing feature * @@ -568,6 +571,7 @@ struct ext2_super_block { #define EXT2_FEATURE_COMPAT_EXT_ATTR 0x0008 #define EXT2_FEATURE_COMPAT_RESIZE_INODE 0x0010 #define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020 +#define EXT2_FEATURE_COMPAT_LAZY_BG 0x0040 #define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001 #define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002 diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index c3d04289..8618fe26 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -341,6 +341,7 @@ typedef struct ext2_struct_inode_scan *ext2_inode_scan; #define EXT2_SF_BAD_INODE_BLK 0x0002 #define EXT2_SF_BAD_EXTRA_BYTES 0x0004 #define EXT2_SF_SKIP_MISSING_ITABLE 0x0008 +#define EXT2_SF_DO_LAZY 0x0010 /* * ext2fs_check_if_mounted flags @@ -437,6 +438,7 @@ typedef struct ext2_icount *ext2_icount_t; EXT3_FEATURE_COMPAT_HAS_JOURNAL|\ EXT2_FEATURE_COMPAT_RESIZE_INODE|\ EXT2_FEATURE_COMPAT_DIR_INDEX|\ + EXT2_FEATURE_COMPAT_LAZY_BG|\ EXT2_FEATURE_COMPAT_EXT_ATTR) /* This #ifdef is temporary until compression is fully supported */ diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c index 222568eb..8d528b44 100644 --- a/lib/ext2fs/inode.c +++ b/lib/ext2fs/inode.c @@ -164,6 +164,9 @@ errcode_t ext2fs_open_inode_scan(ext2_filsys fs, int buffer_blocks, } if (scan->fs->badblocks && scan->fs->badblocks->num) scan->scan_flags |= EXT2_SF_CHK_BADBLOCKS; + if (EXT2_HAS_COMPAT_FEATURE(fs->super, + EXT2_FEATURE_COMPAT_LAZY_BG)) + scan->scan_flags |= EXT2_SF_DO_LAZY; *ret_scan = scan; return 0; } @@ -407,9 +410,13 @@ errcode_t ext2fs_get_next_inode_full(ext2_inode_scan scan, ext2_ino_t *ino, return retval; } /* - * This is done outside the above if statement so that the - * check can be done for block group #0. + * These checks are done outside the above if statement so + * they can be done for block group #0. */ + if ((scan->scan_flags & EXT2_SF_DO_LAZY) && + (scan->fs->group_desc[scan->current_group].bg_flags & + EXT2_BG_INODE_UNINIT)) + goto force_new_group; if (scan->current_block == 0) { if (scan->scan_flags & EXT2_SF_SKIP_MISSING_ITABLE) { goto force_new_group; diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 7ab0a4db..cb470b8e 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -60,12 +60,16 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) errcode_t retval; char *block_bitmap, *inode_bitmap; char *block_buf, *inode_buf; + int lazy_flag = 0; blk_t blk; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); if (!(fs->flags & EXT2_FLAG_RW)) return EXT2_ET_RO_FILSYS; + if (EXT2_HAS_COMPAT_FEATURE(fs->super, + EXT2_FEATURE_COMPAT_LAZY_BG)) + lazy_flag = 1; inode_nbytes = block_nbytes = 0; block_bitmap = inode_bitmap = 0; if (do_block) { @@ -89,6 +93,10 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) for (i = 0; i < fs->group_desc_count; i++) { if (!block_bitmap || !do_block) goto skip_block_bitmap; + + if (lazy_flag && fs->group_desc[i].bg_flags & + EXT2_BG_BLOCK_UNINIT) + goto skip_this_block_bitmap; memcpy(block_buf, block_bitmap, block_nbytes); if (i == fs->group_desc_count - 1) { @@ -113,12 +121,17 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) if (retval) return EXT2_ET_BLOCK_BITMAP_WRITE; } + skip_this_block_bitmap: block_bitmap += block_nbytes; skip_block_bitmap: if (!inode_bitmap || !do_inode) continue; + if (lazy_flag && fs->group_desc[i].bg_flags & + EXT2_BG_INODE_UNINIT) + goto skip_this_inode_bitmap; + memcpy(inode_buf, inode_bitmap, inode_nbytes); blk = fs->group_desc[i].bg_inode_bitmap; if (blk) { @@ -133,6 +146,7 @@ static errcode_t write_bitmaps(ext2_filsys fs, int do_inode, int do_block) if (retval) return EXT2_ET_INODE_BITMAP_WRITE; } + skip_this_inode_bitmap: inode_bitmap += inode_nbytes; } @@ -155,12 +169,17 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) errcode_t retval; int block_nbytes = (int) EXT2_BLOCKS_PER_GROUP(fs->super) / 8; int inode_nbytes = (int) EXT2_INODES_PER_GROUP(fs->super) / 8; + int lazy_flag = 0; blk_t blk; EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS); fs->write_bitmaps = ext2fs_write_bitmaps; + if (EXT2_HAS_COMPAT_FEATURE(fs->super, + EXT2_FEATURE_COMPAT_LAZY_BG)) + lazy_flag = 1; + retval = ext2fs_get_mem(strlen(fs->device_name) + 80, &buf); if (retval) return retval; @@ -209,6 +228,9 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) for (i = 0; i < fs->group_desc_count; i++) { if (block_bitmap) { blk = fs->group_desc[i].bg_block_bitmap; + if (lazy_flag && fs->group_desc[i].bg_flags & + EXT2_BG_BLOCK_UNINIT) + blk = 0; if (blk) { retval = io_channel_read_blk(fs->io, blk, -block_nbytes, block_bitmap); @@ -222,11 +244,14 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) ext2fs_swap_bitmap(fs, block_bitmap, block_nbytes); #endif } else - memset(block_bitmap, 0, block_nbytes); + memset(block_bitmap, 0xff, block_nbytes); block_bitmap += block_nbytes; } if (inode_bitmap) { blk = fs->group_desc[i].bg_inode_bitmap; + if (lazy_flag && fs->group_desc[i].bg_flags & + EXT2_BG_INODE_UNINIT) + blk = 0; if (blk) { retval = io_channel_read_blk(fs->io, blk, -inode_nbytes, inode_bitmap); @@ -240,7 +265,7 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) ext2fs_swap_bitmap(fs, inode_bitmap, inode_nbytes); #endif } else - memset(inode_bitmap, 0, inode_nbytes); + memset(inode_bitmap, 0xff, inode_nbytes); inode_bitmap += inode_nbytes; } } diff --git a/lib/ext2fs/swapfs.c b/lib/ext2fs/swapfs.c index 90817012..a4c66980 100644 --- a/lib/ext2fs/swapfs.c +++ b/lib/ext2fs/swapfs.c @@ -78,6 +78,7 @@ void ext2fs_swap_group_desc(struct ext2_group_desc *gdp) gdp->bg_free_blocks_count = ext2fs_swab16(gdp->bg_free_blocks_count); gdp->bg_free_inodes_count = ext2fs_swab16(gdp->bg_free_inodes_count); gdp->bg_used_dirs_count = ext2fs_swab16(gdp->bg_used_dirs_count); + gdp->bg_flags = ext2fs_swab16(gdp->bg_flags); } void ext2fs_swap_ext_attr(char *to, char *from, int bufsize, int has_header) |