Bug 217749

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: Linux Reporter: Mohadeb Mondal (mohadeb.mondal)
Component: KernelAssignee: Virtual assignee for kernel bugs (linux-kernel)
Status: NEW ---    
Severity: high    
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: 6.4.4-200.fc38.x86_64 Subsystem:
Regression: No Bisected commit-id:
Attachments: NFS 4.2 intra server copy of 1 byte file
NFS 4.2 inter server copy of more than 128 KB file
NFS 4.2 inter server copy of 128 KB file

Description Mohadeb Mondal 2023-08-02 09:29:33 UTC
Created attachment 304754 [details]
NFS 4.2 intra server copy of 1 byte file

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 09:31:14 UTC
Created attachment 304755 [details]
NFS 4.2 inter server copy of more than 128 KB file
Comment 2 Mohadeb Mondal 2023-08-02 09:31:51 UTC
Created attachment 304756 [details]
NFS 4.2 inter server copy of 128 KB file