anchor.diff:  -spec get_xattr(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), xattr:name(), boolean()) ->
       {ok, #xattr{}} | logical_file_manager:error_reply().
   get_xattr(Worker, SessId, FileKey, XattrKey, Inherited) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_xattr(SessId, uuid_to_guid(Worker, FileKey), XattrKey, Inherited),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_xattr(SessId, uuid_to_guid(Worker, FileKey), XattrKey, Inherited)).
   
   -spec set_xattr(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), #xattr{}) ->
       ok | logical_file_manager:error_reply().
   set_xattr(Worker, SessId, FileKey, Xattr) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_xattr(SessId, uuid_to_guid(Worker, FileKey), Xattr),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_xattr(SessId, uuid_to_guid(Worker, FileKey), Xattr)).
   
   -spec remove_xattr(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), xattr:name()) ->
       ok | logical_file_manager:error_reply().
   remove_xattr(Worker, SessId, FileKey, XattrKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:remove_xattr(SessId, uuid_to_guid(Worker, FileKey), XattrKey),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:remove_xattr(SessId, uuid_to_guid(Worker, FileKey), XattrKey)).
   
   -spec list_xattr(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), boolean(), boolean()) ->
       {ok, [xattr:name()]} | logical_file_manager:error_reply().
   list_xattr(Worker, SessId, FileKey, Inherited, ShowInternal) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:list_xattr(SessId, uuid_to_guid(Worker, FileKey), Inherited, ShowInternal),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:list_xattr(SessId, uuid_to_guid(Worker, FileKey), Inherited, ShowInternal)).
   
   -spec get_acl(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path()) ->
       {ok, [lfm_perms:access_control_entity()]} | logical_file_manager:error_reply().
   get_acl(Worker, SessId, FileKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_acl(SessId, uuid_to_guid(Worker, FileKey)),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_acl(SessId, uuid_to_guid(Worker, FileKey))).
   
   -spec set_acl(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), [lfm_perms:access_control_entity()]) ->
       ok | logical_file_manager:error_reply().
   set_acl(Worker, SessId, FileKey, EntityList) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_acl(SessId, uuid_to_guid(Worker, FileKey), EntityList),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_acl(SessId, uuid_to_guid(Worker, FileKey), EntityList)).
   
   -spec get_transfer_encoding(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid()) ->
       {ok, xattr:transfer_encoding()} | logical_file_manager:error_reply().
   get_transfer_encoding(Worker, SessId, FileKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_transfer_encoding(SessId, uuid_to_guid(Worker, FileKey)),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_transfer_encoding(SessId, uuid_to_guid(Worker, FileKey))).
   
   -spec set_transfer_encoding(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid(), xattr:transfer_encoding()) ->
       ok | logical_file_manager:error_reply().
   set_transfer_encoding(Worker, SessId, FileKey, Encoding) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_transfer_encoding(SessId, uuid_to_guid(Worker, FileKey), Encoding),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_transfer_encoding(SessId, uuid_to_guid(Worker, FileKey), Encoding)).
   
   -spec get_cdmi_completion_status(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid()) ->
       {ok, xattr:cdmi_completion_status()} | logical_file_manager:error_reply().
   get_cdmi_completion_status(Worker, SessId, FileKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_cdmi_completion_status(SessId, uuid_to_guid(Worker, FileKey)),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_cdmi_completion_status(SessId, uuid_to_guid(Worker, FileKey))).
   
   -spec set_cdmi_completion_status(node(), session:id(),
       logical_file_manager:file_key() | file_meta:uuid(), xattr:cdmi_completion_status()) ->
       ok | logical_file_manager:error_reply().
   set_cdmi_completion_status(Worker, SessId, FileKey, CompletionStatus) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_cdmi_completion_status(SessId, uuid_to_guid(Worker, FileKey), CompletionStatus),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_cdmi_completion_status(SessId, uuid_to_guid(Worker, FileKey), CompletionStatus)).
   
   -spec get_mimetype(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid()) ->
       {ok, xattr:mimetype()} | logical_file_manager:error_reply().
   get_mimetype(Worker, SessId, FileKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_mimetype(SessId, uuid_to_guid(Worker, FileKey)),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_mimetype(SessId, uuid_to_guid(Worker, FileKey))).
   
   -spec set_mimetype(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid(), xattr:mimetype()) ->
   ok | logical_file_manager:error_reply().
   set_mimetype(Worker, SessId, FileKey, Mimetype) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_mimetype(SessId, uuid_to_guid(Worker, FileKey), Mimetype),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_mimetype(SessId, uuid_to_guid(Worker, FileKey), Mimetype)).
   
   -spec fsync(node(), logical_file_manager:handle()) ->
       ok | logical_file_manager:error_reply().
   fsync(Worker, TestHandle) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
  -            Result = logical_file_manager:fsync(Handle),
  -            Host ! {self(), Result}
  +    ?EXEC(Worker,
  +        begin
  +            [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
  +            logical_file_manager:fsync(Handle)
           end).
   
   -spec rm_recursive(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path()) ->
       ok | logical_file_manager:error_reply().
   rm_recursive(Worker, SessId, FileKey) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:rm_recursive(SessId, uuid_to_guid(Worker, FileKey)),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:rm_recursive(SessId, uuid_to_guid(Worker, FileKey))).
   
   -spec get_metadata(node(), session:id(), logical_file_manager:file_key(),
       custom_metadata:type(), custom_metadata:filter(), boolean()) ->
       {ok, custom_metadata:value()}.
   get_metadata(Worker, SessId, FileKey, Type, Names, Inherited) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:get_metadata(SessId, FileKey, Type, Names, Inherited),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:get_metadata(SessId, FileKey, Type, Names, Inherited)).
   
   -spec set_metadata(node(), session:id(), logical_file_manager:file_key(),
       custom_metadata:type(), custom_metadata:value(), custom_metadata:filter()) ->
       ok.
   set_metadata(Worker, SessId, FileKey, Type, Value, Names) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:set_metadata(SessId, FileKey, Type, Value, Names),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:set_metadata(SessId, FileKey, Type, Value, Names)).
   
   -spec has_custom_metadata(node(), session:id(), logical_file_manager:file_key()) ->
       {ok, boolean()}.
   has_custom_metadata(Worker, SessId, FileKey) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:has_custom_metadata(SessId, FileKey),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:has_custom_metadata(SessId, FileKey)).
   
   -spec remove_metadata(node(), session:id(), logical_file_manager:file_key(),
       custom_metadata:type()) -> ok.
   remove_metadata(Worker, SessId, FileKey, Type) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:remove_metadata(SessId, FileKey, Type),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:remove_metadata(SessId, FileKey, Type)).
   
   -spec check_perms(node(), session:id(), logical_file_manager:file_key(), helpers:open_mode()) ->
       {ok, boolean()} | {error, term()}.
   check_perms(Worker, SessId, FileKey, OpenMode) ->
  -    exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:check_perms(SessId, FileKey, OpenMode),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:check_perms(SessId, FileKey, OpenMode)).
   
   -spec create_share(node(), session:id(), logical_file_manager:file_key(), share_info:name()) ->
       {ok, {share_info:id(), share_info:share_guid()}} | {error, term()}.
   create_share(Worker, SessId, FileKey, Name) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:create_share(SessId, FileKey, Name),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:create_share(SessId, FileKey, Name)).
   
   -spec remove_share(node(), session:id(), share_info:id()) ->
       ok | {error, term()}.
   remove_share(Worker, SessId, FileKey) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:remove_share(SessId, FileKey),
  -            Host ! {self(), Result}
  -        end).
  +    ?EXEC(Worker, logical_file_manager:remove_share(SessId, FileKey)).
   
   -spec remove_share_by_guid(node(), session:id(), share_info:share_guid()) ->
       ok | {error, term()}.
   remove_share_by_guid(Worker, SessId, ShareGuid) ->
  -        exec(Worker,
  -        fun(Host) ->
  -            Result =
  -                logical_file_manager:remove_share_by_guid(SessId, ShareGuid),
  -            Host ! {self(), Result}
  -        end).
  -
  -%todo refactor this module
  +    ?EXEC(Worker, logical_file_manager:remove_share_by_guid(SessId, ShareGuid)).
   
   %%%===================================================================
   %%% Internal functions
  
positive.code: -spec stat(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid()) ->
      {ok, lfm_attrs:file_attributes()} | logical_file_manager:error_reply().
  stat(Worker, SessId, FileKey) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:stat(SessId, uuid_to_guid(Worker, FileKey)),
              Host ! {self(), Result}
          end).
  
  -spec truncate(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid(), non_neg_integer()) ->
      term().
  truncate(Worker, SessId, FileKey, Size) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:truncate(SessId, uuid_to_guid(Worker, FileKey), Size),
              Host ! {self(), Result}
          end).
  
  -spec create(node(), session:id(), file_meta:path(), file_meta:posix_permissions()) ->
      {ok, fslogic_worker:file_guid()} | logical_file_manager:error_reply().
  create(Worker, SessId, FilePath, Mode) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:create(SessId, FilePath, Mode),
              Host ! {self(), Result}
          end).
  
  -spec unlink(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path()) ->
      ok | logical_file_manager:error_reply().
  unlink(Worker, SessId, FileKey) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:unlink(SessId, uuid_to_guid(Worker, FileKey), false),
              Host ! {self(), Result}
          end).
  
  -spec open(node(), session:id(), FileKey :: fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(),
      OpenType :: helpers:open_mode()) ->
      {ok, logical_file_manager:handle()} | logical_file_manager:error_reply().
  open(Worker, SessId, FileKey, OpenMode) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  case logical_file_manager:open(SessId, uuid_to_guid(Worker, FileKey), OpenMode) of
                      {ok, Handle} ->
                          TestHandle = crypto:rand_bytes(10),
                          ets:insert(lfm_handles, {TestHandle, Handle}),
                          {ok, TestHandle};
                      Other -> Other
                  end,
              Host ! {self(), Result}
          end).
  
  -spec close(node(), logical_file_manager:handle()) ->
      ok | logical_file_manager:error_reply().
  close(Worker, TestHandle) ->
      exec(Worker,
          fun(Host) ->
              [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
              logical_file_manager:fsync(Handle),
              logical_file_manager:release(Handle),
              ets:delete(lfm_handles, TestHandle),
              Host ! {self(), ok}
          end).
  
  -spec close_all(node()) -> ok.
  close_all(Worker) ->
      exec(Worker,
          fun(Host) ->
              lists:foreach(fun({_, Handle}) ->
                  logical_file_manager:fsync(Handle),
                  logical_file_manager:release(Handle)
              end, ets:tab2list(lfm_handles)),
              true = ets:delete_all_objects(lfm_handles),
              Host ! {self(), ok}
          end).
  
  -spec read(node(), logical_file_manager:handle(), integer(), integer()) ->
      {ok, binary()} | logical_file_manager:error_reply().
  read(Worker, TestHandle, Offset, Size) ->
      exec(Worker,
          fun(Host) ->
              [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
              Result =
                  case logical_file_manager:read(Handle, Offset, Size) of
                      {ok, NewHandle, Res}  ->
                          ets:insert(lfm_handles, {TestHandle, NewHandle}),
                          {ok, Res};
                      Other -> Other
                  end,
              Host ! {self(), Result}
          end).
  
  -spec write(node(), logical_file_manager:handle(), integer(), binary()) ->
      {ok, integer()} | logical_file_manager:error_reply().
  write(Worker, TestHandle, Offset, Bytes) ->
      exec(Worker,
          fun(Host) ->
              [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
              Result =
                  case logical_file_manager:write(Handle, Offset, Bytes) of
                      {ok, NewHandle, Res}  ->
                          ets:insert(lfm_handles, {TestHandle, NewHandle}),
                          {ok, Res};
                      Other -> Other
                  end,
              Host ! {self(), Result}
          end).
  
  -spec write_and_check(node(), logical_file_manager:handle(), integer(), binary()) ->
      {ok, integer(), StatAns} | logical_file_manager:error_reply() when
      StatAns :: {ok, lfm_attrs:file_attributes()} | logical_file_manager:error_reply().
  write_and_check(Worker, TestHandle, Offset, Bytes) ->
      exec(Worker,
          fun(Host) ->
              [{_, Handle}] = ets:lookup(lfm_handles, TestHandle),
              #lfm_handle{file_guid = GUID,
                  fslogic_ctx = #fslogic_ctx{session_id = SessId}} = Handle,
              Result =
                  case logical_file_manager:write(Handle, Offset, Bytes) of
                      {ok, NewHandle, Res}  ->
                          ets:insert(lfm_handles, {TestHandle, NewHandle}),
                          case logical_file_manager:fsync(NewHandle) of
                              ok ->
                                  {ok, Res, logical_file_manager:stat(SessId, {guid, GUID})};
                              Other2 ->
                                  Other2
                          end;
                      Other -> Other
                  end,
              Host ! {self(), Result}
          end).
  
  -spec mkdir(node(), session:id(), binary()) ->
      {ok, fslogic_worker:file_guid()} | logical_file_manager:error_reply().
  mkdir(Worker, SessId, Path) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:mkdir(SessId, Path),
              Host ! {self(), Result}
          end).
  
  -spec mkdir(node(), session:id(), binary(), file_meta:posix_permissions()) ->
      {ok, DirUUID :: file_meta:uuid()} | logical_file_manager:error_reply().
  mkdir(Worker, SessId, Path, Mode) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:mkdir(SessId, Path, Mode),
              Host ! {self(), Result}
          end).
  
  -spec ls(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), integer(), integer()) ->
      {ok, [{fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), file_meta:name()}]} | logical_file_manager:error_reply().
  ls(Worker, SessId, FileKey, Offset, Limit) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:ls(SessId, uuid_to_guid(Worker, FileKey), Offset, Limit),
              Host ! {self(), Result}
          end).
  
  -spec mv(node(), session:id(), fslogic_worker:file_guid_or_path(), file_meta:path()) ->
      {ok, fslogic_worker:file_guid()} | logical_file_manager:error_reply().
  mv(Worker, SessId, FileKeyFrom, PathTo) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:mv(SessId, FileKeyFrom, PathTo),
              Host ! {self(), Result}
          end).
  
  -spec set_perms(node(), session:id(), logical_file_manager:file_key() | file_meta:uuid(), file_meta:posix_permissions()) ->
      ok | logical_file_manager:error_reply().
  set_perms(Worker, SessId, FileKey, NewPerms) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:set_perms(SessId, uuid_to_guid(Worker, FileKey), NewPerms),
              Host ! {self(), Result}
          end).
  
  -spec update_times(node(), session:id(), logical_file_manager:file_key(),
      file_meta:time(), file_meta:time(), file_meta:time()) ->
      ok | logical_file_manager:error_reply().
  update_times(Worker, SessId, FileKey, ATime, MTime, CTime) ->
      exec(Worker,
          fun(Host) ->
              Result =
                  logical_file_manager:update_times(SessId, FileKey, ATime, MTime, CTime),
              Host ! {self(), Result}
          end).
  
  -spec get_xattr(node(), session:id(), fslogic_worker:file_guid_or_path() | file_meta:uuid_or_path(), xattr:name()) ->
      {ok, #xattr{}} | logical_file_manager:error_reply().
  
negative.code:     set_mimetype/4, fsync/2, rm_recursive/3, get_metadata/6, set_metadata/6,
      has_custom_metadata/3, remove_metadata/4, check_perms/4, create_share/4,
      remove_share/3, remove_share_by_guid/3]).
  
  -define(EXEC(Worker, Function),
      exec(Worker,
          fun(Host) ->
              Result = Function,
              Host ! {self(), Result}
          end)).
  
  %%%===================================================================
  %%% API
  