Commit Graph

1156 Commits (6d82e1f4c7af427975009063d387f66cf9672962)

Author SHA1 Message Date
Eric Sandeen 80f4b3ae49 fsck: fix -C option parsing
The i++; statement is unreachable; fix same as commit
f1c2eaac535bd9172a35ce39b6d8f392321f274d in util-linux

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-16 18:43:04 -04:00
Theodore Ts'o 2418dfd7b9 dumpe2fs: display "free blocks" as "free clusters" for bigalloc file systems
Change this for the equivalent function in debugfs as well.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-16 10:13:41 -04:00
Theodore Ts'o 75405ffde6 Merge branch 'maint' into next 2011-09-16 00:00:04 -04:00
Lukas Czerner d2bfdc7ff1 e2fsprogs: Use punch hole as "discard" on regular files
If e2fsprogs tools (mke2fs, e2fsck) is run on regular file instead of
on block device, we can use punch hole instead of regular discard
command which would not work on regular file anyway. This gives us
several advantages. First of all when e2fsck is run with '-E discard'
parameter it will punch out all ununsed space from the image, hence
trimming down the file system image. And secondly, when creating an
file system on regular file (with '-E discard' which is default), we
can use punch hole to clear the file content, hence we can skip inode
table initialization, because reads from sparse area returns zeros. This
will result in faster file system creation (without the need to specify
lazy_itable_init) and smaller images.

This commit also fixes some tests that would fail due to mke2fs showing
discard progress, hence the output would differ.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:49:20 -04:00
Lukas Czerner c859cb1de0 e2fsprogs: create open() and stat() helpers
In many places we are using #ifdef HAVE_OPEN64 to determine if we can
use open64() but that's ugly. This commit creates two new helpers
ext2fs_open_file() for open() and ext2fs_stat() for stat(). Also we need
new typedef ext2fs_struct_stat for struct stat.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:46:57 -04:00
Yury V. Zaytsev 45792c1276 mke2fs: check that auto-detected blocksize <= sys_page_size
Block size can be specified manually via the -b option or deduced
automatically. Unfortunately, the check that it is still smaller than
the system page size is only performed right after the command line
options are parsed.

Therefore, if buggy or inappropriately installed/configured hardware
hints that larger block sizes have to be used, mkfs will silently create
a file system which can not be mounted on the system in question.

By moving the check beyond the last assignment to blocksize it is now
ensured, that mkfs will issue a warning even if inappropriate blocksize
was auto-detected.

The new behavior can be easily tested, by exporting the following
variables before running mkfs:

    export MKE2FS_DEVICE_SECTSIZE=8192
    export MKE2FS_DEVICE_PHYS_SECTSIZE=8192

Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:46:27 -04:00
Surbhi Palande 57cb271642 mke2fs.8: Fix the documentation of maximum journal size
Fix the max journal size in mke2fs man page.

Signed-off-by: Surbhi Palande <csurbhi@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-15 23:35:18 -04:00
Theodore Ts'o 7fef2bb11f badblocks: update man page's description of the -v option
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15 19:33:34 -04:00
Theodore Ts'o b715080757 mke2fs: use "extent" consistently as a feature name in the man page
Addresses-Debian-Bug: #639411

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-15 14:25:51 -04:00
Lukas Czerner 9d10f017e2 e2image: fix invalid lseek error detection
In flush_l2_cache() we are using ext2fs_llseek() however we do not
properly detect the error code returned from the function, because we
are assigning it into ULL variable, hence we will not see negative
values.

Fix this by changing the type of the variable to ext2_loff_t which is
signed and hence will store negative values.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-14 13:49:04 -04:00
Theodore Ts'o 478113973e mke2fs.static: change library ordering to avoid a link error
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-09-13 23:03:17 -04:00
Lukas Czerner faa2dcdad0 mke2fs: Use ext2fs_flush() only once
We are doing ext2fs_flush() twice right now at the end of the mke2fs.
First by directly calling ext2fs_flush() which is intended to write
superblock and fs accounting information. And then it is invoked again
when we are calling ext2fs_close(), only this time, because the fs is
not dirty, we are writing out only superblock.

I think it is bad to call it twice because even when writing only super
block it takes some time on bigger file systems and moreover
ext2fs_close() can fail without any reasonable explanation for the user.
Also ext2fs_flush() is printing out progress and it is confusing for the
users.

Fix all this by removing the ext2fs_flush() and leaving it all to
ext2fs_close(). However we need to introduce new variables to store
check interval and max mount count, because fs structure is freed on
ext2fs_close() and we really want to print those information as the last
info for the user.

[ Fixed type mismatch in a printf format statement -tytso]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-09-13 22:42:19 -04:00
Aditya Kali 771e8db9f0 tune2fs: Add support for turning on quota feature
This patch adds support for setting the quota feature in superblock
and allows selectively creating quota inodes (user or group or both)
in the superblock. Currently, modifying the quota feature is only
supported when the filesystem is unmounted.
Also, when setting the quota feature, tune2fs will use aquota.user or
aquota.group file inode number in superblock if these files exist.
Otherwise it will initialize empty quota inodes #3 and #4 and use them.

Here is how it works:
 # Set quota feature and initialize both (user and group) quota inodes
 $ tune2fs -O quota /dev/ram1

 # Enable only one type of quota
 $ tune2fs -Q usrquota /dev/ram1

 # Enable grpquota, disable usrquota
 $ tune2fs -Q ^usrquota,grpquota /dev/ram1

 # Clear quota feature and remove quota inodes
 $ tune2fs -O ^quota /dev/ram1

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-08-31 18:08:42 -04:00
Aditya Kali 1f5d7a890e mke2fs: support creation of filesystem with quota feature
mke2fs also creates quota inodes (userquota: inode# 3 and
groupquota: inode #4) inodes while creating a filesystem when 'quota'
feature is set.
 # To set quota feature and initialize quota inodes during mke2fs:
 $mke2fs -t ext4 -O quota /dev/ram1

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-08-31 16:31:49 -04:00
Andreas Dilger d4c0d8e5b8 mke2fs: document stripe_width, not stripe-width
For consistency with other multi-word options, document the extended
option stripe_width instead of stripe-width.  This also avoids the
complexity of parsing options that have an embedded '-'.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-07-17 23:13:47 -04:00
Theodore Ts'o f37901a22d Merge branch 'maint' into next
Conflicts:
	misc/tune2fs.c
2011-07-04 20:51:19 -04:00
Theodore Ts'o 5b734a0e71 mke2fs: allow setting the stride and stripe width to zero
Mke2fs previously would give an error if the user tried setting the
stride and stripe-width parameters to zero; but this is necessary to
override the stride and stripe-width settings which get automatically
set from the block device's geometry information in sysfs.  So allow
setting these parameters to zero.

Addresses-Google-Bug: #4988555

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-04 20:43:39 -04:00
Theodore Ts'o 9a976ac732 tune2fs: Fix mount_opts handling
The extended options parsing for mount_opts was horribly buggy.
Invalid mount options that had an argument would get interpreted as an
extended mount options.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-04 20:14:35 -04:00
Theodore Ts'o 035f32ab17 tune2fs: allow setting the stride and stripe width to zero
Tune2fs previously would give an error if the user tried setting the
stride and stripe-width parameters to zero; but this is necessary to
disable the stride and stripe-width settings.  So allow setting these
superblock fields to zero.

Addresses-Google-Bug: #4988557

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-07-04 19:37:11 -04:00
Theodore Ts'o 1ca87790b9 libext2fs: fix makefile dependency problem
lib/ext2fs/Makefile.in had a buggy entry for blkmap64_ba.c in $(SRCS),
which caused this source file to not have a valid Makefile dependency
entry, so blkmap64_ba.o would not get rebuilt when it needed to be.

Also updated the Makefile dependency for the misc directory while
we're at it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-19 21:58:20 -04:00
Theodore Ts'o b12a0bc301 mke2fs: change bigalloc default cluster size to 16*blocksize
This was the original default, but it accidentally got changed to
4*blocksize in commit 4c2b28ab67.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16 10:11:06 -04:00
Theodore Ts'o fe75afbf33 Fix superblock field s_blocks_count for bigalloc file systems
Treat the s_blocks_count field in the superblock as a free block count
(instead of the number of free clusters) for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-16 01:38:43 -04:00
Andreas Dilger 96367ad3bc misc: quiet "unused variable" compiler warnings
Some of the newly-merged patches added "unused variable" compiler
warnings.  Delete unused variables.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-15 22:17:38 -04:00
Theodore Ts'o 2d34a25f81 mke2fs: add support for cluster size in mke2fs.conf
Add support for specifying the cluster size in mke2fs.conf

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-14 14:32:48 -04:00
Theodore Ts'o 4c2b28ab67 mke2fs: Add support for [devices] stanza in mke2fs.conf
Add the [devices] stanza which allows device-specific defaults to be
specified in the mke2fs.conf file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-14 14:32:41 -04:00
Andreas Dilger 6c54689fad mke2fs: skip zeroing journal blocks
Add the ability to skip zeroing journal blocks on disk.  This can
significantly speed up mke2fs with large journals.  At worst the
uninitialized journal is only a very short-term risk (if at all),
because the journal will be overwritten on any new filesystem as
soon as any significant amount of data is written to disk, and
the new journal TID would need to match the offset/TID of an old
commit block still left on disk.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 12:19:12 -04:00
Andreas Dilger 25bc8c756f tune2fs: add dir_index feature to tune2fs man page
Add description of missing dir_index feature to tune2fs(8) man page.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-11 11:29:54 -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 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 f16f9d92aa Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.c
2011-06-07 13:38:38 -04:00
Andreas Dilger 8185ab9f38 mke2fs: Don't erase flash device if "-n" is given
If "mke2fs -n" is used, there should be no changes to the underlying
device.  Unfortunately, when the "discard" option was added in commit
c7cd908be5, it did not check for the "-n"
flag, and will discard all data on a flash device even if "-n" is given.

Check for the "noaction" flag before discarding any filesystem data.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-06-07 13:37:03 -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 bcb942c201 dumpe2fs: teach dumpe2fs to be cluster aware
Add support to dumpe2fs so it can display the block bitmaps correctly
for bigalloc file systems.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-06-04 20:06:32 -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 3977a4ff5b Merge branch 'maint' into next
Conflicts:
	misc/tune2fs.c
2011-05-31 20:08:58 -04:00
Kazuya Mio 2972b16376 tune2fs: Fix overflow of interval check
Add the check of maximum check interval.
s_checkinterval is 32bit variable, so it cannot be set more than 2^32.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-31 20:07:38 -04:00
Kazuya Mio b1503c446a e2fsprogs: Unify the upper limit of reserved blocks count
In e2fsprogs, the upper limit of reserved blocks count is a half of
filesystem's blocks count. This patch fixes the incorrect checks of
reserved blocks count.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-31 20:07:38 -04:00
Eric Sandeen d568782ade mke2fs: don't set stripe/stride to 1 block
Block devices may set minimum or optimal IO hints equal to
blocksize; in this case there is really nothing for ext4
to do with this information (i.e. search for a block-aligned
allocation?) so don't set fs geometry with single-block
values.

Zeev also reported that with a block-sized stripe, the
ext4 allocator spends time spinning in ext4_mb_scan_aligned(),
oddly enough.

Reported-by: Zeev Tarantov <zeev.tarantov@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18 13:19:57 -04:00
Lukas Czerner 92dcfb7692 e2image: Support for conversion QCOW2 image into raw
This commit adds support for converting QCOW2 image created previously
with e2image into raw image. The QCOW2 image is detected automatically,
so there is not new option. Just use following command:

  e2image -r image.qcow image.raw

No that this tool is aimed to quickly convert qcow2 image created with
e2image into raw image. In order to improve speed we are doing some
assumption I believe might not be true for regular qcow2 images. So it
was not tested with regular QCOW2 images and it might not work with
them. The intention of this tool is only convert images previously
created by e2image.

Note that there is nothing special with QCOW2 images created by e2images
and it can be used with tools like qemu-img, or qemu-nbd without any
problems.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-18 11:53:11 -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
Aditya Kali d3859af33f mke2fs: Allow specifying reserved_ratio via mke2fs.conf
This patch adds support for specifying 'reserved_ratio' (percent blocks
reserved for super user, same as '-m' command line option) in mke2fs.conf.
It adds profile_get_double function in profile.c that allows reading
floating point values from profile files.

Signed-off-by: Aditya Kali <adityakali@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-14 23:34:48 -04:00
Theodore Ts'o b18c5fd51e Merge branch 'maint' into next 2011-05-07 23:24:55 -04:00
Carsten Hey 05950620a8 logsave: Update usage message so it is correct
Addresses-Debian-Bug: #619788
Signed-off-by: Carsten Hey <carsten@debian.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-07 21:21:42 -04:00
Eric Sandeen a8d8432b58 filefrag: count 0 extents properly when verbose
/boot/a: 0 extents found

works properly, but

Filesystem type is: ef53
Filesystem cylinder groups is approximately 61
File size of a is 0 (0 blocks, blocksize 1024)
 ext logical physical expected length flags
a: 1 extent found

yields 1 extent when it should be 0.

Fix this up by special-casing no extents returned in verbose
mode; skip printing the header for the columns too, since there
are no columns to print.

Also, in nonverbose mode we can set fm_extent_count to 0
so that FIEMAP will just query the extent count without gathering
details; clarify this with a comment.

Addresses-RedHat-Bugzilla: 653234
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-05-07 18:34:40 -04:00
Theodore Ts'o 5af9eeaa7d Merge branch 'maint' into next
Conflicts:
	lib/e2p/ls.c
2011-03-18 16:44:37 -04:00
Eric Sandeen d4a9330212 e2fsprogs: man page typo fixes
Fix a few typos in manpages.

Reported-by: Branislav Náter <bnater@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-03-18 15:03: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
Lukas Czerner 7d9e31655f mke2fs: Display progress report during the device discard
For some time now we are doing initial discard of the device prior to
filesystem creation. However, there is no feedback for the user and
hence on some devices with slow TRIM implementation it may appear that
mke2fs is stuck.

This commit introduce new function mke2fs_discard_device(), which is a
wrapper for io_channel_discard(). The discard is done in chunks of
2GB, which seems reasonably well for both slow and fast devices, and
discard progress is reported back to the user.

I gave up on doing fancy things like align discard according to
discard_alignment, checking for discard granularity and computing
estimate time. First of all, because it would require either new ioctl
to retrieve those information or use of libudev library, none of it
seems to be worth it. Regarding discard_granularity, I doubt there is
any sane device with discard granularity that big it would affect this.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 21:55:33 -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
Lukas Czerner 855a77a197 mke2fs: Simple man page nodiscard option correction
It is not true that 'nodiscard' is set as default, so remove this
sentence. The default is 'discard' and it is properly documented in man
page.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-20 21:50:24 -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
Theodore Ts'o 89d4597510 badblocks: Add accounting for different types of errors
When using the -v option, report a breakdown of the number of read,
write, and comparison errors that were found by badblocks.

Thanks to Ragnar Kjørstad for providing this patch.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-20 15:29:51 -05:00
Theodore Ts'o 39791dc0bd badblocks: Fix up recover_block handling in badblocks
If there was a bad block for block #0, badblocks would never switch
back testing blocks more efficiently.  In addition, we were
double-incrementing the blocks to be tested in the read/write test due
to failure to remove code.

Thanks to Ragnar Kjørstad for pointing these problems out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-20 15:19:47 -05:00
Theodore Ts'o 175d43bead Merge branch 'maint' into next 2011-02-18 01:19:05 -05:00
Theodore Ts'o 468d82f430 badblocks: Only report errors when reading/writing one block at a time
With Direct I/O, the kernel can report 0 bytes read even though the
first block has no errors.  So there are any errors, we need try to
read/write blocks one at a time and to get an accurate report.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-18 01:16:03 -05:00
Theodore Ts'o e53e8fb009 badblocks: Add the -B option which forces the use of buffered I/O
If for some reason direct I/O does not work correctly, force the use
of buffered I/O.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-18 01:16:02 -05:00
Theodore Ts'o 7d6840354a badblocks: Fix bug so that O_DIRECT mode is correctly entered
The check to see if the block number is properly aligned was not done
correctly.  Fix this.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2011-02-18 01:09:39 -05:00
Theodore Ts'o 616f68bf77 Merge branch 'maint' into next 2011-02-10 19:04:46 -05:00
Jim Meyering b637f8e7ed filefrag: remove useless assignment
The very next one memset's all bytes of fiemap to 0.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2011-02-06 19:01:25 -05:00
Kazuya Mio 9ac557a1df e4defrag: Use libext2fs to get the correct superblock information
Currently, e4defrag always does byte-swapping when it gets superblock
information, so the calculation of the best extents count is not
correct on little endian machine. This doesn't cause data corruption,
but it may confuse users by showing the wrong extent count.  To solve
this problem, we use ext2fs_open() instead of get_superblock_info()
that is the original function.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-24 16:56:24 -05:00
Theodore Ts'o 8d9c50c557 configure: control whether e4defrag is built/installed via --disable-defrag
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-24 15:19:44 -05:00
Kazuya Mio b07f014fac e4defrag: fix segfault when e4defrag races with unlink/truncate
If a file gets deleted or truncated while e4defrag is trying to
operate on it, it's possible for it seg fault.

Addresses-Red-Hat-Bugzilla: #641926

Reported-by: Michal Piotrowski <mkkp4x4@gmail.com>
Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-24 14:43:13 -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 0f7479b340 mke2fs: don't complain if the fs type "default" is not defined in mke2fs.conf
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-22 18:31:36 -05:00
Theodore Ts'o 9b27e9cc32 mke2fs: take the device size into account when determining the size type
If the file system size was not specified on the command line, we were
always using the usage type "floppy" since we didn't determine the
device size until after calling parse_fs_types().  Doh!

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-22 18:22:40 -05:00
Namhyung Kim 5182ad4c21 mke2fs.8.in: add ENVIRONMENT section
Add ENVIRONMENT section and describe behavior of MKE2FS_SYNC,
MKE2FS_CONFIG, MKE2FS_FIRST_META_BG, MKE2FS_DEVICE_SECTSIZE
and MKE2FS_SKIP_CHECK_MSG.

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 8a1cf3c243 mke2fs: clean up error handling in mke2fs_setup_tdb()
Avoid memory leaks on error paths, and make sure we issue the correct
error messages in the case of (highly) unlikely errors.

Original patch submitted by Namhyung Kim <namhyung@gmail.com>, but
highly rewritten since then.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-21 21:57:02 -05:00
Namhyung Kim 9ec68af7b6 mke2fs: add some error checks into PRS()
Check return value of some functions and exit if unhandled error occurred.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-21 20:31:26 -05:00
Namhyung Kim 22d8ce512f mke2fs: fix determination of size_type
In original code, 'huge' type could not be selected because it
always be caught for 'big' type. Change the ordering.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-21 18:44:56 -05:00
Namhyung Kim 9a2767ffed mke2fs.8.in: add missing "big" and "huge" usage-type description
The commit 493024ea1d ("mke2fs: Fix up the
fs type and feature selection for 64-bit blocks") added 'big' and 'huge'
usage-type but was missing description in man page. Add it.

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-21 18:43:59 -05:00
Theodore Ts'o 74e1211b23 mke2fs: Avoid potential NULL dereference
... in the very unlikely case that e2p_os2string fails to allocate
memory.

Reported-by: Namhyung Kim <namhyung@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-21 18:12:12 -05:00
Theodore Ts'o e163242102 mke2fs: Use ext2fs_div_ceil to simplify write_inode_tables()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-20 10:42:57 -05:00
Theodore Ts'o 25623feab4 Merge branch 'master' into next
Conflicts:
	e2fsck/e2fsck.h
	e2fsck/unix.c
2010-12-16 23:20:11 -05:00
Theodore Ts'o 30c0529d27 e4defrag: Fix the overflow in e4defrag with > 2GB files
The fallocate() interface on 32-bit machines is defined to use off_t,
not loff_t (even though the system call interface is 64-bit clean).
This causes e4defrag to fail on files greater than 2GB.  Fix this by
trying to use fallocate64(), and using the hard-coded syscall if it
does not exist.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-16 22:53:34 -05:00
Kazuya Mio 77e72e2b8e e4defrag: update man page about -c option
Add the description of the size per one extent and the maximum extent size
in ext4 into e4defrag man page.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-13 09:59:07 -05:00
Kazuya Mio 4baacad703 e4defrag: avoid unsuccessful return for an non-privileged user
If non-privileged user runs e4defrag, e4defrag returns an exit status
of 1 despite its success. This patch fixes this problem.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-13 09:59:07 -05:00
Kazuya Mio 02808f7d9a e4defrag: fix file blocks calculation
e4defrag uses st_blocks (struct stat) to calculate file blocks. However,
st_blocks also has meta data blocks in addition to file blocks. So, we
calculate file blocks by sum of the extent length.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-13 09:59:06 -05:00
Kazuya Mio 94d26c267d e4defrag: output size per extent by -c option
e4defrag with -c option outputs "ratio" that means the levels of
fragmentation. However, it's difficult for users to understand, so we will
use size per extent instead of ratio.

Before:
# e4defrag -c /mnt/mp1/file
<File>                                         now/best          ratio
/mnt/mp1/file                                    6/1             0.00%

 Total/best extents                             6/1
 Fragmentation ratio                            0.00%
 Fragmentation score                            0.04
 [0-30 no problem: 31-55 a little bit fragmented: 55- needs defrag]
 This file(/mnt/mp1/file) does not need defragmentation.
 Done.

After:
# e4defrag -c /mnt/mp1/file
<File>                                         now/best       size/ext
/mnt/mp1/file                                    6/1          16666 KB

 Total/best extents                             6/1
 Average size per extent                        16666 KB
 Fragmentation score                            0
 [0-30 no problem: 31-55 a little bit fragmented: 56- needs defrag]
 This file (/mnt/mp1/file) does not need defragmentation.
 Done.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-13 09:57:26 -05:00
Peng Tao ae09b934a7 e4defrag: return more specific error message on ioctl failure
Currently e4defrag relies on the EXT4_IOC_MOVE_EXT ioctl to perform online
defragmentation. However, this iotcl kernel patch is not available before
2.6.30-rc1. e4defrag shall fail without obvious reasons on systems running
older kernels. The patch adds more detailed error message addressing this
issue and prompts users with the minimal kernel version that is needed to
run e4defrag.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-12-13 09:44:57 -05:00
Eric Sandeen 43eb2ad477 e4defrag: skip "rootfs" entry when checking for ext4 filesystem
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-13 09:29:19 -05:00
Darrick J. Wong 90b9dce3e5 e4defrag: open the file to be defragged in read/write mode
Akira Fujita merged a patch into 2.6.33 that adds a requirement that a
file being defragged must be opened with read and write access, so
e2fsprogs needs to satisfy that.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-13 09:23:45 -05:00
Theodore Ts'o 0358c9f9a4 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass4.c
	misc/dumpe2fs.c
	resize/online.c
2010-12-13 09:16:09 -05:00
Andreas Dilger 0e2afdbacc dumpe2fs: fix output for flex_bg bitmap offsets
When running dumpe2fs on a filesystem formatted with flex_bg, it
prints out the relative offsets for the bitmaps and inode table
badly on 64-bit systems, because the offset is computed as a
large positive number instead of being a negative numer (which
will not be printed at all):

Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED]
 Block bitmap at 0x0102 (+4294934786), Inode bitmap at 0x0202 (+4294935042)
 Inode table at 0x037e-0x03fa (+4294935422)

This commit prints out the relative offsets for flex_bg
groups as the offset within the reported group.  This makes it
more clear where the metadata is located, rather than simply
printing some large negative number.

Group 1: (Blocks 0x8000-0xffff) [INODE_UNINIT, ITABLE_ZEROED]
 Block bitmap at 0x0102 (bg #0 +258), Inode bitmap at 0x0202 (bg #0 +514)
 Inode table at 0x037e-0x03fa (bg #0 +894)

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-05 22:20:19 -05:00
Theodore Ts'o 5a2db04637 mke2fs: Fix (minor) memory leaks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-01 18:49:26 -05:00
Theodore Ts'o 2ee4544d07 mke2fs: Fail if the requested file system type is not defined in mke2fs.conf
If the user passes a file system type which is not defined in
mke2fs.conf (i.e., mke2fs -t xfs ...) change mke2fs so that it prints
a warning and aborts the run.  (There is an exception for ext2, since
that file system does not need a special definition in the fs_types
section of the /etc/mke2fs.conf file.)

In addition, print a warning if there are usage types (specified using
the -T option) which are not defined in /etc/mke2fs.conf.

Addresses-Debian-Bug: #594609

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-12-01 18:28:35 -05:00
Lukas Czerner 7361c08e5d mke2fs: Use unix_discard() for discards
There is generic discard function in struct_io_manager, or in
unix_io_manager to be specific. So use this instead of
mke2fs_discard_blocks().

Since mke2fs_discard_blocks() is not used anymore (and should not be)
remove it.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-11-22 21:14:28 -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
Theodore Ts'o f35c7b5594 Merge branch 'maint' 2010-11-22 16:33:39 -05:00
Lukas Czerner 7fe5ff3c1e mke2fs: Add discard option into mke2fs.conf
Allow to specify discard in mke2fs.conf. Also change the way how to
specify default value for lazy_itable_init. It is better to have all
this defaulting done in the same place so do it in definition (as we do
with discard).

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 16:15:16 -05:00
Lukas Czerner 0bc85dfb38 mke2fs: Deprecate -K option, introduce discard/nodiscard
It would be nice to have consistent "discard" options in every system
tool (mount, fsck, mkfs) taking advantage of discards. Also "discard"
and "nodiscard" is more descriptive instead of just "-K" and can be
easily defaulted and it is something we can not do with "-K".

With this commit you need to specify extended option like this:

./mke2fs -T <fstype> -E nodiscard <device>

in order make a filesystem without discarding the device first. And

./mke2fs -T <fstype> -E discard <device>

respectively.

-K option is with this commit deprecated and should not be used anymore.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 13:00:11 -05:00
Theodore Ts'o 2b21a0d9b6 mke2fs: Force the default blocksize to be at least the logical sector size
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 11:14:35 -05:00
Theodore Ts'o 92eb5a3392 mke2fs: Set logical/physical sector size from environment for debugging
If MKE2FS_DEVICE_SECTSIZE is set, then this will override the logical
sector size, which is the smallest sector size that can be written
atomically by the device.  (Previously MKE2FS_DEVICE_SECTSIZE set the
physical sector size, which was incorrect given its historical usage.)
The environment variable MKE2FS_DEVICE_PHYS_SECTSIZE will set the
physical sector size, which is the actual sector size used by the
device in reality.

The logical sector size is always less than or equal to the physical
sector size; and writes smaller than the physical sector size but
greather than or equal to the logical sector size will cause a
read-modify-write cycle within the device firmware (or in some
abstract layer lower than the Linux block I/O subsystem, at any rate).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 11:09:00 -05:00
Theodore Ts'o 1599b470fb mke2fs: Fill in min_io and opt_io with physical sector size
If the device does not have an explicitly specified minimum io_size or
optimal io_size, and the physical sector size is greater than the
block size, then use the physical sector size as a better-than-nothing
hint.

This should help for SSD's that have a physical sector size of 8k or
16k (which are reportedly will be coming soon).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 10:50:42 -05:00
Theodore Ts'o f89f54aff4 mke2fs: Do not require -F for block size < physical size
There will be SSD's out soon that have 8k or 16k phyiscal block sizes.
So don't enforce a requirement that the block size be less than the
physical block size unless the force option is given, and don't give a
warning if the user can't do anything about it (i.e., if the physical
block size is > than the page size).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-11-22 09:22:05 -05:00
Theodore Ts'o 210fd2c707 mke2fs: Enable lazy_itable_init if the kernel supports this feature
Add check for /sys/fs/ext4/features/lazy_itable_init.  If this file
exists, it should be OK to skip initializing the inode table since the
kernel will do it at mount time.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-10-01 10:47:38 -04:00
Theodore Ts'o 9946478a23 tune2fs.8: Document that the device can be specified via LABEL= or UUID=
Addresses-Debian-Bug: #580236

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-25 21:41:21 -04: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
Eric Sandeen 792cce3092 mke2fs: make "invalid blocks count" error more clear
Mistakes on the commandline can lead to odd error messages:

# mke2fs -t ext4 -E stride=128 stripe-width=512 /dev/sda1
mke2fs: invalid blocks count - /dev/sda1

Making it a bit more explicit is more obvious:

mke2fs: invalid blocks count '/dev/sda1' on device 'stripe-width=512'

(hint, the mistake was no comma separation for -E)

Reported-by: Adam Huffman <bloch@verdurin.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-09-20 09:25:23 -04:00
Eric Sandeen 6fcd6f84c2 mke2fs: use lazy inode init on some discard-able devices
If a device supports discard -and- returns 0s for discarded blocks,
then we can skip the inode table initialization -and- the inode table
zeroing at mkfs time, and skip the lazy init as well since they are
already zeroed out.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-09-20 09:20:25 -04:00
Theodore Ts'o 9345f02671 tune2fs, debugfs, libext2fs: Add support for ext4 default mount options
Add support for 2.6.35's new default mount options which can be
specified in the superblock.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-09-18 19:38:22 -04:00
Theodore Ts'o 61ef2474c2 badblocks: Deal with UTF-8 characters in progress message
Addresses-Gentoo-Bug: #309909
Addresses-Debian-Bug: #583782
Addresses-Debian-Bug: #587834

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-08-01 22:30:33 -04:00
Tim Small e447ba3731 mke2fs: fix mke2fs "invalid inode ratio" error message
Make error message consistent with the validity test.

Signed-off-by: Tim Small <tim@seoss.co.uk>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-30 20:43:11 -04:00
Eric Sandeen eddf36bac0 mke2fs.8.in: clarify the sign of a block-size constraint.
This bit of the mke2fs manpage is slightly confusing:

-b block-size
    Specify the size of blocks in bytes. <snip>
    If block-size is negative, then mke2fs will use heuristics
    to determine the appropriate block size, with the constraint
    that the block size will be at least block-size bytes.

because it sounds like the block size will be at least a negative
number.  Clarify just what the negative sign means.

Reported-by: Chris Frost <chris@frostnet.net>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-07-30 20:40:23 -04:00
Theodore Ts'o db0bdb49f4 Merge branch 'maint' into next
Conflicts:
	resize/extent.c
2010-07-19 02:37:41 -04:00
Mike Frysinger b887f08f95 e2freefrag: Fix getopt bug on machines with unsigned chars
The getopt() function returns an int, not a char.  On systems where the
default char is unsigned (like ppc), we get weird behavior where -1 is
truncated to 0xff but compared to (int)-1.

Also fix this same bug for two test programs, test_rel and iscan,
which aren't currently used at the moment.

Addresses-Gentoo-Bug: #299386

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-07-05 14:53:58 -04:00
Theodore Ts'o f96cb89e7a e2freefrag: Display the total number of free extents
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-07-05 14:51:47 -04:00
Valerie Aurora Henson cd5ca12d43 e2image: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 20:00:00 -04:00
Valerie Aurora Henson d991bc742f e2image: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: Nick Dokos <nicholas.dokos@hp.com>
Signed-off-by: Valerie Aurora (Henson) <vaurora@redhat.com>
2010-06-13 19:00:00 -04:00
Valerie Aurora Henson 7117f8d6c5 tune2fs: Fix up to be 64-bit block number safe
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 16:00:00 -04:00
Theodore Ts'o 295c3e038a dumpe2fs: Fix up to be 64-bit block number safe
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 15:00:00 -04:00
Theodore Ts'o 493024ea1d mke2fs: Fix up the fs type and feature selection for 64-bit blocks
We need to defer setting the blocks count field in the fs_param
structure until it is known whether 64-bit feature will be enabled
(and whether the blocks count is valid).

We also add a new mke2fs.conf configuration parameter,
auto_64-bit_support which will automatically enable the 64-bit feature
if the number of blocks requires it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 14:00:00 -04:00
Jose R. Santos 02d6f47e96 mke2fs: Fix up mke2fs to be able to make 64-bit file systems
Use 64-bit interfaces in mke2fs.  This should be most most of whats
needed to support creating a 64-bit filesystem. 

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-13 13:00:00 -04:00
Valerie Aurora Henson 5648c35ab1 badblocks: Use ext2fs_get_device_size2()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-06-13 12:00:00 -04:00
Theodore Ts'o 97d26ce9e3 Merge branch 'maint' into next
Conflicts:
	e2fsck/journal.c
	e2fsck/pass1.c
	e2fsck/pass2.c
	misc/mke2fs.c
2010-06-07 12:42:40 -04:00
Theodore Ts'o 079ad63d59 tune2fs: Enable uninit_bg to be set without requiring an fsck
Allow the uninit_bg feature to be set without requiring an fsck.  The
first full fsck will require scanning all of the inode table blocks,
but subsequent fsck's will be fast.  This allows flexibility over
requiring a full fsck after setting this feature, which is what
tune2fs previously mandated.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-19 12:14:39 -04:00
Theodore Ts'o bb1158b92e mke2fs: account for physical as well as logical sector size
Some devices, notably 4k sector drives, may have a 512 logical
sector size, mapped onto a 4k physical sector size.

When mke2fs is ratcheting down the blocksize for small filesystems,
or when a blocksize is specified on the commandline, we should not
willingly go below the physical sector size of the device.

When a blocksize is specified, we -must- not go below
the logical sector size of the device.

Add a new library function, ext2fs_get_device_phys_sectsize()
to get the physical sector size if possible, and adjust the
logic in mke2fs to enforce the above rules.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 23:04:40 -04:00
Theodore Ts'o b25df6f817 mke2fs: Fix compile warning message
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 23:04:39 -04:00
Theodore Ts'o 5aa6c3f61c Add configure options --enable-symlink-build and --enable-symlink-install
These options allow e2fsprogs to be built using symlinks instead of
hard links, and to be installed using symlinks instead of hard links,
respectively.

Addresses-Sourceforge-Bug: #1436294

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-17 19:21:42 -04:00
Eric Sandeen 1bb14a22b5 mke2fs: be explicit if external journal device is not found
This for RH bug #572935 -
RFE: Misleading error message from mke2fs -J option

If the journal device UUID is typo'd or otherwise not found,
the error message looks like it's a usage() type of problem.

It'd be helpful to explicitly say that the device requested
could not be found.

Addresses-Red-Hat-Bug: #572935

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2010-05-12 12:54:12 -04:00
Theodore Ts'o d531450cdd mke2fs: Allow a flex_bg size of 1
It's unusual, and rarely needed, but it's legal value.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-05-10 21:49:58 -04:00
Theodore Ts'o c5b23f6c0e Merge branch 'maint' into next 2010-03-15 18:53:45 -04:00
Eric Sandeen ecced2c358 mke2fs: Don't ask to proceed in case of a badly aligned partition
Just print the warning message in this case.

Addresses-Red-Hat-Bug: #569021
Addresses-Launchpad-Bug: #530071

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-03-15 00:14:00 -04:00
Theodore Ts'o cc84d866e2 Merge branch 'maint' into next
Conflicts:
	e2fsck/pass1.c
2010-02-10 18:20:58 -05:00
Eric Sandeen 13b0b1231e mke2fs: fix up topo complaints on regular files
mkfsing a plain file would lead to a warning about being unable
to determine geometry; we should just skip the topology-getting
if we see that we have a regular file.

This was breaking "make check" but I had missed it since I
inadvertently stopped running the checks during the Fedora
RPM build.

Also, add a newline to the warning.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-02-05 22:50:21 -05:00
Theodore Ts'o 3067d96a2d mke2fs: Fix printf type warning
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2010-01-31 18:51:31 -05:00
Theodore Ts'o 2d07b3ad98 Merge branch 'maint' into next
Conflicts:
	configure
	lib/ext2fs/alloc_tables.c
	misc/mke2fs.c
2010-01-31 18:49:08 -05:00
Theodore Ts'o ca92d98f0a filefrag: Fix a core dump on sparc32 platforms with 8k file systems
On 32-bit platforms where the file system block size is 8k or greater,
the calculation bpib*bpib*bpib* will overflow a 32-bit calculation,
leading to a divide by zero error.  Fix this.

Thanks to Mikulas Patocka for pointing this out.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-11-29 01:03:04 -05:00
Eric Sandeen f3befe3e6b mke2fs: open device writable for trim/discard
Sorry about that, the discard ioctl doesn't actually work
unless you open the file with write capabilities...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-25 07:05:37 -05:00
Eric Sandeen c7cd908be5 mke2fs support for BLKDISCARD
Try calling the BLKDISCARD ioctl at mkfs time to pre-discard all blocks
on an ssd, or a thinly-provisioned storage device.

No real error checking; if it fails, it fails, and that's ok - it's
just an optimization.  Also, it cannot work in conjunction with
the undo io manager, for obvious reasons.

Optionally disabled with a "-K" (mnemonic: Keep) option.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-16 21:53:39 -05:00
Matthias Andree d0a4e54e6a Disconnect e4defrag from build on non-Linux hosts.
Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-16 00:31:06 -05:00
Theodore Ts'o 4486af5b4c Merge branch 'maint' into next
Conflicts:
	misc/mke2fs.c
2009-11-16 00:30:57 -05:00
Eric Sandeen 5827d2412d mke2fs support for BLKDISCARD
Try calling the BLKDISCARD ioctl at mkfs time to pre-discard all blocks
on an ssd, or a thinly-provisioned storage device.

No real error checking; if it fails, it fails, and that's ok - it's
just an optimization.  Also, it cannot work in conjunction with
the undo io manager, for obvious reasons.

Optionally disabled with a "-K" (mnemonic: Keep) option.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-11-15 23:54:03 -05:00
Theodore Ts'o b49f78fe6e Convert ext2fs_group_{first,last}_block() to *block2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 21:24:06 -04:00
Theodore Ts'o 6493f8e85d Convert ext2fs_group_of_blk() to ext2fs_group_of_blk2()
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-25 20:50:15 -04:00
Valerie Aurora Henson d7cca6b06f Convert to use block group accessor functions
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-25 21:43:47 -04:00
Eric Sandeen e633b58ac7 libext2fs: clean up ext2fs_bg_flags_ interfaces
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-10-25 21:41:32 -04:00
Theodore Ts'o 72a729dbf9 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
2009-10-24 15:14:54 -04:00
Theodore Ts'o c5fbf38855 tune2fs.8: Clarify tune2fs's -i option
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-24 14:25:39 -04:00
Theodore Ts'o 77f464fb19 dumpe2fs: Fix usage message for -o superblock=<num> and -o blocksize=<num>
Addresses-Launchpad-Bug: #448099

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-24 14:15:55 -04:00
Theodore Ts'o 95bcea9fc1 Merge branch 'maint' into next
Conflicts:
	configure
	configure.in
	misc/mke2fs.c
2009-10-04 20:40:46 -04:00
Eric Sandeen 9ed8e5fec2 mke2fs: get device topology values from blkid
Handle automatic selection of stride/stripe:

mke2fs 1.41.9 (22-Aug-2009)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=16 blocks, Stripe width=32 blocks
...

And warn on block device misalignment:

mke2fs 1.41.9 (22-Aug-2009)
/dev/sdc1 alignment is offset by 32256 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Proceed anyway? (y,n)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-10-04 15:09:18 -04:00
Theodore Ts'o e1f0850795 Don't use in-tree header files if using system uuid or blkid libraries
This commit forces the use of the system-provided blkid or uuid header
files if we are using the system-provided blkid or uuid libraries.
This avoids using the in-tree header files with the system libraries.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-10-04 14:45:08 -04:00
Cristian Rodríguez 484ddc8767 fix fd leak that causes fsck to fail with "too many open files"
fsck leaks fds when invoked with -R -A -M -a -t noopts=nofail

Signed-off-by: Cristian Rodríguez <crrodriguez@opensuse.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-10-03 13:38:47 -04:00
Theodore Ts'o 1d4a493fa2 e2undo: Initialize com_err error tables for the ext2fs library
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-08 21:29:21 -04:00
Valerie Aurora Henson 4efbac6fed Convert uses of super->s_*_blocks_count to ext2fs_*_blocks_count()
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-09-07 20:46:34 -04:00
Valerie Aurora Henson a63745e81c Use ext2fs_file_acl_block() instead of using .i_file_acl directly
This provides support for 48-bit file acl blocks.

Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 22:29:45 -04:00
Theodore Ts'o 7a9f055f0e mke2fs.8.in: Clarify flex_bg feature description
Add a more explicit description of how specifying the flex_bg file
system feature changes the layout of the per-block group metadata.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 16:21:32 -04:00
Theodore Ts'o 73ebdf9972 tune2fs.8: Document the flex_bg file system option in the man page
Addresses-Sourceforge-Bug: #2822186

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 16:21:32 -04:00
Theodore Ts'o 1d9b818317 dumpe2fs: Print more information about the inline journal
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-06 18:55:09 -04:00
Valerie Aurora Henson 95fd65bb7f libext2fs: create generic numeric progress meters and use them
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-08-23 19:20:03 -04:00
Theodore Ts'o 732c8cd58f Use accessor functions fields for bg_flags in the block group descriptors
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-09-07 21:15:12 -04:00
Valerie Aurora Henson 24a117abd0 Convert to use io_channel_read_blk64() and io_channel_write_blk64()
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-09-07 21:14:24 -04:00
Theodore Ts'o dc615a21c3 Merge branch 'maint' into next 2009-09-07 17:02:35 -04:00
Kyle McMartin a9e55a1191 e4defrag: fix ppc build
ppc glibc seems to be missing sync_file_range, so we fell back
to the local define, and there ppc differs as well, so the
build was failing.

Thanks to Kyle for the patch w/ the tidy solution.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-09-07 17:00:33 -04:00
Theodore Ts'o c1b875979f e4defrag: Link with ext2fs library
Since e4defrag uses ext2fs_swab32, it needs to link against the ext2fs
library.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-23 22:34:28 -04:00
Theodore Ts'o 31b5a2b961 mke2fs.conf: Use the feature name "extent" instead of "extents"
The feature name "extent" is documented in mke2fs.conf, although both
"extent" and "extents" are accepted by e2fsprogs.

Addreses-Debian-Bug: #540111

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-23 15:06:48 -04:00
Theodore Ts'o ffd8078297 e2freefrag: Update manpage to include e2fsprogs version and release date
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 23:41:49 -04:00
Valerie Aurora Henson 3c041a514c Convert tune2fs, dumpe2fs, and e2image to the new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 21:15:30 -04:00
Aneesh Kumar K.V 154a5d7537 tune2fs: handle bad blocks when resizing inodes
When increasing inode size if we find that the new block
that we needed to increase the inode table size is a bad
block we fail. This make sure we don't end up with a corrupt
file system when doing inode resize on a file system having
bad blocks.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-20 13:13:20 -04:00
Aneesh Kumar K.V 91fac97938 tune2fs: Handle fs meta-data blocks during inode resize
With file system formated for RAID arrays we can have inode bitmap
and block bitmap after inode table. Make sure we move them around
properly when doing inode resize.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-20 13:12:49 -04:00
Aneesh Kumar K.V a9e5177be9 tune2fs: Make e2fsprogs handle ENOSPC better with inode resize
This removes the metadata block bitmap and makes the error handling
simpler. It also check for the enospc with the correct number needed
blocks. Also added specific error messages. We need to run e2undo
only if we start modiyfing inode, group desc and inode table.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-20 13:12:49 -04:00
Eric Sandeen 334cfccbca filefrag: don't print extent header on bmap fallback
The extent list header gets printed before we fall back to bmap:

# filefrag -v /mnt/test/bar
Filesystem type is: 58465342
File size of /mnt/test/bar is 12288 (3 blocks, blocksize 4096)
 ext logical physical expected length flags <---- HERE
Discontinuity: Block 2 is at 17 (was 16)
/mnt/test/bar: 2 extents found

so delay printing it until we know fiemap is working.

(though ideally it'd be nice to have the same verbose output
regardless of the interface we used, I think).

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-15 23:52:27 -04:00
Eric Sandeen 1f3d16deaa filefrag: fix frag count in bmap case
The fragmentation count in the bmap case seems to be
off by one:

/mnt/test/bar: 0 extents found

Addresses-Debian-Bug: #540376

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-08-15 23:52:00 -04:00
Theodore Ts'o 5d5e01d7e0 filefrag: Add option to force use of the FIBMAP ioctl
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-15 23:15:44 -04:00
Theodore Ts'o 0d990d0af7 Add V=1 support when linking e2freefrag in misc/Makefile.in
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:22:32 -04:00
Theodore Ts'o 1e48a456b6 e2freefrag: Take into account the last free extent in the file system
Fix a bug in e2freefrag where if the last free extent is at the very
end of the filesystem, it would be disregarded.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:22:24 -04:00
Theodore Ts'o 3e343b8d9a e2freefrag: Fix to work correctly for file systems with 1kb block sizes
If the file system has a non-zero s_first_data_block, as is the case
when the block size is 1kb, e2freefrag would incorrectly try to
reference invalid data blocks in the block allocation bitmap.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:23 -04:00
Theodore Ts'o cba91c4b52 e2freefrag: Do not print chunk-related information by default
Only print information related to chunk sizes if a chunksize is
printed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:23 -04:00
Theodore Ts'o aff2cf8ed2 e2freefrag: Clarify e2freefrag's messages
"Free chunks" is confusing since it has nothing to do with the
chunksize; use "free extents" instead.

Also add a missing newline in an error message.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 23:21:17 -04:00
Theodore Ts'o 137a7dc05c e2freefrag: Initialize the ext2 error table
... so error messages are printed correctly

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-09 19:15:45 -04:00
Valerie Aurora Henson 463e732777 Convert mke2fs to new bitmap interface
Signed-off-by: Valerie Aurora Henson <vaurora@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-05 00:17:56 -04:00
Theodore Ts'o 1d72214658 Merge branch 'maint' into next 2009-08-22 13:18:29 -04:00
Theodore Ts'o 88fca201ac Move declaration of FS_IOC_FIEMAP ioctl to fiemap.h
This helps e4defrag compile on systems where the system header files
don't yet define FS_IOC_FIEMAP.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-08-22 13:16:14 -04:00
Theodore Ts'o baa8dbeb4e Merge branch 'maint' into next
Conflicts:
	misc/Makefile.in
2009-08-01 20:43:00 -04:00
Eric Sandeen 4f1d0e8608 e4defrag: remove a lot of cruft
e4defrag.c had a lot of stuff copied into it from other
places, redefinitions of existing interfaces, etc.

We should be able to remove most of this, as the tool only
works on recent kernels anyway, we should just pick up
definitions from recent kernel headers whenever possible.

I've left the local definitions of fallocate, fadvise
(changed to posix_fadvise) and sync_file_range, and
wrapped them in #ifdef configure-time tests - though
really it seems like only fallocate should be necessary
by now, and perhaps the others can be dropped.

We still need some Makefile work so that it won't try to
build e4defrag if the right pieces aren't there (and
if the local definitions won't work...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-27 10:53:46 -04:00
Andreas Dilger ad751f11ec e2freefrag: Improve output to include be more like xfs_db's freesp -s
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-24 18:33:46 -04:00
Theodore Ts'o 0b2681f45b e2freefrag: New program which displays how fragmented the free space is
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-22 03:40:58 -04:00
Theodore Ts'o d0c537748d mke2fs: Add strings.h include for strcasecmp() declaration
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-18 18:41:51 -04:00
Eric Sandeen bbbb81c1d9 filefrag: fix it so it works in the bmap fallback case.
It looks like some debugging crept in?

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-18 09:56:10 -04:00
Theodore Ts'o 3c77b8ec54 Fix miscellaneous gcc -Wall warnings in blkid and tune2fs
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 23:56:49 -04:00
Theodore Ts'o 9d4bade4ac filefrag: Restore "perfect" number of extents calculation for ext2/ext3
The FIEMAP support added in e2fsprogs 1.41.6 broke the "perfection
would be XXX expects" calculation restore it.

Also fix some gcc -Wall warnings as well.  (Cleaning up gcc -Wall is
what caused me to notice this regression).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-11 23:44:56 -04:00
Peng Tao f97ea10fde filefrag: fix fm_start in filefrag_fiemap loop
When used with -v and the targeted file has more than 144
extents(double of the length of fm_extents array provided by buf),
filefrag_fiemap loops and calls fiemap ioctl() multiple times to
calculate the actual number of extents in a file. Each call to fiemap
ioctl() uses fm_start as the starting logical offset. The patch fixes
fm_start in each loop( except for the first one) and makes the extent
calculation correct for files with more that 144 extents.

To produce the problem, first run filefrag -v on a highly fragmented
file.  Then change the buf size in filefrag_fiemap to make it large
enough to have all the extent mapped in a single loop and run filefrag
-v after recompiling.  The former will produce a much smaller extent
count because of the false fm_start used in the loop. And the two will
produce different extent output since the 145th extent.

Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02 00:24:15 -04:00
Peng Tao ca4d95a932 remove bogus "-e" option from filefrag manpage
filefrag doesn't support "-e" option, so clean it up in the manpage.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-02 00:16:52 -04:00
Theodore Ts'o c13351f6c5 Add support for configure --enable-verbose-makecmds
Some people don't want to see the concise "kernel-style" make output.
This configure option allows build engines that want to see the full
set of commands executed by the makefile to get what they want.  Most
people will find this more distracting than useful, unless they need
to debug the Makefiles.

(It is not necessary to rerun configure to enable this verbose make
output temprarily; if a developer wants to do a quick debug of a
directory's makefile, he or she can simply edit the definition of the
$(E) and $(Q) variables in the Makefile; instructions can be found in
the MCONFIG file which is included in at the beginning of every
Makefile.)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-02 00:11:17 -04:00
Theodore Ts'o a6a1c0815c Fix Makefile dependencies for libcom_err
The e2fsprogs makefiles were using the same Makefile variable
LIBCOM_ERR for the link-line arguments as well as the dependencies.
Since LIBCOM_ERR can now include non-file arguments such as
"-lpthread", we need to use a separate DEPLIBCOM_ERR variable that
only has build file dependencies.

Do the same thing for STATIC_LIBCOM_ERR and PROFILED_LIBCOM_ERR.

Addresses-Sourceforge-Patches: #2813809

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-01 22:06:51 -04:00
Theodore Ts'o 6013bbf596 Do not build and install uuidgen from if the uuid library was disabled.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-30 21:34:08 -04:00
Theodore Ts'o caa6003b64 libuuid, uuidd: Avoid infinite loop while reading from the socket fd
If for some reason the uuidd daemon or the process calling uuidd
exited unexpectely, the read_all() function would end up looping
forever, either in uuidd or in libuuid.  Fix this terminating the loop
if no data can be read after five tries to read from the file
descriptor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 20:03:20 -04:00
Theodore Ts'o 2842bb3188 uuidd: Avoid closing the server socket when calling create_daemon()
In the event that file descriptors 0-2 are closed when uuidd is
started, the server socket could be created as a file descriptor that
will get closed when create_daemon() tries detaching the uuidd daemon
from its controlling tty.   Avoid this case by using dup(2).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 19:32:50 -04:00
Theodore Ts'o 427f95f879 logsave: Don't send the ^A and ^B delimiters to the console
Some terminal programs may print wierd characters when they see the
\001 or \002 characters.  So filter them out if the -s option
(skip_mode) is enabled.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 15:09:29 -04:00
Theodore Ts'o c510d6f268 badblocks: Make sure the list of bad blocks found is flushed on interrupt
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 01:04:02 -04:00
Theodore Ts'o 4001b8a8ff badblocks.8: Alphabetize options in badblocks man page
... to make it easier to find a specific option in the man page.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 01:03:27 -04:00
Theodore Ts'o e3dee8c91f badblocks.8: Update description of the -s option in badblocks man page
Addresses-Debian-Bug: #523063

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 00:59:35 -04:00
Theodore Ts'o 83bfa27d32 badblocks: Print the currently tested block number when interrupted with ^C
This can be useful for the user who wishes to restart the badblocks
program after interrupting it.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-29 00:52:27 -04:00
Eric Sandeen 1b600bfa48 lsattr: exit with a non-zero status on errors
lsattr doesn't return an error if you point it at a file that
doesn't exist.

This is slightly trickier because it can take more than one
file as an arg, but ls seems to report an error if any occurred,
so this does the same, it'll report the last error that was
encountered.

Addresses-RedHat-Bugzilla: #489841
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-06-21 21:46:34 -04:00
Theodore Ts'o 8a48035095 Fix encoding for rec_len in directories for >= 64k blocksize file systems
Previously e2fsprogs interpreted 0 for a rec_len of 65536 (which could
occur if the directory block is completely empty in 64k blocksize
filesystems), while the kernel interpreted 65535 to mean 65536.  The
kernel will accept both to mean 65536, and encodes 65535 to be 65536.
This commit changes e2fsprogs to match.

We add the encoding agreed upon for 128k and 256k filesystems, but we
don't enable support for these larger block sizes, since they haven't
been fully tested.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-21 21:07:38 -04:00
Theodore Ts'o 1acde2b277 dumpe2fs, tune2fs: fix miscellaneous memory leaks
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-15 03:55:10 -04:00
Theodore Ts'o 3b5126de44 badblocks: Remove 4096 blocksize limit
There is no need to prohibit the use of block sizes larger than 4k in
the badblocks program.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-02 09:31:24 -04:00
Theodore Ts'o 1384cc64b5 Fix spelling mistake in the man page for chattr
Addresses-Debian-Bug: #531385

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-02 09:02:39 -04:00
Theodore Ts'o e78968f7a4 filefrag: Fix error checking for the fiemap ioctl
Thanks to Peng Tao for reporting this problem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-02 08:45:22 -04:00
Theodore Ts'o 5635e75c91 Merge branch 'maint' into next 2009-07-21 17:07:33 -04:00
Theodore Ts'o 6a0ee32dcb Merge branch 'maint' into next 2009-07-12 01:14:39 -04:00
Kazuya Mio ae50746004 e4defrag: Fix compile warnings
When compile e2fsprogs git tree with gcc-wall option, we get some warnings about
e4defrag. This patch fixes them.

Signed-off-by: Kazuya Mio <k-mio@sx.jp.nec.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-07-11 14:52:21 -04:00
Theodore Ts'o 1d21f4bd8d e4defrag: Fix a core dump when trying to defrag a file with no blocks
Signed-off-by Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09 15:03:39 -04:00
Theodore Ts'o 4836459a3f Add e4defrag to the misc directory
To make it easier to maintain changes and fixes to the e4defrag
program, check it into the e2fsprogs source tree.

Signed-off-by: Akira Fujita <a-fujita@rs.jp.nec.com>
Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-07-09 14:56:43 -04:00
Theodore Ts'o 4f858546e1 Update man pages to include ext4 in the synposis, instead of just "ext2/ext3"
The e2fsprogs programs have historically just said that they operate
on ext2 and ext3 file system in their man pages.  Update them to say
that they also operate on ext4 file systems.

Addresses-Launchpad-bug: #381854

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30 12:34:28 -04:00
Theodore Ts'o 93aa024699 mke2fs.8: Fix man page to use hyphens instead of minus signs for options
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-30 00:15:22 -04:00
Eric Sandeen 312c2a404c chattr: manpage tidyups
Tidy up the chattr(1) manpage to completely document all
available options, and differentiate those which are read-only
early in the manpage as well.

* Remove "I" from settable attribute list
* add "e" to 2nd list of settable attributes & descriptions
* Note that h/E/I/X/Z are readonly
* Correct "H" to "h" for huge file attribute description
* fix long_name for indexed directory in flags_array

Addresses-Red-Hat-Bugzilla: BZ#502971

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 08:33:09 -04:00
Aneesh Kumar K.V 7c8da6e376 chattr: Add extent conversion support
This patch adds new option, +e to chattr. The +e option
is used to convert the ext3 format (non extent) file
to ext4 (extent) format. This can be used to migrate
the ext3 file system to ext4 file system.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-05-28 08:32:29 -04:00
Kalpak Shah e62847c5db filefrag: Add support to use the FIEMAP ioctl
The FIEMAP ioctl is more efficient and doesn't require root
privileges.  So if it is available, use it in preference to repeated
FIBMAP calls.

Signed-off-by: Kalpak Shah <kalpak.shah@sun.com>
Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-05-02 21:02:29 -04:00
Theodore Ts'o de7a86e23c mke2fs.8: Clarify in the man page that fs defaults come from mke2fs.conf
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 22:46:48 -04:00
Theodore Ts'o 9266fc7a2f tune2fs: Fix format string warnings
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:13:37 -04:00
Theodore Ts'o 6e6b71d697 logsave: Fix warn_unused_result warnings from gcc
Fixed a potential bug where by partial returns from the write(2)
system call could some bytes to be lost when writing to the log file.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 15:12:40 -04:00
Theodore Ts'o 14b596d409 configure.in: add --disable-libblkid option
Add an option to switch between the private (in-tree) libblkid and
public (in-system installed) library.  The private version is still
enabled by default.

If --disable-libblkid is specified the findfs(8) program, which is a
variant of tune2fs, is also not built or installed.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-22 09:18:30 -04:00
Theodore Ts'o 27c3e539b6 Explain the significance of the 'T' attribute in the chattr.1 man page
Addresses-Debian-Bug: #365619

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-21 22:18:19 -04:00
Theodore Ts'o c927bec16f tune2fs: Clarify manpage regarding how to see the current settings
Addresses-Debian-Bug: #515693

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 11:39:22 -04:00
Theodore Ts'o f203bbdbec e2fsck, tune2fs: Fix Hurd compilation problem due to lack of PATH_MAX
Hurd doesn't define PATH_MAX, so calculate the exact size needed for
the tdb filename, and allocate it dynamically.

Addresses-Debian-Bug: #521602

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 10:53:32 -04:00
Theodore Ts'o 38e7385e74 uuidd: Fix warn_unused_result warnings from gcc
Fixed a potential bug caused by partial returns from the write system
call (especially possible for network connections).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-04-18 09:14:31 -04:00
Theodore Ts'o a620baddee mke2fs: Don't try to create the journal in super-only mode
Since we aren't initializing the inode table, creating the journal
will just fail.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-31 07:42:24 -04:00
Jim Meyering 45e338f533 remove useless if-before-free tests
In case you're wondering about whether this change is safe from a
portability standpoint, fear not.  This has been beaten to death
in other forums.  Here are a few threads:

  http://thread.gmane.org/gmane.comp.version-control.git/74187
  http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/12712
  http://thread.gmane.org/gmane.emacs.devel/98144
  http://thread.gmane.org/gmane.comp.lib.glibc.alpha/13092

There has been debate about whether it's a good idea from a
performance standpoint, too, but imho you'll have a hard time
finding an instance where this sort of change induces a
measurable performance penalty.  If you do, please let me know.

Signed-off-by: Jim Meyering <meyering@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-08 20:37:12 -04:00
Eric Sandeen eb630fd870 e2fsprogs: blkid.static make target
Nice for testing w/o needing to swizzle around system
libraries...

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2009-03-06 02:41:46 -05:00
Theodore Ts'o 8d8224550c mke2fs, tune2fs: Do not allow the reserved_ratio to be negative
Add a check to make sure the argument to the -m option (which
specifies the reserved ratio) is greater than zero.

Addresses-Debian-Bug: #517015

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 02:25:06 -05:00
Theodore Ts'o b7c5b40308 Add support for a new superblock field: s_kbytes_written
This field tracks the lifetime amount of writes to the filesystem.  It
will be updated by the kernel as well as by e2fsprogs programs which
write to the filesystem.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-03-06 01:59:23 -05:00
Theodore Ts'o 37d17a65ec mke2fs: If the device size is exactly 16TB treat it as if it had 16TB - 1 block
This allows users who create a 16TB LVM to have mke2fs do (mostly) the
right thing automatcally.
2009-01-20 14:03:03 -05:00
Theodore Ts'o b0afdda1bc mke2fs: Add -U option to specify the UUID for the new filesystem
Patch integrated from Mandriva

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 13:20:31 -05:00
Theodore Ts'o 1a71bd4200 mke2fs: Treat an argv[0] of "mke3fs" the same as "mkfs.ext3"
Mandriva apparently uses "mke3fs" as an alias for mkfs.ext3.  I'm not
particularly fond of that practice, but we'll include it as legacy
support.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 12:02:40 -05:00
Theodore Ts'o 31f1815fa9 tune2fs: Fix tune2fs -I so it won't corrupt RAID filesystems
If a filesystem is built with the stride extended-option (which is
often used in RAID filesystems to make sure the block and inode
allocation bitmaps don't end up hitting one disk platter harder than
the rest), this can cause tune2fs -I to corrupt the filesystem because
it fails to handle the case where the allocation bitmaps are located
after the inode table, where the inode table needs to grow.  Handle
this case correctly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 11:49:17 -05:00
Theodore Ts'o ec43da2f35 tune2fs: General (whitespace) cleanup
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 02:34:39 -05:00
Theodore Ts'o 5bf81baea0 tune2fs: Don't allow the -I option if the flex_bg feature is enabled
With flex_bg usually the inode table for most block groups are packed
right against each other, so expanding the inode table size needs
special handling that's not currently in tune2fs.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-01-20 01:50:07 -05:00
Theodore Ts'o a11d0746b4 dumpe2fs: Only print inline journal information if the journal is internal
Currently dumpe2fs displays an error if run on a filesystem with an
external journal.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 15:05:51 -05:00
Theodore Ts'o ad64399d15 Add support to build profiled binaries in the misc directory
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 12:34:28 -05:00
Theodore Ts'o 27c6de45a4 tune2fs: Fix inefficient O(n**2) algorithms when expanding the inode size
When running "tune2fs -I 256" on moderate to large filesystems, the
time required to run tune2fs can take many hours (20+ before some
users gave up in disgust).  This was due to some O(n**2) and O(n*m)
algorithms in move_block() and inode_scan_and_fix(), respectively.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-15 00:32:39 -05:00
Theodore Ts'o 9d4a4dc287 tune2fs: Update the block group checksums when changing the UUID
Since the block group checksums depend on the UUID, we need to update
the block group checksums when setting the UUID.  We only do so if all
of the checksums are correct, however.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-11-14 17:42:27 -05:00
Theodore Ts'o 08c8b1ab34 mke2fs.8: Add an explanation of how the -t and -O options interact
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-02 08:47:48 -04:00
Theodore Ts'o 42e572b5b6 badblocks: Fix progress output for "badblocks -sw /dev/XXX"
Always initialize the starting time so that badblocks -sw works.
Thanks Jelle de Jong (jelledejong at powercraft.nl) for reporting this
bug.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-10-01 20:00:54 -04:00
Theodore Ts'o 711d3846a0 Fix various spelling mistakes in various man pages
Thanks to A. Costa for pointing these out.

Addresses-Debian-Bug: #498100
Addresses-Debian-Bug: #498101
Addresses-Debian-Bug: #498102
Addresses-Debian-Bug: #498103

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-07 14:08:40 -04:00
Manish Katiyar 504f7a2981 badblocks: Display time and percentage complete in verbose mode.
Addresses-Debian-Bug: #429739.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-05 07:51:33 -04:00
Theodore Ts'o 29551cacca Fix e2initrd_helper, blkid, and fsck from linking with unneeded libraries
... especially when using ELF shared libraries.  We only need to link
with a library if the executable uses that library directly.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-04 22:39:20 -04:00
Theodore Ts'o 55da987650 Improve ELF shared library handling
Pass in -rpath-link option to the linker so that blkid will build
correctly on systems that don't have libcom_err.so.2 installed.

Fix debugfs to only try to link with -ldl when building without shared
libraries; with ELF shared libraries, the library which requires -ldl
(libss.so) can required the library dependency itself.

Fix how we build tune2fs.static so that we use @LDFLAG_STATIC@, via
$(LDFLAGS_STATIC), instead of hard-coding the use of -static.

Addresses-Sourceforge-Bug: #2088537

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 23:12:38 -04:00
Theodore Ts'o 3b4a66cfb6 Fix bold font specifer in mke2fs.8 man page
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 21:23:35 -04:00
Theodore Ts'o 22301afb01 badblocks: Open the device with O_LARGEFILE
Linux doesn't enforce the Large File Support API requirements on block
devices, but in case someone wants to run badblocks on a normal file,
open the device file with O_LARGEFILE.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-02 08:29:20 -04:00
Theodore Ts'o a8fbdc0950 filefrag: Fix calculation of ideal number of extents
Fix calculation of the ideal number of extents needed for a file to
take into account sparse files.

In addition, suppress the "this file is extent-based" message unless
verbose mode is enabled.

Addresses-Debian-Bug: #458306

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01 15:58:37 -04:00
Theodore Ts'o f38cf3cb34 Only use the test_io manager if the right environment variables are set
In order to make it possible for the test_io manager to be compiled in
by default, make all of the programs that might try to use it to only
do so if the environment variables TEST_IO_FLAGS and TEST_IO_DEBUG are
set.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-09-01 11:36:53 -04:00
Theodore Ts'o d5f57d9553 mke2fs: Allow the default hash algorithm in mke2fs.conf
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-29 21:39:36 -04:00
Theodore Ts'o 10ff68d42d tune2fs: Add support for setting the default hash algorithm for htree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-29 21:21:19 -04:00
Theodore Ts'o d1070d91b4 tune2fs, mke2fs: Change default directory hash algorithm to half_md4
The half_md4 algorithm is faster and more collision resistant.  Let's
switch to it as the default.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-29 20:02:50 -04:00
Theodore Ts'o efc6f628e1 Remove trailing whitespace for the entire source tree
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-27 23:07:54 -04:00
Theodore Ts'o 5dd77dbe5a Add support for with empty directory blocks in 64k blocksize filesystems
The rec_len field in the directory entry is 16 bits, so if the
filesystem is completely empty, rec_len of 0 is used to designate
65536, for the case where the directory entry takes the entire 64k
block.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2008-08-25 21:08:19 -04:00