while (!fifo_full(&ca->free_inc)) {
                size_t n;
+
                get_random_bytes(&n, sizeof(n));
 
                n %= (size_t) (ca->sb.nbuckets - ca->sb.first_bucket);
                         struct bkey *k, int n, bool wait)
 {
        int ret;
+
        mutex_lock(&c->bucket_lock);
        ret = __bch_bucket_alloc_set(c, reserve, k, n, wait);
        mutex_unlock(&c->bucket_lock);
 
        for (i = 0; i < MAX_OPEN_BUCKETS; i++) {
                struct open_bucket *b = kzalloc(sizeof(*b), GFP_KERNEL);
+
                if (!b)
                        return -ENOMEM;
 
 
 static inline uint8_t gen_after(uint8_t a, uint8_t b)
 {
        uint8_t r = a - b;
+
        return r > 128U ? 0 : r;
 }
 
 
                                       struct bkey_float *f)
 {
        const uint64_t *p = &k->low - (f->exponent >> 6);
+
        return shrd128(p[-1], p[0], f->exponent & 63) & BKEY_MANTISSA_MASK;
 }
 
                 * but a branch instruction is avoided.
                 */
                unsigned int p = n << 4;
+
                p &= ((int) (p - t->size)) >> 31;
 
                prefetch(&t->tree[p]);
                                          struct bset_tree *start)
 {
        struct bkey *ret = NULL;
+
        iter->size = ARRAY_SIZE(iter->data);
        iter->used = 0;
 
                         struct bset_sort_state *state)
 {
        uint64_t start_time = local_clock();
-
        struct btree_iter iter;
+
        bch_btree_iter_init(b, &iter, NULL);
 
        btree_mergesort(b, new->set->data, &iter, false, true);
 
 static void btree_node_read_endio(struct bio *bio)
 {
        struct closure *cl = bio->bi_private;
+
        closure_put(cl);
 }
 
                                      struct bkey *k, gfp_t gfp)
 {
        struct btree *b = kzalloc(sizeof(struct btree), gfp);
+
        if (!b)
                return NULL;
 
 {
        struct btree *b;
        struct closure cl;
+
        closure_init_stack(&cl);
 
        if (c->shrink.list.next)
                                                  struct btree_op *op)
 {
        struct btree *n = bch_btree_node_alloc(b->c, op, b->level, b->parent);
+
        if (!IS_ERR_OR_NULL(n)) {
                mutex_lock(&n->write_lock);
                bch_btree_sort_into(&b->keys, &n->keys, &b->c->sort);
 
        if (!RB_EMPTY_ROOT(&buf->keys)) {
                struct keybuf_key *w;
+
                w = RB_FIRST(&buf->keys, struct keybuf_key, node);
                buf->start      = START_KEY(&w->key);
 
 {
        bool ret = false;
        struct keybuf_key *p, *w, s;
+
        s.key = *start;
 
        if (bkey_cmp(end, &buf->start) <= 0 ||
 struct keybuf_key *bch_keybuf_next(struct keybuf *buf)
 {
        struct keybuf_key *w;
+
        spin_lock(&buf->lock);
 
        w = RB_FIRST(&buf->keys, struct keybuf_key, node);
 
 static int debug_seq_show(struct seq_file *f, void *data)
 {
        struct closure *cl;
+
        spin_lock_irq(&closure_list_lock);
 
        list_for_each_entry(cl, &closure_list, all) {
 
        while (size) {
                struct keybuf_key *w;
                unsigned int bytes = min(i->bytes, size);
-
                int err = copy_to_user(buf, i->buf, bytes);
+
                if (err)
                        return err;
 
 {
        if (!IS_ERR_OR_NULL(bcache_debug)) {
                char name[50];
-               snprintf(name, 50, "bcache-%pU", c->sb.set_uuid);
 
+               snprintf(name, 50, "bcache-%pU", c->sb.set_uuid);
                c->debug = debugfs_create_file(name, 0400, bcache_debug, c,
                                               &cache_set_debug_ops);
        }
 
 
        for (j = 0; j < KEY_PTRS(k); j++) {
                size_t n = PTR_BUCKET_NR(b->c, k, j);
-               printk(" bucket %zu", n);
 
+               printk(" bucket %zu", n);
                if (n >= b->c->sb.first_bucket && n < b->c->sb.nbuckets)
                        printk(" prio %i",
                               PTR_BUCKET(b->c, k, j)->prio);
 static bool bch_btree_ptr_invalid(struct btree_keys *bk, const struct bkey *k)
 {
        struct btree *b = container_of(bk, struct btree, keys);
+
        return __bch_btree_ptr_invalid(b->c, k);
 }
 
 
        while (1) {
                struct bkey *k = bch_btree_iter_next(iter);
+
                if (!k)
                        break;
 
 static bool bch_extent_invalid(struct btree_keys *bk, const struct bkey *k)
 {
        struct btree *b = container_of(bk, struct btree, keys);
+
        return __bch_extent_invalid(b->c, k);
 }
 
 
 void bch_bbio_free(struct bio *bio, struct cache_set *c)
 {
        struct bbio *b = container_of(bio, struct bbio, bio);
+
        mempool_free(b, &c->bio_meta);
 }
 
                     struct bkey *k, unsigned int ptr)
 {
        struct bbio *b = container_of(bio, struct bbio, bio);
+
        bch_bkey_copy_single_ptr(&b->key, k, ptr);
        __bch_submit_bbio(bio, c);
 }
 
        if (threshold) {
                unsigned int t = local_clock_us();
-
                int us = t - b->submit_time_us;
                int congested = atomic_read(&c->congested);
 
                if (us > (int) threshold) {
                        int ms = us / 1024;
+
                        c->congested_last_us = t;
 
                        ms = min(ms, CONGESTED_MAX + congested);
 
 static void journal_read_endio(struct bio *bio)
 {
        struct closure *cl = bio->bi_private;
+
        closure_put(cl);
 }
 
 
        struct bio *bio;
        struct bio_list list;
+
        bio_list_init(&list);
 
        if (!w->need_write) {
 
 static void moving_io_destructor(struct closure *cl)
 {
        struct moving_io *io = container_of(cl, struct moving_io, cl);
+
        kfree(io);
 }
 
 static unsigned int bucket_heap_top(struct cache *ca)
 {
        struct bucket *b;
+
        return (b = heap_peek(&ca->heap)) ? GC_SECTORS_USED(b) : 0;
 }
 
 
 
        bio_for_each_segment(bv, bio, iter) {
                void *d = kmap(bv.bv_page) + bv.bv_offset;
+
                csum = bch_crc64_update(csum, d, bv.bv_len);
                kunmap(bv.bv_page);
        }
                        ? min_t(uint64_t, INT_MAX,
                                KEY_START(k) - bio->bi_iter.bi_sector)
                        : INT_MAX;
-
                int ret = s->d->cache_miss(b, s, bio, sectors);
+
                if (ret != MAP_CONTINUE)
                        return ret;
 
 
        if (bio->bi_status) {
                struct search *s = container_of(cl, struct search, cl);
+
                s->iop.status = bio->bi_status;
                /* Only cache read errors are recoverable */
                s->recoverable = false;
                            unsigned int cmd, unsigned long arg)
 {
        struct cached_dev *dc = container_of(d, struct cached_dev, disk);
+
        return __blkdev_driver_ioctl(dc->bdev, mode, cmd, arg);
 }
 
 
                               bool hit, bool bypass)
 {
        struct cached_dev *dc = container_of(d, struct cached_dev, disk);
+
        mark_cache_stats(&dc->accounting.collector, hit, bypass);
        mark_cache_stats(&c->accounting.collector, hit, bypass);
 }
 void bch_mark_cache_readahead(struct cache_set *c, struct bcache_device *d)
 {
        struct cached_dev *dc = container_of(d, struct cached_dev, disk);
+
        atomic_inc(&dc->accounting.collector.cache_readaheads);
        atomic_inc(&c->accounting.collector.cache_readaheads);
 }
 void bch_mark_cache_miss_collision(struct cache_set *c, struct bcache_device *d)
 {
        struct cached_dev *dc = container_of(d, struct cached_dev, disk);
+
        atomic_inc(&dc->accounting.collector.cache_miss_collisions);
        atomic_inc(&c->accounting.collector.cache_miss_collisions);
 }
 
 {
        BKEY_PADDED(key) k;
        struct closure cl;
-       closure_init_stack(&cl);
 
+       closure_init_stack(&cl);
        lockdep_assert_held(&bch_register_lock);
 
        if (bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, true))
 static struct uuid_entry *uuid_find_empty(struct cache_set *c)
 {
        static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
+
        return uuid_find(c, zero_uuid);
 }
 
 static int open_dev(struct block_device *b, fmode_t mode)
 {
        struct bcache_device *d = b->bd_disk->private_data;
+
        if (test_bit(BCACHE_DEV_CLOSING, &d->flags))
                return -ENXIO;
 
 static void release_dev(struct gendisk *b, fmode_t mode)
 {
        struct bcache_device *d = b->private_data;
+
        closure_put(&d->cl);
 }
 
        if (!d->c &&
            BDEV_STATE(&dc->sb) != BDEV_STATE_NONE) {
                struct closure cl;
+
                closure_init_stack(&cl);
 
                SET_BDEV_STATE(&dc->sb, BDEV_STATE_STALE);
 {
        struct cached_dev *dc = container_of(w, struct cached_dev, detach);
        struct closure cl;
+
        closure_init_stack(&cl);
 
        BUG_ON(!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags));
 
        if (bch_is_zero(u->uuid, 16)) {
                struct closure cl;
+
                closure_init_stack(&cl);
 
                memcpy(u->uuid, dc->sb.uuid, 16);
 static void flash_dev_free(struct closure *cl)
 {
        struct bcache_device *d = container_of(cl, struct bcache_device, cl);
+
        mutex_lock(&bch_register_lock);
        atomic_long_sub(bcache_dev_sectors_dirty(d),
                        &d->c->flash_dev_dirty_sectors);
 void bch_cache_set_release(struct kobject *kobj)
 {
        struct cache_set *c = container_of(kobj, struct cache_set, kobj);
+
        kfree(c);
        module_put(THIS_MODULE);
 }
 {
        int iter_size;
        struct cache_set *c = kzalloc(sizeof(struct cache_set), GFP_KERNEL);
+
        if (!c)
                return NULL;
 
        err = "failed to register device";
        if (SB_IS_BDEV(sb)) {
                struct cached_dev *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
+
                if (!dc)
                        goto err_close;
 
                mutex_unlock(&bch_register_lock);
        } else {
                struct cache *ca = kzalloc(sizeof(*ca), GFP_KERNEL);
+
                if (!ca)
                        goto err_close;
 
 
 
        if (attr == &sysfs_size) {
                uint64_t v;
+
                strtoi_h_or_return(buf, v);
 
                u->sectors = v >> 9;
        if (attr == &sysfs_flash_vol_create) {
                int r;
                uint64_t v;
+
                strtoi_h_or_return(buf, v);
 
                r = bch_flash_dev_create(c, v);
 
        if (attr == &sysfs_prune_cache) {
                struct shrink_control sc;
+
                sc.gfp_mask = GFP_KERNEL;
                sc.nr_to_scan = strtoul_or_return(buf);
                c->shrink.scan_objects(&c->shrink, &sc);
 SHOW(bch_cache_set_internal)
 {
        struct cache_set *c = container_of(kobj, struct cache_set, internal);
+
        return bch_cache_set_show(&c->kobj, attr, buf);
 }
 
 STORE(bch_cache_set_internal)
 {
        struct cache_set *c = container_of(kobj, struct cache_set, internal);
+
        return bch_cache_set_store(&c->kobj, attr, buf, size);
 }
 
 
 int bch_parse_uuid(const char *s, char *uuid)
 {
        size_t i, j, x;
+
        memset(uuid, 0, 16);
 
        for (i = 0, j = 0;
 
 static void dirty_io_destructor(struct closure *cl)
 {
        struct dirty_io *io = container_of(cl, struct dirty_io, cl);
+
        kfree(io);
 }
 
 
 static inline struct bkey *bkey_next(const struct bkey *k)
 {
        __u64 *d = (void *) k;
+
        return (struct bkey *) (d + bkey_u64s(k));
 }
 
 static inline struct bkey *bkey_idx(const struct bkey *k, unsigned int nr_keys)
 {
        __u64 *d = (void *) k;
+
        return (struct bkey *) (d + nr_keys);
 }
 /* Enough for a key with 6 pointers */