extents.c (6f10f7d1b02b1bbc305f88d7696445dd38b13881) extents.c (1fae7cf05293d3a2c9e59c1bc59372322386467c)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2010 Kent Overstreet <kent.overstreet@gmail.com>
4 *
5 * Uses a block device as cache for other block devices; optimized for SSDs.
6 * All allocation is done in buckets, which should match the erase block size
7 * of the device.
8 *

--- 120 unchanged lines hidden (view full) ---

129 unsigned int j;
130 char buf[80];
131
132 bch_extent_to_text(buf, sizeof(buf), k);
133 printk(" %s", buf);
134
135 for (j = 0; j < KEY_PTRS(k); j++) {
136 size_t n = PTR_BUCKET_NR(b->c, k, j);
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2010 Kent Overstreet <kent.overstreet@gmail.com>
4 *
5 * Uses a block device as cache for other block devices; optimized for SSDs.
6 * All allocation is done in buckets, which should match the erase block size
7 * of the device.
8 *

--- 120 unchanged lines hidden (view full) ---

129 unsigned int j;
130 char buf[80];
131
132 bch_extent_to_text(buf, sizeof(buf), k);
133 printk(" %s", buf);
134
135 for (j = 0; j < KEY_PTRS(k); j++) {
136 size_t n = PTR_BUCKET_NR(b->c, k, j);
137 printk(" bucket %zu", n);
138
137
138 printk(" bucket %zu", n);
139 if (n >= b->c->sb.first_bucket && n < b->c->sb.nbuckets)
140 printk(" prio %i",
141 PTR_BUCKET(b->c, k, j)->prio);
142 }
143
144 printk(" %s\n", bch_ptr_status(b->c, k));
145}
146

--- 14 unchanged lines hidden (view full) ---

161 bch_extent_to_text(buf, sizeof(buf), k);
162 cache_bug(c, "spotted btree ptr %s: %s", buf, bch_ptr_status(c, k));
163 return true;
164}
165
166static bool bch_btree_ptr_invalid(struct btree_keys *bk, const struct bkey *k)
167{
168 struct btree *b = container_of(bk, struct btree, keys);
139 if (n >= b->c->sb.first_bucket && n < b->c->sb.nbuckets)
140 printk(" prio %i",
141 PTR_BUCKET(b->c, k, j)->prio);
142 }
143
144 printk(" %s\n", bch_ptr_status(b->c, k));
145}
146

--- 14 unchanged lines hidden (view full) ---

161 bch_extent_to_text(buf, sizeof(buf), k);
162 cache_bug(c, "spotted btree ptr %s: %s", buf, bch_ptr_status(c, k));
163 return true;
164}
165
166static bool bch_btree_ptr_invalid(struct btree_keys *bk, const struct bkey *k)
167{
168 struct btree *b = container_of(bk, struct btree, keys);
169
169 return __bch_btree_ptr_invalid(b->c, k);
170}
171
172static bool btree_ptr_bad_expensive(struct btree *b, const struct bkey *k)
173{
174 unsigned int i;
175 char buf[80];
176 struct bucket *g;

--- 152 unchanged lines hidden (view full) ---

329 uint64_t old_offset;
330 unsigned int old_size, sectors_found = 0;
331
332 BUG_ON(!KEY_OFFSET(insert));
333 BUG_ON(!KEY_SIZE(insert));
334
335 while (1) {
336 struct bkey *k = bch_btree_iter_next(iter);
170 return __bch_btree_ptr_invalid(b->c, k);
171}
172
173static bool btree_ptr_bad_expensive(struct btree *b, const struct bkey *k)
174{
175 unsigned int i;
176 char buf[80];
177 struct bucket *g;

--- 152 unchanged lines hidden (view full) ---

330 uint64_t old_offset;
331 unsigned int old_size, sectors_found = 0;
332
333 BUG_ON(!KEY_OFFSET(insert));
334 BUG_ON(!KEY_SIZE(insert));
335
336 while (1) {
337 struct bkey *k = bch_btree_iter_next(iter);
338
337 if (!k)
338 break;
339
340 if (bkey_cmp(&START_KEY(k), insert) >= 0) {
341 if (KEY_SIZE(k))
342 break;
343 else
344 continue;

--- 148 unchanged lines hidden (view full) ---

493 bch_extent_to_text(buf, sizeof(buf), k);
494 cache_bug(c, "spotted extent %s: %s", buf, bch_ptr_status(c, k));
495 return true;
496}
497
498static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
499{
500 struct btree *b = container_of(bk, struct btree, keys);
339 if (!k)
340 break;
341
342 if (bkey_cmp(&START_KEY(k), insert) >= 0) {
343 if (KEY_SIZE(k))
344 break;
345 else
346 continue;

--- 148 unchanged lines hidden (view full) ---

495 bch_extent_to_text(buf, sizeof(buf), k);
496 cache_bug(c, "spotted extent %s: %s", buf, bch_ptr_status(c, k));
497 return true;
498}
499
500static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
501{
502 struct btree *b = container_of(bk, struct btree, keys);
503
501 return __bch_extent_invalid(b->c, k);
502}
503
504static bool bch_extent_bad_expensive(struct btree *b, const struct bkey *k,
505 unsigned int ptr)
506{
507 struct bucket *g = PTR_BUCKET(b->c, k, ptr);
508 char buf[80];

--- 116 unchanged lines hidden ---
504 return __bch_extent_invalid(b->c, k);
505}
506
507static bool bch_extent_bad_expensive(struct btree *b, const struct bkey *k,
508 unsigned int ptr)
509{
510 struct bucket *g = PTR_BUCKET(b->c, k, ptr);
511 char buf[80];

--- 116 unchanged lines hidden ---