summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/struct-funcs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-08-09 17:30:23 +0200
committerDavid Sterba <dsterba@suse.com>2019-09-09 14:59:16 +0200
commit48bc39501a549ec978c8aad28eb89ca3a2a7ca03 (patch)
tree14e0cacf281cc9f1164db829b42fa22ab6348a78 /fs/btrfs/struct-funcs.c
parentbtrfs: define separate btrfs_set/get_XX helpers (diff)
downloadlinux-48bc39501a549ec978c8aad28eb89ca3a2a7ca03.tar.xz
linux-48bc39501a549ec978c8aad28eb89ca3a2a7ca03.zip
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: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/struct-funcs.c')
-rw-r--r--fs/btrfs/struct-funcs.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
index e63936e4c1e0..3a29b911d2e2 100644
--- a/fs/btrfs/struct-funcs.c
+++ b/fs/btrfs/struct-funcs.c
@@ -52,7 +52,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
int size = sizeof(u##bits); \
u##bits res; \
\
- if (token && token->kaddr && token->offset <= offset && \
+ ASSERT(token); \
+ \
+ if (token->kaddr && token->offset <= offset && \
token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
@@ -70,11 +72,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
} \
p = kaddr + part_offset - map_start; \
res = get_unaligned_le##bits(p + off); \
- if (token) { \
- token->kaddr = kaddr; \
- token->offset = map_start; \
- token->eb = eb; \
- } \
+ token->kaddr = kaddr; \
+ token->offset = map_start; \
+ token->eb = eb; \
return res; \
} \
u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
@@ -116,7 +116,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
unsigned long map_len; \
int size = sizeof(u##bits); \
\
- if (token && token->kaddr && token->offset <= offset && \
+ ASSERT(token); \
+ \
+ if (token->kaddr && token->offset <= offset && \
token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
@@ -135,11 +137,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
} \
p = kaddr + part_offset - map_start; \
put_unaligned_le##bits(val, p + off); \
- if (token) { \
- token->kaddr = kaddr; \
- token->offset = map_start; \
- token->eb = eb; \
- } \
+ token->kaddr = kaddr; \
+ token->offset = map_start; \
+ token->eb = eb; \
} \
void btrfs_set_##bits(struct extent_buffer *eb, void *ptr, \
unsigned long off, u##bits val) \