From: Geert U. <Gee...@so...> - 2008-08-29 13:23:51
|
From: Geert Uytterhoeven <Gee...@so...> Optimize accesses to members of remaining on-disk structures: - Use get_aligned_le*() for aligned members Signed-off-by: Geert Uytterhoeven <Gee...@so...> --- fs/squashfs/inode.c | 62 ++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 30 deletions(-) --- a/fs/squashfs/inode.c +++ b/fs/squashfs/inode.c @@ -566,8 +566,8 @@ static int get_fragment_location(struct &offset)) return 0; - *fragment_start_block = le64_to_cpu(fragment_entry.start_block); - *fragment_size = le32_to_cpu(fragment_entry.size); + *fragment_start_block = get_aligned_le64(&fragment_entry.start_block); + *fragment_size = get_aligned_le32(&fragment_entry.size); return 1; } @@ -594,12 +594,12 @@ static struct squashfs_cache_entry *get_ static void squashfs_new_inode(struct squashfs_sb_info *msblk, struct inode *i, struct squashfs_base_inode_header *inodeb) { - i->i_ino = le32_to_cpu(inodeb->inode_number); - i->i_mtime.tv_sec = le32_to_cpu(inodeb->mtime); + i->i_ino = get_aligned_le32(&inodeb->inode_number); + i->i_mtime.tv_sec = get_aligned_le32(&inodeb->mtime); i->i_atime.tv_sec = i->i_mtime.tv_sec; i->i_ctime.tv_sec = i->i_mtime.tv_sec; i->i_uid = le32_to_cpu(msblk->uid[inodeb->uid]); - i->i_mode = le16_to_cpu(inodeb->inode_type_mode) >> 4; + i->i_mode = get_aligned_le16(&inodeb->inode_type_mode) >> 4; i->i_size = 0; if (inodeb->guid == SQUASHFS_GUIDS) @@ -624,7 +624,7 @@ static squashfs_inode_t squashfs_inode_l sizeof(raw_inode), &start, &offset)) return SQUASHFS_INVALID_BLK; - inode = le64_to_cpu(raw_inode); + inode = get_aligned_le64(&raw_inode); TRACE("squashfs_inode_lookup, inode = 0x%llx\n", (unsigned long long)inode); @@ -733,7 +733,7 @@ static int squashfs_read_inode(struct in squashfs_new_inode(msblk, i, inodeb); - inode_type = le16_to_cpu(inodeb->inode_type_mode) & 0xf; + inode_type = get_aligned_le16(&inodeb->inode_type_mode) & 0xf; switch (inode_type) { case SQUASHFS_FILE_TYPE: { unsigned int frag_size; @@ -787,21 +787,22 @@ static int squashfs_read_inode(struct in frag_blk = SQUASHFS_INVALID_BLK; - fragment = le32_to_cpu(inodep->fragment); + fragment = get_aligned_le32(&inodep->fragment); if (fragment != SQUASHFS_INVALID_FRAG && !get_fragment_location(s, fragment, &frag_blk, &frag_size)) goto failed_read; - i->i_nlink = le32_to_cpu(inodep->nlink); - i->i_size = le64_to_cpu(inodep->file_size); + i->i_nlink = get_aligned_le32(&inodep->nlink); + i->i_size = get_aligned_le64(&inodep->file_size); i->i_fop = &generic_ro_fops; i->i_mode |= S_IFREG; i->i_blocks = ((i->i_size - 1) >> 9) + 1; SQUASHFS_I(i)->u.s1.fragment_start_block = frag_blk; SQUASHFS_I(i)->u.s1.fragment_size = frag_size; SQUASHFS_I(i)->u.s1.fragment_offset = - le32_to_cpu(inodep->offset); - SQUASHFS_I(i)->start_block = le64_to_cpu(inodep->start_block); + get_aligned_le32(&inodep->offset); + SQUASHFS_I(i)->start_block = + get_aligned_le64(&inodep->start_block); SQUASHFS_I(i)->u.s1.block_list_start = next_block; SQUASHFS_I(i)->offset = next_offset; i->i_data.a_ops = &squashfs_aops; @@ -820,17 +821,19 @@ static int squashfs_read_inode(struct in &next_offset)) goto failed_read; - i->i_nlink = le32_to_cpu(inodep->nlink); - i->i_size = le32_to_cpu(inodep->file_size_offset) & 0x7ffff; + i->i_nlink = get_aligned_le32(&inodep->nlink); + i->i_size = + get_aligned_le32(&inodep->file_size_offset) & 0x7ffff; i->i_op = &squashfs_dir_inode_ops; i->i_fop = &squashfs_dir_ops; i->i_mode |= S_IFDIR; - SQUASHFS_I(i)->start_block = le32_to_cpu(inodep->start_block); + SQUASHFS_I(i)->start_block = + get_aligned_le32(&inodep->start_block); SQUASHFS_I(i)->offset = - le32_to_cpu(inodep->file_size_offset) >> 19; + get_aligned_le32(&inodep->file_size_offset) >> 19; SQUASHFS_I(i)->u.s2.directory_index_count = 0; SQUASHFS_I(i)->u.s2.parent_inode = - le32_to_cpu(inodep->parent_inode); + get_aligned_le32(&inodep->parent_inode); TRACE("Directory inode %x:%x, start_block %llx, offset %x\n", SQUASHFS_INODE_BLK(inode), offset, @@ -877,8 +880,8 @@ static int squashfs_read_inode(struct in &next_offset)) goto failed_read; - i->i_nlink = le32_to_cpu(inodep->nlink); - i->i_size = le16_to_cpu(inodep->symlink_size); + i->i_nlink = get_aligned_le32(&inodep->nlink); + i->i_size = get_aligned_le16(&inodep->symlink_size); i->i_op = &page_symlink_inode_operations; i->i_data.a_ops = &squashfs_symlink_aops; i->i_mode |= S_IFLNK; @@ -901,11 +904,11 @@ static int squashfs_read_inode(struct in &next_offset)) goto failed_read; - i->i_nlink = le32_to_cpu(inodep->nlink); + i->i_nlink = get_aligned_le32(&inodep->nlink); i->i_mode |= inode_type == SQUASHFS_CHRDEV_TYPE ? S_IFCHR : S_IFBLK; - rdev = le16_to_cpu(inodep->rdev); + rdev = get_aligned_le16(&inodep->rdev); init_special_inode(i, i->i_mode, old_decode_dev(rdev)); TRACE("Device inode %x:%x, rdev %x\n", @@ -921,7 +924,7 @@ static int squashfs_read_inode(struct in &next_offset)) goto failed_read; - i->i_nlink = le32_to_cpu(inodep->nlink); + i->i_nlink = get_aligned_le32(&inodep->nlink); i->i_mode |= inode_type == SQUASHFS_FIFO_TYPE ? S_IFIFO : S_IFSOCK; init_special_inode(i, i->i_mode, 0); @@ -1390,8 +1393,7 @@ static int read_block_index(struct super } while (blocks-- > 0) { - block += - SQUASHFS_COMPRESSED_SIZE_BLOCK(le32_to_cpu(*block_list)); + block += SQUASHFS_COMPRESSED_SIZE_BLOCK(get_aligned_le32(block_list)); block_list++; } @@ -1535,7 +1537,7 @@ static long long read_blocklist(struct i == -1) return 0; - *bsize = le32_to_cpu(*block_list); + *bsize = get_aligned_le32(block_list); return block; } @@ -1701,15 +1703,15 @@ static int get_dir_index_using_offset(st sizeof(index), &index_start, &index_offset); - if (le32_to_cpu(index.index) > f_pos) + if (get_aligned_le32(&index.index) > f_pos) break; squashfs_get_cached_block(s, NULL, index_start, index_offset, index.size + 1, &index_start, &index_offset); - length = le32_to_cpu(index.index); - *next_block = le32_to_cpu(index.start_block) + + length = get_aligned_le32(&index.index); + *next_block = get_aligned_le32(&index.start_block) + get_unaligned_le64(&sblk->directory_table_start); } @@ -1760,8 +1762,8 @@ static int get_dir_index_using_name(stru if (strcmp(index->name, str) > 0) break; - length = le32_to_cpu(index->index); - *next_block = le32_to_cpu(index->start_block) + + length = get_aligned_le32(&index->index); + *next_block = get_aligned_le32(&index->start_block) + get_unaligned_le64(&sblk->directory_table_start); } -- With kind regards, Geert Uytterhoeven Software Architect Sony Techsoft Centre Europe The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium Phone: +32 (0)2 700 8453 Fax: +32 (0)2 700 8622 E-mail: Gee...@so... Internet: http://www.sony-europe.com/ A division of Sony Europe (Belgium) N.V. VAT BE 0413.825.160 · RPR Brussels Fortis · BIC GEBABEBB · IBAN BE41293037680010 |