aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:14:37 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit6d36dcd48f1e4e7446d603a3df9638bd314a182d (patch)
tree321f6f36de71adaab1754b113401e05d50cd5ebd /fs/btrfs/ctree.h
parent479965d66e320f1a095bb76027171daa675a9c72 (diff)
Btrfs: Avoid memcpy where possible in extent_buffers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h45
1 files changed, 40 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 30fbbd7221a9..aed08618aca6 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -483,15 +483,50 @@ static inline void btrfs_set_##name(struct extent_buffer *eb, \
483#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ 483#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \
484static inline u##bits btrfs_##name(struct extent_buffer *eb) \ 484static inline u##bits btrfs_##name(struct extent_buffer *eb) \
485{ \ 485{ \
486 __le##bits res; \ 486 int err; \
487 read_eb_member(eb, NULL, type, member, &res); \ 487 char *map_token; \
488 return le##bits##_to_cpu(res); \ 488 char *kaddr; \
489 unsigned long map_start; \
490 unsigned long map_len; \
491 unsigned long offset = offsetof(type, member); \
492 err = map_extent_buffer(eb, offset, \
493 sizeof(((type *)0)->member), \
494 &map_token, &kaddr, \
495 &map_start, &map_len, KM_USER0); \
496 if (!err) { \
497 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
498 map_start); \
499 u##bits res = le##bits##_to_cpu(*tmp); \
500 unmap_extent_buffer(eb, map_token, KM_USER0); \
501 return res; \
502 } else { \
503 __le##bits res; \
504 read_eb_member(eb, NULL, type, member, &res); \
505 return le##bits##_to_cpu(res); \
506 } \
489} \ 507} \
490static inline void btrfs_set_##name(struct extent_buffer *eb, \ 508static inline void btrfs_set_##name(struct extent_buffer *eb, \
491 u##bits val) \ 509 u##bits val) \
492{ \ 510{ \
493 val = cpu_to_le##bits(val); \ 511 int err; \
494 write_eb_member(eb, NULL, type, member, &val); \ 512 char *map_token; \
513 char *kaddr; \
514 unsigned long map_start; \
515 unsigned long map_len; \
516 unsigned long offset = offsetof(type, member); \
517 err = map_extent_buffer(eb, offset, \
518 sizeof(((type *)0)->member), \
519 &map_token, &kaddr, \
520 &map_start, &map_len, KM_USER0); \
521 if (!err) { \
522 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
523 map_start); \
524 *tmp = cpu_to_le##bits(val); \
525 unmap_extent_buffer(eb, map_token, KM_USER0); \
526 } else { \
527 val = cpu_to_le##bits(val); \
528 write_eb_member(eb, NULL, type, member, &val); \
529 } \
495} 530}
496 531
497#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \ 532#define BTRFS_SETGET_STACK_FUNCS(name, type, member, bits) \