linux/drivers/md/bcache/request.h
Kent Overstreet d4e3b928ab closures: CLOSURE_CALLBACK() to fix type punning
Control flow integrity is now checking that type signatures match on
indirect function calls. That breaks closures, which embed a work_struct
in a closure in such a way that a closure_fn may also be used as a
workqueue fn by the underlying closure code.

So we have to change closure fns to take a work_struct as their
argument - but that results in a loss of clarity, as closure fns have
different semantics from normal workqueue functions (they run owning a
ref on the closure, which must be released with continue_at() or
closure_return()).

Thus, this patc introduces CLOSURE_CALLBACK() and closure_type() macros
as suggested by Kees, to smooth things over a bit.

Suggested-by: Kees Cook <keescook@chromium.org>
Cc: Coly Li <colyli@suse.de>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-11-24 00:29:58 -05:00

48 lines
997 B
C

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _BCACHE_REQUEST_H_
#define _BCACHE_REQUEST_H_
struct data_insert_op {
struct closure cl;
struct cache_set *c;
struct bio *bio;
struct workqueue_struct *wq;
unsigned int inode;
uint16_t write_point;
uint16_t write_prio;
blk_status_t status;
union {
uint16_t flags;
struct {
unsigned int bypass:1;
unsigned int writeback:1;
unsigned int flush_journal:1;
unsigned int csum:1;
unsigned int replace:1;
unsigned int replace_collision:1;
unsigned int insert_data_done:1;
};
};
struct keylist insert_keys;
BKEY_PADDED(replace_key);
};
unsigned int bch_get_congested(const struct cache_set *c);
CLOSURE_CALLBACK(bch_data_insert);
void bch_cached_dev_request_init(struct cached_dev *dc);
void cached_dev_submit_bio(struct bio *bio);
void bch_flash_dev_request_init(struct bcache_device *d);
void flash_dev_submit_bio(struct bio *bio);
extern struct kmem_cache *bch_search_cache;
#endif /* _BCACHE_REQUEST_H_ */