dsl_dataset_clone_swap's recursive locking prevention is a hack
dsl_dataset_clone_swap tries to prevent recursive locking attempts but use the assumption (fortunately correct) that the current thread is the only owner for writes. The lock order is also sketchy.
Gordon Ross says:
Using RW_WRITE_HELD here could easily mask other bugs. Also, trying for the two locks first in one order, and then in the reverse order is sloppy. Would be better to always take these two locks in order of memory address. (That's a trick used elsewhere in fs code, i.e. in NFS.)