fix bug in add-support-collapse-range
[ext4-patch-queue.git] / optimize-hurd-tests
blob48c55f0677abc4998491ea109e67add7e1273c3b
1 ext4: optimize Hurd tests when reading/writing inodes
3 Set a in-memory superblock flag to indicate whether the file system is
4 designed to support the Hurd.
6 Also, add a sanity check to make sure the 64-bit feature is not set
7 for Hurd file systems, since i_file_acl_high conflicts with a
8 Hurd-specific field.
10 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
11 ---
12  fs/ext4/ext4.h  |  2 ++
13  fs/ext4/inode.c |  9 +++------
14  fs/ext4/super.c | 10 ++++++++++
15  3 files changed, 15 insertions(+), 6 deletions(-)
17 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
18 index f4f889e..e01135d 100644
19 --- a/fs/ext4/ext4.h
20 +++ b/fs/ext4/ext4.h
21 @@ -1001,6 +1001,8 @@ struct ext4_inode_info {
22  #define EXT4_MOUNT2_STD_GROUP_SIZE     0x00000002 /* We have standard group
23                                                       size of blocksize * 8
24                                                       blocks */
25 +#define EXT4_MOUNT2_HURD_COMPAT                0x00000004 /* Support HURD-castrated
26 +                                                     file systems */
28  #define clear_opt(sb, opt)             EXT4_SB(sb)->s_mount_opt &= \
29                                                 ~EXT4_MOUNT_##opt
30 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
31 index ed2c13a..b5e182a 100644
32 --- a/fs/ext4/inode.c
33 +++ b/fs/ext4/inode.c
34 @@ -4168,8 +4168,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
35         EXT4_INODE_GET_XTIME(i_atime, inode, raw_inode);
36         EXT4_EINODE_GET_XTIME(i_crtime, ei, raw_inode);
38 -       if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
39 -           cpu_to_le32(EXT4_OS_HURD)) {
40 +       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
41                 inode->i_version = le32_to_cpu(raw_inode->i_disk_version);
42                 if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) {
43                         if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
44 @@ -4345,8 +4344,7 @@ static int ext4_do_update_inode(handle_t *handle,
45                 goto out_brelse;
46         raw_inode->i_dtime = cpu_to_le32(ei->i_dtime);
47         raw_inode->i_flags = cpu_to_le32(ei->i_flags & 0xFFFFFFFF);
48 -       if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
49 -           cpu_to_le32(EXT4_OS_HURD))
50 +       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT)))
51                 raw_inode->i_file_acl_high =
52                         cpu_to_le16(ei->i_file_acl >> 32);
53         raw_inode->i_file_acl_lo = cpu_to_le32(ei->i_file_acl);
54 @@ -4391,8 +4389,7 @@ static int ext4_do_update_inode(handle_t *handle,
55                         raw_inode->i_block[block] = ei->i_data[block];
56         }
58 -       if (EXT4_SB(inode->i_sb)->s_es->s_creator_os !=
59 -           cpu_to_le32(EXT4_OS_HURD)) {
60 +       if (likely(!test_opt2(inode->i_sb, HURD_COMPAT))) {
61                 raw_inode->i_disk_version = cpu_to_le32(inode->i_version);
62                 if (ei->i_extra_isize) {
63                         if (EXT4_FITS_IN_INODE(raw_inode, ei, i_version_hi))
64 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
65 index 3c9eadf..6adee9a 100644
66 --- a/fs/ext4/super.c
67 +++ b/fs/ext4/super.c
68 @@ -3580,6 +3580,16 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
69                        "feature flags set on rev 0 fs, "
70                        "running e2fsck is recommended");
72 +       if (es->s_creator_os == cpu_to_le32(EXT4_OS_HURD)) {
73 +               set_opt2(sb, HURD_COMPAT);
74 +               if (EXT4_HAS_INCOMPAT_FEATURE(sb,
75 +                                             EXT4_FEATURE_INCOMPAT_64BIT)) {
76 +                       ext4_msg(sb, KERN_ERR,
77 +                                "The Hurd can't support 64-bit file systems");
78 +                       goto failed_mount;
79 +               }
80 +       }
82         if (IS_EXT2_SB(sb)) {
83                 if (ext2_feature_set_ok(sb))
84                         ext4_msg(sb, KERN_INFO, "mounting ext2 file system "