Commit 48bc3950 authored by David Sterba's avatar David Sterba

btrfs: assume valid token for btrfs_set/get_token helpers

Now that we can safely assume that the token is always a valid pointer,
remove the branches that check that.
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent cb495113
...@@ -52,7 +52,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \ ...@@ -52,7 +52,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
int size = sizeof(u##bits); \ int size = sizeof(u##bits); \
u##bits res; \ u##bits res; \
\ \
if (token && token->kaddr && token->offset <= offset && \ ASSERT(token); \
\
if (token->kaddr && token->offset <= offset && \
token->eb == eb && \ token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \ (token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \ kaddr = token->kaddr; \
...@@ -70,11 +72,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \ ...@@ -70,11 +72,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
} \ } \
p = kaddr + part_offset - map_start; \ p = kaddr + part_offset - map_start; \
res = get_unaligned_le##bits(p + off); \ res = get_unaligned_le##bits(p + off); \
if (token) { \
token->kaddr = kaddr; \ token->kaddr = kaddr; \
token->offset = map_start; \ token->offset = map_start; \
token->eb = eb; \ token->eb = eb; \
} \
return res; \ return res; \
} \ } \
u##bits btrfs_get_##bits(const struct extent_buffer *eb, \ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
...@@ -116,7 +116,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \ ...@@ -116,7 +116,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
unsigned long map_len; \ unsigned long map_len; \
int size = sizeof(u##bits); \ int size = sizeof(u##bits); \
\ \
if (token && token->kaddr && token->offset <= offset && \ ASSERT(token); \
\
if (token->kaddr && token->offset <= offset && \
token->eb == eb && \ token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \ (token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \ kaddr = token->kaddr; \
...@@ -135,11 +137,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \ ...@@ -135,11 +137,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
} \ } \
p = kaddr + part_offset - map_start; \ p = kaddr + part_offset - map_start; \
put_unaligned_le##bits(val, p + off); \ put_unaligned_le##bits(val, p + off); \
if (token) { \
token->kaddr = kaddr; \ token->kaddr = kaddr; \
token->offset = map_start; \ token->offset = map_start; \
token->eb = eb; \ token->eb = eb; \
} \
} \ } \
void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \ void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
unsigned long off, u##bits val) \ unsigned long off, u##bits val) \
......
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