On Tue, Feb 25, 2025 at 07:00:05PM +0800, Ming Lei wrote: > On Mon, Feb 24, 2025 at 01:31:14PM -0800, Keith Busch wrote: > > static inline bool ublk_dev_is_user_copy(const struct ublk_device *ub) > > { > > - return ub->dev_info.flags & UBLK_F_USER_COPY; > > + return ub->dev_info.flags & (UBLK_F_USER_COPY | UBLK_F_SUPPORT_ZERO_COPY); > > } > > I'd suggest to set UBLK_F_USER_COPY explicitly either from userspace or > kernel side. > > One reason is that UBLK_F_UNPRIVILEGED_DEV mode can't work for both. In my reference implementation using ublksrv, I had the userspace explicitly setting F_USER_COPY automatically if zero copy was requested. Is that what you mean? Or do you need the kernel side to set both flags if zero copy is requested too? I actually have a newer diff for ublksrv making use of the SQE links. I'll send that out with the next update since it looks like there will need to be at least one more version. Relevant part from the cover letter, https://lore.kernel.org/io-uring/20250203154517.937623-1-kbusch@xxxxxxxx/ diff --git a/ublksrv_tgt.cpp b/ublksrv_tgt.cpp index 8f9cf28..f3ebe14 100644 --- a/ublksrv_tgt.cpp +++ b/ublksrv_tgt.cpp @@ -723,7 +723,7 @@ static int cmd_dev_add(int argc, char *argv[]) data.tgt_type = optarg; break; case 'z': - data.flags |= UBLK_F_SUPPORT_ZERO_COPY; + data.flags |= UBLK_F_SUPPORT_ZERO_COPY | UBLK_F_USER_COPY; break; case 'q': data.nr_hw_queues = strtol(optarg, NULL, 10);