anchor.diff:  
   %% @doc Generate a raw file path
   -define(gen_raw_file_path(_FilePath),
  -        lists:append([_FilePath, "_", integer_to_list(leo_date:now())])).
  +lists:append([_FilePath, "_", integer_to_list(leo_date:now())])).
   
   %% @doc Retrieve object-storage info
   -define(get_obj_storage_info(_ObjStorageId),
  -        leo_object_storage_server:get_backend_info(_ObjStorageId, ?SERVER_OBJ_STORAGE)).
  +leo_object_storage_server:get_backend_info(_ObjStorageId, ?SERVER_OBJ_STORAGE)).
   
   
   %% @doc Diagnosis log-related definitions
  --define(DEF_LOG_SUB_DIR,        "log/").
  +-define(DEF_LOG_SUB_DIR, "log/").
   -define(LOG_GROUP_ID_DIAGNOSIS, 'log_diagnosis_grp').
  --define(LOG_ID_DIAGNOSIS,       'log_diagnosis').
  +-define(LOG_ID_DIAGNOSIS, 'log_diagnosis').
   -define(LOG_FILENAME_DIAGNOSIS, "leo_object_storage_").
  --define(DIAGNOSIS_REP_SUFFIX,   ".report").
  +-define(DIAGNOSIS_REP_SUFFIX, ".report").
   
   
   %% @doc Output diagnosis log
   -define(output_diagnosis_log(Metadata),
  -        begin
  -            #?METADATA{offset = _Offset,
  -                       addr_id = _AddrId,
  -                       key = _Key,
  -                       dsize = _Dsize,
  -                       clock = _Clock,
  -                       timestamp = _Timestamp,
  -                       del = _Del
  -                      } = Metadata,
  -            _Path_1 = binary_to_list(_Key),
  -
  -            {_Path_2, _CIndex} =
  -                begin
  -                    _Tokens = string:tokens(_Path_1, "\n"),
  -                    case length(_Tokens) of
  -                        1 ->
  -                            {_Path_1, 0};
  -                        _ ->
  -                            [_ParentPath,_CNum|_] = _Tokens,
  -                            case catch list_to_integer(_CNum) of
  -                                {'EXIT',_} ->
  -                                    {_ParentPath, 0};
  -                                _Num->
  -                                    {_ParentPath, _Num}
  -                            end
  -                    end
  -                end,
  -
  -            leo_logger_client_base:append(
  -              {LoggerId, #message_log{format  = "~w\t~w\t~s\t~w\t~w\t~w\t~s\t~w~n",
  -                                      message = [_Offset,
  -                                                 _AddrId,
  -                                                 _Path_2,
  -                                                 _CIndex,
  -                                                 _Dsize,
  -                                                 _Clock,
  -                                                 leo_date:date_format(_Timestamp),
  -                                                 _Del
  -                                                ]}
  -              })
  -        end).
  +begin
  +#?METADATA{offset = _Offset,
  +addr_id = _AddrId,
  +key = _Key,
  +dsize = _Dsize,
  +clock = _Clock,
  +timestamp = _Timestamp,
  +del = _Del
  +} = Metadata,
  +_Path_1 = binary_to_list(_Key),
  +
  +{_Path_2, _CIndex} =
  +begin
  +_Tokens = string:tokens(_Path_1, "\n"),
  +case length(_Tokens) of
  +1 ->
  +{_Path_1, 0};
  +_ ->
  +[_ParentPath,_CNum|_] = _Tokens,
  +case catch list_to_integer(_CNum) of
  +{'EXIT',_} ->
  +{_ParentPath, 0};
  +_Num->
  +{_ParentPath, _Num}
  +end
  +end
  +end,
  +
  +leo_logger_client_base:append(
  +{LoggerId, #message_log{format  = "~w\t~w\t~s\t~w\t~w\t~w\t~s\t~w~n",
  +message = [_Offset,
  +_AddrId,
  +_Path_2,
  +_CIndex,
  +_Dsize,
  +_Clock,
  +leo_date:date_format(_Timestamp),
  +_Del
  +]}
  +})
  +end).
   
   %% @doc Default value of step of a batch-processing
   -define(DEF_COMPACTION_NUM_OF_STEPS, 10).
   
   %% @doc Compaction-related records:
   -record(compaction_event_info, {
  -          id :: atom(),
  -          event = ?EVENT_RUN :: compaction_event(),
  -          controller_pid :: pid(),
  -          client_pid     :: pid(),
  -          is_diagnosing = false :: boolean(),
  -          is_recovering = false :: boolean(),
  -          is_forced_run = false :: boolean(),
  -          callback :: function()
  -         }).
  +id :: atom(),
  +event = ?EVENT_RUN :: compaction_event(),
  +controller_pid :: pid(),
  +client_pid :: pid(),
  +is_diagnosing = false :: boolean(),
  +is_recovering = false :: boolean(),
  +is_forced_run = false :: boolean(),
  +callback :: function()
  +}).
   
   -record(compaction_prms, {
  -          key_bin  = <<>> :: binary(),
  -          body_bin = <<>> :: binary(),
  -          metadata = #?METADATA{} :: #?METADATA{},
  -          next_offset = 0         :: non_neg_integer()|eof,
  -          start_lock_offset = 0   :: non_neg_integer(),
  -          callback_fun            :: function(),
  -          num_of_active_objs = 0  :: non_neg_integer(),
  -          size_of_active_objs = 0 :: non_neg_integer(),
  -          total_num_of_objs = 0   :: non_neg_integer(),
  -          total_size_of_objs = 0  :: non_neg_integer()
  -         }).
  +key_bin = <<>> :: binary(),
  +body_bin = <<>> :: binary(),
  +metadata = #?METADATA{} :: #?METADATA{},
  +next_offset = 0 :: non_neg_integer()|eof,
  +start_lock_offset = 0 :: non_neg_integer(),
  +callback_fun :: function(),
  +num_of_active_objs = 0  :: non_neg_integer(),
  +size_of_active_objs = 0 :: non_neg_integer(),
  +total_num_of_objs = 0 :: non_neg_integer(),
  +total_size_of_objs = 0 :: non_neg_integer()
  +}).
   
   -record(compaction_skip_garbage, {
  -          buf = <<>> :: binary(),
  -          read_pos = 0 :: non_neg_integer(),
  -          prefetch_size = ?DEF_COMPACTION_SKIP_PS :: pos_integer(),
  -          is_skipping = false :: boolean(),
  -          is_close_eof = false :: boolean()
  -         }).
  +buf = <<>> :: binary(),
  +read_pos = 0 :: non_neg_integer(),
  +prefetch_size = ?DEF_COMPACTION_SKIP_PS :: pos_integer(),
  +is_skipping = false :: boolean(),
  +is_close_eof = false :: boolean()
  +}).
   
   -record(compaction_worker_state, {
  -          id :: atom(),
  -          obj_storage_id :: atom(),
  -          obj_storage_id_read :: atom(),
  -          meta_db_id :: atom(),
  -          obj_storage_info = #backend_info{} :: #backend_info{},
  -          compact_cntl_pid :: pid(),
  +id :: atom(),
  +obj_storage_id :: atom(),
  +obj_storage_id_read :: atom(),
  +meta_db_id :: atom(),
  +obj_storage_info = #backend_info{} :: #backend_info{},
  +compact_cntl_pid :: pid(),
             diagnosis_log_id :: atom(),
             status = ?ST_IDLING :: compaction_state(),
             is_locked = false :: boolean(),
  
positive.code: %% Records
  %%--------------------------------------------------------------------
  -record(backend_info, {
            backend            :: atom(),
            avs_ver_cur = <<>> :: binary(),
            avs_ver_prv = <<>> :: binary(), %% need to know during compaction
            linked_path = []   :: string(),
            file_path   = []   :: string(),
            write_handler      :: pid()|undefined,
            read_handler       :: pid()|undefined
           }).
  
  -record(metadata, { %% - leofs-v1.0.0-pre3
            key = <<>> :: binary(),        %% filename
            addr_id = 0 :: integer(),      %% ring-address id (MD5 > hex-to-integer)
            ksize = 0 :: integer(),        %% file-path size
            dsize = 0 :: integer(),        %% data size
            msize = 0 :: integer(),        %% custom-metadata size
            csize  = 0 :: integer(),       %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),      %% * # of chunked objects (for large-object)
            cindex = 0 :: integer(),       %% * chunked object index (for large-object)
            offset = 0 :: integer(),       %% object-container's offset
            clock = 0 :: integer(),        %% clock
            timestamp = 0 :: integer(),    %% timestamp
            checksum = 0 :: integer(),     %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),    %% RING's Hash(CRC32) when write an object.
            del = ?DEL_FALSE :: del_flag() %% [{0,not_deleted}, {1,deleted}]
           }).
  
  -record(metadata_1, { %% leofs-v1.0.0 - v1.3.0
            key = <<>> :: binary(),           %% filename
            addr_id = 0 :: integer(),         %% ring-address id (MD5 > hex-to-integer)
            ksize = 0 :: integer(),           %% file-path size
            dsize = 0 :: integer(),           %% data size
            msize = 0 :: integer(),           %% custom-metadata size
            csize = 0 :: integer(),           %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),         %% * # of chunked objects (for large-object)
            cindex = 0 :: integer(),          %% * chunked object index (for large-object)
            offset = 0 :: integer(),          %% object-container's offset
            clock = 0 :: integer(),           %% clock
            timestamp = 0 :: integer(),       %% timestamp
            checksum = 0 :: integer(),        %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),       %% RING's Hash(CRC32) when write an object.
            cluster_id :: atom(),             %% [+] cluster-id for the mdc-replication
            num_of_replicas = 0 :: integer(), %% [+] # of replicas for the mdc-replication
            ver = 0 :: integer(),             %% [+] version number
            del = ?DEL_FALSE :: del_flag()    %% [{0,not_deleted}, {1,deleted}]
           }).
  
  -record(metadata_2, { %% leofs-v1.3.1 - v1.3.2.1
            key = <<>> :: binary(),           %% filename
            addr_id = 0 :: integer(),         %% ring-address id (MD5 > hex-to-integer)
            ksize = 0 :: integer(),           %% file-path size
            dsize = 0 :: integer(),           %% data size
            meta = <<>> :: binary(),          %% [+] custom-metadata (user defined metadata)
            msize = 0 :: integer(),           %% custom-metadata size
            csize = 0 :: integer(),           %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),         %% * # of chunked objects (for large-object)
            cindex  = 0 :: integer(),         %% * chunked object index (for large-object)
            offset  = 0 :: integer(),         %% object-container's offset
            clock = 0 :: integer(),           %% clock
            timestamp = 0 :: integer(),       %% timestamp
            checksum = 0 :: integer(),        %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),       %% RING's Hash(CRC32) when write an object.
            cluster_id :: atom(),             %% cluster-id for the mdc-replication
            num_of_replicas = 0 :: integer(), %% # of replicas for the mdc-replication
            ver = 0 :: integer(),             %% version number
            del = ?DEL_FALSE :: del_flag()    %% [{0,not_deleted}, {1,deleted}]
           }).
  
  -record(metadata_3, { %% leofs-v1.3.1 - the latest version
            key = <<>> :: binary(),                   %% filename
            addr_id = 0 :: integer(),                 %% ring-address id (MD5 > hex-to-integer)
            ksize = 0 :: integer(),                   %% file-path size
            dsize = 0 :: integer(),                   %% data size
            meta = <<>> :: binary(),                  %% custom-metadata (user defined metadata)
            msize = 0 :: integer(),                   %% custom-metadata size
            csize = 0 :: integer(),                   %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),                 %% * # of chunked objects (for large-object)
            cindex  = 0 :: integer(),                 %% * chunked object index (for large-object)
            offset  = 0 :: integer(),                 %% object-container's offset
            clock = 0 :: integer(),                   %% clock
            timestamp = 0 :: integer(),               %% timestamp
            checksum = 0 :: integer(),                %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),               %% RING's Hash(CRC32) when write an object.
            cluster_id :: atom(),                     %% cluster-id for the mdc-replication
            num_of_replicas = 0 :: non_neg_integer(), %% [mdcr/bucket] # of replicas for the mdc-replication
                                                      %%              - [0: no effects,
                                                      %%                 1..*: preferred value of the data-replicatino]
                                                      %%                  as well as preferred_r, preferred_w, preferred_d
            preferred_r = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful READ operation
            preferred_w = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful WRITE operation
            preferred_d = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful DELETE operation
            ver = 0 :: integer(),                     %% version number
            del = ?DEL_FALSE :: del_flag()            %% [{0,not_deleted}, {1,deleted}]
           }).
  -define(METADATA, 'metadata_3').
  
  -record(object, { %% - leofs-v1.0.0-pre3
            method,
            key = <<>> :: binary(),        %% filename
            addr_id = 0 :: integer(),      %% ring-address id (MD5 > hex-to-integer)
            data = <<>> :: binary(),       %% file
            meta = <<>> :: binary(),       %% custom-metadata
            ksize = 0 :: integer(),        %% filename size
            dsize = 0 :: integer(),        %% data size
            msize = 0 :: integer(),        %% custom-metadata size
            csize = 0 :: integer(),        %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),      %% * # of chunked objects (for large-object)
            cindex = 0 :: integer(),       %% * chunked object index (for large-object)
            offset = 0 :: integer(),       %% object-container's offset
            clock = 0 :: integer(),        %% clock
            timestamp = 0 :: integer(),    %% timestamp
            checksum = 0 :: integer(),     %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),    %% RING's Hash(CRC32) when write an object.
            req_id = 0 :: integer(),       %% request id
            del = ?DEL_FALSE :: del_flag() %% delete flag
           }).
  
  -record(object_1, { %% leofs-v1.0.0 - v1.3.2.1
            method,
            key = <<>>   :: binary(),         %% filename
            addr_id = 0 :: integer(),         %% ring-address id (MD5 > hex-to-integer)
            data = <<>> :: binary(),          %% file
            meta = <<>> :: binary(),          %% custom-metadata (user defined metadata)
            ksize = 0 :: integer(),           %% filename size
            dsize = 0 :: integer(),           %% data size
            msize = 0 :: integer(),           %% custom-metadata size
            csize = 0 :: integer(),           %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),         %% * # of chunked objects (for large-object)
            cindex = 0 :: integer(),          %% * chunked object index (for large-object)
            offset = 0 :: integer(),          %% object-container's offset
            clock = 0 :: integer(),           %% clock
            timestamp = 0 :: integer(),       %% timestamp
            checksum = 0 :: integer(),        %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),       %% RING's Hash(CRC32) when write an object.
            req_id= 0 :: integer(),           %% request id
            cluster_id :: atom(),             %% [+] cluster-id for the mdc-replication
            num_of_replicas = 0 :: integer(), %% [+] # of replicas for the mdc-replication
            ver = 0 :: integer(),             %% [+] version number
            del = ?DEL_FALSE :: del_flag()    %% delete flag
           }).
  
  -record(object_2, { %% leofs-v1.3.3 - the latest version
            method,
            key = <<>>   :: binary(),         %% filename
            addr_id = 0 :: integer(),         %% ring-address id (MD5 > hex-to-integer)
            data = <<>> :: binary(),          %% file
            meta = <<>> :: binary(),          %% custom-metadata (user defined metadata)
            ksize = 0 :: integer(),           %% filename size
            dsize = 0 :: integer(),           %% data size
            msize = 0 :: integer(),           %% custom-metadata size
            csize = 0 :: integer(),           %% * chunked data size    (for large-object)
            cnumber = 0 :: integer(),         %% * # of chunked objects (for large-object)
            cindex = 0 :: integer(),          %% * chunked object index (for large-object)
            offset = 0 :: integer(),          %% object-container's offset
            clock = 0 :: integer(),           %% clock
            timestamp = 0 :: integer(),       %% timestamp
            checksum = 0 :: integer(),        %% checksum (MD5 > hex-to-integer)
            ring_hash = 0 :: integer(),       %% RING's Hash(CRC32) when write an object.
            req_id= 0 :: integer(),           %% request id
            cluster_id :: atom(),             %% cluster-id for the mdc-replication
            num_of_replicas = 0 :: non_neg_integer(), %% [mdcr/bucket] # of replicas for the mdc-replication
                                                      %%              - [0: no effects,
                                                      %%                 1..*: preferred value of the data-replicatino]
                                                      %%                  as well as preferred_r, preferred_w, preferred_d
            preferred_r = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful READ operation
            preferred_w = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful WRITE operation
            preferred_d = 0 :: non_neg_integer(),     %% [+] [mdcr/bucket] # of replicas needed for a successful DELETE operation
            ver = 0 :: integer(),                     %% version number
            del = ?DEL_FALSE :: del_flag()            %% delete flag
           }).
  -define(OBJECT, 'object_2').
  
  -record(storage_stats, {
            file_path       = [] :: string(),
            total_sizes     = 0  :: non_neg_integer(),
            active_sizes    = 0  :: non_neg_integer(),
            total_num       = 0  :: non_neg_integer(),
            active_num      = 0  :: non_neg_integer(),
            compaction_hist = [] :: [#compaction_hist{}]
           }).
  
  
  -define(DEF_SYNC_INTERVAL, 1000).
  
negative.code: -define(DEF_THRESHOLD_SLOW_PROC, 1000).
  
  -ifdef(TEST).
  -define(DEF_MIN_COMPACTION_WT, 10).  %% 10msec
  -define(DEF_REG_COMPACTION_WT, 100). %% 100msec
  -define(DEF_MAX_COMPACTION_WT, 300). %% 300msec
  -define(DEF_COMPACTION_TIMEOUT, timer:minutes(1)). %% 1min
  -else.
  -define(DEF_MIN_COMPACTION_WT,  300). %% 300msec
  