Unfortunately it's not very simple to define a tile as inaccessible and maintain pathfinding efficiency. As far as I know Dwarf Fortress maintains an accessibility map which divides the map into separate accessible regions. Any tile in one region can access any other tile in the same region. Whenever any tile that was accessible becomes blocked or the other way around the game updates this map. So when checking if something is reachable the game just compares the starting tiles region to the ending tile's region if it isn't the same the game already knows there is no path. If it is the same then it runs A* to find the exact path there. Without this the game wouldn't be able to know without testing every accessible tile from the start before it realizes there is not path.
Now after a long winded explanation of that the problem arises in that everything uses the same accessibility map including baddies which is why locking your doors and blocking off any targets break them since they have nothing in their region they can attack so they just act dumb. So to make the idea work the game would have to maintain two accessibility maps one for the dwarves and one for everything else. Since some things like fluids can cause changes to this frequently you effectively double that work frequently. This is also a reason flying stuff can't path as well since to make them work right they'd need another accessibility map to be computed to properly tell where they can and can't go.
The simple solution to this problem is to just have dwarves completely ignore tasks which involve things on outside tiles and to suspend those jobs until they are allowed out and instead take other jobs. That way the dwarves would continue to work on inside jobs or have no job and not dance around at the entrance continually taking tasks that lead them outside and promptly canceling them when they step on an outside tile. This would fix most cases. The only case it wouldn't would be if to get to a tile counted as inside the dwarf would have to pass outside and then they'd go stupid again. But that'd never be an issue for the way I design my forts so good enough for me

!