diff options
author | Mateusz Guzik <[email protected]> | 2021-04-26 21:44:40 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2021-05-10 12:05:49 -0700 |
commit | 1b7d883eaa8951c75aae2c54b8203a9f6d05bd70 (patch) | |
tree | ff152946d60bb4543e4d0c2b4e79bdfe8ebd7b68 /module | |
parent | e5c01296ff71f20d31bc4b5b38b64da16e4d187c (diff) |
FreeBSD: damage control racing .. lookups in face of mkdir/rmdir
External-issue: https://reviews.freebsd.org/D29769
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Mateusz Guzik <[email protected]>
Closes #11926
Diffstat (limited to 'module')
-rw-r--r-- | module/os/freebsd/zfs/zfs_vnops_os.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 8c0449f90..011ac9334 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -781,6 +781,9 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, znode_t *zdp = VTOZ(dvp); znode_t *zp; zfsvfs_t *zfsvfs = zdp->z_zfsvfs; +#if __FreeBSD_version > 1300124 + seqc_t dvp_seqc; +#endif int error = 0; /* @@ -806,6 +809,10 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, ZFS_ENTER(zfsvfs); ZFS_VERIFY_ZP(zdp); +#if __FreeBSD_version > 1300124 + dvp_seqc = vn_seqc_read_notmodify(dvp); +#endif + *vpp = NULL; if (flags & LOOKUP_XATTR) { @@ -975,6 +982,26 @@ zfs_lookup(vnode_t *dvp, const char *nm, vnode_t **vpp, } } +#if __FreeBSD_version > 1300124 + if ((cnp->cn_flags & ISDOTDOT) != 0) { + /* + * FIXME: zfs_lookup_lock relocks vnodes and does nothing to + * handle races. In particular different callers may end up + * with different vnodes and will try to add conflicting + * entries to the namecache. + * + * While finding different result may be acceptable in face + * of concurrent modification, adding conflicting entries + * trips over an assert in the namecache. + * + * Ultimately let an entry through once everything settles. + */ + if (!vn_seqc_consistent(dvp, dvp_seqc)) { + cnp->cn_flags &= ~MAKEENTRY; + } + } +#endif + /* Insert name into cache (as non-existent) if appropriate. */ if (zfsvfs->z_use_namecache && !zfsvfs->z_replay && error == ENOENT && (cnp->cn_flags & MAKEENTRY) != 0) |