summaryrefslogtreecommitdiff
path: root/lib/ext2fs/alloc_tables.c
AgeCommit message (Collapse)AuthorFilesLines
2011-09-18Shorten compile commands run by the build systemTheodore Ts'o1-0/+1
The DEFS line in MCONFIG had gotten so long that it exceeded 4k, and this was starting to cause some tools heartburn. It also made "make V=1" almost useless, since trying to following the individual commands run by make was lost in the noise of all of the defines. So fix this by putting the configure-generated defines in lib/config.h and the directory pathnames to lib/dirpaths.h. In addition, clean up some vestigal defines in configure.in and in the Makefiles to further shorten the cc command lines. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: replace missing flexbg initialization in flexbg_offsetTheodore Ts'o1-0/+2
Commit 25567a7b0fa9 accidentally removed the initialization for flexbg and flexbg_size, which affected ext2fs_allocate_group_table() and ext2fs_allocate_tables(). Replace them. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-07libext2fs: Fix gcc -Wall warningsTheodore Ts'o1-1/+2
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-05e2fsck, libext2fs: support for bigalloc file systems with a blocksize of 1024Theodore Ts'o1-35/+37
Filesystems with a blocksize of 1024 have the superblock starting at block #1. However, the first data block in the superblock is 0 to simplify the cluster calculations. So we must compensate for this in a number of places, mostly in the ext2fs library, but also in e2fsck. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13libext2fs: Teach *_initialize and *_allocate_group to be 64-bit safeTheodore Ts'o1-17/+17
This is needed to enable 64-bit mke2fs to work correctly. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-07Merge branch 'maint' into nextTheodore Ts'o1-2/+2
Conflicts: e2fsck/journal.c e2fsck/pass1.c e2fsck/pass2.c misc/mke2fs.c
2010-05-17libe2p, libext2fs: Update file copyright permission states to match COPYINGTheodore Ts'o1-2/+2
The top-level COPYING file states that the e2p and ext2fs libraries are available under the LGPLv2. The files were incorrectly labelled. Alex Thomas/Luster has been consulted wrt to the ext3_extents.h file; the rest of the files were primarily authored by Theodore Ts'o. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-01-31Merge branch 'maint' into nextTheodore Ts'o1-0/+2
Conflicts: configure lib/ext2fs/alloc_tables.c misc/mke2fs.c
2009-11-30libext2fs: Improve flex_bg inode table placement algorithmTheodore Ts'o1-0/+2
When trying to find the best place for the inode table in the last flex block group, use the true size for the flex_bg's portion of the inode table instead of the worst case required size of the inode table fragment if the file system is resized. This fixes a corner case where if the size of the filesystem is just big enough that there is only room for a single block group in the last flex_bg, and that partial block group is too small for the full portion of the inode table, the inode table is placed in the very first block group: Group 64: (Blocks 2097152-2099199) [INODE_UNINIT, ITABLE_ZEROED] Checksum 0xd305, unused inodes 8080 Block bitmap at 2097152 (+0), Inode bitmap at 2097168 (+16) Inode table at 8626-9130 (+4292878770) ^^^^^^^^^ Thanks to Vyacheslav Dubeyko for pointing this out. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25Convert ext2fs_group_{first,last}_block() to *block2()Theodore Ts'o1-7/+7
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25Convert ext2fs_group_of_blk() to ext2fs_group_of_blk2()Theodore Ts'o1-3/+3
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25Convert to use block group accessor functionsValerie Aurora Henson1-17/+17
Convert direct accesses to use the following block group accessor functions: ext2fs_block_bitmap_loc(), ext2fs_inode_bitmap_loc(), ext2fs_inode_table_loc(), ext2fs_bg_itable_unused(), ext2fs_block_bitmap_loc_set(), ext2fs_inode_bitmap_loc_set(), ext2fs_inode_table_loc_set(), ext2fs_bg_free_inodes_count(), ext2fs_ext2fs_bg_used_dirs_count(), ext2fs_bg_free_inodes_count_set(), ext2fs_bg_free_blocks_count_set(), ext2fs_bg_used_dirs_count_set() Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25libext2fs: clean up ext2fs_bg_flags_ interfacesEric Sandeen1-3/+3
The ext2fs_bg_flag* functions were confusing. Currently we have this: void ext2fs_bg_flags_set(ext2_filsys fs, dgrp_t group, __u16 bg_flags); void ext2fs_bg_flags_clear(ext2_filsys fs, dgrp_t group,__u16 bg_flags); (_set (unused) sets exactly bg_flags; _clear clears all and ignores bg_flags) and these, which can twiddle individual bits in bg_flags: void ext2fs_bg_flag_set(ext2_filsys fs, dgrp_t group, __u16 bg_flag); void ext2fs_bg_flag_clear(ext2_filsys fs, dgrp_t group, __u16 bg_flag); A better interface, after the patch below, is just: ext2fs_bg_flags_zap(fs, group) /* zeros bg_flags */ ext2fs_bg_flags_set(fs, group, flags) /* adds flags to bg_flags */ ext2fs_bg_flags_clear(fs, group, flags) /* clears flags in bg_flags */ and remove the original ext2fs_bg_flags_set / ext2fs_bg_flags_clear. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()Valerie Aurora Henson1-3/+3
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-23libext2fs: create generic numeric progress meters and use themValerie Aurora Henson1-0/+7
With 64-bit file systems, mke2fs can take a long time to do things other than write inode tables. I exported the mke2fs numeric progress meter and used it for allocating group tables and the final file system flush. Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07Use accessor functions fields for bg_flags in the block group descriptorsTheodore Ts'o1-3/+4
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-05Convert libext2fs to 64-bit bitmap interfaceValerie Aurora Henson1-6/+7
(Includes fixes from Nick Dokos) Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com> Signed-off-by: Nick Dokos <nicholas.dokos@hp.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-22libext2fs: Use blk_t instead of int in ext2fs_allocate_group_tableTheodore Ts'o1-1/+1
We are using a signed int to store a block number in ext2fs_allocate_group_table. We don't actually do any computation or comparisons using it, so it shouldn't cause any bugs, but it's technically incorrect, and it's possible an overly clever compiler might do something wrong with it. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-16Fix various signed/unsigned gcc warningsTheodore Ts'o1-2/+2
Some of these could affect filesystems between 2^31 and 2^32-1 blocks. Thanks to Valerie Aurora Henson for pointing out the problems in lib/ext2fs/alloc_tables.c, which led me to do a "make gcc-wall" scan over the source tree. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27Remove trailing whitespace for the entire source treeTheodore Ts'o1-3/+3
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-07-17Fix inode table allocation with flexbgFrederic Bohe1-9/+7
Disordered inode tables may appear when inode_blocks_per_group is lesser or equal to the number of groups in a flex group. This bug can be reproduced with: mkfs.ext4 -t ext4dev -G512 70G In that case, you can see with dump2fs that inode tables for groups 510 and 511 are placed just after group 51's inode table instead of being placed after group 509's inode table. Signed-off-by: Frederic Bohe <frederic.bohe@bull.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-07-07libext2fs: Fix FLEX_BG offset used by ext2fs_allocate_group_tableTheodore Ts'o1-1/+4
The offset for both inode bitmaps and inode tables is overshot by one block causing a hole between the group of bitmaps and inode tables when initializing a filesystem using mke2fs. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-06-07Fix gcc -Wall warnings in libext2fsTheodore Ts'o1-4/+4
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-04-22mke2fs: New bitmap and inode table allocation for FLEX_BGTheodore Ts'o1-3/+115
Change the way we allocate bitmaps and inode tables if the FLEX_BG feature is used at mke2fs time. It places calculates a new offset for bitmaps and inode table base on the number of groups that the user wishes to pack together using the new "-G" option. Creating a filesystem with 64 block groups in a flex group can be done by: mke2fs -j -I 256 -O flex_bg -G 32 /dev/sdX Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: Valerie Clement <valerie.clement@bull.net> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2008-03-20Add uninit block group support to various libext2fs functionsJose R. Santos1-3/+1
Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: Andreas Dilger <adilger@clusterfs.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2006-09-12Create new ext2fs library inlines: ext2fs_group_{first,last}_block()Eric Sandeen1-8/+4
Create new ext2fs library inline functions in order to calculate the starting and ending blocks in a block group. Signed-off-by: Eric Sandeen <esandeen@redhat.com>
2006-05-13Change mke2fs's layout of RAID-optimized filesystems to be more optimalTheodore Ts'o1-1/+5
When allocating space for the RAID filesystems with the stride parameter, place each portion of the group's inode table right up after the superblock (if present) in order to minimize fragmentation of the freespace. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2002-10-30Add support for the meta_bg feature flag to the resize2fs program.Theodore Ts'o1-22/+19
Fix bug in meta_bg support in mke2fs, e2fsck, and dumpe2fs; we were incorrectly reserving the legacy block groups desriptor blocks.
2001-05-14Many files:Theodore Ts'o1-5/+0
alloc.c, alloc_tables.c, badblocks.c, bb_compat.c, bb_inode.c, bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c, check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c, ext2_fs.h, fileio.c, finddev.c, flushb.c, freefs.c, get_pathname.c, getsize.c, icount.c, imager.c, initialize.c, inline.c, inode.c, irel_ma.c, ismounted.c, link.c, lookup.c, mkdir.c, mkjournal.c, namei.c, native.c, newdir.c, nt_io.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c, rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c, tst_byteswap.c, tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c, version.c, write_bb_file.c, ext2_fs.h: Moved file from include/linux. Adjust all files in this directroy to include this file.
1998-09-03Many files:Theodore Ts'o1-2/+2
rw_bitmaps.c: Fixed signed/unsigned warnings. fileio.c (ext2fs_file_set_size): Remove unneeded extern from the function declaration. dblist.c (make_dblist): Add safety check in case the dblist pointer passed in is null (in which case, assign it to fs->dblist). Fixed some signed/unsigned warnings. bmap.c: Make addr_per_block be of type blk_t to avoid signed/unsigned warnings. namei.c (ext2fs_follow_link): Remove uneeded extern from the function declaration. get_pathname.c (get_pathname_proc): Use return value from ext2fs_get_mem, instead of checking if &gp->name is NULL. dir_iterate.c (ext2fs_process_dir_block): dblist_dir.c (ext2fs_dblist_dir_iterate): Remove uneeded extern from the function declaration. block.c (ext2fs_block_iterate2): If the read_inode call fails, return the error directly instead of jumping to the cleanup routine, since we don't need to do any cleanup. alloc_table.c (ext2fs_allocate_group_table): Make this function take a dgrp_t for its group argument. ext2fs.h: Make dgrp_t an __u32 type, and make fs->desc_group_count be of type dgrp_t.
1998-06-10Many files:Theodore Ts'o1-0/+6
alloc_tables.c (ext2fs_allocate_group_table): Fix bug so that if the stride length hits a bad value, we retry the block allocation starting at the beginning of the block group. ext2fs.h, bb_inode.c, block.c, bmove.c, dir_iterate.c, expanddir.c, ext2fsP.h, read_bb.c: Change blkcnt_t to be e2_blkcnt_t to avoid collision with LFS API.
1998-01-19Many files:Theodore Ts'o1-0/+4
inode.c (ext2fs_open_inode_scan): Initialize the group variables so that we don't need to call get_next_blockgroup() the first time around. Saves a bit of time, and prevents us from needing to assign -1 to current_group (which is an unsigned value). icount.c (insert_icount_el): Cast the estimated number of inodes from a float to an ino_t. alloc.c, alloc_tables.c, badlbocks.c, bb_compat.c, bb_inode.c, bitmaps.c, bitops.c, block.c, bmap.c, bmove.c, brel_ma.c, check_desc.c, closefs.c, cmp_bitmaps.c, dblist.c, dblist_dir.c, dir_iterate.c, dirblock.c, dupfs.c, expanddir.c, ext2fs.h, fileio.c, freefs.c, get_pathname.c, getsize.c, icount.c, initialize.c, inline.c, inode.c, irel_ma.c, ismounted.c, link.c, lookup.c, mkdir.c, namei.c, native.c, newdir.c, openfs.c, read_bb.c, read_bb_file.c, rs_bitmap.c, rw_bitmaps.c, swapfs.c, test_io.c, tst_badblocks.c, tst_getsize.c, tst_iscan.c, unix_io.c, unlink.c, valid_blk.c, version.c: If EXT2_FLAT_INCLUDES is defined, then assume all of the ext2-specific header files are in a flat directory. block.c, bmove.c, dirblock.c, fileio.c: Explicitly cast all assignments from void * to be compatible with C++. closefs.c (ext2fs_flush): Add a call to io_channel_flush() to make sure the contents of the disk are flushed to disk. dblist.c (ext2fs_add_dir_block): Change new to be new_entry to avoid C++ namespace clash. bitmaps.c (ext2fs_copy_bitmap): Change new to be new_map to avoid C++ namespace clash. ext2fs.h, bb_inode.c, block.c, bmove.c, brel.h, brel_ma.c, irel.h, irel_ma.c, dblist.c, dblist_dir.c, dir_iterate.c, ext2fsP.h, expanddir.c, get_pathname.c, inode.c, link.c, unlink.c: Change private to be priv_data (to avoid C++ namespace clash)
1997-12-01Many files:Theodore Ts'o1-1/+0
dblist.c (ext2fs_get_num_dirs): Make ext2fs_get_num_dirs more paranoid about validating the directory counts from the block group information. all files: Don't include stdlib.h anymore; include it in ext2_fs.h, since that file requires stdlib.h ChangeLog, Makefile.in, dirinfo.c: dirinfo.c (e2fsck_add_dir_info): Use ext2fs_get_num_dirs instead of e2fsck_get_num_dirs, which has been removed. Makefile.in (PROGS): Remove @EXTRA_PROGS@, since we don't want to compile and install flushb. ChangeLog, configure.in: Remove @EXTRA_PROGS@, since we aren't using it in 2fsck/Makefile.in anymore ChangeLog, Makefile.in: Install debugfs in /sbin, instead of /usr/sbin. libext2fs.texinfo: Update version string to be 1.12 Makefile.in: Fix bug in find script which made the exclusion list, where a '-' was missing from an -name option.
1997-10-25Many files:Theodore Ts'o1-3/+0
alloc.c (ext2fs_alloc_block): New function which allocates a block and updates the filesystem accounting records appropriately. ext2_err.et.in: Added new error codes: EXT2_NO_MEMORY, EXT2_INVALID_ARGUMENT, EXT2_BLOCK_ALLOC_FAIL, EXT2_INODE_ALLOC_FAIL, EXT2_NOT_DIRECTORY Change various library files to use these functions instead of EINVAL, ENOENT, etc. ChangeLog, pass1.c, pass3.c: pass3.c (get_lost_and_found): Check error return of EXT2_FILE_NOT_FOUND instead of ENOTDIR pass1.c (pass1_check_directory): Return EXT2_NO_DIRECTORY instead of ENOTDIR expect.icount: Change expected error string to be "Invalid argument passed to ext2 library" instead of just "Invalid argument"
1997-10-19Many files:Theodore Ts'o1-0/+4
Add #ifdef's for HAVE_SYS_STAT_H and HAVE_SYS_TYPES_H
1997-08-10Many files:Theodore Ts'o1-0/+2
block.c (ext2fs_block_iterate2): Use retval which is a errcode_t type. bitmaps.c (make_bitmap): Use size_t instead of int where appropriate. bb_inode.c (set_bad_block_proc): Add #pragma argsused for Turbo C. alloc.c (ext2fs_new_inode): Use ino_t instead of int for the group number. get_pathname.c: Use ino_t instead of int where appropriate. ext2fs.h: Make the magic structure element be errcode_t instead of int. alloc.c alloc_tables.c badblocks.c bb_compat.c bb_inode.c bitmaps.c block.c bmove.c brel_ma.c check_desc.c closefs.c cmp_bitmaps.c dblist.c dblist_dir.c dir_iterate.c dirblock.c dupfs.c expanddir.c freefs.c get_pathname.c icount.c initialize.c inline.c inode.c irel_ma.c link.c llseek.c lookup.c mkdir.c namei.c newdir.c read_bb.c read_bb_file.c rs_bitmap.c rw_bitmaps.c swapfs.c test_io.c tst_badblocks.c tst_iscan.c unix_io.c unlink.c valid_blk.c version.c: Add an #ifdef for HAVE_UNISTD_H
1997-06-09Many files:Theodore Ts'o1-37/+59
bmove.c (ext2fs_move_blocks): New function which takes a bitmap of blocks which need to be moved, and moves those blocks to another location in the filesystem. rs_bitmap.c (ext2fs_resize_generic_bitmap): When expanding a bitmap, make sure all of the new parts of the bitmap are zero. bitmaps.c (ext2fs_copy_bitmap): Fix bug; the destination bitmap wasn't being returned to the caller. alloc_tables.c (ext2fs_allocate_group_table): Add new function ext2fs_allocate_group_table() which sets the group tables for a particular block group. The relevant code was factored out of ext2fs_allocate_tables(). dblist.c (make_dblist): Adjust the initial size of the directory block list to be a bit more realize (ten plus twice the number of directories in the filesystem). Check in interim work.
1997-04-29Many files:Theodore Ts'o1-2/+11
Checkin of e2fsprogs 1.10
1997-04-29Many files:Theodore Ts'o1-0/+3
Checked in e2fsprogs 1.09
1997-04-29Many files:Theodore Ts'o1-21/+20
Checked in e2fsprogs 1.08.
1997-04-29Many files:Theodore Ts'o1-0/+80
Checked in e2fsprogs-1.07