Project

General

Profile

Feature #21944

kclient: implement copy_file_range

Added by Greg Farnum almost 2 years ago. Updated 6 months ago.

Status:
Resolved
Priority:
Normal
Category:
fs/ceph
Target version:
-
Start date:
Due date:
% Done:

0%

Source:
Development
Tags:
Backport:
Reviewed:
Affected Versions:

Description

http://man7.org/linux/man-pages/man2/copy_file_range.2.html

It’s an in-kernel (or even served-side) copy of data between two files. We should be able to do this by using the copy-from RADOS ops, directed either from the client or the mds.

I’m not sure if FUSE has hooks for this or not, though?

History

#1 Updated by Zheng Yan almost 2 years ago

I think even kernel VFS does not provide hook for this. kernel uses both splice_read and splice_write callbacks to implement this syscall. there is no easy way to combine these two callbacks into one.

#2 Updated by Luis Henriques about 1 year ago

Zheng Yan wrote:

I think even kernel VFS does not provide hook for this. kernel uses both splice_read and splice_write callbacks to implement this syscall. there is no easy way to combine these two callbacks into one.

The struct file_operations has a .copy_file_range field which nfs and cifs seem to use to implement this. Or did I misunderstood you?

I see there's no one assigned to this feature, so I'll try to spend some time in the next few weeks to have a look and see if this is doable.

#3 Updated by Zheng Yan about 1 year ago

glad to hear, thanks

#4 Updated by Luis Henriques about 1 year ago

I finally managed to spend some time looking at this, so here's a small update.

I managed to hack libceph to include a ceph_osdc_copy_from function, which I'm able to use to copy an object in a file into an object in a different file. Unfortunately, I'm missing something because when I cat the file I see there's no data there anymore (the file is truncated). If I use 'rados -p cephfs_data_a get <object ID>' I can see that the object has changed and includes the expected contents, but the FS client doesn't see that change (even with an umount/mount).

So... I'm missing something (probably something obvious!). I tried playing with caps, but not luck. Anyway, I'll continue playing a bit more with this.

#5 Updated by Luis Henriques about 1 year ago

And another update: I've managed to implement a copy_file_range PoC, where the RADOS 'copy-from' operation is used (or, at least, partially used as we still need some manual copy when the files offsets (or copy len) aren't object aligned).

The code still requires a good clean-up, specially the cephfs side of it (the actually copy-from code lives in the libceph module and should be mostly ready). I expect to send out an RFC soon.

#6 Updated by Patrick Donnelly about 1 year ago

  • Subject changed from Implement file_copy_range to kclient: implement file_copy_range
  • Status changed from New to In Progress
  • Assignee set to Luis Henriques
  • Source set to Development
  • Component(FS) kceph added

See "[RFC PATCH 0/2] copy_file_range in cephfs kernel client" on ceph-devel.

#7 Updated by Luis Henriques about 1 year ago

  • Subject changed from kclient: implement file_copy_range to kclient: implement copy_range_range

#8 Updated by Luis Henriques about 1 year ago

  • Subject changed from kclient: implement copy_range_range to kclient: implement copy_file_range

#9 Updated by Patrick Donnelly 7 months ago

  • Project changed from fs to Linux kernel client
  • Start date deleted (10/27/2017)

#10 Updated by Ilya Dryomov 6 months ago

  • Category set to fs/ceph
  • Status changed from In Progress to Resolved

In 4.20, but the copyfrom optimization was subsequently disabled due to https://tracker.ceph.com/issues/37378.

Also available in: Atom PDF