-#if CONFIG_VFS_FUNNEL
- if (!THREAD_SAFE_FS(fdvp))
- fdvp_unsafe = fdvp;
- if (!THREAD_SAFE_FS(tdvp))
- tdvp_unsafe = tdvp;
-
- if (fdvp_unsafe != NULLVP) {
- /*
- * Lock parents in vnode address order to avoid deadlocks
- * note that it's possible for the fdvp to be unsafe,
- * but the tdvp to be safe because tvp could be a directory
- * in the root of a filesystem... in that case, tdvp is the
- * in the filesystem that this root is mounted on
- */
- if (tdvp_unsafe == NULL || fdvp_unsafe == tdvp_unsafe) {
- lock_first = fdvp_unsafe;
- lock_second = NULL;
- } else if (fdvp_unsafe < tdvp_unsafe) {
- lock_first = fdvp_unsafe;
- lock_second = tdvp_unsafe;
- } else {
- lock_first = tdvp_unsafe;
- lock_second = fdvp_unsafe;
- }
- if ( (_err = lock_fsnode(lock_first, &funnel_state)) )
- return (_err);
-
- if (lock_second != NULL && (_err = lock_fsnode(lock_second, NULL))) {
- unlock_fsnode(lock_first, &funnel_state);
- return (_err);
- }
-
- /*
- * Lock both children in vnode address order to avoid deadlocks
- */
- if (tvp == NULL || tvp == fvp) {
- lock_first = fvp;
- lock_second = NULL;
- } else if (fvp < tvp) {
- lock_first = fvp;
- lock_second = tvp;
- } else {
- lock_first = tvp;
- lock_second = fvp;
- }
- if ( (_err = lock_fsnode(lock_first, NULL)) )
- goto out1;
-
- if (lock_second != NULL && (_err = lock_fsnode(lock_second, NULL))) {
- unlock_fsnode(lock_first, NULL);
- goto out1;
- }
- }
-#endif /* CONFIG_VFS_FUNNEL */
-