On Mon, May 20, 2024 at 03:50:17PM +0530, Nitesh Shetty wrote: > For the devices which does not support copy, copy emulation is added. > It is required for in-kernel users like fabrics, where file descriptor is > not available and hence they can't use copy_file_range. > Copy-emulation is implemented by reading from source into memory and > writing to the corresponding destination. > At present in kernel user of emulation is fabrics. I still don't see the point of offering this in the block layer, at least in this form. Caller usually can pre-allocate a buffer if they need regular copies instead of doing constant allocation and freeing which puts a lot of stress on the page allocator. > +static void *blkdev_copy_alloc_buf(ssize_t req_size, ssize_t *alloc_size, > + gfp_t gfp) > +{ > + int min_size = PAGE_SIZE; > + char *buf; > + > + while (req_size >= min_size) { > + buf = kvmalloc(req_size, gfp); > + if (buf) { > + *alloc_size = req_size; > + return buf; > + } > + req_size >>= 1; > + } > + > + return NULL; And requiring a kernel mapping for data is is never used through the kernel mapping is pretty silly as well.