Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcachefs: Move bkey bkey_unpack_key() to bkey.h

Long ago, bkey_unpack_key() was added to bset.h instead of bkey.h
because bkey.h didn't include btree_types.h, which it needs for the
compiled unpack function.

This patch finally moves it to the proper location.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>

+100 -96
+94
fs/bcachefs/bkey.h
··· 5 5 #include <linux/bug.h> 6 6 #include "bcachefs_format.h" 7 7 8 + #include "btree_types.h" 8 9 #include "util.h" 9 10 #include "vstructs.h" 10 11 ··· 365 364 const struct bkey_packed *); 366 365 bool bch2_bkey_pack(struct bkey_packed *, const struct bkey_i *, 367 366 const struct bkey_format *); 367 + 368 + typedef void (*compiled_unpack_fn)(struct bkey *, const struct bkey_packed *); 369 + 370 + static inline void 371 + __bkey_unpack_key_format_checked(const struct btree *b, 372 + struct bkey *dst, 373 + const struct bkey_packed *src) 374 + { 375 + if (IS_ENABLED(HAVE_BCACHEFS_COMPILED_UNPACK)) { 376 + compiled_unpack_fn unpack_fn = b->aux_data; 377 + unpack_fn(dst, src); 378 + 379 + if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) && 380 + bch2_expensive_debug_checks) { 381 + struct bkey dst2 = __bch2_bkey_unpack_key(&b->format, src); 382 + 383 + BUG_ON(memcmp(dst, &dst2, sizeof(*dst))); 384 + } 385 + } else { 386 + *dst = __bch2_bkey_unpack_key(&b->format, src); 387 + } 388 + } 389 + 390 + static inline struct bkey 391 + bkey_unpack_key_format_checked(const struct btree *b, 392 + const struct bkey_packed *src) 393 + { 394 + struct bkey dst; 395 + 396 + __bkey_unpack_key_format_checked(b, &dst, src); 397 + return dst; 398 + } 399 + 400 + static inline void __bkey_unpack_key(const struct btree *b, 401 + struct bkey *dst, 402 + const struct bkey_packed *src) 403 + { 404 + if (likely(bkey_packed(src))) 405 + __bkey_unpack_key_format_checked(b, dst, src); 406 + else 407 + *dst = *packed_to_bkey_c(src); 408 + } 409 + 410 + /** 411 + * bkey_unpack_key -- unpack just the key, not the value 412 + */ 413 + static inline struct bkey bkey_unpack_key(const struct btree *b, 414 + const struct bkey_packed *src) 415 + { 416 + return likely(bkey_packed(src)) 417 + ? bkey_unpack_key_format_checked(b, src) 418 + : *packed_to_bkey_c(src); 419 + } 420 + 421 + static inline struct bpos 422 + bkey_unpack_pos_format_checked(const struct btree *b, 423 + const struct bkey_packed *src) 424 + { 425 + #ifdef HAVE_BCACHEFS_COMPILED_UNPACK 426 + return bkey_unpack_key_format_checked(b, src).p; 427 + #else 428 + return __bkey_unpack_pos(&b->format, src); 429 + #endif 430 + } 431 + 432 + static inline struct bpos bkey_unpack_pos(const struct btree *b, 433 + const struct bkey_packed *src) 434 + { 435 + return likely(bkey_packed(src)) 436 + ? bkey_unpack_pos_format_checked(b, src) 437 + : packed_to_bkey_c(src)->p; 438 + } 439 + 440 + /* Disassembled bkeys */ 441 + 442 + static inline struct bkey_s_c bkey_disassemble(struct btree *b, 443 + const struct bkey_packed *k, 444 + struct bkey *u) 445 + { 446 + __bkey_unpack_key(b, u, k); 447 + 448 + return (struct bkey_s_c) { u, bkeyp_val(&b->format, k), }; 449 + } 450 + 451 + /* non const version: */ 452 + static inline struct bkey_s __bkey_disassemble(struct btree *b, 453 + struct bkey_packed *k, 454 + struct bkey *u) 455 + { 456 + __bkey_unpack_key(b, u, k); 457 + 458 + return (struct bkey_s) { .k = u, .v = bkeyp_val(&b->format, k), }; 459 + } 368 460 369 461 static inline u64 bkey_field_max(const struct bkey_format *f, 370 462 enum bch_bkey_fields nr)
+1
fs/bcachefs/bkey_buf.h
··· 3 3 #define _BCACHEFS_BKEY_BUF_H 4 4 5 5 #include "bcachefs.h" 6 + #include "bkey.h" 6 7 7 8 struct bkey_buf { 8 9 struct bkey_i *k;
-93
fs/bcachefs/bset.h
··· 205 205 return btree_aux_data_bytes(b) / sizeof(u64); 206 206 } 207 207 208 - typedef void (*compiled_unpack_fn)(struct bkey *, const struct bkey_packed *); 209 - 210 - static inline void 211 - __bkey_unpack_key_format_checked(const struct btree *b, 212 - struct bkey *dst, 213 - const struct bkey_packed *src) 214 - { 215 - if (IS_ENABLED(HAVE_BCACHEFS_COMPILED_UNPACK)) { 216 - compiled_unpack_fn unpack_fn = b->aux_data; 217 - unpack_fn(dst, src); 218 - 219 - if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) && 220 - bch2_expensive_debug_checks) { 221 - struct bkey dst2 = __bch2_bkey_unpack_key(&b->format, src); 222 - 223 - BUG_ON(memcmp(dst, &dst2, sizeof(*dst))); 224 - } 225 - } else { 226 - *dst = __bch2_bkey_unpack_key(&b->format, src); 227 - } 228 - } 229 - 230 - static inline struct bkey 231 - bkey_unpack_key_format_checked(const struct btree *b, 232 - const struct bkey_packed *src) 233 - { 234 - struct bkey dst; 235 - 236 - __bkey_unpack_key_format_checked(b, &dst, src); 237 - return dst; 238 - } 239 - 240 - static inline void __bkey_unpack_key(const struct btree *b, 241 - struct bkey *dst, 242 - const struct bkey_packed *src) 243 - { 244 - if (likely(bkey_packed(src))) 245 - __bkey_unpack_key_format_checked(b, dst, src); 246 - else 247 - *dst = *packed_to_bkey_c(src); 248 - } 249 - 250 - /** 251 - * bkey_unpack_key -- unpack just the key, not the value 252 - */ 253 - static inline struct bkey bkey_unpack_key(const struct btree *b, 254 - const struct bkey_packed *src) 255 - { 256 - return likely(bkey_packed(src)) 257 - ? bkey_unpack_key_format_checked(b, src) 258 - : *packed_to_bkey_c(src); 259 - } 260 - 261 - static inline struct bpos 262 - bkey_unpack_pos_format_checked(const struct btree *b, 263 - const struct bkey_packed *src) 264 - { 265 - #ifdef HAVE_BCACHEFS_COMPILED_UNPACK 266 - return bkey_unpack_key_format_checked(b, src).p; 267 - #else 268 - return __bkey_unpack_pos(&b->format, src); 269 - #endif 270 - } 271 - 272 - static inline struct bpos bkey_unpack_pos(const struct btree *b, 273 - const struct bkey_packed *src) 274 - { 275 - return likely(bkey_packed(src)) 276 - ? bkey_unpack_pos_format_checked(b, src) 277 - : packed_to_bkey_c(src)->p; 278 - } 279 - 280 - /* Disassembled bkeys */ 281 - 282 - static inline struct bkey_s_c bkey_disassemble(struct btree *b, 283 - const struct bkey_packed *k, 284 - struct bkey *u) 285 - { 286 - __bkey_unpack_key(b, u, k); 287 - 288 - return (struct bkey_s_c) { u, bkeyp_val(&b->format, k), }; 289 - } 290 - 291 - /* non const version: */ 292 - static inline struct bkey_s __bkey_disassemble(struct btree *b, 293 - struct bkey_packed *k, 294 - struct bkey *u) 295 - { 296 - __bkey_unpack_key(b, u, k); 297 - 298 - return (struct bkey_s) { .k = u, .v = bkeyp_val(&b->format, k), }; 299 - } 300 - 301 208 #define for_each_bset(_b, _t) \ 302 209 for (_t = (_b)->set; _t < (_b)->set + (_b)->nsets; _t++) 303 210
+1
fs/bcachefs/btree_cache.h
··· 4 4 5 5 #include "bcachefs.h" 6 6 #include "btree_types.h" 7 + #include "bkey_methods.h" 7 8 8 9 extern const char * const bch2_btree_node_flags[]; 9 10
+1 -1
fs/bcachefs/btree_types.h
··· 5 5 #include <linux/list.h> 6 6 #include <linux/rhashtable.h> 7 7 8 - #include "bkey_methods.h" 8 + //#include "bkey_methods.h" 9 9 #include "buckets_types.h" 10 10 #include "darray.h" 11 11 #include "journal_types.h"
-2
fs/bcachefs/buckets.h
··· 229 229 int bch2_trans_mark_reservation(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned); 230 230 int bch2_trans_mark_reflink_p(struct btree_trans *, enum btree_id, unsigned, struct bkey_s_c, struct bkey_i *, unsigned); 231 231 232 - int bch2_mark_key(struct btree_trans *, struct bkey_s_c, struct bkey_s_c, unsigned); 233 - 234 232 int bch2_trans_fs_usage_apply(struct btree_trans *, struct replicas_delta_list *); 235 233 236 234 int bch2_trans_mark_metadata_bucket(struct btree_trans *, struct bch_dev *,
+1
fs/bcachefs/inode.h
··· 2 2 #ifndef _BCACHEFS_INODE_H 3 3 #define _BCACHEFS_INODE_H 4 4 5 + #include "bkey.h" 5 6 #include "opts.h" 6 7 7 8 extern const char * const bch2_inode_opts[];
+1
fs/bcachefs/keylist.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 3 3 #include "bcachefs.h" 4 + #include "bkey.h" 4 5 #include "keylist.h" 5 6 6 7 int bch2_keylist_realloc(struct keylist *l, u64 *inline_u64s,
+1
fs/bcachefs/replicas.h
··· 2 2 #ifndef _BCACHEFS_REPLICAS_H 3 3 #define _BCACHEFS_REPLICAS_H 4 4 5 + #include "bkey.h" 5 6 #include "eytzinger.h" 6 7 #include "replicas_types.h" 7 8