aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:14:27 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commit479965d66e320f1a095bb76027171daa675a9c72 (patch)
treee8b57bf49e2c0eb37e5dbd389f716e4dc21d54dc /fs/btrfs/ctree.h
parent5f39d397dfbe140a14edecd4e73c34ce23c4f9ee (diff)
Btrfs: Optimizations for the extent_buffer code
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h48
1 files changed, 43 insertions, 5 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index c4b829806855..30fbbd7221a9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -22,6 +22,7 @@
22#include <linux/fs.h> 22#include <linux/fs.h>
23#include <linux/workqueue.h> 23#include <linux/workqueue.h>
24#include <linux/completion.h> 24#include <linux/completion.h>
25#include <asm/kmap_types.h>
25#include "bit-radix.h" 26#include "bit-radix.h"
26#include "extent_map.h" 27#include "extent_map.h"
27 28
@@ -431,15 +432,52 @@ struct btrfs_root {
431static inline u##bits btrfs_##name(struct extent_buffer *eb, \ 432static inline u##bits btrfs_##name(struct extent_buffer *eb, \
432 type *s) \ 433 type *s) \
433{ \ 434{ \
434 __le##bits res; \ 435 int err; \
435 read_eb_member(eb, s, type, member, &res); \ 436 char *map_token; \
436 return le##bits##_to_cpu(res); \ 437 char *kaddr; \
438 unsigned long map_start; \
439 unsigned long map_len; \
440 unsigned long offset = (unsigned long)s + \
441 offsetof(type, member); \
442 err = map_extent_buffer(eb, offset, \
443 sizeof(((type *)0)->member), \
444 &map_token, &kaddr, \
445 &map_start, &map_len, KM_USER0); \
446 if (!err) { \
447 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
448 map_start); \
449 u##bits res = le##bits##_to_cpu(*tmp); \
450 unmap_extent_buffer(eb, map_token, KM_USER0); \
451 return res; \
452 } else { \
453 __le##bits res; \
454 read_eb_member(eb, s, type, member, &res); \
455 return le##bits##_to_cpu(res); \
456 } \
437} \ 457} \
438static inline void btrfs_set_##name(struct extent_buffer *eb, \ 458static inline void btrfs_set_##name(struct extent_buffer *eb, \
439 type *s, u##bits val) \ 459 type *s, u##bits val) \
440{ \ 460{ \
441 val = cpu_to_le##bits(val); \ 461 int err; \
442 write_eb_member(eb, s, type, member, &val); \ 462 char *map_token; \
463 char *kaddr; \
464 unsigned long map_start; \
465 unsigned long map_len; \
466 unsigned long offset = (unsigned long)s + \
467 offsetof(type, member); \
468 err = map_extent_buffer(eb, offset, \
469 sizeof(((type *)0)->member), \
470 &map_token, &kaddr, \
471 &map_start, &map_len, KM_USER0); \
472 if (!err) { \
473 __le##bits *tmp = (__le##bits *)(kaddr + offset - \
474 map_start); \
475 *tmp = cpu_to_le##bits(val); \
476 unmap_extent_buffer(eb, map_token, KM_USER0); \
477 } else { \
478 val = cpu_to_le##bits(val); \
479 write_eb_member(eb, s, type, member, &val); \
480 } \
443} 481}
444 482
445#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \ 483#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \