Improve publication of the newly allocated snapdata.
authorkib <kib@FreeBSD.org>
Fri, 21 Jul 2017 18:42:35 +0000 (18:42 +0000)
committerkib <kib@FreeBSD.org>
Fri, 21 Jul 2017 18:42:35 +0000 (18:42 +0000)
commit24abfe4267ad39d5bfd2ba81d38e1de35f40a3a0
treeb9221fcb0226de3c23e2315fd77e810689c08f94
parent404727946649a30d5dafa0b20c9ec994dbd77f6c
Improve publication of the newly allocated snapdata.

For freshly allocated snapdata, Lock sn_lock in advance, so
si_snapdata readers see the locked snapdata and not race.

For existing snapdata, if the thread was put to sleep waiting for
sn_lock, re-read si_snapdata.  This either closes the race or makes
the reliance on LK_DRAIN less important.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
sys/ufs/ffs/ffs_snapshot.c