Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Dec 2020 12:51:21 +0100
From:      Harry Schmalzbauer <freebsd@omnilan.de>
To:        Ronald Klop <ronald-lists@klop.ws>, FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: rc.d/zpool runs before ada(4) attaches
Message-ID:  <08815f92-742c-2934-e746-fd04ca9b4e16@omnilan.de>
In-Reply-To: <1439301337.11.1606815206810@localhost>
References:  <b55604d6-5c23-a590-859c-a52f36386d44@omnilan.de> <1439301337.11.1606815206810@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 01.12.2020 um 10:33 schrieb Ronald Klop:
:
:
:
>> One machine fails importing zpool because the correponding vdevs 
>> (ada0-ada2)
>> are not available at the time rc.d/zpool runs.
>>
>>
>> Adhoc  I'm not aware of any rc(8) vs. driver awareness.
>> Is there any?
>>
>> Suggestions how to fix else than 'sleep 1'?
>>
>> Thanks,
>>
>> -harry
>>
>> P.S.: ahci(4) is compiled into kernel, machine is a HPE U48 (Gen 10 
>> plus MicroServer), zfsloader loads root_MFS kernel module
>>
>
>
> There have been some changes to etc/rc.d/zpool in September.
> Do you have the latest version? Compare with:
> https://github.com/freebsd/freebsd/blob/master/libexec/rc/rc.d/zpool
> or
> https://svnweb.freebsd.org/base/head/libexec/rc/rc.d/zpool?revision=365354&view=markup 
>
>
> Otherwise it would be helpful for readers if you could post some logs 
> which indicate what is happening.
> /var/run/dmesg.boot or the output of "dmesg"
> Part of /var/log/messages
> Part of /var/log/console.log if it exists.
>

Thanks, I'm on -current from view days ago.
The problem is that cam(4) is still probing devices, when rc.d/zpool 
runs, since mount_root_from succeeded, because it is a RAM disk, so 
succeeds independent of any real drive/controller probing.
I can imagine of other seldom edgecases hitting the issue too.

So my proposed patch, working for me, looks like this:
Index: libexec/rc/rc.d/zpool
===================================================================
--- libexec/rc/rc.d/zpool       (revision 368202)
+++ libexec/rc/rc.d/zpool       (working copy)
@@ -18,8 +18,16 @@

  zpool_start()
  {
-       local cachefile
+        local cachefile n=0 camlist=`camcontrol devlist -v`

+       # Wait for cam(4) devices attaching, 4 times at max by increasing
+       # 1s each (10s max in total)
+        while [ X"${camlist#*target*lun*probe}" != X"${camlist}" ]; do
+               [ $n -lt 4 ] || break
+               sleep $((n+=1))
+               camlist=`camcontrol devlist -v`
+       done
+
         for cachefile in /etc/zfs/zpool.cache /boot/zfs/zpool.cache; do
                 if [ -r $cachefile ]; then
                         zpool import -c $cachefile -a -N && break

best,
-harry



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?08815f92-742c-2934-e746-fd04ca9b4e16>