Skip to content

Commit c4f6570

Browse files
committed
ext4: kill i_version support for Hurd-castrated file systems
The Hurd file system uses uses the inode field which is now used for i_version for its translator block. This means that ext2 file systems that are formatted for GNU Hurd can't be used to support NFSv4. Given that Hurd file systems don't support extents, and a huge number of modern file system features, this is no great loss. If we don't do this, the attempt to update the i_version field will stomp over the translator block field, which will cause file system corruption for Hurd file systems. This can be replicated via: mke2fs -t ext2 -o hurd /dev/vdc mount -t ext4 /dev/vdc /vdc touch /vdc/bug0000 umount /dev/vdc e2fsck -f /dev/vdc Addresses-Debian-Bug: #738758 Reported-By: Gabriele Giacone <1o5g4r8o@gmail.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 9c191f7 commit c4f6570

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

fs/ext4/inode.c

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,11 +4168,14 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
41684168
EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
41694169
EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
41704170

4171-
inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
4172-
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
4173-
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
4174-
inode->i_version |=
4175-
(__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
4171+
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
4172+
cpu_to_le32(EXT4_OS_HURD)) {
4173+
inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
4174+
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
4175+
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
4176+
inode->i_version |=
4177+
(__u64)(le32_to_cpu(raw_inode->i_version_hi)) << 32;
4178+
}
41764179
}
41774180

41784181
ret = 0;
@@ -4388,12 +4391,16 @@ static int ext4_do_update_inode(handle_t *handle,
43884391
raw_inode->i_block[block] = ei->i_data[block];
43894392
}
43904393

4391-
raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
4392-
if (ei->i_extra_isize) {
4393-
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
4394-
raw_inode->i_version_hi =
4395-
cpu_to_le32(inode->i_version >> 32);
4396-
raw_inode->i_extra_isize = cpu_to_le16(ei->i_extra_isize);
4394+
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
4395+
cpu_to_le32(EXT4_OS_HURD)) {
4396+
raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
4397+
if (ei->i_extra_isize) {
4398+
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
4399+
raw_inode->i_version_hi =
4400+
cpu_to_le32(inode->i_version >> 32);
4401+
raw_inode->i_extra_isize =
4402+
cpu_to_le16(ei->i_extra_isize);
4403+
}
43974404
}
43984405

43994406
ext4_inode_csum_set(inode, raw_inode, ei);

0 commit comments

Comments
 (0)