Re: [PATCH v4 2/4] dmabuf: Implement copy_file_range callback for dmabuf direct I/O prep

From: Christoph Hellwig
Date: Tue Jun 03 2025 - 09:05:38 EST


On Tue, Jun 03, 2025 at 05:52:43PM +0800, wangtao wrote:
> +static ssize_t dma_buf_rw_file(struct dma_buf *dmabuf, loff_t my_pos,
> + struct file *file, loff_t pos, size_t count, bool is_write)
> +{
> + if (!dmabuf->ops->rw_file)
> + return -EINVAL;
> +
> + if (my_pos >= dmabuf->size)
> + count = 0;
> + else
> + count = min_t(size_t, count, dmabuf->size - my_pos);
> + if (!count)
> + return 0;
> +
> + return dmabuf->ops->rw_file(dmabuf, my_pos, file, pos, count, is_write);

So despite claiming in the cover letter that dmabufs can't support
direct I/O you are just reimplementing it badly here using a side
interface.