Whamcloud - gitweb
tools/e2fsprogs.git
3 years agoLU-13672 tune2fs: reset MMP state on error exit 26/38926/2
Andreas Dilger [Fri, 12 Jun 2020 21:21:48 +0000 (15:21 -0600)]
LU-13672 tune2fs: reset MMP state on error exit

If tune2fs cannot perform the requested change, ensure that the MMP
block is reset to the unused state before exiting.  Otherwise, the
filesystem will be left with mmp_seq = EXT4_MMP_SEQ_FSCK set, which
prevents it from being mounted afterward:

    LDISKFS-fs warning (device dm-9): ldiskfs_multi_mount_protect:311:
        fsck is running on the filesystem

Add a test to try some failed tune2fs operations and verify that the
MMP block is left in a clean state afterward.

Change-Id: I3a5acc5875fa2d082a66e751ec4b326ffe3ebbe5
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38926
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
4 years agoLU-13241 libext2fs: add quota to libext2fs 27/38027/4 v1.45.6.wc1
Li Dongyang [Mon, 23 Mar 2020 01:56:00 +0000 (12:56 +1100)]
LU-13241 libext2fs: add quota to libext2fs

add quota related interface to libext2fs and install the
relevant headers.

Change-Id: I17e6b5aa74e0f1bb1465168a1cf4e03184e003b0
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/38027
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
4 years agoATM-1754 tests: skip f_large_dir on aarch64
Andreas Dilger [Thu, 21 May 2020 20:57:49 +0000 (14:57 -0600)]
ATM-1754 tests: skip f_large_dir on aarch64

Skip the f_large_dir test on the aarch64 builders because this is
extremely slow (90 minutes) and clogs up the build system when
there are many patches in the queue.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I8c3a588c34caae5332b4c643df940b0e855cab07
Reviewed-on: https://review.whamcloud.com/38693
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Wang Shilong <wshilong@ddn.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
4 years agoLU-13177 build: add support for SLES15SP1
Minh Diep [Tue, 28 Jan 2020 22:35:46 +0000 (14:35 -0800)]
LU-13177 build: add support for SLES15SP1

Add SUSE 15SP1 to distro and spec file

Change-Id: Ica12ae0246db4755746ada6647122e8853fc6258
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/37357
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
4 years agoLU-11915 deubugfs: add support for xattrs in external inodes
Artem Blagodarenko [Thu, 4 Jul 2019 10:54:17 +0000 (13:54 +0300)]
LU-11915 deubugfs: add support for xattrs in external inodes

There was "e2fsck: add support for xattrs in external inodes" before
that added xattr in external inode support to utils. But it was
not applied to the last e2fsprogs version for some reasons.

This patch adds external inode output to debugfs that is required
for conf-sanity 115 test.

Change-Id: I3cfca85e2d34b54030d21fafa12be3dbf30e5b5c
Signed-off-by: Artem Blagodarenko <c17828@cray.com>
Reviewed-on: https://review.whamcloud.com/35417
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
4 years agoLU-12403 build: add support for RHEL/CentOS 8
Li Dongyang [Tue, 11 Jun 2019 05:05:03 +0000 (15:05 +1000)]
LU-12403 build: add support for RHEL/CentOS 8

Add RHEL/CentOS 8 to Distro, reuse the RHEL 7 spec.

Change-Id: Ic0fa915d1145ffc04bd5f6f7e3531b892a3d004a
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/35168
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
4 years agoLU-12226 debian: fix debhelper level requirement
Li Dongyang [Fri, 26 Apr 2019 05:23:28 +0000 (15:23 +1000)]
LU-12226 debian: fix debhelper level requirement

Requiring debhelper >= 11 will break the build on
Ubuntu 16.04 LTS, it only has debhelper 9 and 10
from backports.

Change-Id: I40838a4de5ee7a841ba970d4f7531f8fe9dc5ff4
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/34765
Reviewed-by: Minh Diep <mdiep@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
4 years agoLU-12158 mke2fs: avoid too large stride and stripe_width
Wang Shilong [Tue, 21 May 2019 04:06:39 +0000 (12:06 +0800)]
LU-12158 mke2fs: avoid too large stride and stripe_width

According to benchmarks numbers, too large stripe and stripe_width
will make preassure with ext4 mballoc allocater and hurts performances
finally.
                    2MB Chunk size                 256K Chunk size
stripe_width,stride     Write(MB/s)    Read(MB/s)   Write(MB/s) Read(MB/s)
512,512                 10,810         10,124       10,492      6,923
1024,1024               10,793         10,064       10,431      6,921
2048,2048               8,047          10,080       6,629       7,381
4096,4096               7,350          10,089       6,505       7,282

Performance number comes from Shuichi Ihara.

This patch try to avoid use too large stride and stripe_width when mkfs.
If users really want large value they could do it by specify mkfs options
or run tune2fs later.

Change-Id: I768f1ecb39837338e08842b21b4fca8b98165d2a
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/34767
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Andreas Dilger <adilger@whamcloud.com>
4 years agoLU-11609 mke2fs: allow 64bit feature without extents
Andreas Dilger [Sat, 3 Nov 2018 09:10:22 +0000 (03:10 -0600)]
LU-11609 mke2fs: allow 64bit feature without extents

The 64bit feature should be allowed without extents to for 32-bit
metadata_csum checksums to be stored in the group descriptor.
Change the extents check to check for more than 2^32 blocks instead
of the 64bit feature flag.  This also avoids warnings later if the
metadata_csum feature is enabled on a filesystem without 64bit.

Consolidate repeated 64bit feature checks into one check.

The fs_blocks_count value is always set when parse_fs_type() is
called, so no need to check if it is zero.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Ie73ff0ed50cfed5d6a9596260c6b6dc32d3ebbe5
Reviewed-on: https://review.whamcloud.com/33897
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
4 years agoLU-11215 libe2p: add large_xattr as an alias of ea_inode
Li Dongyang [Mon, 6 Aug 2018 01:33:44 +0000 (11:33 +1000)]
LU-11215 libe2p: add large_xattr as an alias of ea_inode

The upstream version of large xattr suppport doesn't
add "large_xattr" as a feature name, but it's still
used by our test scripts.

e2fsprogs commit:6a081f6d2a5cff0f5a077065aab39901d54bfb61

Change-Id: I48d7ac54b2b2ad252c404050bc4c3d9527865107
Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-on: https://review.whamcloud.com/32932
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
4 years agoLU-10638 build: add support for Scientific
Alexander Boyko [Thu, 8 Feb 2018 06:43:40 +0000 (01:43 -0500)]
LU-10638 build: add support for Scientific

Add Scientific to Distro with a reference to RHEL.

Signed-off-by: Alexander Boyko <c17825@cray.com>
Change-Id: I05001ee9233e4cac6b2c6b523a374ffdc243394d
Cray-bug-id: MRP-3882
Reviewed-on: https://review.whamcloud.com/31220
Reviewed-by: Artem Blagodarenko <c17828@cray.com>
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
4 years agoLU-8300 e2fsck: print out FID with dirent inode number
Andreas Dilger [Sat, 18 Jun 2016 10:50:41 +0000 (04:50 -0600)]
LU-8300 e2fsck: print out FID with dirent inode number

When printing out the dirent inode number in e2fsck, also print
out the FID, if available, for reference in the future if needed.

   Entry 'lustre.conf' in /ROOT/etc/yum/protected.d (50132) has
   deleted/unused inode=1964 fid=[0x200000401:0x844:0x0].  Clear? yes

This can be useful if LFSCK is able to rebuild the MDT layout from
the OST object xattrs, but the filename isn't stored on the OST.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: Id0ec22c47d83f16c392e93328d2869e7a53ebbe5
Reviewed-on: https://review.whamcloud.com/20866
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Artem Blagodarenko <c17828@cray.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
4 years agoLU-9501 mke2fs: avoid inode number error with large FS
Alexey Lyashkov [Mon, 15 May 2017 14:45:38 +0000 (17:45 +0300)]
LU-9501 mke2fs: avoid inode number error with large FS

Limit inodes count instead of error return, to use all inodes in
the filesystem.

Change-Id: I76ee0a6c11b099b8c17d90b0778e3c0f0cf1f60a
Signed-off-by: Alexey Lyashkov <alexey.lyashkov@seagate.com>
Reviewed-on: https://review.whamcloud.com/27111
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
4 years agoLU-6722 jbd: double minimum journal size for RHEL7
Fan Yong [Fri, 26 Jun 2015 15:29:59 +0000 (23:29 +0800)]
LU-6722 jbd: double minimum journal size for RHEL7

In RHEL7 (kernel version >= 3.10.0), the maximum journal transaction
size is reduced to half of the RHEL6 case. That may cause Lustre to
complain that the declared transaction credits too large for very
small journal device. This patch increases the minimum journal size
from 4MB to 8MB for RHEL7 case, then counteract the above limitation
about the journal transaction size.

Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: Iec8a2c561416cb7b5acce342c8ebcb845c8d7a19
Reviewed-on: http://review.whamcloud.com/15401
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoLU-5845 build: add support for SUSE_LINUX-12 .spec file
Bob Glossman [Thu, 16 Oct 2014 18:41:07 +0000 (11:41 -0700)]
LU-5845 build: add support for SUSE_LINUX-12 .spec file

Add the SLES 12 .spec file.
For now SLES 12 and SLES 11 can share the same .spec file.

  LU-8390 build: use correct .spec file for SLES 12

  Changes in output from the lsb_release command in SLES 12
  resulted in using the wrong .spec file in builds.
  This patch corrects the problem for old and new versions.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
  Change-Id: I41d47c305eba7d3dd0d313be5ad8192592291fad
  Reviewed-on: http://review.whamcloud.com/21237
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Signed-off-by: Bob Glossman <bob.glossman@intel.com>
Change-Id: I3b716c09ea8632d2333aaf61b8a6c881ccd18a88
Reviewed-on: http://review.whamcloud.com/12316
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoLU-5307 build: add support for RHEL-7 .spec file
Andreas Dilger [Fri, 18 Jul 2014 20:47:02 +0000 (14:47 -0600)]
LU-5307 build: add support for RHEL-7 .spec file

Add the RHEL 7 .spec file.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I00278b50c3669f56c5297a75b89775fec9476f43

4 years agoLU-1540 e2fsck: add missing symlink NUL terminator
Andreas Dilger [Sat, 14 Jul 2012 02:33:01 +0000 (20:33 -0600)]
LU-1540 e2fsck: add missing symlink NUL terminator

If a long symbolic link target is written into an external block
without a NUL terminator, its length is decided by the inode's size.
Make symlink check add a NUL termination in such cases if needed.

Such faulty symlinks were generated by osd-ldiskfs on the MDS until
Lustre 2.1.3 and Lustre 2.3.  The in-kernel code would handle such
unterminated symlinks correctly, since it used the inode size to
determine the symlink length, but e2fsck would assume the symlink
is broken if there wasn't a trailing NUL.

  LU-2627 e2fsck: check_symlink() SIGSEGV

  Since e2fsck_pass1_check_symlink() calls into check_symlink()
  with pctx == NULL, we should use 'ino' instead of 'pctx->ino'
  in check_symlink().

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
  Change-Id: If9c16f96d0655d5a886ef607f1f47ced6176f8d8

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I4419b30f1adb4a7d273796a936427aa351510213

4 years agoext2fs: check if Lustre filesystem is mounted
Andreas Dilger [Fri, 13 Apr 2012 08:16:24 +0000 (02:16 -0600)]
ext2fs: check if Lustre filesystem is mounted

Add a check to ext2fs_check_mount_point() to loo in /proc/fs/lustre/*
to see if Lustre is mounted, since st_rdev of the mountpoint does not
match st_rdev of the block device itself, which confuses libext2fs.

  LU-6093 ext2fs: don't confuse mke2fs by Lustre zfs mount

  check_if_lustre_mounted() by efb735 will mistakenly report the
  device is mounted when there is a ZFS-based Lustre mount.

  This patch fix it by parsing the real device name from the pool
  name exported in Lustre proc file with "zpool" command.

  It also includes a typo fix in check_if_lustre_mounted() and a
  few other code cleanups.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
  Change-Id: I43dabbcd6fa721c569cd9cc0f4a6de93ab761392
  Reviewed-on: http://review.whamcloud.com/14223
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agodebugfs: dump "fid" and "lma" xattrs on inode stat
Andreas Dilger [Fri, 13 Apr 2012 18:55:45 +0000 (12:55 -0600)]
debugfs: dump "fid" and "lma" xattrs on inode stat

Print out the Lustre "fid" and "lma" object xattr contents,
if present, with debugfs stat to simplify debugging.

  LU-8998 debugfs: handle combined LMA EA and PFID EA

  We need to store the stripe size and stripe count information in
  the OST object's PFID EA for the layout LFSCK to recover the MDT
  object or its (lost or corrupted) LOV EA. On the other hand, for
  PFL file, we also need to store its PFL ID and extent information
  in its OST object's PFID EA.

  Consider performance, we will store the PFID EA inside the inode
  body to avoid extra IO when read/write the PFID EA. Unfortunately,
  the space inside current 256-bytes inode for EA is very limited,
  and above enlarged PFID EA exceeds such limitation. So we have to
  make some hack with the PFID EA and LMA EA combined together. The
  patch makes the debugfs tool to handle such case properly.

Signed-off-by: Fan Yong <fan.yong@intel.com>
  Change-Id: I1380d16d94d6d05272e22fdfff07ada038685669
  Reviewed-on: https://review.whamcloud.com/19436
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agotests: add basic tests for dirdata feature
Andreas Dilger [Fri, 18 May 2018 04:52:58 +0000 (14:52 +1000)]
tests: add basic tests for dirdata feature

Signed-off-by: Pravin Shelar <pravin@clusterfs.org>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
4 years agoe2fsck: add support for dirdata feature
Andreas Dilger [Thu, 17 May 2018 03:43:16 +0000 (13:43 +1000)]
e2fsck: add support for dirdata feature

Add support for the INCOMPAT_DIRDATA feature, which allows
storing extra data in the directory entry beyond the name.
This allows the Lustre File IDentifier to be accessed in
an efficient manner, and would be useful for expanding a
filesystem to allow more than 2^32 inodes in the future.

Include this patches:

e2fsck: e2fsck -D does not change dirdata content

Fix dir optimization to preserve dirdata content for dot
and dotdot entries.

Lustre-bug: https://jira.hpdd.intel.com/browse/LU-1774
Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: Iae190794da75a2080a8e5cc5b95a49e0c894f72f

e2fsprogs: Consider DIRENT_LUFID flag in link_proc().

While adding the new file entry in directory block, link_proc()
calculates minimum record length of the existing directory entry
without considering the dirent data size and which leads to
corruption. Changed the code to use EXT2_DIR_REC_LEN() which will
return correct record length including dirent data size.

Lustre-bug: https://jira.hpdd.intel.com/browse/LU-2462
Signed-off-by: Manisha Salve <msalve@ddn.com>
Change-Id: Ic593c558c47a78183143ec8e99d8385ac94d06f7

libext2fs, e2fsck: don't use ext2_dir_entry_2

Due to endian issues, do not use ext2_dir_entry_2 because it will
have the wrong byte order on directory entries that are swabbed.
Instead, use the standard practice of mask-and-shift to access the
file_type and dirdata flags.

Lustre-bug: https://jira.hpdd.intel.com/browse/LU-4677
Signed-off-by: Pravin Shelar <pravin@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
4 years agotests: verify large xattr inode support
Andreas Dilger [Fri, 13 Apr 2012 08:14:16 +0000 (02:14 -0600)]
tests: verify large xattr inode support

Verify that inodes with large EAs in a secondary inode are working:
* EA inode needs to have EA_INODE_FL set
* EA inode should reference parent inode number+generation

Signed-off-by: Kalpak Shah <kalpak@sun.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agolibext2fs: add a regression test for in-inode xattrs
Andreas Dilger [Fri, 13 Apr 2012 08:01:12 +0000 (02:01 -0600)]
libext2fs: add a regression test for in-inode xattrs

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoe2fsck: clean up xattr checking code
Andreas Dilger [Fri, 13 Apr 2012 08:01:12 +0000 (02:01 -0600)]
e2fsck: clean up xattr checking code

Clean up xattr header/list processing for in-inode xattrs instead
of doing lots of explicit pointer math.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agotests: add test cases for inode badness
Andreas Dilger [Fri, 13 Apr 2012 07:23:17 +0000 (01:23 -0600)]
tests: add test cases for inode badness

Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoe2fsck: track errors/badness found for each inode
Andreas Dilger [Fri, 13 Apr 2012 07:13:58 +0000 (01:13 -0600)]
e2fsck: track errors/badness found for each inode

The present e2fsck code checks the inode, per field basis.  It
doesn't take into consideration to total sanity of the inode.
This may cause e2fsck turning a garbage inode into an apparently
sane inode ("It is a vessel of fertilizer, and none may abide
its strength.").

The following patch adds a heuristics to detect the degree of
badness of an inode. icount mechanism is used to keep track of
the badness of every inode.  The badness is increased as various
fields in inode are found to be corrupt.  Badness above a certain
threshold value results in deletion of the inode.  The default
badness threshold value is 7, it can be specified to e2fsck
using "-E inode_badness_threshold=<value>"

This can avoid lengthy pass1b shared block processing, where a
corrupt chunk of the inode table has resulted in a bunch of
garbage inodes suddenly having shared blocks with a lot of good
inodes (or each other).

  LU-11882 e2fsck: zero date is not inode badness

  Lustre FS OST has some precreated objects which have zeroed
  creation time. e2fsck adds badness points for such inodes.
  If OST has many precreated objects, e2fsck spends too much time
  during phase2, because processes each of such inode.

  Let's allow Lustre FS inode has zeroed time field for
  precreated objects.

  Change-Id: I171a0fe741449ca99b29b5af51032a7b4c716344
  Cray-bug-id: LUS-6857
Signed-off-by: Artem Blagodarenko <c17828@cray.com>
Signed-off-by: Girish Shilamkar <girish@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agotests: add tests for expanding inode extra size
Andreas Dilger [Fri, 13 Apr 2012 00:05:03 +0000 (18:05 -0600)]
tests: add tests for expanding inode extra size

Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoe2fsck: add support for expanding the inode size
Andreas Dilger [Fri, 13 Apr 2012 00:03:37 +0000 (18:03 -0600)]
e2fsck: add support for expanding the inode size

This patch adds a "-E expand_extra_isize" feature which makes sure
that _every_ used inode has i_extra_isize >= s_min_extra_isize if
s_min_extra_isize is set. Else it makes sure that i_extra_isize
of every inode is equal to sizeof(ext2_inode_large) - 128.

This is useful for the case where nanosecond timestamps or 64-bit
inode version fields are required for all inodes in the filesystem.

There is also a fix for test f_itable_collision, the original
E2FSCK_TIME would overflow on a 32bit system when adding with
ctx->time_fudge in EXT4_XTIME_FUTURE, making us increase the
inode badness incorrectly.

  LU-10205 libext2fs: fix buffer overrun in ext2fs_expand_extra_isize

  In ext2fs_expand_extra_isize, we size buffer using 'size' but then
  do the memcpy with the rounded-up size, which can overflow the buffer.

  With MALLOC_CHECK_=2, I see:
  Error in `../e2fsck/e2fsck': free(): invalid pointer: <addr>

  Change-Id: I31be58de12d4d50646c7aa96959de0efc5c279c3
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
  Reviewed-on: https://review.whamcloud.com/29975
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Change-Id: I306ff4f81d8bd6bdf0446c76d6772951043fead4
Signed-off-by: Kalpak Shah <kalpak@clusterfs.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agotests: add tests for uninitialized bitmaps
Andreas Dilger [Thu, 12 Apr 2012 23:52:44 +0000 (17:52 -0600)]
tests: add tests for uninitialized bitmaps

Various tests for handing uninitialized block and inode bitmaps,
and inodes beyond the in-use high watermark.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoe2fsck: allow deleting or zeroing shared blocks
Andreas Dilger [Thu, 12 Apr 2012 23:32:53 +0000 (17:32 -0600)]
e2fsck: allow deleting or zeroing shared blocks

E2fsck fixes files that are found to be sharing blocks by cloning
the shared blocks and giving each file a private copy in pass 1D.

Allowing all files claiming the shared blocks to have copies can
inadvertantly bypass access restrictions.  Deleting all the files,
zeroing the cloned blocks, or placing the files in the /lost+found
directory after cloning may be preferable in some secure environments.

The following patches implement config file and command line options
in e2fsck that allow pass 1D behavior to be tuned according to site
policy.  It adds two extended options and config file counterparts.
On the command line:

 -E clone=dup|zero

    Select the block cloning method.  "dup" is old behavior,
    and is the default.  "zero" is a new method that substitutes
    zero-filled blocks for the shared blocks in all the files
    that claim them.

 -E shared=preserve|lost+found|delete

    Select the disposition of files containing shared blocks.
    "preserve" is the old behavior which remains the default.
    "lost+found" causes files to be unlinked after cloning so
    they will be reconnected to /lost+found in pass 3.
    "delete" skips cloning entirely and simply deletes the files.

In the config file:
  [options]
      clone=dup|zero
      shared=preserve|lost+found|delete

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoe2fsck: parse config file before command-line opts
Andreas Dilger [Thu, 12 Apr 2012 23:24:55 +0000 (17:24 -0600)]
e2fsck: parse config file before command-line opts

The patch changes the order that the config file and command line
are parsed so that command line has precedence.  It also parses
the -E option for every occurrence, otherwise the -E option is
not cumulative.

Signed-off-by: Jim Garlick <garlick@llnl.gov>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agotests: verify > 65000 subdirectories
Andreas Dilger [Thu, 12 Apr 2012 22:02:12 +0000 (16:02 -0600)]
tests: verify > 65000 subdirectories

Add test case to verify nlink handling of large directories.

Change-Id: Iba4f75ae523078bc852616ebff73e1e28ac95301
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agoTT-177 build: add .spec file for SLES11 packaging
Andreas Dilger [Fri, 13 Apr 2012 08:23:12 +0000 (02:23 -0600)]
TT-177 build: add .spec file for SLES11 packaging

Include the upstream SLES11 .spec file to ensure the packages we
build match the upstream packages.  Any later patches that change
the packaging should patch the .spec file appropriately.

Add in the SLES-specific patches, excluding the replacement de.po
file, since the original SLES11 de.po file is only against 1.41.4,
and is missing a large number of changes to the translated messages
related to 64-bit format specifiers.

Always skip m_hugefile and t_replay_and_set tests, building rpms in
an ext3 environment will make the tests fail.

  LU-4284 build: add missing Provides line in SLES spec file

  Need to add a line in the SUSE spec file for Provides: ldiskfsprogs.
  This is present in the RHEL spec file and is needed to resolve
  dependencies in lustre server rpms at rpm install time.

Signed-off-by: Bob Glossman <bob.glossman@intel.com>
  Change-Id: Ib4821004d27c9a7271ffdbd7403990e586d6c9ca

  LU-9713 build: Require uptodate libcom_err, libss

  Ensure that the libcom_err and libext2fs2 packages installed match the
  other packages built from e2fsprogs so that modifications to those
  libraries (e.g. project quota) are available.

  Test-Parameters: clientdistro=sles12sp2 mdsdistro=sles12sp2 ossdistro=sles12sp2

  Change-Id: Idc22a029a6950cc1ffb9b6e44181d345db3ebbe5
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
  Reviewed-on: https://review.whamcloud.com/27834
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I783d58bd78d7c4c66cc85ec5557ae1aaf64016ba

4 years agobuild: add RHEL6 .spec file for packaging
Andreas Dilger [Fri, 13 Apr 2012 08:19:19 +0000 (02:19 -0600)]
build: add RHEL6 .spec file for packaging

Include the upstream RHEL6 .spec file to ensure the packages we
build match the upstream packages.  Any later patches that change
the packaging should patch the .spec file appropriately.

Change-Id: Ia12d193ff1a9c5a40cee2585a9bc47d5f9f63f4d
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agobuild: update e2fsprogs.spec for distro builds
Andreas Dilger [Thu, 12 Apr 2012 21:39:04 +0000 (15:39 -0600)]
build: update e2fsprogs.spec for distro builds

Add the distro version to the RPM release number, so that it the
RPM names do not conflict.

Allow the RPM built from upstream to replace the split packages
provided by the distros.  At some point in the future it may be
desirable to also split the RPM built by this spec file, but this
bs complicated by the fact that SLES and RHEL have different splits.

Change-Id: Iab8f75a7f7bd9790899a2024d91079d55501ef65
Signed-off-by: Girish Shilamkar <girish.shilamkar@sun.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agofilefrag: Lustre changes to filefrag FIEMAP handling
Andreas Dilger [Thu, 12 Apr 2012 21:31:35 +0000 (15:31 -0600)]
filefrag: Lustre changes to filefrag FIEMAP handling

Add support for multiple-device filesystems by defining a new
fe_device field in the fiemap_extent structure.  This allows
printing the filesystem-relative or linux block device number
associated with each extent of a file.  If a single filesystem
extent is mirrored to multiple block devices, the fe_device
field can be used to disambiguate the multiple copies.

If the "-l" (device-logical) option is given to filefrag, then
all extents for a particular device of a file are returned
before returning extents for the next device.  This makes it
easier to see if extent allocation within a single device is
contiguous, instead of returning all of the blocks of a file
interleaved in file-logical-offset order.

Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agobuild: update version for Lustre build
Andreas Dilger [Thu, 12 Apr 2012 20:00:07 +0000 (14:00 -0600)]
build: update version for Lustre build

Add Lustre-specific build version to distinguish packages from
upstream packages.

Since e2fsprogs release 1.44.4 the Version in e2fsprogs.spec
is not generated anymore. However contrib/build-rpm still relies
on the Version from the spec, maintain the version in the spec
as well.

e2fsprogs commit: e5f0f3eebef7b483d5cc8b37023d6e0256776d94

Change-Id: I4a31e659ff4d98f9bb00fea731bd1ee59a55fd38
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
4 years agomke2fs: set overhead in super block
Li Dongyang [Mon, 27 Jan 2020 03:06:36 +0000 (22:06 -0500)]
mke2fs: set overhead in super block

If overhead is not recorded in the super block, it is calculated
during mount in kernel, for bigalloc file systems it takes
O(groups**2) in time.  For a 1PB device with 32K cluster size it takes
~12 mins to mount, with most of the time spent on figuring out
overhead.

While we can not improve the overhead algorithm in kernel due to the
nature of bigalloc, we can work out the overhead during mke2fs and set
it in the super block, avoiding calculating it every time when it
mounts.

Overhead is s_first_data_block plus internal journal blocks plus the
block and inode bitmaps, inode table, super block backups and group
descriptor blocks for every group.  This patch introduces
ext2fs_count_used_clusters(), which calculates the clusters used in
the block bitmap for the given range.

When bad blocks are involved, it gets tricky because the blocks
counted as overhead and the bad blocks can end up in the same
allocation cluster.  In this case we will unmark the bad blocks from
the block bitmap, convert to cluster bitmap and get the overhead, then
mark the bad blocks back in the cluster bitmap.

Reset the overhead to zero when resizing, we can not simply count the
used blocks as overhead like we do when mke2fs.  The overhead can be
calculated by kernel side during mount.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoext2fs: rename "s_overhead_blocks" to "s_overhead_clusters"
Li Dongyang [Wed, 20 Nov 2019 04:35:25 +0000 (04:35 +0000)]
ext2fs: rename "s_overhead_blocks" to "s_overhead_clusters"

Rename s_overhead_blocks field from struct ext2_super_block to
make it consistent with the kernel counterpart.

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: optimize ext2fs_convert_subcluster_bitmap()
Li Dongyang [Mon, 27 Jan 2020 02:52:02 +0000 (21:52 -0500)]
libext2fs: optimize ext2fs_convert_subcluster_bitmap()

For a bigalloc filesystem, converting the block bitmap from blocks
to chunks in ext2fs_convert_subcluster_bitmap() can take a long time
when the device is huge, because we test the bitmap
bit-by-bit using ext2fs_test_block_bitmap2().
Use ext2fs_find_first_set_block_bitmap2() which is more efficient
for mke2fs when the fs is mostly empty.

e2fsck can also benefit from this during pass1 block scanning.

Time taken for "mke2fs -O bigalloc,extent -C 131072 -b 4096" on a 1PB
device:

without patch:
real    27m49.457s
user    21m36.474s
sys     6m9.514s

with patch:
real    6m31.908s
user    0m1.806s
sys    6m29.697s

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoTeach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flag
Theodore Ts'o [Tue, 22 Oct 2019 22:42:25 +0000 (18:42 -0400)]
Teach ext2fs_open2() to honor the EXT2_FLAG_SUPER_ONLY flag

Opening the file system with EXT2_FLAG_SUPER_ONLY will leave
fs->group_desc to be NULL and modify "dumpe2fs -h" and tune2fs when it
is emulating e2label to use this flag.  This speeds up "dumpe2fs -h"
and "e2label" when operating on very large file systems.

To allow other libext2fs functions to work without too many surprises,
ext2fs_group_desc() will read in the block group descriptors on
demand.  This allows "dumpe2fs -h" to be able to read the journal
inode, for example.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cray-bug-id: LUS-5777

4 years agoUpdate release notes, etc., for the 1.45.6 release v1.45.6
Theodore Ts'o [Sat, 21 Mar 2020 03:51:07 +0000 (23:51 -0400)]
Update release notes, etc., for the 1.45.6 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoAOSP: tune2fs, resize2fs: make ramdisk binaries.
Jaegeuk Kim [Wed, 12 Feb 2020 19:34:49 +0000 (11:34 -0800)]
AOSP: tune2fs, resize2fs: make ramdisk binaries.

Bug: 149391799
Change-Id: I5183755915710e28a603e3f718f16813ea9991a0
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
From AOSP commit: a13a88d0d557a396f63702fb8db008487e2384d7

4 years agoAOSP: e2fsdroid: Don't skip unusable blocks in BaseFS.
David Anderson [Fri, 14 Feb 2020 20:44:48 +0000 (12:44 -0800)]
AOSP: e2fsdroid: Don't skip unusable blocks in BaseFS.

Currently, basefs_allocator will iterate through blocks owned by an
inode until it finds a block that is free. This effectively ignores the
logical to physical block mapping, which can lead to a bigger delta in
the final image.

An example of how this can happen is if the BaseFS has a deduplicated
block (D), that is not deduplicated in the new image:

  Old image: 1 2 3 D 4 5
  New image: 1 2 3 ? 4 5

If the allocator sees that "D" is not usable, and skips to block "4",
we will have a non-ideal assignment.

  Bad image: 1 2 3 4 5 ?

This patch refactors get_next_block() to acquire at most one block. It's
called a single time, and then only called in a loop if absolutely no
blocks can be acquired from anywhere else.

In a Virtual A/B simulation, this reduces the COW snapshot size by about
90MB.

Bug: 139201772
Test: manual test
Change-Id: I354f0dee1ee191dba0e1f90491ed591dba388f7f
From AOSP commit: a495b54f89b2ec0e46be8e3564e4852c6434687c

4 years agoAOSP: e2fsdroid: Fix logical block sequencing in BaseFS.
David Anderson [Fri, 14 Feb 2020 03:20:32 +0000 (19:20 -0800)]
AOSP: e2fsdroid: Fix logical block sequencing in BaseFS.

By iterating over blocks to write BaseFS, holes in the extent tree are
skipped. This is problematic because the purpose of BaseFS is to
preserve the logical to physical block assignment between builds. By not
preserving the location of holes, the assignment can be incorrect.

For example, consider the following block list for a file:
   1 2 3 0 4 5

If this is recorded as:
   1 2 3 4 5

If the first block changes to a hole, the intended mapping will not be
preserved at all:
   0 1 2 0 3

This patch makes two changes to e2fsdroid to fix this. The first change
is that holes are now recorded in BaseFS, by iterating over the extent
tree rather than the block list, and inserting zeroes where appropriate.

The second change is that the block allocator now recognizes when blocks
have been skipped (either to deduplication or to holes), and skips the
same number of logical blocks in BaseFS as well.

In a Virtual A/B simulation, this reduces the COW snapshot size by
approximately 100MB.

Bug: 139201772
Test: m target-files-package, inspect .map files
From AOSP commit: d391f3bf38cbe51718d5c3c0bb3e72b1a9978625

4 years agoAOSP: e2fsdroid: Properly free the dedup block map.
David Anderson [Wed, 29 Jan 2020 23:31:14 +0000 (15:31 -0800)]
AOSP: e2fsdroid: Properly free the dedup block map.

When BaseFS specifies the same block for two files, it gets added to a
separate "dedup" bitmap, and removed from the free block bitmap. If the
new build does not use every block in this bitmap, there will be an
inconsistency: the block bitmap marks blocks as in-use when they are
actually free. Although this doesn't matter for AOSP's read-only file
systems, it does cause e2fsck to complain, which breaks the build.

Fix the inconsistency by properly freeing all unused blocks within the
dedup block set.

Bug: 139201772
Test: build AOSP using BaseFS
Change-Id: I6b6511eb713a56fec932f1d5668f1766d64d9479
From AOSP commit: 346bee6f8b97aefe7714688f738606c116099fbc

4 years agoAOSP: Build e2freefrag
Alessio Balsini [Fri, 24 Jan 2020 16:04:44 +0000 (16:04 +0000)]
AOSP: Build e2freefrag

Enable the build of e2freefrag to monitor the free space fragmentation
in ext2/3/4 filesystems.

Bug: 146078546
Test: m + e2freefrag on device
Change-Id: Ia56e443a789ae881a03bdaeae1093567e1736c4c
Signed-off-by: Alessio Balsini <balsini@google.com>
From AOSP commit: ab77f6c79f3dab697cd56ad3b793e7d555ac9415

4 years agoAOSP: Add -e2fsprogs to the e2fsprogs chattr and lsattr.
Elliott Hughes [Thu, 23 Jan 2020 23:44:10 +0000 (15:44 -0800)]
AOSP: Add -e2fsprogs to the e2fsprogs chattr and lsattr.

We want to start shipping the toybox chattr and lsattr on the device all
the time, so the build system rightly complains that then we'd have two
modules with the same name.

I went with a suffix rather than a prefix so that tab completion works
for folks still wanting to use the e2fsprogs versions.

Bug: http://b/147769529
Test: builds
Change-Id: Ib904fa6c709d29ce709302c61e452383c02cb9a3
From AOSP commit: 8525a455e7410461560a99a42feb0dbfabab5c8e

4 years agoAOSP: Make ramdisk_available.
Yifan Hong [Wed, 22 Jan 2020 00:44:20 +0000 (16:44 -0800)]
AOSP: Make ramdisk_available.

Test: pass
Bug: 147347110
Change-Id: Ie800ba1b56773dcc1b6563c4f19c27eccb9ffc1a
From AOSP commit: f5a8e8fdefd78deae971a475a7fa43734eef205e

4 years agoAOSP: Change #define to _BLKID_TYPES_H
Kousik Kumar [Fri, 10 Jan 2020 00:15:30 +0000 (16:15 -0800)]
AOSP: Change #define to _BLKID_TYPES_H

blkid_types.h and ext_types.h having the exact same content results in
mismatches in remote RBE builds. Given blkid_types.h is actually
supposed to be different, changing this to remove the mismatch.

Test: Ran a build, and all e2fsprogs mismatches went away between
local/remote.

Change-Id: I63ab1719ee1d0ccd28907f0bc99531260251fa99
From AOSP commit: ec10b513c283706f984edeec47301b0661f7d283

4 years agoAOSP: Allow resize2fs to compile with BUILD_HOST_static
Dario Freni [Mon, 6 Jan 2020 15:57:14 +0000 (15:57 +0000)]
AOSP: Allow resize2fs to compile with BUILD_HOST_static

Bug: 144477678
Test: BUILD_HOST_static=1 m resize2fs; m resize2fs
Change-Id: I0986deccfe496153e662dcc3cc2fb1ffb6973c21
From AOSP commit: 2c767b86591c64cd7b84c5619e8d8b8a0afd557e

4 years agoAOSP: Allow debugfs_static to be compiled as host tool.
Dario Freni [Thu, 2 Jan 2020 12:59:39 +0000 (12:59 +0000)]
AOSP: Allow debugfs_static to be compiled as host tool.

Bug: 144477678
Test: m debugfs_static
Change-Id: I7c360a2a381f8508578d14c32bbb280f386dd925
From AOSP commit: 742bb05a401eb2feb6caaee1c8d66fc1c37eef77

4 years agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Sat, 21 Mar 2020 02:31:25 +0000 (22:31 -0400)]
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomisc: add text describing the impact of an inode size < 128 bytes in man pages
Theodore Ts'o [Sat, 21 Mar 2020 01:35:03 +0000 (21:35 -0400)]
misc: add text describing the impact of an inode size < 128 bytes in man pages

Addresses-Debian-Bug: #953493
Addresses-Debian-Bug: #953494
Addresses-Debian-Bug: #951808
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibe2p: add a thread-safe variant of e2p_feature2string
Theodore Ts'o [Fri, 20 Mar 2020 21:57:38 +0000 (17:57 -0400)]
libe2p: add a thread-safe variant of e2p_feature2string

This commit adds the function e2p_feature_to_string() which allows the
caller to pass in a preallocated buffer.

Google-Bug-Id: 16978603
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: fix the {set_get}_bitmap_range functions when bitmap->start > 7
Theodore Ts'o [Fri, 20 Mar 2020 19:24:18 +0000 (15:24 -0400)]
libext2fs: fix the {set_get}_bitmap_range functions when bitmap->start > 7

The bitmap array's set/get bitmap_range functions were not subtracting
out bitmap->start.  This doesn't matter for normal file systems, since
the bitmap->start is zero or one, and the passed-in starting range is
a multiple of eight, and the starting range is then divided by 8.

But with a non-standard/fuzzed file system, bitmap->start could be
significantly larger, and this could then lead to a array out of
bounds memory reference.

Google-Bug-Id: 147849134
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: clarify overflow link count error message
Jan Kara [Thu, 13 Feb 2020 10:15:56 +0000 (11:15 +0100)]
e2fsck: clarify overflow link count error message

When directory link count is set to overflow value (1) but during pass 4
we find out the exact link count would fit, we either silently fix this
(which is not great because e2fsck then reports the fs was modified but
output doesn't indicate why in any way), or we report that link count is
wrong and ask whether we should fix it (in case -n option was
specified). The second case is even more misleading because it suggests
non-trivial fs corruption which then gets silently fixed on the next
run. Similarly to how we fix up other non-problems, just create a new
error message for the case directory link count is not overflown anymore
and always report it to clarify what is going on.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit 4ebce13292f54c96f43dcb1bd1d5b8df5dc8749d)

4 years agodebian: drop libattr1-dev from the build dependencies list
Theodore Ts'o [Sun, 15 Mar 2020 04:56:01 +0000 (00:56 -0400)]
debian: drop libattr1-dev from the build dependencies list

The libattr has stopped providing attr/xattr.h; we now use
sys/xattr.h.  So there is no longer any reason to require that the
libattr1-dev package be present when building e2fsprogs, so drop it.

Addresses-Debian-Bug: #953926
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: fix "make check" when using static libraries
Theodore Ts'o [Sun, 15 Mar 2020 04:26:22 +0000 (00:26 -0400)]
e2fsck: fix "make check" when using static libraries

Fixes: 70303df16ca6 ("e2fsck: consistently use ext2fs_get_mem()")

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: make ext2fs_dirent_has_tail() more strict
Theodore Ts'o [Sun, 15 Mar 2020 03:24:39 +0000 (23:24 -0400)]
libext2fs: make ext2fs_dirent_has_tail() more strict

Previously ext2fs_dirent_has_tail() would return true if the directory
was corrupted.  If the directory is corrupted, then by definition it
doesn't have a valid checksum tail.

(This fixes a big-endian failure on the master branch.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomisc: fix typos in chattr's man page
Sawood Alam [Tue, 10 Mar 2020 02:47:29 +0000 (22:47 -0400)]
misc: fix typos in chattr's man page

Plural form "directories" should be used along with "files".
"id's" should be "ids" (i.e., plural form, not apostrophe).
"much" should "must".

Signed-off-by: Sawood Alam <ibnesayeed@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomke2fs.conf: remove options.fname_encoding
Pino Toscano [Mon, 9 Mar 2020 16:36:10 +0000 (12:36 -0400)]
mke2fs.conf: remove options.fname_encoding

Introduced with commit e7236a9476cd1fa5296fbc4aa573b36426901a08,
it was later renamed to encoding, and turned into a fs_type-only
option with commit 28887533bb64db318e74c38cd9c0ad6d0bb2ced2.

Hence, remove an option that does not exist in the default
configuration.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: check open(O_EXCL) first in ismounted.c
Lukas Czerner [Tue, 3 Mar 2020 13:53:48 +0000 (14:53 +0100)]
libext2fs: check open(O_EXCL) first in ismounted.c

Currently the ext2fs_check_mount_point() will use the open(O_EXCL) check
on linux after all the other checks are done. However it is not
necessary to check mntent if open(O_EXCL) succeeds because it means that
the device is not mounted.

Moreover the commit ea4d53b7 introduced a regression where a following
set of commands fails:

vgcreate mygroup /dev/sda
lvcreate -L 1G -n lvol0 mygroup
mkfs.ext4 /dev/mygroup/lvol0
mount /dev/mygroup/lvol0 /mnt
lvrename /dev/mygroup/lvol0 /dev/mygroup/lvol1
lvcreate -L 1G -n lvol0 mygroup
mkfs.ext4 /dev/mygroup/lvol0   <<<--- This fails

It fails because it thinks that /dev/mygroup/lvol0 is mounted because
the device name in /proc/mounts is not updated following the lvrename.

Move the open(O_EXCL) check before the mntent check and return
immediatelly if the device is not busy.

Fixes: ea4d53b7 ("libext2fs/ismounted.c: check device id in advance to skip false device names")
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reported-by: Zdenek Kabelac <zkabelac@redhat.com>
Reported-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomke2fs: fix permissions setting with "mke2fs -d /path/files"
Theodore Ts'o [Sat, 7 Mar 2020 17:35:48 +0000 (12:35 -0500)]
mke2fs: fix permissions setting with "mke2fs -d /path/files"

Set the directory for directories in cases where the owner permissions
is not rwx.  This was reported[1] by Robert Yang but we are using a
different approach to fixing the issue.

[1] https://lore.kernel.org/r/1582542522-97508-1-git-send-email-liezhi.yang@windriver.com

Also set the permissions in a more portable way by making a
distinction between the host OS's permissions stats and Linux's
permissions.  We still assume the low 12 bits are the historical Unix
assignments, but we don't assume ST_IFMT bits are the same as Linux's.

Reported-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: don't use O_DIRECT for files on tmpfs
Andreas Dilger [Fri, 21 Feb 2020 21:40:56 +0000 (14:40 -0700)]
libext2fs: don't use O_DIRECT for files on tmpfs

If a filesystem image is on tmpfs, opening it with O_DIRECT for
reading the MMP will fail.  This is unnecessary, since the image
file can't really be open on another node at this point.  If the
open with O_DIRECT fails, retry without it when plausible.

Remove the special-casing of tmpfs from the mmp test cases.

Change-Id: I41f4b31657b06f62f10be8d6e524d303dd36a321
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: avoid overflow with very large dirs
Andreas Dilger [Wed, 12 Feb 2020 01:07:21 +0000 (18:07 -0700)]
e2fsck: avoid overflow with very large dirs

In alloc_size_dir() it multiples signed ints when allocating the
buffer for rehashing an htree-indexed directory.  This will overflow
when the directory size is above 4GB, which is possible with largedir
directories having about 100M entries, assuming an average 3/4 leaf
fullness and 24-byte filenames, or fewer with longer filenames.
The same problem exisgs in get_next_block().

Similarly, the out_dir struct used a signed int for the number of
blocks in the directory, which may result in a negative size if the
directory is over 2GB (about 50M entries or fewer).

Use appropriate unsigned variables for block counts, and use larger
types for calculating the byte count for memory offsets/sizes.

Such large directories not been seen yet, but are not too far away.
The ext2fs_get_array() function will properly calculate the needed
memory allocation, and detect overflow on 32-bit systems.
Add ext2fs_resize_array() to do the same for array resize.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomisc: handle very large files with filefrag
Andreas Dilger [Fri, 7 Feb 2020 01:09:46 +0000 (18:09 -0700)]
misc: handle very large files with filefrag

Avoid overflowing the column-width calc printing files over 4B blocks.

Document the [KMG] suffixes for the "-b <blocksize>" option.

The blocksize is limited to at most 1GiB blocksize to avoid shifting
all extents down to zero GB in size.  Even the use of 1GB blocksize
is unlikely, but non-ext4 filesystems may use multi-GB extents.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: consistently use ext2fs_get_mem()
Andreas Dilger [Fri, 7 Feb 2020 01:09:45 +0000 (18:09 -0700)]
e2fsck: consistently use ext2fs_get_mem()

Consistently use ext2fs_get_mem() and ext2fs_free_mem() instead of
calling malloc() and free() directly in e2fsck.  In several places
it is possible to use ext2fs_get_memzero() instead of explicitly
calling memset() on the memory afterward.

This is just a code cleanup, and does not fix any specific bugs.

[ Fix up library dependencies in e2fsck/Makefile.in to fix "make
  check" breakages. -- TYT ]

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: fix overflow if more than 4B inodes
Andreas Dilger [Fri, 7 Feb 2020 01:09:44 +0000 (18:09 -0700)]
e2fsck: fix overflow if more than 4B inodes

Even though we don't have support for filesystems with over 4B inodes
in the current e2fsprogs, this may happen in the future.  There are
latent overflow bugs when calculating the number of inodes in the
filesystem that can trivially be fixed now, rather than waiting for
them to be hit at some point in the future.  The block number calcs
are already correct in this code.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agodebugfs: print inode numbers as unsigned
Andreas Dilger [Fri, 7 Feb 2020 01:09:43 +0000 (18:09 -0700)]
debugfs: print inode numbers as unsigned

Print inode numbers as unsigned values, to avoid printing negative
numbers for inodes above 2B.

Flags should be printed as hex instead of signed decimal values.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agodebugfs: allow comment lines in command file
Andreas Dilger [Fri, 7 Feb 2020 01:09:42 +0000 (18:09 -0700)]
debugfs: allow comment lines in command file

Allow comment lines with '#' at the start of the line in the command
file passed in to debugfs via the "-f" option or from standard input.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: reduce memory usage for many directories
Andreas Dilger [Fri, 7 Feb 2020 01:09:41 +0000 (18:09 -0700)]
e2fsck: reduce memory usage for many directories

Pack struct dx_dir_info and dx_dirblock_info properly in memory, to
avoid holes, and fields are not larger than necessary.  This reduces
the memory needed for each hashed dir, according to pahole(1) from:

    struct dx_dir_info {
        /* size: 32, cachelines: 1, members: 6 */
        /* sum members: 26, holes: 1, sum holes: 2 */
        /* padding: 4 */
    };
    struct dx_dirblock_info {
        /* size: 56, cachelines: 1, members: 9 */
        /* sum members: 48, holes: 2, sum holes: 8 */
        /* last cacheline: 56 bytes */
    };

to 8 bytes less for each directory and directory block, and leaves
space for future use if needed (e.g. larger numblocks):

    struct dx_dir_info {
        /* size: 24, cachelines: 1, members: 6 */
        /* sum members: 20, holes: 1, sum holes: 4 */
        /* bit holes: 1, sum bit holes: 7 bits */
    };
    struct dx_dirblock_info {
        /* size: 48, cachelines: 1, members: 9 */
    };

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: avoid mallinfo() if over 2GB allocated
Andreas Dilger [Fri, 7 Feb 2020 01:09:40 +0000 (18:09 -0700)]
e2fsck: avoid mallinfo() if over 2GB allocated

Don't use mallinfo() for determining the amount of memory used if it
is over 2GB.  Otherwise, the signed ints used by this interface can
can overflow and return garbage values.  This makes the actual amount
of memory used by e2fsck misleading and hard to determine.

Instead, use brk() to get the total amount of memory allocated, and print
this if the more detailed mallinfo() information is not suitable for use.

There does not appear to be a mallinfo64() variant of this function.
There does appear to be an abomination named malloc_info() that writes
XML-formatted malloc stats to a FILE stream that would need to be read
and parsed in order to get these stats, but that doesn't seem worthwhile.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shilong Wang <wshilong@ddn.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: use proper types for variables
Andreas Dilger [Fri, 7 Feb 2020 01:09:39 +0000 (18:09 -0700)]
e2fsck: use proper types for variables

Use ext2_ino_t instead of ino_t for referencing inode numbers.
Use loff_t for for file offsets, and dgrp_t for group numbers.

Cast products to ssize_t before multiplication to avoid overflow.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Reviewed-by: Shilong Wang <wshilong@ddn.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: fix e2fsck_allocate_memory() overflow
Andreas Dilger [Fri, 7 Feb 2020 01:09:38 +0000 (18:09 -0700)]
e2fsck: fix e2fsck_allocate_memory() overflow

e2fsck_allocate_memory() takes an "unsigned int size" argument, which
will overflow for allocations above 4GB.  This happens for dir_info
and dx_dir_info arrays when there are more than 350M directories in a
filesystem, and for the dblist array above 180M directories.

There is also a risk of overflow during the binary search in both
e2fsck_get_dir_info() and e2fsck_get_dx_dir_info() when the midpoint
of the array is calculated, if there would be more than 2B directories
in the filesystem and working above the half way point.

Also, in some places inode numbers are "int" instead of "ext2_ino_t",
which can also cause problems with the array size calculations, and
makes it hard to identify where inode numbers are used.

Fix e2fsck_allocate_memory() to take an "unsigned long" argument to
match ext2fs_get_mem(), so that it can do single memory allocations
over 4GB.

Fix e2fsck_get_dir_info() and e2fsck_get_dx_dir_info() to temporarily
use an unsigned long long value to calculate the midpoint (which will
always fit into an ext2_ino_t again afterward).

Change variables that hold inode numbers to be ext2_ino_t, and print
them as unsigned values instead of printing negative inode numbers.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Shilong Wang <wshilong@ddn.com>
Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agotst_libext2fs: Avoid multiple definition of global variables
Lukas Czerner [Mon, 10 Feb 2020 15:24:59 +0000 (16:24 +0100)]
tst_libext2fs: Avoid multiple definition of global variables

gcc version 10 changed the default from -fcommon to -fno-common and as a
result e2fsprogs make check tests fail because tst_libext2fs.c end up
with a build error.

This is because it defines two global variables debug_prog_name and
extra_cmds that are already defined in debugfs/debugfs.c. With -fcommon
linker was able to resolve those into the same object, however with
-fno-common it's no longer able to do it and we end up with multiple
definition errors.

Fix the problem by using SKIP_GLOBDEFS macro to skip the variables
definition in debugfs.c. Note that debug_prog_name is also defined in
lib/ext2fs/extent.c when DEBUG macro is used, but this does not work even
with older gcc versions and is never used regardless so I am not going to
bother with it.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agochattr.1: improve attribute formatting with labels and indented paragraphs
Jeremy Visser [Mon, 3 Feb 2020 02:37:41 +0000 (13:37 +1100)]
chattr.1: improve attribute formatting with labels and indented paragraphs

By convention, lists of options in man pages use a label followed by an
indented description, such as this example from the Options section:

     -R     Recursively change attributes of directories and
            their contents.

But the Attributes section places the available attributes mid-sentence,
which makes it visually more difficult to parse:

     A file with the 'a' attribute set can only be opened
     in append mode for writing.  [...]

     When a file with the 'A' attribute set is accessed, its
     atime record is not modified.  [...]

This patch places a label beside each attribute description, which (in
my opinion) improves readability, especially when visually skimming the
list.  For example:

     a      A file with the 'a' attribute set can only be
            opened in append mode for writing.

     A      When a file with the 'A' attribute set is accessed,
            its atime record is not modified.

Signed-off-by: Jeremy Visser <jeremyvisser@google.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: avoid array buffer overruns caused by insane directory blocks
Theodore Ts'o [Sun, 16 Feb 2020 00:10:01 +0000 (19:10 -0500)]
libext2fs: avoid array buffer overruns caused by insane directory blocks

Reported-by: canardo909@gmx.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: fix potential OOB read check_for_inode_bad_blocks()
Theodore Ts'o [Thu, 16 Jan 2020 23:14:37 +0000 (18:14 -0500)]
libext2fs: fix potential OOB read check_for_inode_bad_blocks()

If the bad block list has been reset in the middle of an inode scan,
it's possible for bb->list[scan->bad_blocks_ptr] to result in an
out-of-bounds read access.

This is highly unlikely to happen under normal circumstances; in
particular, we generally don't use bad block inodes any more.  In
addition, this would only happen if the bad block inode itself is
corrupt so e2fsck needs to wipe it out.  This might cause e2fsck to
crash, but it will more likely cause a part of the inode table to be
wrongly considered invalid, causing file system to be incorrectly
fixed.

This was reported by TALOS as TALOS-2020-0974 and CVE-2020-6057, but
after closer examination, we don't believe this can be used in any way
to exploit the system or release information about the system, since
all this can do is to cause part of the inode table to be skipped when
it shouldn't be, and this can't be leveraged since any information
about the ASLR of the process is obsolete once e2fsck exits.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agommp: abstract out repeated 'sizeof(buf), buf' usage
Andreas Dilger [Tue, 14 Jan 2020 21:42:18 +0000 (14:42 -0700)]
mmp: abstract out repeated 'sizeof(buf), buf' usage

The printf("%.*s") format requires both the buffer size and buffer
pointer to be specified for each use.  Since this is repeatedly given
as "(int)sizeof(buf), (char *)buf" for mmp_nodename and mmp_bdevname
fields, with typecasts to avoid compiler warnings.

Add a helper macro EXT2_LEN_STR() to avoid repeated boilerplate code.

This can also be used for other superblock buffer fields that may not
have NUL-terminated strings (e.g. s_volume_name, s_last_mounted,
s_{first,last}_error_func, s_mount_opts) to simplify code and avoid
the need for temporary buffers for NUL-termination.

Annotate the superblock string fields that may not be NUL-terminated.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agommp: don't assume NUL termination for MMP strings
Andreas Dilger [Tue, 14 Jan 2020 21:42:17 +0000 (14:42 -0700)]
mmp: don't assume NUL termination for MMP strings

Don't assume that mmp_nodename and mmp_bdevname are NUL terminated,
since very long node/device names may completely fill the buffers.

Limit string printing to the maximum buffer size for safety, and
change the field definitions to __u8 to make it more clear that
they are not NUL-terminated strings, as is done with other strings
in the superblock that do not have NUL termination.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: reserve the error code EXT2_ET_NO_GDESC
Theodore Ts'o [Thu, 16 Jan 2020 20:35:29 +0000 (15:35 -0500)]
libext2fs: reserve the error code EXT2_ET_NO_GDESC

This is really only needed in the 1.46+ where the EXT2_FLAG_SUPER_ONLY
is honored by ext2fs_open to only read the superblock, so that
fs->group_desc can be NULL.  We define it in the maint branch so that
we can be sure the error tables are kept in sync (in the unlikely case
that a new error code needs to be assigned in the maint branch).

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibcom_err: deal with the fact that the Hurd error messages are not zero-based
Theodore Ts'o [Wed, 8 Jan 2020 15:59:37 +0000 (10:59 -0500)]
libcom_err: deal with the fact that the Hurd error messages are not zero-based

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoUpdate release notes, etc., for the 1.45.5 release v1.45.5
Theodore Ts'o [Mon, 6 Jan 2020 04:54:30 +0000 (23:54 -0500)]
Update release notes, etc., for the 1.45.5 release

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: always compile swapfs functions on all architectures
Theodore Ts'o [Mon, 6 Jan 2020 23:01:48 +0000 (18:01 -0500)]
libext2fs: always compile swapfs functions on all architectures

By only compiling the ext2fs_swap_* functions on big-endian systems,
it causes debian/libext2fs2.symbols to need to be different on
different little-endian vs big-endian architectures.  Including the
ext2fS_swap_* functions increases the size of the library by ~6k,
which is not a big deal.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2scrub, e2scrub_all: don't sleep unnecessarily in exitcode
Theodore Ts'o [Mon, 6 Jan 2020 21:01:23 +0000 (16:01 -0500)]
e2scrub, e2scrub_all: don't sleep unnecessarily in exitcode

The two second sleep is only needed in e2scrub, and when there is a
failure, so that systemd has a chance to gather the log output before
e2scrub exits.  It's not needed if the script is exiting successfully,
and it's never needed for e2scrub_all ever.

Addresses-Debian-Bug: #948193
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agodebian: add autopkgtest files
Theodore Ts'o [Mon, 6 Jan 2020 16:47:21 +0000 (11:47 -0500)]
debian: add autopkgtest files

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: don't scan /etc/mtab if file system not found in /proc/mounts
Theodore Ts'o [Mon, 6 Jan 2020 19:42:01 +0000 (14:42 -0500)]
libext2fs: don't scan /etc/mtab if file system not found in /proc/mounts

Previously we would scan /etc/mtab if the device is not found in
/proc/mounts.  This is because previously, /etc/mtab would have the
filename for a loopback mount, while /proc/mounts would only have
something like /dev/loop0.  Since on many systems /etc/mtab is now a
symlink to /proc/mounts, ismounted.c has a special function,
check_loop_mounted.

For this reason, it's not necessary to fall back to trying to scan
/etc/mtab if a device / filename is not found from scanning
/proc/mounts.  This also prevents failures if the file /etc/mtab does
not exist but /proc/mounts does exist when checking to see if a device
is mounted when it isn't.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2fsck: don't check for future superblock times if checkinterval == 0
Theodore Ts'o [Thu, 2 Jan 2020 02:50:27 +0000 (21:50 -0500)]
e2fsck: don't check for future superblock times if checkinterval == 0

We are no longer enabling periodic file system checks by default in
mke2fs.  The only reason why we force file system checks if the last
mount time or last write time in the superblock is if this might
bypass the periodic file systme checks.  So if the checkinterval is
zero, skip the last mount/write time checks since there's no reason to
force a check just because the system clock is incorrect.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agodebian: update debhelper compat level to 12
Theodore Ts'o [Thu, 2 Jan 2020 01:40:43 +0000 (20:40 -0500)]
debian: update debhelper compat level to 12

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoconfig: update config.{guess,sub}
Theodore Ts'o [Wed, 1 Jan 2020 20:16:41 +0000 (15:16 -0500)]
config: update config.{guess,sub}

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agopo: update zh_CN.po (from translationproject.org)
Boyuan Yang [Wed, 1 Jan 2020 19:33:29 +0000 (14:33 -0500)]
po: update zh_CN.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agopo: update ms.po (from translationproject.org)
Sharuzzaman Ahmat Raslan [Wed, 1 Jan 2020 19:33:29 +0000 (14:33 -0500)]
po: update ms.po (from translationproject.org)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoDrop use of -pedantic when doing gcc-wall
Theodore Ts'o [Wed, 1 Jan 2020 00:48:37 +0000 (19:48 -0500)]
Drop use of -pedantic when doing gcc-wall

With newer versions of gcc -pedantic is *super* pedantic, and
generates way too much noise.  So we drop it, and thus we don't need
util/gcc-wall-cleanup and util/static-analysis-cleanup.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: use ext2fs_file_llseek in inode_io.c
Theodore Ts'o [Wed, 1 Jan 2020 00:37:31 +0000 (19:37 -0500)]
libext2fs: use ext2fs_file_llseek in inode_io.c

Enable the use of files > 2GB when using the inode_io manager.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: chage ext2_off_t and ext2_off64_t to be signed types
Theodore Ts'o [Wed, 1 Jan 2020 00:00:49 +0000 (19:00 -0500)]
libext2fs: chage ext2_off_t and ext2_off64_t to be signed types

The ext2_off_t and ext2_off64_t types are used by ext2_file_lseek()
and ext2_file_llseek(), and they need to be signed so that it can be a
negative offset from the end of the file when EXT2_SEEK_END is used.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agolibext2fs: use __u64 instead of ext2_off64_t in qcow.c
Theodore Ts'o [Tue, 31 Dec 2019 22:16:25 +0000 (17:16 -0500)]
libext2fs: use __u64 instead of ext2_off64_t in qcow.c

The type ext2_off64_t should only be used in the context of the ext2fs
library's llseek() and ftruncate() analogs, ext2_file_llseek() and
ext2_inode_set_size().  That's because like the POSIX.1's off_t, it
needs to be a signed integer value so that SEEK_END will work
correctly.

qcow.c's use of ext2_off64_t is only internal, and not in any exposed
interfaces, so changes nothing; it just prepares us to be able to
change the type of ext2_off64_t.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agomke2fs: fix setting bad blocks in the block bitmap
Li Dongyang [Wed, 20 Nov 2019 04:35:24 +0000 (04:35 +0000)]
mke2fs: fix setting bad blocks in the block bitmap

We mark the bad blocks as used on fs->block_map before allocating
group tables.  Don't translate the block number to cluster number when
doing this, the fs->block_map is still a block-granularity allocation
map, it will be coverted later by ext2fs_convert_subcluster_bitmap().

Signed-off-by: Li Dongyang <dongyangli@ddn.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoe2image: remove redundant -fr from man page and usage message
Benno Schulenberg [Thu, 5 Dec 2019 17:57:35 +0000 (18:57 +0100)]
e2image: remove redundant -fr from man page and usage message

Also, add a missing dash and two missing brackets and two missing
spaces, and remove three excess spaces.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
4 years agoAOSP: e2fsdroid: Skip Base FS entries that no longer exist.
David Anderson [Sat, 7 Dec 2019 00:48:52 +0000 (16:48 -0800)]
AOSP: e2fsdroid: Skip Base FS entries that no longer exist.

Don't reserve blocks in the base map if the file does not exist in the
target image. This can happen if a file is removed or renamed in between
two builds. If the removed file is quite large, skipping it is important
since otherwise it will prevent blocks from being allocated for new files.

Bug: 145316683
Test: e2fsdroid with dynamic partitions
Change-Id: I63a9372c58adeaae3e1235fd92fed78a284ed391
From AOSP commit: 2b6646a3d2a7dd9972275cb829239ae033762da5