This looks right, except we also need to preserve @ukernel's recent change (see 1dae27c50538c066a7f22702838100baf243904b).  Maybe add a

bool trimmed_read = false;

and set it to true when adjusting length, and make the conditional

if (trimmed_read && op.extent.length == 0) { ...