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)
downloadkernel_samsung_smdk4412-479965d66e320f1a095bb76027171daa675a9c72.zip
kernel_samsung_smdk4412-479965d66e320f1a095bb76027171daa675a9c72.tar.gz
kernel_samsung_smdk4412-479965d66e320f1a095bb76027171daa675a9c72.tar.bz2
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 c4b8298..30fbbd7 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -22,6 +22,7 @@
#include <linux/fs.h>
#include <linux/workqueue.h>
#include <linux/completion.h>
+#include <asm/kmap_types.h>
#include "bit-radix.h"
#include "extent_map.h"
@@ -431,15 +432,52 @@ struct btrfs_root {
static inline u##bits btrfs_##name(struct extent_buffer *eb, \
type *s) \
{ \
- __le##bits res; \
- read_eb_member(eb, s, type, member, &res); \
- return le##bits##_to_cpu(res); \
+ int err; \
+ char *map_token; \
+ char *kaddr; \
+ unsigned long map_start; \
+ unsigned long map_len; \
+ unsigned long offset = (unsigned long)s + \
+ offsetof(type, member); \
+ err = map_extent_buffer(eb, offset, \
+ sizeof(((type *)0)->member), \
+ &map_token, &kaddr, \
+ &map_start, &map_len, KM_USER0); \
+ if (!err) { \
+ __le##bits *tmp = (__le##bits *)(kaddr + offset - \
+ map_start); \
+ u##bits res = le##bits##_to_cpu(*tmp); \
+ unmap_extent_buffer(eb, map_token, KM_USER0); \
+ return res; \
+ } else { \
+ __le##bits res; \
+ read_eb_member(eb, s, type, member, &res); \
+ return le##bits##_to_cpu(res); \
+ } \
} \
static inline void btrfs_set_##name(struct extent_buffer *eb, \
type *s, u##bits val) \
{ \
- val = cpu_to_le##bits(val); \
- write_eb_member(eb, s, type, member, &val); \
+ int err; \
+ char *map_token; \
+ char *kaddr; \
+ unsigned long map_start; \
+ unsigned long map_len; \
+ unsigned long offset = (unsigned long)s + \
+ offsetof(type, member); \
+ err = map_extent_buffer(eb, offset, \
+ sizeof(((type *)0)->member), \
+ &map_token, &kaddr, \
+ &map_start, &map_len, KM_USER0); \
+ if (!err) { \
+ __le##bits *tmp = (__le##bits *)(kaddr + offset - \
+ map_start); \
+ *tmp = cpu_to_le##bits(val); \
+ unmap_extent_buffer(eb, map_token, KM_USER0); \
+ } else { \
+ val = cpu_to_le##bits(val); \
+ write_eb_member(eb, s, type, member, &val); \
+ } \
}
#define BTRFS_SETGET_HEADER_FUNCS(name, type, member, bits) \