sa_handle_get_from_db can allocate sa_handle_t in two modes: SA_HDL_PRIVATE and SA_HDL_SHARED.
SA_HDL_PRIVATE case is easy -- we just allocate a new handle object with fields set to appropriate values. sa_bonus points to a buffer, but the buffer has no knowledge of the SA handle. In the case of SA_HDL_SHARED we allocate a new handle and associate it with the buffer via dmu_buf_set_user_ie, but only if the buffer does not have a SA already associated with it. In the latter case, sa_handle_get_from_db simply returns the associated handle. So, in this sense the handle gets shared. What concerns me is that there is no corresponding "unsharing" mechanism in sa_handle_destroy. It would destroy the handle regardless of any possible sharing. So I suspect that if any actual sharing would ever occur then there could be a trouble. As far as I could see in the code, no actual sharing ever happens (modulo bugs). So in the end the only actual purpose of SA_HDL_SHARED seems to be debugging via sa_evict -> panic. I would like to ask you if my understanding of that code is correct. Thank you. -- Andriy Gapon
_______________________________________________ developer mailing list [email protected] http://lists.open-zfs.org/mailman/listinfo/developer
