There is a race condition in the ZFS parallel mount code which shows up if you 
have zoned datasets with the same mountpoint as those in the global zone. The 
code makes the incorrect assumption that mount points are globally unique. This 
results in mount failures during boot or pool import.

Take the following set of filesystems which have been sorted by mountpoint by 
the existing code - mountpoints followed by the filesystem in brackets. The 
letters at the left are my annotations.

With this set of filesystems, `zfs_foreach_mountpoint()` will create tasks 
_a-h_, task _g_ will create _A-D_ and _D_ will create _s-z_. The problem is 
that, for example, _t_ can run before _B_.

```
a   / (rpool/ROOT/r151024l)
b   / (rpool/ROOT/r151028.pre2)
c   / (rpool/ROOT/r151026.l1tf)
d   /data (data/zone/build/export)
e   /data (data/zone/reci/export)
f   /data (data)
g   /data (data/zone/ns1/export)
 A  /data/sendmail (data/zone/build/export/sendmail)
 B  /data/sendmail (data/sendmail)
 C  /data/sendmail (data/zone/ns1/export/sendmail)
 D  /data/sendmail (data/zone/reci/export/sendmail)
  s /data/sendmail/clientmqueue (data/zone/reci/export/sendmail/clientmqueue)
  t /data/sendmail/clientmqueue (data/sendmail/clientmqueue)
  u /data/sendmail/clientmqueue (data/zone/ns1/export/sendmail/clientmqueue)
  v /data/sendmail/clientmqueue (data/zone/build/export/sendmail/clientmqueue)
  w /data/sendmail/mqueue (data/zone/ns1/export/sendmail/mqueue)
  x /data/sendmail/mqueue (data/zone/build/export/sendmail/mqueue)
  y /data/sendmail/mqueue (data/sendmail/mqueue)
  z /data/sendmail/mqueue (data/zone/reci/export/sendmail/mqueue)
h   /home (data/home)
 Z  /home/af (data/home/af)
```

The fix I've gone for at the moment is to change the sort so that filesystems 
with the `zoned` attribute are sorted to the bottom. In the global zone, that 
results in the expected sorted list of filesystems and has the additional 
benefit that we can stop creating tasks once we see a zoned filesystem in the 
list. In a non-global zone, only the delegated filesystems are seen so the list 
is just traversed as normal.
You can view, comment on, or merge this pull request online at:

  https://github.com/openzfs/openzfs/pull/700

-- Commit Summary --

  * Race in ZFS parallel mount

-- File Changes --

    M usr/src/lib/libzfs/common/libzfs_mount.c (34)

-- Patch Links --

https://github.com/openzfs/openzfs/pull/700.patch
https://github.com/openzfs/openzfs/pull/700.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openzfs/openzfs/pull/700

------------------------------------------
openzfs: openzfs-developer
Permalink: 
https://openzfs.topicbox.com/groups/developer/Tc23e72f4569fbbf8-M53cdab155df6b0ea9e5647e7
Delivery options: https://openzfs.topicbox.com/groups/developer/subscription

Reply via email to