* btrfs-tools: debian/patches/09-unaligned-memaccess.patch
@ 2013-05-22 5:08 Holger Fischer
2013-05-24 10:52 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Holger Fischer @ 2013-05-22 5:08 UTC (permalink / raw)
To: linux-btrfs
[-- Attachment #1: Type: text/plain, Size: 334 bytes --]
Dear BTRFS-Community,
attached is a patch that probably could be applied upstream:
It is ... Fixing unaligned memory accesses ...
Details to this patch could be read under
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656955
I rechecked against latest git.
As far as I can see, it's not applied yet.
Best Regards
Holger Fischer
[-- Attachment #2: 09-unaligned-memaccess.patch --]
[-- Type: text/x-diff, Size: 2342 bytes --]
Author: Shawn Landen <shawnlandden@gmail.com>
Description: Fixing unaligned memory accesses (Closes: #656955).
Index: b/ctree.h
===================================================================
--- a/ctree.h
+++ b/ctree.h
@@ -19,6 +19,8 @@
#ifndef __BTRFS__
#define __BTRFS__
+#include <stdint.h>
+
#if BTRFS_FLAT_INCLUDES
#include "list.h"
#include "kerncompat.h"
@@ -1072,13 +1074,17 @@ struct btrfs_root {
static inline u##bits btrfs_##name(struct extent_buffer *eb) \
{ \
struct btrfs_header *h = (struct btrfs_header *)eb->data; \
- return le##bits##_to_cpu(h->member); \
+ uint##bits##_t t; \
+ memcpy(&t, &h->member, sizeof(h->member)); \
+ return le##bits##_to_cpu(t); \
} \
static inline void btrfs_set_##name(struct extent_buffer *eb, \
u##bits val) \
{ \
struct btrfs_header *h = (struct btrfs_header *)eb->data; \
- h->member = cpu_to_le##bits(val); \
+ uint##bits##_t t; \
+ t = cpu_to_le##bits(val); \
+ memcpy(&h->member, &t, sizeof(h->member)); \
}
#define BTRFS_SETGET_FUNCS(name, type, member, bits) \
@@ -1104,11 +1110,15 @@ static inline void btrfs_set_##name(stru
#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \
static inline u##bits btrfs_##name(type *s) \
{ \
- return le##bits##_to_cpu(s->member); \
+ uint##bits##_t t; \
+ memcpy(&t, &s->member, sizeof(s->member)); \
+ return le##bits##_to_cpu(t); \
} \
static inline void btrfs_set_##name(type *s, u##bits val) \
{ \
- s->member = cpu_to_le##bits(val); \
+ uint##bits##_t t; \
+ t = cpu_to_le##bits(val); \
+ memcpy(&s->member, &t, sizeof(s->member)); \
}
BTRFS_SETGET_FUNCS(device_type, struct btrfs_dev_item, type, 64);
Index: b/volumes.c
===================================================================
--- a/volumes.c
+++ b/volumes.c
@@ -425,10 +425,11 @@ static int find_next_chunk(struct btrfs_
if (found_key.objectid != objectid)
*offset = 0;
else {
+ u64 t;
chunk = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_chunk);
- *offset = found_key.offset +
- btrfs_chunk_length(path->nodes[0], chunk);
+ t = found_key.offset + btrfs_chunk_length(path->nodes[0], chunk);
+ memcpy(offset, &t, sizeof(found_key.offset));
}
}
ret = 0;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: btrfs-tools: debian/patches/09-unaligned-memaccess.patch
2013-05-22 5:08 btrfs-tools: debian/patches/09-unaligned-memaccess.patch Holger Fischer
@ 2013-05-24 10:52 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2013-05-24 10:52 UTC (permalink / raw)
To: Holger Fischer; +Cc: linux-btrfs
On Wed, May 22, 2013 at 07:08:42AM +0200, Holger Fischer wrote:
> Dear BTRFS-Community,
> attached is a patch that probably could be applied upstream:
> It is ... Fixing unaligned memory accesses ...
> Details to this patch could be read under
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=656955
>
> I rechecked against latest git.
> As far as I can see, it's not applied yet.
I had been applied, but had to be updated further, see
https://git.kernel.org/cgit/linux/kernel/git/mason/btrfs-progs.git/commit/?id=7b668965f0cf3fb8632c505a7a011189ee1a5a8e
"
Replacing memcpy with memmove does't work - gcc treats memmove
the same way it treats memcpy.
This patch brings in {get|put}_unaligned_le{16|32|64} (using the
packed struct method), and uses them in the failing get/set calls.
On architectures where unaligned accesses are cheap, these unaligned
macros should be optimized out by the compiler.
"
What's still missing is get_unaligned_* in the BTRFS_SETGET_STACK_FUNCS
macros.
david
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-24 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-22 5:08 btrfs-tools: debian/patches/09-unaligned-memaccess.patch Holger Fischer
2013-05-24 10:52 ` David Sterba
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.