All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: fix unaligned access at btrfs_csum_final()
@ 2010-03-21 23:31 Alexander Beregalov
  2010-03-23 15:34 ` Chris Mason
  0 siblings, 1 reply; 3+ messages in thread
From: Alexander Beregalov @ 2010-03-21 23:31 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Alexander Beregalov

Btrfs on Sparc64 produces a lot of warnings
Kernel unaligned access at TPC[10148c84] btrfs_csum_final+0x44/0x60 [btrfs]

It happens when btrfs_csum_final is called from write_dev_supers():
2195:	btrfs_csum_final(crc, sb->csum);

crc is u32, aligning sb->csum on 4-byte boundary fixes the problem.

Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
---
 fs/btrfs/ctree.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0af2e38..4dbf330 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -327,7 +327,7 @@ struct btrfs_header {
  * it currently lacks any block count etc etc
  */
 struct btrfs_super_block {
-	u8 csum[BTRFS_CSUM_SIZE];
+	u8 csum[BTRFS_CSUM_SIZE] __attribute__ ((aligned(4)));
 	/* the first 4 fields must match struct btrfs_header */
 	u8 fsid[BTRFS_FSID_SIZE];    /* FS specific uuid */
 	__le64 bytenr; /* this block number */
-- 
1.7.0.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: fix unaligned access at btrfs_csum_final()
  2010-03-21 23:31 [PATCH] Btrfs: fix unaligned access at btrfs_csum_final() Alexander Beregalov
@ 2010-03-23 15:34 ` Chris Mason
  2010-03-24  0:51   ` Chris Mason
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Mason @ 2010-03-23 15:34 UTC (permalink / raw)
  To: Alexander Beregalov; +Cc: linux-btrfs

On Mon, Mar 22, 2010 at 02:31:08AM +0300, Alexander Beregalov wrote:
> Btrfs on Sparc64 produces a lot of warnings
> Kernel unaligned access at TPC[10148c84] btrfs_csum_final+0x44/0x60 [btrfs]

Great, thanks for trackign this down.

> 
> It happens when btrfs_csum_final is called from write_dev_supers():
> 2195:	btrfs_csum_final(crc, sb->csum);
> 
> crc is u32, aligning sb->csum on 4-byte boundary fixes the problem.

So the size of the csum field is already 4 byte aligned, I'm surprised
we need this?

-chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: fix unaligned access at btrfs_csum_final()
  2010-03-23 15:34 ` Chris Mason
@ 2010-03-24  0:51   ` Chris Mason
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Mason @ 2010-03-24  0:51 UTC (permalink / raw)
  To: Alexander Beregalov, linux-btrfs

On Tue, Mar 23, 2010 at 11:34:20AM -0400, Chris Mason wrote:
> On Mon, Mar 22, 2010 at 02:31:08AM +0300, Alexander Beregalov wrote:
> > Btrfs on Sparc64 produces a lot of warnings
> > Kernel unaligned access at TPC[10148c84] btrfs_csum_final+0x44/0x60 [btrfs]
> 
> Great, thanks for trackign this down.
> 
> > 
> > It happens when btrfs_csum_final is called from write_dev_supers():
> > 2195:	btrfs_csum_final(crc, sb->csum);
> > 
> > crc is u32, aligning sb->csum on 4-byte boundary fixes the problem.
> 
> So the size of the csum field is already 4 byte aligned, I'm surprised
> we need this?

Jens did some testing and this patch changes the size of the super
struct, which changes things on disk.

But, the real problem is write_dev_supers operates on a copy of the
super struct and that copy isn't aligned.  So we just need to align the
copy in struct btrfs_fs_info, which Jens should have a neat little patch
for shortly.

So we should finally have this one fixed up shortly.  Thanks again.

-chris


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-24  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-21 23:31 [PATCH] Btrfs: fix unaligned access at btrfs_csum_final() Alexander Beregalov
2010-03-23 15:34 ` Chris Mason
2010-03-24  0:51   ` Chris Mason

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.