diff options
author | Kent Overstreet <koverstreet@google.com> | 2013-03-25 14:46:44 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2013-03-25 15:06:13 -0400 |
commit | b1a67b0f4c747ca10c96ebb24f04e2a74b3c298d (patch) | |
tree | 32ff70d72673de4e99ae3b8c517540ccbe6a547f | |
parent | 07e86ccb543bb1e748f32d6f0f18913d3f58d988 (diff) |
bcache: Style/checkpatch fixes
Took out some nested functions, and fixed some more checkpatch
complaints.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
Cc: linux-bcache@vger.kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | drivers/md/bcache/alloc.c | 22 | ||||
-rw-r--r-- | drivers/md/bcache/bcache.h | 10 | ||||
-rw-r--r-- | drivers/md/bcache/bset.c | 9 | ||||
-rw-r--r-- | drivers/md/bcache/btree.c | 4 | ||||
-rw-r--r-- | drivers/md/bcache/debug.c | 8 | ||||
-rw-r--r-- | drivers/md/bcache/journal.c | 8 | ||||
-rw-r--r-- | drivers/md/bcache/movinggc.c | 24 | ||||
-rw-r--r-- | drivers/md/bcache/request.c | 12 | ||||
-rw-r--r-- | drivers/md/bcache/stats.c | 3 | ||||
-rw-r--r-- | drivers/md/bcache/super.c | 7 |
10 files changed, 51 insertions, 56 deletions
diff --git a/drivers/md/bcache/alloc.c b/drivers/md/bcache/alloc.c index ed18115e078e..2879487d036a 100644 --- a/drivers/md/bcache/alloc.c +++ b/drivers/md/bcache/alloc.c | |||
@@ -229,24 +229,14 @@ static void invalidate_one_bucket(struct cache *ca, struct bucket *b) | |||
229 | fifo_push(&ca->free_inc, b - ca->buckets); | 229 | fifo_push(&ca->free_inc, b - ca->buckets); |
230 | } | 230 | } |
231 | 231 | ||
232 | static void invalidate_buckets_lru(struct cache *ca) | 232 | #define bucket_prio(b) \ |
233 | { | 233 | (((unsigned) (b->prio - ca->set->min_prio)) * GC_SECTORS_USED(b)) |
234 | unsigned bucket_prio(struct bucket *b) | ||
235 | { | ||
236 | return ((unsigned) (b->prio - ca->set->min_prio)) * | ||
237 | GC_SECTORS_USED(b); | ||
238 | } | ||
239 | |||
240 | bool bucket_max_cmp(struct bucket *l, struct bucket *r) | ||
241 | { | ||
242 | return bucket_prio(l) < bucket_prio(r); | ||
243 | } | ||
244 | 234 | ||
245 | bool bucket_min_cmp(struct bucket *l, struct bucket *r) | 235 | #define bucket_max_cmp(l, r) (bucket_prio(l) < bucket_prio(r)) |
246 | { | 236 | #define bucket_min_cmp(l, r) (bucket_prio(l) > bucket_prio(r)) |
247 | return bucket_prio(l) > bucket_prio(r); | ||
248 | } | ||
249 | 237 | ||
238 | static void invalidate_buckets_lru(struct cache *ca) | ||
239 | { | ||
250 | struct bucket *b; | 240 | struct bucket *b; |
251 | ssize_t i; | 241 | ssize_t i; |
252 | 242 | ||
diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h index d01a553f63f3..b2846e70149b 100644 --- a/drivers/md/bcache/bcache.h +++ b/drivers/md/bcache/bcache.h | |||
@@ -644,8 +644,8 @@ struct gc_stat { | |||
644 | * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e. | 644 | * we'll continue to run normally for awhile with CACHE_SET_STOPPING set (i.e. |
645 | * flushing dirty data). | 645 | * flushing dirty data). |
646 | * | 646 | * |
647 | * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down the | 647 | * CACHE_SET_STOPPING_2 gets set at the last phase, when it's time to shut down |
648 | * allocation thread. | 648 | * the allocation thread. |
649 | */ | 649 | */ |
650 | #define CACHE_SET_UNREGISTERING 0 | 650 | #define CACHE_SET_UNREGISTERING 0 |
651 | #define CACHE_SET_STOPPING 1 | 651 | #define CACHE_SET_STOPPING 1 |
@@ -1012,11 +1012,11 @@ static inline struct bucket *PTR_BUCKET(struct cache_set *c, | |||
1012 | * searches - it told you where a key started. It's not used anymore, | 1012 | * searches - it told you where a key started. It's not used anymore, |
1013 | * and can probably be safely dropped. | 1013 | * and can probably be safely dropped. |
1014 | */ | 1014 | */ |
1015 | #define KEY(dev, sector, len) (struct bkey) \ | 1015 | #define KEY(dev, sector, len) \ |
1016 | { \ | 1016 | ((struct bkey) { \ |
1017 | .high = (1ULL << 63) | ((uint64_t) (len) << 20) | (dev), \ | 1017 | .high = (1ULL << 63) | ((uint64_t) (len) << 20) | (dev), \ |
1018 | .low = (sector) \ | 1018 | .low = (sector) \ |
1019 | } | 1019 | }) |
1020 | 1020 | ||
1021 | static inline void bkey_init(struct bkey *k) | 1021 | static inline void bkey_init(struct bkey *k) |
1022 | { | 1022 | { |
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c index 79fe1f0190f7..4dc9cb4efacb 100644 --- a/drivers/md/bcache/bset.c +++ b/drivers/md/bcache/bset.c | |||
@@ -161,9 +161,9 @@ bool bch_ptr_bad(struct btree *b, const struct bkey *k) | |||
161 | #ifdef CONFIG_BCACHE_EDEBUG | 161 | #ifdef CONFIG_BCACHE_EDEBUG |
162 | bug: | 162 | bug: |
163 | mutex_unlock(&b->c->bucket_lock); | 163 | mutex_unlock(&b->c->bucket_lock); |
164 | btree_bug(b, "inconsistent pointer %s: bucket %zu pin %i " | 164 | btree_bug(b, |
165 | "prio %i gen %i last_gc %i mark %llu gc_gen %i", pkey(k), | 165 | "inconsistent pointer %s: bucket %zu pin %i prio %i gen %i last_gc %i mark %llu gc_gen %i", |
166 | PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin), | 166 | pkey(k), PTR_BUCKET_NR(b->c, k, i), atomic_read(&g->pin), |
167 | g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen); | 167 | g->prio, g->gen, g->last_gc, GC_MARK(g), g->gc_gen); |
168 | return true; | 168 | return true; |
169 | #endif | 169 | #endif |
@@ -1049,7 +1049,8 @@ void bch_btree_sort_partial(struct btree *b, unsigned start) | |||
1049 | for (i = start; i <= b->nsets; i++) | 1049 | for (i = start; i <= b->nsets; i++) |
1050 | keys += b->sets[i].data->keys; | 1050 | keys += b->sets[i].data->keys; |
1051 | 1051 | ||
1052 | order = roundup_pow_of_two(__set_bytes(b->sets->data, keys)) / PAGE_SIZE; | 1052 | order = roundup_pow_of_two(__set_bytes(b->sets->data, |
1053 | keys)) / PAGE_SIZE; | ||
1053 | if (order) | 1054 | if (order) |
1054 | order = ilog2(order); | 1055 | order = ilog2(order); |
1055 | } | 1056 | } |
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index af9ea4a96330..24b678059091 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c | |||
@@ -1021,8 +1021,8 @@ retry: | |||
1021 | goto err_free; | 1021 | goto err_free; |
1022 | 1022 | ||
1023 | if (!b) { | 1023 | if (!b) { |
1024 | cache_bug(c, "Tried to allocate bucket" | 1024 | cache_bug(c, |
1025 | " that was in btree cache"); | 1025 | "Tried to allocate bucket that was in btree cache"); |
1026 | __bkey_put(c, &k.key); | 1026 | __bkey_put(c, &k.key); |
1027 | goto retry; | 1027 | goto retry; |
1028 | } | 1028 | } |
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c index 4b37ef2b80e5..141a5cac11ad 100644 --- a/drivers/md/bcache/debug.c +++ b/drivers/md/bcache/debug.c | |||
@@ -217,8 +217,8 @@ void bch_data_verify(struct search *s) | |||
217 | if (memcmp(p1 + bv->bv_offset, | 217 | if (memcmp(p1 + bv->bv_offset, |
218 | p2 + bv->bv_offset, | 218 | p2 + bv->bv_offset, |
219 | bv->bv_len)) | 219 | bv->bv_len)) |
220 | printk(KERN_ERR "bcache (%s): verify failed" | 220 | printk(KERN_ERR |
221 | " at sector %llu\n", | 221 | "bcache (%s): verify failed at sector %llu\n", |
222 | bdevname(dc->bdev, name), | 222 | bdevname(dc->bdev, name), |
223 | (uint64_t) s->orig_bio->bi_sector); | 223 | (uint64_t) s->orig_bio->bi_sector); |
224 | 224 | ||
@@ -525,8 +525,8 @@ static ssize_t btree_fuzz(struct kobject *k, struct kobj_attribute *a, | |||
525 | k = bkey_next(k), l = bkey_next(l)) | 525 | k = bkey_next(k), l = bkey_next(l)) |
526 | if (bkey_cmp(k, l) || | 526 | if (bkey_cmp(k, l) || |
527 | KEY_SIZE(k) != KEY_SIZE(l)) | 527 | KEY_SIZE(k) != KEY_SIZE(l)) |
528 | pr_err("key %zi differs: %s " | 528 | pr_err("key %zi differs: %s != %s", |
529 | "!= %s", (uint64_t *) k - i->d, | 529 | (uint64_t *) k - i->d, |
530 | pkey(k), pkey(l)); | 530 | pkey(k), pkey(l)); |
531 | 531 | ||
532 | for (j = 0; j < 3; j++) { | 532 | for (j = 0; j < 3; j++) { |
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c index c871ffaabbb0..21fd1010cf5d 100644 --- a/drivers/md/bcache/journal.c +++ b/drivers/md/bcache/journal.c | |||
@@ -293,9 +293,9 @@ int bch_journal_replay(struct cache_set *s, struct list_head *list, | |||
293 | BUG_ON(i->pin && atomic_read(i->pin) != 1); | 293 | BUG_ON(i->pin && atomic_read(i->pin) != 1); |
294 | 294 | ||
295 | if (n != i->j.seq) | 295 | if (n != i->j.seq) |
296 | pr_err("journal entries %llu-%llu " | 296 | pr_err( |
297 | "missing! (replaying %llu-%llu)\n", | 297 | "journal entries %llu-%llu missing! (replaying %llu-%llu)\n", |
298 | n, i->j.seq - 1, start, end); | 298 | n, i->j.seq - 1, start, end); |
299 | 299 | ||
300 | for (k = i->j.start; | 300 | for (k = i->j.start; |
301 | k < end(&i->j); | 301 | k < end(&i->j); |
@@ -439,7 +439,7 @@ static void do_journal_discard(struct cache *ca) | |||
439 | 439 | ||
440 | bio_init(bio); | 440 | bio_init(bio); |
441 | bio->bi_sector = bucket_to_sector(ca->set, | 441 | bio->bi_sector = bucket_to_sector(ca->set, |
442 | ca->sb.d[ja->discard_idx]); | 442 | ca->sb.d[ja->discard_idx]); |
443 | bio->bi_bdev = ca->bdev; | 443 | bio->bi_bdev = ca->bdev; |
444 | bio->bi_rw = REQ_WRITE|REQ_DISCARD; | 444 | bio->bi_rw = REQ_WRITE|REQ_DISCARD; |
445 | bio->bi_max_vecs = 1; | 445 | bio->bi_max_vecs = 1; |
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c index c69fc92b02cf..e3ec0a550b00 100644 --- a/drivers/md/bcache/movinggc.c +++ b/drivers/md/bcache/movinggc.c | |||
@@ -183,6 +183,16 @@ err: if (!IS_ERR_OR_NULL(w->private)) | |||
183 | closure_return(cl); | 183 | closure_return(cl); |
184 | } | 184 | } |
185 | 185 | ||
186 | static bool bucket_cmp(struct bucket *l, struct bucket *r) | ||
187 | { | ||
188 | return GC_SECTORS_USED(l) < GC_SECTORS_USED(r); | ||
189 | } | ||
190 | |||
191 | static unsigned bucket_heap_top(struct cache *ca) | ||
192 | { | ||
193 | return GC_SECTORS_USED(heap_peek(&ca->heap)); | ||
194 | } | ||
195 | |||
186 | void bch_moving_gc(struct closure *cl) | 196 | void bch_moving_gc(struct closure *cl) |
187 | { | 197 | { |
188 | struct cache_set *c = container_of(cl, struct cache_set, gc.cl); | 198 | struct cache_set *c = container_of(cl, struct cache_set, gc.cl); |
@@ -190,16 +200,6 @@ void bch_moving_gc(struct closure *cl) | |||
190 | struct bucket *b; | 200 | struct bucket *b; |
191 | unsigned i; | 201 | unsigned i; |
192 | 202 | ||
193 | bool bucket_cmp(struct bucket *l, struct bucket *r) | ||
194 | { | ||
195 | return GC_SECTORS_USED(l) < GC_SECTORS_USED(r); | ||
196 | } | ||
197 | |||
198 | unsigned top(struct cache *ca) | ||
199 | { | ||
200 | return GC_SECTORS_USED(heap_peek(&ca->heap)); | ||
201 | } | ||
202 | |||
203 | if (!c->copy_gc_enabled) | 203 | if (!c->copy_gc_enabled) |
204 | closure_return(cl); | 204 | closure_return(cl); |
205 | 205 | ||
@@ -220,7 +220,7 @@ void bch_moving_gc(struct closure *cl) | |||
220 | sectors_to_move += GC_SECTORS_USED(b); | 220 | sectors_to_move += GC_SECTORS_USED(b); |
221 | heap_add(&ca->heap, b, bucket_cmp); | 221 | heap_add(&ca->heap, b, bucket_cmp); |
222 | } else if (bucket_cmp(b, heap_peek(&ca->heap))) { | 222 | } else if (bucket_cmp(b, heap_peek(&ca->heap))) { |
223 | sectors_to_move -= top(ca); | 223 | sectors_to_move -= bucket_heap_top(ca); |
224 | sectors_to_move += GC_SECTORS_USED(b); | 224 | sectors_to_move += GC_SECTORS_USED(b); |
225 | 225 | ||
226 | ca->heap.data[0] = b; | 226 | ca->heap.data[0] = b; |
@@ -233,7 +233,7 @@ void bch_moving_gc(struct closure *cl) | |||
233 | sectors_to_move -= GC_SECTORS_USED(b); | 233 | sectors_to_move -= GC_SECTORS_USED(b); |
234 | } | 234 | } |
235 | 235 | ||
236 | ca->gc_move_threshold = top(ca); | 236 | ca->gc_move_threshold = bucket_heap_top(ca); |
237 | 237 | ||
238 | pr_debug("threshold %u", ca->gc_move_threshold); | 238 | pr_debug("threshold %u", ca->gc_move_threshold); |
239 | } | 239 | } |
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 4f552de49aaa..dbda9646ef38 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c | |||
@@ -1117,11 +1117,13 @@ static void add_sequential(struct task_struct *t) | |||
1117 | t->sequential_io = 0; | 1117 | t->sequential_io = 0; |
1118 | } | 1118 | } |
1119 | 1119 | ||
1120 | static void check_should_skip(struct cached_dev *dc, struct search *s) | 1120 | static struct hlist_head *iohash(struct cached_dev *dc, uint64_t k) |
1121 | { | 1121 | { |
1122 | struct hlist_head *iohash(uint64_t k) | 1122 | return &dc->io_hash[hash_64(k, RECENT_IO_BITS)]; |
1123 | { return &dc->io_hash[hash_64(k, RECENT_IO_BITS)]; } | 1123 | } |
1124 | 1124 | ||
1125 | static void check_should_skip(struct cached_dev *dc, struct search *s) | ||
1126 | { | ||
1125 | struct cache_set *c = s->op.c; | 1127 | struct cache_set *c = s->op.c; |
1126 | struct bio *bio = &s->bio.bio; | 1128 | struct bio *bio = &s->bio.bio; |
1127 | 1129 | ||
@@ -1162,7 +1164,7 @@ static void check_should_skip(struct cached_dev *dc, struct search *s) | |||
1162 | 1164 | ||
1163 | spin_lock(&dc->io_lock); | 1165 | spin_lock(&dc->io_lock); |
1164 | 1166 | ||
1165 | hlist_for_each_entry(i, iohash(bio->bi_sector), hash) | 1167 | hlist_for_each_entry(i, iohash(dc, bio->bi_sector), hash) |
1166 | if (i->last == bio->bi_sector && | 1168 | if (i->last == bio->bi_sector && |
1167 | time_before(jiffies, i->jiffies)) | 1169 | time_before(jiffies, i->jiffies)) |
1168 | goto found; | 1170 | goto found; |
@@ -1180,7 +1182,7 @@ found: | |||
1180 | s->task->sequential_io = i->sequential; | 1182 | s->task->sequential_io = i->sequential; |
1181 | 1183 | ||
1182 | hlist_del(&i->hash); | 1184 | hlist_del(&i->hash); |
1183 | hlist_add_head(&i->hash, iohash(i->last)); | 1185 | hlist_add_head(&i->hash, iohash(dc, i->last)); |
1184 | list_move_tail(&i->lru, &dc->io_lru); | 1186 | list_move_tail(&i->lru, &dc->io_lru); |
1185 | 1187 | ||
1186 | spin_unlock(&dc->io_lock); | 1188 | spin_unlock(&dc->io_lock); |
diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index bf6cf9518c89..64e679449c2a 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c | |||
@@ -95,7 +95,8 @@ static KTYPE(bch_stats); | |||
95 | 95 | ||
96 | static void scale_accounting(unsigned long data); | 96 | static void scale_accounting(unsigned long data); |
97 | 97 | ||
98 | void bch_cache_accounting_init(struct cache_accounting *acc, struct closure *parent) | 98 | void bch_cache_accounting_init(struct cache_accounting *acc, |
99 | struct closure *parent) | ||
99 | { | 100 | { |
100 | kobject_init(&acc->total.kobj, &bch_stats_ktype); | 101 | kobject_init(&acc->total.kobj, &bch_stats_ktype); |
101 | kobject_init(&acc->five_minute.kobj, &bch_stats_ktype); | 102 | kobject_init(&acc->five_minute.kobj, &bch_stats_ktype); |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 7b8efc770871..484ae6c8f43a 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
@@ -526,7 +526,8 @@ void bch_prio_write(struct cache *ca) | |||
526 | for (i = prio_buckets(ca) - 1; i >= 0; --i) { | 526 | for (i = prio_buckets(ca) - 1; i >= 0; --i) { |
527 | long bucket; | 527 | long bucket; |
528 | struct prio_set *p = ca->disk_buckets; | 528 | struct prio_set *p = ca->disk_buckets; |
529 | struct bucket_disk *d = p->data, *end = d + prios_per_bucket(ca); | 529 | struct bucket_disk *d = p->data; |
530 | struct bucket_disk *end = d + prios_per_bucket(ca); | ||
530 | 531 | ||
531 | for (b = ca->buckets + i * prios_per_bucket(ca); | 532 | for (b = ca->buckets + i * prios_per_bucket(ca); |
532 | b < ca->buckets + ca->sb.nbuckets && d < end; | 533 | b < ca->buckets + ca->sb.nbuckets && d < end; |
@@ -865,8 +866,8 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c) | |||
865 | 866 | ||
866 | if (dc->sb.block_size < c->sb.block_size) { | 867 | if (dc->sb.block_size < c->sb.block_size) { |
867 | /* Will die */ | 868 | /* Will die */ |
868 | pr_err("Couldn't attach %s: block size " | 869 | pr_err("Couldn't attach %s: block size less than set's block size", |
869 | "less than set's block size", buf); | 870 | buf); |
870 | return -EINVAL; | 871 | return -EINVAL; |
871 | } | 872 | } |
872 | 873 | ||