summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/struct-funcs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2020-04-29 19:29:04 +0200
committerDavid Sterba <dsterba@suse.com>2020-05-25 11:25:32 +0200
commit870b388db02cac33eebe40a1cbeb056cf13e9f40 (patch)
tree92610e2454cfc6c76928cbaa02a678e0ec1a0227 /fs/btrfs/struct-funcs.c
parenta31356b9e263b723d4991383efc87b71c6e87991 (diff)
downloadlinux-stable-870b388db02cac33eebe40a1cbeb056cf13e9f40.tar.gz
linux-stable-870b388db02cac33eebe40a1cbeb056cf13e9f40.tar.bz2
linux-stable-870b388db02cac33eebe40a1cbeb056cf13e9f40.zip
btrfs: preset set/get token with first page and drop condition
All the set/get helpers first check if the token contains a cached address. After first use the address is always valid, but the extra check is done for each call. The token initialization can optimistically set it to the first extent buffer page, that we know always exists. Then the condition in all btrfs_token_*/btrfs_set_token_* can be simplified by removing the address check from the condition, but for development the assertion still makes sure it's valid. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/struct-funcs.c')
-rw-r--r--fs/btrfs/struct-funcs.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
index cebd0b5e4f37..cef628a5a9e0 100644
--- a/fs/btrfs/struct-funcs.c
+++ b/fs/btrfs/struct-funcs.c
@@ -52,8 +52,8 @@ u##bits btrfs_get_token_##bits(struct btrfs_map_token *token, \
u##bits res; \
\
ASSERT(token); \
- \
- if (token->kaddr && token->offset <= offset && \
+ ASSERT(token->kaddr); \
+ if (token->offset <= offset && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
p = kaddr + part_offset - token->offset; \
@@ -113,8 +113,8 @@ void btrfs_set_token_##bits(struct btrfs_map_token *token, \
int size = sizeof(u##bits); \
\
ASSERT(token); \
- \
- if (token->kaddr && token->offset <= offset && \
+ ASSERT(token->kaddr); \
+ if (token->offset <= offset && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
p = kaddr + part_offset - token->offset; \