Bug 2228350

Summary: Linux client uses server side copy of NFS 4.2 when small files are copied between two intra server file system mount points
Product: [Fedora] Fedora Reporter: Mohadeb Mondal <mohadeb.mondal>
Component: kernelAssignee: Kernel Maintainer List <kernel-maint>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 38CC: acaringi, adscvr, airlied, alciregi, bskeggs, hdegoede, hpa, jarodwilson, josef, kernel-maint, lgoncalv, linville, masami256, mchehab, ptalbert, steved
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
NFS 4.2 intra server copy of 1 byte file
none
NFS 4.2 inter server copy of 128 KB file
none
NFS 4.2 inter server copy of more than 128 KB file none

Description Mohadeb Mondal 2023-08-02 07:05:30 UTC
Justification: The server-side copy of small files takes more time than the R/W copy in NFS 4.2.
When I have two NFS 4.2 files systems from the same NFS server mounted in my linux client & I issue a copy operation between one file system to the other file system, the linux client issues server side copy of NFS 4.2 with COPY_NOTIFY packet.
If these two file systems are part of two different server, the same linux client issues server side copy of NFS 4.2 with COPY_NOTIFY packet only if the file size is more than 128 KB.
For less <= 128 KB files the client uses READ and WRITE operations in case of inter server copy.

As the protocol does not specify any way for the server to drive the client for switching to the legacy file copy method, the same mechanism for the inter-server server-side copy could be applied to the intra-server copy as well.

The request has two parts.
1. Introduce one config parameter in "/etc/nfs.conf" where a user can provide the minimum file size required for COPY_NOTIFY operation. Default it to 128 KB. If the file size is less, the client should use READ and WRITE operations instead of COPY_NOTIFY for both inter & intra server copy in NFS 4.2 mount.

2. Modify how intra server copy is handled now. It should follow similar approach as followed by inter server copy. It should utilize the config variable from point  1 to decide between "READ and WRITE operation" and "COPY_NOTIFY".

Reproducible: Always

Steps to Reproduce:
1.Configure two Linux NFS 4.2 server & take one Fedora 38 client.
2.Configure 2 file system in one server and one file system in another server.
3.Initiate file copy between file systems in the same server.
4.Also initiate file copy between file systems in the two different server.
5.Try step 3-4 with file size of 1 byte, 128 KB & 129 KB files.
6.Take packet capture and see the content.

Actual Results:  
For inter server copy, 
It uses COPY_NOTIFY operation for file size more than 128 KB. for <= 128 KB it use READ and WRITE operations.
For intra server copy,
It uses COPY_NOTIFY operation for all file sizes

Expected Results:  
1. One new parameter is introduced in nfs.conf to configure minimum file size for COPY_NOTIFY operation with a default value 128 KB.
2. For file sizes more than the configured value or more than 128KB if not configured, the client should issue COPY_NOTIFY operation for intra & inter server copy.
3. For other case, it should use READ and WRITE operations instead of COPY_NOTIFY for both inter & intra server copy in NFS 4.2 mount

The test was done with
Fedora Linux 38 (Workstation Edition) with
Kernel 6.4.4-200.fc38.x86_64

I have also attached packet capture of 1 byte, 128 KB & > 128 KB file copy operation for your reference.

Comment 1 Mohadeb Mondal 2023-08-02 07:08:04 UTC
Created attachment 1981259 [details]
NFS 4.2 intra server copy of 1 byte file

Comment 2 Mohadeb Mondal 2023-08-02 07:09:04 UTC
Created attachment 1981260 [details]
NFS 4.2 inter server copy of 128 KB file

Comment 3 Mohadeb Mondal 2023-08-02 07:11:07 UTC
Created attachment 1981261 [details]
NFS 4.2 inter server copy of more than 128 KB file