diff options
Diffstat (limited to 'fs/ext2/dir.c')
-rw-r--r-- | fs/ext2/dir.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 764109886ec0..47cda410b548 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
@@ -28,21 +28,30 @@ | |||
28 | 28 | ||
29 | typedef struct ext2_dir_entry_2 ext2_dirent; | 29 | typedef struct ext2_dir_entry_2 ext2_dirent; |
30 | 30 | ||
31 | /* | ||
32 | * Tests against MAX_REC_LEN etc were put in place for 64k block | ||
33 | * sizes; if that is not possible on this arch, we can skip | ||
34 | * those tests and speed things up. | ||
35 | */ | ||
31 | static inline unsigned ext2_rec_len_from_disk(__le16 dlen) | 36 | static inline unsigned ext2_rec_len_from_disk(__le16 dlen) |
32 | { | 37 | { |
33 | unsigned len = le16_to_cpu(dlen); | 38 | unsigned len = le16_to_cpu(dlen); |
34 | 39 | ||
40 | #if (PAGE_CACHE_SIZE >= 65536) | ||
35 | if (len == EXT2_MAX_REC_LEN) | 41 | if (len == EXT2_MAX_REC_LEN) |
36 | return 1 << 16; | 42 | return 1 << 16; |
43 | #endif | ||
37 | return len; | 44 | return len; |
38 | } | 45 | } |
39 | 46 | ||
40 | static inline __le16 ext2_rec_len_to_disk(unsigned len) | 47 | static inline __le16 ext2_rec_len_to_disk(unsigned len) |
41 | { | 48 | { |
49 | #if (PAGE_CACHE_SIZE >= 65536) | ||
42 | if (len == (1 << 16)) | 50 | if (len == (1 << 16)) |
43 | return cpu_to_le16(EXT2_MAX_REC_LEN); | 51 | return cpu_to_le16(EXT2_MAX_REC_LEN); |
44 | else | 52 | else |
45 | BUG_ON(len > (1 << 16)); | 53 | BUG_ON(len > (1 << 16)); |
54 | #endif | ||
46 | return cpu_to_le16(len); | 55 | return cpu_to_le16(len); |
47 | } | 56 | } |
48 | 57 | ||
@@ -98,7 +107,7 @@ static int ext2_commit_chunk(struct page *page, loff_t pos, unsigned len) | |||
98 | if (IS_DIRSYNC(dir)) { | 107 | if (IS_DIRSYNC(dir)) { |
99 | err = write_one_page(page, 1); | 108 | err = write_one_page(page, 1); |
100 | if (!err) | 109 | if (!err) |
101 | err = ext2_sync_inode(dir); | 110 | err = sync_inode_metadata(dir, 1); |
102 | } else { | 111 | } else { |
103 | unlock_page(page); | 112 | unlock_page(page); |
104 | } | 113 | } |
@@ -129,15 +138,15 @@ static void ext2_check_page(struct page *page, int quiet) | |||
129 | p = (ext2_dirent *)(kaddr + offs); | 138 | p = (ext2_dirent *)(kaddr + offs); |
130 | rec_len = ext2_rec_len_from_disk(p->rec_len); | 139 | rec_len = ext2_rec_len_from_disk(p->rec_len); |
131 | 140 | ||
132 | if (rec_len < EXT2_DIR_REC_LEN(1)) | 141 | if (unlikely(rec_len < EXT2_DIR_REC_LEN(1))) |
133 | goto Eshort; | 142 | goto Eshort; |
134 | if (rec_len & 3) | 143 | if (unlikely(rec_len & 3)) |
135 | goto Ealign; | 144 | goto Ealign; |
136 | if (rec_len < EXT2_DIR_REC_LEN(p->name_len)) | 145 | if (unlikely(rec_len < EXT2_DIR_REC_LEN(p->name_len))) |
137 | goto Enamelen; | 146 | goto Enamelen; |
138 | if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1)) | 147 | if (unlikely(((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))) |
139 | goto Espan; | 148 | goto Espan; |
140 | if (le32_to_cpu(p->inode) > max_inumber) | 149 | if (unlikely(le32_to_cpu(p->inode) > max_inumber)) |
141 | goto Einumber; | 150 | goto Einumber; |
142 | } | 151 | } |
143 | if (offs != limit) | 152 | if (offs != limit) |