On Wed, 10 Sep 2025, Bart Van Assche wrote: > The dm core splits REQ_PREFLUSH bios that have data into two bios. > First, a REQ_PREFLUSH bio with no data is submitted to all underlying > dm devices. Next, the REQ_PREFLUSH flag is cleared and the same bio is > resubmitted. This approach is essential if there are multiple underlying > devices to provide correct REQ_PREFLUSH semantics. > > Splitting a bio into an empty flush bio and a non-flush data bio is > not necessary if there is only a single underlying device. Hence this > patch that does not split REQ_PREFLUSH bios if there is only one > underlying device. > > This patch preserves the order of REQ_PREFLUSH writes if there is only > one underlying device and if one or more write bios have been queued > past the REQ_PREFLUSH bio before the REQ_PREFLUSH bio is processed. > > Cc: Mike Snitzer <snitzer@xxxxxxxxxx> > Cc: Damien Le Moal <dlemoal@xxxxxxxxxx> > Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> > --- > > Changes compared to v1: > - Made the patch description more detailed. > - Removed the reference to write pipelining from the patch description. Hi I think that the problem here is that not all targets handle a PREFLUSH bio with data (for example, dm-integrity doesn't handle it correctly; it assumes that the PREFLUSH bio is empty). I suggest that the logic should be changed to test that "t->flush_bypasses_map == true" (that will rule out targets that don't support flush optimization) and "dm_table_get_devices returns just one device" - if both of these conditions are true, you can send the PREFLUSH bio with data to the one device that dm_table_get_devices returned. It will also optimize the case when you have multiple dm-linear targets with just one underlying device. Mikulas