git: 773d9d7e40db - stable/13 - ffs_snapblkfree(): add a comment explaining lockmgr invocation

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Mon, 07 Feb 2022 09:50:54 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=773d9d7e40dbd1d37517ba20d983fc7d31f5cc8b

commit 773d9d7e40dbd1d37517ba20d983fc7d31f5cc8b
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-23 00:33:18 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-02-07 09:38:50 +0000

    ffs_snapblkfree(): add a comment explaining lockmgr invocation
    
    (cherry picked from commit 4559700a0a99376640a8913d08bdf0cfb0124d4a)
---
 sys/ufs/ffs/ffs_snapshot.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c
index a0d16d9eccef..cb5c4f5e2481 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -1807,9 +1807,15 @@ retry:
 		VI_UNLOCK(devvp);
 		return (0);
 	}
+
+	/*
+	 * Use LK_SLEEPFAIL because sn might be freed under us while
+	 * both devvp interlock and snaplk are not owned.
+	 */
 	if (lockmgr(&sn->sn_lock, LK_INTERLOCK | LK_EXCLUSIVE | LK_SLEEPFAIL,
 	    VI_MTX(devvp)) != 0)
 		goto retry;
+
 	TAILQ_FOREACH(ip, &sn->sn_head, i_nextsnap) {
 		vp = ITOV(ip);
 		if (DOINGSOFTDEP(vp))