1. 07 11月, 2019 1 次提交
    • E
      ext4: add support for IV_INO_LBLK_64 encryption policies · b925acb8
      Eric Biggers 提交于
      IV_INO_LBLK_64 encryption policies have special requirements from the
      filesystem beyond those of the existing encryption policies:
      
      - Inode numbers must never change, even if the filesystem is resized.
      - Inode numbers must be <= 32 bits.
      - File logical block numbers must be <= 32 bits.
      
      ext4 has 32-bit inode and file logical block numbers.  However,
      resize2fs can re-number inodes when shrinking an ext4 filesystem.
      
      However, typically the people who would want to use this format don't
      care about filesystem shrinking.  They'd be fine with a solution that
      just prevents the filesystem from being shrunk.
      
      Therefore, add a new feature flag EXT4_FEATURE_COMPAT_STABLE_INODES that
      will do exactly that.  Then wire up the fscrypt_operations to expose
      this flag to fs/crypto/, so that it allows IV_INO_LBLK_64 policies when
      this flag is set.
      Acked-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      b925acb8
  2. 30 8月, 2019 1 次提交
    • D
      ext4: Initialize timestamps limits · 4881c497
      Deepa Dinamani 提交于
      ext4 has different overflow limits for max filesystem
      timestamps based on the extra bytes available.
      
      The timestamp limits are calculated according to the
      encoding table in
      a4dad1aei(ext4: Fix handling of extended tv_sec):
      
      * extra  msb of                         adjust for signed
      * epoch  32-bit                         32-bit tv_sec to
      * bits   time    decoded 64-bit tv_sec  64-bit tv_sec      valid time range
      * 0 0    1    -0x80000000..-0x00000001  0x000000000   1901-12-13..1969-12-31
      * 0 0    0    0x000000000..0x07fffffff  0x000000000   1970-01-01..2038-01-19
      * 0 1    1    0x080000000..0x0ffffffff  0x100000000   2038-01-19..2106-02-07
      * 0 1    0    0x100000000..0x17fffffff  0x100000000   2106-02-07..2174-02-25
      * 1 0    1    0x180000000..0x1ffffffff  0x200000000   2174-02-25..2242-03-16
      * 1 0    0    0x200000000..0x27fffffff  0x200000000   2242-03-16..2310-04-04
      * 1 1    1    0x280000000..0x2ffffffff  0x300000000   2310-04-04..2378-04-22
      * 1 1    0    0x300000000..0x37fffffff  0x300000000   2378-04-22..2446-05-10
      
      Note that the time limits are not correct for deletion times.
      
      Added a warn when an inode cannot be extended to incorporate an
      extended timestamp.
      Signed-off-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
      Acked-by: NJeff Layton <jlayton@kernel.org>
      Cc: tytso@mit.edu
      Cc: adilger.kernel@dilger.ca
      Cc: linux-ext4@vger.kernel.org
      4881c497
  3. 28 8月, 2019 1 次提交
    • Z
      ext4: fix integer overflow when calculating commit interval · 9ba55543
      zhangyi (F) 提交于
      If user specify a large enough value of "commit=" option, it may trigger
      signed integer overflow which may lead to sbi->s_commit_interval becomes
      a large or small value, zero in particular.
      
      UBSAN: Undefined behaviour in ../fs/ext4/super.c:1592:31
      signed integer overflow:
      536870912 * 1000 cannot be represented in type 'int'
      [...]
      Call trace:
      [...]
      [<ffffff9008a2d120>] ubsan_epilogue+0x34/0x9c lib/ubsan.c:166
      [<ffffff9008a2d8b8>] handle_overflow+0x228/0x280 lib/ubsan.c:197
      [<ffffff9008a2d95c>] __ubsan_handle_mul_overflow+0x4c/0x68 lib/ubsan.c:218
      [<ffffff90086d070c>] handle_mount_opt fs/ext4/super.c:1592 [inline]
      [<ffffff90086d070c>] parse_options+0x1724/0x1a40 fs/ext4/super.c:1773
      [<ffffff90086d51c4>] ext4_remount+0x2ec/0x14a0 fs/ext4/super.c:4834
      [...]
      
      Although it is not a big deal, still silence the UBSAN by limit the
      input value.
      Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: NJan Kara <jack@suse.cz>
      9ba55543
  4. 13 8月, 2019 3 次提交
    • E
      ext4: add fs-verity read support · 22cfe4b4
      Eric Biggers 提交于
      Make ext4_mpage_readpages() verify data as it is read from fs-verity
      files, using the helper functions from fs/verity/.
      
      To support both encryption and verity simultaneously, this required
      refactoring the decryption workflow into a generic "post-read
      processing" workflow which can do decryption, verification, or both.
      
      The case where the ext4 block size is not equal to the PAGE_SIZE is not
      supported yet, since in that case ext4_mpage_readpages() sometimes falls
      back to block_read_full_page(), which does not support fs-verity yet.
      Co-developed-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      22cfe4b4
    • E
      ext4: add basic fs-verity support · c93d8f88
      Eric Biggers 提交于
      Add most of fs-verity support to ext4.  fs-verity is a filesystem
      feature that enables transparent integrity protection and authentication
      of read-only files.  It uses a dm-verity like mechanism at the file
      level: a Merkle tree is used to verify any block in the file in
      log(filesize) time.  It is implemented mainly by helper functions in
      fs/verity/.  See Documentation/filesystems/fsverity.rst for the full
      documentation.
      
      This commit adds all of ext4 fs-verity support except for the actual
      data verification, including:
      
      - Adding a filesystem feature flag and an inode flag for fs-verity.
      
      - Implementing the fsverity_operations to support enabling verity on an
        inode and reading/writing the verity metadata.
      
      - Updating ->write_begin(), ->write_end(), and ->writepages() to support
        writing verity metadata pages.
      
      - Calling the fs-verity hooks for ->open(), ->setattr(), and ->ioctl().
      
      ext4 stores the verity metadata (Merkle tree and fsverity_descriptor)
      past the end of the file, starting at the first 64K boundary beyond
      i_size.  This approach works because (a) verity files are readonly, and
      (b) pages fully beyond i_size aren't visible to userspace but can be
      read/written internally by ext4 with only some relatively small changes
      to ext4.  This approach avoids having to depend on the EA_INODE feature
      and on rearchitecturing ext4's xattr support to support paging
      multi-gigabyte xattrs into memory, and to support encrypting xattrs.
      Note that the verity metadata *must* be encrypted when the file is,
      since it contains hashes of the plaintext data.
      
      This patch incorporates work by Theodore Ts'o and Chandan Rajendra.
      Reviewed-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      c93d8f88
    • E
      ext4: wire up new fscrypt ioctls · 29b3692e
      Eric Biggers 提交于
      Wire up the new ioctls for adding and removing fscrypt keys to/from the
      filesystem, and the new ioctl for retrieving v2 encryption policies.
      
      The key removal ioctls also required making ext4_drop_inode() call
      fscrypt_drop_inode().
      
      For more details see Documentation/filesystems/fscrypt.rst and the
      fscrypt patches that added the implementation of these ioctls.
      Reviewed-by: NTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      29b3692e
  5. 18 5月, 2019 1 次提交
  6. 12 5月, 2019 1 次提交
  7. 02 5月, 2019 1 次提交
  8. 01 5月, 2019 1 次提交
  9. 26 4月, 2019 2 次提交
    • G
      ext4: Support case-insensitive file name lookups · b886ee3e
      Gabriel Krisman Bertazi 提交于
      This patch implements the actual support for case-insensitive file name
      lookups in ext4, based on the feature bit and the encoding stored in the
      superblock.
      
      A filesystem that has the casefold feature set is able to configure
      directories with the +F (EXT4_CASEFOLD_FL) attribute, enabling lookups
      to succeed in that directory in a case-insensitive fashion, i.e: match
      a directory entry even if the name used by userspace is not a byte per
      byte match with the disk name, but is an equivalent case-insensitive
      version of the Unicode string.  This operation is called a
      case-insensitive file name lookup.
      
      The feature is configured as an inode attribute applied to directories
      and inherited by its children.  This attribute can only be enabled on
      empty directories for filesystems that support the encoding feature,
      thus preventing collision of file names that only differ by case.
      
      * dcache handling:
      
      For a +F directory, Ext4 only stores the first equivalent name dentry
      used in the dcache. This is done to prevent unintentional duplication of
      dentries in the dcache, while also allowing the VFS code to quickly find
      the right entry in the cache despite which equivalent string was used in
      a previous lookup, without having to resort to ->lookup().
      
      d_hash() of casefolded directories is implemented as the hash of the
      casefolded string, such that we always have a well-known bucket for all
      the equivalencies of the same string. d_compare() uses the
      utf8_strncasecmp() infrastructure, which handles the comparison of
      equivalent, same case, names as well.
      
      For now, negative lookups are not inserted in the dcache, since they
      would need to be invalidated anyway, because we can't trust missing file
      dentries.  This is bad for performance but requires some leveraging of
      the vfs layer to fix.  We can live without that for now, and so does
      everyone else.
      
      * on-disk data:
      
      Despite using a specific version of the name as the internal
      representation within the dcache, the name stored and fetched from the
      disk is a byte-per-byte match with what the user requested, making this
      implementation 'name-preserving'. i.e. no actual information is lost
      when writing to storage.
      
      DX is supported by modifying the hashes used in +F directories to make
      them case/encoding-aware.  The new disk hashes are calculated as the
      hash of the full casefolded string, instead of the string directly.
      This allows us to efficiently search for file names in the htree without
      requiring the user to provide an exact name.
      
      * Dealing with invalid sequences:
      
      By default, when a invalid UTF-8 sequence is identified, ext4 will treat
      it as an opaque byte sequence, ignoring the encoding and reverting to
      the old behavior for that unique file.  This means that case-insensitive
      file name lookup will not work only for that file.  An optional bit can
      be set in the superblock telling the filesystem code and userspace tools
      to enforce the encoding.  When that optional bit is set, any attempt to
      create a file name using an invalid UTF-8 sequence will fail and return
      an error to userspace.
      
      * Normalization algorithm:
      
      The UTF-8 algorithms used to compare strings in ext4 is implemented
      lives in fs/unicode, and is based on a previous version developed by
      SGI.  It implements the Canonical decomposition (NFD) algorithm
      described by the Unicode specification 12.1, or higher, combined with
      the elimination of ignorable code points (NFDi) and full
      case-folding (CF) as documented in fs/unicode/utf8_norm.c.
      
      NFD seems to be the best normalization method for EXT4 because:
      
        - It has a lower cost than NFC/NFKC (which requires
          decomposing to NFD as an intermediary step)
        - It doesn't eliminate important semantic meaning like
          compatibility decompositions.
      
      Although:
      
        - This implementation is not completely linguistic accurate, because
        different languages have conflicting rules, which would require the
        specialization of the filesystem to a given locale, which brings all
        sorts of problems for removable media and for users who use more than
        one language.
      Signed-off-by: NGabriel Krisman Bertazi <krisman@collabora.co.uk>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      b886ee3e
    • G
      ext4: include charset encoding information in the superblock · c83ad55e
      Gabriel Krisman Bertazi 提交于
      Support for encoding is considered an incompatible feature, since it has
      potential to create collisions of file names in existing filesystems.
      If the feature flag is not enabled, the entire filesystem will operate
      on opaque byte sequences, respecting the original behavior.
      
      The s_encoding field stores a magic number indicating the encoding
      format and version used globally by file and directory names in the
      filesystem.  The s_encoding_flags defines policies for using the charset
      encoding, like how to handle invalid sequences.  The magic number is
      mapped to the exact charset table, but the mapping is specific to ext4.
      Since we don't have any commitment to support old encodings, the only
      encoding I am supporting right now is utf8-12.1.0.
      
      The current implementation prevents the user from enabling encoding and
      per-directory encryption on the same filesystem at the same time.  The
      incompatibility between these features lies in how we do efficient
      directory searches when we cannot be sure the encryption of the user
      provided fname will match the actual hash stored in the disk without
      decrypting every directory entry, because of normalization cases.  My
      quickest solution is to simply block the concurrent use of these
      features for now, and enable it later, once we have a better solution.
      Signed-off-by: NGabriel Krisman Bertazi <krisman@collabora.co.uk>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      c83ad55e
  10. 25 4月, 2019 1 次提交
  11. 18 4月, 2019 1 次提交
    • E
      fscrypt: cache decrypted symlink target in ->i_link · 2c58d548
      Eric Biggers 提交于
      Path lookups that traverse encrypted symlink(s) are very slow because
      each encrypted symlink needs to be decrypted each time it's followed.
      This also involves dropping out of rcu-walk mode.
      
      Make encrypted symlinks faster by caching the decrypted symlink target
      in ->i_link.  The first call to fscrypt_get_symlink() sets it.  Then,
      the existing VFS path lookup code uses the non-NULL ->i_link to take the
      fast path where ->get_link() isn't called, and lookups in rcu-walk mode
      remain in rcu-walk mode.
      
      Also set ->i_link immediately when a new encrypted symlink is created.
      
      To safely free the symlink target after an RCU grace period has elapsed,
      introduce a new function fscrypt_free_inode(), and make the relevant
      filesystems call it just before actually freeing the inode.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      2c58d548
  12. 07 4月, 2019 1 次提交
    • C
      block: remove CONFIG_LBDAF · 72deb455
      Christoph Hellwig 提交于
      Currently support for 64-bit sector_t and blkcnt_t is optional on 32-bit
      architectures.  These types are required to support block device and/or
      file sizes larger than 2 TiB, and have generally defaulted to on for
      a long time.  Enabling the option only increases the i386 tinyconfig
      size by 145 bytes, and many data structures already always use
      64-bit values for their in-core and on-disk data structures anyway,
      so there should not be a large change in dynamic memory usage either.
      
      Dropping this option removes a somewhat weird non-default config that
      has cause various bugs or compiler warnings when actually used.
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      72deb455
  13. 15 3月, 2019 1 次提交
    • J
      ext4: avoid panic during forced reboot · 1dc1097f
      Jan Kara 提交于
      When admin calls "reboot -f" - i.e., does a hard system reboot by
      directly calling reboot(2) - ext4 filesystem mounted with errors=panic
      can panic the system. This happens because the underlying device gets
      disabled without unmounting the filesystem and thus some syscall running
      in parallel to reboot(2) can result in the filesystem getting IO errors.
      
      This is somewhat surprising to the users so try improve the behavior by
      switching to errors=remount-ro behavior when the system is running
      reboot(2).
      Signed-off-by: NJan Kara <jack@suse.cz>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      1dc1097f
  14. 15 2月, 2019 1 次提交
    • A
      ext4: don't update s_rev_level if not required · c9e716eb
      Andreas Dilger 提交于
      Don't update the superblock s_rev_level during mount if it isn't
      actually necessary, only if superblock features are being set by
      the kernel.  This was originally added for ext3 since it always
      set the INCOMPAT_RECOVER and HAS_JOURNAL features during mount,
      but this is not needed since no journal mode was added to ext4.
      
      That will allow Geert to mount his 20-year-old ext2 rev 0.0 m68k
      filesystem, as a testament of the backward compatibility of ext4.
      
      Fixes: 0390131b ("ext4: Allow ext4 to run without a journal")
      Signed-off-by: NAndreas Dilger <adilger@dilger.ca>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      c9e716eb
  15. 24 1月, 2019 1 次提交
  16. 31 12月, 2018 1 次提交
    • T
      ext4: avoid kernel warning when writing the superblock to a dead device · e8680786
      Theodore Ts'o 提交于
      The xfstests generic/475 test switches the underlying device with
      dm-error while running a stress test.  This results in a large number
      of file system errors, and since we can't lock the buffer head when
      marking the superblock dirty in the ext4_grp_locked_error() case, it's
      possible the superblock to be !buffer_uptodate() without
      buffer_write_io_error() being true.
      
      We need to set buffer_uptodate() before we call mark_buffer_dirty() or
      this will trigger a WARN_ON.  It's safe to do this since the
      superblock must have been properly read into memory or the mount would
      have been successful.  So if buffer_uptodate() is not set, we can
      safely assume that this happened due to a failed attempt to write the
      superblock.
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      e8680786
  17. 20 12月, 2018 2 次提交
    • T
      ext4: force inode writes when nfsd calls commit_metadata() · fde87268
      Theodore Ts'o 提交于
      Some time back, nfsd switched from calling vfs_fsync() to using a new
      commit_metadata() hook in export_operations().  If the file system did
      not provide a commit_metadata() hook, it fell back to using
      sync_inode_metadata().  Unfortunately doesn't work on all file
      systems.  In particular, it doesn't work on ext4 due to how the inode
      gets journalled --- the VFS writeback code will not always call
      ext4_write_inode().
      
      So we need to provide our own ext4_nfs_commit_metdata() method which
      calls ext4_write_inode() directly.
      
      Google-Bug-Id: 121195940
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      fde87268
    • T
      ext4: avoid declaring fs inconsistent due to invalid file handles · 8a363970
      Theodore Ts'o 提交于
      If we receive a file handle, either from NFS or open_by_handle_at(2),
      and it points at an inode which has not been initialized, and the file
      system has metadata checksums enabled, we shouldn't try to get the
      inode, discover the checksum is invalid, and then declare the file
      system as being inconsistent.
      
      This can be reproduced by creating a test file system via "mke2fs -t
      ext4 -O metadata_csum /tmp/foo.img 8M", mounting it, cd'ing into that
      directory, and then running the following program.
      
      #define _GNU_SOURCE
      #include <fcntl.h>
      
      struct handle {
      	struct file_handle fh;
      	unsigned char fid[MAX_HANDLE_SZ];
      };
      
      int main(int argc, char **argv)
      {
      	struct handle h = {{8, 1 }, { 12, }};
      
      	open_by_handle_at(AT_FDCWD, &h.fh, O_RDONLY);
      	return 0;
      }
      
      Google-Bug-Id: 120690101
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      8a363970
  18. 04 12月, 2018 4 次提交
  19. 26 11月, 2018 1 次提交
    • T
      ext4: add ext4_sb_bread() to disambiguate ENOMEM cases · fb265c9c
      Theodore Ts'o 提交于
      Today, when sb_bread() returns NULL, this can either be because of an
      I/O error or because the system failed to allocate the buffer.  Since
      it's an old interface, changing would require changing many call
      sites.
      
      So instead we create our own ext4_sb_bread(), which also allows us to
      set the REQ_META flag.
      
      Also fixed a problem in the xattr code where a NULL return in a
      function could also mean that the xattr was not found, which could
      lead to the wrong error getting returned to userspace.
      
      Fixes: ac27a0ec ("ext4: initial copy of files from ext3")
      Cc: stable@kernel.org # 2.6.19
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      fb265c9c
  20. 07 11月, 2018 2 次提交
  21. 12 10月, 2018 1 次提交
  22. 02 10月, 2018 1 次提交
  23. 16 9月, 2018 1 次提交
  24. 02 9月, 2018 1 次提交
    • T
      ext4: recalucate superblock checksum after updating free blocks/inodes · 4274f516
      Theodore Ts'o 提交于
      When mounting the superblock, ext4_fill_super() calculates the free
      blocks and free inodes and stores them in the superblock.  It's not
      strictly necessary, since we don't use them any more, but it's nice to
      keep them roughly aligned to reality.
      
      Since it's not critical for file system correctness, the code doesn't
      call ext4_commit_super().  The problem is that it's in
      ext4_commit_super() that we recalculate the superblock checksum.  So
      if we're not going to call ext4_commit_super(), we need to call
      ext4_superblock_csum_set() to make sure the superblock checksum is
      consistent.
      
      Most of the time, this doesn't matter, since we end up calling
      ext4_commit_super() very soon thereafter, and definitely by the time
      the file system is unmounted.  However, it doesn't work in this
      sequence:
      
      mke2fs -Fq -t ext4 /dev/vdc 128M
      mount /dev/vdc /vdc
      cp xfstests/git-versions /vdc
      godown /vdc
      umount /vdc
      mount /dev/vdc
      tune2fs -l /dev/vdc
      
      With this commit, the "tune2fs -l" no longer fails.
      Reported-by: NChengguang Xu <cgxu519@gmx.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      
      
      4274f516
  25. 30 7月, 2018 5 次提交
    • W
      ext4: fix race when setting the bitmap corrupted flag · 9af0b3d1
      Wang Shilong 提交于
      Whenever we hit block or inode bitmap corruptions we set
      bit and then reduce this block group free inode/clusters
      counter to expose right available space.
      
      However some of ext4_mark_group_bitmap_corrupted() is called
      inside group spinlock, some are not, this could make it happen
      that we double reduce one block group free counters from system.
      
      Always hold group spinlock for it could fix it, but it looks
      a little heavy, we could use test_and_set_bit() to fix race
      problems here.
      Signed-off-by: NWang Shilong <wshilong@ddn.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      9af0b3d1
    • C
      ext4: check allocation failure when duplicating "data" in ext4_remount() · 21ac738e
      Chengguang Xu 提交于
      There is no check for allocation failure when duplicating
      "data" in ext4_remount(). Check for failure and return
      error -ENOMEM in this case.
      Signed-off-by: NChengguang Xu <cgxu519@gmx.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
      21ac738e
    • J
      ext4: fix warning message in ext4_enable_quotas() · 7f144fd0
      Junichi Uekawa 提交于
      Output the warning message before we clobber type and be -1 all the time.
      The error message would now be
      
      [    1.519791] EXT4-fs warning (device vdb): ext4_enable_quotas:5402:
      Failed to enable quota tracking (type=0, err=-3). Please run e2fsck to fix.
      Signed-off-by: NJunichi Uekawa <uekawa@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Reviewed-by: NAndreas Dilger <adilger@dilger.ca>
      7f144fd0
    • A
      ext4: super: extend timestamps to 40 bits · 6a0678a7
      Arnd Bergmann 提交于
      The inode timestamps use 34 bits in ext4, but the various timestamps in
      the superblock are limited to 32 bits. If every user accesses these as
      'unsigned', then this is good until year 2106, but it seems better to
      extend this a bit further in the process of removing the deprecated
      get_seconds() function.
      
      This adds another byte for each timestamp in the superblock, making
      them long enough to store timestamps beyond what is in the inodes,
      which seems good enough here (in ocfs2, they are already 64-bit wide,
      which is appropriate for a new layout).
      
      I did not modify e2fsprogs, which obviously needs the same change to
      actually interpret future timestamps correctly.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      6a0678a7
    • T
      ext4: fix check to prevent initializing reserved inodes · 50122847
      Theodore Ts'o 提交于
      Commit 8844618d: "ext4: only look at the bg_flags field if it is
      valid" will complain if block group zero does not have the
      EXT4_BG_INODE_ZEROED flag set.  Unfortunately, this is not correct,
      since a freshly created file system has this flag cleared.  It gets
      almost immediately after the file system is mounted read-write --- but
      the following somewhat unlikely sequence will end up triggering a
      false positive report of a corrupted file system:
      
         mkfs.ext4 /dev/vdc
         mount -o ro /dev/vdc /vdc
         mount -o remount,rw /dev/vdc
      
      Instead, when initializing the inode table for block group zero, test
      to make sure that itable_unused count is not too large, since that is
      the case that will result in some or all of the reserved inodes
      getting cleared.
      
      This fixes the failures reported by Eric Whiteney when running
      generic/230 and generic/231 in the the nojournal test case.
      
      Fixes: 8844618d ("ext4: only look at the bg_flags field if it is valid")
      Reported-by: NEric Whitney <enwlinux@gmail.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      50122847
  26. 18 7月, 2018 1 次提交
  27. 09 7月, 2018 2 次提交
    • T
      ext4: clear mmp sequence number when remounting read-only · 2dca60d9
      Theodore Ts'o 提交于
      Previously, when an MMP-protected file system is remounted read-only,
      the kmmpd thread would exit the next time it woke up (a few seconds
      later), without resetting the MMP sequence number back to
      EXT4_MMP_SEQ_CLEAN.
      
      Fix this by explicitly killing the MMP thread when the file system is
      remounted read-only.
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: Andreas Dilger <adilger@dilger.ca>
      2dca60d9
    • T
      ext4: fix false negatives *and* false positives in ext4_check_descriptors() · 44de022c
      Theodore Ts'o 提交于
      Ext4_check_descriptors() was getting called before s_gdb_count was
      initialized.  So for file systems w/o the meta_bg feature, allocation
      bitmaps could overlap the block group descriptors and ext4 wouldn't
      notice.
      
      For file systems with the meta_bg feature enabled, there was a
      fencepost error which would cause the ext4_check_descriptors() to
      incorrectly believe that the block allocation bitmap overlaps with the
      block group descriptor blocks, and it would reject the mount.
      
      Fix both of these problems.
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      Cc: stable@vger.kernel.org
      44de022c