The branch main has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=161e9a97363d17caf0b47983b28a37f3f59f9978

commit 161e9a97363d17caf0b47983b28a37f3f59f9978
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2021-07-17 22:56:47 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2021-07-27 16:58:47 +0000

    nullfs: provide custom null_advlock bypass
    
    The advlock VOP takes the vnode unlocked, which makes the normal bypass
    function racy.  Same as null_pgcache_read(), nullfs implementation needs
    to take interlock and reference lower vnode under it.
    
    Reported and tested by: pho
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D31310
---
 sys/fs/nullfs/null_vnops.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c
index 56973530fd95..0d5092f5e33d 100644
--- a/sys/fs/nullfs/null_vnops.c
+++ b/sys/fs/nullfs/null_vnops.c
@@ -980,6 +980,28 @@ null_read_pgcache(struct vop_read_pgcache_args *ap)
        return (error);
 }
 
+static int
+null_advlock(struct vop_advlock_args *ap)
+{
+       struct vnode *lvp, *vp;
+       struct null_node *xp;
+       int error;
+
+       vp = ap->a_vp;
+       VI_LOCK(vp);
+       xp = VTONULL(vp);
+       if (xp == NULL) {
+               VI_UNLOCK(vp);
+               return (EBADF);
+       }
+       lvp = xp->null_lowervp;
+       vref(lvp);
+       VI_UNLOCK(vp);
+       error = VOP_ADVLOCK(lvp, ap->a_id, ap->a_op, ap->a_fl, ap->a_flags);
+       vrele(lvp);
+       return (error);
+}
+
 /*
  * Avoid standard bypass, since lower dvp and vp could be no longer
  * valid after vput().
@@ -1052,6 +1074,7 @@ struct vop_vector null_vnodeops = {
        .vop_bypass =           null_bypass,
        .vop_access =           null_access,
        .vop_accessx =          null_accessx,
+       .vop_advlock =          null_advlock,
        .vop_advlockpurge =     vop_stdadvlockpurge,
        .vop_bmap =             VOP_EOPNOTSUPP,
        .vop_stat =             null_stat,
_______________________________________________
dev-commits-src-main@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"

Reply via email to