linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Andreas Dilger <adilger@dilger.ca>
Subject: [PATCH] misc: fix alignment warnings on ARM
Date: Fri, 22 May 2015 16:40:51 -0600	[thread overview]
Message-ID: <1432334451-15863-1-git-send-email-adilger@dilger.ca> (raw)

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>
---
 misc/filefrag.c |    2 +-
 misc/tune2fs.c  |    6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/misc/filefrag.c b/misc/filefrag.c
index 3b104c6..46f1218 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -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)) /
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index d2e8b20..36c2ff7 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -240,7 +240,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;
@@ -2609,7 +2609,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))
@@ -2964,7 +2964,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 (ext2fs_has_group_desc_csum(fs)) {
-- 
1.7.3.4


             reply	other threads:[~2015-05-22 22:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-22 22:40 Andreas Dilger [this message]
2015-06-20  1:38 ` [PATCH] misc: fix alignment warnings on ARM Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432334451-15863-1-git-send-email-adilger@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).