Messages in this thread | | | Date | Mon, 24 Jul 2023 11:16:06 +0530 | From | Nitesh Shetty <> | Subject | Re: [PATCH v13 4/9] fs, block: copy_file_range for def_blk_ops for direct block device |
| |
On 23/07/20 09:57AM, Christoph Hellwig wrote: >> +/* Copy source offset from source block device to destination block >> + * device. Returns the length of bytes copied. >> + */ >> +ssize_t blkdev_copy_offload_failfast( >> + struct block_device *bdev_in, loff_t pos_in, >> + struct block_device *bdev_out, loff_t pos_out, >> + size_t len, gfp_t gfp_mask) > >This is an odd and very misnamed interface. > >Either we have a klkdev_copy() interface that automatically falls back >to a fallback (maybe with an opt-out), or we have separate >blkdev_copy_offload/blkdev_copy_emulated interface and let the caller >decide. But none of that really is "failfast". > >Also this needs to go into the helpers patch and not a patch that is >supposed to just wire copying up for block device node. > Acked.
>> index b07de77ef126..d27148a2543f 100644 >> --- a/fs/read_write.c >> +++ b/fs/read_write.c >> @@ -1447,7 +1447,8 @@ static int generic_copy_file_checks(struct file *file_in, loff_t pos_in, >> return -EOVERFLOW; >> >> /* Shorten the copy to EOF */ >> - size_in = i_size_read(inode_in); >> + size_in = i_size_read(file_in->f_mapping->host); > >generic_copy_file_checks needs to be fixed to use ->mapping->host both >or inode_in and inode_out at the top of the file instead of this >band aid. And that needs to be a separate patch with a Fixes tag. > Addressed below.
>> @@ -1708,7 +1709,9 @@ int generic_file_rw_checks(struct file *file_in, struct file *file_out) >> /* Don't copy dirs, pipes, sockets... */ >> if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) >> return -EISDIR; >> - if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) >> + >> + if ((!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) && >> + (!S_ISBLK(inode_in->i_mode) || !S_ISBLK(inode_out->i_mode))) > >This is using weird indentation, and might also not be doing >exactly what we want. I think the better thing to do here is to: > > 1) check for the accetable types only on the in inode > 2) have a check that the mode matches for the in and out inodes > >And please do this as a separate prep patch instead of hiding it here. > Agreed. We will send a separate patch, that enables copy_file_range on block devices.
Thank you, Nitesh Shetty
| |