Whamcloud - gitweb
misc: fix alignment warnings on ARM
authorAndreas Dilger <adilger@dilger.ca>
Fri, 22 May 2015 22:40:51 +0000 (16:40 -0600)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 20 Jun 2015 01:33:19 +0000 (21:33 -0400)
Some temporary char buffers allocated on the stack are not properly
aligned when typecast to a structure containing __u32 or __u64 types,
and this can cause alignment warnings on ARM and other alignment
sensitive architectures, and potential slowdowns to do fixups.

Fix the buffer alignment to avoid such issues.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=680090

Reported-by: Gordan Bobic <gordan.bobic@gmail.com>
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/filefrag.c
misc/tune2fs.c

index c1a8684..c8fda48 100644 (file)
@@ -198,7 +198,7 @@ static void print_extent_info(struct fiemap_extent *fm_extent, int cur_ex,
 static int filefrag_fiemap(int fd, int blk_shift, int *num_extents,
                           ext2fs_struct_stat *st)
 {
-       char buf[16384];
+       __u64 buf[2048];        /* __u64 for proper field alignment */
        struct fiemap *fiemap = (struct fiemap *)buf;
        struct fiemap_extent *fm_ext = &fiemap->fm_extents[0];
        int count = (sizeof(buf) - sizeof(*fiemap)) /
index 61078cc..cd1d17f 100644 (file)
@@ -226,7 +226,7 @@ static int remove_journal_device(ext2_filsys fs)
 {
        char            *journal_path;
        ext2_filsys     jfs;
-       char            buf[SUPERBLOCK_SIZE];
+       char            buf[SUPERBLOCK_SIZE] __attribute__ ((aligned(8)));
        journal_superblock_t    *jsb;
        int             i, nr_users;
        errcode_t       retval;
@@ -1936,7 +1936,7 @@ fs_update_journal_user(struct ext2_super_block *sb, __u8 old_uuid[UUID_SIZE])
        __u8 *j_uuid;
        char *journal_path;
        char uuid[UUID_STR_SIZE];
-       char buf[SUPERBLOCK_SIZE];
+       char buf[SUPERBLOCK_SIZE] __attribute__ ((aligned(8)));
 
        if (!(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) ||
                uuid_is_null(sb->s_journal_uuid))
@@ -2279,7 +2279,7 @@ retry_open:
        if (U_flag) {
                int set_csum = 0;
                dgrp_t i;
-               char buf[SUPERBLOCK_SIZE];
+               char buf[SUPERBLOCK_SIZE] __attribute__ ((aligned(8)));
                __u8 old_uuid[UUID_SIZE];
 
                if (sb->s_feature_ro_compat &