Commit 354c6e07 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4

Pull ext4 fixes from Ted Ts'o:
 "Fix a variety of bugs, many of which were found by folks using fuzzing
  or error injection.

  Also fix up how test_dummy_encryption mount option is handled for the
  new mount API.

  Finally, fix/cleanup a number of comments and ext4 Documentation
  files"

* tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
  ext4: fix a doubled word "need" in a comment
  ext4: add reserved GDT blocks check
  ext4: make variable "count" signed
  ext4: correct the judgment of BUG in ext4_mb_normalize_request
  ext4: fix bug_on ext4_mb_use_inode_pa
  ext4: fix up test_dummy_encryption handling for new mount API
  ext4: use kmemdup() to replace kmalloc + memcpy
  ext4: fix super block checksum incorrect after mount
  ext4: improve write performance with disabled delalloc
  ext4: fix warning when submitting superblock in ext4_commit_super()
  ext4, doc: remove unnecessary escaping
  ext4: fix incorrect comment in ext4_bio_write_page()
  fs: fix jbd2_journal_try_to_free_buffers() kernel-doc comment
parents ace2045e 1f3ddff3
...@@ -13,8 +13,8 @@ disappeared as of Linux 3.0. ...@@ -13,8 +13,8 @@ disappeared as of Linux 3.0.
There are two places where extended attributes can be found. The first There are two places where extended attributes can be found. The first
place is between the end of each inode entry and the beginning of the place is between the end of each inode entry and the beginning of the
next inode entry. For example, if inode.i\_extra\_isize = 28 and next inode entry. For example, if inode.i_extra_isize = 28 and
sb.inode\_size = 256, then there are 256 - (128 + 28) = 100 bytes sb.inode_size = 256, then there are 256 - (128 + 28) = 100 bytes
available for in-inode extended attribute storage. The second place available for in-inode extended attribute storage. The second place
where extended attributes can be found is in the block pointed to by where extended attributes can be found is in the block pointed to by
``inode.i_file_acl``. As of Linux 3.11, it is not possible for this ``inode.i_file_acl``. As of Linux 3.11, it is not possible for this
...@@ -38,8 +38,8 @@ Extended attributes, when stored after the inode, have a header ...@@ -38,8 +38,8 @@ Extended attributes, when stored after the inode, have a header
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- h\_magic - h_magic
- Magic number for identification, 0xEA020000. This value is set by the - Magic number for identification, 0xEA020000. This value is set by the
Linux driver, though e2fsprogs doesn't seem to check it(?) Linux driver, though e2fsprogs doesn't seem to check it(?)
...@@ -55,28 +55,28 @@ The beginning of an extended attribute block is in ...@@ -55,28 +55,28 @@ The beginning of an extended attribute block is in
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- h\_magic - h_magic
- Magic number for identification, 0xEA020000. - Magic number for identification, 0xEA020000.
* - 0x4 * - 0x4
- \_\_le32 - __le32
- h\_refcount - h_refcount
- Reference count. - Reference count.
* - 0x8 * - 0x8
- \_\_le32 - __le32
- h\_blocks - h_blocks
- Number of disk blocks used. - Number of disk blocks used.
* - 0xC * - 0xC
- \_\_le32 - __le32
- h\_hash - h_hash
- Hash value of all attributes. - Hash value of all attributes.
* - 0x10 * - 0x10
- \_\_le32 - __le32
- h\_checksum - h_checksum
- Checksum of the extended attribute block. - Checksum of the extended attribute block.
* - 0x14 * - 0x14
- \_\_u32 - __u32
- h\_reserved[3] - h_reserved[3]
- Zero. - Zero.
The checksum is calculated against the FS UUID, the 64-bit block number The checksum is calculated against the FS UUID, the 64-bit block number
...@@ -100,46 +100,46 @@ Attributes stored inside an inode do not need be stored in sorted order. ...@@ -100,46 +100,46 @@ Attributes stored inside an inode do not need be stored in sorted order.
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_u8 - __u8
- e\_name\_len - e_name_len
- Length of name. - Length of name.
* - 0x1 * - 0x1
- \_\_u8 - __u8
- e\_name\_index - e_name_index
- Attribute name index. There is a discussion of this below. - Attribute name index. There is a discussion of this below.
* - 0x2 * - 0x2
- \_\_le16 - __le16
- e\_value\_offs - e_value_offs
- Location of this attribute's value on the disk block where it is stored. - Location of this attribute's value on the disk block where it is stored.
Multiple attributes can share the same value. For an inode attribute Multiple attributes can share the same value. For an inode attribute
this value is relative to the start of the first entry; for a block this this value is relative to the start of the first entry; for a block this
value is relative to the start of the block (i.e. the header). value is relative to the start of the block (i.e. the header).
* - 0x4 * - 0x4
- \_\_le32 - __le32
- e\_value\_inum - e_value_inum
- The inode where the value is stored. Zero indicates the value is in the - The inode where the value is stored. Zero indicates the value is in the
same block as this entry. This field is only used if the same block as this entry. This field is only used if the
INCOMPAT\_EA\_INODE feature is enabled. INCOMPAT_EA_INODE feature is enabled.
* - 0x8 * - 0x8
- \_\_le32 - __le32
- e\_value\_size - e_value_size
- Length of attribute value. - Length of attribute value.
* - 0xC * - 0xC
- \_\_le32 - __le32
- e\_hash - e_hash
- Hash value of attribute name and attribute value. The kernel doesn't - Hash value of attribute name and attribute value. The kernel doesn't
update the hash for in-inode attributes, so for that case this value update the hash for in-inode attributes, so for that case this value
must be zero, because e2fsck validates any non-zero hash regardless of must be zero, because e2fsck validates any non-zero hash regardless of
where the xattr lives. where the xattr lives.
* - 0x10 * - 0x10
- char - char
- e\_name[e\_name\_len] - e_name[e_name_len]
- Attribute name. Does not include trailing NULL. - Attribute name. Does not include trailing NULL.
Attribute values can follow the end of the entry table. There appears to Attribute values can follow the end of the entry table. There appears to
be a requirement that they be aligned to 4-byte boundaries. The values be a requirement that they be aligned to 4-byte boundaries. The values
are stored starting at the end of the block and grow towards the are stored starting at the end of the block and grow towards the
xattr\_header/xattr\_entry table. When the two collide, the overflow is xattr_header/xattr_entry table. When the two collide, the overflow is
put into a separate disk block. If the disk block fills up, the put into a separate disk block. If the disk block fills up, the
filesystem returns -ENOSPC. filesystem returns -ENOSPC.
...@@ -167,15 +167,15 @@ the key name. Here is a map of name index values to key prefixes: ...@@ -167,15 +167,15 @@ the key name. Here is a map of name index values to key prefixes:
* - 1 * - 1
- “user.” - “user.”
* - 2 * - 2
- “system.posix\_acl\_access” - “system.posix_acl_access”
* - 3 * - 3
- “system.posix\_acl\_default” - “system.posix_acl_default”
* - 4 * - 4
- “trusted.” - “trusted.”
* - 6 * - 6
- “security.” - “security.”
* - 7 * - 7
- “system.” (inline\_data only?) - “system.” (inline_data only?)
* - 8 * - 8
- “system.richacl” (SuSE kernels only?) - “system.richacl” (SuSE kernels only?)
......
...@@ -23,7 +23,7 @@ means that a block group addresses 32 gigabytes instead of 128 megabytes, ...@@ -23,7 +23,7 @@ means that a block group addresses 32 gigabytes instead of 128 megabytes,
also shrinking the amount of file system overhead for metadata. also shrinking the amount of file system overhead for metadata.
The administrator can set a block cluster size at mkfs time (which is The administrator can set a block cluster size at mkfs time (which is
stored in the s\_log\_cluster\_size field in the superblock); from then stored in the s_log_cluster_size field in the superblock); from then
on, the block bitmaps track clusters, not individual blocks. This means on, the block bitmaps track clusters, not individual blocks. This means
that block groups can be several gigabytes in size (instead of just that block groups can be several gigabytes in size (instead of just
128MiB); however, the minimum allocation unit becomes a cluster, not a 128MiB); however, the minimum allocation unit becomes a cluster, not a
......
...@@ -9,15 +9,15 @@ group. ...@@ -9,15 +9,15 @@ group.
The inode bitmap records which entries in the inode table are in use. The inode bitmap records which entries in the inode table are in use.
As with most bitmaps, one bit represents the usage status of one data As with most bitmaps, one bit represents the usage status of one data
block or inode table entry. This implies a block group size of 8 \* block or inode table entry. This implies a block group size of 8 *
number\_of\_bytes\_in\_a\_logical\_block. number_of_bytes_in_a_logical_block.
NOTE: If ``BLOCK_UNINIT`` is set for a given block group, various parts NOTE: If ``BLOCK_UNINIT`` is set for a given block group, various parts
of the kernel and e2fsprogs code pretends that the block bitmap contains of the kernel and e2fsprogs code pretends that the block bitmap contains
zeros (i.e. all blocks in the group are free). However, it is not zeros (i.e. all blocks in the group are free). However, it is not
necessarily the case that no blocks are in use -- if ``meta_bg`` is set, necessarily the case that no blocks are in use -- if ``meta_bg`` is set,
the bitmaps and group descriptor live inside the group. Unfortunately, the bitmaps and group descriptor live inside the group. Unfortunately,
ext2fs\_test\_block\_bitmap2() will return '0' for those locations, ext2fs_test_block_bitmap2() will return '0' for those locations,
which produces confusing debugfs output. which produces confusing debugfs output.
Inode Table Inode Table
......
...@@ -56,39 +56,39 @@ established that the super block and the group descriptor table, if ...@@ -56,39 +56,39 @@ established that the super block and the group descriptor table, if
present, will be at the beginning of the block group. The bitmaps and present, will be at the beginning of the block group. The bitmaps and
the inode table can be anywhere, and it is quite possible for the the inode table can be anywhere, and it is quite possible for the
bitmaps to come after the inode table, or for both to be in different bitmaps to come after the inode table, or for both to be in different
groups (flex\_bg). Leftover space is used for file data blocks, indirect groups (flex_bg). Leftover space is used for file data blocks, indirect
block maps, extent tree blocks, and extended attributes. block maps, extent tree blocks, and extended attributes.
Flexible Block Groups Flexible Block Groups
--------------------- ---------------------
Starting in ext4, there is a new feature called flexible block groups Starting in ext4, there is a new feature called flexible block groups
(flex\_bg). In a flex\_bg, several block groups are tied together as one (flex_bg). In a flex_bg, several block groups are tied together as one
logical block group; the bitmap spaces and the inode table space in the logical block group; the bitmap spaces and the inode table space in the
first block group of the flex\_bg are expanded to include the bitmaps first block group of the flex_bg are expanded to include the bitmaps
and inode tables of all other block groups in the flex\_bg. For example, and inode tables of all other block groups in the flex_bg. For example,
if the flex\_bg size is 4, then group 0 will contain (in order) the if the flex_bg size is 4, then group 0 will contain (in order) the
superblock, group descriptors, data block bitmaps for groups 0-3, inode superblock, group descriptors, data block bitmaps for groups 0-3, inode
bitmaps for groups 0-3, inode tables for groups 0-3, and the remaining bitmaps for groups 0-3, inode tables for groups 0-3, and the remaining
space in group 0 is for file data. The effect of this is to group the space in group 0 is for file data. The effect of this is to group the
block group metadata close together for faster loading, and to enable block group metadata close together for faster loading, and to enable
large files to be continuous on disk. Backup copies of the superblock large files to be continuous on disk. Backup copies of the superblock
and group descriptors are always at the beginning of block groups, even and group descriptors are always at the beginning of block groups, even
if flex\_bg is enabled. The number of block groups that make up a if flex_bg is enabled. The number of block groups that make up a
flex\_bg is given by 2 ^ ``sb.s_log_groups_per_flex``. flex_bg is given by 2 ^ ``sb.s_log_groups_per_flex``.
Meta Block Groups Meta Block Groups
----------------- -----------------
Without the option META\_BG, for safety concerns, all block group Without the option META_BG, for safety concerns, all block group
descriptors copies are kept in the first block group. Given the default descriptors copies are kept in the first block group. Given the default
128MiB(2^27 bytes) block group size and 64-byte group descriptors, ext4 128MiB(2^27 bytes) block group size and 64-byte group descriptors, ext4
can have at most 2^27/64 = 2^21 block groups. This limits the entire can have at most 2^27/64 = 2^21 block groups. This limits the entire
filesystem size to 2^21 * 2^27 = 2^48bytes or 256TiB. filesystem size to 2^21 * 2^27 = 2^48bytes or 256TiB.
The solution to this problem is to use the metablock group feature The solution to this problem is to use the metablock group feature
(META\_BG), which is already in ext3 for all 2.6 releases. With the (META_BG), which is already in ext3 for all 2.6 releases. With the
META\_BG feature, ext4 filesystems are partitioned into many metablock META_BG feature, ext4 filesystems are partitioned into many metablock
groups. Each metablock group is a cluster of block groups whose group groups. Each metablock group is a cluster of block groups whose group
descriptor structures can be stored in a single disk block. For ext4 descriptor structures can be stored in a single disk block. For ext4
filesystems with 4 KB block size, a single metablock group partition filesystems with 4 KB block size, a single metablock group partition
...@@ -110,7 +110,7 @@ bytes, a meta-block group contains 32 block groups for filesystems with ...@@ -110,7 +110,7 @@ bytes, a meta-block group contains 32 block groups for filesystems with
a 1KB block size, and 128 block groups for filesystems with a 4KB a 1KB block size, and 128 block groups for filesystems with a 4KB
blocksize. Filesystems can either be created using this new block group blocksize. Filesystems can either be created using this new block group
descriptor layout, or existing filesystems can be resized on-line, and descriptor layout, or existing filesystems can be resized on-line, and
the field s\_first\_meta\_bg in the superblock will indicate the first the field s_first_meta_bg in the superblock will indicate the first
block group using this new layout. block group using this new layout.
Please see an important note about ``BLOCK_UNINIT`` in the section about Please see an important note about ``BLOCK_UNINIT`` in the section about
...@@ -121,15 +121,15 @@ Lazy Block Group Initialization ...@@ -121,15 +121,15 @@ Lazy Block Group Initialization
A new feature for ext4 are three block group descriptor flags that A new feature for ext4 are three block group descriptor flags that
enable mkfs to skip initializing other parts of the block group enable mkfs to skip initializing other parts of the block group
metadata. Specifically, the INODE\_UNINIT and BLOCK\_UNINIT flags mean metadata. Specifically, the INODE_UNINIT and BLOCK_UNINIT flags mean
that the inode and block bitmaps for that group can be calculated and that the inode and block bitmaps for that group can be calculated and
therefore the on-disk bitmap blocks are not initialized. This is therefore the on-disk bitmap blocks are not initialized. This is
generally the case for an empty block group or a block group containing generally the case for an empty block group or a block group containing
only fixed-location block group metadata. The INODE\_ZEROED flag means only fixed-location block group metadata. The INODE_ZEROED flag means
that the inode table has been initialized; mkfs will unset this flag and that the inode table has been initialized; mkfs will unset this flag and
rely on the kernel to initialize the inode tables in the background. rely on the kernel to initialize the inode tables in the background.
By not writing zeroes to the bitmaps and inode table, mkfs time is By not writing zeroes to the bitmaps and inode table, mkfs time is
reduced considerably. Note the feature flag is RO\_COMPAT\_GDT\_CSUM, reduced considerably. Note the feature flag is RO_COMPAT_GDT_CSUM,
but the dumpe2fs output prints this as “uninit\_bg”. They are the same but the dumpe2fs output prints this as “uninit_bg”. They are the same
thing. thing.
.. SPDX-License-Identifier: GPL-2.0 .. SPDX-License-Identifier: GPL-2.0
+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| i.i\_block Offset | Where It Points | | i.i_block Offset | Where It Points |
+=====================+==============================================================================================================================================================================================================================+ +=====================+==============================================================================================================================================================================================================================+
| 0 to 11 | Direct map to file blocks 0 to 11. | | 0 to 11 | Direct map to file blocks 0 to 11. |
+---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ +---------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
......
...@@ -4,7 +4,7 @@ Checksums ...@@ -4,7 +4,7 @@ Checksums
--------- ---------
Starting in early 2012, metadata checksums were added to all major ext4 Starting in early 2012, metadata checksums were added to all major ext4
and jbd2 data structures. The associated feature flag is metadata\_csum. and jbd2 data structures. The associated feature flag is metadata_csum.
The desired checksum algorithm is indicated in the superblock, though as The desired checksum algorithm is indicated in the superblock, though as
of October 2012 the only supported algorithm is crc32c. Some data of October 2012 the only supported algorithm is crc32c. Some data
structures did not have space to fit a full 32-bit checksum, so only the structures did not have space to fit a full 32-bit checksum, so only the
...@@ -20,7 +20,7 @@ encounters directory blocks that lack sufficient empty space to add a ...@@ -20,7 +20,7 @@ encounters directory blocks that lack sufficient empty space to add a
checksum, it will request that you run ``e2fsck -D`` to have the checksum, it will request that you run ``e2fsck -D`` to have the
directories rebuilt with checksums. This has the added benefit of directories rebuilt with checksums. This has the added benefit of
removing slack space from the directory files and rebalancing the htree removing slack space from the directory files and rebalancing the htree
indexes. If you \_ignore\_ this step, your directories will not be indexes. If you _ignore_ this step, your directories will not be
protected by a checksum! protected by a checksum!
The following table describes the data elements that go into each type The following table describes the data elements that go into each type
...@@ -35,39 +35,39 @@ of checksum. The checksum function is whatever the superblock describes ...@@ -35,39 +35,39 @@ of checksum. The checksum function is whatever the superblock describes
- Length - Length
- Ingredients - Ingredients
* - Superblock * - Superblock
- \_\_le32 - __le32
- The entire superblock up to the checksum field. The UUID lives inside - The entire superblock up to the checksum field. The UUID lives inside
the superblock. the superblock.
* - MMP * - MMP
- \_\_le32 - __le32
- UUID + the entire MMP block up to the checksum field. - UUID + the entire MMP block up to the checksum field.
* - Extended Attributes * - Extended Attributes
- \_\_le32 - __le32
- UUID + the entire extended attribute block. The checksum field is set to - UUID + the entire extended attribute block. The checksum field is set to
zero. zero.
* - Directory Entries * - Directory Entries
- \_\_le32 - __le32
- UUID + inode number + inode generation + the directory block up to the - UUID + inode number + inode generation + the directory block up to the
fake entry enclosing the checksum field. fake entry enclosing the checksum field.
* - HTREE Nodes * - HTREE Nodes
- \_\_le32 - __le32
- UUID + inode number + inode generation + all valid extents + HTREE tail. - UUID + inode number + inode generation + all valid extents + HTREE tail.
The checksum field is set to zero. The checksum field is set to zero.
* - Extents * - Extents
- \_\_le32 - __le32
- UUID + inode number + inode generation + the entire extent block up to - UUID + inode number + inode generation + the entire extent block up to
the checksum field. the checksum field.
* - Bitmaps * - Bitmaps
- \_\_le32 or \_\_le16 - __le32 or __le16
- UUID + the entire bitmap. Checksums are stored in the group descriptor, - UUID + the entire bitmap. Checksums are stored in the group descriptor,
and truncated if the group descriptor size is 32 bytes (i.e. ^64bit) and truncated if the group descriptor size is 32 bytes (i.e. ^64bit)
* - Inodes * - Inodes
- \_\_le32 - __le32
- UUID + inode number + inode generation + the entire inode. The checksum - UUID + inode number + inode generation + the entire inode. The checksum
field is set to zero. Each inode has its own checksum. field is set to zero. Each inode has its own checksum.
* - Group Descriptors * - Group Descriptors
- \_\_le16 - __le16
- If metadata\_csum, then UUID + group number + the entire descriptor; - If metadata_csum, then UUID + group number + the entire descriptor;
else if gdt\_csum, then crc16(UUID + group number + the entire else if gdt_csum, then crc16(UUID + group number + the entire
descriptor). In all cases, only the lower 16 bits are stored. descriptor). In all cases, only the lower 16 bits are stored.
...@@ -5,14 +5,14 @@ Large Extended Attribute Values ...@@ -5,14 +5,14 @@ Large Extended Attribute Values
To enable ext4 to store extended attribute values that do not fit in the To enable ext4 to store extended attribute values that do not fit in the
inode or in the single extended attribute block attached to an inode, inode or in the single extended attribute block attached to an inode,
the EA\_INODE feature allows us to store the value in the data blocks of the EA_INODE feature allows us to store the value in the data blocks of
a regular file inode. This “EA inode” is linked only from the extended a regular file inode. This “EA inode” is linked only from the extended
attribute name index and must not appear in a directory entry. The attribute name index and must not appear in a directory entry. The
inode's i\_atime field is used to store a checksum of the xattr value; inode's i_atime field is used to store a checksum of the xattr value;
and i\_ctime/i\_version store a 64-bit reference count, which enables and i_ctime/i_version store a 64-bit reference count, which enables
sharing of large xattr values between multiple owning inodes. For sharing of large xattr values between multiple owning inodes. For
backward compatibility with older versions of this feature, the backward compatibility with older versions of this feature, the
i\_mtime/i\_generation *may* store a back-reference to the inode number i_mtime/i_generation *may* store a back-reference to the inode number
and i\_generation of the **one** owning inode (in cases where the EA and i_generation of the **one** owning inode (in cases where the EA
inode is not referenced by multiple inodes) to verify that the EA inode inode is not referenced by multiple inodes) to verify that the EA inode
is the correct one being accessed. is the correct one being accessed.
...@@ -7,34 +7,34 @@ Each block group on the filesystem has one of these descriptors ...@@ -7,34 +7,34 @@ Each block group on the filesystem has one of these descriptors
associated with it. As noted in the Layout section above, the group associated with it. As noted in the Layout section above, the group
descriptors (if present) are the second item in the block group. The descriptors (if present) are the second item in the block group. The
standard configuration is for each block group to contain a full copy of standard configuration is for each block group to contain a full copy of
the block group descriptor table unless the sparse\_super feature flag the block group descriptor table unless the sparse_super feature flag
is set. is set.
Notice how the group descriptor records the location of both bitmaps and Notice how the group descriptor records the location of both bitmaps and
the inode table (i.e. they can float). This means that within a block the inode table (i.e. they can float). This means that within a block
group, the only data structures with fixed locations are the superblock group, the only data structures with fixed locations are the superblock
and the group descriptor table. The flex\_bg mechanism uses this and the group descriptor table. The flex_bg mechanism uses this
property to group several block groups into a flex group and lay out all property to group several block groups into a flex group and lay out all
of the groups' bitmaps and inode tables into one long run in the first of the groups' bitmaps and inode tables into one long run in the first
group of the flex group. group of the flex group.
If the meta\_bg feature flag is set, then several block groups are If the meta_bg feature flag is set, then several block groups are
grouped together into a meta group. Note that in the meta\_bg case, grouped together into a meta group. Note that in the meta_bg case,
however, the first and last two block groups within the larger meta however, the first and last two block groups within the larger meta
group contain only group descriptors for the groups inside the meta group contain only group descriptors for the groups inside the meta
group. group.
flex\_bg and meta\_bg do not appear to be mutually exclusive features. flex_bg and meta_bg do not appear to be mutually exclusive features.
In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the In ext2, ext3, and ext4 (when the 64bit feature is not enabled), the
block group descriptor was only 32 bytes long and therefore ends at block group descriptor was only 32 bytes long and therefore ends at
bg\_checksum. On an ext4 filesystem with the 64bit feature enabled, the bg_checksum. On an ext4 filesystem with the 64bit feature enabled, the
block group descriptor expands to at least the 64 bytes described below; block group descriptor expands to at least the 64 bytes described below;
the size is stored in the superblock. the size is stored in the superblock.
If gdt\_csum is set and metadata\_csum is not set, the block group If gdt_csum is set and metadata_csum is not set, the block group
checksum is the crc16 of the FS UUID, the group number, and the group checksum is the crc16 of the FS UUID, the group number, and the group
descriptor structure. If metadata\_csum is set, then the block group descriptor structure. If metadata_csum is set, then the block group
checksum is the lower 16 bits of the checksum of the FS UUID, the group checksum is the lower 16 bits of the checksum of the FS UUID, the group
number, and the group descriptor structure. Both block and inode bitmap number, and the group descriptor structure. Both block and inode bitmap
checksums are calculated against the FS UUID, the group number, and the checksums are calculated against the FS UUID, the group number, and the
...@@ -51,59 +51,59 @@ The block group descriptor is laid out in ``struct ext4_group_desc``. ...@@ -51,59 +51,59 @@ The block group descriptor is laid out in ``struct ext4_group_desc``.
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- bg\_block\_bitmap\_lo - bg_block_bitmap_lo
- Lower 32-bits of location of block bitmap. - Lower 32-bits of location of block bitmap.
* - 0x4 * - 0x4
- \_\_le32 - __le32
- bg\_inode\_bitmap\_lo - bg_inode_bitmap_lo
- Lower 32-bits of location of inode bitmap. - Lower 32-bits of location of inode bitmap.
* - 0x8 * - 0x8
- \_\_le32 - __le32
- bg\_inode\_table\_lo - bg_inode_table_lo
- Lower 32-bits of location of inode table. - Lower 32-bits of location of inode table.
* - 0xC * - 0xC
- \_\_le16 - __le16
- bg\_free\_blocks\_count\_lo - bg_free_blocks_count_lo
- Lower 16-bits of free block count. - Lower 16-bits of free block count.
* - 0xE * - 0xE
- \_\_le16 - __le16
- bg\_free\_inodes\_count\_lo - bg_free_inodes_count_lo
- Lower 16-bits of free inode count. - Lower 16-bits of free inode count.
* - 0x10 * - 0x10
- \_\_le16 - __le16
- bg\_used\_dirs\_count\_lo - bg_used_dirs_count_lo
- Lower 16-bits of directory count. - Lower 16-bits of directory count.
* - 0x12 * - 0x12
- \_\_le16 - __le16
- bg\_flags - bg_flags
- Block group flags. See the bgflags_ table below. - Block group flags. See the bgflags_ table below.
* - 0x14 * - 0x14
- \_\_le32 - __le32
- bg\_exclude\_bitmap\_lo - bg_exclude_bitmap_lo
- Lower 32-bits of location of snapshot exclusion bitmap. - Lower 32-bits of location of snapshot exclusion bitmap.
* - 0x18 * - 0x18
- \_\_le16 - __le16
- bg\_block\_bitmap\_csum\_lo - bg_block_bitmap_csum_lo
- Lower 16-bits of the block bitmap checksum. - Lower 16-bits of the block bitmap checksum.
* - 0x1A * - 0x1A
- \_\_le16 - __le16
- bg\_inode\_bitmap\_csum\_lo - bg_inode_bitmap_csum_lo
- Lower 16-bits of the inode bitmap checksum. - Lower 16-bits of the inode bitmap checksum.
* - 0x1C * - 0x1C
- \_\_le16 - __le16
- bg\_itable\_unused\_lo - bg_itable_unused_lo
- Lower 16-bits of unused inode count. If set, we needn't scan past the - Lower 16-bits of unused inode count. If set, we needn't scan past the
``(sb.s_inodes_per_group - gdt.bg_itable_unused)``\ th entry in the ``(sb.s_inodes_per_group - gdt.bg_itable_unused)`` th entry in the
inode table for this group. inode table for this group.
* - 0x1E * - 0x1E
- \_\_le16 - __le16
- bg\_checksum - bg_checksum
- Group descriptor checksum; crc16(sb\_uuid+group\_num+bg\_desc) if the - Group descriptor checksum; crc16(sb_uuid+group_num+bg_desc) if the
RO\_COMPAT\_GDT\_CSUM feature is set, or RO_COMPAT_GDT_CSUM feature is set, or
crc32c(sb\_uuid+group\_num+bg\_desc) & 0xFFFF if the crc32c(sb_uuid+group_num+bg_desc) & 0xFFFF if the
RO\_COMPAT\_METADATA\_CSUM feature is set. The bg\_checksum RO_COMPAT_METADATA_CSUM feature is set. The bg_checksum
field in bg\_desc is skipped when calculating crc16 checksum, field in bg_desc is skipped when calculating crc16 checksum,
and set to zero if crc32c checksum is used. and set to zero if crc32c checksum is used.
* - * -
- -
...@@ -111,48 +111,48 @@ The block group descriptor is laid out in ``struct ext4_group_desc``. ...@@ -111,48 +111,48 @@ The block group descriptor is laid out in ``struct ext4_group_desc``.
- These fields only exist if the 64bit feature is enabled and s_desc_size - These fields only exist if the 64bit feature is enabled and s_desc_size
> 32. > 32.
* - 0x20 * - 0x20
- \_\_le32 - __le32
- bg\_block\_bitmap\_hi - bg_block_bitmap_hi
- Upper 32-bits of location of block bitmap. - Upper 32-bits of location of block bitmap.
* - 0x24 * - 0x24
- \_\_le32 - __le32
- bg\_inode\_bitmap\_hi - bg_inode_bitmap_hi
- Upper 32-bits of location of inodes bitmap. - Upper 32-bits of location of inodes bitmap.
* - 0x28 * - 0x28
- \_\_le32 - __le32
- bg\_inode\_table\_hi - bg_inode_table_hi
- Upper 32-bits of location of inodes table. - Upper 32-bits of location of inodes table.
* - 0x2C * - 0x2C
- \_\_le16 - __le16
- bg\_free\_blocks\_count\_hi - bg_free_blocks_count_hi
- Upper 16-bits of free block count. - Upper 16-bits of free block count.
* - 0x2E * - 0x2E
- \_\_le16 - __le16
- bg\_free\_inodes\_count\_hi - bg_free_inodes_count_hi
- Upper 16-bits of free inode count. - Upper 16-bits of free inode count.
* - 0x30 * - 0x30
- \_\_le16 - __le16
- bg\_used\_dirs\_count\_hi - bg_used_dirs_count_hi
- Upper 16-bits of directory count. - Upper 16-bits of directory count.
* - 0x32 * - 0x32
- \_\_le16 - __le16
- bg\_itable\_unused\_hi - bg_itable_unused_hi
- Upper 16-bits of unused inode count. - Upper 16-bits of unused inode count.
* - 0x34 * - 0x34
- \_\_le32 - __le32
- bg\_exclude\_bitmap\_hi - bg_exclude_bitmap_hi
- Upper 32-bits of location of snapshot exclusion bitmap. - Upper 32-bits of location of snapshot exclusion bitmap.
* - 0x38 * - 0x38
- \_\_le16 - __le16
- bg\_block\_bitmap\_csum\_hi - bg_block_bitmap_csum_hi
- Upper 16-bits of the block bitmap checksum. - Upper 16-bits of the block bitmap checksum.
* - 0x3A * - 0x3A
- \_\_le16 - __le16
- bg\_inode\_bitmap\_csum\_hi - bg_inode_bitmap_csum_hi
- Upper 16-bits of the inode bitmap checksum. - Upper 16-bits of the inode bitmap checksum.
* - 0x3C * - 0x3C
- \_\_u32 - __u32
- bg\_reserved - bg_reserved
- Padding to 64 bytes. - Padding to 64 bytes.
.. _bgflags: .. _bgflags:
...@@ -166,8 +166,8 @@ Block group flags can be any combination of the following: ...@@ -166,8 +166,8 @@ Block group flags can be any combination of the following:
* - Value * - Value
- Description - Description
* - 0x1 * - 0x1
- inode table and bitmap are not initialized (EXT4\_BG\_INODE\_UNINIT). - inode table and bitmap are not initialized (EXT4_BG_INODE_UNINIT).
* - 0x2 * - 0x2
- block bitmap is not initialized (EXT4\_BG\_BLOCK\_UNINIT). - block bitmap is not initialized (EXT4_BG_BLOCK_UNINIT).
* - 0x4 * - 0x4
- inode table is zeroed (EXT4\_BG\_INODE\_ZEROED). - inode table is zeroed (EXT4_BG_INODE_ZEROED).
.. SPDX-License-Identifier: GPL-2.0 .. SPDX-License-Identifier: GPL-2.0
The Contents of inode.i\_block The Contents of inode.i_block
------------------------------ ------------------------------
Depending on the type of file an inode describes, the 60 bytes of Depending on the type of file an inode describes, the 60 bytes of
...@@ -47,7 +47,7 @@ In ext4, the file to logical block map has been replaced with an extent ...@@ -47,7 +47,7 @@ In ext4, the file to logical block map has been replaced with an extent
tree. Under the old scheme, allocating a contiguous run of 1,000 blocks tree. Under the old scheme, allocating a contiguous run of 1,000 blocks
requires an indirect block to map all 1,000 entries; with extents, the requires an indirect block to map all 1,000 entries; with extents, the
mapping is reduced to a single ``struct ext4_extent`` with mapping is reduced to a single ``struct ext4_extent`` with
``ee_len = 1000``. If flex\_bg is enabled, it is possible to allocate ``ee_len = 1000``. If flex_bg is enabled, it is possible to allocate
very large files with a single extent, at a considerable reduction in very large files with a single extent, at a considerable reduction in
metadata block use, and some improvement in disk efficiency. The inode metadata block use, and some improvement in disk efficiency. The inode
must have the extents flag (0x80000) flag set for this feature to be in must have the extents flag (0x80000) flag set for this feature to be in
...@@ -76,28 +76,28 @@ which is 12 bytes long: ...@@ -76,28 +76,28 @@ which is 12 bytes long:
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le16 - __le16
- eh\_magic - eh_magic
- Magic number, 0xF30A. - Magic number, 0xF30A.
* - 0x2 * - 0x2
- \_\_le16 - __le16
- eh\_entries - eh_entries
- Number of valid entries following the header. - Number of valid entries following the header.
* - 0x4 * - 0x4
- \_\_le16 - __le16
- eh\_max - eh_max
- Maximum number of entries that could follow the header. - Maximum number of entries that could follow the header.
* - 0x6 * - 0x6
- \_\_le16 - __le16
- eh\_depth - eh_depth
- Depth of this extent node in the extent tree. 0 = this extent node - Depth of this extent node in the extent tree. 0 = this extent node
points to data blocks; otherwise, this extent node points to other points to data blocks; otherwise, this extent node points to other
extent nodes. The extent tree can be at most 5 levels deep: a logical extent nodes. The extent tree can be at most 5 levels deep: a logical
block number can be at most ``2^32``, and the smallest ``n`` that block number can be at most ``2^32``, and the smallest ``n`` that
satisfies ``4*(((blocksize - 12)/12)^n) >= 2^32`` is 5. satisfies ``4*(((blocksize - 12)/12)^n) >= 2^32`` is 5.
* - 0x8 * - 0x8
- \_\_le32 - __le32
- eh\_generation - eh_generation
- Generation of the tree. (Used by Lustre, but not standard ext4). - Generation of the tree. (Used by Lustre, but not standard ext4).
Internal nodes of the extent tree, also known as index nodes, are Internal nodes of the extent tree, also known as index nodes, are
...@@ -112,22 +112,22 @@ recorded as ``struct ext4_extent_idx``, and are 12 bytes long: ...@@ -112,22 +112,22 @@ recorded as ``struct ext4_extent_idx``, and are 12 bytes long:
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- ei\_block - ei_block
- This index node covers file blocks from 'block' onward. - This index node covers file blocks from 'block' onward.
* - 0x4 * - 0x4
- \_\_le32 - __le32
- ei\_leaf\_lo - ei_leaf_lo
- Lower 32-bits of the block number of the extent node that is the next - Lower 32-bits of the block number of the extent node that is the next
level lower in the tree. The tree node pointed to can be either another level lower in the tree. The tree node pointed to can be either another
internal node or a leaf node, described below. internal node or a leaf node, described below.
* - 0x8 * - 0x8
- \_\_le16 - __le16
- ei\_leaf\_hi - ei_leaf_hi
- Upper 16-bits of the previous field. - Upper 16-bits of the previous field.
* - 0xA * - 0xA
- \_\_u16 - __u16
- ei\_unused - ei_unused
- -
Leaf nodes of the extent tree are recorded as ``struct ext4_extent``, Leaf nodes of the extent tree are recorded as ``struct ext4_extent``,
...@@ -142,24 +142,24 @@ and are also 12 bytes long: ...@@ -142,24 +142,24 @@ and are also 12 bytes long:
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- ee\_block - ee_block
- First file block number that this extent covers. - First file block number that this extent covers.
* - 0x4 * - 0x4
- \_\_le16 - __le16
- ee\_len - ee_len
- Number of blocks covered by extent. If the value of this field is <= - Number of blocks covered by extent. If the value of this field is <=
32768, the extent is initialized. If the value of the field is > 32768, 32768, the extent is initialized. If the value of the field is > 32768,
the extent is uninitialized and the actual extent length is ``ee_len`` - the extent is uninitialized and the actual extent length is ``ee_len`` -
32768. Therefore, the maximum length of a initialized extent is 32768 32768. Therefore, the maximum length of a initialized extent is 32768
blocks, and the maximum length of an uninitialized extent is 32767. blocks, and the maximum length of an uninitialized extent is 32767.
* - 0x6 * - 0x6
- \_\_le16 - __le16
- ee\_start\_hi - ee_start_hi
- Upper 16-bits of the block number to which this extent points. - Upper 16-bits of the block number to which this extent points.
* - 0x8 * - 0x8
- \_\_le32 - __le32
- ee\_start\_lo - ee_start_lo
- Lower 32-bits of the block number to which this extent points. - Lower 32-bits of the block number to which this extent points.
Prior to the introduction of metadata checksums, the extent header + Prior to the introduction of metadata checksums, the extent header +
...@@ -182,8 +182,8 @@ including) the checksum itself. ...@@ -182,8 +182,8 @@ including) the checksum itself.
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- eb\_checksum - eb_checksum
- Checksum of the extent block, crc32c(uuid+inum+igeneration+extentblock) - Checksum of the extent block, crc32c(uuid+inum+igeneration+extentblock)
Inline Data Inline Data
......
...@@ -11,12 +11,12 @@ file is smaller than 60 bytes, then the data are stored inline in ...@@ -11,12 +11,12 @@ file is smaller than 60 bytes, then the data are stored inline in
attribute space, then it might be found as an extended attribute attribute space, then it might be found as an extended attribute
“system.data” within the inode body (“ibody EA”). This of course “system.data” within the inode body (“ibody EA”). This of course
constrains the amount of extended attributes one can attach to an inode. constrains the amount of extended attributes one can attach to an inode.
If the data size increases beyond i\_block + ibody EA, a regular block If the data size increases beyond i_block + ibody EA, a regular block
is allocated and the contents moved to that block. is allocated and the contents moved to that block.
Pending a change to compact the extended attribute key used to store Pending a change to compact the extended attribute key used to store
inline data, one ought to be able to store 160 bytes of data in a inline data, one ought to be able to store 160 bytes of data in a
256-byte inode (as of June 2015, when i\_extra\_isize is 28). Prior to 256-byte inode (as of June 2015, when i_extra_isize is 28). Prior to
that, the limit was 156 bytes due to inefficient use of inode space. that, the limit was 156 bytes due to inefficient use of inode space.
The inline data feature requires the presence of an extended attribute The inline data feature requires the presence of an extended attribute
...@@ -25,12 +25,12 @@ for “system.data”, even if the attribute value is zero length. ...@@ -25,12 +25,12 @@ for “system.data”, even if the attribute value is zero length.
Inline Directories Inline Directories
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~
The first four bytes of i\_block are the inode number of the parent The first four bytes of i_block are the inode number of the parent
directory. Following that is a 56-byte space for an array of directory directory. Following that is a 56-byte space for an array of directory
entries; see ``struct ext4_dir_entry``. If there is a “system.data” entries; see ``struct ext4_dir_entry``. If there is a “system.data”
attribute in the inode body, the EA value is an array of attribute in the inode body, the EA value is an array of
``struct ext4_dir_entry`` as well. Note that for inline directories, the ``struct ext4_dir_entry`` as well. Note that for inline directories, the
i\_block and EA space are treated as separate dirent blocks; directory i_block and EA space are treated as separate dirent blocks; directory
entries cannot span the two. entries cannot span the two.
Inline directory entries are not checksummed, as the inode checksum Inline directory entries are not checksummed, as the inode checksum
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,8 +7,8 @@ Multiple mount protection (MMP) is a feature that protects the ...@@ -7,8 +7,8 @@ Multiple mount protection (MMP) is a feature that protects the
filesystem against multiple hosts trying to use the filesystem filesystem against multiple hosts trying to use the filesystem
simultaneously. When a filesystem is opened (for mounting, or fsck, simultaneously. When a filesystem is opened (for mounting, or fsck,
etc.), the MMP code running on the node (call it node A) checks a etc.), the MMP code running on the node (call it node A) checks a
sequence number. If the sequence number is EXT4\_MMP\_SEQ\_CLEAN, the sequence number. If the sequence number is EXT4_MMP_SEQ_CLEAN, the
open continues. If the sequence number is EXT4\_MMP\_SEQ\_FSCK, then open continues. If the sequence number is EXT4_MMP_SEQ_FSCK, then
fsck is (hopefully) running, and open fails immediately. Otherwise, the fsck is (hopefully) running, and open fails immediately. Otherwise, the
open code will wait for twice the specified MMP check interval and check open code will wait for twice the specified MMP check interval and check
the sequence number again. If the sequence number has changed, then the the sequence number again. If the sequence number has changed, then the
...@@ -40,38 +40,38 @@ The MMP structure (``struct mmp_struct``) is as follows: ...@@ -40,38 +40,38 @@ The MMP structure (``struct mmp_struct``) is as follows:
- Name - Name
- Description - Description
* - 0x0 * - 0x0
- \_\_le32 - __le32
- mmp\_magic - mmp_magic
- Magic number for MMP, 0x004D4D50 (“MMP”). - Magic number for MMP, 0x004D4D50 (“MMP”).
* - 0x4 * - 0x4
- \_\_le32 - __le32
- mmp\_seq - mmp_seq
- Sequence number, updated periodically. - Sequence number, updated periodically.
* - 0x8 * - 0x8
- \_\_le64 - __le64
- mmp\_time - mmp_time
- Time that the MMP block was last updated. - Time that the MMP block was last updated.
* - 0x10 * - 0x10
- char[64] - char[64]
- mmp\_nodename - mmp_nodename
- Hostname of the node that opened the filesystem. - Hostname of the node that opened the filesystem.
* - 0x50 * - 0x50
- char[32] - char[32]
- mmp\_bdevname - mmp_bdevname
- Block device name of the filesystem. - Block device name of the filesystem.
* - 0x70 * - 0x70
- \_\_le16 - __le16
- mmp\_check\_interval - mmp_check_interval
- The MMP re-check interval, in seconds. - The MMP re-check interval, in seconds.
* - 0x72 * - 0x72
- \_\_le16 - __le16
- mmp\_pad1 - mmp_pad1
- Zero. - Zero.
* - 0x74 * - 0x74
- \_\_le32[226] - __le32[226]
- mmp\_pad2 - mmp_pad2
- Zero. - Zero.
* - 0x3FC * - 0x3FC
- \_\_le32 - __le32
- mmp\_checksum - mmp_checksum
- Checksum of the MMP block. - Checksum of the MMP block.
...@@ -7,7 +7,7 @@ An ext4 file system is split into a series of block groups. To reduce ...@@ -7,7 +7,7 @@ An ext4 file system is split into a series of block groups. To reduce
performance difficulties due to fragmentation, the block allocator tries performance difficulties due to fragmentation, the block allocator tries
very hard to keep each file's blocks within the same group, thereby very hard to keep each file's blocks within the same group, thereby
reducing seek times. The size of a block group is specified in reducing seek times. The size of a block group is specified in
``sb.s_blocks_per_group`` blocks, though it can also calculated as 8 \* ``sb.s_blocks_per_group`` blocks, though it can also calculated as 8 *
``block_size_in_bytes``. With the default block size of 4KiB, each group ``block_size_in_bytes``. With the default block size of 4KiB, each group
will contain 32,768 blocks, for a length of 128MiB. The number of block will contain 32,768 blocks, for a length of 128MiB. The number of block
groups is the size of the device divided by the size of a block group. groups is the size of the device divided by the size of a block group.
......
...@@ -34,7 +34,7 @@ ext4 reserves some inode for special features, as follows: ...@@ -34,7 +34,7 @@ ext4 reserves some inode for special features, as follows:
* - 10 * - 10
- Replica inode, used for some non-upstream feature? - Replica inode, used for some non-upstream feature?
* - 11 * - 11
- Traditional first non-reserved inode. Usually this is the lost+found directory. See s\_first\_ino in the superblock. - Traditional first non-reserved inode. Usually this is the lost+found directory. See s_first_ino in the superblock.
Note that there are also some inodes allocated from non-reserved inode numbers Note that there are also some inodes allocated from non-reserved inode numbers
for other filesystem features which are not referenced from standard directory for other filesystem features which are not referenced from standard directory
...@@ -47,9 +47,9 @@ hierarchy. These are generally reference from the superblock. They are: ...@@ -47,9 +47,9 @@ hierarchy. These are generally reference from the superblock. They are:
* - Superblock field * - Superblock field
- Description - Description
* - s\_lpf\_ino * - s_lpf_ino
- Inode number of lost+found directory. - Inode number of lost+found directory.
* - s\_prj\_quota\_inum * - s_prj_quota_inum
- Inode number of quota file tracking project quotas - Inode number of quota file tracking project quotas
* - s\_orphan\_file\_inum * - s_orphan_file_inum
- Inode number of file tracking orphan inodes. - Inode number of file tracking orphan inodes.
This diff is collapsed.
...@@ -829,7 +829,7 @@ int ext4_get_block_unwritten(struct inode *inode, sector_t iblock, ...@@ -829,7 +829,7 @@ int ext4_get_block_unwritten(struct inode *inode, sector_t iblock,
ext4_debug("ext4_get_block_unwritten: inode %lu, create flag %d\n", ext4_debug("ext4_get_block_unwritten: inode %lu, create flag %d\n",
inode->i_ino, create); inode->i_ino, create);
return _ext4_get_block(inode, iblock, bh_result, return _ext4_get_block(inode, iblock, bh_result,
EXT4_GET_BLOCKS_IO_CREATE_EXT); EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT);
} }
/* Maximum number of blocks we map for direct IO at once. */ /* Maximum number of blocks we map for direct IO at once. */
......
...@@ -4104,6 +4104,15 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, ...@@ -4104,6 +4104,15 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
size = size >> bsbits; size = size >> bsbits;
start = start_off >> bsbits; start = start_off >> bsbits;
/*
* For tiny groups (smaller than 8MB) the chosen allocation
* alignment may be larger than group size. Make sure the
* alignment does not move allocation to a different group which
* makes mballoc fail assertions later.
*/
start = max(start, rounddown(ac->ac_o_ex.fe_logical,
(ext4_lblk_t)EXT4_BLOCKS_PER_GROUP(ac->ac_sb)));
/* don't cover already allocated blocks in selected range */ /* don't cover already allocated blocks in selected range */
if (ar->pleft && start <= ar->lleft) { if (ar->pleft && start <= ar->lleft) {
size -= ar->lleft + 1 - start; size -= ar->lleft + 1 - start;
...@@ -4176,7 +4185,22 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac, ...@@ -4176,7 +4185,22 @@ ext4_mb_normalize_request(struct ext4_allocation_context *ac,
} }
rcu_read_unlock(); rcu_read_unlock();
if (start + size <= ac->ac_o_ex.fe_logical && /*
* In this function "start" and "size" are normalized for better
* alignment and length such that we could preallocate more blocks.
* This normalization is done such that original request of
* ac->ac_o_ex.fe_logical & fe_len should always lie within "start" and
* "size" boundaries.
* (Note fe_len can be relaxed since FS block allocation API does not
* provide gurantee on number of contiguous blocks allocation since that
* depends upon free space left, etc).
* In case of inode pa, later we use the allocated blocks
* [pa_start + fe_logical - pa_lstart, fe_len/size] from the preallocated
* range of goal/best blocks [start, size] to put it at the
* ac_o_ex.fe_logical extent of this inode.
* (See ext4_mb_use_inode_pa() for more details)
*/
if (start + size <= ac->ac_o_ex.fe_logical ||
start > ac->ac_o_ex.fe_logical) { start > ac->ac_o_ex.fe_logical) {
ext4_msg(ac->ac_sb, KERN_ERR, ext4_msg(ac->ac_sb, KERN_ERR,
"start %lu, size %lu, fe_logical %lu", "start %lu, size %lu, fe_logical %lu",
......
...@@ -438,7 +438,7 @@ int ext4_ext_migrate(struct inode *inode) ...@@ -438,7 +438,7 @@ int ext4_ext_migrate(struct inode *inode)
/* /*
* Worst case we can touch the allocation bitmaps and a block * Worst case we can touch the allocation bitmaps and a block
* group descriptor block. We do need need to worry about * group descriptor block. We do need to worry about
* credits for modifying the quota inode. * credits for modifying the quota inode.
*/ */
handle = ext4_journal_start(inode, EXT4_HT_MIGRATE, handle = ext4_journal_start(inode, EXT4_HT_MIGRATE,
......
...@@ -1929,7 +1929,8 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, ...@@ -1929,7 +1929,8 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
struct dx_hash_info *hinfo) struct dx_hash_info *hinfo)
{ {
unsigned blocksize = dir->i_sb->s_blocksize; unsigned blocksize = dir->i_sb->s_blocksize;
unsigned count, continued; unsigned continued;
int count;
struct buffer_head *bh2; struct buffer_head *bh2;
ext4_lblk_t newblock; ext4_lblk_t newblock;
u32 hash2; u32 hash2;
......
...@@ -465,7 +465,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, ...@@ -465,7 +465,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
/* /*
* In the first loop we prepare and mark buffers to submit. We have to * In the first loop we prepare and mark buffers to submit. We have to
* mark all buffers in the page before submitting so that * mark all buffers in the page before submitting so that
* end_page_writeback() cannot be called from ext4_bio_end_io() when IO * end_page_writeback() cannot be called from ext4_end_bio() when IO
* on the first buffer finishes and we are still working on submitting * on the first buffer finishes and we are still working on submitting
* the second buffer. * the second buffer.
*/ */
......
...@@ -53,6 +53,16 @@ int ext4_resize_begin(struct super_block *sb) ...@@ -53,6 +53,16 @@ int ext4_resize_begin(struct super_block *sb)
if (!capable(CAP_SYS_RESOURCE)) if (!capable(CAP_SYS_RESOURCE))
return -EPERM; return -EPERM;
/*
* If the reserved GDT blocks is non-zero, the resize_inode feature
* should always be set.
*/
if (EXT4_SB(sb)->s_es->s_reserved_gdt_blocks &&
!ext4_has_feature_resize_inode(sb)) {
ext4_error(sb, "resize_inode disabled but reserved GDT blocks non-zero");
return -EFSCORRUPTED;
}
/* /*
* If we are not using the primary superblock/GDT copy don't resize, * If we are not using the primary superblock/GDT copy don't resize,
* because the user tools have no way of handling this. Probably a * because the user tools have no way of handling this. Probably a
......
This diff is collapsed.
...@@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode, ...@@ -1895,11 +1895,10 @@ ext4_xattr_block_set(handle_t *handle, struct inode *inode,
unlock_buffer(bs->bh); unlock_buffer(bs->bh);
ea_bdebug(bs->bh, "cloning"); ea_bdebug(bs->bh, "cloning");
s->base = kmalloc(bs->bh->b_size, GFP_NOFS); s->base = kmemdup(BHDR(bs->bh), bs->bh->b_size, GFP_NOFS);
error = -ENOMEM; error = -ENOMEM;
if (s->base == NULL) if (s->base == NULL)
goto cleanup; goto cleanup;
memcpy(s->base, BHDR(bs->bh), bs->bh->b_size);
s->first = ENTRY(header(s->base)+1); s->first = ENTRY(header(s->base)+1);
header(s->base)->h_refcount = cpu_to_le32(1); header(s->base)->h_refcount = cpu_to_le32(1);
s->here = ENTRY(s->base + offset); s->here = ENTRY(s->base + offset);
......
...@@ -2114,7 +2114,7 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh) ...@@ -2114,7 +2114,7 @@ __journal_try_to_free_buffer(journal_t *journal, struct buffer_head *bh)
/** /**
* jbd2_journal_try_to_free_buffers() - try to free page buffers. * jbd2_journal_try_to_free_buffers() - try to free page buffers.
* @journal: journal for operation * @journal: journal for operation
* @page: to try and free * @folio: Folio to detach data from.
* *
* For all the buffers on this page, * For all the buffers on this page,
* if they are fully written out ordered data, move them onto BUF_CLEAN * if they are fully written out ordered data, move them onto BUF_CLEAN
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment