Whamcloud - gitweb
tools/e2fsprogs.git
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Tue, 13 May 2014 15:01:07 +0000 (11:01 -0400)]
Merge branch 'maint' into next

Conflicts:
debugfs/Makefile.in
debugfs/debug_cmds.ct
debugfs/debugfs.c
debugfs/debugfs.h
e2fsck/Makefile.in
misc/Makefile.in
misc/mke2fs.c

10 years agomke2fs: set gdt csum when creating packed fs
Darrick J. Wong [Mon, 12 May 2014 04:21:29 +0000 (00:21 -0400)]
mke2fs: set gdt csum when creating packed fs

When we're creating a fs with metadata blocks packed at the beginning
(packed_meta_blocks=1 in mke2fs.conf), set the group descriptor
checksum or else we create DOA filesystems with checksum errors.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
10 years agoresize2fs: fix sanity check in reserve_sparse_super2_last_group()
Darrick J. Wong [Mon, 12 May 2014 03:33:08 +0000 (23:33 -0400)]
resize2fs: fix sanity check in reserve_sparse_super2_last_group()

In reserve_sparse_super2_last_group, the old_desc check should only be
performed if ext2fs_super_and_bgd_loc2() gave us a location -- a
return value of 0 means that there is no old-style GDT block.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoquota: remove mke2fs's and tune2fs's warning messages regarding quota
Theodore Ts'o [Sun, 11 May 2014 04:23:49 +0000 (00:23 -0400)]
quota: remove mke2fs's and tune2fs's warning messages regarding quota

We no longer need to reference https://ext4.wiki.kernel.org/index.php/Quota
since we've fixed the nasty bugs associated with e2fsck and the quota
feature.  The wiki page will be updated once we've done a release that
includes these fixes indicated the verison which these problems have
been fixed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agotests: add basic e2fsck regression test for fixing the quota inode
Theodore Ts'o [Sun, 11 May 2014 04:01:33 +0000 (00:01 -0400)]
tests: add basic e2fsck regression test for fixing the quota inode

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agodebugfs: add commands to query the quota information
Theodore Ts'o [Sun, 11 May 2014 03:28:10 +0000 (23:28 -0400)]
debugfs: add commands to query the quota information

This allows us to verify quota information in an ext4 file systems
with the quota feature.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: support storing the quota file handles in the quota context
Theodore Ts'o [Sun, 11 May 2014 03:19:12 +0000 (23:19 -0400)]
quota: support storing the quota file handles in the quota context

This makes memory management easier because when the quota context is
released, all of the quota file handles get released automatically.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: integrate mkquota.h into quotaio.h
Theodore Ts'o [Sat, 10 May 2014 22:55:20 +0000 (18:55 -0400)]
quota: integrate mkquota.h into quotaio.h

There are interfaces that are used by mke2fs.c and tune2fs.c which are
in quotaio.h, and some future changes will be much simpler if we can
combine the two header files together.  Also the guard #ifdef for
mkquota.h was incorrect, which caused problems when both header files
needed to be included.

Also remove quota.pc and installation rules for libquota, since this
library is never going to be something that we can export externally
anyway.  Eventually we'll want to clean up the interfaces and move the
external publishable interfaces to the libext2fs library, and then
rename what's left from libquota.a to libsupport.a for internal use
only.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: fix memory leak in quota_compare_and_update()
Theodore Ts'o [Sat, 10 May 2014 21:29:18 +0000 (17:29 -0400)]
quota: fix memory leak in quota_compare_and_update()

The quota_handle wasn't getting closed in quota_compare_and_update().
Fix this, and also make sure that quota_file_close() doesn't
unnecessarily modify the quota inode if it's not necessary.  Otherwise
e2fsck will claim that the file system is modified when it didn't need
to be.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: fix e2fsck to notice missing quota entries
Theodore Ts'o [Sat, 10 May 2014 05:27:31 +0000 (01:27 -0400)]
quota: fix e2fsck to notice missing quota entries

Previously if there was a missing quota entry --- i.e., if there were
files owned by group "eng", but there was no quota record for group
"eng", e2fsck would not notice the missing entry.  This means that the
usage informtion would not be properly repaired.  This is unfortunate.
Fix this by marking each quota record in quota_dict that has a
corresponding record on disk, and then check to see if there are any
records in quota_dict that have not been marked as having been seen.
In that case, we know we need to update the relevant quota inode.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: fix e2fsck so we update the quota file correctly
Theodore Ts'o [Sat, 10 May 2014 05:11:41 +0000 (01:11 -0400)]
quota: fix e2fsck so we update the quota file correctly

In scan_dquota_callback() we were copying dqb_off from the on-disk
dquot structure to the dqot structure that we have constructed in
memory.  This is a bad idea, because if we detect that the quota inode
is corrupted and needs to be replaced, when we later write out the
inode, the fact that we have a non-zero dqb_off value means that quota
routines will not bother updating the quota tree index, since
presumably the quota tree index already has an entry for this dqot.

The problem is that e2fsck, the only user of these functions, has
zapped the quota inode so it can be written from scratch.  So this
means the index for the quota records are not written out, so the
kernel can not find any of the records in the quota inodes.  Oops.

The fix is simple; there is no reason to copy the dqb_off field into
the quota_dict copy of struct dquot.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agoquota: add debugging code to print the dquot structure
Theodore Ts'o [Sat, 10 May 2014 05:09:44 +0000 (01:09 -0400)]
quota: add debugging code to print the dquot structure

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Aditya Kali <adityakali@google.com>
10 years agodebugfs: force logdump to display (old) journal contents
Darrick J. Wong [Thu, 1 May 2014 23:13:02 +0000 (16:13 -0700)]
debugfs: force logdump to display (old) journal contents

If the user passes the -O option to logdump, try to dump old log
contents.  This can be used to try to track down journal problems even
after the journal has been replayed.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agodebugfs: teach logdump to deal with 64bit revoke tables
Darrick J. Wong [Mon, 12 May 2014 00:57:18 +0000 (20:57 -0400)]
debugfs: teach logdump to deal with 64bit revoke tables

The logdump command doesn't know how to deal with revoke tables in
64bit journals, so teach it to do this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs: always warn if 128-byte inode and inline_data
Darrick J. Wong [Mon, 12 May 2014 00:24:55 +0000 (20:24 -0400)]
mke2fs: always warn if 128-byte inode and inline_data

The combination of 128-byte inodes and inline_data is silly, since
there's no room in the inode table.  Unfortunately, if neither
mke2fs.conf nor the mkfs command line options specify an inode size,
the default inode size is set to 128 bytes (by libext2fs) and the
warning isn't printed.  Therefore, always do the check-and-warning.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: create sockets when populating filesystem
Darrick J. Wong [Sun, 11 May 2014 22:42:23 +0000 (18:42 -0400)]
libext2fs: create sockets when populating filesystem

Since the code to copy-in a socket when creating a filesystem is
fairly simple, just do it here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc: coverity fixes
Darrick J. Wong [Sun, 11 May 2014 22:34:50 +0000 (18:34 -0400)]
misc: coverity fixes

Fix various small resource leaks and error code handling issues that
Coverity pointed out.

Fixes-Coverity-Bugs: 11919{39-45}, 1174118, 1049160, 1049144
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc: create better-packaged static analysis reports
Darrick J. Wong [Sun, 11 May 2014 22:32:07 +0000 (18:32 -0400)]
misc: create better-packaged static analysis reports

Fix some minor bugs relating to passing CFLAGS to cppcheck, and
package the cppcheck output into nicer looking reports.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Sun, 11 May 2014 22:30:11 +0000 (18:30 -0400)]
Merge branch 'maint' into next

Conflicts:
e2fsck/pass1.c

10 years agolibquota: fix dict_uint_cmp()
Niu Yawei [Thu, 8 May 2014 02:38:53 +0000 (10:38 +0800)]
libquota: fix dict_uint_cmp()

dict_uint_cmp() returns an usigned int value in int type, which
could mess the dict key comparison when the difference of two
keys is greater than INT_MAX.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoAdd a make variable for the pkgconfig install dir
David Michael [Wed, 7 May 2014 03:05:17 +0000 (23:05 -0400)]
Add a make variable for the pkgconfig install dir

Adding the pkgconfigdir variable allows specifying an installation
location for pkg-config files independent of libdir.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoFix cross compilation problem in parse-types.sh
Chen Qi [Tue, 6 May 2014 01:08:42 +0000 (21:08 -0400)]
Fix cross compilation problem in parse-types.sh

The checking of types in parse-types.sh doesn't make much sense in a
cross-compilation environment, because the generated binary is
executed on build machine.

So even if asm_types.h has got correct statements for types, it's
possible that the generated binary will report an error, because these
types are for the target machine.

Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs: check for a partition table and warn if present
Theodore Ts'o [Mon, 5 May 2014 05:22:22 +0000 (01:22 -0400)]
mke2fs: check for a partition table and warn if present

This supercedes the "whole disk" check, since it does a better job and
there are times when it is quite legitimate to want to use the whole
disk.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: print extra information about existing ext2/3/4 file systems
Theodore Ts'o [Mon, 5 May 2014 04:20:31 +0000 (00:20 -0400)]
mke2fs: print extra information about existing ext2/3/4 file systems

The basic idea is to provide a bit more context in this situation:

% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
Proceed anyway? (y,n)

... by adding this bit of context:

% ./misc/mke2fs -t ext4 /dev/sdc3
mke2fs 1.42.9 (4-Feb-2014)
/dev/sdc3 contains a ext4 file system
last mounted on /SOX-backups on Mon May  5 08:59:53 2014
Proceed anyway? (y,n)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: print a message when creating a regular file
Theodore Ts'o [Mon, 5 May 2014 03:40:58 +0000 (23:40 -0400)]
mke2fs: print a message when creating a regular file

We've added the ability to automatically recreate a file if it doesn't
exist prior to creating the file system, since this is often used (for
example) when managing file system images for use in virtual machines.
We should at least notify the user that this is going on to avoid
surprises in the case of misspelled device/file names.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoresize2fs: fix inode table move for the backwards move case
Theodore Ts'o [Mon, 28 Apr 2014 14:07:16 +0000 (10:07 -0400)]
resize2fs: fix inode table move for the backwards move case

In the case where the new location of the inode table is before the
old inode table, the optimization which tries to optimize zero block
moves breaks.  Fix it.

This fixes a bug that was tickled by the reproduction described in the
previous commit.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps
Theodore Ts'o [Mon, 28 Apr 2014 14:03:12 +0000 (10:03 -0400)]
libext2fs: fix alloc_allocate_group_table() if the flexbg_offset wraps

If the previous block group's inode table ends at the very end of file
system, wrap around to the beginning of the flex_bg.

This fixes a bug was tickled by:

mke2fs.conf:
frontload = {
features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2
hash_alg = half_md4
num_backup_sb = 0
packed_meta_blocks = 1
inode_ratio = 4194304
flex_bg_size = 262144
}

mke2fs -T frontload /tmp/foo.img 2T
resize2fs -M /tmp/foo.img
resize2fs -M /tmp/foo.img

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoresize2fs: refine minimum required blocks for flex_bg file systems
Theodore Ts'o [Sun, 27 Apr 2014 19:52:48 +0000 (15:52 -0400)]
resize2fs: refine minimum required blocks for flex_bg file systems

The previous commit exposed bugs in the calculation for flex_bg file
systems.  The problem is that since (by default) we keep the metadata
blocks for the flex_bg in the first block group of the flex_bg, and
because we don't want to overwrite metadata blocks used by the
original file system with data blocks make life easier in case the
resize is aborted for some reason, we need to treat all of the
metadata blocks in the existing flex_bg has in use for the purposes of
calculate_minimum_resize_size().

Even though this means we need to reserve more data blocks to avoid
running out of space, the net result of these two commits is a net
savings in how much we can shrink a file system.

Using the following test sequence:

mke2fs -F -t ext4 /tmp/foo.img 2T
resize2fs -M /tmp/foo.img
resize2fs -M /tmp/foo.img
resize2fs -M /tmp/foo.img

Here is the comparison in the resulting file systems between the old
and new resize2fs (units are in 4k blocks):

                resize #1  resize #2   resize #3
old resize2fs    1117186     45679       43536
new resize2fs      48784     37413       37392

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoresize2fs: fix overly-pessimistic calculation of minimum size required
Theodore Ts'o [Sun, 27 Apr 2014 02:08:02 +0000 (22:08 -0400)]
resize2fs: fix overly-pessimistic calculation of minimum size required

For extent-mapped file systems, we need to reserve some extra space in
case we need to grow the extent tree.  Calculate the safety margin
more intelligently, so we don't overestimate the amount of space
required.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Dmitry Monakhov <dmonakhov@openvz.org>
10 years agoe2fsck: if any problems are fixed in pass 0, check the whole file system
Theodore Ts'o [Sun, 27 Apr 2014 03:14:47 +0000 (23:14 -0400)]
e2fsck: if any problems are fixed in pass 0, check the whole file system

If there are any PREEN_OK problems fixed in check_super_block(), don't
skip checking the full file system.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsprogs/filefrag: print shared extent flag
Mark Fasheh [Sun, 27 Apr 2014 00:23:00 +0000 (20:23 -0400)]
e2fsprogs/filefrag: print shared extent flag

Filefrag doesn't catch and print the shared extent flag. Add this for
users of filefrag on file systems with shared extents (such as btrfs).

Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: only print the low-level file system stats in verbose mode
Theodore Ts'o [Sat, 26 Apr 2014 23:00:50 +0000 (19:00 -0400)]
mke2fs: only print the low-level file system stats in verbose mode

Also print the file system UUID if it is non-NULL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: check for pre-existing file system
Theodore Ts'o [Sat, 26 Apr 2014 22:42:31 +0000 (18:42 -0400)]
mke2fs: check for pre-existing file system

Warn the system administrator if there is an existing file system on
the block device, and give the administrator an opportunity to abort
the mkfs operation.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: add an option in mke2fs.conf to proceed after a delay
Theodore Ts'o [Sat, 26 Apr 2014 21:34:52 +0000 (17:34 -0400)]
mke2fs: add an option in mke2fs.conf to proceed after a delay

If mke2fs needs to ask the user for permission, and the user doesn't
type anything the specified delay in the /etc/mke2fs.conf file,
proceed as if the user had said yes.  The default is to do what we
currently do, which is to wait until the user answers the question one
way or the other.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: create a regular file if necessary
Theodore Ts'o [Sat, 26 Apr 2014 20:17:38 +0000 (16:17 -0400)]
mke2fs: create a regular file if necessary

This is useful when creating a filesystem for use with a VM, for
example.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: don't complain if the regular file is too small
Theodore Ts'o [Sat, 26 Apr 2014 19:12:21 +0000 (15:12 -0400)]
mke2fs: don't complain if the regular file is too small

Don't ask the user if it's OK that a regular file is smaller than the
requested size.  This test only makes sense if we are creating the
file system on a block device.  This allow users to not need to
manually answer the "proceed?" question when creating a file system
backed by a simple file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs, tune2fs: call proceed_question() from check_plausibility()'s caller
Theodore Ts'o [Sat, 26 Apr 2014 17:14:32 +0000 (13:14 -0400)]
mke2fs, tune2fs: call proceed_question() from check_plausibility()'s caller

Move the call to proceed_question() from check_plausibility() to its
caller.  This allows more fine grained control by mke2fs about when it
might want to call check_plausibility().

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: don't ask the proceed question using a regular file
Theodore Ts'o [Sat, 26 Apr 2014 16:16:44 +0000 (12:16 -0400)]
mke2fs: don't ask the proceed question using a regular file

Very often people are creating file systems using regular files, so we
shouldn't ask the user to confirm using the proceed question.
Otherwise it encourages users to use the -F flag, which is a bad
thing.

We do need to continue to check if the external journal device is a
block device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: skip low dtime check if the number of inodes > s_mkfs_time
Theodore Ts'o [Tue, 22 Apr 2014 18:14:56 +0000 (14:14 -0400)]
e2fsck: skip low dtime check if the number of inodes > s_mkfs_time

We already skip the low dtime check if the number of inods is greater
than the last mount or last written time.  However, if a very large
file system is resized sufficiently large that the number of inodes is
greater than when the file system was original created, we can end up
running afoul of the low dtime check.  This results in a large number
of false positives which e2fsck can fix up without causing any
problems, but it can induce a large amount of anxiety for the system
administrator.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Patrik Horník <patrik@hornik.sk>
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Mon, 14 Apr 2014 20:37:23 +0000 (16:37 -0400)]
Merge branch 'maint' into next

10 years agotests: fix resize test tmpfs max-file-size checking
Andreas Dilger [Mon, 14 Apr 2014 16:48:16 +0000 (12:48 -0400)]
tests: fix resize test tmpfs max-file-size checking

Old distros may not have the "truncate" tool, so use "dd" instead.

If tmpfs cannot handle a 2GB temp file (e.g. old RHEL5 and SLES 11
kernels) then skip the test instead of failing it.  If this fails,
try to report better error messages instead of failing silently.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agofix miscellaneous build warnings
Andreas Dilger [Mon, 14 Apr 2014 16:20:25 +0000 (12:20 -0400)]
fix miscellaneous build warnings

Fix various unused variable and use-uninitialized warnings.

Add generated files into .gitignore.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs.c: return error when failed to populate fs
Robert Yang [Mon, 14 Apr 2014 15:43:24 +0000 (11:43 -0400)]
mke2fs.c: return error when failed to populate fs

We need return retval when "mke2fs -d" failed, otherwise the "$?"
would be 0 which is misleading.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
10 years agoe4defrag: fix error reporting when ext2fs_open fails
Theodore Ts'o [Fri, 11 Apr 2014 03:16:34 +0000 (23:16 -0400)]
e4defrag: fix error reporting when ext2fs_open fails

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe4defrag: open fs with EXT2_FLAG_64BITS flag
Jon Ernst [Fri, 11 Apr 2014 03:06:35 +0000 (23:06 -0400)]
e4defrag: open fs with EXT2_FLAG_64BITS flag

This allows e4defrag to work with 64-bit and bigalloc file systems.

Signed-off-by: Jon Ernst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Tue, 8 Apr 2014 23:26:45 +0000 (19:26 -0400)]
Merge branch 'maint' into next

10 years agolibext2fs: fix build errors on bigendian hosts
Eryu Guan [Thu, 27 Mar 2014 10:17:24 +0000 (18:17 +0800)]
libext2fs: fix build errors on bigendian hosts

Fix the following build errors on bigendian hosts.

- ctx is a pointer, use '->' not '.'
- add missing argument to ext2fs_dirent_swab_in2

make[2]: Entering directory `/root/e2fsprogs/lib/ext2fs'
        CC inline_data.c
inline_data.c: In function â€˜ext2fs_inline_data_dir_iterate’:
inline_data.c:221:5: error: request for member â€˜errcode’ in something not a structure or union
  ctx.errcode = ext2fs_dirent_swab_in2(fs, ctx->buf, ctx->buflen, 0);
     ^
inline_data.c:222:9: error: request for member â€˜errcode’ in something not a structure or union
  if (ctx.errcode) {
         ^
inline_data.c: In function â€˜ext2fs_inline_data_dir_expand’:
inline_data.c:364:2: error: too few arguments to function â€˜ext2fs_dirent_swab_in2’
  retval = ext2fs_dirent_swab_in2(fs, buf, size);
  ^
In file included from inline_data.c:19:0:
ext2fs.h:1569:18: note: declared here
 extern errcode_t ext2fs_dirent_swab_in2(ext2_filsys fs, char *buf, size_t size,
                  ^
make[2]: *** [inline_data.o] Error 1

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
10 years agologsave: make message when process has a non-zero exit code to be less scary
Theodore Ts'o [Sat, 29 Mar 2014 14:25:49 +0000 (10:25 -0400)]
logsave: make message when process has a non-zero exit code to be less scary

Addresses-Debian-Bug: #468821

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: print runs of duplicate blocks instead of all of them
Darrick J. Wong [Sat, 15 Mar 2014 16:12:35 +0000 (12:12 -0400)]
e2fsck: print runs of duplicate blocks instead of all of them

When pass1 finds blocks that are mapped to multiple files, it will
print every duplicated block.  If there are long sequences of
duplicate blocks (e.g. the e_pblk field is wrong in an extent), this
can cause a gigantic flood of output when a range could convey the
same information.  Therefore, teach pass1b to print ranges when
possible.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix parents when modifying extents
Darrick J. Wong [Sat, 15 Mar 2014 15:36:34 +0000 (11:36 -0400)]
libext2fs: fix parents when modifying extents

In ext2fs_extent_set_bmap() and ext2fs_punch_extent(), fix the parents
when altering either end of an extent so that the parent nodes reflect
the added mapping.

There's a slight complication to using fix_parents: if there are two
mappings to an lblk in the tree, the value of handle->path->curr can
point to either extent afterwards), which is documented in a comment.

Some additional color commentary from Darrick:

  In the _set_bmap() case, I noticed that the "remapping last block in
  extent" case would produce symptoms if we are trying to remap a
  block from "extent" to "next_extent", and the two extents are
  pointed to by different index nodes.  _extent_replace(...,
  next_extent) updates e_lblk in the leaf extent, but because there's
  no _extent_fix_parents() call, the index nodes never get updated.

  In the _punch_extent() case, we conclude that we need to split an
  extent into two pieces since we're punching out the middle.  If the
  extent is the last extent in the block, the second extent will be
  inserted into a new leaf node block.  Without _fix_parents(), the
  index node doesn't seem to get updated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix memory leak when drastically shrinking extent tree depth
Darrick J. Wong [Fri, 14 Mar 2014 13:56:33 +0000 (09:56 -0400)]
libext2fs: fix memory leak when drastically shrinking extent tree depth

In ext2fs_extent_free(), h(andle)->max_depth is used as a loop
conditional variable to free all the h->path[].buf pointers.  However,
ext2fs_extent_delete() sets max_depth = 0 if we've removed everything
from the extent tree, which causes a subsequent _free() to leak some
buf pointers.  max_depth can be re-incremented when splitting extent
nodes, but there's no guarantee that it'll reach the old value before
the free.

Therefore, remember the size of h->paths[] separately, and use that
when freeing the extent handle.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomisc: fix header complaints and resource leaks in e2fsprogs
Darrick J. Wong [Fri, 14 Mar 2014 13:43:11 +0000 (09:43 -0400)]
misc: fix header complaints and resource leaks in e2fsprogs

Fix a few minor bugs that cppcheck complained about.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix 64bit overflow in ext2fs_block_alloc_stats_range
Darrick J. Wong [Fri, 14 Mar 2014 13:35:01 +0000 (09:35 -0400)]
libext2fs: fix 64bit overflow in ext2fs_block_alloc_stats_range

In ext2fs_block_alloc_stats_range(), the quantity "-inuse * n" is
calculated as a signed 32-bit quantity.  Unfortunately, gcc (4.6.3 on
Ubuntu 12.04) doesn't sign-extend this quantity to fill the blk64_t
parameter that ext2fs_free_blocks_count_add() wants, so the end result
is that the superblock gets a ridiculously huge free block count.

Changing the declaration of 'n' to blk64_t seems to fix this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomisc: cppcheck cleanups
Darrick J. Wong [Fri, 14 Mar 2014 13:34:10 +0000 (09:34 -0400)]
misc: cppcheck cleanups

Fix a number of things that cppcheck complains about.  Most of these
are minor resource leaks and forgotten declarations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoall: Introduce cppcheck static checking for make C=1
Darrick J. Wong [Fri, 14 Mar 2014 13:32:48 +0000 (09:32 -0400)]
all: Introduce cppcheck static checking for make C=1

Introduce more static checking via cppcheck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoresize2fs: add inline dirs for remapping
Darrick J. Wong [Fri, 14 Mar 2014 13:31:02 +0000 (09:31 -0400)]
resize2fs: add inline dirs for remapping

When we're looking for directory blocks for the inode remapping step,
we need to include inline_data directories in the remap process.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: repair side effects when iterating dirents in inline dirs
Darrick J. Wong [Fri, 14 Mar 2014 13:30:17 +0000 (09:30 -0400)]
libext2fs: repair side effects when iterating dirents in inline dirs

In ext2fs_inline_data_dir_iterate(), we must be very careful to undo
any modifications we make to the dir_context pointer passed in by the
caller, because it's entirely possible that the caller will still want
to do something with the ctx or something inside.

Specifically, ext2fs_dblist_dir_iterate() wants to be able to free
ctx->buf, and it reuses the ctx for multiple dblist entries.  That
means that assigning ctx->buf will cause weird crashes at the end of
dir_iterate().

Since we're being careful with ctx, we might as well handle adding the
INLINE_DATA flag to ctx->flags for ext2fs_process_dir_block, since the
dblist caller forgets to unset the flag before reusing the ctx.

This fixes some crashes and valgrind complaints in resize2fs, and is
necessary for the next patch, which fixes resize2fs not to corrupt
inline_data filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: during inlinedata expand, don't corrupt inode
Darrick J. Wong [Fri, 14 Mar 2014 13:28:13 +0000 (09:28 -0400)]
libext2fs: during inlinedata expand, don't corrupt inode

When expanding an inline data inode, it's possible that the reduction
in the size of the EA structures causes the freeing of the EA block,
which changes the inode.  If this happens, the local version of the
inode that ext2fs_inline_data_expand was modifying will be out of sync
with what's on the disk.  This local copy gets written out to disk
after a block allocation, at which point it's possible that the inode
EA block and logical block zero point to the same physical block,
which is bad news.

Therefore, write the local copy to disk before removing the inline
data EA, and reread it afterwards.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: zero errcode when checking inline data blocks
Darrick J. Wong [Fri, 14 Mar 2014 13:26:21 +0000 (09:26 -0400)]
e2fsck: zero errcode when checking inline data blocks

When checking inline data blocks, always zero pctx->errcode because
otherwise a previous error condition could leak through and "cause" a
fatal block iteration failure.  I found this by corrupting an xattr
block on an inline_data inode and fsck aborted when I tried to repair
it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix iblocks correctly when expanding an inline_data file
Darrick J. Wong [Fri, 14 Mar 2014 13:23:21 +0000 (09:23 -0400)]
libext2fs: fix iblocks correctly when expanding an inline_data file

i_blocks covers the number of blocks allocated to an inode for data,
extents, and ACL blocks.  Since it's possible for a file to have a
separate ACL block and inline data, we must be careful when expanding
an inline data file to adjust, not set, the value of i_blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: don't fail when doing a strict rewrite of inline data
Darrick J. Wong [Fri, 14 Mar 2014 13:23:03 +0000 (09:23 -0400)]
libext2fs: don't fail when doing a strict rewrite of inline data

ext2fs_inline_data_set() tries to ensure that there is sufficient free
space in the inode to store the inline data.  Unfortunately, it gets
the check wrong -- ext2fs_xattr_inode_max_size() returns the amount of
unused bytes in the EA area, and _data_set() doesn't factor in the
size of the existing inline data.  Therefore, a strict rewrite of an
N-byte inlinedata with another N-byte inlinedata fails.

Fix the code to do the size check correctly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: don't rehash inline directories
Darrick J. Wong [Fri, 14 Mar 2014 13:16:20 +0000 (09:16 -0400)]
e2fsck: don't rehash inline directories

If a directory's contents are stored entirely inside the inode,
there's no index to rebuild and no dirblock checksum to recompute.
As far as I know these are the only two reasons to call dir rehash.

Therefore, we can move on to the next dir instead of what we do right
now, which is try to iterate the dir blocks (which of course fails due
to the inline_data iflag being set) and then flood stdout with useless
messages that aren't even failures.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: fix build failure on big endian systems
Theodore Ts'o [Thu, 13 Mar 2014 17:40:37 +0000 (13:40 -0400)]
libext2fs: fix build failure on big endian systems

Fix a typo that we didn't notice because all the world's an x86.  :-)

Reported-by: jon ernst <jonernst07@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebugfs: create commands to edit extended attributes
Darrick J. Wong [Wed, 12 Mar 2014 03:49:58 +0000 (23:49 -0400)]
debugfs: create commands to edit extended attributes

Enhance debugfs to be able to display and modify extended attributes, and
create some simple tests for the extended attribute editing functions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agodebugfs, libext2fs: minor fixups to xattr support
Darrick J. Wong [Wed, 12 Mar 2014 03:49:13 +0000 (23:49 -0400)]
debugfs, libext2fs: minor fixups to xattr support

Add magic number checking to the extended attribute editing handle;
move inline data to the head of the attribute list when writing so
that inline data ends up in the inode area; and always zero the
attribute space before writing to ensure that we can delete the last
xattr.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agocreate_inode: fix gcc -Wall complaints
Theodore Ts'o [Wed, 12 Mar 2014 03:40:17 +0000 (23:40 -0400)]
create_inode: fix gcc -Wall complaints

We had several functions that were not returning zero on success.  Fix
this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agocreate_inode: handle hard link inum mappings per populate_fs invocation
Darrick J. Wong [Wed, 12 Mar 2014 03:34:41 +0000 (23:34 -0400)]
create_inode: handle hard link inum mappings per populate_fs invocation

When calling populate_fs, the map for hardlink detection is not
cleaned up between populate_fs invocations, which could lead to
unexpected results if anyone calls populate_fs twice in the same
client program).  This doesn't happen right now, but we might as well
clean it up.

The detctor fails if the external directory crosses mountpoints,
so fix that too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agocreate_inode: move debugfs internal state back to debugfs
Darrick J. Wong [Tue, 11 Mar 2014 06:54:23 +0000 (23:54 -0700)]
create_inode: move debugfs internal state back to debugfs

Since create_inode.c is shared between debugfs and mke2fs, don't
spread debugfs internal state into mke2fs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agocreate_inode: whitespace fixes
Darrick J. Wong [Wed, 12 Mar 2014 03:26:58 +0000 (23:26 -0400)]
create_inode: whitespace fixes

Fix a ton of whitespace issues.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agocreate_inode: minor cleanups
Darrick J. Wong [Wed, 12 Mar 2014 03:25:06 +0000 (23:25 -0400)]
create_inode: minor cleanups

Fix a couple of small style issues in the create_inode files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agocreate_inode: clean up return mess in do_write_internal
Darrick J. Wong [Wed, 12 Mar 2014 03:10:32 +0000 (23:10 -0400)]
create_inode: clean up return mess in do_write_internal

do_write_internal returns errno when ext2 library calls fail; since
errno only reflects the outcome of the last C library call, this will
result in confused callers.  Eliminate the naked return since
this results in an undefined return value.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoUpdate Makefile dependencies
Theodore Ts'o [Thu, 6 Mar 2014 16:26:41 +0000 (11:26 -0500)]
Update Makefile dependencies

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoMerge branch 'ry/mke2fs-populate' into next
Theodore Ts'o [Thu, 6 Mar 2014 16:22:42 +0000 (11:22 -0500)]
Merge branch 'ry/mke2fs-populate' into next

Conflicts:
debugfs/debugfs.c

10 years agomke2fs.8.in: update the manual for the -d option
Robert Yang [Thu, 6 Mar 2014 16:00:25 +0000 (11:00 -0500)]
mke2fs.8.in: update the manual for the -d option

Update the manual for the -d option

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agodebugfs: use the functions in misc/create_inode.c
Robert Yang [Thu, 6 Mar 2014 16:00:25 +0000 (11:00 -0500)]
debugfs: use the functions in misc/create_inode.c

* Use the functions in misc/create_inode.c, and remove the duplicated
  code.

* The CREATE_INODE_DEPS in the debugfs/Makefile.in is used for recording
  create_inode.o's depends which is from misc/Makefile.in, we have to
  recompile create_inode.o because we need it to print more messages when
  it is used by debugfs, just like we recompile e2freefrag.o, but it seems
  that the e2freefrag.o's depends in debugfs/Makefile.in is incorrect, it
  would not rebuild when its depends (e.g.: lib/config.h) is changed,
  which would cause unexpected errors. Make duplicated code in
  debugfs/Makefile.in and misc/Makefile.in is not a good idea, maybe we'd
  better define CREATE_INODE_DEPS in the top Makefile, I'd like to send
  another patch and fix the e2freefrag if you are fine with it.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: handle hardlinks
Robert Yang [Thu, 6 Mar 2014 16:00:25 +0000 (11:00 -0500)]
misc/create_inode.c: handle hardlinks

Create the inode and save the native inode number when we meet the hard
link (st_nlink > 1) at the first time, use ext2fs_link() to link the
name to the target inode number when we meet the same native inode
number again.

This algorithm is referred this from the genext2fs.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs.c: add an option: -d root-directory
Robert Yang [Thu, 6 Mar 2014 16:00:25 +0000 (11:00 -0500)]
mke2fs.c: add an option: -d root-directory

This option is used for adding the files from a given directory (the
root-directory) to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: set owner/mode/time for the inode
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: set owner/mode/time for the inode

Set the uid, gid, mode and time for inode.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: create directory
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: create directory

The do_mkdir_internal() is used for making dir on the target fs, most of
the code are from debugfs/debugfs.c, the debugfs/debugfs.c will be
modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: copy regular file
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: copy regular file

The do_write_internal() is used for copying file from native fs to
target, most of the code are from debugfs/debugfs.c, the
debugfs/debugfs.c will be modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: create symlink
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: create symlink

The do_symlink_internal() is used for creating symlinks, most of the
code are from debugfs/debugfs.c, the debugfs/debugfs.c will be modified
to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: create special file
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: create special file

The do_mknod_internal() is used for creating special file which is
block, character and fifo, most of the code are from debugfs/debugfs.c,
the debugfs/debugfs.c will be modified to use this function.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomisc/create_inode.c: copy files recursively
Robert Yang [Thu, 6 Mar 2014 16:00:24 +0000 (11:00 -0500)]
misc/create_inode.c: copy files recursively

Use opendir() and readdir() to read the native directory, then use
lstat() to identify the file type and call the corresponding function to
add the file to the filesystem, call the populate_fs() recursively if it
is a directory.

NOTE: the libext2fs can't create the socket file.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agomke2fs: add the ability to copy files from a given directory
Robert Yang [Thu, 6 Mar 2014 16:00:23 +0000 (11:00 -0500)]
mke2fs: add the ability to copy files from a given directory

We will add a -d option which will be used for adding the files from a
given directory to the filesystem, it is similiar to genext2fs, but
genext2fs doesn't fully support ext4.

* We already have the basic operations in debugfs:
  - Copy regular file
  - Create directory
  - Create symlink
  - Create special file

  We will move these operations into create_inode.h and create_inode.c,
  then let both mke2fs and debugfs use them.

* What we need to do are:
  - Copy the given directory recursively, this will be done by the
    populate_fs()
  - Set the owner, mode and other informations
  - Handle the hard links

TODO:
  - The libext2fs can't create the socket file (S_IFSOCK), do we have a
    plan to support it ?

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Reviewed-by: Darren Hart <dvhart@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agoMerge branch 'maint' into next
Theodore Ts'o [Thu, 6 Mar 2014 15:53:34 +0000 (10:53 -0500)]
Merge branch 'maint' into next

10 years agomke2fs: disable resize_inode feature if 64bit feature is enabled
Eryu Guan [Thu, 4 Jul 2013 09:05:10 +0000 (17:05 +0800)]
mke2fs: disable resize_inode feature if 64bit feature is enabled

Since auto_64-bit_support is on by default, resize_inode feature will
be disabled when creating a >16T ext4 according to mke2fs.conf(5).

This should also be done when making ext4 with "-O 64bit" to enable
64bit feature explicitly. Otherwise online resize to enlarge a
over-16T fs to larger would fail.

[root@localhost resize]# truncate -s 50t fs.img
[root@localhost resize]# losetup /dev/loop0 fs.img
[root@localhost resize]# mkfs -t ext4 -O 64bit /dev/loop0 30t
[root@localhost resize]# mount /dev/loop0 mnt
[root@localhost resize]# resize2fs /dev/loop0
resize2fs 1.42.7 (21-Jan-2013)
Filesystem at /dev/loop0 is mounted on /root/resize/mnt; on-line resizing required
old_desc_blocks = 3840, new_desc_blocks = 6400
resize2fs: Invalid argument While checking for on-line resizing support

And dmesg shows
[688378.442623] EXT4-fs (loop0): resizing filesystem from 6710886400 to 13421772800 blocks
[688378.443216] EXT4-fs warning (device loop0): verify_reserved_gdb:700: reserved GDT 3201 missing grp 177147 (5804756097)
[688378.443222] EXT4-fs (loop0): resized filesystem to 8858370048
[688378.528451] EXT4-fs warning (device loop0): ext4_group_extend:1710: can't shrink FS - resize aborted

With this fix resize2fs could do the online enlarge correctly.

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: don't use e2fsck_global_ctx in e2fsck_set_bitmap_type()
Theodore Ts'o [Wed, 5 Mar 2014 00:10:26 +0000 (19:10 -0500)]
e2fsck: don't use e2fsck_global_ctx in e2fsck_set_bitmap_type()

There is no reason to use e2fsck_global_ctx in
e2fsck_set_bitmap_type(), since we can get the context structure from
fs->priv_data.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: always make sure e2fsck_global_ctx is set
Theodore Ts'o [Wed, 5 Mar 2014 00:05:00 +0000 (19:05 -0500)]
e2fsck: always make sure e2fsck_global_ctx is set

The e2fsck_global_ctx varible was only being set if HAVE_SIGNAL_H is
defined.  There are systems, such as Android, where this is not true.

This was causing e2fsck_set_bitmap_type() to seg fault since
e2fsck_global_ctx was not NULL.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: JP Abgrall <jpa@google.com>
10 years agolibext2fs: add a unit test for inline data
Zheng Liu [Mon, 3 Mar 2014 06:03:52 +0000 (01:03 -0500)]
libext2fs: add a unit test for inline data

In this unit test, we will test the interface of inline data and make
sure it is fine.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: export inode cache creation function
Zheng Liu [Mon, 3 Mar 2014 06:03:24 +0000 (01:03 -0500)]
libext2fs: export inode cache creation function

Currently we have already exported inode cache flush and free functions
for users.  This commit exports inode cache creation function.  Later
we will use this function to initialize inode cache and do some unit
tests for inline data.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: enable inline_data feature on ext4dev filesystem
Zheng Liu [Mon, 3 Mar 2014 06:03:16 +0000 (01:03 -0500)]
mke2fs: enable inline_data feature on ext4dev filesystem

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agotests: change result in f_bad_disconnected_inode
Zheng Liu [Mon, 3 Mar 2014 06:02:59 +0000 (01:02 -0500)]
tests: change result in f_bad_disconnected_inode

In this test, inode flag is some random data, and after we apply inline
data patch set we should need to handle it.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: check inline_data in pass3
Zheng Liu [Mon, 3 Mar 2014 06:02:52 +0000 (01:02 -0500)]
e2fsck: check inline_data in pass3

In e2fsck_expand_directory() we don't handle a dir with inline data
because when this function is called the directory inode shouldn't
contains inline data.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: check inline_data in pass2
Zheng Liu [Mon, 3 Mar 2014 06:02:44 +0000 (01:02 -0500)]
e2fsck: check inline_data in pass2

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: check inline_data in pass1
Zheng Liu [Mon, 3 Mar 2014 06:02:36 +0000 (01:02 -0500)]
e2fsck: check inline_data in pass1

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agoe2fsck: add problem descriptions and check inline data feature
Zheng Liu [Mon, 3 Mar 2014 06:02:28 +0000 (01:02 -0500)]
e2fsck: add problem descriptions and check inline data feature

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agomke2fs: add inline_data support in mke2fs
Zheng Liu [Mon, 3 Mar 2014 06:02:14 +0000 (01:02 -0500)]
mke2fs: add inline_data support in mke2fs

Now inline_data doesn't depend on ext_attr.  Hence we don't need to do
this sanity check.  But if the inode size is too small (128 bytes),
inline_data will be useless because we couldn't save data in ibody
extented attribute.  So we need to report this error.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
10 years agolibext2fs: add inline_data feature into EXT2_LIB_FEATURE_INCOMPAT_SUPP
Zheng Liu [Mon, 3 Mar 2014 05:35:51 +0000 (00:35 -0500)]
libext2fs: add inline_data feature into EXT2_LIB_FEATURE_INCOMPAT_SUPP

Let e2fsprogs support inline_data feature.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agolibext2fs: handle inline data in read/write function
Zheng Liu [Mon, 3 Mar 2014 05:35:51 +0000 (00:35 -0500)]
libext2fs: handle inline data in read/write function

Currently ext2fs_file_read/write are used to copy data from/to a file.
But they manipulate data by blocksize.  For supporting inline data, we
handle it in two new fucntions called ext2fs_file_read/write_inline_data.

In read path the implementation is straightforward.  But in write path
things get more complicated because if the size of data is greater than
the maximum size of inline data we will expand this file.  So now we
will check this in ext2fs_inline_data_set.  If this inode doesn't have
enough space, it will return EXT2_ET_INLINE_DATA_NO_SPACE error.  Then
the caller will check this error and tries to expand the file.

The following commands in debugfs can handle inline_data feature after
applying this patch:
- dump
- cat
- rdump
- write

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 years agodebugfs: handle inline data feature in punch command
Zheng Liu [Mon, 3 Mar 2014 05:34:40 +0000 (00:34 -0500)]
debugfs: handle inline data feature in punch command

Now punch command only can remove all inline data because now
punch command is based on block unit and the size of inline data is
never beyond a block size.

Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>