Commit a6591715 authored by Chris Mason's avatar Chris Mason

Btrfs: stop using highmem for extent_buffers

The extent_buffers have a very complex interface where
we use HIGHMEM for metadata and try to cache a kmap mapping
to access the memory.

The next commit adds reader/writer locks, and concurrent use
of this kmap cache would make it even more complex.

This commit drops the ability to use HIGHMEM with extent buffers,
and rips out all of the related code.
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 199c36ea
This diff is collapsed.
...@@ -217,7 +217,6 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, ...@@ -217,7 +217,6 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
unsigned long len; unsigned long len;
unsigned long cur_len; unsigned long cur_len;
unsigned long offset = BTRFS_CSUM_SIZE; unsigned long offset = BTRFS_CSUM_SIZE;
char *map_token = NULL;
char *kaddr; char *kaddr;
unsigned long map_start; unsigned long map_start;
unsigned long map_len; unsigned long map_len;
...@@ -228,8 +227,7 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, ...@@ -228,8 +227,7 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
len = buf->len - offset; len = buf->len - offset;
while (len > 0) { while (len > 0) {
err = map_private_extent_buffer(buf, offset, 32, err = map_private_extent_buffer(buf, offset, 32,
&map_token, &kaddr, &kaddr, &map_start, &map_len);
&map_start, &map_len, KM_USER0);
if (err) if (err)
return 1; return 1;
cur_len = min(len, map_len - (offset - map_start)); cur_len = min(len, map_len - (offset - map_start));
...@@ -237,7 +235,6 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, ...@@ -237,7 +235,6 @@ static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
crc, cur_len); crc, cur_len);
len -= cur_len; len -= cur_len;
offset += cur_len; offset += cur_len;
unmap_extent_buffer(buf, map_token, KM_USER0);
} }
if (csum_size > sizeof(inline_result)) { if (csum_size > sizeof(inline_result)) {
result = kzalloc(csum_size * sizeof(char), GFP_NOFS); result = kzalloc(csum_size * sizeof(char), GFP_NOFS);
...@@ -1603,7 +1600,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, ...@@ -1603,7 +1600,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
goto fail_bdi; goto fail_bdi;
} }
fs_info->btree_inode->i_mapping->flags &= ~__GFP_FS; mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS);
INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC); INIT_RADIX_TREE(&fs_info->fs_roots_radix, GFP_ATOMIC);
INIT_LIST_HEAD(&fs_info->trans_list); INIT_LIST_HEAD(&fs_info->trans_list);
......
...@@ -3114,7 +3114,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree, ...@@ -3114,7 +3114,7 @@ struct extent_buffer *alloc_extent_buffer(struct extent_io_tree *tree,
i = 0; i = 0;
} }
for (; i < num_pages; i++, index++) { for (; i < num_pages; i++, index++) {
p = find_or_create_page(mapping, index, GFP_NOFS | __GFP_HIGHMEM); p = find_or_create_page(mapping, index, GFP_NOFS);
if (!p) { if (!p) {
WARN_ON(1); WARN_ON(1);
goto free_eb; goto free_eb;
...@@ -3487,9 +3487,8 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv, ...@@ -3487,9 +3487,8 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
page = extent_buffer_page(eb, i); page = extent_buffer_page(eb, i);
cur = min(len, (PAGE_CACHE_SIZE - offset)); cur = min(len, (PAGE_CACHE_SIZE - offset));
kaddr = kmap_atomic(page, KM_USER1); kaddr = page_address(page);
memcpy(dst, kaddr + offset, cur); memcpy(dst, kaddr + offset, cur);
kunmap_atomic(kaddr, KM_USER1);
dst += cur; dst += cur;
len -= cur; len -= cur;
...@@ -3499,9 +3498,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv, ...@@ -3499,9 +3498,9 @@ void read_extent_buffer(struct extent_buffer *eb, void *dstv,
} }
int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start, int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
unsigned long min_len, char **token, char **map, unsigned long min_len, char **map,
unsigned long *map_start, unsigned long *map_start,
unsigned long *map_len, int km) unsigned long *map_len)
{ {
size_t offset = start & (PAGE_CACHE_SIZE - 1); size_t offset = start & (PAGE_CACHE_SIZE - 1);
char *kaddr; char *kaddr;
...@@ -3531,42 +3530,12 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start, ...@@ -3531,42 +3530,12 @@ int map_private_extent_buffer(struct extent_buffer *eb, unsigned long start,
} }
p = extent_buffer_page(eb, i); p = extent_buffer_page(eb, i);
kaddr = kmap_atomic(p, km); kaddr = page_address(p);
*token = kaddr;
*map = kaddr + offset; *map = kaddr + offset;
*map_len = PAGE_CACHE_SIZE - offset; *map_len = PAGE_CACHE_SIZE - offset;
return 0; return 0;
} }
int map_extent_buffer(struct extent_buffer *eb, unsigned long start,
unsigned long min_len,
char **token, char **map,
unsigned long *map_start,
unsigned long *map_len, int km)
{
int err;
int save = 0;
if (eb->map_token) {
unmap_extent_buffer(eb, eb->map_token, km);
eb->map_token = NULL;
save = 1;
}
err = map_private_extent_buffer(eb, start, min_len, token, map,
map_start, map_len, km);
if (!err && save) {
eb->map_token = *token;
eb->kaddr = *map;
eb->map_start = *map_start;
eb->map_len = *map_len;
}
return err;
}
void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km)
{
kunmap_atomic(token, km);
}
int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
unsigned long start, unsigned long start,
unsigned long len) unsigned long len)
...@@ -3590,9 +3559,8 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv, ...@@ -3590,9 +3559,8 @@ int memcmp_extent_buffer(struct extent_buffer *eb, const void *ptrv,
cur = min(len, (PAGE_CACHE_SIZE - offset)); cur = min(len, (PAGE_CACHE_SIZE - offset));
kaddr = kmap_atomic(page, KM_USER0); kaddr = page_address(page);
ret = memcmp(ptr, kaddr + offset, cur); ret = memcmp(ptr, kaddr + offset, cur);
kunmap_atomic(kaddr, KM_USER0);
if (ret) if (ret)
break; break;
...@@ -3625,9 +3593,8 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv, ...@@ -3625,9 +3593,8 @@ void write_extent_buffer(struct extent_buffer *eb, const void *srcv,
WARN_ON(!PageUptodate(page)); WARN_ON(!PageUptodate(page));
cur = min(len, PAGE_CACHE_SIZE - offset); cur = min(len, PAGE_CACHE_SIZE - offset);
kaddr = kmap_atomic(page, KM_USER1); kaddr = page_address(page);
memcpy(kaddr + offset, src, cur); memcpy(kaddr + offset, src, cur);
kunmap_atomic(kaddr, KM_USER1);
src += cur; src += cur;
len -= cur; len -= cur;
...@@ -3656,9 +3623,8 @@ void memset_extent_buffer(struct extent_buffer *eb, char c, ...@@ -3656,9 +3623,8 @@ void memset_extent_buffer(struct extent_buffer *eb, char c,
WARN_ON(!PageUptodate(page)); WARN_ON(!PageUptodate(page));
cur = min(len, PAGE_CACHE_SIZE - offset); cur = min(len, PAGE_CACHE_SIZE - offset);
kaddr = kmap_atomic(page, KM_USER0); kaddr = page_address(page);
memset(kaddr + offset, c, cur); memset(kaddr + offset, c, cur);
kunmap_atomic(kaddr, KM_USER0);
len -= cur; len -= cur;
offset = 0; offset = 0;
...@@ -3689,9 +3655,8 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src, ...@@ -3689,9 +3655,8 @@ void copy_extent_buffer(struct extent_buffer *dst, struct extent_buffer *src,
cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset)); cur = min(len, (unsigned long)(PAGE_CACHE_SIZE - offset));
kaddr = kmap_atomic(page, KM_USER0); kaddr = page_address(page);
read_extent_buffer(src, kaddr + offset, src_offset, cur); read_extent_buffer(src, kaddr + offset, src_offset, cur);
kunmap_atomic(kaddr, KM_USER0);
src_offset += cur; src_offset += cur;
len -= cur; len -= cur;
...@@ -3704,20 +3669,17 @@ static void move_pages(struct page *dst_page, struct page *src_page, ...@@ -3704,20 +3669,17 @@ static void move_pages(struct page *dst_page, struct page *src_page,
unsigned long dst_off, unsigned long src_off, unsigned long dst_off, unsigned long src_off,
unsigned long len) unsigned long len)
{ {
char *dst_kaddr = kmap_atomic(dst_page, KM_USER0); char *dst_kaddr = page_address(dst_page);
if (dst_page == src_page) { if (dst_page == src_page) {
memmove(dst_kaddr + dst_off, dst_kaddr + src_off, len); memmove(dst_kaddr + dst_off, dst_kaddr + src_off, len);
} else { } else {
char *src_kaddr = kmap_atomic(src_page, KM_USER1); char *src_kaddr = page_address(src_page);
char *p = dst_kaddr + dst_off + len; char *p = dst_kaddr + dst_off + len;
char *s = src_kaddr + src_off + len; char *s = src_kaddr + src_off + len;
while (len--) while (len--)
*--p = *--s; *--p = *--s;
kunmap_atomic(src_kaddr, KM_USER1);
} }
kunmap_atomic(dst_kaddr, KM_USER0);
} }
static inline bool areas_overlap(unsigned long src, unsigned long dst, unsigned long len) static inline bool areas_overlap(unsigned long src, unsigned long dst, unsigned long len)
...@@ -3730,20 +3692,17 @@ static void copy_pages(struct page *dst_page, struct page *src_page, ...@@ -3730,20 +3692,17 @@ static void copy_pages(struct page *dst_page, struct page *src_page,
unsigned long dst_off, unsigned long src_off, unsigned long dst_off, unsigned long src_off,
unsigned long len) unsigned long len)
{ {
char *dst_kaddr = kmap_atomic(dst_page, KM_USER0); char *dst_kaddr = page_address(dst_page);
char *src_kaddr; char *src_kaddr;
if (dst_page != src_page) { if (dst_page != src_page) {
src_kaddr = kmap_atomic(src_page, KM_USER1); src_kaddr = page_address(src_page);
} else { } else {
src_kaddr = dst_kaddr; src_kaddr = dst_kaddr;
BUG_ON(areas_overlap(src_off, dst_off, len)); BUG_ON(areas_overlap(src_off, dst_off, len));
} }
memcpy(dst_kaddr + dst_off, src_kaddr + src_off, len); memcpy(dst_kaddr + dst_off, src_kaddr + src_off, len);
kunmap_atomic(dst_kaddr, KM_USER0);
if (dst_page != src_page)
kunmap_atomic(src_kaddr, KM_USER1);
} }
void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset, void memcpy_extent_buffer(struct extent_buffer *dst, unsigned long dst_offset,
......
...@@ -120,8 +120,6 @@ struct extent_state { ...@@ -120,8 +120,6 @@ struct extent_state {
struct extent_buffer { struct extent_buffer {
u64 start; u64 start;
unsigned long len; unsigned long len;
char *map_token;
char *kaddr;
unsigned long map_start; unsigned long map_start;
unsigned long map_len; unsigned long map_len;
struct page *first_page; struct page *first_page;
...@@ -279,15 +277,10 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree, ...@@ -279,15 +277,10 @@ int clear_extent_buffer_uptodate(struct extent_io_tree *tree,
int extent_buffer_uptodate(struct extent_io_tree *tree, int extent_buffer_uptodate(struct extent_io_tree *tree,
struct extent_buffer *eb, struct extent_buffer *eb,
struct extent_state *cached_state); struct extent_state *cached_state);
int map_extent_buffer(struct extent_buffer *eb, unsigned long offset,
unsigned long min_len, char **token, char **map,
unsigned long *map_start,
unsigned long *map_len, int km);
int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset, int map_private_extent_buffer(struct extent_buffer *eb, unsigned long offset,
unsigned long min_len, char **token, char **map, unsigned long min_len, char **map,
unsigned long *map_start, unsigned long *map_start,
unsigned long *map_len, int km); unsigned long *map_len);
void unmap_extent_buffer(struct extent_buffer *eb, char *token, int km);
int extent_range_uptodate(struct extent_io_tree *tree, int extent_range_uptodate(struct extent_io_tree *tree,
u64 start, u64 end); u64 start, u64 end);
int extent_clear_unlock_delalloc(struct inode *inode, int extent_clear_unlock_delalloc(struct inode *inode,
......
...@@ -664,10 +664,6 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -664,10 +664,6 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
struct btrfs_sector_sum *sector_sum; struct btrfs_sector_sum *sector_sum;
u32 nritems; u32 nritems;
u32 ins_size; u32 ins_size;
char *eb_map;
char *eb_token;
unsigned long map_len;
unsigned long map_start;
u16 csum_size = u16 csum_size =
btrfs_super_csum_size(&root->fs_info->super_copy); btrfs_super_csum_size(&root->fs_info->super_copy);
...@@ -814,30 +810,9 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -814,30 +810,9 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
item_end = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item); item_end = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_csum_item);
item_end = (struct btrfs_csum_item *)((unsigned char *)item_end + item_end = (struct btrfs_csum_item *)((unsigned char *)item_end +
btrfs_item_size_nr(leaf, path->slots[0])); btrfs_item_size_nr(leaf, path->slots[0]));
eb_token = NULL;
next_sector: next_sector:
if (!eb_token || write_extent_buffer(leaf, &sector_sum->sum, (unsigned long)item, csum_size);
(unsigned long)item + csum_size >= map_start + map_len) {
int err;
if (eb_token)
unmap_extent_buffer(leaf, eb_token, KM_USER1);
eb_token = NULL;
err = map_private_extent_buffer(leaf, (unsigned long)item,
csum_size,
&eb_token, &eb_map,
&map_start, &map_len, KM_USER1);
if (err)
eb_token = NULL;
}
if (eb_token) {
memcpy(eb_token + ((unsigned long)item & (PAGE_CACHE_SIZE - 1)),
&sector_sum->sum, csum_size);
} else {
write_extent_buffer(leaf, &sector_sum->sum,
(unsigned long)item, csum_size);
}
total_bytes += root->sectorsize; total_bytes += root->sectorsize;
sector_sum++; sector_sum++;
...@@ -850,10 +825,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans, ...@@ -850,10 +825,7 @@ int btrfs_csum_file_blocks(struct btrfs_trans_handle *trans,
goto next_sector; goto next_sector;
} }
} }
if (eb_token) {
unmap_extent_buffer(leaf, eb_token, KM_USER1);
eb_token = NULL;
}
btrfs_mark_buffer_dirty(path->nodes[0]); btrfs_mark_buffer_dirty(path->nodes[0]);
if (total_bytes < sums->len) { if (total_bytes < sums->len) {
btrfs_release_path(path); btrfs_release_path(path);
......
...@@ -2541,13 +2541,6 @@ static void btrfs_read_locked_inode(struct inode *inode) ...@@ -2541,13 +2541,6 @@ static void btrfs_read_locked_inode(struct inode *inode)
inode_item = btrfs_item_ptr(leaf, path->slots[0], inode_item = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_inode_item); struct btrfs_inode_item);
if (!leaf->map_token)
map_private_extent_buffer(leaf, (unsigned long)inode_item,
sizeof(struct btrfs_inode_item),
&leaf->map_token, &leaf->kaddr,
&leaf->map_start, &leaf->map_len,
KM_USER1);
inode->i_mode = btrfs_inode_mode(leaf, inode_item); inode->i_mode = btrfs_inode_mode(leaf, inode_item);
inode->i_nlink = btrfs_inode_nlink(leaf, inode_item); inode->i_nlink = btrfs_inode_nlink(leaf, inode_item);
inode->i_uid = btrfs_inode_uid(leaf, inode_item); inode->i_uid = btrfs_inode_uid(leaf, inode_item);
...@@ -2585,11 +2578,6 @@ static void btrfs_read_locked_inode(struct inode *inode) ...@@ -2585,11 +2578,6 @@ static void btrfs_read_locked_inode(struct inode *inode)
if (!maybe_acls) if (!maybe_acls)
cache_no_acl(inode); cache_no_acl(inode);
if (leaf->map_token) {
unmap_extent_buffer(leaf, leaf->map_token, KM_USER1);
leaf->map_token = NULL;
}
btrfs_free_path(path); btrfs_free_path(path);
switch (inode->i_mode & S_IFMT) { switch (inode->i_mode & S_IFMT) {
...@@ -2634,13 +2622,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, ...@@ -2634,13 +2622,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
struct btrfs_inode_item *item, struct btrfs_inode_item *item,
struct inode *inode) struct inode *inode)
{ {
if (!leaf->map_token)
map_private_extent_buffer(leaf, (unsigned long)item,
sizeof(struct btrfs_inode_item),
&leaf->map_token, &leaf->kaddr,
&leaf->map_start, &leaf->map_len,
KM_USER1);
btrfs_set_inode_uid(leaf, item, inode->i_uid); btrfs_set_inode_uid(leaf, item, inode->i_uid);
btrfs_set_inode_gid(leaf, item, inode->i_gid); btrfs_set_inode_gid(leaf, item, inode->i_gid);
btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size);
...@@ -2669,11 +2650,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, ...@@ -2669,11 +2650,6 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,
btrfs_set_inode_rdev(leaf, item, inode->i_rdev); btrfs_set_inode_rdev(leaf, item, inode->i_rdev);
btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags); btrfs_set_inode_flags(leaf, item, BTRFS_I(inode)->flags);
btrfs_set_inode_block_group(leaf, item, 0); btrfs_set_inode_block_group(leaf, item, 0);
if (leaf->map_token) {
unmap_extent_buffer(leaf, leaf->map_token, KM_USER1);
leaf->map_token = NULL;
}
} }
/* /*
......
...@@ -50,36 +50,22 @@ u##bits btrfs_##name(struct extent_buffer *eb, \ ...@@ -50,36 +50,22 @@ u##bits btrfs_##name(struct extent_buffer *eb, \
unsigned long part_offset = (unsigned long)s; \ unsigned long part_offset = (unsigned long)s; \
unsigned long offset = part_offset + offsetof(type, member); \ unsigned long offset = part_offset + offsetof(type, member); \
type *p; \ type *p; \
/* ugly, but we want the fast path here */ \ int err; \
if (eb->map_token && offset >= eb->map_start && \ char *kaddr; \
offset + sizeof(((type *)0)->member) <= eb->map_start + \ unsigned long map_start; \
eb->map_len) { \ unsigned long map_len; \
p = (type *)(eb->kaddr + part_offset - eb->map_start); \ u##bits res; \
return le##bits##_to_cpu(p->member); \ err = map_private_extent_buffer(eb, offset, \
} \ sizeof(((type *)0)->member), \
{ \ &kaddr, &map_start, &map_len); \
int err; \ if (err) { \
char *map_token; \ __le##bits leres; \
char *kaddr; \ read_eb_member(eb, s, type, member, &leres); \
int unmap_on_exit = (eb->map_token == NULL); \ return le##bits##_to_cpu(leres); \
unsigned long map_start; \ } \
unsigned long map_len; \ p = (type *)(kaddr + part_offset - map_start); \
u##bits res; \ res = le##bits##_to_cpu(p->member); \
err = map_extent_buffer(eb, offset, \ return res; \
sizeof(((type *)0)->member), \
&map_token, &kaddr, \
&map_start, &map_len, KM_USER1); \
if (err) { \
__le##bits leres; \
read_eb_member(eb, s, type, member, &leres); \
return le##bits##_to_cpu(leres); \
} \
p = (type *)(kaddr + part_offset - map_start); \
res = le##bits##_to_cpu(p->member); \
if (unmap_on_exit) \
unmap_extent_buffer(eb, map_token, KM_USER1); \
return res; \
} \
} \ } \
void btrfs_set_##name(struct extent_buffer *eb, \ void btrfs_set_##name(struct extent_buffer *eb, \
type *s, u##bits val) \ type *s, u##bits val) \
...@@ -87,36 +73,21 @@ void btrfs_set_##name(struct extent_buffer *eb, \ ...@@ -87,36 +73,21 @@ void btrfs_set_##name(struct extent_buffer *eb, \
unsigned long part_offset = (unsigned long)s; \ unsigned long part_offset = (unsigned long)s; \
unsigned long offset = part_offset + offsetof(type, member); \ unsigned long offset = part_offset + offsetof(type, member); \
type *p; \ type *p; \
/* ugly, but we want the fast path here */ \ int err; \
if (eb->map_token && offset >= eb->map_start && \ char *kaddr; \
offset + sizeof(((type *)0)->member) <= eb->map_start + \ unsigned long map_start; \
eb->map_len) { \ unsigned long map_len; \
p = (type *)(eb->kaddr + part_offset - eb->map_start); \ err = map_private_extent_buffer(eb, offset, \
p->member = cpu_to_le##bits(val); \ sizeof(((type *)0)->member), \
return; \ &kaddr, &map_start, &map_len); \
} \ if (err) { \
{ \ __le##bits val2; \
int err; \ val2 = cpu_to_le##bits(val); \
char *map_token; \ write_eb_member(eb, s, type, member, &val2); \
char *kaddr; \ return; \
int unmap_on_exit = (eb->map_token == NULL); \ } \
unsigned long map_start; \ p = (type *)(kaddr + part_offset - map_start); \
unsigned long map_len; \ p->member = cpu_to_le##bits(val); \
err = map_extent_buffer(eb, offset, \
sizeof(((type *)0)->member), \
&map_token, &kaddr, \
&map_start, &map_len, KM_USER1); \
if (err) { \
__le##bits val2; \
val2 = cpu_to_le##bits(val); \
write_eb_member(eb, s, type, member, &val2); \
return; \
} \
p = (type *)(kaddr + part_offset - map_start); \
p->member = cpu_to_le##bits(val); \
if (unmap_on_exit) \
unmap_extent_buffer(eb, map_token, KM_USER1); \
} \
} }
#include "ctree.h" #include "ctree.h"
...@@ -125,15 +96,6 @@ void btrfs_node_key(struct extent_buffer *eb, ...@@ -125,15 +96,6 @@ void btrfs_node_key(struct extent_buffer *eb,
struct btrfs_disk_key *disk_key, int nr) struct btrfs_disk_key *disk_key, int nr)
{ {
unsigned long ptr = btrfs_node_key_ptr_offset(nr); unsigned long ptr = btrfs_node_key_ptr_offset(nr);
if (eb->map_token && ptr >= eb->map_start &&
ptr + sizeof(*disk_key) <= eb->map_start + eb->map_len) {
memcpy(disk_key, eb->kaddr + ptr - eb->map_start,
sizeof(*disk_key));
return;
} else if (eb->map_token) {
unmap_extent_buffer(eb, eb->map_token, KM_USER1);
eb->map_token = NULL;
}
read_eb_member(eb, (struct btrfs_key_ptr *)ptr, read_eb_member(eb, (struct btrfs_key_ptr *)ptr,
struct btrfs_key_ptr, key, disk_key); struct btrfs_key_ptr, key, disk_key);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment