Loading drivers/md/bcache/closure.h +1 −12 Original line number Diff line number Diff line Loading @@ -347,14 +347,6 @@ do { \ do_closure_init(_cl, parent, running); \ } while (0) /** * __closure_init() - Initialize a closure, skipping the memset() * * May be used instead of closure_init() when memory has already been zeroed. */ #define __closure_init(cl, parent) \ closure_init_type(cl, parent, true) /** * closure_init() - Initialize a closure, setting the refcount to 1 * @cl: closure to initialize Loading @@ -362,10 +354,7 @@ do { \ * lifetime; may be NULL. */ #define closure_init(cl, parent) \ do { \ memset((cl), 0, sizeof(*(cl))); \ __closure_init(cl, parent); \ } while (0) closure_init_type(cl, parent, true) static inline void closure_init_stack(struct closure *cl) { Loading drivers/md/bcache/request.c +27 −20 Original line number Diff line number Diff line Loading @@ -597,14 +597,12 @@ struct search { /* Stack frame for bio_complete */ struct closure cl; struct bcache_device *d; struct bbio bio; struct bio *orig_bio; struct bio *cache_miss; struct bcache_device *d; unsigned insert_bio_sectors; unsigned recoverable:1; unsigned write:1; unsigned read_dirty_data:1; Loading Loading @@ -712,8 +710,11 @@ static void cache_lookup(struct closure *cl) { struct search *s = container_of(cl, struct search, iop.cl); struct bio *bio = &s->bio.bio; int ret; bch_btree_op_init(&s->op, -1); int ret = bch_btree_map_keys(&s->op, s->iop.c, ret = bch_btree_map_keys(&s->op, s->iop.c, &KEY(s->iop.inode, bio->bi_iter.bi_sector, 0), cache_lookup_fn, MAP_END_KEY); if (ret == -EAGAIN) Loading Loading @@ -756,12 +757,12 @@ static void bio_complete(struct search *s) } } static void do_bio_hook(struct search *s) static void do_bio_hook(struct search *s, struct bio *orig_bio) { struct bio *bio = &s->bio.bio; bio_init(bio); __bio_clone_fast(bio, s->orig_bio); __bio_clone_fast(bio, orig_bio); bio->bi_end_io = request_endio; bio->bi_private = &s->cl; Loading @@ -780,26 +781,32 @@ static void search_free(struct closure *cl) mempool_free(s, s->d->c->search); } static struct search *search_alloc(struct bio *bio, struct bcache_device *d) static inline struct search *search_alloc(struct bio *bio, struct bcache_device *d) { struct search *s; s = mempool_alloc(d->c->search, GFP_NOIO); memset(s, 0, offsetof(struct search, iop.insert_keys)); __closure_init(&s->cl, NULL); closure_init(&s->cl, NULL); do_bio_hook(s, bio); s->iop.inode = d->id; s->iop.c = d->c; s->d = d; s->op.lock = -1; s->iop.write_point = hash_long((unsigned long) current, 16); s->orig_bio = bio; s->write = (bio->bi_rw & REQ_WRITE) != 0; s->iop.flush_journal = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0; s->cache_miss = NULL; s->d = d; s->recoverable = 1; s->write = (bio->bi_rw & REQ_WRITE) != 0; s->read_dirty_data = 0; s->start_time = jiffies; do_bio_hook(s); s->iop.c = d->c; s->iop.bio = NULL; s->iop.inode = d->id; s->iop.write_point = hash_long((unsigned long) current, 16); s->iop.write_prio = 0; s->iop.error = 0; s->iop.flags = 0; s->iop.flush_journal = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0; return s; } Loading Loading @@ -845,7 +852,7 @@ static void cached_dev_read_error(struct closure *cl) trace_bcache_read_retry(s->orig_bio); s->iop.error = 0; do_bio_hook(s); do_bio_hook(s, s->orig_bio); /* XXX: invalidate cache */ Loading drivers/md/bcache/request.h +13 −8 Original line number Diff line number Diff line Loading @@ -13,6 +13,10 @@ struct data_insert_op { uint16_t write_prio; short error; union { uint16_t flags; struct { unsigned bypass:1; unsigned writeback:1; unsigned flush_journal:1; Loading @@ -22,8 +26,9 @@ struct data_insert_op { unsigned replace_collision:1; unsigned insert_data_done:1; }; }; /* Anything past this point won't get zeroed in search_alloc() */ struct keylist insert_keys; BKEY_PADDED(replace_key); }; Loading Loading
drivers/md/bcache/closure.h +1 −12 Original line number Diff line number Diff line Loading @@ -347,14 +347,6 @@ do { \ do_closure_init(_cl, parent, running); \ } while (0) /** * __closure_init() - Initialize a closure, skipping the memset() * * May be used instead of closure_init() when memory has already been zeroed. */ #define __closure_init(cl, parent) \ closure_init_type(cl, parent, true) /** * closure_init() - Initialize a closure, setting the refcount to 1 * @cl: closure to initialize Loading @@ -362,10 +354,7 @@ do { \ * lifetime; may be NULL. */ #define closure_init(cl, parent) \ do { \ memset((cl), 0, sizeof(*(cl))); \ __closure_init(cl, parent); \ } while (0) closure_init_type(cl, parent, true) static inline void closure_init_stack(struct closure *cl) { Loading
drivers/md/bcache/request.c +27 −20 Original line number Diff line number Diff line Loading @@ -597,14 +597,12 @@ struct search { /* Stack frame for bio_complete */ struct closure cl; struct bcache_device *d; struct bbio bio; struct bio *orig_bio; struct bio *cache_miss; struct bcache_device *d; unsigned insert_bio_sectors; unsigned recoverable:1; unsigned write:1; unsigned read_dirty_data:1; Loading Loading @@ -712,8 +710,11 @@ static void cache_lookup(struct closure *cl) { struct search *s = container_of(cl, struct search, iop.cl); struct bio *bio = &s->bio.bio; int ret; bch_btree_op_init(&s->op, -1); int ret = bch_btree_map_keys(&s->op, s->iop.c, ret = bch_btree_map_keys(&s->op, s->iop.c, &KEY(s->iop.inode, bio->bi_iter.bi_sector, 0), cache_lookup_fn, MAP_END_KEY); if (ret == -EAGAIN) Loading Loading @@ -756,12 +757,12 @@ static void bio_complete(struct search *s) } } static void do_bio_hook(struct search *s) static void do_bio_hook(struct search *s, struct bio *orig_bio) { struct bio *bio = &s->bio.bio; bio_init(bio); __bio_clone_fast(bio, s->orig_bio); __bio_clone_fast(bio, orig_bio); bio->bi_end_io = request_endio; bio->bi_private = &s->cl; Loading @@ -780,26 +781,32 @@ static void search_free(struct closure *cl) mempool_free(s, s->d->c->search); } static struct search *search_alloc(struct bio *bio, struct bcache_device *d) static inline struct search *search_alloc(struct bio *bio, struct bcache_device *d) { struct search *s; s = mempool_alloc(d->c->search, GFP_NOIO); memset(s, 0, offsetof(struct search, iop.insert_keys)); __closure_init(&s->cl, NULL); closure_init(&s->cl, NULL); do_bio_hook(s, bio); s->iop.inode = d->id; s->iop.c = d->c; s->d = d; s->op.lock = -1; s->iop.write_point = hash_long((unsigned long) current, 16); s->orig_bio = bio; s->write = (bio->bi_rw & REQ_WRITE) != 0; s->iop.flush_journal = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0; s->cache_miss = NULL; s->d = d; s->recoverable = 1; s->write = (bio->bi_rw & REQ_WRITE) != 0; s->read_dirty_data = 0; s->start_time = jiffies; do_bio_hook(s); s->iop.c = d->c; s->iop.bio = NULL; s->iop.inode = d->id; s->iop.write_point = hash_long((unsigned long) current, 16); s->iop.write_prio = 0; s->iop.error = 0; s->iop.flags = 0; s->iop.flush_journal = (bio->bi_rw & (REQ_FLUSH|REQ_FUA)) != 0; return s; } Loading Loading @@ -845,7 +852,7 @@ static void cached_dev_read_error(struct closure *cl) trace_bcache_read_retry(s->orig_bio); s->iop.error = 0; do_bio_hook(s); do_bio_hook(s, s->orig_bio); /* XXX: invalidate cache */ Loading
drivers/md/bcache/request.h +13 −8 Original line number Diff line number Diff line Loading @@ -13,6 +13,10 @@ struct data_insert_op { uint16_t write_prio; short error; union { uint16_t flags; struct { unsigned bypass:1; unsigned writeback:1; unsigned flush_journal:1; Loading @@ -22,8 +26,9 @@ struct data_insert_op { unsigned replace_collision:1; unsigned insert_data_done:1; }; }; /* Anything past this point won't get zeroed in search_alloc() */ struct keylist insert_keys; BKEY_PADDED(replace_key); }; Loading