Bug 458001 - KDE / KIO / Dolphin needs to support "copy_file_range" for server-side copies over a network (such as NFS)
Summary: KDE / KIO / Dolphin needs to support "copy_file_range" for server-side copies...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kio
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: KIO Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-17 17:05 UTC by flan_suse
Modified: 2026-10-30 17:15 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.32
Sentry Crash Report:


Attachments
strace -f -e trace=copy_file_range,ioctl -p $(pidof dolphin) (641.42 KB, text/x-log)
2026-10-29 23:37 UTC, flan_suse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description flan_suse 2022-08-17 17:05:56 UTC
When copying a large file on an NFS mount with Dolphin, it takes a very long time since it does a round trip over the network.

NFS 4.2 has already supported server side copies, yet Dolphin does not take advantage of this with "copy_file_range".

This means someone has to resort to the terminal with "cp" in order to copy files without sending the data on a round trip over the network.

I thought this was included in KDE Frameworks 5.88? But apparently this is not the case?

Has anything been done with this: https://invent.kde.org/frameworks/kio/-/merge_requests/602
Comment 1 Nicolas Fella 2022-08-17 20:35:14 UTC
Is this about browsing NFS directly in Dolphin (i.e. a nfs:/ URL) or a NFS mounted to the local filesystem and accessed via Dolphin as if it was a regular file?
Comment 2 flan_suse 2022-08-18 02:28:40 UTC
(In reply to Nicolas Fella from comment #1)
> Is this about browsing NFS directly in Dolphin (i.e. a nfs:/ URL) or a NFS
> mounted to the local filesystem and accessed via Dolphin as if it was a
> regular file?

Mounted normally with "mount".

For example:

mount -t nfs 192.168.0.100:/remote/path/of/share /mnt/remote

nfsstat -m reveals the client and server are both using NFS v4.2. Copying a file with cp is very fast and uses "copy_fele_range" as expected. The copy operation does *not* make a round trip over the gigabit network. It's done on the server (which is one of the major features specifically introduced with NFS v4.2)

Output of nfsstat -m:

Flags: rw,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.0.2,local_lock=none,addr=192.168.0.100

Copying a large 2 GB file with cp takes only a few seconds. (Server side copy!) :)

Copying a large 2 GB file with Dolphin takes over half a minute! (Round trip over the network.) :'(

The 2 GB file is filled with random data.

I expected this feature was already used by Dolphin since KDE Frameworks 5.88+, but it doesn't seem to be the case?

Is there any activity or update on this?
Comment 3 Nicolas Fella 2022-08-18 10:41:14 UTC
Okay, so this is about the file worker, not the nfs worker.
Comment 4 flan_suse 2022-08-18 14:51:36 UTC
(In reply to Nicolas Fella from comment #3)
> Okay, so this is about the file worker, not the nfs worker.

My main confusion / question:

Has this been addressed by the KDE developers and *should* be working as expected?

Or was the feature "accepted" but never finalized?

Being a layperson end-user, I cannot tell if it was actually included in the final code or not.

https://invent.kde.org/frameworks/kio/-/merge_requests/602

That's why I was unsure to submit this ticket as a "bug" or a "wishlist". Because if it *was* implemented, then it's not working as intended. However, if it was not implemented, then yes, this is a *dearly* needed feature of Dolphin/KIO.

Network shares (even NFS) and NAS appliances are not rare for Linux users. Besides, everything else is in place; it's just that the client (i.e, Dolphin) needs to use it.
Comment 5 Bug Janitor Service 2022-08-20 08:46:35 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/957
Comment 6 Méven Car 2022-08-20 09:23:56 UTC
(In reply to flan_suse from comment #4)
> (In reply to Nicolas Fella from comment #3)
> > Okay, so this is about the file worker, not the nfs worker.
> 
> My main confusion / question:
> 
> Has this been addressed by the KDE developers and *should* be working as
> expected?
> 
> Or was the feature "accepted" but never finalized?
> 
> Being a layperson end-user, I cannot tell if it was actually included in the
> final code or not.
> 
> https://invent.kde.org/frameworks/kio/-/merge_requests/602
> 
> That's why I was unsure to submit this ticket as a "bug" or a "wishlist".
> Because if it *was* implemented, then it's not working as intended. 

Despite it was implemented and improved things, we still had inefficiencies that my new MR addresses mostly.
Your bug report is quite legitimate, thanks for pointing this out.
Comment 7 Méven Car 2022-08-26 16:35:15 UTC
Git commit fa8edc7099820d72179b29ccd15535b5398c5952 by Méven Car, on behalf of Méven Car.
Committed on 26/08/2022 at 16:35.
Pushed by meven into branch 'master'.

file_unix: optimize copy

 * avoid to stat the source file to get its size in the loop

M  +8    -7    src/ioslaves/file/file_unix.cpp

https://invent.kde.org/frameworks/kio/commit/fa8edc7099820d72179b29ccd15535b5398c5952
Comment 8 Méven Car 2022-08-27 07:26:05 UTC
Please note we still have a margin of improvements, still this MR (https://invent.kde.org/frameworks/kio/-/merge_requests/602) should be significant especially for NFS to NFS transferts.

Feel free to reopen this bug if you feel it has not reached what you expected.

The next speed improvement we can get is in our radar (https://invent.kde.org/frameworks/kio/-/merge_requests/957#note_509744) but will necessitate a lot more work unfortunately.
Comment 9 flan_suse 2026-07-27 13:16:31 UTC
This is a problem again.

Other file managers, including PCManFM-Qt don't have this issue.

When I copy a file with cp, it is done on the server over an SMB or NFS share mounted via fstab/systemd. This takes advantage of block clones on a ZFS server.

When I do the same thing with PCManFM-Qt, it works just like using cp.

When I use Dolphin, copies are not only less efficient and slower but they also duplicate the space on a ZFS server. They do not take advantage of block cloning.

If "cp" and "PCManFM-Qt" work without any tweaking, how come Dolphin's copy/paste is using this rudimentary and inefficient method?

If find myself having to use the terminal and alternative file browsers because of this. I don't understand why copying files has so much complex code with Dolphin? Why is it doing anything extra under the hood?
Comment 10 Méven 2026-10-29 08:41:13 UTC
Thanks for reopening.

Dolphin does ask the server to copy: KIO tries FICLONE first, like cp, and
then copies with copy_file_range().

The difference is the size of each copy_file_range() call. cp passes the whole file in one call. KIO copies in
pieces: 512 KiB up to KF 6.30, and since 6.31 a size that adapts to the speed of the copy.

ZFS only clones a range that starts and ends on the block size of the dataset
(its recordsize). For any other range the server copies the data instead, so
the copy stays on the server but takes the space twice. With recordsize=1M,
512 KiB pieces never line up with a block.

To confirm this, could you provide:
- your KDE Frameworks version
- your ZFS version, and the output of: zfs get recordsize <dataset>
- the calls Dolphin makes during a copy, from:
strace -f -e trace=copy_file_range,ioctl -p $(pidof dolphin)
(copy one large file in Dolphin while this runs, then stop it with Ctrl+C)

If the cause is confirmed, the fix is to keep the boundaries of each copied
piece aligned on a large block size.
Comment 11 flan_suse 2026-10-29 23:34:33 UTC
(In reply to Méven from comment #10)

> To confirm this, could you provide:
> - your KDE Frameworks version
> - your ZFS version, and the output of: zfs get recordsize <dataset>
> - the calls Dolphin makes during a copy, from:
> strace -f -e trace=copy_file_range,ioctl -p $(pidof dolphin)
> (copy one large file in Dolphin while this runs, then stop it with Ctrl+C)

KDE Frameworks Version: 6.31.0
ZFS Version: 2.4.2
Record size: 1M for all datasets. (From the user's perspective, it shouldn't matter if it's 32K or 16M record size.)

I'll attach the log file of strace. This was over SMB, but you're saying that the fix will work for NFS too?



> If the cause is confirmed, the fix is to keep the boundaries of each copied
> piece aligned on a large block size.

If it resolves this issue and will "just work" no matter what the record size is, that's great.

I still don't understand, though. Why should Dolphin try to align anything? "cp" doesn't need anything special, as you noted it passes the whole file. What's the magic that PCManFM-Qt uses? How is it that without any tweaking or workarounds, PCManFM-Qt it is exponentially superior when copying large files over an SMB or NFS share? Not only does copying a 5 GB file happen instantly, but it takes up no additional space on the ZFS server. I can't rely on Dolphin to copy large files over SMB or NFS. I had to make a Service Menu shortcut that uses "cp" to copy the file in the same directory, which I then move to another folder, in order to take advantage of ZFS block cloning. Sometimes I find myself just using PCManFM-Qt, but then I miss out on other features of Dolphin.

> The difference is the size of each copy_file_range() call. cp passes the
> whole file in one call. KIO copies in
> pieces: 512 KiB up to KF 6.30, and since 6.31 a size that adapts to the
> speed of the copy.

This is what I mean. It feels like Dolphin is trying to be too smart which ends up hurting performance and space usage efficiency.
Comment 12 flan_suse 2026-10-29 23:37:16 UTC
Created attachment 197813 [details]
strace -f -e trace=copy_file_range,ioctl -p $(pidof dolphin)

This is over an SMB share over a local network.

ZFS 2.4.2
ZFS Record Size: 1M
KDE Frameworks: 6.31.0
Dolphin: 26.08.2
Comment 13 Bug Janitor Service 2026-10-30 09:49:07 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kio/-/merge_requests/2528
Comment 14 Méven 2026-10-30 10:33:17 UTC
Git commit 7d9df740872357bb314d23f81ad5f150d6a69768 by Méven Car.
Committed on 30/10/2026 at 09:44.
Pushed by meven into branch 'master'.

file_unix_copy: align copy_file_range calls on 8 MiB

Before this change, the copy started with a 512 KiB chunk and doubled
it, so every call after the first started on an odd multiple of
512 KiB. ZFS clones only whole records, 1 MiB by default, and copies
the data of any other range. This also holds for a server-side copy
over NFS or SMB to a ZFS server. A copy within a ZFS dataset then took
the space twice.

copy_file_range() calls now start with 8 MiB and end on a multiple of
the largest power of two in the chunk, at least 8 MiB, except at the
end of the file. A clone takes milliseconds, so a call slower than the
latency target moves the data, such as between two NFS mounts without
a server-side copy. The chunk can then shrink to 512 KiB again, as
before. The sendfile() path between two filesystems keeps the 512 KiB
start, as nothing can be cloned there.

M  +27   -5    src/kioworkers/file/file_unix_copy.cpp

https://invent.kde.org/frameworks/kio/-/commit/7d9df740872357bb314d23f81ad5f150d6a69768
Comment 15 Nate Graham 2026-10-30 17:15:20 UTC
Nice!