aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2013-03-28 14:50:55 -0400
committerJens Axboe <axboe@kernel.dk>2013-03-28 14:50:55 -0400
commit169ef1cf6171d35550fef85645b83b960e241cff (patch)
tree61451e5477e992d5bdee0fc906f9db018afc1239 /drivers/md/bcache
parent0b6ef4164f50698eee536903d69d086add1a7889 (diff)
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>
Diffstat (limited to 'drivers/md/bcache')
-rw-r--r--drivers/md/bcache/bcache.h2
-rw-r--r--drivers/md/bcache/bset.c4
-rw-r--r--drivers/md/bcache/btree.c18
-rw-r--r--drivers/md/bcache/debug.c2
-rw-r--r--drivers/md/bcache/journal.c4
-rw-r--r--drivers/md/bcache/movinggc.c4
-rw-r--r--drivers/md/bcache/request.c14
-rw-r--r--drivers/md/bcache/super.c18
-rw-r--r--drivers/md/bcache/sysfs.c24
-rw-r--r--drivers/md/bcache/sysfs.h2
-rw-r--r--drivers/md/bcache/util.c38
-rw-r--r--drivers/md/bcache/util.h54
-rw-r--r--drivers/md/bcache/writeback.c6
13 files changed, 89 insertions, 101 deletions
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h
index b2846e70149b..f05723565f17 100644
--- a/drivers/md/bcache/bcache.h
+++ b/drivers/md/bcache/bcache.h
@@ -1033,7 +1033,7 @@ static inline void bkey_init(struct bkey *k)
1033 * jset: The checksum is _always_ the first 8 bytes of these structs 1033 * jset: The checksum is _always_ the first 8 bytes of these structs
1034 */ 1034 */
1035#define csum_set(i) \ 1035#define csum_set(i) \
1036 crc64(((void *) (i)) + sizeof(uint64_t), \ 1036 bch_crc64(((void *) (i)) + sizeof(uint64_t), \
1037 ((void *) end(i)) - (((void *) (i)) + sizeof(uint64_t))) 1037 ((void *) end(i)) - (((void *) (i)) + sizeof(uint64_t)))
1038 1038
1039/* Error handling macros */ 1039/* Error handling macros */
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
index 4dc9cb4efacb..0b33aac1f146 100644
--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -1026,7 +1026,7 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter,
1026 1026
1027 if (!start) { 1027 if (!start) {
1028 spin_lock(&b->c->sort_time_lock); 1028 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);
1030 spin_unlock(&b->c->sort_time_lock); 1030 spin_unlock(&b->c->sort_time_lock);
1031 } 1031 }
1032} 1032}
@@ -1076,7 +1076,7 @@ void bch_btree_sort_into(struct btree *b, struct btree *new)
1076 btree_mergesort(b, new->sets->data, &iter, false, true); 1076 btree_mergesort(b, new->sets->data, &iter, false, true);
1077 1077
1078 spin_lock(&b->c->sort_time_lock); 1078 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);
1080 spin_unlock(&b->c->sort_time_lock); 1080 spin_unlock(&b->c->sort_time_lock);
1081 1081
1082 bkey_copy_key(&new->key, &b->key); 1082 bkey_copy_key(&new->key, &b->key);
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index 24b678059091..f2b2c653c5a5 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -129,7 +129,7 @@ static uint64_t btree_csum_set(struct btree *b, struct bset *i)
129 uint64_t crc = b->key.ptr[0]; 129 uint64_t crc = b->key.ptr[0];
130 void *data = (void *) i + 8, *end = end(i); 130 void *data = (void *) i + 8, *end = end(i);
131 131
132 crc = crc64_update(crc, data, end - data); 132 crc = bch_crc64_update(crc, data, end - data);
133 return crc ^ 0xffffffffffffffff; 133 return crc ^ 0xffffffffffffffff;
134} 134}
135 135
@@ -231,7 +231,7 @@ out:
231 mutex_unlock(&b->c->fill_lock); 231 mutex_unlock(&b->c->fill_lock);
232 232
233 spin_lock(&b->c->btree_read_time_lock); 233 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);
235 spin_unlock(&b->c->btree_read_time_lock); 235 spin_unlock(&b->c->btree_read_time_lock);
236 236
237 smp_wmb(); /* read_done is our write lock */ 237 smp_wmb(); /* read_done is our write lock */
@@ -259,7 +259,7 @@ void bch_btree_read(struct btree *b)
259 b->bio->bi_rw = REQ_META|READ_SYNC; 259 b->bio->bi_rw = REQ_META|READ_SYNC;
260 b->bio->bi_size = KEY_SIZE(&b->key) << 9; 260 b->bio->bi_size = KEY_SIZE(&b->key) << 9;
261 261
262 bio_map(b->bio, b->sets[0].data); 262 bch_bio_map(b->bio, b->sets[0].data);
263 263
264 pr_debug("%s", pbtree(b)); 264 pr_debug("%s", pbtree(b));
265 trace_bcache_btree_read(b->bio); 265 trace_bcache_btree_read(b->bio);
@@ -327,12 +327,12 @@ static void do_btree_write(struct btree *b)
327 btree_bio_init(b); 327 btree_bio_init(b);
328 b->bio->bi_rw = REQ_META|WRITE_SYNC; 328 b->bio->bi_rw = REQ_META|WRITE_SYNC;
329 b->bio->bi_size = set_blocks(i, b->c) * block_bytes(b->c); 329 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);
331 331
332 bkey_copy(&k.key, &b->key); 332 bkey_copy(&k.key, &b->key);
333 SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i)); 333 SET_PTR_OFFSET(&k.key, 0, PTR_OFFSET(&k.key, 0) + bset_offset(b, i));
334 334
335 if (!bio_alloc_pages(b->bio, GFP_NOIO)) { 335 if (!bch_bio_alloc_pages(b->bio, GFP_NOIO)) {
336 int j; 336 int j;
337 struct bio_vec *bv; 337 struct bio_vec *bv;
338 void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1)); 338 void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
@@ -347,7 +347,7 @@ static void do_btree_write(struct btree *b)
347 continue_at(cl, btree_write_done, NULL); 347 continue_at(cl, btree_write_done, NULL);
348 } else { 348 } else {
349 b->bio->bi_vcnt = 0; 349 b->bio->bi_vcnt = 0;
350 bio_map(b->bio, i); 350 bch_bio_map(b->bio, i);
351 351
352 trace_bcache_btree_write(b->bio); 352 trace_bcache_btree_write(b->bio);
353 bch_submit_bbio(b->bio, b->c, &k.key, 0); 353 bch_submit_bbio(b->bio, b->c, &k.key, 0);
@@ -815,7 +815,7 @@ retry:
815void bch_cannibalize_unlock(struct cache_set *c, struct closure *cl) 815void bch_cannibalize_unlock(struct cache_set *c, struct closure *cl)
816{ 816{
817 if (c->try_harder == cl) { 817 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);
819 c->try_harder = NULL; 819 c->try_harder = NULL;
820 __closure_wake_up(&c->try_wait); 820 __closure_wake_up(&c->try_wait);
821 } 821 }
@@ -1536,7 +1536,7 @@ static void bch_btree_gc(struct closure *cl)
1536 1536
1537 available = bch_btree_gc_finish(c); 1537 available = bch_btree_gc_finish(c);
1538 1538
1539 time_stats_update(&c->btree_gc_time, start_time); 1539 bch_time_stats_update(&c->btree_gc_time, start_time);
1540 1540
1541 stats.key_bytes *= sizeof(uint64_t); 1541 stats.key_bytes *= sizeof(uint64_t);
1542 stats.dirty <<= 9; 1542 stats.dirty <<= 9;
@@ -2007,7 +2007,7 @@ static int btree_split(struct btree *b, struct btree_op *op)
2007 rw_unlock(true, n1); 2007 rw_unlock(true, n1);
2008 btree_node_free(b, op); 2008 btree_node_free(b, op);
2009 2009
2010 time_stats_update(&b->c->btree_split_time, start_time); 2010 bch_time_stats_update(&b->c->btree_split_time, start_time);
2011 2011
2012 return 0; 2012 return 0;
2013err_free2: 2013err_free2:
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 141a5cac11ad..732234d9ec04 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -200,7 +200,7 @@ void bch_data_verify(struct search *s)
200 if (!check) 200 if (!check)
201 return; 201 return;
202 202
203 if (bio_alloc_pages(check, GFP_NOIO)) 203 if (bch_bio_alloc_pages(check, GFP_NOIO))
204 goto out_put; 204 goto out_put;
205 205
206 check->bi_rw = READ_SYNC; 206 check->bi_rw = READ_SYNC;
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 21fd1010cf5d..b0a3d0577d13 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -54,7 +54,7 @@ reread: left = ca->sb.bucket_size - offset;
54 54
55 bio->bi_end_io = journal_read_endio; 55 bio->bi_end_io = journal_read_endio;
56 bio->bi_private = &op->cl; 56 bio->bi_private = &op->cl;
57 bio_map(bio, data); 57 bch_bio_map(bio, data);
58 58
59 closure_bio_submit(bio, &op->cl, ca); 59 closure_bio_submit(bio, &op->cl, ca);
60 closure_sync(&op->cl); 60 closure_sync(&op->cl);
@@ -621,7 +621,7 @@ static void journal_write_unlocked(struct closure *cl)
621 621
622 bio->bi_end_io = journal_write_endio; 622 bio->bi_end_io = journal_write_endio;
623 bio->bi_private = w; 623 bio->bi_private = w;
624 bio_map(bio, w->data); 624 bch_bio_map(bio, w->data);
625 625
626 trace_bcache_journal_write(bio); 626 trace_bcache_journal_write(bio);
627 bio_list_add(&list, bio); 627 bio_list_add(&list, bio);
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index e3ec0a550b00..8589512c972e 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -85,7 +85,7 @@ static void moving_init(struct moving_io *io)
85 PAGE_SECTORS); 85 PAGE_SECTORS);
86 bio->bi_private = &io->s.cl; 86 bio->bi_private = &io->s.cl;
87 bio->bi_io_vec = bio->bi_inline_vecs; 87 bio->bi_io_vec = bio->bi_inline_vecs;
88 bio_map(bio, NULL); 88 bch_bio_map(bio, NULL);
89} 89}
90 90
91static void write_moving(struct closure *cl) 91static void write_moving(struct closure *cl)
@@ -159,7 +159,7 @@ static void read_moving(struct closure *cl)
159 bio->bi_rw = READ; 159 bio->bi_rw = READ;
160 bio->bi_end_io = read_moving_endio; 160 bio->bi_end_io = read_moving_endio;
161 161
162 if (bio_alloc_pages(bio, GFP_KERNEL)) 162 if (bch_bio_alloc_pages(bio, GFP_KERNEL))
163 goto err; 163 goto err;
164 164
165 pr_debug("%s", pkey(&w->key)); 165 pr_debug("%s", pkey(&w->key));
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index dbda9646ef38..83731dc36f34 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -58,8 +58,8 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
58 char __user *buf, size_t nbytes, loff_t *ppos) 58 char __user *buf, size_t nbytes, loff_t *ppos)
59{ 59{
60 char tmp[1024]; 60 char tmp[1024];
61 int len = snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes, 61 int len = bch_snprint_string_list(tmp, PAGE_SIZE, bch_cache_modes,
62 cgroup_to_bcache(cgrp)->cache_mode + 1); 62 cgroup_to_bcache(cgrp)->cache_mode + 1);
63 63
64 if (len < 0) 64 if (len < 0)
65 return len; 65 return len;
@@ -70,7 +70,7 @@ static ssize_t cache_mode_read(struct cgroup *cgrp, struct cftype *cft,
70static int cache_mode_write(struct cgroup *cgrp, struct cftype *cft, 70static int cache_mode_write(struct cgroup *cgrp, struct cftype *cft,
71 const char *buf) 71 const char *buf)
72{ 72{
73 int v = read_string_list(buf, bch_cache_modes); 73 int v = bch_read_string_list(buf, bch_cache_modes);
74 if (v < 0) 74 if (v < 0)
75 return v; 75 return v;
76 76
@@ -205,7 +205,7 @@ static void bio_csum(struct bio *bio, struct bkey *k)
205 205
206 bio_for_each_segment(bv, bio, i) { 206 bio_for_each_segment(bv, bio, i) {
207 void *d = kmap(bv->bv_page) + bv->bv_offset; 207 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);
209 kunmap(bv->bv_page); 209 kunmap(bv->bv_page);
210 } 210 }
211 211
@@ -835,7 +835,7 @@ static void request_read_done(struct closure *cl)
835 s->op.cache_bio->bi_sector = s->cache_miss->bi_sector; 835 s->op.cache_bio->bi_sector = s->cache_miss->bi_sector;
836 s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev; 836 s->op.cache_bio->bi_bdev = s->cache_miss->bi_bdev;
837 s->op.cache_bio->bi_size = s->cache_bio_sectors << 9; 837 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);
839 839
840 src = bio_iovec(s->op.cache_bio); 840 src = bio_iovec(s->op.cache_bio);
841 dst = bio_iovec(s->cache_miss); 841 dst = bio_iovec(s->cache_miss);
@@ -962,8 +962,8 @@ static int cached_dev_cache_miss(struct btree *b, struct search *s,
962 if (!bch_btree_insert_check_key(b, &s->op, s->op.cache_bio)) 962 if (!bch_btree_insert_check_key(b, &s->op, s->op.cache_bio))
963 goto out_put; 963 goto out_put;
964 964
965 bio_map(s->op.cache_bio, NULL); 965 bch_bio_map(s->op.cache_bio, NULL);
966 if (bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO)) 966 if (bch_bio_alloc_pages(s->op.cache_bio, __GFP_NOWARN|GFP_NOIO))
967 goto out_put; 967 goto out_put;
968 968
969 s->cache_miss = miss; 969 s->cache_miss = miss;
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 484ae6c8f43a..f47ecb5cb318 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -142,7 +142,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
142 goto err; 142 goto err;
143 143
144 err = "Bad UUID"; 144 err = "Bad UUID";
145 if (is_zero(sb->uuid, 16)) 145 if (bch_is_zero(sb->uuid, 16))
146 goto err; 146 goto err;
147 147
148 err = "Unsupported superblock version"; 148 err = "Unsupported superblock version";
@@ -170,7 +170,7 @@ static const char *read_super(struct cache_sb *sb, struct block_device *bdev,
170 goto out; 170 goto out;
171 171
172 err = "Bad UUID"; 172 err = "Bad UUID";
173 if (is_zero(sb->set_uuid, 16)) 173 if (bch_is_zero(sb->set_uuid, 16))
174 goto err; 174 goto err;
175 175
176 err = "Bad cache device number in set"; 176 err = "Bad cache device number in set";
@@ -218,7 +218,7 @@ static void __write_super(struct cache_sb *sb, struct bio *bio)
218 bio->bi_sector = SB_SECTOR; 218 bio->bi_sector = SB_SECTOR;
219 bio->bi_rw = REQ_SYNC|REQ_META; 219 bio->bi_rw = REQ_SYNC|REQ_META;
220 bio->bi_size = SB_SIZE; 220 bio->bi_size = SB_SIZE;
221 bio_map(bio, NULL); 221 bch_bio_map(bio, NULL);
222 222
223 out->offset = cpu_to_le64(sb->offset); 223 out->offset = cpu_to_le64(sb->offset);
224 out->version = cpu_to_le64(sb->version); 224 out->version = cpu_to_le64(sb->version);
@@ -332,7 +332,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
332 332
333 bio->bi_end_io = uuid_endio; 333 bio->bi_end_io = uuid_endio;
334 bio->bi_private = cl; 334 bio->bi_private = cl;
335 bio_map(bio, c->uuids); 335 bch_bio_map(bio, c->uuids);
336 336
337 bch_submit_bbio(bio, c, k, i); 337 bch_submit_bbio(bio, c, k, i);
338 338
@@ -344,7 +344,7 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
344 pkey(&c->uuid_bucket)); 344 pkey(&c->uuid_bucket));
345 345
346 for (u = c->uuids; u < c->uuids + c->nr_uuids; u++) 346 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))
348 pr_debug("Slot %zi: %pU: %s: 1st: %u last: %u inv: %u", 348 pr_debug("Slot %zi: %pU: %s: 1st: %u last: %u inv: %u",
349 u - c->uuids, u->uuid, u->label, 349 u - c->uuids, u->uuid, u->label,
350 u->first_reg, u->last_reg, u->invalidated); 350 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)
491 491
492 bio->bi_end_io = prio_endio; 492 bio->bi_end_io = prio_endio;
493 bio->bi_private = ca; 493 bio->bi_private = ca;
494 bio_map(bio, ca->disk_buckets); 494 bch_bio_map(bio, ca->disk_buckets);
495 495
496 closure_bio_submit(bio, &ca->prio, ca); 496 closure_bio_submit(bio, &ca->prio, ca);
497 closure_sync(cl); 497 closure_sync(cl);
@@ -538,7 +538,7 @@ void bch_prio_write(struct cache *ca)
538 538
539 p->next_bucket = ca->prio_buckets[i + 1]; 539 p->next_bucket = ca->prio_buckets[i + 1];
540 p->magic = pset_magic(ca); 540 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);
542 542
543 bucket = bch_bucket_alloc(ca, WATERMARK_PRIO, &cl); 543 bucket = bch_bucket_alloc(ca, WATERMARK_PRIO, &cl);
544 BUG_ON(bucket == -1); 544 BUG_ON(bucket == -1);
@@ -585,7 +585,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
585 585
586 prio_io(ca, bucket, READ_SYNC); 586 prio_io(ca, bucket, READ_SYNC);
587 587
588 if (p->csum != crc64(&p->magic, bucket_bytes(ca) - 8)) 588 if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
589 pr_warn("bad csum reading priorities"); 589 pr_warn("bad csum reading priorities");
590 590
591 if (p->magic != pset_magic(ca)) 591 if (p->magic != pset_magic(ca))
@@ -898,7 +898,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c)
898 sysfs_remove_file(&dc->kobj, &sysfs_attach); 898 sysfs_remove_file(&dc->kobj, &sysfs_attach);
899 */ 899 */
900 900
901 if (is_zero(u->uuid, 16)) { 901 if (bch_is_zero(u->uuid, 16)) {
902 struct closure cl; 902 struct closure cl;
903 closure_init_stack(&cl); 903 closure_init_stack(&cl);
904 904
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 5c7e77073b1f..4d9cca47e4c6 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -105,9 +105,9 @@ SHOW(__bch_cached_dev)
105#define var(stat) (dc->stat) 105#define var(stat) (dc->stat)
106 106
107 if (attr == &sysfs_cache_mode) 107 if (attr == &sysfs_cache_mode)
108 return snprint_string_list(buf, PAGE_SIZE, 108 return bch_snprint_string_list(buf, PAGE_SIZE,
109 bch_cache_modes + 1, 109 bch_cache_modes + 1,
110 BDEV_CACHE_MODE(&dc->sb)); 110 BDEV_CACHE_MODE(&dc->sb));
111 111
112 sysfs_printf(data_csum, "%i", dc->disk.data_csum); 112 sysfs_printf(data_csum, "%i", dc->disk.data_csum);
113 var_printf(verify, "%i"); 113 var_printf(verify, "%i");
@@ -126,10 +126,10 @@ SHOW(__bch_cached_dev)
126 char dirty[20]; 126 char dirty[20];
127 char derivative[20]; 127 char derivative[20];
128 char target[20]; 128 char target[20];
129 hprint(dirty, 129 bch_hprint(dirty,
130 atomic_long_read(&dc->disk.sectors_dirty) << 9); 130 atomic_long_read(&dc->disk.sectors_dirty) << 9);
131 hprint(derivative, dc->writeback_rate_derivative << 9); 131 bch_hprint(derivative, dc->writeback_rate_derivative << 9);
132 hprint(target, dc->writeback_rate_target << 9); 132 bch_hprint(target, dc->writeback_rate_target << 9);
133 133
134 return sprintf(buf, 134 return sprintf(buf,
135 "rate:\t\t%u\n" 135 "rate:\t\t%u\n"
@@ -202,7 +202,7 @@ STORE(__cached_dev)
202 bch_cached_dev_run(dc); 202 bch_cached_dev_run(dc);
203 203
204 if (attr == &sysfs_cache_mode) { 204 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);
206 206
207 if (v < 0) 207 if (v < 0)
208 return v; 208 return v;
@@ -224,7 +224,7 @@ STORE(__cached_dev)
224 } 224 }
225 225
226 if (attr == &sysfs_attach) { 226 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)
228 return -EINVAL; 228 return -EINVAL;
229 229
230 list_for_each_entry(c, &bch_cache_sets, list) { 230 list_for_each_entry(c, &bch_cache_sets, list) {
@@ -657,9 +657,9 @@ SHOW(__bch_cache)
657 ((size_t) ca->sb.nbuckets)); 657 ((size_t) ca->sb.nbuckets));
658 658
659 if (attr == &sysfs_cache_replacement_policy) 659 if (attr == &sysfs_cache_replacement_policy)
660 return snprint_string_list(buf, PAGE_SIZE, 660 return bch_snprint_string_list(buf, PAGE_SIZE,
661 cache_replacement_policies, 661 cache_replacement_policies,
662 CACHE_REPLACEMENT(&ca->sb)); 662 CACHE_REPLACEMENT(&ca->sb));
663 663
664 if (attr == &sysfs_priority_stats) { 664 if (attr == &sysfs_priority_stats) {
665 int cmp(const void *l, const void *r) 665 int cmp(const void *l, const void *r)
@@ -747,7 +747,7 @@ STORE(__bch_cache)
747 } 747 }
748 748
749 if (attr == &sysfs_cache_replacement_policy) { 749 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);
751 751
752 if (v < 0) 752 if (v < 0)
753 return v; 753 return v;
diff --git a/drivers/md/bcache/sysfs.h b/drivers/md/bcache/sysfs.h
index 34e4ba1184fe..0526fe92a683 100644
--- a/drivers/md/bcache/sysfs.h
+++ b/drivers/md/bcache/sysfs.h
@@ -62,7 +62,7 @@ do { \
62#define sysfs_hprint(file, val) \ 62#define sysfs_hprint(file, val) \
63do { \ 63do { \
64 if (attr == &sysfs_ ## file) { \ 64 if (attr == &sysfs_ ## file) { \
65 ssize_t ret = hprint(buf, val); \ 65 ssize_t ret = bch_hprint(buf, val); \
66 strcat(buf, "\n"); \ 66 strcat(buf, "\n"); \
67 return ret + 1; \ 67 return ret + 1; \
68 } \ 68 } \
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index dcec2e4f84ad..22324d8b2840 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -19,7 +19,7 @@
19#define simple_strtouint(c, end, base) simple_strtoul(c, end, base) 19#define simple_strtouint(c, end, base) simple_strtoul(c, end, base)
20 20
21#define STRTO_H(name, type) \ 21#define STRTO_H(name, type) \
22int name ## _h(const char *cp, type *res) \ 22int bch_ ## name ## _h(const char *cp, type *res) \
23{ \ 23{ \
24 int u = 0; \ 24 int u = 0; \
25 char *e; \ 25 char *e; \
@@ -67,14 +67,13 @@ int name ## _h(const char *cp, type *res) \
67 *res = i; \ 67 *res = i; \
68 return 0; \ 68 return 0; \
69} \ 69} \
70EXPORT_SYMBOL_GPL(name ## _h);
71 70
72STRTO_H(strtoint, int) 71STRTO_H(strtoint, int)
73STRTO_H(strtouint, unsigned int) 72STRTO_H(strtouint, unsigned int)
74STRTO_H(strtoll, long long) 73STRTO_H(strtoll, long long)
75STRTO_H(strtoull, unsigned long long) 74STRTO_H(strtoull, unsigned long long)
76 75
77ssize_t hprint(char *buf, int64_t v) 76ssize_t bch_hprint(char *buf, int64_t v)
78{ 77{
79 static const char units[] = "?kMGTPEZY"; 78 static const char units[] = "?kMGTPEZY";
80 char dec[3] = ""; 79 char dec[3] = "";
@@ -93,9 +92,8 @@ ssize_t hprint(char *buf, int64_t v)
93 92
94 return sprintf(buf, "%lli%s%c", v, dec, units[u]); 93 return sprintf(buf, "%lli%s%c", v, dec, units[u]);
95} 94}
96EXPORT_SYMBOL_GPL(hprint);
97 95
98ssize_t snprint_string_list(char *buf, size_t size, const char * const list[], 96ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[],
99 size_t selected) 97 size_t selected)
100{ 98{
101 char *out = buf; 99 char *out = buf;
@@ -108,9 +106,8 @@ ssize_t snprint_string_list(char *buf, size_t size, const char * const list[],
108 out[-1] = '\n'; 106 out[-1] = '\n';
109 return out - buf; 107 return out - buf;
110} 108}
111EXPORT_SYMBOL_GPL(snprint_string_list);
112 109
113ssize_t read_string_list(const char *buf, const char * const list[]) 110ssize_t bch_read_string_list(const char *buf, const char * const list[])
114{ 111{
115 size_t i; 112 size_t i;
116 char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL); 113 char *s, *d = kstrndup(buf, PAGE_SIZE - 1, GFP_KERNEL);
@@ -130,9 +127,8 @@ ssize_t read_string_list(const char *buf, const char * const list[])
130 127
131 return i; 128 return i;
132} 129}
133EXPORT_SYMBOL_GPL(read_string_list);
134 130
135bool is_zero(const char *p, size_t n) 131bool bch_is_zero(const char *p, size_t n)
136{ 132{
137 size_t i; 133 size_t i;
138 134
@@ -141,9 +137,8 @@ bool is_zero(const char *p, size_t n)
141 return false; 137 return false;
142 return true; 138 return true;
143} 139}
144EXPORT_SYMBOL_GPL(is_zero);
145 140
146int parse_uuid(const char *s, char *uuid) 141int bch_parse_uuid(const char *s, char *uuid)
147{ 142{
148 size_t i, j, x; 143 size_t i, j, x;
149 memset(uuid, 0, 16); 144 memset(uuid, 0, 16);
@@ -170,9 +165,8 @@ int parse_uuid(const char *s, char *uuid)
170 } 165 }
171 return i; 166 return i;
172} 167}
173EXPORT_SYMBOL_GPL(parse_uuid);
174 168
175void time_stats_update(struct time_stats *stats, uint64_t start_time) 169void bch_time_stats_update(struct time_stats *stats, uint64_t start_time)
176{ 170{
177 uint64_t now = local_clock(); 171 uint64_t now = local_clock();
178 uint64_t duration = time_after64(now, start_time) 172 uint64_t duration = time_after64(now, start_time)
@@ -195,9 +189,8 @@ void time_stats_update(struct time_stats *stats, uint64_t start_time)
195 189
196 stats->last = now ?: 1; 190 stats->last = now ?: 1;
197} 191}
198EXPORT_SYMBOL_GPL(time_stats_update);
199 192
200unsigned next_delay(struct ratelimit *d, uint64_t done) 193unsigned bch_next_delay(struct ratelimit *d, uint64_t done)
201{ 194{
202 uint64_t now = local_clock(); 195 uint64_t now = local_clock();
203 196
@@ -207,9 +200,8 @@ unsigned next_delay(struct ratelimit *d, uint64_t done)
207 ? div_u64(d->next - now, NSEC_PER_SEC / HZ) 200 ? div_u64(d->next - now, NSEC_PER_SEC / HZ)
208 : 0; 201 : 0;
209} 202}
210EXPORT_SYMBOL_GPL(next_delay);
211 203
212void bio_map(struct bio *bio, void *base) 204void bch_bio_map(struct bio *bio, void *base)
213{ 205{
214 size_t size = bio->bi_size; 206 size_t size = bio->bi_size;
215 struct bio_vec *bv = bio->bi_io_vec; 207 struct bio_vec *bv = bio->bi_io_vec;
@@ -235,9 +227,8 @@ start: bv->bv_len = min_t(size_t, PAGE_SIZE - bv->bv_offset,
235 size -= bv->bv_len; 227 size -= bv->bv_len;
236 } 228 }
237} 229}
238EXPORT_SYMBOL_GPL(bio_map);
239 230
240int bio_alloc_pages(struct bio *bio, gfp_t gfp) 231int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp)
241{ 232{
242 int i; 233 int i;
243 struct bio_vec *bv; 234 struct bio_vec *bv;
@@ -253,7 +244,6 @@ int bio_alloc_pages(struct bio *bio, gfp_t gfp)
253 244
254 return 0; 245 return 0;
255} 246}
256EXPORT_SYMBOL_GPL(bio_alloc_pages);
257 247
258/* 248/*
259 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any 249 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group (Any
@@ -365,7 +355,7 @@ static const uint64_t crc_table[256] = {
365 0x9AFCE626CE85B507 355 0x9AFCE626CE85B507
366}; 356};
367 357
368uint64_t crc64_update(uint64_t crc, const void *_data, size_t len) 358uint64_t bch_crc64_update(uint64_t crc, const void *_data, size_t len)
369{ 359{
370 const unsigned char *data = _data; 360 const unsigned char *data = _data;
371 361
@@ -376,14 +366,12 @@ uint64_t crc64_update(uint64_t crc, const void *_data, size_t len)
376 366
377 return crc; 367 return crc;
378} 368}
379EXPORT_SYMBOL(crc64_update);
380 369
381uint64_t crc64(const void *data, size_t len) 370uint64_t bch_crc64(const void *data, size_t len)
382{ 371{
383 uint64_t crc = 0xffffffffffffffff; 372 uint64_t crc = 0xffffffffffffffff;
384 373
385 crc = crc64_update(crc, data, len); 374 crc = bch_crc64_update(crc, data, len);
386 375
387 return crc ^ 0xffffffffffffffff; 376 return crc ^ 0xffffffffffffffff;
388} 377}
389EXPORT_SYMBOL(crc64);
diff --git a/drivers/md/bcache/util.h b/drivers/md/bcache/util.h
index 56705fdcc149..577393e38c3a 100644
--- a/drivers/md/bcache/util.h
+++ b/drivers/md/bcache/util.h
@@ -307,42 +307,42 @@ do { \
307#define ANYSINT_MAX(t) \ 307#define ANYSINT_MAX(t) \
308 ((((t) 1 << (sizeof(t) * 8 - 2)) - (t) 1) * (t) 2 + (t) 1) 308 ((((t) 1 << (sizeof(t) * 8 - 2)) - (t) 1) * (t) 2 + (t) 1)
309 309
310int strtoint_h(const char *, int *); 310int bch_strtoint_h(const char *, int *);
311int strtouint_h(const char *, unsigned int *); 311int bch_strtouint_h(const char *, unsigned int *);
312int strtoll_h(const char *, long long *); 312int bch_strtoll_h(const char *, long long *);
313int strtoull_h(const char *, unsigned long long *); 313int bch_strtoull_h(const char *, unsigned long long *);
314 314
315static inline int strtol_h(const char *cp, long *res) 315static inline int bch_strtol_h(const char *cp, long *res)
316{ 316{
317#if BITS_PER_LONG == 32 317#if BITS_PER_LONG == 32
318 return strtoint_h(cp, (int *) res); 318 return bch_strtoint_h(cp, (int *) res);
319#else 319#else
320 return strtoll_h(cp, (long long *) res); 320 return bch_strtoll_h(cp, (long long *) res);
321#endif 321#endif
322} 322}
323 323
324static inline int strtoul_h(const char *cp, long *res) 324static inline int bch_strtoul_h(const char *cp, long *res)
325{ 325{
326#if BITS_PER_LONG == 32 326#if BITS_PER_LONG == 32
327 return strtouint_h(cp, (unsigned int *) res); 327 return bch_strtouint_h(cp, (unsigned int *) res);
328#else 328#else
329 return strtoull_h(cp, (unsigned long long *) res); 329 return bch_strtoull_h(cp, (unsigned long long *) res);
330#endif 330#endif
331} 331}
332 332
333#define strtoi_h(cp, res) \ 333#define strtoi_h(cp, res) \
334 (__builtin_types_compatible_p(typeof(*res), int) \ 334 (__builtin_types_compatible_p(typeof(*res), int) \
335 ? strtoint_h(cp, (void *) res) \ 335 ? bch_strtoint_h(cp, (void *) res) \
336 : __builtin_types_compatible_p(typeof(*res), long) \ 336 : __builtin_types_compatible_p(typeof(*res), long) \
337 ? strtol_h(cp, (void *) res) \ 337 ? bch_strtol_h(cp, (void *) res) \
338 : __builtin_types_compatible_p(typeof(*res), long long) \ 338 : __builtin_types_compatible_p(typeof(*res), long long) \
339 ? strtoll_h(cp, (void *) res) \ 339 ? bch_strtoll_h(cp, (void *) res) \
340 : __builtin_types_compatible_p(typeof(*res), unsigned int) \ 340 : __builtin_types_compatible_p(typeof(*res), unsigned int) \
341 ? strtouint_h(cp, (void *) res) \ 341 ? bch_strtouint_h(cp, (void *) res) \
342 : __builtin_types_compatible_p(typeof(*res), unsigned long) \ 342 : __builtin_types_compatible_p(typeof(*res), unsigned long) \
343 ? strtoul_h(cp, (void *) res) \ 343 ? bch_strtoul_h(cp, (void *) res) \
344 : __builtin_types_compatible_p(typeof(*res), unsigned long long)\ 344 : __builtin_types_compatible_p(typeof(*res), unsigned long long)\
345 ? strtoull_h(cp, (void *) res) : -EINVAL) 345 ? bch_strtoull_h(cp, (void *) res) : -EINVAL)
346 346
347#define strtoul_safe(cp, var) \ 347#define strtoul_safe(cp, var) \
348({ \ 348({ \
@@ -379,15 +379,15 @@ static inline int strtoul_h(const char *cp, long *res)
379 __builtin_types_compatible_p(typeof(var), const char *) \ 379 __builtin_types_compatible_p(typeof(var), const char *) \
380 ? "%s\n" : "%i\n", var) 380 ? "%s\n" : "%i\n", var)
381 381
382ssize_t hprint(char *buf, int64_t v); 382ssize_t bch_hprint(char *buf, int64_t v);
383 383
384bool is_zero(const char *p, size_t n); 384bool bch_is_zero(const char *p, size_t n);
385int parse_uuid(const char *s, char *uuid); 385int bch_parse_uuid(const char *s, char *uuid);
386 386
387ssize_t snprint_string_list(char *buf, size_t size, const char * const list[], 387ssize_t bch_snprint_string_list(char *buf, size_t size, const char * const list[],
388 size_t selected); 388 size_t selected);
389 389
390ssize_t read_string_list(const char *buf, const char * const list[]); 390ssize_t bch_read_string_list(const char *buf, const char * const list[]);
391 391
392struct time_stats { 392struct time_stats {
393 /* 393 /*
@@ -400,7 +400,7 @@ struct time_stats {
400 uint64_t last; 400 uint64_t last;
401}; 401};
402 402
403void time_stats_update(struct time_stats *stats, uint64_t time); 403void bch_time_stats_update(struct time_stats *stats, uint64_t time);
404 404
405#define NSEC_PER_ns 1L 405#define NSEC_PER_ns 1L
406#define NSEC_PER_us NSEC_PER_USEC 406#define NSEC_PER_us NSEC_PER_USEC
@@ -462,7 +462,7 @@ static inline void ratelimit_reset(struct ratelimit *d)
462 d->next = local_clock(); 462 d->next = local_clock();
463} 463}
464 464
465unsigned next_delay(struct ratelimit *d, uint64_t done); 465unsigned bch_next_delay(struct ratelimit *d, uint64_t done);
466 466
467#define __DIV_SAFE(n, d, zero) \ 467#define __DIV_SAFE(n, d, zero) \
468({ \ 468({ \
@@ -568,9 +568,9 @@ static inline unsigned fract_exp_two(unsigned x, unsigned fract_bits)
568 568
569#define bio_end(bio) ((bio)->bi_sector + bio_sectors(bio)) 569#define bio_end(bio) ((bio)->bi_sector + bio_sectors(bio))
570 570
571void bio_map(struct bio *bio, void *base); 571void bch_bio_map(struct bio *bio, void *base);
572 572
573int bio_alloc_pages(struct bio *bio, gfp_t gfp); 573int bch_bio_alloc_pages(struct bio *bio, gfp_t gfp);
574 574
575static inline sector_t bdev_sectors(struct block_device *bdev) 575static inline sector_t bdev_sectors(struct block_device *bdev)
576{ 576{
@@ -583,7 +583,7 @@ do { \
583 bch_generic_make_request(bio, &(dev)->bio_split_hook); \ 583 bch_generic_make_request(bio, &(dev)->bio_split_hook); \
584} while (0) 584} while (0)
585 585
586uint64_t crc64_update(uint64_t, const void *, size_t); 586uint64_t bch_crc64_update(uint64_t, const void *, size_t);
587uint64_t crc64(const void *, size_t); 587uint64_t bch_crc64(const void *, size_t);
588 588
589#endif /* _BCACHE_UTIL_H */ 589#endif /* _BCACHE_UTIL_H */
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index a80ee5373fd8..93e7e31a4bd3 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -95,7 +95,7 @@ static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors)
95 !dc->writeback_percent) 95 !dc->writeback_percent)
96 return 0; 96 return 0;
97 97
98 return next_delay(&dc->writeback_rate, sectors * 10000000ULL); 98 return bch_next_delay(&dc->writeback_rate, sectors * 10000000ULL);
99} 99}
100 100
101/* Background writeback */ 101/* Background writeback */
@@ -118,7 +118,7 @@ static void dirty_init(struct keybuf_key *w)
118 bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS); 118 bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS);
119 bio->bi_private = w; 119 bio->bi_private = w;
120 bio->bi_io_vec = bio->bi_inline_vecs; 120 bio->bi_io_vec = bio->bi_inline_vecs;
121 bio_map(bio, NULL); 121 bch_bio_map(bio, NULL);
122} 122}
123 123
124static void refill_dirty(struct closure *cl) 124static void refill_dirty(struct closure *cl)
@@ -349,7 +349,7 @@ static void read_dirty(struct closure *cl)
349 io->bio.bi_rw = READ; 349 io->bio.bi_rw = READ;
350 io->bio.bi_end_io = read_dirty_endio; 350 io->bio.bi_end_io = read_dirty_endio;
351 351
352 if (bio_alloc_pages(&io->bio, GFP_KERNEL)) 352 if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL))
353 goto err_free; 353 goto err_free;
354 354
355 pr_debug("%s", pkey(&w->key)); 355 pr_debug("%s", pkey(&w->key));