summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/struct-funcs.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2019-08-09 17:48:21 +0200
committerDavid Sterba <dsterba@suse.com>2019-09-09 14:59:16 +0200
commitc82f823c9b006c31059341af41da9f8b2e3e64d9 (patch)
treeb6b9204325f78f83df3a1a871ee4a7abc6e29b07 /fs/btrfs/struct-funcs.c
parentbtrfs: assume valid token for btrfs_set/get_token helpers (diff)
downloadlinux-c82f823c9b006c31059341af41da9f8b2e3e64d9.tar.xz
linux-c82f823c9b006c31059341af41da9f8b2e3e64d9.zip
btrfs: tie extent buffer and it's token together
Further simplifaction of the get/set helpers is possible when the token is uniquely tied to an extent buffer. A condition and an assignment can be avoided. The initializations are moved closer to the first use when the extent buffer is valid. There's one exception in __push_leaf_left where the token is reused. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/struct-funcs.c')
-rw-r--r--fs/btrfs/struct-funcs.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/fs/btrfs/struct-funcs.c b/fs/btrfs/struct-funcs.c
index 3a29b911d2e2..73f7987143df 100644
--- a/fs/btrfs/struct-funcs.c
+++ b/fs/btrfs/struct-funcs.c
@@ -53,9 +53,9 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
u##bits res; \
\
ASSERT(token); \
+ ASSERT(token->eb == eb); \
\
if (token->kaddr && token->offset <= offset && \
- token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
p = kaddr + part_offset - token->offset; \
@@ -74,7 +74,6 @@ u##bits btrfs_get_token_##bits(const struct extent_buffer *eb, \
res = get_unaligned_le##bits(p + off); \
token->kaddr = kaddr; \
token->offset = map_start; \
- token->eb = eb; \
return res; \
} \
u##bits btrfs_get_##bits(const struct extent_buffer *eb, \
@@ -117,9 +116,9 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
int size = sizeof(u##bits); \
\
ASSERT(token); \
+ ASSERT(token->eb == eb); \
\
if (token->kaddr && token->offset <= offset && \
- token->eb == eb && \
(token->offset + PAGE_SIZE >= offset + size)) { \
kaddr = token->kaddr; \
p = kaddr + part_offset - token->offset; \
@@ -139,7 +138,6 @@ void btrfs_set_token_##bits(struct extent_buffer *eb, \
put_unaligned_le##bits(val, p + off); \
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) \