Commit Graph

1235 Commits (534a4c3db58064caee4fc3e9e294251240d9d28a)

Author SHA1 Message Date
Andreas Dilger 534a4c3db5 ext2fs: don't use O_DIRECT if not available
O_DIRECT is not defined on OSX.  Since direct IO is only a new
optimization and not needed for correct functionality, disable
it if O_DIRECT is unavailable.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:50:01 -04:00
Andreas Dilger a1a769987b misc: fix compile warnings on OSX
The BLKFLSBUF and FDFLUSH ioctls are Linux specific, and do not
really have anything to do with __GNUC__ (which is also used on
OS/X and Solaris).  Only print these warnings on Linux systems.

statfs64() is deprecated on OSX and generates a deliberate warning.
Fix some other warnings that show up on OSX builds.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:50:01 -04:00
Andreas Dilger 65d05cec3d ext2fs: fix ext2fs_warn_bitmap32() return warning
This was reported as "control reaches end of non-void function",
but comparing to other similar functions it should be a void
function.  Since it is only declared in the "private" ext2fsP.h
header, it should be OK to change the function prototype.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:33:02 -04:00
Andreas Dilger 1ac2aa23ef ext2fs: fix undeclared posix_memalign() warning
Older distros do not define posix_memalign() by default in the
headers.  If ext2fs.h is included early in the headers, it is
possible to "#define _XOPEN_SOURCE 600" so that the stdlib.h
header will define it, but if ext2fs.h is included after stdlib.h
there is no posix_memalign() declaration.

Add a posix_memalign() declaration if stdlib.h didn't do it.  This
is a bit of a hack for GNU headers, but it works on Linux and OS/X
without problems.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:04:42 -04:00
Andreas Dilger cf5301d7f2 misc: clean up compiler warnings
Fix several types of compiler warnings (unused variables/labels),
uninitialized variables, etc that are hit with gcc -Wall.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 10:58:25 -04:00
Theodore Ts'o 44fe08f1fa e2fsck: add basic bigalloc support to check (but not yet repair) file systems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:58:16 -04:00
Theodore Ts'o c6ed60cdeb mke2fs: support creating bigalloc file systems
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:57:22 -04:00
Theodore Ts'o 4a2a9b70c8 libext2fs: allocate clusters to files in expand_dir.c and mkjournal.c
Teach ext2fs_expand_dir() and ext2fs_add_journal_inode() about
allocating blocks when clustered allocation is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:54:53 -04:00
Theodore Ts'o b0ecb787ef libext2fs: teach block allocation functions about bigalloc/clusters
Optimize ext2fs_new_block2() and ext2fs_get_free_blocks2() when
bigalloc is enabled.  Also fix the uninitialized block bitmap code so
that it correctly deals clustered allocation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 18:51:58 -04:00
Theodore Ts'o 94968e749b libext2fs: teach bitmap functions about bigalloc/cluster
This patch makes the following changes:

* ext2fs_allocate_block_bitmap() now allocates a bitmap with cluster
  granularity for bigalloc file systems.  For mke2fs and e2fsck, a
  newly added function, ext2fs_allocate_subcluster_bitmap() allocates
  a bitmap with block granularity (even for bigalloc file systems).
  The newly added function ext2fs_get_bitmap_granularity() will return
  the number of bits (log2) of the granularity used by the bitmap.

* The ext2fs_{mark,unmark,test}_block_bitmap2() functions will shift
  their passed-in argument by log2(cluster_ganularity) bits right.
  This means that the arguments for the single-argument bitmap
  functions will be interpreted with block granluarity, since this
  minimizes code changes in the rest of the code base.

* The ext2fs_{get,set}_block_bitmap_range() functions will interpret
  their arguments in cluster granularity.  This is a bit inconsistent,
  but the caller of those functions will need to be taught about the
  subtleties of clusters for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 17:55:09 -04:00
Theodore Ts'o 1afb468b9a libext2fs: create extent-based directories if the extents feature is enabled
This allows mke2fs to create the root and lost+found directories using
extents.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-10 13:58:18 -04:00
Theodore Ts'o 6a6337c3df Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/bitmaps.c
	lib/ext2fs/rw_bitmaps.c
	misc/dumpe2fs.c
2011-06-04 20:24:36 -04:00
Theodore Ts'o b92fbed778 libext2fs: Teach block bitmap read, write, and allocation funcs about clusters
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 20:05:22 -04:00
Theodore Ts'o 1da5ef7079 libext2fs: change fs->clustersize to fs->cluster_ratio_bits
The log2 of the ratio of cluster size to block size is far more useful
than just storing the cluster size.  So make this change, and then
define basic utility macros: EXT2FS_CLUSTER_RATIO(),
EXT2FS_CLUSTER_MASK(), EXT2FS_B2C(), EXT2FS_C2B(), and
EXT2FS_NUM_B2C().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 17:43:10 -04:00
Theodore Ts'o ae9e37cd11 libext2fs: change EXT2_MAX_BLOCKS_PER_GROUP() to be cluster size aware
Change the EXT2_MAX_BLOCKS_PER_GROUP so that it takes the cluster size
into account.  This way we can open bigalloc file systems without
ext2fs_open() thinking that they are corrupt.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 16:40:26 -04:00
Theodore Ts'o 6220b6715f libext2fs: require cluster size == block_size when opening a !bigalloc fs
In ext2fs_open() check to make sure the cluster size superblock field
is the same as the block size field when the bigalloc feature is not
set.  This is necessary since we will start introducing calculations
based on the cluster size field.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 16:36:19 -04:00
Theodore Ts'o 1e082c6209 libcom_err: Fix install rule if installing with hard links
If $(LINK_INSTALL_FLAGS) is -f instead of -sf, the Makefile's install
rule would not work correctly while installing com_err.h

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 11:24:18 -04:00
Lukas Czerner bf0449b1a6 e2image: Add support for qcow2 format
This commit adds support for exporting filesystem into QCOW2 image
format. Like sparse format this saves space, by writing only necessary
(metadata blocks) into image. Unlike sparse image, QCOW2 image is NOT
sparse, hence does not change its size by copying with not-sparse-aware
tools.

New options '-Q' has been added to tell the e2image to use QCOW2 as an
output image format. QCOW2 supports encryption and compression, however
e2image so far does no support such features, however you can still
scramble filenames with '-s' option.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18 11:51:06 -04:00
Lukas Czerner ffec46fea4 e2fsprogs: Add memory allocation and zero-out helpers
Add functions ext2fs_get_memzero() which will malloc() the memory
using ext2fs_get_mem(), but it will zero the allocated memory afterwards
with memset().

Add function ext2fs_get_arrayzero() which will use calloc() for
allocating and zero-out the array.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18 11:41:02 -04:00
Tao Ma 598d20cc3c mke2fs: make s_inodes_per_group >= 8 in ext2fs_initialize
current mkfs.ext4 fails if we tried with the following parameters:

	mkfs.ext4  -m 0 -N 16 -O ^has_journal,^resize_inode,^uninit_bg,extent,meta_bg -b 1024 /dev/sdb3

It will cause segfault, but it is caused by another issue.  See my
patch "mke2fs: Avoid segmentation fault in
ext2fs_alloc_generic_bmap". And with that patch, the mkfs.ext4 will
fail with the error: /dev/sdb3: Memory allocation failed while setting
up superblock

The reason is that in ext2fs_initialize, we align s_inodes_per_group
to 8, but fails to consider the case that s_inodes_per_group < 8.
So make at least 8 inodes for s_inodes_per_group.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-14 23:26:13 -04:00
Lukas Czerner 5fff975431 e2fsprogs: fix memory leak in ext2fs_free_generic_bmap()
In ext2fs_free_generic_bmap() when we are freeing 64-bit bitmap, we do
call free_bmap() to free backend specific bitmap structures, however we
should also free ext2fs_generic_bitmap structure as well.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-08 18:21:59 -04:00
Lukas Czerner ba7cb5d9d7 e2fsprogs: fix freeing bitmap in allocation error path
In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation
fails ext2fs_generic_bitmap should be freed, however in current state it
first frees ext2fs_generic_bitmap and then
ext2fs_generic_bitmap->description which is wrong. This commit fix the
free ordering.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-08 18:06:30 -04:00
Theodore Ts'o 5af9eeaa7d Merge branch 'maint' into next
Conflicts:
	lib/e2p/ls.c
2011-03-18 16:44:37 -04:00
Theodore Ts'o 4df1618250 add new superblock field: s_overhead_blocks
It turns out that it's very hard to calculate overheads in the face of
clustered allocation (bigalloc).  This is because multiple metadata
blocks from different block groups can end up in the same allocation
cluster.  Calculating the exact overhead requires O(all block bitmaps)
in memory, or O(number of block groups**2) in time.  So we will
calculate this at mkfs time and stash it in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-03-18 14:47:15 -04:00
Theodore Ts'o aa07cb79b0 mke2fs: If the device supports discard, don't print an error message
Check to see if the device supports discard before starting the
progress bar, and then printing an error about inappropriate ioctl for
device (when creating a file system image to a file, for example).

Also, add a function signature in the ext2_io.h header file for
io_channel_discard() and fix an extra, uneeded argument in mke2fs's
call to that function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-27 20:09:54 -05:00
Theodore Ts'o 829d999488 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/initialize.c
2011-02-27 19:47:44 -05:00
Theodore Ts'o 412376efff Add basic BIGALLOC support for cluster-based allocation
This adds the superblock fields needed so that dumpe2fs works and the
code points and renames the superblock fields from describing
fragments to clusters.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-25 21:43:54 -05:00
Aditya Kali 0edcc27021 e2fsprogs: reserving code points for new ext4 quota feature
This patch adds support for detecting the new 'quota' feature in ext4.
The patch reserves code points for usr and group quota inodes and also
for the feature flag EXT4_FEATURE_RO_COMPAT_QUOTA.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-25 18:31:52 -05:00
Theodore Ts'o 214580a339 Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.conf.5.in
2011-02-20 21:54:43 -05:00
Eric Sandeen 6a426c97ec e2fsprogs: enable user namespace xattrs by default
User namespace xattrs are generally useful, and I think extN
is the only filesystem requiring a special mount option to
enable them, when xattrs are otherwise available.  So this
change sets that mount option into the defaults, via a
mke2fs.conf option.

Note that if xattrs are config'd off, this will lead to a
mostly-harmless:

   EXT4-fs (sdc1): (no)user_xattr options not supported

message at mount time...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 21:36:26 -05:00
Eric Sandeen 3daf592646 e2fsprogs: turn off enforced fsck intervals by default
The forced fsck often comes at unexpected and inopportune moments,
and even enterprise customers are often caught by surprise when
this happens.  Because a filesystem with an error condition will
be marked as requiring fsck anyway, I submit that the time-based
and mount-based checks are not particularly useful, and that
administrators can schedule fscks on their own time, or tune2fs
the enforced intervals if they so choose.  This patch disables the
intervals by default, and I've added a new mkfs.conf option to
turn on the old behavior of random, unexpected, time-consuming
fscks at boot time.  ;)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 20:45:12 -05:00
Eric Sandeen b6d274f7c6 e2fsprogs: create com_err.h link in includedir
After debian bug #192277, debian/rules started making a symlink
to com_err.h in /usr/include.  Now I have Fedora bug #550889
for the same issue, and perhaps it's time to make this link
by default, rather than fixing it up in packaging steps?

[ Changed by tytso to remove the explicit -s option; this will default
  to creating a hard link by default, which slightly faster.  If
  people want to use symlinks for all links during the install
  process, they can use configure option --enable-symlink-install.
  The reason for this change is that some file systems, like AFS,
  don't support symlinks, and AFS users complain when they can't build
  or install into AFS.  So I don't want to use symlinks
  unconditionally without a way of switching things back and forth,
  and it's easier if we just make all links made during the install
  process to be hard links or sym links. ]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 18:10:21 -05:00
Theodore Ts'o da2a5a4bae Merge branch 'maint' into next
Conflicts:
	resize/resize2fs.c
2010-12-22 19:00:21 -05:00
Theodore Ts'o a4fdf09414 libext2fs: Don't use the extended rec_len encoding for standard file systems
If the file system has a blocksize less than 64k, then don't use the
extended rec_len encoding, to be consistent with what the kernel will
do.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-22 13:53:02 -05:00
Namhyung Kim 91dc3f0db0 libext2fs: fix possible memory leak in write_journal_inode()
ext2fs_zero_block2() allocates static buffer if needed so it
should be freed at last (call it again with 0 args).

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-22 10:43:01 -05:00
Theodore Ts'o 58caabc37d ext2fs: fix memory leak in an error case in inode_open()
Reported-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-21 18:05:07 -05:00
Theodore Ts'o 2150278fa2 libext2fs: fix potential free() of garbage in ext2fs_update_bb_inode()
There was a potential of freeing an uninitialized pointer in
rec.block_buf, which was pointed out by Namhyung Kim <namhyung@gmail.com>

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20 10:58:58 -05:00
Namhyung Kim f57e64a851 libext2fs: fix dubious code in ext2fs_unmark_generic_bitmap()
Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:54:27 -05:00
Namhyung Kim 877d1dc0ab libext2fs: remove unnecessary casts to ext2fs_generic_bitmap
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:50:33 -05:00
Namhyung Kim 3ece37ea0a libext2fs: fix dubious code in ext2fs_numeric_progress_init()
Looks like a copy & paste problem to me.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:07:10 -05:00
Namhyung Kim beb4295ca4 libext2fs: fix potential build failure with OMIT_COM_ERR
This fixes following build failure when OMIT_COM_ERR is defined:

 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_clear_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:437: error: invalid storage class for function ‘ext2fs_test_clear_generic_bitmap_range’
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_end’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_get_generic_bitmap_start’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_unmark_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_mark_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
 lib/ext2fs/gen_bitmap.c: In function ‘ext2fs_test_generic_bitmap’:
 lib/ext2fs/gen_bitmap.c:559: error: expected declaration or statement at end of input
make[2]: *** [gen_bitmap.o] Error 1
make[2]: Leaving directory e2fsprogs/lib/ext2fs'
make[1]: *** [all-libs-recursive] Error 1
make[1]: Leaving directory e2fsprogs'
make: *** [all] Error 2

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-20 10:07:10 -05:00
Theodore Ts'o 562f264243 Merge branch 'maint' into next
Conflicts:
	lib/ext2fs/block.c
	lib/ext2fs/csum.c
	resize/main.c
2010-12-20 10:06:58 -05:00
Theodore Ts'o 9098c986b6 libext2fs: Fix compile bug on big-endian architectures
Addresses-Sourceforge-Bug: #3138115

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16 22:11:43 -05:00
Theodore Ts'o 94ded6c16b libext2fs: fix ref_offset callback with sparse files in ext2fs_block_iterate2()
Addresses-Sourceforge-Bug: 3081087

Reported-by: vmo@users.sourceforge.net
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16 19:34:24 -05:00
Eric Sandeen c816ecb204 e2fsprogs: fix type-punning warnings
Flags used during RHEL/Fedora builds lead to a couple type-punning
warnings:

  recovery.c: In function 'do_one_pass':
  recovery.c:539: warning: dereferencing type-punned pointer will break strict-aliasing rules
  ./csum.c: In function 'print_csum':
  ./csum.c:170: warning: dereferencing type-punned pointer will break strict-aliasing rules

The two changes below fix this up.

Note that the csum test binary output changes slightly, but this does
not break any tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-16 17:15:30 -05:00
Lukas Czerner efa1a355a1 e2fsck: Discard free data and inode blocks.
In Pass 5 when we are checking block and inode bitmaps we have great
opportunity to discard free space and unused inodes on the device,
because bitmaps has just been verified as valid. This commit takes
advantage of this opportunity and discards both, all free space and
unused inodes.

I have added new set of options, 'nodiscard' and 'discard'. When the
underlying devices does not support discard, or discard ends with an
error, or when any kind of error occurs on the filesystem, no further
discard attempt will be made and the e2fsck will behave as it would
with nodiscard option provided.

As an addition, when there is any not-yet-zeroed inode table and
discard zeroes data, then inode table is marked as zeroed.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 21:01:41 -05:00
Lukas Czerner d866599ab4 e2fsprogs: Add CHANNEL_FLAGS_DISCARD_ZEROES flag for io_manager
When the device have discard support and simultaneously discard zeroes
data (and it is properly advertised), then we can take advantage of such
behavior in several e2fsprogs tools.

Add new flag CHANNEL_FLAGS_DISCARD_ZEROES for struct_io_channel so
each io_manager can take advantage of this. The flag is properly set
according to BLKDISCARDZEROES ioctl in unix_open.

Also remove old mke2fs_discard_zeroes_data() function and substitute it
with helper which test this flag.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 20:41:46 -05:00
Lukas Czerner e90a59ed43 e2fsprogs: Add discard function into struct_io_manager
In order to provide generic "discard" function for all e2fsprogs tools
add a discard function prototype into struct_io_manager. Specific
function for specific io managers can be crated that way.

This commit also creates unix_discard function which uses BLKDISCARD
ioctl to discard data blocks on the block device and bind it into
unit_io_manager structure to be available for all e2fsprogs tools.
Note that BLKDISCARD is still Linux specific ioctl, however other
unix systems may provide similar functionality. So far the
unix_discard() remains linux specific hence is embedded in #ifdef
__linux__ macro.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 20:41:00 -05:00
Justin Maggard 4fca2b9c07 Fix EXT4_FEATURE_RO_COMPAT_HUGE_FILE check
Creating a 4TB file on a filesystem with the 64bit flag set results in
e2fsck consistently complaining about i_blocks being wrong, with
confusing messages like this:

Inode 29818882, i_blocks is 8388608816, should be 8388608816.  Fix? no

That appears to be caused by ext2fs_inode_i_blocks() checking for the
EXT4_FEATURE_RO_COMPAT_HUGE_FILE in the wrong place.  Fix it.

Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 17:32:28 -05:00
Theodore Ts'o 9d92a201de Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	lib/ext2fs/ext2fs.h
	misc/mke2fs.c
2010-09-24 22:40:21 -04:00