Skip to content

Commit 4e1ebae

Browse files
Coly Liaxboe
authored andcommitted
bcache: only use block_bytes() on struct cache
Because struct cache_set and struct cache both have struct cache_sb, therefore macro block_bytes() can be used on both of them. When removing the embedded struct cache_sb from struct cache_set, this macro won't be used on struct cache_set anymore. This patch unifies all block_bytes() usage only on struct cache, this is one of the preparation to remove the embedded struct cache_sb from struct cache_set. Signed-off-by: Coly Li <colyli@suse.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1132e56 commit 4e1ebae

7 files changed

Lines changed: 24 additions & 24 deletions

File tree

‎drivers/md/bcache/bcache.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ struct bbio {
759759

760760
#define bucket_pages(c) ((c)->sb.bucket_size / PAGE_SECTORS)
761761
#define bucket_bytes(c) ((c)->sb.bucket_size << 9)
762-
#define block_bytes(c) ((c)->sb.block_size << 9)
762+
#define block_bytes(ca) ((ca)->sb.block_size << 9)
763763

764764
static inline unsigned int meta_bucket_pages(struct cache_sb *sb)
765765
{

‎drivers/md/bcache/btree.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
static inline struct bset *write_block(struct btree *b)
106106
{
107-
return ((void *) btree_bset_first(b)) + b->written * block_bytes(b->c);
107+
return ((void *) btree_bset_first(b)) + b->written * block_bytes(b->c->cache);
108108
}
109109

110110
static void bch_btree_init_next(struct btree *b)
@@ -173,7 +173,7 @@ void bch_btree_node_read_done(struct btree *b)
173173
goto err;
174174

175175
err = "bad btree header";
176-
if (b->written + set_blocks(i, block_bytes(b->c)) >
176+
if (b->written + set_blocks(i, block_bytes(b->c->cache)) >
177177
btree_blocks(b))
178178
goto err;
179179

@@ -199,13 +199,13 @@ void bch_btree_node_read_done(struct btree *b)
199199

200200
bch_btree_iter_push(iter, i->start, bset_bkey_last(i));
201201

202-
b->written += set_blocks(i, block_bytes(b->c));
202+
b->written += set_blocks(i, block_bytes(b->c->cache));
203203
}
204204

205205
err = "corrupted btree";
206206
for (i = write_block(b);
207207
bset_sector_offset(&b->keys, i) < KEY_SIZE(&b->key);
208-
i = ((void *) i) + block_bytes(b->c))
208+
i = ((void *) i) + block_bytes(b->c->cache))
209209
if (i->seq == b->keys.set[0].data->seq)
210210
goto err;
211211

@@ -347,7 +347,7 @@ static void do_btree_node_write(struct btree *b)
347347

348348
b->bio->bi_end_io = btree_node_write_endio;
349349
b->bio->bi_private = cl;
350-
b->bio->bi_iter.bi_size = roundup(set_bytes(i), block_bytes(b->c));
350+
b->bio->bi_iter.bi_size = roundup(set_bytes(i), block_bytes(b->c->cache));
351351
b->bio->bi_opf = REQ_OP_WRITE | REQ_META | REQ_FUA;
352352
bch_bio_map(b->bio, i);
353353

@@ -423,10 +423,10 @@ void __bch_btree_node_write(struct btree *b, struct closure *parent)
423423

424424
do_btree_node_write(b);
425425

426-
atomic_long_add(set_blocks(i, block_bytes(b->c)) * b->c->sb.block_size,
426+
atomic_long_add(set_blocks(i, block_bytes(b->c->cache)) * b->c->sb.block_size,
427427
&PTR_CACHE(b->c, &b->key, 0)->btree_sectors_written);
428428

429-
b->written += set_blocks(i, block_bytes(b->c));
429+
b->written += set_blocks(i, block_bytes(b->c->cache));
430430
}
431431

432432
void bch_btree_node_write(struct btree *b, struct closure *parent)
@@ -1344,7 +1344,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
13441344

13451345
if (nodes < 2 ||
13461346
__set_blocks(b->keys.set[0].data, keys,
1347-
block_bytes(b->c)) > blocks * (nodes - 1))
1347+
block_bytes(b->c->cache)) > blocks * (nodes - 1))
13481348
return 0;
13491349

13501350
for (i = 0; i < nodes; i++) {
@@ -1378,7 +1378,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
13781378
k = bkey_next(k)) {
13791379
if (__set_blocks(n1, n1->keys + keys +
13801380
bkey_u64s(k),
1381-
block_bytes(b->c)) > blocks)
1381+
block_bytes(b->c->cache)) > blocks)
13821382
break;
13831383

13841384
last = k;
@@ -1394,7 +1394,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
13941394
* though)
13951395
*/
13961396
if (__set_blocks(n1, n1->keys + n2->keys,
1397-
block_bytes(b->c)) >
1397+
block_bytes(b->c->cache)) >
13981398
btree_blocks(new_nodes[i]))
13991399
goto out_unlock_nocoalesce;
14001400

@@ -1403,7 +1403,7 @@ static int btree_gc_coalesce(struct btree *b, struct btree_op *op,
14031403
last = &r->b->key;
14041404
}
14051405

1406-
BUG_ON(__set_blocks(n1, n1->keys + keys, block_bytes(b->c)) >
1406+
BUG_ON(__set_blocks(n1, n1->keys + keys, block_bytes(b->c->cache)) >
14071407
btree_blocks(new_nodes[i]));
14081408

14091409
if (last)
@@ -2210,7 +2210,7 @@ static int btree_split(struct btree *b, struct btree_op *op,
22102210
goto err;
22112211

22122212
split = set_blocks(btree_bset_first(n1),
2213-
block_bytes(n1->c)) > (btree_blocks(b) * 4) / 5;
2213+
block_bytes(n1->c->cache)) > (btree_blocks(b) * 4) / 5;
22142214

22152215
if (split) {
22162216
unsigned int keys = 0;

‎drivers/md/bcache/debug.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ struct dentry *bcache_debug;
2525
for (i = (start); \
2626
(void *) i < (void *) (start) + (KEY_SIZE(&b->key) << 9) &&\
2727
i->seq == (start)->seq; \
28-
i = (void *) i + set_blocks(i, block_bytes(b->c)) * \
29-
block_bytes(b->c))
28+
i = (void *) i + set_blocks(i, block_bytes(b->c->cache)) * \
29+
block_bytes(b->c->cache))
3030

3131
void bch_btree_verify(struct btree *b)
3232
{
@@ -82,14 +82,14 @@ void bch_btree_verify(struct btree *b)
8282

8383
for_each_written_bset(b, ondisk, i) {
8484
unsigned int block = ((void *) i - (void *) ondisk) /
85-
block_bytes(b->c);
85+
block_bytes(b->c->cache);
8686

8787
pr_err("*** on disk block %u:\n", block);
8888
bch_dump_bset(&b->keys, i, block);
8989
}
9090

9191
pr_err("*** block %zu not written\n",
92-
((void *) i - (void *) ondisk) / block_bytes(b->c));
92+
((void *) i - (void *) ondisk) / block_bytes(b->c->cache));
9393

9494
for (j = 0; j < inmemory->keys; j++)
9595
if (inmemory->d[j] != sorted->d[j])

‎drivers/md/bcache/journal.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ reread: left = ca->sb.bucket_size - offset;
9898
return ret;
9999
}
100100

101-
blocks = set_blocks(j, block_bytes(ca->set));
101+
blocks = set_blocks(j, block_bytes(ca));
102102

103103
/*
104104
* Nodes in 'list' are in linear increasing order of
@@ -734,7 +734,7 @@ static void journal_write_unlocked(struct closure *cl)
734734
struct cache *ca = c->cache;
735735
struct journal_write *w = c->journal.cur;
736736
struct bkey *k = &c->journal.key;
737-
unsigned int i, sectors = set_blocks(w->data, block_bytes(c)) *
737+
unsigned int i, sectors = set_blocks(w->data, block_bytes(ca)) *
738738
c->sb.block_size;
739739

740740
struct bio *bio;
@@ -754,7 +754,7 @@ static void journal_write_unlocked(struct closure *cl)
754754
return;
755755
}
756756

757-
c->journal.blocks_free -= set_blocks(w->data, block_bytes(c));
757+
c->journal.blocks_free -= set_blocks(w->data, block_bytes(ca));
758758

759759
w->data->btree_level = c->root->level;
760760

@@ -847,7 +847,7 @@ static struct journal_write *journal_wait_for_write(struct cache_set *c,
847847
struct journal_write *w = c->journal.cur;
848848

849849
sectors = __set_blocks(w->data, w->data->keys + nkeys,
850-
block_bytes(c)) * c->sb.block_size;
850+
block_bytes(c->cache)) * c->sb.block_size;
851851

852852
if (sectors <= min_t(size_t,
853853
c->journal.blocks_free * c->sb.block_size,

‎drivers/md/bcache/request.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int bch_keylist_realloc(struct keylist *l, unsigned int u64s,
9999
* bch_data_insert_keys() will insert the keys created so far
100100
* and finish the rest when the keylist is empty.
101101
*/
102-
if (newsize * sizeof(uint64_t) > block_bytes(c) - sizeof(struct jset))
102+
if (newsize * sizeof(uint64_t) > block_bytes(c->cache) - sizeof(struct jset))
103103
return -ENOMEM;
104104

105105
return __bch_keylist_realloc(l, u64s);

‎drivers/md/bcache/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1527,7 +1527,7 @@ static int flash_dev_run(struct cache_set *c, struct uuid_entry *u)
15271527

15281528
kobject_init(&d->kobj, &bch_flash_dev_ktype);
15291529

1530-
if (bcache_device_init(d, block_bytes(c), u->sectors,
1530+
if (bcache_device_init(d, block_bytes(c->cache), u->sectors,
15311531
NULL, &bcache_flash_ops))
15321532
goto err;
15331533

‎drivers/md/bcache/sysfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ SHOW(__bch_cache_set)
714714
sysfs_print(synchronous, CACHE_SYNC(&c->sb));
715715
sysfs_print(journal_delay_ms, c->journal_delay_ms);
716716
sysfs_hprint(bucket_size, bucket_bytes(c));
717-
sysfs_hprint(block_size, block_bytes(c));
717+
sysfs_hprint(block_size, block_bytes(c->cache));
718718
sysfs_print(tree_depth, c->root->level);
719719
sysfs_print(root_usage_percent, bch_root_usage(c));
720720

0 commit comments

Comments
 (0)