Skip to content

Commit

Permalink
Support for ARM requires non-accelerated CRC.
Browse files Browse the repository at this point in the history
  • Loading branch information
szmyd committed Dec 20, 2023
1 parent 0154c9e commit d56a1df
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@ cmake-*/**
# Visual Studio
CMakeSettings.json
.vs/**
.cache
5 changes: 3 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "4.9.3"
version = "4.9.4"

homepage = "https://github.com/eBay/Homestore"
description = "HomeStore Storage Engine"
Expand Down Expand Up @@ -59,7 +59,8 @@ def requirements(self):
self.requires("sisl/[>=10.3]")

self.requires("farmhash/cci.20190513@")
self.requires("isa-l/2.30.0")
if self.settings.arch in ['x86', 'x86_64']:
self.requires("isa-l/2.30.0")
self.requires("spdk/21.07.y")

def build(self):
Expand Down
42 changes: 23 additions & 19 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ cmake_minimum_required(VERSION 3.13)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)

find_package(Threads)
find_library(LIB_AIO aio REQUIRED)
find_package(isa-l REQUIRED)
find_package(iomgr REQUIRED)
find_package(farmhash REQUIRED)
find_package(GTest REQUIRED)

set (COMMON_DEPS
iomgr::iomgr
farmhash::farmhash
isa-l::isa-l
sisl::sisl
)

set(COMMON_TEST_DEPS
${COMMON_DEPS}
${spdk_LIBRARY_LIST}
${dpdk_LIBRARY_LIST}
GTest::gmock
)
find_library(LIB_AIO aio QUIET REQUIRED)
find_package(isa-l QUIET)
find_package(iomgr QUIET REQUIRED)
find_package(farmhash QUIET REQUIRED)
find_package(GTest QUIET REQUIRED)

list(APPEND COMMON_DEPS
iomgr::iomgr
farmhash::farmhash
sisl::sisl
)
if (${isa-l_FOUND})
list(APPEND COMMON_DEPS isa-l::isa-l)
else ()
add_flags("-DNO_ISAL")
endif()

list(APPEND COMMON_TEST_DEPS
${COMMON_DEPS}
${spdk_LIBRARY_LIST}
${dpdk_LIBRARY_LIST}
GTest::gmock
)

include_directories (BEFORE lib/)
include_directories (BEFORE include/)
Expand Down
4 changes: 4 additions & 0 deletions src/include/homestore/btree/detail/btree_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
#include "btree_internal.hpp"
#include <homestore/btree/btree_kv.hpp>
// #include <iomgr/iomgr_flip.hpp>
#ifndef NO_ISAL
#include <isa-l/crc.h>
#else
#include "common/crc.h"
#endif

namespace homestore {
ENUM(locktype_t, uint8_t, NONE, READ, WRITE)
Expand Down
39 changes: 39 additions & 0 deletions src/lib/common/crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#define MAX_ITER 8

extern "C" {
// crc16_t10dif reference function, slow crc16 from the definition.
static inline uint16_t crc16_t10dif(uint16_t seed, const unsigned char* buf, uint64_t len) {
size_t rem = seed;
unsigned int i, j;

uint16_t poly = 0x8bb7; // t10dif standard

for (i = 0; i < len; i++) {
rem = rem ^ (buf[i] << 8);
for (j = 0; j < MAX_ITER; j++) {
rem = rem << 1;
rem = (rem & 0x10000) ? rem ^ poly : rem;
}
}
return rem;
}

// crc32_ieee reference function, slow crc32 from the definition.
static inline uint32_t crc32_ieee(uint32_t seed, const unsigned char* buf, uint64_t len) {
uint64_t rem = ~seed;
unsigned int i, j;

uint32_t poly = 0x04C11DB7; // IEEE standard

for (i = 0; i < len; i++) {
rem = rem ^ ((uint64_t)buf[i] << 24);
for (j = 0; j < MAX_ITER; j++) {
rem = rem << 1;
rem = (rem & 0x100000000ULL) ? rem ^ poly : rem;
}
}
return ~rem;
}
}
4 changes: 4 additions & 0 deletions src/lib/device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
#include <map>
#include <vector>

#ifndef NO_ISAL
#include <isa-l/crc.h>
#else
#include "common/crc.h"
#endif
#include <iomgr/iomgr.hpp>
#include <sisl/fds/sparse_vector.hpp>
#include <homestore/homestore_decl.hpp>
Expand Down
4 changes: 4 additions & 0 deletions src/lib/device/device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
#include <vector>

#include <iomgr/iomgr.hpp>
#ifndef NO_ISAL
#include <isa-l/crc.h>
#else
#include "common/crc.h"
#endif
#include <sisl/logging/logging.h>

#include <boost/uuid/random_generator.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/lib/device/physical_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <iomgr/iomgr.hpp>
#include <iomgr/iomgr_flip.hpp>
#include <sisl/fds/utils.hpp>
#include <isa-l/crc.h>

#include <homestore/homestore_decl.hpp>
#include "device/chunk.h"
Expand Down
4 changes: 4 additions & 0 deletions src/lib/device/physical_dev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@

#include <boost/icl/split_interval_set.hpp>
#include <nlohmann/json.hpp>
#ifndef NO_ISAL
#include <isa-l/crc.h>
#else
#include "common/crc.h"
#endif
#include <sisl/metrics/metrics.hpp>
#include <sisl/logging/logging.h>
#include <homestore/homestore_decl.hpp>
Expand Down
1 change: 0 additions & 1 deletion src/lib/logstore/log_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include <iterator>

#include <sisl/fds/vector_pool.hpp>
#include <isa-l/crc.h>
#include <iomgr/iomgr_flip.hpp>

#include <homestore/logstore_service.hpp>
Expand Down
3 changes: 3 additions & 0 deletions src/lib/logstore/log_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
*********************************************************************************/
#include <cstring>

#ifndef NO_ISAL
#include <isa-l/crc.h>
#else
#endif

#include <homestore/logstore/log_store.hpp>
#include "common/homestore_assert.hpp"
Expand Down
2 changes: 0 additions & 2 deletions src/lib/logstore/log_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* specific language governing permissions and limitations under the License.
*
*********************************************************************************/
#include <isa-l/crc.h>

#include "device/chunk.h"
#include "common/homestore_assert.hpp"
#include "common/homestore_config.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

#include <sisl/fds/compress.hpp>
#include <sisl/fds/utils.hpp>
#include <isa-l/crc.h>
#include <iomgr/iomgr_flip.hpp>

#include <homestore/meta_service.hpp>
Expand Down

0 comments on commit d56a1df

Please sign in to comment.