The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7c1e4aab7934933f0669c2b922976b30ed628a3f

commit 7c1e4aab7934933f0669c2b922976b30ed628a3f
Author:     Konstantin Belousov <[email protected]>
AuthorDate: 2021-08-17 13:47:25 +0000
Commit:     Konstantin Belousov <[email protected]>
CommitDate: 2021-08-27 15:39:45 +0000

    vfs_hash_insert: ensure that predicate is true
    
    After vnode lock, recheck v_hash. When vfs_hash_insert() is used with
    a predicate, recheck it after the selected vnode is locked. Since
    vfs_hash_lock is dropped, vnode could be rehashed during the sleep for
    the vnode lock, which could go unnoticed there.
    
    Reported and tested by: pho
    Reviewed by:    mckusick, rmacklem
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D31464
---
 sys/kern/vfs_hash.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_hash.c b/sys/kern/vfs_hash.c
index e10e9b57e316..c5d67c8b2b33 100644
--- a/sys/kern/vfs_hash.c
+++ b/sys/kern/vfs_hash.c
@@ -93,8 +93,14 @@ vfs_hash_get(const struct mount *mp, u_int hash, int flags, 
struct thread *td,
                        error = vget_finish(vp, flags, vs);
                        if (error == ENOENT && (flags & LK_NOWAIT) == 0)
                                break;
-                       if (error)
+                       if (error != 0)
                                return (error);
+                       if (vp->v_hash != hash ||
+                           (fn != NULL && fn(vp, arg))) {
+                               vput(vp);
+                               /* Restart the bucket walk. */
+                               break;
+                       }
                        *vpp = vp;
                        return (0);
                }
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to