Skip to content

Commit 169ef1c

Browse files
Kent Overstreetaxboe
authored andcommitted
bcache: Don't export utility code, prefix with bch_
Signed-off-by: Kent Overstreet <koverstreet@google.com> Cc: linux-bcache@vger.kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0b6ef41 commit 169ef1c

13 files changed

Lines changed: 89 additions & 101 deletions

File tree

‎drivers/md/bcache/bcache.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ static inline void bkey_init(struct bkey *k)
10331033
* jset: The checksum is _always_ the first 8 bytes of these structs
10341034
*/
10351035
#define csum_set(i) \
1036-
crc64(((void *) (i)) + sizeof(uint64_t), \
1036+
bch_crc64(((void *) (i)) + sizeof(uint64_t), \
10371037
((void *) end(i)) - (((void *) (i)) + sizeof(uint64_t)))
10381038

10391039
/* Error handling macros */

‎drivers/md/bcache/bset.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter,
10261026

10271027
if (!start) {
10281028
spin_lock(&b->c->sort_time_lock);
1029-
time_stats_update(&b->c->sort_time, start_time);
1029+
bch_time_stats_update(&b->c->sort_time, start_time);
10301030
spin_unlock(&b->c->sort_time_lock);
10311031
}
10321032
}
@@ -1076,7 +1076,7 @@ void bch_btree_sort_into(struct btree *b, struct btree *new)
10761076
btree_mergesort(b, new->sets->data, &iter, false, true);
10771077

10781078
spin_lock(&b->c->sort_time_lock);
1079-
time_stats_update(&b->c->sort_time, start_time);
1079+
bch_time_stats_update(&b->c->sort_time, start_time);
10801080
spin_unlock(&b->c->sort_time_lock);
10811081

10821082
bkey_copy_key(&new->key, &b->key);

‎drivers/md/bcache/btree.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
129129
uint64_t crc = b->key.ptr[0];
130130
void *data = (void *) i + 8, *end = end(i);
131131

132-
crc = crc64_update(crc, data, end - data);
132+
crc = bch_crc64_update(crc, data, end - data);
133133
return crc ^ 0xffffffffffffffff;
134134
}
135135

@@ -231,7 +231,7 @@ void bch_btree_read_done(struct closure *cl)
231231
mutex_unlock(&b->c->fill_lock);
232232

233233
spin_lock(&b->c->btree_read_time_lock);
234-
time_stats_update(&b->c->btree_read_time, b->io_start_time);
234+
bch_time_stats_update(&b->c->btree_read_time, b->io_start_time);
235235
spin_unlock(&b->c->btree_read_time_lock);
236236

237237
smp_wmb(); /* read_done is our write lock */
@@ -259,7 +259,7 @@ void bch_btree_read(struct btree *b)
259259
b->bio->bi_rw = REQ_META|READ_SYNC;
260260
b->bio->bi_size = KEY_SIZE(&b->key) << 9;
261261

262-
bio_map(b->bio, b->sets[0].data);
262+
bch_bio_map(b->bio, b->sets[0].data);
263263

264264
pr_debug("%s", pbtree(b));
265265
trace_bcache_btree_read(b->bio);
@@ -327,12 +327,12 @@ static void do_btree_write(struct btree *b)
327327
btree_bio_init(b);
328328
b->bio->bi_rw = REQ_META|WRITE_SYNC;
329329
b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c);
330-
bio_map(b->bio, i);
330+
bch_bio_map(b->bio, i);
331331

332332
bkey_copy(&k.key, &b->key);
333333
SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i));
334334

335-
if (!bio_alloc_pages(b->bio, GFP_NOIO)) {
335+
if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) {
336336
int j;
337337
struct bio_vec *bv;
338338
void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
@@ -347,7 +347,7 @@ static void do_btree_write(struct btree *b)
347347
continue_at(cl, btree_write_done, NULL);
348348
} else {
349349
b->bio->bi_vcnt = 0;
350-
bio_map(b->bio, i);
350+
bch_bio_map(b->bio, i);
351351

352352
trace_bcache_btree_write(b->bio);
353353
bch_submit_bbio(b->bio, b->c, &k.key, 0);
@@ -815,7 +815,7 @@ static struct btree *mca_cannibalize(struct cache_set *c, struct bkey *k,
815815
void bch_cannibalize_unlock(struct cache_set *c, struct closure *cl)
816816
{
817817
if (c->try_harder == cl) {
818-
time_stats_update(&c->try_harder_time, c->try_harder_start);
818+
bch_time_stats_update(&c->try_harder_time, c->try_harder_start);
819819
c->try_harder = NULL;
820820
__closure_wake_up(&c->try_wait);
821821
}
@@ -1536,7 +1536,7 @@ static void bch_btree_gc(struct closure *cl)
15361536

15371537
available = bch_btree_gc_finish(c);
15381538

1539-
time_stats_update(&c->btree_gc_time, start_time);
1539+
bch_time_stats_update(&c->btree_gc_time, start_time);
15401540

15411541
stats.key_bytes *= sizeof(uint64_t);
15421542
stats.dirty <<= 9;
@@ -2007,7 +2007,7 @@ static int btree_split(struct btree *b, struct btree_op *op)
20072007
rw_unlock(true, n1);
20082008
btree_node_free(b, op);
20092009

2010-
time_stats_update(&b->c->btree_split_time, start_time);
2010+
bch_time_stats_update(&b->c->btree_split_time, start_time);
20112011

20122012
return 0;
20132013
err_free2:

‎drivers/md/bcache/debug.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ void bch_data_verify(struct search *s)
200200
if (!check)
201201
return;
202202

203-
if (bio_alloc_pages(check, GFP_NOIO))
203+
if (bch_bio_alloc_pages(check, GFP_NOIO))
204204
goto out_put;
205205

206206
check->bi_rw = READ_SYNC;

‎drivers/md/bcache/journal.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ reread: left = ca->sb.bucket_size - offset;
5454

5555
bio->bi_end_io = journal_read_endio;
5656
bio->bi_private = &op->cl;
57-
bio_map(bio, data);
57+
bch_bio_map(bio, data);
5858

5959
closure_bio_submit(bio, &op->cl, ca);
6060
closure_sync(&op->cl);
@@ -621,7 +621,7 @@ static void journal_write_unlocked(struct closure *cl)
621621

622622
bio->bi_end_io = journal_write_endio;
623623
bio->bi_private = w;
624-
bio_map(bio, w->data);
624+
bch_bio_map(bio, w->data);
625625

626626
trace_bcache_journal_write(bio);
627627
bio_list_add(&list, bio);

‎drivers/md/bcache/movinggc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void moving_init(struct moving_io *io)
8585
PAGE_SECTORS);
8686
bio->bi_private = &io->s.cl;
8787
bio->bi_io_vec = bio->bi_inline_vecs;
88-
bio_map(bio, NULL);
88+
bch_bio_map(bio, NULL);
8989
}
9090

9191
static void write_moving(struct closure *cl)
@@ -159,7 +159,7 @@ static void read_moving(struct closure *cl)
159159
bio->bi_rw = READ;
160160
bio->bi_end_io = read_moving_endio;
161161

162-
if (bio_alloc_pages(bio, GFP_KERNEL))
162+
if (bch_bio_alloc_pages(bio, GFP_KERNEL))
163163
goto err;
164164

165165
pr_debug("%s", pkey(&w->key));

‎drivers/md/bcache/request.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
5858
char __user *buf, size_t nbytes, loff_t *ppos)
5959
{
6060
char tmp[1024];
61-
int len = snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes,
62-
cgroup_to_bcache(cgrp)->cache_mode + 1);
61+
int len = bch_snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes,
62+
cgroup_to_bcache(cgrp)->cache_mode + 1);
6363

6464
if (len < 0)
6565
return len;
@@ -70,7 +70,7 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
7070
static int cache_mode_write(struct cgroup *cgrp, struct cftype *cft,
7171
const char *buf)
7272
{
73-
int v = read_string_list(buf, bch_cache_modes);
73+
int v = bch_read_string_list(buf, bch_cache_modes);
7474
if (v < 0)
7575
return v;
7676

@@ -205,7 +205,7 @@ static void bio_csum(struct bio *bio, struct bkey *k)
205205

206206
bio_for_each_segment(bv, bio, i) {
207207
void *d = kmap(bv->bv_page) + bv->bv_offset;
208-
csum = crc64_update(csum, d, bv->bv_len);
208+
csum = bch_crc64_update(csum, d, bv->bv_len);
209209
kunmap(bv->bv_page);
210210
}
211211

@@ -835,7 +835,7 @@ static void request_read_done(struct closure *cl)
835835
s->op.cache_bio->bi_sector = s->cache_miss->bi_sector;
836836
s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev;
837837
s->op.cache_bio->bi_size = s->cache_bio_sectors << 9;
838-
bio_map(s->op.cache_bio, NULL);
838+
bch_bio_map(s->op.cache_bio, NULL);
839839

840840
src = bio_iovec(s->op.cache_bio);
841841
dst = bio_iovec(s->cache_miss);
@@ -962,8 +962,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
962962
if (!bch_btree_insert_check_key(b, &s->op, s->op.cache_bio))
963963
goto out_put;
964964

965-
bio_map(s->op.cache_bio, NULL);
966-
if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
965+
bch_bio_map(s->op.cache_bio, NULL);
966+
if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
967967
goto out_put;
968968

969969
s->cache_miss = miss;

‎drivers/md/bcache/super.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
142142
goto err;
143143

144144
err = "Bad UUID";
145-
if (is_zero(sb->uuid, 16))
145+
if (bch_is_zero(sb->uuid, 16))
146146
goto err;
147147

148148
err = "Unsupported superblock version";
@@ -170,7 +170,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
170170
goto out;
171171

172172
err = "Bad UUID";
173-
if (is_zero(sb->set_uuid, 16))
173+
if (bch_is_zero(sb->set_uuid, 16))
174174
goto err;
175175

176176
err = "Bad cache device number in set";
@@ -218,7 +218,7 @@ static void __write_super(struct cache_sb *sb, struct bio *bio)
218218
bio->bi_sector = SB_SECTOR;
219219
bio->bi_rw = REQ_SYNC|REQ_META;
220220
bio->bi_size = SB_SIZE;
221-
bio_map(bio, NULL);
221+
bch_bio_map(bio, NULL);
222222

223223
out->offset = cpu_to_le64(sb->offset);
224224
out->version = cpu_to_le64(sb->version);
@@ -332,7 +332,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
332332

333333
bio->bi_end_io = uuid_endio;
334334
bio->bi_private = cl;
335-
bio_map(bio, c->uuids);
335+
bch_bio_map(bio, c->uuids);
336336

337337
bch_submit_bbio(bio, c, k, i);
338338

@@ -344,7 +344,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
344344
pkey(&c->uuid_bucket));
345345

346346
for (u = c->uuids; u < c->uuids + c->nr_uuids; u++)
347-
if (!is_zero(u->uuid, 16))
347+
if (!bch_is_zero(u->uuid, 16))
348348
pr_debug("Slot %zi: %pU: %s: 1st: %u last: %u inv: %u",
349349
u - c->uuids, u->uuid, u->label,
350350
u->first_reg, u->last_reg, u->invalidated);
@@ -491,7 +491,7 @@ static void prio_io(struct cache *ca, uint64_t bucket, unsigned long rw)
491491

492492
bio->bi_end_io = prio_endio;
493493
bio->bi_private = ca;
494-
bio_map(bio, ca->disk_buckets);
494+
bch_bio_map(bio, ca->disk_buckets);
495495

496496
closure_bio_submit(bio, &ca->prio, ca);
497497
closure_sync(cl);
@@ -538,7 +538,7 @@ void bch_prio_write(struct cache *ca)
538538

539539
p->next_bucket = ca->prio_buckets[i + 1];
540540
p->magic = pset_magic(ca);
541-
p->csum = crc64(&p->magic, bucket_bytes(ca) - 8);
541+
p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
542542

543543
bucket = bch_bucket_alloc(ca, WATERMARK_PRIO, &cl);
544544
BUG_ON(bucket == -1);
@@ -585,7 +585,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
585585

586586
prio_io(ca, bucket, READ_SYNC);
587587

588-
if (p->csum != crc64(&p->magic, bucket_bytes(ca) - 8))
588+
if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
589589
pr_warn("bad csum reading priorities");
590590

591591
if (p->magic != pset_magic(ca))
@@ -898,7 +898,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
898898
sysfs_remove_file(&dc->kobj, &sysfs_attach);
899899
*/
900900

901-
if (is_zero(u->uuid, 16)) {
901+
if (bch_is_zero(u->uuid, 16)) {
902902
struct closure cl;
903903
closure_init_stack(&cl);
904904

‎drivers/md/bcache/sysfs.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ SHOW(__bch_cached_dev)
105105
#define var(stat) (dc->stat)
106106

107107
if (attr == &sysfs_cache_mode)
108-
return snprint_string_list(buf, PAGE_SIZE,
109-
bch_cache_modes + 1,
110-
BDEV_CACHE_MODE(&dc->sb));
108+
return bch_snprint_string_list(buf, PAGE_SIZE,
109+
bch_cache_modes + 1,
110+
BDEV_CACHE_MODE(&dc->sb));
111111

112112
sysfs_printf(data_csum, "%i", dc->disk.data_csum);
113113
var_printf(verify, "%i");
@@ -126,10 +126,10 @@ SHOW(__bch_cached_dev)
126126
char dirty[20];
127127
char derivative[20];
128128
char target[20];
129-
hprint(dirty,
129+
bch_hprint(dirty,
130130
atomic_long_read(&dc->disk.sectors_dirty) << 9);
131-
hprint(derivative, dc->writeback_rate_derivative << 9);
132-
hprint(target, dc->writeback_rate_target << 9);
131+
bch_hprint(derivative, dc->writeback_rate_derivative << 9);
132+
bch_hprint(target, dc->writeback_rate_target << 9);
133133

134134
return sprintf(buf,
135135
"rate:\t\t%u\n"
@@ -202,7 +202,7 @@ STORE(__cached_dev)
202202
bch_cached_dev_run(dc);
203203

204204
if (attr == &sysfs_cache_mode) {
205-
ssize_t v = read_string_list(buf, bch_cache_modes + 1);
205+
ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
206206

207207
if (v < 0)
208208
return v;
@@ -224,7 +224,7 @@ STORE(__cached_dev)
224224
}
225225

226226
if (attr == &sysfs_attach) {
227-
if (parse_uuid(buf, dc->sb.set_uuid) < 16)
227+
if (bch_parse_uuid(buf, dc->sb.set_uuid) < 16)
228228
return -EINVAL;
229229

230230
list_for_each_entry(c, &bch_cache_sets, list) {
@@ -657,9 +657,9 @@ SHOW(__bch_cache)
657657
((size_t) ca->sb.nbuckets));
658658

659659
if (attr == &sysfs_cache_replacement_policy)
660-
return snprint_string_list(buf, PAGE_SIZE,
661-
cache_replacement_policies,
662-
CACHE_REPLACEMENT(&ca->sb));
660+
return bch_snprint_string_list(buf, PAGE_SIZE,
661+
cache_replacement_policies,
662+
CACHE_REPLACEMENT(&ca->sb));
663663

664664
if (attr == &sysfs_priority_stats) {
665665
int cmp(const void *l, const void *r)
@@ -747,7 +747,7 @@ STORE(__bch_cache)
747747
}
748748

749749
if (attr == &sysfs_cache_replacement_policy) {
750-
ssize_t v = read_string_list(buf, cache_replacement_policies);
750+
ssize_t v = bch_read_string_list(buf, cache_replacement_policies);
751751

752752
if (v < 0)
753753
return v;

‎drivers/md/bcache/sysfs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ do { \
6262
#define sysfs_hprint(file, val) \
6363
do { \
6464
if (attr == &sysfs_ ## file) { \
65-
ssize_t ret = hprint(buf, val); \
65+
ssize_t ret = bch_hprint(buf, val); \
6666
strcat(buf, "\n"); \
6767
return ret + 1; \
6868
} \

0 commit comments

Comments
 (0)