Message ID | 20231221012715.3048221-2-song@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | block, md: Better handle REQ_OP_FLUSH | expand |
On Wed, Dec 20, 2023 at 05:27:14PM -0800, Song Liu wrote: > Upper layer (fs, etc.) may issue flush with something like: > > bio_reset(bio, bdev, REQ_OP_FLUSH); > bio->bi_end_io = xxx; > submit_bio(bio); No, they can't. REQ_OP_FLUSH is currently only used by request based drivers and only generated by the flush state machine. (Not that I particularly like this wart, I'd much prefer file systems to submit a REQ_OP_FLUSH than an empty write with a preflush flag, but that's not a trivial change).
On Wed, Dec 20, 2023 at 10:12 PM Christoph Hellwig <hch@infradead.org> wrote: > > On Wed, Dec 20, 2023 at 05:27:14PM -0800, Song Liu wrote: > > Upper layer (fs, etc.) may issue flush with something like: > > > > bio_reset(bio, bdev, REQ_OP_FLUSH); > > bio->bi_end_io = xxx; > > submit_bio(bio); > > No, they can't. REQ_OP_FLUSH is currently only used by request > based drivers and only generated by the flush state machine. Hmm... Then this call trace from bcachefs is the exception here: bch2_journal_write=> submit_bio=> ... md_handle_request => raid5_make_request => chunk_aligned_read => raid5_read_one_chunk => > (Not that I particularly like this wart, I'd much prefer file systems > to submit a REQ_OP_FLUSH than an empty write with a preflush flag, > but that's not a trivial change). Kent, I think we need to update how bcachefs issue flushes. Thanks, Song
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index d5c5e59ddbd2..338423da84ca 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -487,7 +487,8 @@ static inline bool op_is_write(blk_opf_t op) */ static inline bool op_is_flush(blk_opf_t op) { - return op & (REQ_FUA | REQ_PREFLUSH); + return op & (REQ_FUA | REQ_PREFLUSH) || + (op & REQ_OP_MASK) == REQ_OP_FLUSH; } /*
Upper layer (fs, etc.) may issue flush with something like: bio_reset(bio, bdev, REQ_OP_FLUSH); bio->bi_end_io = xxx; submit_bio(bio); op_is_flush(bio->bi_opf) should return true for this bio. Signed-off-by: Song Liu <song@kernel.org> --- include/linux/blk_types.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)