Skip to content

Commit ed3654e

Browse files
committed
ext4: optimize Hurd tests when reading/writing inodes
Set a in-memory superblock flag to indicate whether the file system is designed to support the Hurd. Also, add a sanity check to make sure the 64-bit feature is not set for Hurd file systems, since i_file_acl_high conflicts with a Hurd-specific field. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent c4f6570 commit ed3654e

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

fs/ext4/ext4.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,8 @@ struct ext4_inode_info {
10011001
#define EXT4_MOUNT2_STD_GROUP_SIZE 0x00000002 /* We have standard group
10021002
size of blocksize * 8
10031003
blocks */
1004+
#define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated
1005+
file systems */
10041006

10051007
#define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \
10061008
~EXT4_MOUNT_##opt

fs/ext4/inode.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,8 +4168,7 @@ 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-
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
4172-
cpu_to_le32(EXT4_OS_HURD)) {
4171+
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
41734172
inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
41744173
if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
41754174
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
@@ -4345,8 +4344,7 @@ static int ext4_do_update_inode(handle_t *handle,
43454344
goto out_brelse;
43464345
raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
43474346
raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
4348-
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
4349-
cpu_to_le32(EXT4_OS_HURD))
4347+
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))
43504348
raw_inode->i_file_acl_high =
43514349
cpu_to_le16(ei->i_file_acl >> 32);
43524350
raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
@@ -4391,8 +4389,7 @@ static int ext4_do_update_inode(handle_t *handle,
43914389
raw_inode->i_block[block] = ei->i_data[block];
43924390
}
43934391

4394-
if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
4395-
cpu_to_le32(EXT4_OS_HURD)) {
4392+
if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
43964393
raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
43974394
if (ei->i_extra_isize) {
43984395
if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))

fs/ext4/super.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3580,6 +3580,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
35803580
"feature flags set on rev 0 fs, "
35813581
"running e2fsck is recommended");
35823582

3583+
if (es->s_creator_os == cpu_to_le32(EXT4_OS_HURD)) {
3584+
set_opt2(sb, HURD_COMPAT);
3585+
if (EXT4_HAS_INCOMPAT_FEATURE(sb,
3586+
EXT4_FEATURE_INCOMPAT_64BIT)) {
3587+
ext4_msg(sb, KERN_ERR,
3588+
"The Hurd can't support 64-bit file systems");
3589+
goto failed_mount;
3590+
}
3591+
}
3592+
35833593
if (IS_EXT2_SB(sb)) {
35843594
if (ext2_feature_set_ok(sb))
35853595
ext4_msg(sb, KERN_INFO, "mounting ext2 file system "

0 commit comments

Comments
 (0)