git: 4559700a0a99 - main - ffs_snapblkfree(): add a comment explaining lockmgr invocation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 31 Jan 2022 02:46:57 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=4559700a0a99376640a8913d08bdf0cfb0124d4a
commit 4559700a0a99376640a8913d08bdf0cfb0124d4a
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2022-01-23 00:33:18 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-31 02:46:21 +0000
ffs_snapblkfree(): add a comment explaining lockmgr invocation
Reviewed by: markj, mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34072
---
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 1257ee8f8f4f..6cda327c8fcd 100644
--- a/sys/ufs/ffs/ffs_snapshot.c
+++ b/sys/ufs/ffs/ffs_snapshot.c
@@ -1800,9 +1800,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))