Let defrag calls return success/error/done

In order to be able to defrag stepwise, a caller needs to know whether the end of a database was reached. This change introduces a new API which returns some more info than just true or false.