Hi,
Is this supported ? Can I use NFSv4.2 ‘clone’ command with truenas 24.10 nfs server ?
cp From/to same dataset of the same file
- ‘nfsstat -c’ clone counter increases on the nfs client
- the size of the dataset increases by the size of the file on the NAS, which is not expected.
More info needed.
Is block-cloning enabled on the pool?
zpool get feature@block_cloning <poolname>
Is there a tunable that prevents block-cloning?
cat /sys/module/zfs/parameters/zfs_bclone_enabled
Yes @winnielinnie
karadok@znas:~$ sudo zpool get feature@block_cloning tank
NAME PROPERTY VALUE SOURCE
tank feature@block_cloning active local
karadok@znas:~$ cat /sys/module/zfs/parameters/zfs_bclone_enabled
1
Before test :
root@znas:~# zfs list -o space -Hp tank/media
tank/media 20752632875921 **11997323842176** 19535442624 11977788399552 0 0
karadok@plex-znas:/mnt/znas/media/test$ sudo nfsstat -c
Client rpc stats:
calls retrans authrefrsh
140352 0 140352
Client nfs v4:
null read write commit open
1 0% 138125 98% 0 0% 0 0% 7 0%
open_conf open_noat open_dgrd close setattr
0 0% 16 0% 0 0% 23 0% 7 0%
fsinfo renew setclntid confirm lock
5 0% 0 0% 0 0% 0 0% 0 0%
lockt locku access getattr lookup
0 0% 0 0% 295 0% 779 0% 38 0%
lookup_root remove rename link symlink
1 0% 14 0% 2 0% 0 0% 0 0%
create pathconf statfs readlink readdir
1 0% 4 0% 0 0% 0 0% 379 0%
server_caps delegreturn getacl setacl fs_locations
9 0% 16 0% 0 0% 0 0% 0 0%
rel_lkowner secinfo fsid_present exchange_id create_session
0 0% 0 0% 0 0% 2 0% 1 0%
destroy_session sequence get_lease_time reclaim_comp layoutget
0 0% 618 0% 0 0% 1 0% 0 0%
getdevinfo layoutcommit layoutreturn secinfo_no test_stateid
0 0% 0 0% 0 0% 1 0% 0 0%
free_stateid getdevicelist bind_conn_to_ses destroy_clientid seek
0 0% 0 0% 0 0% 0 0% 0 0%
allocate deallocate layoutstats **clone**
0 0% 0 0% 0 0% **7** 0%
Then duplicating the file from remote NFSv4.2 client
`
karadok@plex-znas:/mnt/znas/media/test$ ls -l
total 9599297
-rwxrwx–x 1 plex plex 4920611723 Aug 3 12:13 file
karadok@plex-znas:/mnt/znas/media/test$ cp file file2`
Result:
karadok@plex-znas:/mnt/znas/media/test$ sudo nfsstat -c
Client rpc stats:
calls retrans authrefrsh
140370 0 140370
Client nfs v4:
null read write commit open
1 0% 138125 98% 0 0% 0 0% 8 0%
open_conf open_noat open_dgrd close setattr
0 0% 17 0% 0 0% 25 0% 8 0%
fsinfo renew setclntid confirm lock
5 0% 0 0% 0 0% 0 0% 0 0%
lockt locku access getattr lookup
0 0% 0 0% 295 0% 785 0% 39 0%
lookup_root remove rename link symlink
1 0% 14 0% 2 0% 0 0% 0 0%
create pathconf statfs readlink readdir
1 0% 4 0% 0 0% 0 0% 379 0%
server_caps delegreturn getacl setacl fs_locations
9 0% 17 0% 0 0% 0 0% 0 0%
rel_lkowner secinfo fsid_present exchange_id create_session
0 0% 0 0% 0 0% 2 0% 1 0%
destroy_session sequence get_lease_time reclaim_comp layoutget
0 0% 622 0% 0 0% 1 0% 0 0%
getdevinfo layoutcommit layoutreturn secinfo_no test_stateid
0 0% 0 0% 0 0% 1 0% 0 0%
free_stateid getdevicelist bind_conn_to_ses destroy_clientid seek
0 0% 0 0% 0 0% 0 0% 0 0%
allocate deallocate layoutstats **clone**
0 0% 0 0% 0 0% **8** 0%
Size before after:
root@znas:~# zfs list -o space -Hp tank/media
tank/media 20752632875921 **11997323842176** 19535442624 11977788399552 0 0
root@znas:~# zfs list -o space -Hp tank/media
tank/media 20752632323249 **12002238826992** 19535588064 11982703238928 0 0
Delta : 4 914 984 816
You’re supposed to check with the zpool command, not zfs or any standard tools.
zpool list -o name,bcloneused,bclonesaved,bcloneratio tank
That was my mistake, thank you @winnielinnie
Herafter, results from duplication of 10GB file filled with /de/urandom
| bclone used |
bclone saved |
bclone_ratio |
free |
| 2 326 091 956 632 |
3 040 833 900 744 |
2.30 |
35 402 898 993 152 |
| 2 326 091 956 632 |
3 051 556 901 064 |
2.31 |
35 402 878 115 840 |
|
-10 723 000 320 |
|
20 877 312 |
If i read it properly, the substraction of the two lines says that thanks to bclone i saved 10GB. The cost of metadatas is approx 20MB, correct ?
Correct.
That 20MB could be from anything, such as the System Dataset, if it lives on your pool.
The “overhead” for block-cloning is practically zero, especially if your recordsize is set to a high value, such as 1M.
No new data blocks are written. The ZFS pool simply adds pointers to the same data blocks, in the same way that it is done with deduplication. The main difference is that block-cloning is triggered by the user “on demand”, while deduplication looks for existing blocks with every new write operation.
1 Like
Because user tools are not aware of deduplicated or cloned blocks, you can end up with a dataset that reports used space that is greater than the total capacity.
That 10GB file you copied is another 10GB file, according to user tools and to the dataset itself.
The pool has a lower-level understanding, as it knows that both 10GB files are compromised of the same data blocks.
You will immediately lose any space savings the moment you modify a file, because most software makes its own temporary copy of the file, rather than to modify it in-place.
This means that if you saved 10GB of space by block-cloning a 10GB high-def movie, but then cropped off 1 minute from the end of the video, you will lose your 10GB savings, even if you save the modified file over itself.