On Fri, Mar 27, 2020 at 08:15:43PM +0300, Max Gurtovoy wrote: > - if (!nvmet_check_transfer_len(req, nvmet_rw_data_len(req))) > + if (!nvmet_check_transfer_len(req, > + nvmet_rw_data_len(req) + req->md_len)) Shouldn't we also calculate the actual metadata length on the fly here? > blk_start_plug(&plug); > + if (req->use_md) Can't we use a non-NULL req->md_sg or non-null req->md_sg_cnt as a metadata supported indicator and remove the use_md flag? Maybe wrap them in a helper function that also checks for blk integrity support using IS_ENABLED and we can skip the stubs as well.