Permalink
Browse files

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>
  • Loading branch information...
1 parent 0b6ef41 commit 169ef1cf6171d35550fef85645b83b960e241cff Kent Overstreet committed with axboe Mar 28, 2013
@@ -1033,7 +1033,7 @@ static inline void bkey_init(struct bkey *k)
* jset: The checksum is _always_ the first 8 bytes of these structs
*/
#define csum_set(i) \
- crc64(((void *) (i)) + sizeof(uint64_t), \
+ bch_crc64(((void *) (i)) + sizeof(uint64_t), \
((void *) end(i)) - (((void *) (i)) + sizeof(uint64_t)))
/* Error handling macros */
View
@@ -1026,7 +1026,7 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter,
if (!start) {
spin_lock(&b->c->sort_time_lock);
- time_stats_update(&b->c->sort_time, start_time);
+ bch_time_stats_update(&b->c->sort_time, start_time);
spin_unlock(&b->c->sort_time_lock);
}
}
@@ -1076,7 +1076,7 @@ void bch_btree_sort_into(struct btree *b, struct btree *new)
btree_mergesort(b, new->sets->data, &iter, false, true);
spin_lock(&b->c->sort_time_lock);
- time_stats_update(&b->c->sort_time, start_time);
+ bch_time_stats_update(&b->c->sort_time, start_time);
spin_unlock(&b->c->sort_time_lock);
bkey_copy_key(&new->key, &b->key);
View
@@ -129,7 +129,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
uint64_t crc = b->key.ptr[0];
void *data = (void *) i + 8, *end = end(i);
- crc = crc64_update(crc, data, end - data);
+ crc = bch_crc64_update(crc, data, end - data);
return crc ^ 0xffffffffffffffff;
}
@@ -231,7 +231,7 @@ void bch_btree_read_done(struct closure *cl)
mutex_unlock(&b->c->fill_lock);
spin_lock(&b->c->btree_read_time_lock);
- time_stats_update(&b->c->btree_read_time, b->io_start_time);
+ bch_time_stats_update(&b->c->btree_read_time, b->io_start_time);
spin_unlock(&b->c->btree_read_time_lock);
smp_wmb(); /* read_done is our write lock */
@@ -259,7 +259,7 @@ void bch_btree_read(struct btree *b)
b->bio->bi_rw = REQ_META|READ_SYNC;
b->bio->bi_size = KEY_SIZE(&b->key) << 9;
- bio_map(b->bio, b->sets[0].data);
+ bch_bio_map(b->bio, b->sets[0].data);
pr_debug("%s", pbtree(b));
trace_bcache_btree_read(b->bio);
@@ -327,12 +327,12 @@ static void do_btree_write(struct btree *b)
btree_bio_init(b);
b->bio->bi_rw = REQ_META|WRITE_SYNC;
b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c);
- bio_map(b->bio, i);
+ bch_bio_map(b->bio, i);
bkey_copy(&k.key, &b->key);
SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i));
- if (!bio_alloc_pages(b->bio, GFP_NOIO)) {
+ if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) {
int j;
struct bio_vec *bv;
void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
@@ -347,7 +347,7 @@ static void do_btree_write(struct btree *b)
continue_at(cl, btree_write_done, NULL);
} else {
b->bio->bi_vcnt = 0;
- bio_map(b->bio, i);
+ bch_bio_map(b->bio, i);
trace_bcache_btree_write(b->bio);
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,
void bch_cannibalize_unlock(struct cache_set *c, struct closure *cl)
{
if (c->try_harder == cl) {
- time_stats_update(&c->try_harder_time, c->try_harder_start);
+ bch_time_stats_update(&c->try_harder_time, c->try_harder_start);
c->try_harder = NULL;
__closure_wake_up(&c->try_wait);
}
@@ -1536,7 +1536,7 @@ static void bch_btree_gc(struct closure *cl)
available = bch_btree_gc_finish(c);
- time_stats_update(&c->btree_gc_time, start_time);
+ bch_time_stats_update(&c->btree_gc_time, start_time);
stats.key_bytes *= sizeof(uint64_t);
stats.dirty <<= 9;
@@ -2007,7 +2007,7 @@ static int btree_split(struct btree *b, struct btree_op *op)
rw_unlock(true, n1);
btree_node_free(b, op);
- time_stats_update(&b->c->btree_split_time, start_time);
+ bch_time_stats_update(&b->c->btree_split_time, start_time);
return 0;
err_free2:
@@ -200,7 +200,7 @@ void bch_data_verify(struct search *s)
if (!check)
return;
- if (bio_alloc_pages(check, GFP_NOIO))
+ if (bch_bio_alloc_pages(check, GFP_NOIO))
goto out_put;
check->bi_rw = READ_SYNC;
@@ -54,7 +54,7 @@ reread: left = ca->sb.bucket_size - offset;
bio->bi_end_io = journal_read_endio;
bio->bi_private = &op->cl;
- bio_map(bio, data);
+ bch_bio_map(bio, data);
closure_bio_submit(bio, &op->cl, ca);
closure_sync(&op->cl);
@@ -621,7 +621,7 @@ static void journal_write_unlocked(struct closure *cl)
bio->bi_end_io = journal_write_endio;
bio->bi_private = w;
- bio_map(bio, w->data);
+ bch_bio_map(bio, w->data);
trace_bcache_journal_write(bio);
bio_list_add(&list, bio);
@@ -85,7 +85,7 @@ static void moving_init(struct moving_io *io)
PAGE_SECTORS);
bio->bi_private = &io->s.cl;
bio->bi_io_vec = bio->bi_inline_vecs;
- bio_map(bio, NULL);
+ bch_bio_map(bio, NULL);
}
static void write_moving(struct closure *cl)
@@ -159,7 +159,7 @@ static void read_moving(struct closure *cl)
bio->bi_rw = READ;
bio->bi_end_io = read_moving_endio;
- if (bio_alloc_pages(bio, GFP_KERNEL))
+ if (bch_bio_alloc_pages(bio, GFP_KERNEL))
goto err;
pr_debug("%s", pkey(&w->key));
@@ -58,8 +58,8 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
char __user *buf, size_t nbytes, loff_t *ppos)
{
char tmp[1024];
- int len = snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes,
- cgroup_to_bcache(cgrp)->cache_mode + 1);
+ int len = bch_snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes,
+ cgroup_to_bcache(cgrp)->cache_mode + 1);
if (len < 0)
return len;
@@ -70,7 +70,7 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
static int cache_mode_write(struct cgroup *cgrp, struct cftype *cft,
const char *buf)
{
- int v = read_string_list(buf, bch_cache_modes);
+ int v = bch_read_string_list(buf, bch_cache_modes);
if (v < 0)
return v;
@@ -205,7 +205,7 @@ static void bio_csum(struct bio *bio, struct bkey *k)
bio_for_each_segment(bv, bio, i) {
void *d = kmap(bv->bv_page) + bv->bv_offset;
- csum = crc64_update(csum, d, bv->bv_len);
+ csum = bch_crc64_update(csum, d, bv->bv_len);
kunmap(bv->bv_page);
}
@@ -835,7 +835,7 @@ static void request_read_done(struct closure *cl)
s->op.cache_bio->bi_sector = s->cache_miss->bi_sector;
s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev;
s->op.cache_bio->bi_size = s->cache_bio_sectors << 9;
- bio_map(s->op.cache_bio, NULL);
+ bch_bio_map(s->op.cache_bio, NULL);
src = bio_iovec(s->op.cache_bio);
dst = bio_iovec(s->cache_miss);
@@ -962,8 +962,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
if (!bch_btree_insert_check_key(b, &s->op, s->op.cache_bio))
goto out_put;
- bio_map(s->op.cache_bio, NULL);
- if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
+ bch_bio_map(s->op.cache_bio, NULL);
+ if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
goto out_put;
s->cache_miss = miss;
View
@@ -142,7 +142,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
goto err;
err = "Bad UUID";
- if (is_zero(sb->uuid, 16))
+ if (bch_is_zero(sb->uuid, 16))
goto err;
err = "Unsupported superblock version";
@@ -170,7 +170,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
goto out;
err = "Bad UUID";
- if (is_zero(sb->set_uuid, 16))
+ if (bch_is_zero(sb->set_uuid, 16))
goto err;
err = "Bad cache device number in set";
@@ -218,7 +218,7 @@ static void __write_super(struct cache_sb *sb, struct bio *bio)
bio->bi_sector = SB_SECTOR;
bio->bi_rw = REQ_SYNC|REQ_META;
bio->bi_size = SB_SIZE;
- bio_map(bio, NULL);
+ bch_bio_map(bio, NULL);
out->offset = cpu_to_le64(sb->offset);
out->version = cpu_to_le64(sb->version);
@@ -332,7 +332,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
bio->bi_end_io = uuid_endio;
bio->bi_private = cl;
- bio_map(bio, c->uuids);
+ bch_bio_map(bio, c->uuids);
bch_submit_bbio(bio, c, k, i);
@@ -344,7 +344,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
pkey(&c->uuid_bucket));
for (u = c->uuids; u < c->uuids + c->nr_uuids; u++)
- if (!is_zero(u->uuid, 16))
+ if (!bch_is_zero(u->uuid, 16))
pr_debug("Slot %zi: %pU: %s: 1st: %u last: %u inv: %u",
u - c->uuids, u->uuid, u->label,
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)
bio->bi_end_io = prio_endio;
bio->bi_private = ca;
- bio_map(bio, ca->disk_buckets);
+ bch_bio_map(bio, ca->disk_buckets);
closure_bio_submit(bio, &ca->prio, ca);
closure_sync(cl);
@@ -538,7 +538,7 @@ void bch_prio_write(struct cache *ca)
p->next_bucket = ca->prio_buckets[i + 1];
p->magic = pset_magic(ca);
- p->csum = crc64(&p->magic, bucket_bytes(ca) - 8);
+ p->csum = bch_crc64(&p->magic, bucket_bytes(ca) - 8);
bucket = bch_bucket_alloc(ca, WATERMARK_PRIO, &cl);
BUG_ON(bucket == -1);
@@ -585,7 +585,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
prio_io(ca, bucket, READ_SYNC);
- if (p->csum != crc64(&p->magic, bucket_bytes(ca) - 8))
+ if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
pr_warn("bad csum reading priorities");
if (p->magic != pset_magic(ca))
@@ -898,7 +898,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
sysfs_remove_file(&dc->kobj, &sysfs_attach);
*/
- if (is_zero(u->uuid, 16)) {
+ if (bch_is_zero(u->uuid, 16)) {
struct closure cl;
closure_init_stack(&cl);
View
@@ -105,9 +105,9 @@ SHOW(__bch_cached_dev)
#define var(stat) (dc->stat)
if (attr == &sysfs_cache_mode)
- return snprint_string_list(buf, PAGE_SIZE,
- bch_cache_modes + 1,
- BDEV_CACHE_MODE(&dc->sb));
+ return bch_snprint_string_list(buf, PAGE_SIZE,
+ bch_cache_modes + 1,
+ BDEV_CACHE_MODE(&dc->sb));
sysfs_printf(data_csum, "%i", dc->disk.data_csum);
var_printf(verify, "%i");
@@ -126,10 +126,10 @@ SHOW(__bch_cached_dev)
char dirty[20];
char derivative[20];
char target[20];
- hprint(dirty,
+ bch_hprint(dirty,
atomic_long_read(&dc->disk.sectors_dirty) << 9);
- hprint(derivative, dc->writeback_rate_derivative << 9);
- hprint(target, dc->writeback_rate_target << 9);
+ bch_hprint(derivative, dc->writeback_rate_derivative << 9);
+ bch_hprint(target, dc->writeback_rate_target << 9);
return sprintf(buf,
"rate:\t\t%u\n"
@@ -202,7 +202,7 @@ STORE(__cached_dev)
bch_cached_dev_run(dc);
if (attr == &sysfs_cache_mode) {
- ssize_t v = read_string_list(buf, bch_cache_modes + 1);
+ ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
if (v < 0)
return v;
@@ -224,7 +224,7 @@ STORE(__cached_dev)
}
if (attr == &sysfs_attach) {
- if (parse_uuid(buf, dc->sb.set_uuid) < 16)
+ if (bch_parse_uuid(buf, dc->sb.set_uuid) < 16)
return -EINVAL;
list_for_each_entry(c, &bch_cache_sets, list) {
@@ -657,9 +657,9 @@ SHOW(__bch_cache)
((size_t) ca->sb.nbuckets));
if (attr == &sysfs_cache_replacement_policy)
- return snprint_string_list(buf, PAGE_SIZE,
- cache_replacement_policies,
- CACHE_REPLACEMENT(&ca->sb));
+ return bch_snprint_string_list(buf, PAGE_SIZE,
+ cache_replacement_policies,
+ CACHE_REPLACEMENT(&ca->sb));
if (attr == &sysfs_priority_stats) {
int cmp(const void *l, const void *r)
@@ -747,7 +747,7 @@ STORE(__bch_cache)
}
if (attr == &sysfs_cache_replacement_policy) {
- ssize_t v = read_string_list(buf, cache_replacement_policies);
+ ssize_t v = bch_read_string_list(buf, cache_replacement_policies);
if (v < 0)
return v;
@@ -62,7 +62,7 @@ do { \
#define sysfs_hprint(file, val) \
do { \
if (attr == &sysfs_ ## file) { \
- ssize_t ret = hprint(buf, val); \
+ ssize_t ret = bch_hprint(buf, val); \
strcat(buf, "\n"); \
return ret + 1; \
} \
Oops, something went wrong.

0 comments on commit 169ef1c

Please sign in to comment.