MFV r272804:

Refactor the code and stop restore_object from creating two transactions.

Illumos issue:
    3693 restore_object uses at least two transactions to restore an object

MFC after:	2 weeks

(cherry picked from commit 0dc921b9429b9b35ae5ac9bf3ce2afc06d050053)