Bug 259505

Summary: Bug in zfs receive - Mountpoint not changed
Product: Base System Reporter: ERM Consulting <heiko.grethe>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Works As Intended    
Severity: Affects Many People CC: grahamperrin, heiko.grethe, newton.ja.terry
Priority: ---    
Version: 12.2-RELEASE   
Hardware: i386   
OS: Any   

Description ERM Consulting 2021-10-28 14:59:58 UTC
transfering several datasets from one pool to the other only the first mountpoint is set as expected:

Using:
zfs send -R zDataStorage8Backup/datasetShares@auto-20211027-050000 | zfs receive -Fd zDataStorage8

creates correct mountpoint (/zDataStorage8/datasetShares)

zfs list
NAME                                USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                       315M  13.9T   128K  /zDataStorage8
zDataStorage8/datasetShares         311M  13.9T   311M  /zDataStorage8/datasetShares

But the second transfer:
zfs send -R zDataStorage8Backup/datasetVM@auto-20211027-120000 | zfs receive -Fd zDataStorage8

does not change the mountpoint (/zDataStorage8Backup/datasetVM)

zfs list
NAME                                USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                      2.22T  11.7T   128K  /zDataStorage8
zDataStorage8/datasetShares        2.16T  11.7T  2.10T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM            62.0G  11.7T  62.0G  /zDataStorage8Backup/datasetVM
We can change the mountpoint later, but this seems to be a bug.
Comment 1 Newton Terry 2021-10-28 15:28:47 UTC
On a 13.0-RELEASE VM test system I can't reproduce:

# zfs send -R zDataStorage8Backup/datasetShares@01 | zfs receive -Fd zDataStorage8

# zfs list

NAME                                USED   AVAIL    REFER  MOUNTPOINT
zDataStorage8                       876K   831M       96K  /zDataStorage8
zDataStorage8/datasetShares          96K   831M       96K  /zDataStorage8/datasetShares

Second transfer:

# zfs send -R zDataStorage8Backup/datasetVM@01 | zfs receive -Fd zDataStorage8

# zfs list
NAME                                USED   AVAIL    REFER  MOUNTPOINT
zDataStorage8                       876K   831M       96K  /zDataStorage8
zDataStorage8/datasetShares          96K   831M       96K  /zDataStorage8/datasetShares
zDataStorage8/datasetVM              96K   831M       96K  /zDataStorage8/datasetVM
Comment 2 Newton Terry 2021-10-28 15:58:11 UTC
Same on a 12.2-RELEASE-p10 amd64 VM. The mount points are created correctly.

Sorry, saw the RELEASE version after saving comment #1.
Comment 3 ERM Consulting 2021-10-29 07:18:14 UTC
Hmm, we have the wrong behavior very stable on XigmaNAS® 12.2.0.4 - Ornithopter
build on FreeBSD 12.2-RELEASE P7.
Comment 4 Andriy Gapon freebsd_committer freebsd_triage 2021-10-29 07:21:32 UTC
(In reply to ERM Consulting from comment #0)
Please show output of
zfs get mountpoint zDataStorage8Backup/datasetVM zDataStorage8/datasetVM
Comment 5 ERM Consulting 2021-11-01 10:00:20 UTC
(In reply to Andriy Gapon from comment #4)
Sorry, as it is one of our LIVE-systems we have changed the mountpoint manually.

But I can create a further pool and do the same transfer again.
I will setup zDataStorage8Backup2 and start the send-receive again. It will take about 2 days.

If you would like to get other information do not hesitate to ask.
Comment 6 ERM Consulting 2021-11-02 11:49:30 UTC
Here we are:

Original situation (only one pool: zDataStorage8):
storage8: ~# zfs list
NAME                          USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                6.40T  7.51T   139K  /zDataStorage8
zDataStorage8/datasetShares  2.16T  7.51T  2.11T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM      4.24T  7.51T  3.77T  /zDataStorage8/datasetVM

Created second pool zDataStorage8Backup2:
storage8: ~# zfs list
NAME                          USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                6.40T  7.51T   139K  /zDataStorage8
zDataStorage8/datasetShares  2.16T  7.51T  2.11T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM      4.24T  7.51T  3.77T  /zDataStorage8/datasetVM
zDataStorage8Backup2          360K  15.8T    96K  /zDataStorage8Backup2

Creating first Dataset:
zfs send -R zDataStorage8/datasetShares@auto-20211101-050000 | zfs receive -Fd zDataStorage8Backup2

Expected mountpoint for datasetShares:
storage8: ~# zfs list
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                       6.41T  7.50T   139K  /zDataStorage8
zDataStorage8/datasetShares         2.16T  7.50T  2.11T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM             4.25T  7.50T  3.77T  /zDataStorage8/datasetVM
zDataStorage8Backup2                2.15T  13.7T    96K  /zDataStorage8Backup2
zDataStorage8Backup2/datasetShares  2.15T  13.7T  2.09T  /zDataStorage8Backup2/datasetShares

Creating second Dataset:
zfs send -R zDataStorage8/datasetVM@auto-20211101-040000  | zfs receive -Fd zDataStorage8Backup2

Result - wrong mountpoint for datasetVM:
storage8: ~# zfs list
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                       6.43T  7.49T   139K  /zDataStorage8
zDataStorage8/datasetShares         2.16T  7.49T  2.11T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM             4.26T  7.49T  3.77T  /zDataStorage8/datasetVM
zDataStorage8Backup2                6.31T  9.54T    96K  /zDataStorage8Backup2
zDataStorage8Backup2/datasetShares  2.15T  9.54T  2.09T  /zDataStorage8Backup2/datasetShares
zDataStorage8Backup2/datasetVM      4.17T  9.54T  3.71T  /zDataStorage8/datasetVM

Requested command:
storage8: ~# zfs get mountpoint zDataStorage8Backup2/datasetVM zDataStorage8/datasetVM
NAME                            PROPERTY    VALUE                     SOURCE
zDataStorage8/datasetVM         mountpoint  /zDataStorage8/datasetVM  local
zDataStorage8Backup2/datasetVM  mountpoint  /zDataStorage8/datasetVM  received
Comment 7 Andriy Gapon freebsd_committer freebsd_triage 2021-11-02 21:59:37 UTC
(In reply to ERM Consulting from comment #6)
I am not sure if I understand the situation correctly but it seems that zDataStorage8/datasetVM has its mountpoint explicitly set to /zDataStorage8/datasetVM. "Normally" that property would not be manually set, but rather automatically deduced (inherited) from the pool and dataset name.
When the property is explicitly set, like in your case, then it retains its value when the dataset is sent via a replication stream (send -R).  So, the received dataset would use exactly the same value of the property.

But if the property is automatic (default / inherited) then for the received dataset it would be re-derived from the new pool / dataset names.

In practice, try to run this command first:
zfs inherit mountpoint DataStorage8/datasetVM
And then re-do the send | recv test.
Comment 8 ERM Consulting 2021-11-04 09:09:37 UTC
OK, solved!
I was not aware that we can switch of the "inherit mountpoint" functionality.
We used your recommended command on the old dataset:

   zfs inherit mountpoint DataStorage8/datasetVM

Then send->received the dataset to the new pool and now we have the correct mountpoint:

storage8: ~# zfs list
NAME                                 USED  AVAIL  REFER  MOUNTPOINT
zDataStorage8                       6.67T  7.24T   139K  /zDataStorage8
zDataStorage8/datasetShares         2.16T  7.24T  2.11T  /zDataStorage8/datasetShares
zDataStorage8/datasetVM             4.51T  7.24T  3.86T  /zDataStorage8/datasetVM
zDataStorage8Backup2                6.31T  9.54T   104K  /zDataStorage8Backup2
zDataStorage8Backup2/datasetShares  2.15T  9.54T  2.09T  /zDataStorage8Backup2/datasetShares
zDataStorage8Backup2/datasetVM      4.17T  9.54T  3.71T  /zDataStorage8Backup2/datasetVM

Many thanks for your help!
No Bug, lag on knowledge!