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

bcachefs: bkey_for_each_ptr() now declares loop iter

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

+7 -38
-1
fs/bcachefs/btree_gc.c
··· 1844 1844 { 1845 1845 struct bch_fs *c = trans->c; 1846 1846 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 1847 - const struct bch_extent_ptr *ptr; 1848 1847 struct bkey_i *u; 1849 1848 int ret; 1850 1849
-2
fs/bcachefs/btree_io.c
··· 934 934 struct sort_iter *iter; 935 935 struct btree_node *sorted; 936 936 struct bkey_packed *k; 937 - struct bch_extent_ptr *ptr; 938 937 struct bset *i; 939 938 bool used_mempool, blacklisted; 940 939 bool updated_range = b->key.k.type == KEY_TYPE_btree_ptr_v2 && ··· 1895 1896 static void btree_write_submit(struct work_struct *work) 1896 1897 { 1897 1898 struct btree_write_bio *wbio = container_of(work, struct btree_write_bio, work); 1898 - struct bch_extent_ptr *ptr; 1899 1899 BKEY_PADDED_ONSTACK(k, BKEY_BTREE_PTR_VAL_U64s_MAX) tmp; 1900 1900 1901 1901 bkey_copy(&tmp.k, &wbio->key);
-4
fs/bcachefs/data_update.c
··· 356 356 struct bch_fs *c = update->op.c; 357 357 struct bkey_ptrs_c ptrs = 358 358 bch2_bkey_ptrs_c(bkey_i_to_s_c(update->k.k)); 359 - const struct bch_extent_ptr *ptr; 360 359 361 360 bkey_for_each_ptr(ptrs, ptr) { 362 361 if (c->opts.nocow_enabled) ··· 376 377 struct bio *bio = &update->op.wbio.bio; 377 378 struct bkey_i_extent *e; 378 379 struct write_point *wp; 379 - struct bch_extent_ptr *ptr; 380 380 struct closure cl; 381 381 struct btree_iter iter; 382 382 struct bkey_s_c k; ··· 507 509 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 508 510 const union bch_extent_entry *entry; 509 511 struct extent_ptr_decoded p; 510 - const struct bch_extent_ptr *ptr; 511 512 unsigned i, reserve_sectors = k.k->size * data_opts.extra_replicas; 512 513 unsigned ptrs_locked = 0; 513 514 int ret = 0; ··· 652 655 void bch2_data_update_opts_normalize(struct bkey_s_c k, struct data_update_opts *opts) 653 656 { 654 657 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 655 - const struct bch_extent_ptr *ptr; 656 658 unsigned i = 0; 657 659 658 660 bkey_for_each_ptr(ptrs, ptr) {
-1
fs/bcachefs/ec.c
··· 161 161 struct bkey_s_c k, unsigned *block) 162 162 { 163 163 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 164 - const struct bch_extent_ptr *ptr; 165 164 unsigned i, nr_data = s->nr_blocks - s->nr_redundant; 166 165 167 166 bkey_for_each_ptr(ptrs, ptr)
-4
fs/bcachefs/extents.c
··· 843 843 const struct bch_extent_ptr *bch2_bkey_has_device_c(struct bkey_s_c k, unsigned dev) 844 844 { 845 845 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 846 - const struct bch_extent_ptr *ptr; 847 846 848 847 bkey_for_each_ptr(ptrs, ptr) 849 848 if (ptr->dev == dev) ··· 854 855 bool bch2_bkey_has_target(struct bch_fs *c, struct bkey_s_c k, unsigned target) 855 856 { 856 857 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 857 - const struct bch_extent_ptr *ptr; 858 858 859 859 bkey_for_each_ptr(ptrs, ptr) 860 860 if (bch2_dev_in_target(c, ptr->dev, target) && ··· 1063 1065 struct printbuf *err) 1064 1066 { 1065 1067 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 1066 - const struct bch_extent_ptr *ptr2; 1067 1068 u64 bucket; 1068 1069 u32 bucket_offset; 1069 1070 struct bch_dev *ca; ··· 1304 1307 } 1305 1308 incompressible: 1306 1309 if (target && bch2_target_accepts_data(c, BCH_DATA_user, target)) { 1307 - const struct bch_extent_ptr *ptr; 1308 1310 unsigned i = 0; 1309 1311 1310 1312 bkey_for_each_ptr(ptrs, ptr) {
+1 -5
fs/bcachefs/extents.h
··· 300 300 bkey_extent_entry_for_each_from(_p, _entry, _p.start) 301 301 302 302 #define __bkey_for_each_ptr(_start, _end, _ptr) \ 303 - for ((_ptr) = (_start); \ 303 + for (typeof(_start) (_ptr) = (_start); \ 304 304 ((_ptr) = __bkey_ptr_next(_ptr, _end)); \ 305 305 (_ptr)++) 306 306 ··· 547 547 static inline bool bkey_extent_is_unwritten(struct bkey_s_c k) 548 548 { 549 549 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 550 - const struct bch_extent_ptr *ptr; 551 550 552 551 bkey_for_each_ptr(ptrs, ptr) 553 552 if (ptr->unwritten) ··· 564 565 { 565 566 struct bch_devs_list ret = (struct bch_devs_list) { 0 }; 566 567 struct bkey_ptrs_c p = bch2_bkey_ptrs_c(k); 567 - const struct bch_extent_ptr *ptr; 568 568 569 569 bkey_for_each_ptr(p, ptr) 570 570 ret.data[ret.nr++] = ptr->dev; ··· 575 577 { 576 578 struct bch_devs_list ret = (struct bch_devs_list) { 0 }; 577 579 struct bkey_ptrs_c p = bch2_bkey_ptrs_c(k); 578 - const struct bch_extent_ptr *ptr; 579 580 580 581 bkey_for_each_ptr(p, ptr) 581 582 if (!ptr->cached) ··· 587 590 { 588 591 struct bch_devs_list ret = (struct bch_devs_list) { 0 }; 589 592 struct bkey_ptrs_c p = bch2_bkey_ptrs_c(k); 590 - const struct bch_extent_ptr *ptr; 591 593 592 594 bkey_for_each_ptr(p, ptr) 593 595 if (ptr->cached)
-1
fs/bcachefs/io_misc.c
··· 74 74 struct bkey_i_extent *e; 75 75 struct bch_devs_list devs_have; 76 76 struct write_point *wp; 77 - struct bch_extent_ptr *ptr; 78 77 79 78 devs_have.nr = 0; 80 79
+5 -15
fs/bcachefs/io_write.c
··· 396 396 bool nocow) 397 397 { 398 398 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(bkey_i_to_s_c(k)); 399 - const struct bch_extent_ptr *ptr; 400 399 struct bch_write_bio *n; 401 - struct bch_dev *ca; 402 400 403 401 BUG_ON(c->opts.nochanges); 404 402 405 403 bkey_for_each_ptr(ptrs, ptr) { 406 404 BUG_ON(!bch2_dev_exists2(c, ptr->dev)); 407 405 408 - ca = bch_dev_bkey_exists(c, ptr->dev); 406 + struct bch_dev *ca = bch_dev_bkey_exists(c, ptr->dev); 409 407 410 408 if (to_entry(ptr + 1) < ptrs.end) { 411 409 n = to_wbio(bio_alloc_clone(NULL, &wbio->bio, ··· 1106 1108 static inline void bch2_nocow_write_unlock(struct bch_write_op *op) 1107 1109 { 1108 1110 struct bch_fs *c = op->c; 1109 - const struct bch_extent_ptr *ptr; 1110 1111 struct bkey_i *k; 1111 1112 1112 1113 for_each_keylist_key(&op->insert_keys, k) { ··· 1124 1127 struct bkey_s_c k, 1125 1128 u64 new_i_size) 1126 1129 { 1127 - struct bkey_i *new; 1128 - struct bkey_ptrs ptrs; 1129 - struct bch_extent_ptr *ptr; 1130 - int ret; 1131 - 1132 1130 if (!bch2_extents_match(bkey_i_to_s_c(orig), k)) { 1133 1131 /* trace this */ 1134 1132 return 0; 1135 1133 } 1136 1134 1137 - new = bch2_bkey_make_mut_noupdate(trans, k); 1138 - ret = PTR_ERR_OR_ZERO(new); 1135 + struct bkey_i *new = bch2_bkey_make_mut_noupdate(trans, k); 1136 + int ret = PTR_ERR_OR_ZERO(new); 1139 1137 if (ret) 1140 1138 return ret; 1141 1139 1142 1140 bch2_cut_front(bkey_start_pos(&orig->k), new); 1143 1141 bch2_cut_back(orig->k.p, new); 1144 1142 1145 - ptrs = bch2_bkey_ptrs(bkey_i_to_s(new)); 1143 + struct bkey_ptrs ptrs = bch2_bkey_ptrs(bkey_i_to_s(new)); 1146 1144 bkey_for_each_ptr(ptrs, ptr) 1147 1145 ptr->unwritten = 0; 1148 1146 ··· 1217 1225 struct btree_trans *trans; 1218 1226 struct btree_iter iter; 1219 1227 struct bkey_s_c k; 1220 - struct bkey_ptrs_c ptrs; 1221 - const struct bch_extent_ptr *ptr; 1222 1228 DARRAY_PREALLOCATED(struct bucket_to_lock, 3) buckets; 1223 1229 u32 snapshot; 1224 1230 struct bucket_to_lock *stale_at; ··· 1259 1269 break; 1260 1270 1261 1271 /* Get iorefs before dropping btree locks: */ 1262 - ptrs = bch2_bkey_ptrs_c(k); 1272 + struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 1263 1273 bkey_for_each_ptr(ptrs, ptr) { 1264 1274 struct bpos b = PTR_BUCKET_POS(c, ptr); 1265 1275 struct nocow_lock_bucket *l =
-1
fs/bcachefs/journal_io.c
··· 1678 1678 struct bch_fs *c = container_of(j, struct bch_fs, journal); 1679 1679 struct bch_dev *ca; 1680 1680 struct journal_buf *w = journal_last_unwritten_buf(j); 1681 - struct bch_extent_ptr *ptr; 1682 1681 struct bio *bio; 1683 1682 unsigned sectors = vstruct_sectors(w->data, c->block_bits); 1684 1683
+1 -4
fs/bcachefs/move.c
··· 695 695 break; 696 696 697 697 if (!bp.level) { 698 - const struct bch_extent_ptr *ptr; 699 - unsigned i = 0; 700 - 701 698 k = bch2_backpointer_get_key(trans, &iter, bp_pos, bp, 0); 702 699 ret = bkey_err(k); 703 700 if (bch2_err_matches(ret, BCH_ERR_transaction_restart)) ··· 717 720 data_opts.target = io_opts.background_target; 718 721 data_opts.rewrite_ptrs = 0; 719 722 723 + unsigned i = 0; 720 724 bkey_for_each_ptr(bch2_bkey_ptrs_c(k), ptr) { 721 725 if (ptr->dev == bucket.inode) { 722 726 data_opts.rewrite_ptrs |= 1U << i; ··· 888 890 struct data_update_opts *data_opts) 889 891 { 890 892 struct bkey_ptrs_c ptrs = bch2_bkey_ptrs_c(k); 891 - const struct bch_extent_ptr *ptr; 892 893 struct bch_ioctl_data *op = arg; 893 894 unsigned i = 0; 894 895